From ffe09d8e982e87ebd6be4c6a16e5b3aa2c684f8f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Queru Date: Fri, 30 Apr 2010 13:57:27 -0700 Subject: [PATCH] Delete libcore, now in its own project Change-Id: Id5f98ddaeb626616cbc48112b3166403ae8d5c78 --- libcore/Android.mk | 163 - libcore/AndroidManifest.xml | 34 - libcore/NOTICE | 437 -- libcore/annotation/MODULE_LICENSE_APACHE2 | 0 .../java/java/lang/annotation/Annotation.java | 125 - .../annotation/AnnotationFormatError.java | 66 - .../AnnotationTypeMismatchException.java | 71 - .../java/java/lang/annotation/Documented.java | 30 - .../java/lang/annotation/ElementType.java | 60 - .../IncompleteAnnotationException.java | 70 - .../java/java/lang/annotation/Inherited.java | 30 - .../java/java/lang/annotation/Retention.java | 32 - .../java/lang/annotation/RetentionPolicy.java | 42 - .../java/java/lang/annotation/Target.java | 31 - .../java/java/lang/annotation/package.html | 10 - .../annotation/internal/nls/Messages.java | 146 - .../internal/nls/messages.properties | 19 - .../tests/java/lang/annotation/AllTests.java | 41 - .../annotation/AnnotationFormatErrorTest.java | 80 - .../java/lang/annotation/AnnotationTest.java | 471 -- .../AnnotationTypeMismatchExceptionTest.java | 72 - .../java/lang/annotation/ElementTypeTest.java | 83 - .../IncompleteAnnotationExceptionTest.java | 87 - .../lang/annotation/RetentionPolicyTest.java | 78 - .../java/lang/annotation/TestAnnotation1.java | 25 - .../java/lang/annotation/TestAnnotation2.java | 15 - .../java/lang/annotation/TestAnnotation3.java | 28 - .../lang/annotation/TestAnnotation3b.java | 28 - .../java/lang/annotation/TestAnnotation4.java | 12 - .../tests/java/lang/annotation/TestEnum1.java | 5 - .../java/lang/annotation/TestEnum1b.java | 5 - .../test/java/tests/annotation/AllTests.java | 38 - libcore/archive/MODULE_LICENSE_APACHE2 | 0 .../main/java/java/util/jar/Attributes.java | 515 -- .../main/java/java/util/jar/InitManifest.java | 222 - .../src/main/java/java/util/jar/JarEntry.java | 219 - .../main/java/java/util/jar/JarException.java | 47 - .../src/main/java/java/util/jar/JarFile.java | 497 -- .../java/java/util/jar/JarInputStream.java | 223 - .../java/java/util/jar/JarOutputStream.java | 85 - .../main/java/java/util/jar/JarVerifier.java | 497 -- .../src/main/java/java/util/jar/Manifest.java | 397 - .../src/main/java/java/util/jar/Pack200.java | 334 - .../src/main/java/java/util/jar/package.html | 12 - .../src/main/java/java/util/zip/Adler32.java | 95 - .../src/main/java/java/util/zip/CRC32.java | 92 - .../java/util/zip/CheckedInputStream.java | 130 - .../java/util/zip/CheckedOutputStream.java | 91 - .../src/main/java/java/util/zip/Checksum.java | 58 - .../java/util/zip/DataFormatException.java | 45 - .../src/main/java/java/util/zip/Deflater.java | 507 -- .../java/util/zip/DeflaterOutputStream.java | 195 - .../java/java/util/zip/GZIPInputStream.java | 241 - .../java/java/util/zip/GZIPOutputStream.java | 108 - .../src/main/java/java/util/zip/Inflater.java | 450 -- .../java/util/zip/InflaterInputStream.java | 358 - .../main/java/java/util/zip/ZipConstants.java | 33 - .../src/main/java/java/util/zip/ZipEntry.java | 755 -- .../main/java/java/util/zip/ZipException.java | 51 - .../src/main/java/java/util/zip/ZipFile.java | 426 - .../java/java/util/zip/ZipInputStream.java | 437 -- .../java/java/util/zip/ZipOutputStream.java | 447 -- .../src/main/java/java/util/zip/package.html | 9 - .../archive/internal/nls/Messages.java | 146 - .../archive/internal/nls/messages.properties | 70 - .../org/apache/harmony/archive/util/Util.java | 78 - libcore/archive/src/main/native/hy2sie.h | 114 - libcore/archive/src/main/native/hycomp.h | 1 - libcore/archive/src/main/native/hymutex.h | 44 - libcore/archive/src/main/native/hyport.h | 1 - .../src/main/native/java_util_zip_Adler32.c | 64 - .../src/main/native/java_util_zip_CRC32.c | 61 - .../src/main/native/java_util_zip_Deflater.c | 321 - .../src/main/native/java_util_zip_Inflater.c | 352 - libcore/archive/src/main/native/sieb.c | 40 - libcore/archive/src/main/native/sieb.h | 21 - libcore/archive/src/main/native/sub.mk | 24 - libcore/archive/src/main/native/zip.c | 37 - libcore/archive/src/main/native/zip.h | 70 - libcore/archive/src/main/native/zipalloc.c | 64 - libcore/archive/src/main/native/zipsup.c | 2319 ------ libcore/archive/src/main/native/zipsup.h | 232 - .../apache/harmony/archive/util/UtilTest.java | 87 - .../archive/tests/java/util/jar/AllTests.java | 50 - .../java/util/jar/AttributesNameTest.java | 104 - .../tests/java/util/jar/AttributesTest.java | 541 -- .../tests/java/util/jar/DalvikExecTest.java | 315 - .../tests/java/util/jar/JarEntryTest.java | 299 - .../tests/java/util/jar/JarExceptionTest.java | 64 - .../tests/java/util/jar/JarExecTest.java | 317 - .../tests/java/util/jar/JarFileTest.java | 1102 --- .../java/util/jar/JarInputStreamTest.java | 641 -- .../java/util/jar/JarOutputStreamTest.java | 204 - .../tests/java/util/jar/ManifestTest.java | 596 -- .../java/util/jar/Pack200PackerTest.java | 187 - .../tests/java/util/jar/Pack200Test.java | 110 - .../java/util/jar/Pack200UnpackerTest.java | 236 - .../tests/java/util/jar/ZipExecTest.java | 324 - .../tests/java/util/zip/Adler32Test.java | 224 - .../archive/tests/java/util/zip/AllTests.java | 55 - .../tests/java/util/zip/CRC32Test.java | 242 - .../java/util/zip/CheckedInputStreamTest.java | 192 - .../util/zip/CheckedOutputStreamTest.java | 195 - .../util/zip/DataFormatExceptionTest.java | 53 - .../util/zip/DeflaterOutputStreamTest.java | 462 -- .../tests/java/util/zip/DeflaterTest.java | 1243 --- .../java/util/zip/GZIPInputStreamTest.java | 360 - .../java/util/zip/GZIPOutputStreamTest.java | 241 - .../util/zip/InflaterInputStreamTest.java | 549 -- .../tests/java/util/zip/InflaterTest.java | 1116 --- .../tests/java/util/zip/ZipEntryTest.java | 647 -- .../tests/java/util/zip/ZipExceptionTest.java | 53 - .../tests/java/util/zip/ZipFileTest.java | 608 -- .../java/util/zip/ZipInputStreamTest.java | 443 -- .../java/util/zip/ZipOutputStreamTest.java | 381 - .../src/test/java/tests/archive/AllTests.java | 39 - libcore/auth/MODULE_LICENSE_APACHE2 | 0 .../javax/security/auth/AuthPermission.java | 97 - .../security/auth/DestroyFailedException.java | 44 - .../java/javax/security/auth/Destroyable.java | 43 - .../auth/PrivateCredentialPermission.java | 388 - .../java/javax/security/auth/Subject.java | 782 -- .../security/auth/SubjectDomainCombiner.java | 121 - .../security/auth/callback/Callback.java | 25 - .../auth/callback/CallbackHandler.java | 54 - .../auth/callback/PasswordCallback.java | 124 - .../UnsupportedCallbackException.java | 64 - .../javax/security/auth/callback/package.html | 22 - .../security/auth/login/LoginException.java | 45 - .../javax/security/auth/login/package.html | 20 - .../java/javax/security/auth/package.html | 18 - .../security/auth/x500/X500Principal.java | 236 - .../javax/security/auth/x500/package.html | 18 - .../harmony/auth/internal/nls/Messages.java | 147 - .../auth/internal/nls/messages.properties | 101 - libcore/awt-kernel/MODULE_LICENSE_APACHE2 | 0 .../java/java/awt/font/NumericShaper.java | 885 --- .../java/java/awt/font/TextAttribute.java | 301 - .../beans/IndexedPropertyChangeEvent.java | 66 - .../java/java/beans/PropertyChangeEvent.java | 116 - .../java/beans/PropertyChangeListener.java | 38 - .../beans/PropertyChangeListenerProxy.java | 61 - .../java/beans/PropertyChangeSupport.java | 501 -- .../concurrent/MODULE_LICENSE_PUBLIC_DOMAIN | 0 .../concurrent/AbstractExecutorService.java | 234 - .../util/concurrent/ArrayBlockingQueue.java | 778 -- .../java/util/concurrent/BlockingQueue.java | 344 - .../concurrent/BrokenBarrierException.java | 38 - .../java/java/util/concurrent/Callable.java | 36 - .../concurrent/CancellationException.java | 34 - .../util/concurrent/CompletionService.java | 97 - .../util/concurrent/ConcurrentHashMap.java | 1324 ---- .../concurrent/ConcurrentLinkedQueue.java | 661 -- .../java/util/concurrent/ConcurrentMap.java | 134 - .../util/concurrent/CopyOnWriteArrayList.java | 1317 ---- .../util/concurrent/CopyOnWriteArraySet.java | 364 - .../java/util/concurrent/CountDownLatch.java | 291 - .../java/util/concurrent/CyclicBarrier.java | 454 -- .../java/java/util/concurrent/DelayQueue.java | 515 -- .../java/java/util/concurrent/Delayed.java | 42 - .../java/java/util/concurrent/Exchanger.java | 656 -- .../util/concurrent/ExecutionException.java | 65 - .../java/java/util/concurrent/Executor.java | 112 - .../concurrent/ExecutorCompletionService.java | 169 - .../java/util/concurrent/ExecutorService.java | 341 - .../java/java/util/concurrent/Executors.java | 676 -- .../java/java/util/concurrent/Future.java | 142 - .../java/java/util/concurrent/FutureTask.java | 331 - .../java/util/concurrent/Java6Arrays.java | 77 - .../util/concurrent/LinkedBlockingQueue.java | 809 -- .../concurrent/PriorityBlockingQueue.java | 564 -- .../RejectedExecutionException.java | 62 - .../concurrent/RejectedExecutionHandler.java | 33 - .../concurrent/ScheduledExecutorService.java | 159 - .../java/util/concurrent/ScheduledFuture.java | 19 - .../ScheduledThreadPoolExecutor.java | 1134 --- .../java/java/util/concurrent/Semaphore.java | 681 -- .../util/concurrent/SynchronousQueue.java | 1128 --- .../java/util/concurrent/ThreadFactory.java | 41 - .../util/concurrent/ThreadPoolExecutor.java | 1927 ----- .../java/java/util/concurrent/TimeUnit.java | 299 - .../util/concurrent/TimeoutException.java | 38 - .../util/concurrent/atomic/AtomicBoolean.java | 127 - .../util/concurrent/atomic/AtomicInteger.java | 228 - .../concurrent/atomic/AtomicIntegerArray.java | 248 - .../atomic/AtomicIntegerFieldUpdater.java | 313 - .../util/concurrent/atomic/AtomicLong.java | 253 - .../concurrent/atomic/AtomicLongArray.java | 247 - .../atomic/AtomicLongFieldUpdater.java | 411 - .../atomic/AtomicMarkableReference.java | 163 - .../concurrent/atomic/AtomicReference.java | 118 - .../atomic/AtomicReferenceArray.java | 155 - .../atomic/AtomicReferenceFieldUpdater.java | 269 - .../atomic/AtomicStampedReference.java | 167 - .../util/concurrent/atomic/UnsafeAccess.java | 34 - .../util/concurrent/atomic/package-info.java | 163 - .../locks/AbstractOwnableSynchronizer.java | 56 - .../locks/AbstractQueuedSynchronizer.java | 2305 ------ .../java/util/concurrent/locks/Condition.java | 435 -- .../java/java/util/concurrent/locks/Lock.java | 327 - .../util/concurrent/locks/LockSupport.java | 201 - .../util/concurrent/locks/ReadWriteLock.java | 104 - .../util/concurrent/locks/ReentrantLock.java | 740 -- .../locks/ReentrantReadWriteLock.java | 1415 ---- .../util/concurrent/locks/UnsafeAccess.java | 34 - .../util/concurrent/locks/package-info.java | 44 - .../java/util/concurrent/package-info.java | 229 - .../AbstractExecutorServiceTest.java | 808 -- .../util/concurrent/AbstractQueueTest.java | 187 - .../AbstractQueuedSynchronizerTest.java | 1304 ---- .../concurrent/ArrayBlockingQueueTest.java | 1060 --- .../util/concurrent/AtomicBooleanTest.java | 146 - .../concurrent/AtomicIntegerArrayTest.java | 340 - .../AtomicIntegerFieldUpdaterTest.java | 297 - .../util/concurrent/AtomicIntegerTest.java | 262 - .../util/concurrent/AtomicLongArrayTest.java | 336 - .../AtomicLongFieldUpdaterTest.java | 298 - .../java/util/concurrent/AtomicLongTest.java | 249 - .../AtomicMarkableReferenceTest.java | 160 - .../concurrent/AtomicReferenceArrayTest.java | 203 - .../AtomicReferenceFieldUpdaterTest.java | 189 - .../util/concurrent/AtomicReferenceTest.java | 143 - .../AtomicStampedReferenceTest.java | 160 - .../concurrent/ConcurrentHashMapTest.java | 609 -- .../concurrent/ConcurrentLinkedQueueTest.java | 537 -- .../concurrent/CopyOnWriteArrayListTest.java | 623 -- .../concurrent/CopyOnWriteArraySetTest.java | 296 - .../util/concurrent/CountDownLatchTest.java | 206 - .../util/concurrent/CyclicBarrierTest.java | 626 -- .../java/util/concurrent/DelayQueueTest.java | 1035 --- .../java/util/concurrent/ExchangerTest.java | 234 - .../ExecutorCompletionServiceTest.java | 162 - .../java/util/concurrent/ExecutorsTest.java | 666 -- .../java/util/concurrent/FutureTaskTest.java | 476 -- .../java/util/concurrent/JSR166TestCase.java | 579 -- .../concurrent/LinkedBlockingQueueTest.java | 1063 --- .../java/util/concurrent/LinkedListTest.java | 453 -- .../java/util/concurrent/LockSupportTest.java | 168 - .../concurrent/PriorityBlockingQueueTest.java | 957 --- .../util/concurrent/PriorityQueueTest.java | 515 -- .../util/concurrent/ReentrantLockTest.java | 1164 --- .../ReentrantReadWriteLockTest.java | 1662 ---- .../concurrent/ScheduledExecutorTest.java | 1149 --- .../java/util/concurrent/SemaphoreTest.java | 919 --- .../util/concurrent/SynchronousQueueTest.java | 896 --- .../api/java/util/concurrent/SystemTest.java | 81 - .../java/util/concurrent/ThreadLocalTest.java | 108 - .../concurrent/ThreadPoolExecutorTest.java | 1570 ---- .../api/java/util/concurrent/ThreadTest.java | 77 - .../java/util/concurrent/TimeUnitTest.java | 335 - .../test/java/tests/concurrent/AllTests.java | 41 - libcore/crypto/MODULE_LICENSE_APACHE2 | 0 .../javax/crypto/BadPaddingException.java | 48 - .../src/main/java/javax/crypto/Cipher.java | 1384 ---- .../java/javax/crypto/CipherInputStream.java | 230 - .../java/javax/crypto/CipherOutputStream.java | 167 - .../src/main/java/javax/crypto/CipherSpi.java | 557 -- .../javax/crypto/EncryptedPrivateKeyInfo.java | 551 -- .../java/javax/crypto/ExemptionMechanism.java | 378 - .../crypto/ExemptionMechanismException.java | 48 - .../javax/crypto/ExemptionMechanismSpi.java | 130 - .../crypto/IllegalBlockSizeException.java | 49 - .../main/java/javax/crypto/KeyAgreement.java | 325 - .../java/javax/crypto/KeyAgreementSpi.java | 141 - .../main/java/javax/crypto/KeyGenerator.java | 251 - .../java/javax/crypto/KeyGeneratorSpi.java | 79 - .../src/main/java/javax/crypto/Mac.java | 431 - .../src/main/java/javax/crypto/MacSpi.java | 146 - .../javax/crypto/NoSuchPaddingException.java | 49 - .../main/java/javax/crypto/NullCipher.java | 49 - .../main/java/javax/crypto/SealedObject.java | 292 - .../src/main/java/javax/crypto/SecretKey.java | 41 - .../java/javax/crypto/SecretKeyFactory.java | 231 - .../javax/crypto/SecretKeyFactorySpi.java | 78 - .../javax/crypto/ShortBufferException.java | 54 - .../java/javax/crypto/interfaces/DHKey.java | 34 - .../javax/crypto/interfaces/DHPrivateKey.java | 39 - .../javax/crypto/interfaces/DHPublicKey.java | 38 - .../java/javax/crypto/interfaces/PBEKey.java | 53 - .../java/javax/crypto/interfaces/package.html | 12 - .../src/main/java/javax/crypto/package.html | 19 - .../java/javax/crypto/spec/DESKeySpec.java | 217 - .../java/javax/crypto/spec/DESedeKeySpec.java | 131 - .../javax/crypto/spec/DHGenParameterSpec.java | 63 - .../javax/crypto/spec/DHParameterSpec.java | 92 - .../javax/crypto/spec/DHPrivateKeySpec.java | 77 - .../javax/crypto/spec/DHPublicKeySpec.java | 77 - .../javax/crypto/spec/IvParameterSpec.java | 93 - .../javax/crypto/spec/OAEPParameterSpec.java | 124 - .../java/javax/crypto/spec/PBEKeySpec.java | 198 - .../javax/crypto/spec/PBEParameterSpec.java | 77 - .../main/java/javax/crypto/spec/PSource.java | 108 - .../javax/crypto/spec/RC2ParameterSpec.java | 164 - .../javax/crypto/spec/RC5ParameterSpec.java | 216 - .../java/javax/crypto/spec/SecretKeySpec.java | 184 - .../main/java/javax/crypto/spec/package.html | 17 - .../crypto/internal/NullCipherSpi.java | 175 - .../harmony/crypto/internal/nls/Messages.java | 147 - .../crypto/internal/nls/messages.properties | 87 - .../crypto/tests/javax/crypto/AllTests.java | 65 - .../javax/crypto/BadPaddingExceptionTest.java | 102 - .../javax/crypto/CipherInputStream1Test.java | 329 - .../javax/crypto/CipherInputStreamTest.java | 85 - .../javax/crypto/CipherOutputStream1Test.java | 270 - .../javax/crypto/CipherOutputStreamTest.java | 60 - .../tests/javax/crypto/CipherSpiTest.java | 455 -- .../crypto/tests/javax/crypto/CipherTest.java | 1684 ---- .../crypto/EncryptedPrivateKeyInfoTest.java | 2252 ------ .../ExemptionMechanismExceptionTest.java | 125 - .../crypto/ExemptionMechanismSpiTest.java | 151 - .../javax/crypto/ExemptionMechanismTest.java | 736 -- .../crypto/IllegalBlockSizeExceptionTest.java | 104 - .../javax/crypto/KeyAgreementSpiTest.java | 132 - .../tests/javax/crypto/KeyAgreementTest.java | 975 --- .../javax/crypto/KeyGeneratorSpiTest.java | 104 - .../tests/javax/crypto/KeyGeneratorTest.java | 690 -- .../crypto/tests/javax/crypto/MacSpiTest.java | 281 - .../crypto/tests/javax/crypto/MacTest.java | 1189 --- .../crypto/NoSuchPaddingExceptionTest.java | 104 - .../tests/javax/crypto/NullCipherTest.java | 435 -- .../tests/javax/crypto/SealedObjectTest.java | 340 - .../javax/crypto/SecretKeyFactorySpiTest.java | 80 - .../javax/crypto/SecretKeyFactoryTest.java | 596 -- .../tests/javax/crypto/SecretKeyTest.java | 72 - .../crypto/ShortBufferExceptionTest.java | 102 - .../tests/javax/crypto/func/AllTests.java | 51 - .../javax/crypto/func/CipherAesTest.java | 77 - .../javax/crypto/func/CipherAesWrapTest.java | 45 - .../javax/crypto/func/CipherDESedeTest.java | 71 - .../crypto/func/CipherDESedeWrapTest.java | 45 - .../javax/crypto/func/CipherDesTest.java | 71 - .../javax/crypto/func/CipherPBETest.java | 113 - .../javax/crypto/func/CipherPBEThread.java | 60 - .../javax/crypto/func/CipherRSATest.java | 85 - .../javax/crypto/func/CipherRSAThread.java | 50 - .../crypto/func/CipherSymmetricKeyThread.java | 73 - .../tests/javax/crypto/func/CipherThread.java | 174 - .../javax/crypto/func/CipherWrapThread.java | 47 - .../func/KeyAgreementFunctionalTest.java | 46 - .../javax/crypto/func/KeyAgreementThread.java | 89 - .../func/KeyGeneratorFunctionalTest.java | 96 - .../javax/crypto/func/KeyGeneratorThread.java | 68 - .../javax/crypto/func/MacFunctionalTest.java | 73 - .../tests/javax/crypto/func/MacThread.java | 57 - .../func/SecretKeyFactoryFunctionalTest.java | 59 - .../crypto/func/SecretKeyFactoryThread.java | 39 - .../tests/javax/crypto/func/TestThread.java | 90 - .../javax/crypto/interfaces/AllTests.java | 43 - .../crypto/interfaces/DHPrivateKeyTest.java | 111 - .../crypto/interfaces/DHPublicKeyTest.java | 112 - .../javax/crypto/interfaces/PBEKeyTest.java | 118 - .../javax/crypto/serialization/AllTests.java | 45 - .../BadPaddingExceptionTest.java | 49 - .../ExemptionMechanismExceptionTest.java | 49 - .../IllegalBlockSizeExceptionTest.java | 49 - .../NoSuchPaddingExceptionTest.java | 49 - .../ShortBufferExceptionTest.java | 49 - .../tests/javax/crypto/spec/AllTests.java | 54 - .../javax/crypto/spec/DESKeySpecTest.java | 332 - .../javax/crypto/spec/DESedeKeySpecTest.java | 234 - .../crypto/spec/DHGenParameterSpecTest.java | 92 - .../crypto/spec/DHParameterSpecTest.java | 119 - .../crypto/spec/DHPrivateKeySpecTest.java | 103 - .../crypto/spec/DHPublicKeySpecTest.java | 103 - .../crypto/spec/IvParameterSpecTest.java | 168 - .../crypto/spec/OAEPParameterSpecTest.java | 202 - .../javax/crypto/spec/PBEKeySpecTest.java | 364 - .../crypto/spec/PBEParameterSpecTest.java | 126 - .../tests/javax/crypto/spec/PSourceTest.java | 162 - .../crypto/spec/RC2ParameterSpecTest.java | 262 - .../crypto/spec/RC5ParameterSpecTest.java | 358 - .../javax/crypto/spec/SecretKeySpecTest.java | 323 - .../support/EncryptedPrivateKeyInfoData.java | 1229 --- .../crypto/tests/support/MyCipher.java | 122 - .../support/MyExemptionMechanismSpi.java | 140 - .../tests/support/MyKeyAgreementSpi.java | 86 - .../tests/support/MyKeyGeneratorSpi.java | 64 - .../crypto/tests/support/MyMacSpi.java | 76 - .../tests/support/MySecretKeyFactorySpi.java | 57 - .../BadPaddingExceptionTest.golden.0.ser | Bin 1388 -> 0 bytes .../BadPaddingExceptionTest.golden.1.ser | Bin 1388 -> 0 bytes .../BadPaddingExceptionTest.golden.2.ser | Bin 1473 -> 0 bytes ...emptionMechanismExceptionTest.golden.0.ser | Bin 1412 -> 0 bytes ...emptionMechanismExceptionTest.golden.1.ser | Bin 1412 -> 0 bytes ...emptionMechanismExceptionTest.golden.2.ser | Bin 1497 -> 0 bytes ...IllegalBlockSizeExceptionTest.golden.0.ser | Bin 1406 -> 0 bytes ...IllegalBlockSizeExceptionTest.golden.1.ser | Bin 1406 -> 0 bytes ...IllegalBlockSizeExceptionTest.golden.2.ser | Bin 1491 -> 0 bytes .../NoSuchPaddingExceptionTest.golden.0.ser | Bin 1397 -> 0 bytes .../NoSuchPaddingExceptionTest.golden.1.ser | Bin 1397 -> 0 bytes .../NoSuchPaddingExceptionTest.golden.2.ser | Bin 1482 -> 0 bytes .../ShortBufferExceptionTest.golden.0.ser | Bin 1391 -> 0 bytes .../ShortBufferExceptionTest.golden.1.ser | Bin 1391 -> 0 bytes .../ShortBufferExceptionTest.golden.2.ser | Bin 1476 -> 0 bytes .../src/test/java/tests/crypto/AllTests.java | 43 - .../hyts_des-ede3-cbc.test1.ciphertext | 1 - .../test/resources/hyts_des-ede3-cbc.test1.iv | 1 - .../resources/hyts_des-ede3-cbc.test1.key | 1 - .../hyts_des-ede3-cbc.test1.plaintext | 1 - .../hyts_des-ede3-cbc.test2.ciphertext | Bin 128 -> 0 bytes .../test/resources/hyts_des-ede3-cbc.test2.iv | 1 - .../resources/hyts_des-ede3-cbc.test2.key | 1 - .../hyts_des-ede3-cbc.test2.plaintext | Bin 126 -> 0 bytes .../hyts_des-ede3-cbc.test3.ciphertext | Bin 10008 -> 0 bytes .../test/resources/hyts_des-ede3-cbc.test3.iv | 1 - .../resources/hyts_des-ede3-cbc.test3.key | 1 - .../hyts_des-ede3-cbc.test3.plaintext | Bin 10000 -> 0 bytes libcore/dalvik/MODULE_LICENSE_APACHE2 | 0 .../java/dalvik/annotation/AndroidOnly.java | 39 - .../dalvik/annotation/AnnotationDefault.java | 27 - .../java/dalvik/annotation/BrokenTest.java | 38 - .../dalvik/annotation/EnclosingClass.java | 27 - .../dalvik/annotation/EnclosingMethod.java | 27 - .../dalvik/annotation/HostController.java | 39 - .../java/dalvik/annotation/InnerClass.java | 27 - .../java/dalvik/annotation/KnownFailure.java | 40 - .../java/dalvik/annotation/MemberClasses.java | 27 - .../java/dalvik/annotation/SideEffect.java | 40 - .../java/dalvik/annotation/Signature.java | 27 - .../main/java/dalvik/annotation/TestInfo.java | 63 - .../java/dalvik/annotation/TestLevel.java | 86 - .../java/dalvik/annotation/TestStatus.java | 44 - .../java/dalvik/annotation/TestTarget.java | 58 - .../dalvik/annotation/TestTargetClass.java | 48 - .../java/dalvik/annotation/TestTargetNew.java | 66 - .../java/dalvik/annotation/TestTargets.java | 43 - .../main/java/dalvik/annotation/Throws.java | 27 - .../main/java/dalvik/annotation/Timeout.java | 40 - .../java/dalvik/annotation/ToBeFixed.java | 45 - .../dalvik/annotation/VirtualTestTarget.java | 59 - .../main/java/dalvik/annotation/package.html | 9 - .../main/java/dalvik/bytecode/Opcodes.java | 316 - .../main/java/dalvik/bytecode/package.html | 8 - .../dalvik/system/AllocationLimitError.java | 42 - .../java/dalvik/system/DexClassLoader.java | 370 - .../src/main/java/dalvik/system/DexFile.java | 291 - .../main/java/dalvik/system/NativeStart.java | 40 - .../java/dalvik/system/PathClassLoader.java | 498 -- .../dalvik/system/PotentialDeadlockError.java | 42 - .../java/dalvik/system/SamplingProfiler.java | 346 - .../dalvik/system/StaleDexCacheError.java | 42 - .../dalvik/system/TemporaryDirectory.java | 100 - .../src/main/java/dalvik/system/TouchDex.java | 151 - .../java/dalvik/system/TouchDexLoader.java | 340 - .../src/main/java/dalvik/system/VMDebug.java | 308 - .../main/java/dalvik/system/VMRuntime.java | 189 - .../src/main/java/dalvik/system/VMStack.java | 85 - .../src/main/java/dalvik/system/Zygote.java | 120 - .../src/main/java/dalvik/system/package.html | 8 - .../harmony/dalvik/NativeTestTarget.java | 68 - .../org/apache/harmony/dalvik/ddmc/Chunk.java | 64 - .../harmony/dalvik/ddmc/ChunkHandler.java | 142 - .../apache/harmony/dalvik/ddmc/DdmServer.java | 177 - .../harmony/dalvik/ddmc/DdmVmInternal.java | 84 - .../org/apache/harmony/dalvik/ddmc/README.txt | 1 - .../main/native/dalvik_system_TouchDex.cpp | 278 - ...g_apache_harmony_dalvik_NativeTestTarget.c | 78 - libcore/dalvik/src/main/native/sub.mk | 18 - libcore/dom/src/test/java/README | 10 - .../src/test/java/org/w3c/dom/DOMError.java | 85 - .../java/org/w3c/dom/DOMErrorHandler.java | 34 - .../src/test/java/org/w3c/dom/DOMLocator.java | 62 - .../java/org/w3c/dom/UserDataHandler.java | 65 - .../test/java/org/w3c/dom/events/Event.java | 141 - .../org/w3c/dom/events/EventException.java | 36 - .../org/w3c/dom/events/EventListener.java | 41 - .../java/org/w3c/dom/events/EventTarget.java | 102 - .../BatikTestDocumentBuilderFactory.java | 239 - .../DOM4JTestDocumentBuilderFactory.java | 154 - .../test/java/org/w3c/domts/DOMErrorImpl.java | 68 - .../java/org/w3c/domts/DOMErrorMonitor.java | 66 - .../java/org/w3c/domts/DOMLocatorImpl.java | 84 - .../src/test/java/org/w3c/domts/DOMTest.java | 289 - .../test/java/org/w3c/domts/DOMTestCase.java | 983 --- .../domts/DOMTestDocumentBuilderFactory.java | 192 - .../java/org/w3c/domts/DOMTestFramework.java | 177 - .../domts/DOMTestIncompatibleException.java | 76 - .../java/org/w3c/domts/DOMTestInnerClass.java | 193 - .../org/w3c/domts/DOMTestLoadException.java | 40 - .../test/java/org/w3c/domts/DOMTestSink.java | 27 - .../test/java/org/w3c/domts/DOMTestSuite.java | 62 - .../org/w3c/domts/DocumentBuilderSetting.java | 282 - .../domts/DocumentBuilderSettingStrategy.java | 199 - .../test/java/org/w3c/domts/EventMonitor.java | 68 - .../JAXPDOMTestDocumentBuilderFactory.java | 183 - .../org/w3c/domts/JTidyDOMImplementation.java | 131 - .../domts/JTidyDocumentBuilderFactory.java | 135 - .../org/w3c/domts/JUnitTestCaseAdapter.java | 491 -- .../org/w3c/domts/JUnitTestSuiteAdapter.java | 64 - .../java/org/w3c/domts/JunitTestCases.java | 2189 ------ .../w3c/domts/LSDocumentBuilderFactory.java | 414 - .../java/org/w3c/domts/UserDataMonitor.java | 69 - .../org/w3c/domts/UserDataNotification.java | 88 - .../XalanDOMTestDocumentBuilderFactory.java | 79 - .../XercesHTML2DocumentBuilderFactory.java | 261 - .../XercesHTMLDocumentBuilderFactory.java | 261 - .../org/w3c/domts/level1/core/TestBatik.java | 43 - .../w3c/domts/level1/core/TestCrimson.java | 48 - .../level1/core/TestCrimsonAltConfig.java | 48 - .../org/w3c/domts/level1/core/TestDOM4J.java | 43 - .../w3c/domts/level1/core/TestDefaultLS.java | 51 - .../level1/core/TestDefaultLSAltConfig.java | 51 - .../domts/level1/core/TestDefaultParser.java | 43 - .../core/TestDefaultParserAltConfig.java | 43 - .../w3c/domts/level1/core/TestGNUJAXP.java | 51 - .../level1/core/TestGNUJAXPAltConfig.java | 49 - .../org/w3c/domts/level1/core/TestJTidy.java | 41 - .../org/w3c/domts/level1/core/TestOracle.java | 50 - .../level1/core/TestOracleAltConfig.java | 49 - .../org/w3c/domts/level1/core/TestXerces.java | 49 - .../level1/core/TestXercesAltConfig.java | 48 - .../org/w3c/domts/level1/core/alltests.java | 595 -- .../core/attrcreatedocumentfragment.java | 97 - .../domts/level1/core/attrcreatetextnode.java | 98 - .../level1/core/attrcreatetextnode2.java | 97 - .../domts/level1/core/attrdefaultvalue.java | 104 - .../domts/level1/core/attreffectivevalue.java | 91 - .../level1/core/attrentityreplacement.java | 96 - .../org/w3c/domts/level1/core/attrname.java | 94 - .../level1/core/attrnextsiblingnull.java | 91 - .../level1/core/attrnotspecifiedvalue.java | 101 - .../domts/level1/core/attrparentnodenull.java | 91 - .../level1/core/attrprevioussiblingnull.java | 91 - .../domts/level1/core/attrremovechild1.java | 99 - .../domts/level1/core/attrreplacechild1.java | 101 - .../attrsetvaluenomodificationallowederr.java | 133 - ...ttrsetvaluenomodificationallowederrEE.java | 123 - .../domts/level1/core/attrspecifiedvalue.java | 94 - .../core/attrspecifiedvaluechanged.java | 96 - .../level1/core/attrspecifiedvalueremove.java | 107 - .../level1/core/cdatasectiongetdata.java | 99 - .../level1/core/cdatasectionnormalize.java | 98 - .../level1/core/characterdataappenddata.java | 97 - .../core/characterdataappenddatagetdata.java | 96 - ...ataappenddatanomodificationallowederr.java | 114 - ...aappenddatanomodificationallowederrEE.java | 101 - .../core/characterdatadeletedatabegining.java | 94 - .../core/characterdatadeletedataend.java | 96 - .../characterdatadeletedataexceedslength.java | 98 - ...aracterdatadeletedatagetlengthanddata.java | 104 - .../core/characterdatadeletedatamiddle.java | 96 - ...atadeletedatanomodificationallowederr.java | 114 - ...adeletedatanomodificationallowederrEE.java | 101 - .../level1/core/characterdatagetdata.java | 90 - .../level1/core/characterdatagetlength.java | 92 - ...taindexsizeerrdeletedatacountnegative.java | 107 - ...taindexsizeerrdeletedataoffsetgreater.java | 104 - ...aindexsizeerrdeletedataoffsetnegative.java | 108 - ...taindexsizeerrinsertdataoffsetgreater.java | 103 - ...aindexsizeerrinsertdataoffsetnegative.java | 107 - ...aindexsizeerrreplacedatacountnegative.java | 108 - ...aindexsizeerrreplacedataoffsetgreater.java | 104 - ...indexsizeerrreplacedataoffsetnegative.java | 109 - ...ataindexsizeerrsubstringcountnegative.java | 108 - ...taindexsizeerrsubstringnegativeoffset.java | 108 - ...ataindexsizeerrsubstringoffsetgreater.java | 104 - .../characterdatainsertdatabeginning.java | 94 - .../core/characterdatainsertdataend.java | 96 - .../core/characterdatainsertdatamiddle.java | 96 - ...atainsertdatanomodificationallowederr.java | 114 - ...ainsertdatanomodificationallowederrEE.java | 99 - .../characterdatareplacedatabegining.java | 94 - .../core/characterdatareplacedataend.java | 96 - ...cterdatareplacedataexceedslengthofarg.java | 97 - ...terdatareplacedataexceedslengthofdata.java | 95 - .../core/characterdatareplacedatamiddle.java | 96 - ...tareplacedatanomodificationallowederr.java | 115 - ...replacedatanomodificationallowederrEE.java | 101 - ...erdatasetdatanomodificationallowederr.java | 114 - ...datasetdatanomodificationallowederrEE.java | 99 - .../core/characterdatasetnodevalue.java | 92 - .../characterdatasubstringexceedsvalue.java | 94 - .../core/characterdatasubstringvalue.java | 93 - .../domts/level1/core/commentgetcomment.java | 102 - .../level1/core/documentcreateattribute.java | 94 - .../core/documentcreatecdatasection.java | 93 - .../level1/core/documentcreatecomment.java | 92 - .../core/documentcreatedocumentfragment.java | 96 - .../level1/core/documentcreateelement.java | 93 - .../documentcreateelementcasesensitive.java | 95 - .../documentcreateelementdefaultattr.java | 106 - .../core/documentcreateentityreference.java | 97 - .../documentcreateentityreferenceknown.java | 100 - .../documentcreateprocessinginstruction.java | 100 - .../level1/core/documentcreatetextnode.java | 92 - .../domts/level1/core/documentgetdoctype.java | 98 - .../level1/core/documentgetdoctypenodtd.java | 88 - .../documentgetelementsbytagnamelength.java | 85 - ...cumentgetelementsbytagnametotallength.java | 86 - .../documentgetelementsbytagnamevalue.java | 93 - .../core/documentgetimplementation.java | 86 - .../level1/core/documentgetrootnode.java | 92 - ...alidcharacterexceptioncreateattribute.java | 98 - ...nvalidcharacterexceptioncreateelement.java | 98 - ...invalidcharacterexceptioncreateentref.java | 110 - ...nvalidcharacterexceptioncreateentref1.java | 107 - ...mentinvalidcharacterexceptioncreatepi.java | 110 - ...entinvalidcharacterexceptioncreatepi1.java | 107 - .../level1/core/documenttypegetdoctype.java | 93 - .../level1/core/documenttypegetentities.java | 120 - .../core/documenttypegetentitieslength.java | 93 - .../core/documenttypegetentitiestype.java | 95 - .../level1/core/documenttypegetnotations.java | 102 - .../core/documenttypegetnotationstype.java | 94 - .../domimplementationfeaturenoversion.java | 82 - .../core/domimplementationfeaturenull.java | 90 - .../core/domimplementationfeaturexml.java | 81 - .../level1/core/elementaddnewattribute.java | 91 - .../core/elementassociatedattribute.java | 94 - .../core/elementchangeattributevalue.java | 94 - .../core/elementcreatenewattribute.java | 98 - .../level1/core/elementgetattributenode.java | 91 - .../core/elementgetattributenodenull.java | 90 - .../level1/core/elementgetelementempty.java | 97 - .../core/elementgetelementsbytagname.java | 86 - ...entgetelementsbytagnameaccessnodelist.java | 96 - .../elementgetelementsbytagnamenomatch.java | 84 - ...ementgetelementsbytagnamespecialvalue.java | 106 - .../domts/level1/core/elementgettagname.java | 92 - .../level1/core/elementinuseattributeerr.java | 112 - .../elementinvalidcharacterexception.java | 99 - .../domts/level1/core/elementnormalize.java | 95 - .../domts/level1/core/elementnotfounderr.java | 104 - .../level1/core/elementremoveattribute.java | 100 - .../elementremoveattributeaftercreate.java | 97 - .../core/elementremoveattributenode.java | 92 - ...attributenodenomodificationallowederr.java | 122 - ...tributenodenomodificationallowederrEE.java | 115 - ...moveattributenomodificationallowederr.java | 117 - ...veattributenomodificationallowederrEE.java | 107 - ...entremoveattributerestoredefaultvalue.java | 100 - .../core/elementreplaceattributewithself.java | 89 - .../core/elementreplaceexistingattribute.java | 97 - ...lementreplaceexistingattributegevalue.java | 95 - .../core/elementretrieveallattributes.java | 98 - .../level1/core/elementretrieveattrvalue.java | 88 - .../level1/core/elementretrievetagname.java | 91 - ...attributenodenomodificationallowederr.java | 116 - ...tributenodenomodificationallowederrEE.java | 117 - .../core/elementsetattributenodenull.java | 94 - ...tsetattributenomodificationallowederr.java | 112 - ...etattributenomodificationallowederrEE.java | 107 - .../level1/core/elementwrongdocumenterr.java | 110 - .../level1/core/entitygetentityname.java | 93 - .../domts/level1/core/entitygetpublicid.java | 101 - .../level1/core/entitygetpublicidnull.java | 94 - .../level1/core/hc_attrappendchild1.java | 100 - .../level1/core/hc_attrappendchild2.java | 99 - .../level1/core/hc_attrappendchild3.java | 106 - .../level1/core/hc_attrappendchild4.java | 118 - .../level1/core/hc_attrappendchild5.java | 103 - .../level1/core/hc_attrappendchild6.java | 96 - .../domts/level1/core/hc_attrchildnodes1.java | 95 - .../domts/level1/core/hc_attrchildnodes2.java | 100 - .../domts/level1/core/hc_attrclonenode1.java | 100 - .../core/hc_attrcreatedocumentfragment.java | 105 - .../level1/core/hc_attrcreatetextnode.java | 97 - .../level1/core/hc_attrcreatetextnode2.java | 97 - .../level1/core/hc_attreffectivevalue.java | 90 - .../domts/level1/core/hc_attrfirstchild.java | 96 - .../domts/level1/core/hc_attrgetvalue1.java | 89 - .../domts/level1/core/hc_attrgetvalue2.java | 111 - .../level1/core/hc_attrhaschildnodes.java | 87 - .../level1/core/hc_attrinsertbefore1.java | 106 - .../level1/core/hc_attrinsertbefore2.java | 106 - .../level1/core/hc_attrinsertbefore3.java | 112 - .../level1/core/hc_attrinsertbefore4.java | 112 - .../level1/core/hc_attrinsertbefore5.java | 119 - .../level1/core/hc_attrinsertbefore6.java | 104 - .../level1/core/hc_attrinsertbefore7.java | 126 - .../domts/level1/core/hc_attrlastchild.java | 96 - .../w3c/domts/level1/core/hc_attrname.java | 94 - .../level1/core/hc_attrnextsiblingnull.java | 90 - .../domts/level1/core/hc_attrnormalize.java | 102 - .../level1/core/hc_attrparentnodenull.java | 90 - .../core/hc_attrprevioussiblingnull.java | 90 - .../level1/core/hc_attrremovechild1.java | 99 - .../level1/core/hc_attrremovechild2.java | 98 - .../level1/core/hc_attrreplacechild1.java | 102 - .../level1/core/hc_attrreplacechild2.java | 108 - .../domts/level1/core/hc_attrsetvalue1.java | 100 - .../domts/level1/core/hc_attrsetvalue2.java | 103 - .../level1/core/hc_attrspecifiedvalue.java | 93 - .../core/hc_attrspecifiedvaluechanged.java | 95 - .../core/hc_characterdataappenddata.java | 96 - .../hc_characterdataappenddatagetdata.java | 95 - .../hc_characterdatadeletedatabegining.java | 93 - .../core/hc_characterdatadeletedataend.java | 95 - ..._characterdatadeletedataexceedslength.java | 97 - ...aracterdatadeletedatagetlengthanddata.java | 103 - .../hc_characterdatadeletedatamiddle.java | 95 - .../level1/core/hc_characterdatagetdata.java | 89 - .../core/hc_characterdatagetlength.java | 91 - ...taindexsizeerrdeletedatacountnegative.java | 107 - ...taindexsizeerrdeletedataoffsetgreater.java | 103 - ...aindexsizeerrdeletedataoffsetnegative.java | 107 - ...taindexsizeerrinsertdataoffsetgreater.java | 102 - ...aindexsizeerrinsertdataoffsetnegative.java | 106 - ...aindexsizeerrreplacedatacountnegative.java | 108 - ...aindexsizeerrreplacedataoffsetgreater.java | 103 - ...indexsizeerrreplacedataoffsetnegative.java | 108 - ...ataindexsizeerrsubstringcountnegative.java | 107 - ...taindexsizeerrsubstringnegativeoffset.java | 107 - ...ataindexsizeerrsubstringoffsetgreater.java | 103 - .../hc_characterdatainsertdatabeginning.java | 93 - .../core/hc_characterdatainsertdataend.java | 95 - .../hc_characterdatainsertdatamiddle.java | 95 - .../hc_characterdatareplacedatabegining.java | 93 - .../core/hc_characterdatareplacedataend.java | 95 - ...cterdatareplacedataexceedslengthofarg.java | 96 - ...terdatareplacedataexceedslengthofdata.java | 94 - .../hc_characterdatareplacedatamiddle.java | 95 - .../core/hc_characterdatasetnodevalue.java | 92 - ...hc_characterdatasubstringexceedsvalue.java | 93 - .../core/hc_characterdatasubstringvalue.java | 92 - .../level1/core/hc_commentgetcomment.java | 106 - .../core/hc_documentcreateattribute.java | 93 - .../level1/core/hc_documentcreatecomment.java | 91 - .../hc_documentcreatedocumentfragment.java | 95 - .../level1/core/hc_documentcreateelement.java | 92 - ...hc_documentcreateelementcasesensitive.java | 103 - .../core/hc_documentcreatetextnode.java | 91 - .../level1/core/hc_documentgetdoctype.java | 102 - ...hc_documentgetelementsbytagnamelength.java | 84 - ...cumentgetelementsbytagnametotallength.java | 186 - .../hc_documentgetelementsbytagnamevalue.java | 92 - .../core/hc_documentgetimplementation.java | 93 - .../level1/core/hc_documentgetrootnode.java | 88 - ...alidcharacterexceptioncreateattribute.java | 97 - ...lidcharacterexceptioncreateattribute1.java | 90 - ...nvalidcharacterexceptioncreateelement.java | 97 - ...validcharacterexceptioncreateelement1.java | 90 - .../hc_domimplementationfeaturenoversion.java | 93 - .../core/hc_domimplementationfeaturenull.java | 101 - .../core/hc_domimplementationfeaturexml.java | 92 - .../core/hc_elementaddnewattribute.java | 91 - .../core/hc_elementassociatedattribute.java | 91 - .../core/hc_elementchangeattributevalue.java | 93 - .../core/hc_elementcreatenewattribute.java | 98 - .../core/hc_elementgetattributenode.java | 87 - .../core/hc_elementgetattributenodenull.java | 89 - .../core/hc_elementgetelementempty.java | 97 - .../core/hc_elementgetelementsbytagname.java | 85 - ...entgetelementsbytagnameaccessnodelist.java | 108 - ...hc_elementgetelementsbytagnamenomatch.java | 83 - ...ementgetelementsbytagnamespecialvalue.java | 105 - .../level1/core/hc_elementgettagname.java | 88 - .../core/hc_elementinuseattributeerr.java | 104 - .../hc_elementinvalidcharacterexception.java | 97 - .../hc_elementinvalidcharacterexception1.java | 92 - .../level1/core/hc_elementnormalize.java | 97 - .../level1/core/hc_elementnormalize2.java | 99 - .../level1/core/hc_elementnotfounderr.java | 103 - .../core/hc_elementremoveattribute.java | 87 - .../hc_elementremoveattributeaftercreate.java | 97 - .../core/hc_elementremoveattributenode.java | 92 - .../hc_elementreplaceattributewithself.java | 90 - .../hc_elementreplaceexistingattribute.java | 96 - ...lementreplaceexistingattributegevalue.java | 95 - .../core/hc_elementretrieveallattributes.java | 108 - .../core/hc_elementretrieveattrvalue.java | 87 - .../core/hc_elementretrievetagname.java | 90 - .../core/hc_elementsetattributenodenull.java | 94 - .../core/hc_elementwrongdocumenterr.java | 108 - .../core/hc_entitiesremovenameditem1.java | 101 - .../level1/core/hc_entitiessetnameditem1.java | 109 - .../core/hc_namednodemapchildnoderange.java | 106 - .../core/hc_namednodemapgetnameditem.java | 93 - .../hc_namednodemapinuseattributeerr.java | 109 - .../core/hc_namednodemapnotfounderr.java | 103 - .../core/hc_namednodemapnumberofnodes.java | 92 - .../core/hc_namednodemapremovenameditem.java | 97 - .../core/hc_namednodemapreturnattrnode.java | 97 - .../core/hc_namednodemapreturnfirstitem.java | 114 - .../core/hc_namednodemapreturnlastitem.java | 116 - .../core/hc_namednodemapreturnnull.java | 94 - .../core/hc_namednodemapsetnameditem.java | 103 - ...c_namednodemapsetnameditemreturnvalue.java | 104 - ...hc_namednodemapsetnameditemthatexists.java | 106 - ..._namednodemapsetnameditemwithnewvalue.java | 99 - .../core/hc_namednodemapwrongdocumenterr.java | 111 - .../domts/level1/core/hc_nodeappendchild.java | 94 - .../core/hc_nodeappendchildchildexists.java | 125 - .../core/hc_nodeappendchilddocfragment.java | 125 - .../core/hc_nodeappendchildgetnodename.java | 95 - .../hc_nodeappendchildinvalidnodetype.java | 102 - ...c_nodeappendchildnewchilddiffdocument.java | 107 - .../core/hc_nodeappendchildnodeancestor.java | 104 - .../core/hc_nodeattributenodeattribute.java | 91 - .../level1/core/hc_nodeattributenodename.java | 88 - .../level1/core/hc_nodeattributenodetype.java | 89 - .../core/hc_nodeattributenodevalue.java | 90 - .../domts/level1/core/hc_nodechildnodes.java | 114 - .../core/hc_nodechildnodesappendchild.java | 124 - .../level1/core/hc_nodechildnodesempty.java | 93 - .../core/hc_nodecloneattributescopied.java | 113 - .../core/hc_nodeclonefalsenocopytext.java | 94 - .../core/hc_nodeclonegetparentnull.java | 90 - .../level1/core/hc_nodeclonenodefalse.java | 97 - .../level1/core/hc_nodeclonenodetrue.java | 113 - .../level1/core/hc_nodeclonetruecopytext.java | 93 - .../core/hc_nodecommentnodeattributes.java | 100 - .../level1/core/hc_nodecommentnodename.java | 100 - .../level1/core/hc_nodecommentnodetype.java | 99 - .../level1/core/hc_nodecommentnodevalue.java | 99 - .../core/hc_nodedocumentfragmentnodename.java | 86 - .../core/hc_nodedocumentfragmentnodetype.java | 86 - .../hc_nodedocumentfragmentnodevalue.java | 92 - .../core/hc_nodedocumentnodeattribute.java | 83 - .../level1/core/hc_nodedocumentnodename.java | 83 - .../level1/core/hc_nodedocumentnodetype.java | 82 - .../level1/core/hc_nodedocumentnodevalue.java | 83 - .../core/hc_nodeelementnodeattributes.java | 109 - .../level1/core/hc_nodeelementnodename.java | 90 - .../level1/core/hc_nodeelementnodetype.java | 84 - .../level1/core/hc_nodeelementnodevalue.java | 81 - .../level1/core/hc_nodegetfirstchild.java | 97 - .../level1/core/hc_nodegetfirstchildnull.java | 88 - .../level1/core/hc_nodegetlastchild.java | 89 - .../level1/core/hc_nodegetlastchildnull.java | 88 - .../level1/core/hc_nodegetnextsibling.java | 89 - .../core/hc_nodegetnextsiblingnull.java | 89 - .../level1/core/hc_nodegetownerdocument.java | 93 - .../core/hc_nodegetownerdocumentnull.java | 82 - .../core/hc_nodegetprevioussibling.java | 89 - .../core/hc_nodegetprevioussiblingnull.java | 89 - .../level1/core/hc_nodehaschildnodes.java | 87 - .../core/hc_nodehaschildnodesfalse.java | 90 - .../level1/core/hc_nodeinsertbefore.java | 119 - .../core/hc_nodeinsertbeforedocfragment.java | 112 - .../hc_nodeinsertbeforeinvalidnodetype.java | 108 - ..._nodeinsertbeforenewchilddiffdocument.java | 109 - .../hc_nodeinsertbeforenewchildexists.java | 119 - .../core/hc_nodeinsertbeforenodeancestor.java | 106 - .../core/hc_nodeinsertbeforenodename.java | 98 - ...c_nodeinsertbeforerefchildnonexistent.java | 106 - .../core/hc_nodeinsertbeforerefchildnull.java | 102 - .../core/hc_nodelistindexequalzero.java | 101 - .../core/hc_nodelistindexgetlength.java | 96 - .../hc_nodelistindexgetlengthofemptylist.java | 93 - .../level1/core/hc_nodelistindexnotzero.java | 100 - .../core/hc_nodelistreturnfirstitem.java | 96 - .../core/hc_nodelistreturnlastitem.java | 100 - .../level1/core/hc_nodelisttraverselist.java | 114 - .../domts/level1/core/hc_nodeparentnode.java | 89 - .../level1/core/hc_nodeparentnodenull.java | 86 - .../domts/level1/core/hc_noderemovechild.java | 94 - .../core/hc_noderemovechildgetnodename.java | 99 - .../level1/core/hc_noderemovechildnode.java | 124 - ...hc_noderemovechildoldchildnonexistent.java | 102 - .../level1/core/hc_nodereplacechild.java | 99 - .../hc_nodereplacechildinvalidnodetype.java | 108 - ..._nodereplacechildnewchilddiffdocument.java | 109 - .../hc_nodereplacechildnewchildexists.java | 121 - .../core/hc_nodereplacechildnodeancestor.java | 106 - .../core/hc_nodereplacechildnodename.java | 99 - ...c_nodereplacechildoldchildnonexistent.java | 104 - .../level1/core/hc_nodetextnodeattribute.java | 89 - .../level1/core/hc_nodetextnodename.java | 85 - .../level1/core/hc_nodetextnodetype.java | 89 - .../level1/core/hc_nodetextnodevalue.java | 90 - .../w3c/domts/level1/core/hc_nodevalue01.java | 85 - .../w3c/domts/level1/core/hc_nodevalue02.java | 85 - .../w3c/domts/level1/core/hc_nodevalue03.java | 101 - .../w3c/domts/level1/core/hc_nodevalue04.java | 92 - .../w3c/domts/level1/core/hc_nodevalue05.java | 85 - .../w3c/domts/level1/core/hc_nodevalue06.java | 83 - .../w3c/domts/level1/core/hc_nodevalue07.java | 100 - .../w3c/domts/level1/core/hc_nodevalue08.java | 100 - .../core/hc_notationsremovenameditem1.java | 101 - .../core/hc_notationssetnameditem1.java | 109 - .../hc_textindexsizeerrnegativeoffset.java | 107 - .../hc_textindexsizeerroffsetoutofbounds.java | 103 - .../core/hc_textparseintolistofelements.java | 125 - .../level1/core/hc_textsplittextfour.java | 94 - .../level1/core/hc_textsplittextone.java | 97 - .../level1/core/hc_textsplittextthree.java | 96 - .../level1/core/hc_textsplittexttwo.java | 95 - .../level1/core/hc_textwithnomarkup.java | 94 - .../core/namednodemapchildnoderange.java | 95 - .../level1/core/namednodemapgetnameditem.java | 95 - .../core/namednodemapinuseattributeerr.java | 110 - .../level1/core/namednodemapnotfounderr.java | 103 - .../core/namednodemapnumberofnodes.java | 92 - .../core/namednodemapremovenameditem.java | 107 - .../namednodemapremovenameditemgetvalue.java | 109 - ...nodemapremovenameditemreturnnodevalue.java | 96 - .../core/namednodemapreturnattrnode.java | 100 - .../core/namednodemapreturnfirstitem.java | 97 - .../core/namednodemapreturnlastitem.java | 97 - .../level1/core/namednodemapreturnnull.java | 93 - .../level1/core/namednodemapsetnameditem.java | 105 - .../namednodemapsetnameditemreturnvalue.java | 104 - .../namednodemapsetnameditemthatexists.java | 107 - .../namednodemapsetnameditemwithnewvalue.java | 99 - .../core/namednodemapwrongdocumenterr.java | 111 - .../domts/level1/core/nodeappendchild.java | 98 - .../core/nodeappendchildchildexists.java | 110 - .../core/nodeappendchilddocfragment.java | 121 - .../core/nodeappendchildgetnodename.java | 95 - .../core/nodeappendchildinvalidnodetype.java | 103 - .../nodeappendchildnewchilddiffdocument.java | 108 - .../core/nodeappendchildnodeancestor.java | 104 - ...deappendchildnomodificationallowederr.java | 116 - ...appendchildnomodificationallowederrEE.java | 100 - .../core/nodeattributenodeattribute.java | 92 - .../level1/core/nodeattributenodename.java | 91 - .../level1/core/nodeattributenodetype.java | 90 - .../level1/core/nodeattributenodevalue.java | 91 - .../core/nodecdatasectionnodeattribute.java | 97 - .../level1/core/nodecdatasectionnodename.java | 98 - .../level1/core/nodecdatasectionnodetype.java | 102 - .../core/nodecdatasectionnodevalue.java | 105 - .../w3c/domts/level1/core/nodechildnodes.java | 105 - .../core/nodechildnodesappendchild.java | 93 - .../level1/core/nodechildnodesempty.java | 95 - .../core/nodecloneattributescopied.java | 105 - .../level1/core/nodeclonefalsenocopytext.java | 95 - .../level1/core/nodeclonegetparentnull.java | 91 - .../domts/level1/core/nodeclonenodefalse.java | 98 - .../domts/level1/core/nodeclonenodetrue.java | 135 - .../level1/core/nodeclonetruecopytext.java | 91 - .../core/nodecommentnodeattributes.java | 100 - .../level1/core/nodecommentnodename.java | 96 - .../level1/core/nodecommentnodetype.java | 96 - .../level1/core/nodecommentnodevalue.java | 96 - .../core/nodedocumentfragmentnodename.java | 87 - .../core/nodedocumentfragmentnodetype.java | 87 - .../core/nodedocumentfragmentnodevalue.java | 93 - .../core/nodedocumentnodeattribute.java | 81 - .../level1/core/nodedocumentnodename.java | 84 - .../level1/core/nodedocumentnodetype.java | 83 - .../level1/core/nodedocumentnodevalue.java | 84 - .../level1/core/nodedocumenttypenodename.java | 90 - .../level1/core/nodedocumenttypenodetype.java | 83 - .../core/nodedocumenttypenodevalue.java | 82 - .../core/nodeelementnodeattributes.java | 103 - .../level1/core/nodeelementnodename.java | 94 - .../level1/core/nodeelementnodetype.java | 85 - .../level1/core/nodeelementnodevalue.java | 82 - .../level1/core/nodeentitynodeattributes.java | 89 - .../domts/level1/core/nodeentitynodename.java | 88 - .../domts/level1/core/nodeentitynodetype.java | 89 - .../level1/core/nodeentitynodevalue.java | 89 - .../nodeentityreferencenodeattributes.java | 93 - .../core/nodeentityreferencenodename.java | 98 - .../core/nodeentityreferencenodetype.java | 96 - .../core/nodeentityreferencenodevalue.java | 98 - .../level1/core/nodeentitysetnodevalue.java | 90 - .../domts/level1/core/nodegetfirstchild.java | 91 - .../level1/core/nodegetfirstchildnull.java | 94 - .../domts/level1/core/nodegetlastchild.java | 91 - .../level1/core/nodegetlastchildnull.java | 94 - .../domts/level1/core/nodegetnextsibling.java | 91 - .../level1/core/nodegetnextsiblingnull.java | 90 - .../level1/core/nodegetownerdocument.java | 100 - .../level1/core/nodegetownerdocumentnull.java | 80 - .../level1/core/nodegetprevioussibling.java | 91 - .../core/nodegetprevioussiblingnull.java | 90 - .../domts/level1/core/nodehaschildnodes.java | 88 - .../level1/core/nodehaschildnodesfalse.java | 95 - .../domts/level1/core/nodeinsertbefore.java | 140 - .../core/nodeinsertbeforedocfragment.java | 112 - .../core/nodeinsertbeforeinvalidnodetype.java | 107 - .../nodeinsertbeforenewchilddiffdocument.java | 109 - .../core/nodeinsertbeforenewchildexists.java | 142 - .../core/nodeinsertbeforenodeancestor.java | 108 - .../level1/core/nodeinsertbeforenodename.java | 98 - ...einsertbeforenomodificationallowederr.java | 118 - ...nsertbeforenomodificationallowederrEE.java | 102 - .../nodeinsertbeforerefchildnonexistent.java | 106 - .../core/nodeinsertbeforerefchildnull.java | 102 - .../level1/core/nodelistindexequalzero.java | 92 - .../level1/core/nodelistindexgetlength.java | 89 - .../nodelistindexgetlengthofemptylist.java | 95 - .../level1/core/nodelistindexnotzero.java | 100 - .../level1/core/nodelistreturnfirstitem.java | 96 - .../level1/core/nodelistreturnlastitem.java | 98 - .../level1/core/nodelisttraverselist.java | 128 - .../core/nodenotationnodeattributes.java | 92 - .../level1/core/nodenotationnodename.java | 93 - .../level1/core/nodenotationnodetype.java | 92 - .../level1/core/nodenotationnodevalue.java | 93 - .../w3c/domts/level1/core/nodeparentnode.java | 97 - .../domts/level1/core/nodeparentnodenull.java | 86 - ...deprocessinginstructionnodeattributes.java | 87 - .../nodeprocessinginstructionnodename.java | 88 - .../nodeprocessinginstructionnodetype.java | 88 - .../nodeprocessinginstructionnodevalue.java | 89 - ...nodeprocessinginstructionsetnodevalue.java | 89 - .../domts/level1/core/noderemovechild.java | 94 - .../core/noderemovechildgetnodename.java | 101 - .../level1/core/noderemovechildnode.java | 107 - ...deremovechildnomodificationallowederr.java | 114 - ...removechildnomodificationallowederrEE.java | 101 - .../noderemovechildoldchildnonexistent.java | 103 - .../domts/level1/core/nodereplacechild.java | 99 - .../core/nodereplacechildinvalidnodetype.java | 107 - .../nodereplacechildnewchilddiffdocument.java | 109 - .../core/nodereplacechildnewchildexists.java | 139 - .../core/nodereplacechildnodeancestor.java | 108 - .../level1/core/nodereplacechildnodename.java | 104 - ...ereplacechildnomodificationallowederr.java | 115 - ...eplacechildnomodificationallowederrEE.java | 102 - .../nodereplacechildoldchildnonexistent.java | 105 - ...esetnodevaluenomodificationallowederr.java | 117 - ...etnodevaluenomodificationallowederrEE.java | 96 - .../level1/core/nodetextnodeattribute.java | 90 - .../domts/level1/core/nodetextnodename.java | 91 - .../domts/level1/core/nodetextnodetype.java | 90 - .../domts/level1/core/nodetextnodevalue.java | 91 - .../w3c/domts/level1/core/nodevalue01.java | 85 - .../w3c/domts/level1/core/nodevalue02.java | 85 - .../w3c/domts/level1/core/nodevalue03.java | 86 - .../w3c/domts/level1/core/nodevalue04.java | 86 - .../w3c/domts/level1/core/nodevalue05.java | 85 - .../w3c/domts/level1/core/nodevalue06.java | 83 - .../w3c/domts/level1/core/nodevalue07.java | 92 - .../w3c/domts/level1/core/nodevalue08.java | 92 - .../w3c/domts/level1/core/nodevalue09.java | 85 - .../level1/core/notationgetnotationname.java | 90 - .../level1/core/notationgetpublicid.java | 89 - .../level1/core/notationgetpublicidnull.java | 94 - .../level1/core/notationgetsystemid.java | 94 - .../level1/core/notationgetsystemidnull.java | 90 - .../core/processinginstructiongetdata.java | 92 - .../core/processinginstructiongettarget.java | 91 - ...uctionsetdatanomodificationallowederr.java | 112 - ...tionsetdatanomodificationallowederrEE.java | 110 - .../core/textindexsizeerrnegativeoffset.java | 108 - .../textindexsizeerroffsetoutofbounds.java | 104 - .../core/textparseintolistofelements.java | 126 - .../domts/level1/core/textsplittextfour.java | 95 - ...textsplittextnomodificationallowederr.java | 117 - ...xtsplittextnomodificationallowederrEE.java | 97 - .../domts/level1/core/textsplittextone.java | 98 - .../domts/level1/core/textsplittextthree.java | 97 - .../domts/level1/core/textsplittexttwo.java | 96 - .../domts/level1/core/textwithnomarkup.java | 95 - .../w3c/domts/level1/html/TestDefaultLS.java | 51 - .../level1/html/TestDefaultLSAltConfig.java | 51 - .../w3c/domts/level1/html/TestXercesHTML.java | 43 - .../org/w3c/domts/level2/core/TestBatik.java | 43 - .../w3c/domts/level2/core/TestCrimson.java | 48 - .../level2/core/TestCrimsonAltConfig.java | 48 - .../org/w3c/domts/level2/core/TestDOM4J.java | 43 - .../w3c/domts/level2/core/TestDefaultLS.java | 50 - .../level2/core/TestDefaultLSAltConfig.java | 51 - .../domts/level2/core/TestDefaultParser.java | 53 - .../core/TestDefaultParserAltConfig.java | 56 - .../w3c/domts/level2/core/TestGNUJAXP.java | 51 - .../level2/core/TestGNUJAXPAltConfig.java | 49 - .../org/w3c/domts/level2/core/TestJTidy.java | 41 - .../org/w3c/domts/level2/core/TestOracle.java | 63 - .../level2/core/TestOracleAltConfig.java | 62 - .../org/w3c/domts/level2/core/TestXerces.java | 49 - .../level2/core/TestXercesAltConfig.java | 48 - .../org/w3c/domts/level2/core/alltests.java | 350 - .../level2/core/attrgetownerelement01.java | 106 - .../level2/core/attrgetownerelement02.java | 100 - .../level2/core/attrgetownerelement03.java | 101 - .../level2/core/attrgetownerelement04.java | 102 - .../level2/core/attrgetownerelement05.java | 109 - .../level2/core/createAttributeNS01.java | 101 - .../level2/core/createAttributeNS02.java | 101 - .../level2/core/createAttributeNS03.java | 132 - .../level2/core/createAttributeNS04.java | 103 - .../level2/core/createAttributeNS05.java | 92 - .../level2/core/createAttributeNS06.java | 93 - .../domts/level2/core/createDocument01.java | 107 - .../domts/level2/core/createDocument02.java | 105 - .../domts/level2/core/createDocument03.java | 104 - .../domts/level2/core/createDocument04.java | 107 - .../domts/level2/core/createDocument05.java | 137 - .../domts/level2/core/createDocument06.java | 108 - .../domts/level2/core/createDocument07.java | 101 - .../domts/level2/core/createDocument08.java | 92 - .../level2/core/createDocumentType01.java | 105 - .../level2/core/createDocumentType02.java | 136 - .../level2/core/createDocumentType03.java | 100 - .../level2/core/createDocumentType04.java | 93 - .../domts/level2/core/createElementNS01.java | 101 - .../domts/level2/core/createElementNS02.java | 101 - .../domts/level2/core/createElementNS03.java | 134 - .../domts/level2/core/createElementNS04.java | 103 - .../domts/level2/core/createElementNS05.java | 92 - .../domts/level2/core/createElementNS06.java | 95 - .../core/documentcreateattributeNS01.java | 95 - .../core/documentcreateattributeNS02.java | 111 - .../core/documentcreateattributeNS03.java | 125 - .../core/documentcreateattributeNS04.java | 120 - .../core/documentcreateattributeNS05.java | 104 - .../core/documentcreateattributeNS06.java | 104 - .../core/documentcreateattributeNS07.java | 111 - .../core/documentcreateelementNS01.java | 115 - .../core/documentcreateelementNS02.java | 110 - .../core/documentcreateelementNS05.java | 111 - .../core/documentcreateelementNS06.java | 105 - .../level2/core/documentgetelementbyid01.java | 101 - .../documentgetelementsbytagnameNS01.java | 97 - .../documentgetelementsbytagnameNS02.java | 103 - .../documentgetelementsbytagnameNS03.java | 88 - .../documentgetelementsbytagnameNS04.java | 97 - .../documentgetelementsbytagnameNS05.java | 90 - .../level2/core/documentimportnode01.java | 111 - .../level2/core/documentimportnode02.java | 117 - .../level2/core/documentimportnode03.java | 113 - .../level2/core/documentimportnode04.java | 119 - .../level2/core/documentimportnode05.java | 113 - .../level2/core/documentimportnode06.java | 102 - .../level2/core/documentimportnode07.java | 105 - .../level2/core/documentimportnode08.java | 109 - .../level2/core/documentimportnode09.java | 106 - .../level2/core/documentimportnode10.java | 106 - .../level2/core/documentimportnode11.java | 105 - .../level2/core/documentimportnode12.java | 108 - .../level2/core/documentimportnode13.java | 104 - .../level2/core/documentimportnode14.java | 111 - .../level2/core/documentimportnode15.java | 103 - .../level2/core/documentimportnode17.java | 103 - .../level2/core/documentimportnode18.java | 106 - .../level2/core/documentimportnode19.java | 136 - .../level2/core/documentimportnode20.java | 134 - .../level2/core/documentimportnode21.java | 144 - .../level2/core/documentimportnode22.java | 144 - .../core/documenttypeinternalSubset01.java | 92 - .../level2/core/documenttypepublicid01.java | 92 - .../level2/core/documenttypesystemid01.java | 92 - .../domimplementationcreatedocument03.java | 127 - .../domimplementationcreatedocument04.java | 116 - .../domimplementationcreatedocument05.java | 115 - .../domimplementationcreatedocument07.java | 112 - ...domimplementationcreatedocumenttype01.java | 109 - ...domimplementationcreatedocumenttype02.java | 127 - ...domimplementationcreatedocumenttype04.java | 131 - .../core/domimplementationfeaturecore.java | 106 - .../domimplementationfeaturexmlversion2.java | 106 - .../core/domimplementationhasfeature01.java | 116 - .../core/domimplementationhasfeature02.java | 88 - .../core/elementgetattributenodens01.java | 115 - .../core/elementgetattributenodens02.java | 98 - .../core/elementgetattributenodens03.java | 101 - .../level2/core/elementgetattributens02.java | 99 - .../core/elementgetelementsbytagnamens02.java | 108 - .../core/elementgetelementsbytagnamens04.java | 112 - .../core/elementgetelementsbytagnamens05.java | 109 - .../level2/core/elementhasattribute01.java | 106 - .../level2/core/elementhasattribute02.java | 97 - .../level2/core/elementhasattribute03.java | 95 - .../level2/core/elementhasattribute04.java | 92 - .../level2/core/elementhasattributens01.java | 98 - .../level2/core/elementhasattributens02.java | 101 - .../level2/core/elementhasattributens03.java | 106 - .../core/elementremoveattributens01.java | 100 - .../core/elementsetattributenodens01.java | 117 - .../core/elementsetattributenodens02.java | 110 - .../core/elementsetattributenodens03.java | 113 - .../core/elementsetattributenodens04.java | 109 - .../core/elementsetattributenodens05.java | 109 - .../core/elementsetattributenodens06.java | 114 - .../level2/core/elementsetattributens01.java | 100 - .../level2/core/elementsetattributens02.java | 103 - .../level2/core/elementsetattributens03.java | 106 - .../level2/core/elementsetattributens04.java | 111 - .../level2/core/elementsetattributens05.java | 98 - .../level2/core/elementsetattributens08.java | 109 - .../core/elementsetattributensurinull.java | 116 - .../domts/level2/core/getAttributeNS01.java | 102 - .../domts/level2/core/getAttributeNS02.java | 103 - .../domts/level2/core/getAttributeNS03.java | 96 - .../domts/level2/core/getAttributeNS04.java | 101 - .../domts/level2/core/getAttributeNS05.java | 99 - .../level2/core/getAttributeNodeNS01.java | 96 - .../level2/core/getAttributeNodeNS02.java | 101 - .../domts/level2/core/getElementById01.java | 96 - .../domts/level2/core/getElementById02.java | 88 - .../level2/core/getElementsByTagNameNS01.java | 90 - .../level2/core/getElementsByTagNameNS02.java | 104 - .../level2/core/getElementsByTagNameNS03.java | 121 - .../level2/core/getElementsByTagNameNS04.java | 112 - .../level2/core/getElementsByTagNameNS05.java | 92 - .../level2/core/getElementsByTagNameNS06.java | 96 - .../level2/core/getElementsByTagNameNS07.java | 96 - .../level2/core/getElementsByTagNameNS08.java | 88 - .../level2/core/getElementsByTagNameNS09.java | 108 - .../level2/core/getElementsByTagNameNS10.java | 124 - .../level2/core/getElementsByTagNameNS11.java | 114 - .../level2/core/getElementsByTagNameNS12.java | 91 - .../level2/core/getElementsByTagNameNS13.java | 97 - .../level2/core/getElementsByTagNameNS14.java | 97 - .../domts/level2/core/getNamedItemNS01.java | 103 - .../domts/level2/core/getNamedItemNS02.java | 99 - .../domts/level2/core/getNamedItemNS03.java | 91 - .../domts/level2/core/getNamedItemNS04.java | 91 - .../w3c/domts/level2/core/hasAttribute01.java | 89 - .../w3c/domts/level2/core/hasAttribute02.java | 96 - .../w3c/domts/level2/core/hasAttribute03.java | 89 - .../w3c/domts/level2/core/hasAttribute04.java | 96 - .../domts/level2/core/hasAttributeNS01.java | 94 - .../domts/level2/core/hasAttributeNS02.java | 93 - .../domts/level2/core/hasAttributeNS03.java | 94 - .../domts/level2/core/hasAttributeNS04.java | 101 - .../domts/level2/core/hasAttributeNS05.java | 99 - .../domts/level2/core/hasAttributes01.java | 89 - .../domts/level2/core/hasAttributes02.java | 89 - .../core/hc_entitiesremovenameditemns1.java | 104 - .../core/hc_entitiessetnameditemns1.java | 106 - .../core/hc_namednodemapinvalidtype1.java | 95 - .../hc_nodedocumentfragmentnormalize1.java | 92 - .../hc_nodedocumentfragmentnormalize2.java | 87 - .../core/hc_notationsremovenameditemns1.java | 104 - .../core/hc_notationssetnameditemns1.java | 106 - .../w3c/domts/level2/core/importNode01.java | 132 - .../w3c/domts/level2/core/importNode02.java | 104 - .../w3c/domts/level2/core/importNode03.java | 105 - .../w3c/domts/level2/core/importNode04.java | 106 - .../w3c/domts/level2/core/importNode05.java | 111 - .../w3c/domts/level2/core/importNode06.java | 108 - .../w3c/domts/level2/core/importNode07.java | 116 - .../w3c/domts/level2/core/importNode08.java | 105 - .../w3c/domts/level2/core/importNode09.java | 117 - .../w3c/domts/level2/core/importNode10.java | 108 - .../w3c/domts/level2/core/importNode11.java | 106 - .../w3c/domts/level2/core/importNode12.java | 114 - .../w3c/domts/level2/core/importNode13.java | 111 - .../w3c/domts/level2/core/importNode14.java | 109 - .../w3c/domts/level2/core/importNode15.java | 105 - .../w3c/domts/level2/core/importNode16.java | 104 - .../w3c/domts/level2/core/importNode17.java | 102 - .../domts/level2/core/internalSubset01.java | 90 - .../w3c/domts/level2/core/isSupported01.java | 94 - .../w3c/domts/level2/core/isSupported02.java | 94 - .../w3c/domts/level2/core/isSupported04.java | 96 - .../w3c/domts/level2/core/isSupported05.java | 96 - .../w3c/domts/level2/core/isSupported06.java | 96 - .../w3c/domts/level2/core/isSupported07.java | 96 - .../w3c/domts/level2/core/isSupported09.java | 96 - .../w3c/domts/level2/core/isSupported10.java | 96 - .../w3c/domts/level2/core/isSupported11.java | 96 - .../w3c/domts/level2/core/isSupported12.java | 122 - .../w3c/domts/level2/core/isSupported13.java | 84 - .../w3c/domts/level2/core/isSupported14.java | 86 - .../w3c/domts/level2/core/localName01.java | 102 - .../w3c/domts/level2/core/localName02.java | 91 - .../w3c/domts/level2/core/localName03.java | 95 - .../w3c/domts/level2/core/localName04.java | 98 - .../core/namednodemapgetnameditemns01.java | 108 - .../core/namednodemapgetnameditemns02.java | 101 - .../core/namednodemapgetnameditemns03.java | 105 - .../core/namednodemapgetnameditemns04.java | 106 - .../core/namednodemapgetnameditemns05.java | 99 - .../core/namednodemapgetnameditemns06.java | 109 - .../core/namednodemapremovenameditemns01.java | 98 - .../core/namednodemapremovenameditemns02.java | 109 - .../core/namednodemapremovenameditemns03.java | 106 - .../core/namednodemapremovenameditemns04.java | 102 - .../core/namednodemapremovenameditemns05.java | 131 - .../core/namednodemapremovenameditemns06.java | 107 - .../core/namednodemapremovenameditemns07.java | 107 - .../core/namednodemapremovenameditemns08.java | 110 - .../core/namednodemapremovenameditemns09.java | 102 - .../core/namednodemapsetnameditemns01.java | 106 - .../core/namednodemapsetnameditemns02.java | 104 - .../core/namednodemapsetnameditemns03.java | 125 - .../core/namednodemapsetnameditemns04.java | 120 - .../core/namednodemapsetnameditemns05.java | 125 - .../core/namednodemapsetnameditemns06.java | 110 - .../core/namednodemapsetnameditemns07.java | 116 - .../core/namednodemapsetnameditemns08.java | 112 - .../core/namednodemapsetnameditemns09.java | 118 - .../core/namednodemapsetnameditemns10.java | 116 - .../core/namednodemapsetnameditemns11.java | 117 - .../w3c/domts/level2/core/namespaceURI01.java | 102 - .../w3c/domts/level2/core/namespaceURI02.java | 100 - .../w3c/domts/level2/core/namespaceURI03.java | 97 - .../w3c/domts/level2/core/namespaceURI04.java | 90 - .../domts/level2/core/nodegetlocalname03.java | 109 - .../level2/core/nodegetnamespaceuri03.java | 113 - .../level2/core/nodegetownerdocument01.java | 98 - .../level2/core/nodegetownerdocument02.java | 106 - .../domts/level2/core/nodegetprefix03.java | 109 - .../level2/core/nodehasattributes01.java | 92 - .../level2/core/nodehasattributes02.java | 99 - .../level2/core/nodehasattributes03.java | 88 - .../level2/core/nodehasattributes04.java | 111 - .../domts/level2/core/nodeissupported01.java | 116 - .../domts/level2/core/nodeissupported02.java | 116 - .../domts/level2/core/nodeissupported03.java | 101 - .../domts/level2/core/nodeissupported04.java | 89 - .../domts/level2/core/nodeissupported05.java | 101 - .../domts/level2/core/nodenormalize01.java | 193 - .../domts/level2/core/nodesetprefix01.java | 103 - .../domts/level2/core/nodesetprefix02.java | 108 - .../domts/level2/core/nodesetprefix03.java | 100 - .../domts/level2/core/nodesetprefix04.java | 108 - .../domts/level2/core/nodesetprefix05.java | 110 - .../domts/level2/core/nodesetprefix06.java | 95 - .../domts/level2/core/nodesetprefix07.java | 96 - .../domts/level2/core/nodesetprefix08.java | 98 - .../domts/level2/core/nodesetprefix09.java | 94 - .../w3c/domts/level2/core/normalize01.java | 102 - .../domts/level2/core/ownerDocument01.java | 86 - .../w3c/domts/level2/core/ownerElement01.java | 96 - .../w3c/domts/level2/core/ownerElement02.java | 89 - .../org/w3c/domts/level2/core/prefix01.java | 91 - .../org/w3c/domts/level2/core/prefix02.java | 96 - .../org/w3c/domts/level2/core/prefix03.java | 97 - .../org/w3c/domts/level2/core/prefix04.java | 90 - .../org/w3c/domts/level2/core/prefix05.java | 106 - .../org/w3c/domts/level2/core/prefix06.java | 107 - .../org/w3c/domts/level2/core/prefix07.java | 100 - .../org/w3c/domts/level2/core/prefix08.java | 122 - .../org/w3c/domts/level2/core/prefix09.java | 110 - .../org/w3c/domts/level2/core/prefix10.java | 102 - .../org/w3c/domts/level2/core/prefix11.java | 103 - .../org/w3c/domts/level2/core/publicId01.java | 89 - .../level2/core/removeAttributeNS01.java | 123 - .../level2/core/removeAttributeNS02.java | 118 - .../level2/core/removeNamedItemNS01.java | 105 - .../level2/core/removeNamedItemNS02.java | 109 - .../level2/core/removeNamedItemNS03.java | 130 - .../domts/level2/core/setAttributeNS01.java | 103 - .../domts/level2/core/setAttributeNS02.java | 102 - .../domts/level2/core/setAttributeNS03.java | 121 - .../domts/level2/core/setAttributeNS04.java | 116 - .../domts/level2/core/setAttributeNS05.java | 102 - .../domts/level2/core/setAttributeNS06.java | 104 - .../domts/level2/core/setAttributeNS07.java | 105 - .../domts/level2/core/setAttributeNS09.java | 111 - .../domts/level2/core/setAttributeNS10.java | 96 - .../level2/core/setAttributeNodeNS01.java | 118 - .../level2/core/setAttributeNodeNS02.java | 127 - .../level2/core/setAttributeNodeNS03.java | 100 - .../level2/core/setAttributeNodeNS04.java | 106 - .../level2/core/setAttributeNodeNS05.java | 114 - .../domts/level2/core/setNamedItemNS01.java | 118 - .../domts/level2/core/setNamedItemNS02.java | 114 - .../domts/level2/core/setNamedItemNS03.java | 105 - .../domts/level2/core/setNamedItemNS04.java | 132 - .../domts/level2/core/setNamedItemNS05.java | 103 - .../org/w3c/domts/level2/core/systemId01.java | 90 - .../w3c/domts/level2/events/TestBatik.java | 43 - .../domts/level2/events/TestDefaultLS.java | 51 - .../level2/events/TestDefaultLSAltConfig.java | 51 - .../level2/events/TestDefaultParser.java | 43 - .../events/TestDefaultParserAltConfig.java | 43 - .../w3c/domts/level2/events/TestOracle.java | 63 - .../level2/events/TestOracleAltConfig.java | 62 - .../w3c/domts/level2/events/TestXerces.java | 49 - .../level2/events/TestXercesAltConfig.java | 48 - .../w3c/domts/level2/html/TestDefaultLS.java | 51 - .../level2/html/TestDefaultLSAltConfig.java | 51 - .../w3c/domts/level2/html/TestXercesHTML.java | 43 - .../org/w3c/domts/level3/core/TestBatik.java | 45 - .../w3c/domts/level3/core/TestDefaultLS.java | 57 - .../level3/core/TestDefaultLSAltConfig.java | 57 - .../domts/level3/core/TestDefaultParser.java | 53 - .../core/TestDefaultParserAltConfig.java | 56 - .../org/w3c/domts/level3/core/TestOracle.java | 63 - .../level3/core/TestOracleAltConfig.java | 62 - .../org/w3c/domts/level3/core/TestXerces.java | 58 - .../level3/core/TestXercesAltConfig.java | 58 - .../org/w3c/domts/level3/ls/TestBatik.java | 45 - .../w3c/domts/level3/ls/TestDefaultLS.java | 57 - .../domts/level3/ls/TestDefaultParser.java | 53 - .../org/w3c/domts/level3/ls/TestOracle.java | 66 - .../org/w3c/domts/level3/ls/TestXerces.java | 56 - .../domts/level3/validation/TestBatik.java | 45 - .../level3/validation/TestDefaultLS.java | 57 - .../validation/TestDefaultLSAltConfig.java | 57 - .../level3/validation/TestDefaultParser.java | 53 - .../TestDefaultParserAltConfig.java | 56 - .../domts/level3/validation/TestOracle.java | 63 - .../validation/TestOracleAltConfig.java | 62 - .../org/w3c/domts/level3/xpath/TestBatik.java | 45 - .../w3c/domts/level3/xpath/TestDefaultLS.java | 57 - .../level3/xpath/TestDefaultLSAltConfig.java | 57 - .../domts/level3/xpath/TestDefaultParser.java | 53 - .../xpath/TestDefaultParserAltConfig.java | 56 - .../org/w3c/domts/level3/xpath/TestXalan.java | 48 - .../level3/xpath/TestXalanAltConfig.java | 47 - .../java/tests/api/org/w3c/dom/AllTests.java | 36 - .../api/org/w3c/dom/AllTests_Level1.java | 53 - .../api/org/w3c/dom/AllTests_Level2.java | 53 - .../dom/src/test/java/tests/dom/AllTests.java | 32 - .../src/test/resources/META-INF/MANIFEST.MF | 16 - libcore/dom/src/test/resources/build.xml | 106 - .../dom/src/test/resources/hc_nodtdstaff.html | 10 - .../dom/src/test/resources/hc_nodtdstaff.svg | 10 - .../src/test/resources/hc_nodtdstaff.xhtml | 10 - .../dom/src/test/resources/hc_nodtdstaff.xml | 10 - libcore/dom/src/test/resources/hc_staff.html | 48 - libcore/dom/src/test/resources/hc_staff.svg | 72 - libcore/dom/src/test/resources/hc_staff.xhtml | 60 - libcore/dom/src/test/resources/hc_staff.xml | 60 - .../src/test/resources/internalSubset01.js | 0 libcore/dom/src/test/resources/nodtdstaff.svg | 11 - libcore/dom/src/test/resources/nodtdstaff.xml | 11 - libcore/dom/src/test/resources/staff.dtd | 17 - libcore/dom/src/test/resources/staff.svg | 72 - libcore/dom/src/test/resources/staff.xml | 57 - libcore/dom/src/test/resources/staff2.dtd | 24 - libcore/dom/src/test/resources/staff2.svg | 13 - libcore/dom/src/test/resources/staff2.xml | 13 - libcore/dom/src/test/resources/staffNS.dtd | 45 - libcore/dom/src/test/resources/staffNS.svg | 73 - libcore/dom/src/test/resources/staffNS.xml | 59 - libcore/dom/src/test/resources/svgtest.js | 0 libcore/dom/src/test/resources/svgunit.js | 0 .../dom/src/test/resources/xhtml1-strict.dtd | 65 - libcore/icu/MODULE_LICENSE_BSD_LIKE | 0 libcore/icu/license.html | 51 - .../icu4jni/charset/CharsetDecoderICU.java | 354 - .../icu4jni/charset/CharsetEncoderICU.java | 428 - .../com/ibm/icu4jni/charset/CharsetICU.java | 129 - .../icu4jni/charset/CharsetProviderICU.java | 118 - .../ibm/icu4jni/charset/NativeConverter.java | 422 - .../com/ibm/icu4jni/common/ErrorCode.java | 205 - .../java/com/ibm/icu4jni/lang/UCharacter.java | 295 - .../com/ibm/icu4jni/regex/NativeRegEx.java | 130 - .../com/ibm/icu4jni/text/BreakIterator.java | 133 - .../ibm/icu4jni/text/CollationAttribute.java | 214 - .../text/CollationElementIterator.java | 230 - .../com/ibm/icu4jni/text/CollationKey.java | 186 - .../java/com/ibm/icu4jni/text/Collator.java | 431 - .../com/ibm/icu4jni/text/DecimalFormat.java | 568 -- .../icu4jni/text/DecimalFormatSymbols.java | 295 - .../ibm/icu4jni/text/NativeBreakIterator.java | 68 - .../com/ibm/icu4jni/text/NativeCollation.java | 263 - .../ibm/icu4jni/text/NativeDecimalFormat.java | 109 - .../icu4jni/text/RuleBasedBreakIterator.java | 133 - .../ibm/icu4jni/text/RuleBasedCollator.java | 719 -- .../icu4jni/text/RuleBasedNumberFormat.java | 258 - .../java/com/ibm/icu4jni/util/Resources.java | 535 -- .../src/main/native/BidiWrapperInterface.c | 253 - .../src/main/native/BidiWrapperInterface.h | 132 - .../src/main/native/BreakIteratorInterface.c | 264 - .../icu/src/main/native/CharacterInterface.c | 194 - .../icu/src/main/native/CollationInterface.c | 589 -- .../icu/src/main/native/CollationInterface.h | 214 - .../icu/src/main/native/ConverterInterface.c | 1378 ---- .../icu/src/main/native/ConverterInterface.h | 299 - .../main/native/DecimalFormatInterface.cpp | 851 -- libcore/icu/src/main/native/ErrorCode.c | 57 - libcore/icu/src/main/native/ErrorCode.h | 27 - libcore/icu/src/main/native/RBNFInterface.cpp | 382 - .../icu/src/main/native/RegExInterface.cpp | 373 - .../icu/src/main/native/ResourceInterface.cpp | 1437 ---- libcore/icu/src/main/native/sub.mk | 30 - libcore/icu/unicode-license.txt | 48 - libcore/json/MODULE_LICENSE_BSD_LIKE | 0 .../src/main/java/org/json/JSONArray.java | 778 -- .../src/main/java/org/json/JSONException.java | 16 - .../src/main/java/org/json/JSONObject.java | 1081 --- .../src/main/java/org/json/JSONStringer.java | 327 - .../src/main/java/org/json/JSONTokener.java | 460 -- libcore/junit/MODULE_LICENSE_CPL | 1 - .../junit/extensions/ActiveTestSuite.java | 64 - .../junit/extensions/ExceptionTestCase.java | 46 - .../java/junit/extensions/RepeatedTest.java | 31 - .../java/junit/extensions/TestDecorator.java | 38 - .../main/java/junit/extensions/TestSetup.java | 37 - .../main/java/junit/extensions/package.html | 6 - .../src/main/java/junit/framework/Assert.java | 291 - .../junit/framework/AssertionFailedError.java | 13 - .../junit/framework/ComparisonFailure.java | 68 - .../java/junit/framework/Protectable.java | 14 - .../src/main/java/junit/framework/Test.java | 17 - .../main/java/junit/framework/TestCase.java | 197 - .../java/junit/framework/TestFailure.java | 57 - .../java/junit/framework/TestListener.java | 23 - .../main/java/junit/framework/TestResult.java | 166 - .../main/java/junit/framework/TestSuite.java | 267 - .../main/java/junit/framework/package.html | 5 - libcore/logging/MODULE_LICENSE_APACHE2 | 0 .../java/util/logging/ConsoleHandler.java | 72 - .../java/java/util/logging/ErrorManager.java | 112 - .../java/java/util/logging/FileHandler.java | 643 -- .../main/java/java/util/logging/Filter.java | 35 - .../java/java/util/logging/Formatter.java | 118 - .../main/java/java/util/logging/Handler.java | 407 - .../main/java/java/util/logging/Level.java | 369 - .../java/java/util/logging/LogManager.java | 596 -- .../java/java/util/logging/LogRecord.java | 514 -- .../main/java/java/util/logging/Logger.java | 1425 ---- .../java/java/util/logging/LoggingMXBean.java | 82 - .../java/util/logging/LoggingPermission.java | 64 - .../java/java/util/logging/MemoryHandler.java | 285 - .../java/util/logging/SimpleFormatter.java | 76 - .../java/java/util/logging/SocketHandler.java | 177 - .../java/java/util/logging/StreamHandler.java | 352 - .../java/java/util/logging/XMLFormatter.java | 213 - .../java/java/util/logging/logging.properties | 65 - .../main/java/java/util/logging/package.html | 10 - .../logging/internal/nls/Messages.java | 147 - .../logging/internal/nls/messages.properties | 52 - .../tests/java/util/logging/AllTests.java | 52 - .../java/util/logging/ConsoleHandlerTest.java | 685 -- .../java/util/logging/ErrorManagerTest.java | 125 - .../java/util/logging/FileHandlerTest.java | 1176 --- .../tests/java/util/logging/FilterTest.java | 69 - .../java/util/logging/FormatterTest.java | 254 - .../tests/java/util/logging/HandlerTest.java | 780 -- .../tests/java/util/logging/LevelTest.java | 645 -- .../java/util/logging/LevelTestResource.java | 34 - .../java/util/logging/LogManagerTest.java | 1560 ---- .../java/util/logging/LogRecordTest.java | 777 -- .../tests/java/util/logging/LoggerTest.java | 4792 ------------ .../java/util/logging/LoggingMXBeanTest.java | 125 - .../util/logging/LoggingPermissionTest.java | 101 - .../java/util/logging/MemoryHandlerTest.java | 554 -- .../tests/java/util/logging/MessagesTest.java | 121 - .../util/logging/SimpleFormatterTest.java | 181 - .../java/util/logging/SocketHandlerTest.java | 1059 --- .../java/util/logging/StreamHandlerTest.java | 1324 ---- .../java/util/logging/XMLFormatterTest.java | 298 - .../util/logging/util/EnvironmentHelper.java | 53 - .../src/test/java/tests/logging/AllTests.java | 39 - .../bundles/java/util/logging/res.properties | 12 - .../bundles/java/util/logging/res2.properties | 13 - .../bundles/java/util/logging/res3.properties | 13 - .../java/util/logging/res_en_US.properties | 12 - .../java/util/logging/res_zh_CN.properties | 13 - .../config/java/util/logging/logging.config | 3 - .../java/util/logging/logging.properties | 3 - .../java/util/logging/LevelTest.golden.ser | Bin 377 -> 0 bytes .../util/logging/LogRecordTest.golden.ser | Bin 2139 -> 0 bytes .../logging/LoggingPermissionTest.golden.ser | Bin 177 -> 0 bytes libcore/luni-kernel/MODULE_LICENSE_APACHE2 | 0 .../src/main/java/java/lang/Class.java | 1634 ---- .../src/main/java/java/lang/ClassCache.java | 702 -- .../src/main/java/java/lang/ClassLoader.java | 1139 --- .../src/main/java/java/lang/Compiler.java | 100 - .../main/java/java/lang/LangAccessImpl.java | 55 - .../src/main/java/java/lang/Object.java | 368 - .../src/main/java/java/lang/Package.java | 321 - .../main/java/java/lang/ProcessManager.java | 384 - .../src/main/java/java/lang/Runtime.java | 889 --- .../java/java/lang/StackTraceElement.java | 245 - .../src/main/java/java/lang/System.java | 755 -- .../src/main/java/java/lang/Thread.java | 1597 ---- .../src/main/java/java/lang/ThreadGroup.java | 926 --- .../src/main/java/java/lang/Throwable.java | 410 - .../java/java/lang/ref/PhantomReference.java | 81 - .../main/java/java/lang/ref/Reference.java | 162 - .../java/java/lang/ref/SoftReference.java | 135 - .../java/java/lang/ref/WeakReference.java | 119 - .../java/lang/reflect/AccessibleObject.java | 465 -- .../main/java/java/lang/reflect/Array.java | 820 -- .../java/java/lang/reflect/Constructor.java | 491 -- .../main/java/java/lang/reflect/Field.java | 939 --- .../main/java/java/lang/reflect/Method.java | 595 -- .../lang/reflect/ReflectionAccessImpl.java | 54 - .../apache/harmony/kernel/vm/LangAccess.java | 129 - .../harmony/kernel/vm/ReflectionAccess.java | 63 - .../apache/harmony/kernel/vm/StringUtils.java | 63 - .../java/org/apache/harmony/kernel/vm/VM.java | 289 - .../lang/annotation/AnnotationFactory.java | 323 - .../lang/annotation/AnnotationMember.java | 387 - .../main/native/java_lang_ProcessManager.c | 435 -- .../src/main/native/java_lang_System.c | 106 - libcore/luni-kernel/src/main/native/sub.mk | 17 - .../harmony/kernel/dalvik/ThreadsTest.java | 306 - libcore/luni/MODULE_LICENSE_APACHE2 | 0 .../java/java/io/BufferedInputStream.java | 454 -- .../java/java/io/BufferedOutputStream.java | 203 - .../src/main/java/java/io/BufferedReader.java | 518 -- .../src/main/java/java/io/BufferedWriter.java | 329 - .../java/java/io/ByteArrayInputStream.java | 235 - .../java/java/io/ByteArrayOutputStream.java | 250 - .../main/java/java/io/CharArrayReader.java | 316 - .../main/java/java/io/CharArrayWriter.java | 330 - .../java/java/io/CharConversionException.java | 45 - .../luni/src/main/java/java/io/Closeable.java | 35 - .../luni/src/main/java/java/io/DataInput.java | 245 - .../main/java/java/io/DataInputStream.java | 492 -- .../src/main/java/java/io/DataOutput.java | 206 - .../main/java/java/io/DataOutputStream.java | 359 - .../src/main/java/java/io/EOFException.java | 45 - .../src/main/java/java/io/EmulatedFields.java | 624 -- .../java/io/EmulatedFieldsForDumping.java | 233 - .../java/io/EmulatedFieldsForLoading.java | 300 - .../src/main/java/java/io/Externalizable.java | 47 - libcore/luni/src/main/java/java/io/File.java | 1496 ---- .../src/main/java/java/io/FileDescriptor.java | 109 - .../src/main/java/java/io/FileFilter.java | 41 - .../main/java/java/io/FileInputStream.java | 377 - .../java/java/io/FileNotFoundException.java | 45 - .../main/java/java/io/FileOutputStream.java | 323 - .../src/main/java/java/io/FilePermission.java | 383 - .../java/io/FilePermissionCollection.java | 103 - .../src/main/java/java/io/FileReader.java | 68 - .../src/main/java/java/io/FileWriter.java | 98 - .../src/main/java/java/io/FilenameFilter.java | 41 - .../main/java/java/io/FilterInputStream.java | 199 - .../main/java/java/io/FilterOutputStream.java | 153 - .../src/main/java/java/io/FilterReader.java | 202 - .../src/main/java/java/io/FilterWriter.java | 135 - .../luni/src/main/java/java/io/Flushable.java | 33 - .../src/main/java/java/io/IOException.java | 47 - .../src/main/java/java/io/InputStream.java | 245 - .../main/java/java/io/InputStreamReader.java | 348 - .../java/java/io/InterruptedIOException.java | 52 - .../java/java/io/InvalidClassException.java | 86 - .../java/java/io/InvalidObjectException.java | 40 - .../java/java/io/LineNumberInputStream.java | 267 - .../main/java/java/io/LineNumberReader.java | 270 - .../main/java/java/io/NotActiveException.java | 55 - .../java/io/NotSerializableException.java | 52 - .../src/main/java/java/io/ObjectInput.java | 114 - .../main/java/java/io/ObjectInputStream.java | 2771 ------- .../java/java/io/ObjectInputValidation.java | 35 - .../src/main/java/java/io/ObjectOutput.java | 94 - .../main/java/java/io/ObjectOutputStream.java | 2014 ----- .../main/java/java/io/ObjectStreamClass.java | 1224 --- .../java/java/io/ObjectStreamConstants.java | 185 - .../java/java/io/ObjectStreamException.java | 54 - .../main/java/java/io/ObjectStreamField.java | 405 - .../java/java/io/OptionalDataException.java | 62 - .../src/main/java/java/io/OutputStream.java | 136 - .../main/java/java/io/OutputStreamWriter.java | 321 - .../main/java/java/io/PipedInputStream.java | 431 - .../main/java/java/io/PipedOutputStream.java | 185 - .../src/main/java/java/io/PipedReader.java | 461 -- .../src/main/java/java/io/PipedWriter.java | 213 - .../src/main/java/java/io/PrintStream.java | 788 -- .../src/main/java/java/io/PrintWriter.java | 814 -- .../java/java/io/PushbackInputStream.java | 374 - .../src/main/java/java/io/PushbackReader.java | 408 - .../main/java/java/io/RandomAccessFile.java | 1102 --- .../luni/src/main/java/java/io/Reader.java | 277 - .../java/java/io/SequenceInputStream.java | 221 - .../src/main/java/java/io/Serializable.java | 37 - .../java/java/io/SerializablePermission.java | 72 - .../java/io/StreamCorruptedException.java | 51 - .../main/java/java/io/StreamTokenizer.java | 671 -- .../java/java/io/StringBufferInputStream.java | 176 - .../src/main/java/java/io/StringReader.java | 264 - .../src/main/java/java/io/StringWriter.java | 249 - .../java/java/io/SyncFailedException.java | 38 - .../java/java/io/UTFDataFormatException.java | 48 - .../java/io/UnsupportedEncodingException.java | 46 - .../java/java/io/WriteAbortedException.java | 81 - .../luni/src/main/java/java/io/Writer.java | 255 - .../luni/src/main/java/java/io/package.html | 16 - .../java/java/lang/AbstractMethodError.java | 48 - .../java/java/lang/AbstractStringBuilder.java | 917 --- .../src/main/java/java/lang/Appendable.java | 87 - .../java/java/lang/ArithmeticException.java | 45 - .../lang/ArrayIndexOutOfBoundsException.java | 60 - .../java/java/lang/ArrayStoreException.java | 46 - .../main/java/java/lang/AssertionError.java | 117 - .../luni/src/main/java/java/lang/Boolean.java | 230 - .../luni/src/main/java/java/lang/Byte.java | 304 - .../src/main/java/java/lang/CharSequence.java | 74 - .../src/main/java/java/lang/Character.java | 3274 -------- .../java/java/lang/ClassCastException.java | 61 - .../java/java/lang/ClassCircularityError.java | 50 - .../main/java/java/lang/ClassFormatError.java | 46 - .../java/lang/ClassNotFoundException.java | 82 - .../java/lang/CloneNotSupportedException.java | 48 - .../src/main/java/java/lang/Cloneable.java | 33 - .../src/main/java/java/lang/Comparable.java | 53 - .../src/main/java/java/lang/Deprecated.java | 33 - .../luni/src/main/java/java/lang/Double.java | 476 -- .../main/java/java/lang/EmptyEnumeration.java | 56 - .../luni/src/main/java/java/lang/Enum.java | 215 - .../lang/EnumConstantNotPresentException.java | 73 - .../luni/src/main/java/java/lang/Error.java | 75 - .../src/main/java/java/lang/Exception.java | 74 - .../lang/ExceptionInInitializerError.java | 82 - .../luni/src/main/java/java/lang/Float.java | 481 -- .../java/java/lang/IllegalAccessError.java | 48 - .../java/lang/IllegalAccessException.java | 47 - .../java/lang/IllegalArgumentException.java | 72 - .../lang/IllegalMonitorStateException.java | 47 - .../java/java/lang/IllegalStateException.java | 72 - .../lang/IllegalThreadStateException.java | 46 - .../lang/IncompatibleClassChangeError.java | 50 - .../java/lang/IndexOutOfBoundsException.java | 46 - .../java/lang/InheritableThreadLocal.java | 65 - .../java/java/lang/InstantiationError.java | 60 - .../java/lang/InstantiationException.java | 56 - .../luni/src/main/java/java/lang/Integer.java | 900 --- .../main/java/java/lang/InternalError.java | 46 - .../java/java/lang/InterruptedException.java | 46 - .../src/main/java/java/lang/Iterable.java | 35 - .../src/main/java/java/lang/LinkageError.java | 49 - .../luni/src/main/java/java/lang/Long.java | 792 -- .../luni/src/main/java/java/lang/Math.java | 1059 --- .../java/lang/NegativeArraySizeException.java | 46 - .../java/java/lang/NoClassDefFoundError.java | 46 - .../main/java/java/lang/NoSuchFieldError.java | 48 - .../java/java/lang/NoSuchFieldException.java | 46 - .../java/java/lang/NoSuchMethodError.java | 47 - .../java/java/lang/NoSuchMethodException.java | 47 - .../java/java/lang/NullPointerException.java | 50 - .../luni/src/main/java/java/lang/Number.java | 85 - .../java/java/lang/NumberFormatException.java | 46 - .../main/java/java/lang/OutOfMemoryError.java | 47 - .../src/main/java/java/lang/Override.java | 34 - .../luni/src/main/java/java/lang/Process.java | 83 - .../main/java/java/lang/ProcessBuilder.java | 221 - .../src/main/java/java/lang/Readable.java | 40 - .../src/main/java/java/lang/Runnable.java | 33 - .../main/java/java/lang/RuntimeException.java | 73 - .../java/java/lang/RuntimePermission.java | 101 - .../java/java/lang/SecurityException.java | 71 - .../main/java/java/lang/SecurityManager.java | 907 --- .../luni/src/main/java/java/lang/Short.java | 326 - .../java/java/lang/StackOverflowError.java | 48 - .../src/main/java/java/lang/StrictMath.java | 1050 --- .../luni/src/main/java/java/lang/String.java | 2380 ------ .../src/main/java/java/lang/StringBuffer.java | 743 -- .../main/java/java/lang/StringBuilder.java | 701 -- .../lang/StringIndexOutOfBoundsException.java | 61 - .../main/java/java/lang/SuppressWarnings.java | 45 - .../src/main/java/java/lang/ThreadDeath.java | 35 - .../src/main/java/java/lang/ThreadLocal.java | 540 -- .../java/lang/TypeNotPresentException.java | 55 - .../src/main/java/java/lang/UnknownError.java | 46 - .../java/java/lang/UnsatisfiedLinkError.java | 46 - .../lang/UnsupportedClassVersionError.java | 46 - .../lang/UnsupportedOperationException.java | 70 - .../main/java/java/lang/VMClassLoader.java | 142 - .../src/main/java/java/lang/VMThread.java | 114 - .../src/main/java/java/lang/VerifyError.java | 46 - .../java/java/lang/VirtualMachineError.java | 49 - .../luni/src/main/java/java/lang/Void.java | 51 - .../luni/src/main/java/java/lang/package.html | 11 - .../java/java/lang/ref/ReferenceQueue.java | 138 - .../src/main/java/java/lang/ref/package.html | 100 - .../java/lang/reflect/AnnotatedElement.java | 71 - .../java/lang/reflect/GenericArrayType.java | 39 - .../java/lang/reflect/GenericDeclaration.java | 35 - .../reflect/GenericSignatureFormatError.java | 36 - .../java/lang/reflect/InvocationHandler.java | 62 - .../reflect/InvocationTargetException.java | 87 - .../MalformedParameterizedTypeException.java | 36 - .../main/java/java/lang/reflect/Member.java | 77 - .../main/java/java/lang/reflect/Modifier.java | 326 - .../java/lang/reflect/ParameterizedType.java | 76 - .../main/java/java/lang/reflect/Proxy.java | 301 - .../java/lang/reflect/ReflectPermission.java | 61 - .../src/main/java/java/lang/reflect/Type.java | 26 - .../java/java/lang/reflect/TypeVariable.java | 59 - .../reflect/UndeclaredThrowableException.java | 81 - .../java/java/lang/reflect/WildcardType.java | 58 - .../main/java/java/lang/reflect/package.html | 17 - .../src/main/java/java/net/Authenticator.java | 331 - .../src/main/java/java/net/BindException.java | 44 - .../src/main/java/java/net/CacheRequest.java | 58 - .../src/main/java/java/net/CacheResponse.java | 63 - .../main/java/java/net/ConnectException.java | 44 - .../main/java/java/net/ContentHandler.java | 67 - .../java/java/net/ContentHandlerFactory.java | 35 - .../src/main/java/java/net/CookieHandler.java | 90 - .../main/java/java/net/DatagramPacket.java | 314 - .../main/java/java/net/DatagramSocket.java | 861 -- .../java/java/net/DatagramSocketImpl.java | 311 - .../java/net/DatagramSocketImplFactory.java | 35 - .../src/main/java/java/net/FileNameMap.java | 40 - .../java/java/net/HttpRetryException.java | 91 - .../main/java/java/net/HttpURLConnection.java | 541 -- .../src/main/java/java/net/Inet4Address.java | 238 - .../src/main/java/java/net/Inet6Address.java | 473 -- .../src/main/java/java/net/InetAddress.java | 1326 ---- .../main/java/java/net/InetSocketAddress.java | 249 - .../main/java/java/net/JarURLConnection.java | 192 - .../java/java/net/MalformedURLException.java | 49 - .../main/java/java/net/MulticastSocket.java | 616 -- .../main/java/java/net/NegCacheElement.java | 44 - .../src/main/java/java/net/NegativeCache.java | 124 - .../src/main/java/java/net/NetPermission.java | 64 - .../main/java/java/net/NetworkInterface.java | 445 -- .../java/java/net/NoRouteToHostException.java | 46 - .../java/java/net/PasswordAuthentication.java | 65 - .../java/net/PortUnreachableException.java | 44 - .../main/java/java/net/ProtocolException.java | 46 - .../luni/src/main/java/java/net/Proxy.java | 176 - .../src/main/java/java/net/ProxySelector.java | 128 - .../main/java/java/net/ProxySelectorImpl.java | 329 - .../src/main/java/java/net/ResponseCache.java | 168 - .../java/java/net/SecureCacheResponse.java | 95 - .../src/main/java/java/net/ServerSocket.java | 570 -- .../luni/src/main/java/java/net/Socket.java | 1240 --- .../src/main/java/java/net/SocketAddress.java | 35 - .../main/java/java/net/SocketException.java | 48 - .../src/main/java/java/net/SocketImpl.java | 368 - .../main/java/java/net/SocketImplFactory.java | 31 - .../src/main/java/java/net/SocketOptions.java | 156 - .../main/java/java/net/SocketPermission.java | 507 -- .../java/net/SocketPermissionCollection.java | 98 - .../java/java/net/SocketTimeoutException.java | 48 - libcore/luni/src/main/java/java/net/URI.java | 1746 ----- .../main/java/java/net/URIEncoderDecoder.java | 216 - .../java/java/net/URISyntaxException.java | 136 - libcore/luni/src/main/java/java/net/URL.java | 918 --- .../main/java/java/net/URLClassLoader.java | 1221 --- .../src/main/java/java/net/URLConnection.java | 1056 --- .../src/main/java/java/net/URLDecoder.java | 174 - .../src/main/java/java/net/URLEncoder.java | 134 - .../main/java/java/net/URLStreamHandler.java | 467 -- .../java/net/URLStreamHandlerFactory.java | 35 - .../java/java/net/UnknownHostException.java | 47 - .../java/net/UnknownServiceException.java | 50 - .../luni/src/main/java/java/net/package.html | 9 - .../java/java/util/AbstractCollection.java | 395 - .../src/main/java/java/util/AbstractList.java | 747 -- .../src/main/java/java/util/AbstractMap.java | 453 -- .../main/java/java/util/AbstractQueue.java | 127 - .../java/util/AbstractSequentialList.java | 91 - .../src/main/java/java/util/AbstractSet.java | 114 - .../src/main/java/java/util/ArrayList.java | 677 -- .../luni/src/main/java/java/util/Arrays.java | 3020 ------- .../luni/src/main/java/java/util/BitSet.java | 995 --- .../src/main/java/java/util/Calendar.java | 1423 ---- .../src/main/java/java/util/Collection.java | 316 - .../src/main/java/java/util/Collections.java | 3640 --------- .../java/java/util/ComparableTimSort.java | 891 --- .../src/main/java/java/util/Comparator.java | 73 - .../util/ConcurrentModificationException.java | 51 - .../src/main/java/java/util/Currency.java | 244 - .../luni/src/main/java/java/util/Date.java | 794 -- .../src/main/java/java/util/Dictionary.java | 116 - .../util/DuplicateFormatFlagsException.java | 68 - .../java/java/util/EmptyStackException.java | 38 - .../luni/src/main/java/java/util/EnumMap.java | 784 -- .../luni/src/main/java/java/util/EnumSet.java | 359 - .../src/main/java/java/util/Enumeration.java | 50 - .../main/java/java/util/EventListener.java | 27 - .../java/java/util/EventListenerProxy.java | 47 - .../src/main/java/java/util/EventObject.java | 70 - ...ormatFlagsConversionMismatchException.java | 85 - .../src/main/java/java/util/Formattable.java | 59 - .../main/java/java/util/FormattableFlags.java | 58 - .../src/main/java/java/util/Formatter.java | 2841 ------- .../java/util/FormatterClosedException.java | 37 - .../java/java/util/GregorianCalendar.java | 1442 ---- .../luni/src/main/java/java/util/HashMap.java | 1041 --- .../luni/src/main/java/java/util/HashSet.java | 213 - .../src/main/java/java/util/Hashtable.java | 1160 --- .../src/main/java/java/util/HugeEnumSet.java | 358 - .../main/java/java/util/IdentityHashMap.java | 817 -- .../util/IllegalFormatCodePointException.java | 69 - .../IllegalFormatConversionException.java | 86 - .../java/util/IllegalFormatException.java | 37 - .../util/IllegalFormatFlagsException.java | 70 - .../util/IllegalFormatPrecisionException.java | 61 - .../util/IllegalFormatWidthException.java | 61 - .../java/util/InputMismatchException.java | 51 - .../InvalidPropertiesFormatException.java | 69 - .../src/main/java/java/util/Iterator.java | 66 - .../main/java/java/util/LinkedHashMap.java | 394 - .../main/java/java/util/LinkedHashSet.java | 91 - .../src/main/java/java/util/LinkedList.java | 801 -- .../luni/src/main/java/java/util/List.java | 353 - .../src/main/java/java/util/ListIterator.java | 132 - .../java/java/util/ListResourceBundle.java | 134 - .../luni/src/main/java/java/util/Locale.java | 821 -- libcore/luni/src/main/java/java/util/Map.java | 253 - .../src/main/java/java/util/MapEntry.java | 89 - .../src/main/java/java/util/MiniEnumSet.java | 249 - .../util/MissingFormatArgumentException.java | 65 - .../util/MissingFormatWidthException.java | 63 - .../java/util/MissingResourceException.java | 75 - .../java/util/NoSuchElementException.java | 53 - .../src/main/java/java/util/Observable.java | 151 - .../src/main/java/java/util/Observer.java | 40 - .../main/java/java/util/PriorityQueue.java | 412 - .../src/main/java/java/util/Properties.java | 783 -- .../java/java/util/PropertyPermission.java | 172 - .../util/PropertyPermissionCollection.java | 96 - .../java/util/PropertyResourceBundle.java | 122 - .../luni/src/main/java/java/util/Queue.java | 91 - .../luni/src/main/java/java/util/Random.java | 253 - .../src/main/java/java/util/RandomAccess.java | 26 - .../main/java/java/util/ResourceBundle.java | 483 -- .../luni/src/main/java/java/util/Scanner.java | 2198 ------ libcore/luni/src/main/java/java/util/Set.java | 196 - .../main/java/java/util/SimpleTimeZone.java | 1063 --- .../src/main/java/java/util/SortedMap.java | 125 - .../src/main/java/java/util/SortedSet.java | 119 - .../main/java/java/util/SpecialAccess.java | 47 - .../luni/src/main/java/java/util/Stack.java | 124 - .../main/java/java/util/StringTokenizer.java | 289 - .../luni/src/main/java/java/util/TimSort.java | 924 --- .../src/main/java/java/util/TimeZone.java | 655 -- .../luni/src/main/java/java/util/Timer.java | 589 -- .../src/main/java/java/util/TimerTask.java | 119 - .../java/util/TooManyListenersException.java | 49 - .../luni/src/main/java/java/util/TreeMap.java | 2407 ------ .../luni/src/main/java/java/util/TreeSet.java | 388 - .../luni/src/main/java/java/util/UUID.java | 494 -- .../UnknownFormatConversionException.java | 60 - .../util/UnknownFormatFlagsException.java | 65 - .../luni/src/main/java/java/util/Vector.java | 1048 --- .../src/main/java/java/util/WeakHashMap.java | 732 -- .../luni/src/main/java/java/util/package.html | 11 - .../luni/internal/io/FileCanonPathCache.java | 136 - .../luni/internal/net/www/MimeTable.java | 139 - .../www/protocol/file/FileURLConnection.java | 210 - .../net/www/protocol/file/Handler.java | 113 - .../www/protocol/ftp/FtpURLConnection.java | 495 -- .../www/protocol/ftp/FtpURLInputStream.java | 88 - .../net/www/protocol/ftp/Handler.java | 72 - .../net/www/protocol/http/Handler.java | 85 - .../net/www/protocol/http/Header.java | 250 - .../www/protocol/http/HttpConfiguration.java | 138 - .../net/www/protocol/http/HttpConnection.java | 271 - .../protocol/http/HttpConnectionManager.java | 176 - .../www/protocol/http/HttpURLConnection.java | 1714 ---- .../net/www/protocol/https/Handler.java | 52 - .../protocol/https/HttpsURLConnection.java | 423 - .../net/www/protocol/jar/Handler.java | 111 - .../www/protocol/jar/JarURLConnection.java | 407 - .../luni/internal/net/www/types.properties | 29 - .../harmony/luni/internal/nls/Messages.java | 147 - .../luni/internal/nls/messages.properties | 26 - .../luni/internal/util/TimezoneGetter.java | 55 - .../harmony/luni/internal/util/ZoneInfo.java | 250 - .../luni/internal/util/ZoneInfoDB.java | 435 -- .../lang/reflect/GenericSignatureParser.java | 497 -- .../luni/lang/reflect/ImplForArray.java | 40 - .../luni/lang/reflect/ImplForType.java | 88 - .../luni/lang/reflect/ImplForVariable.java | 146 - .../luni/lang/reflect/ImplForWildcard.java | 70 - .../luni/lang/reflect/ListOfTypes.java | 78 - .../luni/lang/reflect/ListOfVariables.java | 36 - .../harmony/luni/lang/reflect/Types.java | 34 - .../harmony/luni/net/GenericIPMreq.java | 109 - .../org/apache/harmony/luni/net/NetUtil.java | 118 - .../luni/net/PlainDatagramSocketImpl.java | 423 - .../luni/net/PlainServerSocketImpl.java | 50 - .../harmony/luni/net/PlainSocketImpl.java | 588 -- .../harmony/luni/net/SocketInputStream.java | 94 - .../harmony/luni/net/SocketOutputStream.java | 75 - .../harmony/luni/net/Socks4Message.java | 254 - .../luni/platform/AbstractMemorySpy.java | 120 - .../harmony/luni/platform/Endianness.java | 55 - .../luni/platform/FileDescriptorHandler.java | 34 - .../luni/platform/ICommonDataTypes.java | 121 - .../harmony/luni/platform/IFileSystem.java | 119 - .../harmony/luni/platform/IMemorySpy.java | 46 - .../harmony/luni/platform/IMemorySystem.java | 557 -- .../harmony/luni/platform/INetworkSystem.java | 236 - .../luni/platform/MappedPlatformAddress.java | 62 - .../harmony/luni/platform/OSFileSystem.java | 295 - .../harmony/luni/platform/OSMemory.java | 687 -- .../luni/platform/OSNetworkSystem.java | 832 -- .../harmony/luni/platform/Platform.java | 88 - .../luni/platform/PlatformAddress.java | 285 - .../luni/platform/PlatformAddressFactory.java | 154 - .../luni/platform/RuntimeMemorySpy.java | 37 - .../org/apache/harmony/luni/util/Base64.java | 170 - .../harmony/luni/util/BinarySearch.java | 72 - .../harmony/luni/util/DeleteOnExit.java | 80 - .../harmony/luni/util/ErrorCodeException.java | 33 - .../util/ExposedByteArrayInputStream.java | 57 - .../luni/util/ExternalMessages.properties | 328 - .../luni/util/FloatingPointParser.java | 327 - .../harmony/luni/util/HexStringParser.java | 327 - .../luni/util/HistoricalNamesUtil.java | 170 - .../apache/harmony/luni/util/Inet6Util.java | 249 - .../harmony/luni/util/InputStreamExposer.java | 118 - .../luni/util/InvalidJarIndexException.java | 46 - .../org/apache/harmony/luni/util/Msg.java | 149 - .../org/apache/harmony/luni/util/MsgHelp.java | 188 - .../luni/util/NotImplementedException.java | 98 - .../harmony/luni/util/NumberConverter.java | 298 - .../apache/harmony/luni/util/OIDDatabase.java | 189 - .../util/PasswordProtectedInputStream.java | 75 - .../luni/util/PositionedInputStream.java | 82 - .../apache/harmony/luni/util/PriviAction.java | 139 - .../harmony/luni/util/SHAOutputStream.java | 463 -- .../harmony/luni/util/ThreadLocalCache.java | 103 - .../harmony/luni/util/TwoKeyHashMap.java | 572 -- .../org/apache/harmony/luni/util/URLUtil.java | 56 - .../org/apache/harmony/luni/util/Util.java | 360 - .../org/apache/harmony/misc/HashCode.java | 203 - .../org/apache/harmony/misc/SystemUtils.java | 58 - .../harmony/misc/internal/nls/Messages.java | 143 - .../misc/internal/nls/messages.properties | 23 - libcore/luni/src/main/native/cbigint.c | 875 --- libcore/luni/src/main/native/cbigint.h | 62 - libcore/luni/src/main/native/commonDblParce.c | 606 -- libcore/luni/src/main/native/commonDblParce.h | 32 - libcore/luni/src/main/native/fltconst.h | 156 - libcore/luni/src/main/native/hycomp.h | 452 -- libcore/luni/src/main/native/java_io_File.c | 704 -- .../src/main/native/java_io_FileDescriptor.c | 199 - .../main/native/java_io_ObjectInputStream.c | 287 - .../main/native/java_io_ObjectOutputStream.c | 246 - .../main/native/java_io_ObjectStreamClass.c | 134 - .../src/main/native/java_lang_Character.cpp | 75 - .../luni/src/main/native/java_lang_Double.c | 77 - .../luni/src/main/native/java_lang_Float.c | 85 - libcore/luni/src/main/native/java_lang_Math.c | 204 - .../src/main/native/java_lang_StrictMath.c | 229 - .../src/main/native/java_net_InetAddress.cpp | 328 - .../main/native/java_net_NetworkInterface.c | 845 -- ...che_harmony_luni_platform_OSFileSystem.cpp | 807 -- ..._apache_harmony_luni_platform_OSMemory.cpp | 634 -- ..._harmony_luni_platform_OSNetworkSystem.cpp | 3828 --------- ...g_apache_harmony_luni_util_NumberConvert.c | 291 - .../org_apache_harmony_luni_util_fltparse.c | 609 -- libcore/luni/src/main/native/sub.mk | 34 - .../com/google/coretests/CoreTestDummy.java | 72 - .../google/coretests/CoreTestIsolator.java | 120 - .../com/google/coretests/CoreTestPrinter.java | 180 - .../com/google/coretests/CoreTestResult.java | 170 - .../google/coretests/CoreTestRunnable.java | 172 - .../com/google/coretests/CoreTestRunner.java | 299 - .../com/google/coretests/CoreTestSuite.java | 355 - .../com/google/coretests/CoreTestTimeout.java | 32 - .../test/java/com/google/coretests/Main.java | 50 - .../google/coretests/PerfStatCollector.java | 257 - .../com/google/coretests/ResultPrinter.java | 157 - .../com/google/coretests/StatTestRunner.java | 230 - .../java/com/google/coretests/StatsStore.java | 309 - .../java/com/google/coretests/Version.java | 30 - .../java/junit/runner/BaseTestRunner.java | 326 - .../junit/runner/ClassPathTestCollector.java | 80 - .../java/junit/runner/FailureDetailView.java | 27 - .../junit/runner/LoadingTestCollector.java | 69 - .../runner/ReloadingTestSuiteLoader.java | 19 - .../junit/runner/SimpleTestCollector.java | 20 - .../src/test/java/junit/runner/Sorter.java | 38 - .../junit/runner/StandardTestSuiteLoader.java | 19 - .../junit/runner/TestCaseClassLoader.java | 226 - .../test/java/junit/runner/TestCollector.java | 16 - .../java/junit/runner/TestRunListener.java | 19 - .../java/junit/runner/TestSuiteLoader.java | 9 - .../src/test/java/junit/runner/Version.java | 14 - .../java/junit/runner/excluded.properties | 12 - .../luni/src/test/java/junit/runner/logo.gif | Bin 964 -> 0 bytes .../src/test/java/junit/runner/smalllogo.gif | Bin 883 -> 0 bytes .../test/java/junit/textui/ResultPrinter.java | 142 - .../test/java/junit/textui/TestRunner.java | 189 - .../harmony/luni/platform/AllTests.java | 36 - .../harmony/luni/platform/OSMemoryTest.java | 164 - .../net/www/protocol/http/AllTests.java | 41 - .../protocol/http/HttpURLConnectionTest.java | 344 - .../net/www/protocol/https/AllTests.java | 42 - .../https/HttpsURLConnectionTest.java | 1534 ---- .../harmony/luni/tests/java/io/AllTests.java | 51 - .../tests/java/io/BufferedReaderTest.java | 134 - .../tests/java/io/FileCanonPathCacheTest.java | 120 - .../tests/java/io/FilePermissionTest.java | 49 - .../harmony/luni/tests/java/io/FileTest.java | 191 - .../tests/java/io/InputStreamReaderTest.java | 82 - .../tests/java/io/ObjectInputStreamTest.java | 309 - .../java/io/ObjectStreamConstantsTest.java | 43 - .../tests/java/io/OutputStreamWriterTest.java | 81 - .../java/io/PushBackInputStreamTest.java | 108 - .../tests/java/io/RandomAccessFileTest.java | 51 - .../luni/tests/java/io/ReaderTest.java | 379 - .../luni/tests/java/io/WriterTest.java | 91 - .../java/lang/AbstractMethodErrorTest.java | 51 - .../luni/tests/java/lang/AllTests.java | 124 - .../java/lang/ArithmeticExceptionTest.java | 59 - .../ArrayIndexOutOfBoundsExceptionTest.java | 76 - .../java/lang/ArrayStoreExceptionTest.java | 60 - .../tests/java/lang/AssertionErrorTest.java | 125 - .../luni/tests/java/lang/BooleanTest.java | 235 - .../luni/tests/java/lang/ByteTest.java | 900 --- .../tests/java/lang/CharacterImplTest.java | 52 - .../luni/tests/java/lang/CharacterTest.java | 2332 ------ .../tests/java/lang/Character_SubsetTest.java | 99 - .../java/lang/Character_UnicodeBlockTest.java | 913 --- .../java/lang/ClassCastExceptionTest.java | 60 - .../java/lang/ClassCircularityErrorTest.java | 51 - .../tests/java/lang/ClassFormatErrorTest.java | 51 - .../luni/tests/java/lang/ClassLoaderTest.java | 1264 --- .../java/lang/ClassNotFoundExceptionTest.java | 130 - .../luni/tests/java/lang/ClassTest.java | 2267 ------ .../luni/tests/java/lang/ClassTest2.java | 99 - .../lang/CloneNotSupportedExceptionTest.java | 60 - .../luni/tests/java/lang/CompilerTest.java | 133 - .../luni/tests/java/lang/DoubleTest.java | 1663 ---- .../EnumConstantNotPresentExceptionTest.java | 86 - .../luni/tests/java/lang/EnumTest.java | 346 - .../luni/tests/java/lang/ErrorTest.java | 86 - .../lang/ExceptionInInitializerErrorTest.java | 107 - .../luni/tests/java/lang/ExceptionTest.java | 87 - .../luni/tests/java/lang/ExtendTestClass.java | 29 - .../tests/java/lang/ExtendTestClass1.java | 21 - .../luni/tests/java/lang/FloatTest.java | 1280 --- .../java/lang/IllegalAccessErrorTest.java | 60 - .../java/lang/IllegalAccessExceptionTest.java | 60 - .../lang/IllegalArgumentExceptionTest.java | 117 - .../IllegalMonitorStateExceptionTest.java | 60 - .../java/lang/IllegalStateExceptionTest.java | 122 - .../lang/IllegalThreadStateExceptionTest.java | 60 - .../IncompatibleClassChangeErrorTest.java | 60 - .../lang/IndexOutOfBoundsExceptionTest.java | 60 - .../java/lang/InheritableThreadLocalTest.java | 78 - .../java/lang/InstantiationErrorTest.java | 60 - .../java/lang/InstantiationExceptionTest.java | 60 - .../luni/tests/java/lang/IntegerTest.java | 1531 ---- .../tests/java/lang/InternalErrorTest.java | 60 - .../java/lang/InterruptedExceptionTest.java | 60 - .../tests/java/lang/LinkageErrorTest.java | 60 - .../luni/tests/java/lang/LongTest.java | 1332 ---- .../luni/tests/java/lang/MathTest.java | 1273 --- .../luni/tests/java/lang/MockEnum.java | 57 - .../luni/tests/java/lang/MockEnum2.java | 61 - .../tests/java/lang/MockSecurityManager.java | 69 - .../java/lang/MutableSecurityManager.java | 102 - .../lang/NegativeArraySizeExceptionTest.java | 60 - .../java/lang/NoClassDefFoundErrorTest.java | 60 - .../tests/java/lang/NoSuchFieldErrorTest.java | 60 - .../java/lang/NoSuchFieldExceptionTest.java | 60 - .../java/lang/NoSuchMethodErrorTest.java | 60 - .../java/lang/NoSuchMethodExceptionTest.java | 60 - .../java/lang/NullPointerExceptionTest.java | 59 - .../java/lang/NumberFormatExceptionTest.java | 60 - .../luni/tests/java/lang/NumberTest.java | 124 - .../luni/tests/java/lang/ObjectTest.java | 673 -- .../tests/java/lang/OutOfMemoryErrorTest.java | 64 - .../luni/tests/java/lang/PackageTest.java | 489 -- .../tests/java/lang/ProcessBuilderTest.java | 289 - .../tests/java/lang/PublicClassLoader.java | 97 - .../luni/tests/java/lang/PublicTestClass.java | 73 - .../tests/java/lang/RuntimeExceptionTest.java | 95 - .../java/lang/RuntimePermissionTest.java | 62 - .../luni/tests/java/lang/RuntimeTest.java | 1100 --- .../java/lang/SecurityExceptionTest.java | 122 - .../tests/java/lang/SecurityManagerTest.java | 1601 ---- .../luni/tests/java/lang/ShortTest.java | 841 -- .../java/lang/StackOverflowErrorTest.java | 60 - .../java/lang/StackTraceElementOriginal.java | 30 - .../java/lang/StackTraceElementTest.java | 285 - .../luni/tests/java/lang/StrictMathTest.java | 1491 ---- .../luni/tests/java/lang/String2Test.java | 1743 ----- .../tests/java/lang/StringBuffer2Test.java | 1106 --- .../tests/java/lang/StringBufferTest.java | 718 -- .../tests/java/lang/StringBuilderTest.java | 2191 ------ .../StringIndexOutOfBoundsExceptionTest.java | 71 - .../luni/tests/java/lang/StringTest.java | 739 -- .../luni/tests/java/lang/SystemTest.java | 1238 --- .../luni/tests/java/lang/TestAnnotation.java | 25 - .../luni/tests/java/lang/TestAssertions.java | 29 - .../luni/tests/java/lang/TestAssertions1.java | 29 - .../luni/tests/java/lang/TestClass1.java | 25 - .../luni/tests/java/lang/TestClass1B.java | 25 - .../luni/tests/java/lang/TestClass1C.java | 25 - .../luni/tests/java/lang/TestClass2.java | 24 - .../luni/tests/java/lang/TestClass3.java | 21 - .../luni/tests/java/lang/TestClass4.java | 0 .../luni/tests/java/lang/TestLibrary.java | 50 - .../luni/tests/java/lang/ThreadDeathTest.java | 42 - .../luni/tests/java/lang/ThreadGroupTest.java | 1899 ----- .../luni/tests/java/lang/ThreadLocalTest.java | 217 - .../luni/tests/java/lang/ThreadStateTest.java | 80 - .../luni/tests/java/lang/ThreadTest.java | 2152 ----- .../luni/tests/java/lang/ThrowableTest.java | 413 - .../lang/TypeNotPresentExceptionTest.java | 72 - .../tests/java/lang/UnknownErrorTest.java | 60 - .../java/lang/UnsatisfiedLinkErrorTest.java | 60 - .../UnsupportedClassVersionErrorTest.java | 55 - .../UnsupportedOperationExceptionTest.java | 118 - .../luni/tests/java/lang/VerifyErrorTest.java | 60 - .../java/lang/VirtualMachineErrorTest.java | 61 - .../harmony/luni/tests/java/net/AllTests.java | 51 - .../java/net/ContentHandlerFactoryTest.java | 167 - .../tests/java/net/ContentHandlerTest.java | 115 - .../java/net/HttpRetryExceptionTest.java | 81 - .../tests/java/net/HttpURLConnectionTest.java | 1141 --- .../luni/tests/java/net/Inet4AddressTest.java | 542 -- .../luni/tests/java/net/Inet6AddressTest.java | 1278 --- .../luni/tests/java/net/InetAddressTest.java | 1119 --- .../tests/java/net/InetSocketAddressTest.java | 422 - .../harmony/luni/tests/java/net/URITest.java | 177 - .../tests/java/net/URLConnectionTest.java | 2047 ----- .../luni/tests/java/net/URLEncoderTest.java | 57 - .../harmony/luni/tests/java/net/URLTest.java | 1285 --- .../tests/java/net/test_protocol/Handler.java | 30 - .../java/util/AbstractCollectionTest.java | 523 -- .../luni/tests/java/util/AbstractMapTest.java | 533 -- .../luni/tests/java/util/AbstractSetTest.java | 142 - .../luni/tests/java/util/AllTests.java | 73 - .../luni/tests/java/util/ArrayListTest.java | 57 - .../luni/tests/java/util/ArraysTest.java | 621 -- .../luni/tests/java/util/BitSetTest.java | 94 - .../luni/tests/java/util/CollectionsTest.java | 1003 --- .../luni/tests/java/util/DateTest.java | 49 - .../luni/tests/java/util/DictionaryTest.java | 82 - .../DuplicateFormatFlagsExceptionTest.java | 132 - .../java/util/EventListenerProxyTest.java | 68 - ...tFlagsConversionMismatchExceptionTest.java | 160 - .../luni/tests/java/util/FormattableTest.java | 70 - .../util/FormatterClosedExceptionTest.java | 71 - .../luni/tests/java/util/FormatterTest.java | 72 - .../luni/tests/java/util/HashMapTest.java | 95 - .../tests/java/util/IdentityHashMapTest.java | 511 -- .../IllegalFormatCodePointExceptionTest.java | 127 - .../IllegalFormatConversionExceptionTest.java | 159 - .../util/IllegalFormatFlagsExceptionTest.java | 132 - .../IllegalFormatPrecisionExceptionTest.java | 128 - .../util/IllegalFormatWidthExceptionTest.java | 129 - .../java/util/InputMismatchExceptionTest.java | 97 - .../InvalidPropertiesFormatExceptionTest.java | 53 - .../tests/java/util/LinkedHashMapTest.java | 846 -- .../tests/java/util/ListIteratorTest.java | 313 - .../luni/tests/java/util/LocaleTest.java | 49 - .../luni/tests/java/util/MapEntryTest.java | 148 - .../MissingFormatArgumentExceptionTest.java | 134 - .../util/MissingFormatWidthExceptionTest.java | 132 - .../luni/tests/java/util/ObserverTest.java | 70 - .../luni/tests/java/util/UUIDTest.java | 571 -- .../UnknownFormatConversionExceptionTest.java | 132 - .../util/UnknownFormatFlagsExceptionTest.java | 131 - .../luni/tests/java/util/VectorTest.java | 48 - .../luni/tests/java/util/WeakHashMapTest.java | 134 - .../harmony/luni/tests/pkg1/TestClass.java | 30 - .../harmony/luni/tests/pkg2/TestClass.java | 29 - .../harmony/luni/tests/util/Base64Test.java | 61 - .../harmony/luni/tests/util/MsgHelpTest.java | 85 - .../harmony/luni/tests/util/NYITest.java | 53 - .../luni/src/test/java/tests/AllTests.java | 61 - .../src/test/java/tests/TestSuiteFactory.java | 34 - .../test/java/tests/api/java/io/AllTests.java | 112 - .../api/java/io/BufferedInputStreamTest.java | 578 -- .../api/java/io/BufferedOutputStreamTest.java | 253 - .../tests/api/java/io/BufferedReaderTest.java | 515 -- .../tests/api/java/io/BufferedWriterTest.java | 412 - .../api/java/io/ByteArrayInputStreamTest.java | 325 - .../java/io/ByteArrayOutputStreamTest.java | 327 - .../api/java/io/CharArrayReaderTest.java | 342 - .../api/java/io/CharArrayWriterTest.java | 436 -- .../java/io/CharConversionExceptionTest.java | 66 - .../java/io/ComputeSerialVersionUIDTest.java | 181 - .../java/io/DataInputOutputStreamTest.java | 529 -- .../api/java/io/DataInputStreamTest.java | 517 -- .../api/java/io/DataOutputStreamTest.java | 297 - .../tests/api/java/io/EOFExceptionTest.java | 84 - .../tests/api/java/io/ExternalizableTest.java | 33 - .../tests/api/java/io/FileDescriptorTest.java | 152 - .../tests/api/java/io/FileFilterTest.java | 25 - .../api/java/io/FileInputStreamTest.java | 511 -- .../java/io/FileNotFoundExceptionTest.java | 66 - .../api/java/io/FileOutputStreamTest.java | 451 -- .../tests/api/java/io/FilePermissionTest.java | 261 - .../tests/api/java/io/FileReaderTest.java | 169 - .../test/java/tests/api/java/io/FileTest.java | 2543 ------ .../tests/api/java/io/FileWriterTest.java | 409 - .../tests/api/java/io/FilenameFilterTest.java | 25 - .../api/java/io/FilterInputStreamTest.java | 454 -- .../api/java/io/FilterOutputStreamTest.java | 269 - .../tests/api/java/io/FilterReaderTest.java | 279 - .../tests/api/java/io/FilterWriterTest.java | 228 - .../tests/api/java/io/IOExceptionTest.java | 68 - .../api/java/io/InputStreamReaderTest.java | 756 -- .../tests/api/java/io/InputStreamTest.java | 402 - .../java/io/InterruptedIOExceptionTest.java | 86 - .../java/io/InvalidClassExceptionTest.java | 101 - .../java/io/InvalidObjectExceptionTest.java | 49 - .../java/io/LineNumberInputStreamTest.java | 308 - .../api/java/io/LineNumberReaderTest.java | 310 - .../api/java/io/NotActiveExceptionTest.java | 67 - .../java/io/NotSerializableExceptionTest.java | 66 - .../java/io/ObjectInputOutputStreamTest.java | 468 -- .../io/ObjectInputStreamGetFieldTest.java | 400 - .../api/java/io/ObjectInputStreamTest.java | 1497 ---- .../java/io/ObjectInputValidationTest.java | 23 - .../io/ObjectOutputStreamPutFieldTest.java | 209 - .../api/java/io/ObjectOutputStreamTest.java | 1626 ---- .../api/java/io/ObjectStreamClassTest.java | 245 - .../java/io/ObjectStreamExceptionTest.java | 78 - .../api/java/io/ObjectStreamFieldTest.java | 537 -- .../tests/api/java/io/OpenRandomFileTest.java | 83 - .../tests/api/java/io/OutputStreamTest.java | 172 - .../api/java/io/OutputStreamWriterTest.java | 878 --- .../api/java/io/PipedInputStreamTest.java | 533 -- .../api/java/io/PipedOutputStreamTest.java | 339 - .../tests/api/java/io/PipedReaderTest.java | 408 - .../tests/api/java/io/PipedWriterTest.java | 502 -- .../tests/api/java/io/PrintStreamTest.java | 1179 --- .../tests/api/java/io/PrintWriterTest.java | 1307 ---- .../api/java/io/PushbackInputStreamTest.java | 466 -- .../tests/api/java/io/PushbackReaderTest.java | 673 -- .../api/java/io/RandomAccessFileTest.java | 1504 ---- .../api/java/io/SequenceInputStreamTest.java | 357 - .../java/io/SerializablePermissionTest.java | 77 - .../api/java/io/SerializationStressTest.java | 295 - .../api/java/io/SerializationStressTest0.java | 1012 --- .../api/java/io/SerializationStressTest1.java | 1894 ----- .../api/java/io/SerializationStressTest2.java | 2425 ------ .../api/java/io/SerializationStressTest3.java | 2068 ----- .../api/java/io/SerializationStressTest4.java | 3101 -------- .../api/java/io/SerializationStressTest5.java | 390 - .../api/java/io/SerializationTestClass.java | 335 - .../java/io/StreamCorruptedExceptionTest.java | 66 - .../api/java/io/StreamTokenizerTest.java | 757 -- .../java/io/StringBufferInputStreamTest.java | 176 - .../tests/api/java/io/StringReaderTest.java | 279 - .../tests/api/java/io/StringWriterTest.java | 306 - .../api/java/io/SyncFailedExceptionTest.java | 47 - .../java/io/UTFDataFormatExceptionTest.java | 66 - .../io/UnsupportedEncodingExceptionTest.java | 66 - .../java/io/WriteAbortedExceptionTest.java | 102 - .../java/tests/api/java/io/WriterTest.java | 338 - .../java/tests/api/java/lang/AllTests.java | 47 - .../java/tests/api/java/lang/BooleanTest.java | 53 - .../tests/api/java/lang/Process2Test.java | 128 - .../api/java/lang/ProcessManagerTest.java | 271 - .../java/tests/api/java/lang/ProcessTest.java | 242 - .../java/tests/api/java/lang/StringTest.java | 85 - .../tests/api/java/lang/ref/AllTests.java | 47 - .../java/lang/ref/PhantomReferenceTest.java | 164 - .../api/java/lang/ref/ReferenceQueueTest.java | 283 - .../api/java/lang/ref/ReferenceTest.java | 456 -- .../api/java/lang/ref/SoftReferenceTest.java | 173 - .../api/java/lang/ref/WeakReferenceTest.java | 98 - .../lang/reflect/AccessibleObjectTest.java | 269 - .../tests/api/java/lang/reflect/AllTests.java | 60 - .../api/java/lang/reflect/ArrayTest.java | 1133 --- .../reflect/BoundedGenericMethodsTests.java | 164 - .../java/lang/reflect/ConstructorTest.java | 603 -- .../api/java/lang/reflect/FieldTest.java | 2157 ----- .../lang/reflect/GenericArrayTypeTest.java | 82 - .../lang/reflect/GenericMethodsTests.java | 199 - .../reflect/GenericReflectionCornerCases.java | 291 - .../reflect/GenericReflectionTestsBase.java | 74 - .../GenericSignatureFormatErrorTest.java | 123 - .../java/lang/reflect/GenericTypesTest.java | 289 - .../InvocationTargetExceptionTest.java | 359 - ...formedParameterizedTypeExceptionTests.java | 33 - .../api/java/lang/reflect/MethodTest.java | 1014 --- .../api/java/lang/reflect/ModifierTest.java | 289 - .../lang/reflect/ParameterizedTypeTest.java | 147 - .../api/java/lang/reflect/ProxyTest.java | 398 - .../lang/reflect/ReflectPermissionTest.java | 77 - .../java/lang/reflect/TypeVariableTest.java | 218 - .../UndeclaredThrowableExceptionTests.java | 83 - .../java/lang/reflect/WildcardTypeTest.java | 196 - .../java/tests/api/java/net/AllTests.java | 84 - .../net/AuthenticatorRequestorTypeTest.java | 70 - .../tests/api/java/net/AuthenticatorTest.java | 423 - .../tests/api/java/net/BindExceptionTest.java | 85 - .../tests/api/java/net/CacheRequestTest.java | 87 - .../tests/api/java/net/CacheResponseTest.java | 83 - .../api/java/net/ConnectExceptionTest.java | 56 - .../tests/api/java/net/CookieHandlerTest.java | 235 - .../api/java/net/DatagramPacketTest.java | 612 -- .../net/DatagramSocketImplFactoryTest.java | 257 - .../api/java/net/DatagramSocketImplTest.java | 349 - .../api/java/net/DatagramSocketTest.java | 2853 ------- .../tests/api/java/net/ExcludedProxyTest.java | 238 - .../tests/api/java/net/FileNameMapTest.java | 53 - .../api/java/net/HttpRetryExceptionTest.java | 106 - .../api/java/net/JarURLConnectionTest.java | 543 -- .../java/net/MalformedURLExceptionTest.java | 91 - .../api/java/net/MulticastSocketTest.java | 1163 --- .../tests/api/java/net/NetPermissionTest.java | 81 - .../api/java/net/NetworkInterfaceTest.java | 613 -- .../java/net/NoRouteToHostExceptionTest.java | 88 - .../java/net/PasswordAuthenticationTest.java | 94 - .../net/PortUnreachableExceptionTest.java | 56 - .../api/java/net/ProtocolExceptionTest.java | 85 - .../tests/api/java/net/ProxySelectorTest.java | 737 -- .../java/tests/api/java/net/ProxyTest.java | 343 - .../tests/api/java/net/ProxyTypeTest.java | 84 - .../tests/api/java/net/ResponseCacheTest.java | 341 - .../api/java/net/SecureCacheResponseTest.java | 181 - .../tests/api/java/net/ServerSocketTest.java | 1496 ---- .../api/java/net/SocketExceptionTest.java | 83 - .../api/java/net/SocketImplFactoryTest.java | 211 - .../tests/api/java/net/SocketImplTest.java | 265 - .../api/java/net/SocketPermissionTest.java | 340 - .../java/tests/api/java/net/SocketTest.java | 3404 -------- .../tests/api/java/net/SocketTestCase.java | 172 - .../java/net/SocketTimeoutExceptionTest.java | 40 - .../api/java/net/TestServerSocketInit.java | 30 - .../api/java/net/URISyntaxExceptionTest.java | 166 - .../test/java/tests/api/java/net/URITest.java | 2174 ------ .../api/java/net/URLClassLoaderTest.java | 634 -- .../tests/api/java/net/URLDecoderTest.java | 120 - .../tests/api/java/net/URLEncoderTest.java | 121 - .../java/net/URLStreamHandlerFactoryTest.java | 132 - .../api/java/net/URLStreamHandlerTest.java | 328 - .../java/net/UnknownHostExceptionTest.java | 87 - .../java/net/UnknownServiceExceptionTest.java | 88 - .../tests/api/java/util/AbstractListTest.java | 353 - .../tests/api/java/util/AbstractMapTest.java | 310 - .../api/java/util/AbstractQueueTest.java | 425 - .../java/util/AbstractSequentialListTest.java | 659 -- .../java/tests/api/java/util/AllTests.java | 91 - .../tests/api/java/util/ArrayListTest.java | 856 -- .../java/tests/api/java/util/ArraysTest.java | 2471 ------ .../java/tests/api/java/util/BitSetTest.java | 1564 ---- .../tests/api/java/util/CalendarTest.java | 1327 ---- .../tests/api/java/util/CollectionsTest.java | 2498 ------ .../api/java/util/ConcurrentModTest.java | 753 -- .../ConcurrentModificationExceptionTest.java | 125 - .../tests/api/java/util/CurrencyTest.java | 462 -- .../java/tests/api/java/util/DateTest.java | 718 -- .../java/util/EmptyStackExceptionTest.java | 77 - .../java/tests/api/java/util/EnumMapTest.java | 1288 --- .../java/tests/api/java/util/EnumSetTest.java | 2112 ----- .../tests/api/java/util/EventObjectTest.java | 98 - .../api/java/util/FormattableFlagsTest.java | 43 - .../tests/api/java/util/FormatterTest.java | 4759 ------------ .../api/java/util/GregorianCalendarTest.java | 960 --- .../java/tests/api/java/util/HashMapTest.java | 696 -- .../java/tests/api/java/util/HashSetTest.java | 345 - .../tests/api/java/util/HashtableTest.java | 1032 --- .../api/java/util/IdentityHashMapTest.java | 615 -- .../InvalidPropertiesFormatExceptionTest.java | 51 - .../api/java/util/LinkedHashMapTest.java | 904 --- .../api/java/util/LinkedHashSetTest.java | 447 -- .../tests/api/java/util/LinkedListTest.java | 850 -- .../api/java/util/ListResourceBundleTest.java | 124 - .../java/tests/api/java/util/LocaleTest.java | 662 -- .../util/MissingResourceExceptionTest.java | 109 - .../java/util/NoSuchElementExceptionTest.java | 91 - .../tests/api/java/util/ObservableTest.java | 322 - .../api/java/util/PriorityQueueTest.java | 1026 --- .../tests/api/java/util/PropertiesTest.java | 629 -- .../api/java/util/PropertyPermissionTest.java | 216 - .../java/util/PropertyResourceBundleTest.java | 122 - .../java/tests/api/java/util/RandomTest.java | 376 - .../api/java/util/ResourceBundleTest.java | 496 -- .../api/java/util/SampleBundleClass.java | 43 - .../java/tests/api/java/util/ScannerTest.java | 6919 ----------------- .../api/java/util/SimpleTimeZoneTest.java | 977 --- .../java/tests/api/java/util/StackTest.java | 230 - .../api/java/util/StringTokenizerTest.java | 285 - .../tests/api/java/util/TimeZoneTest.java | 415 - .../tests/api/java/util/TimerTaskTest.java | 276 - .../java/tests/api/java/util/TimerTest.java | 1273 --- .../util/TooManyListenersExceptionTest.java | 82 - .../java/tests/api/java/util/TreeMapTest.java | 891 --- .../java/tests/api/java/util/TreeSetTest.java | 611 -- .../java/tests/api/java/util/VectorTest.java | 1498 ---- .../tests/api/java/util/WeakHashMapTest.java | 525 -- .../java/tests/api/java/util/support/A.java | 13 - .../java/tests/api/java/util/support/B.java | 4 - .../java/tests/api/java/util/support/I.java | 5 - .../java/tests/api/java/util/support/P.java | 28 - .../java/tests/java/lang/String/Tests.java | 84 - .../src/test/java/tests/luni/AllTestsIo.java | 42 - .../test/java/tests/luni/AllTestsLang.java | 46 - .../src/test/java/tests/luni/AllTestsNet.java | 45 - .../test/java/tests/luni/AllTestsUtil.java | 41 - .../luni/src/test/resources/HelloWorld.txt | 1 - libcore/luni/src/test/resources/hyts_Foo.c | 1 - .../luni/src/test/resources/libTestLibrary.so | Bin 5409 -> 0 bytes .../harmony/luni/tests/java/lang/A.class | Bin 322 -> 0 bytes .../luni/tests/java/lang/HelloWorld.txt | 1 - .../luni/tests/java/lang/HelloWorld1.txt | 1 - .../luni/tests/java/lang/illegalClasses.jar | Bin 683 -> 0 bytes .../apache/harmony/luni/tests/key_store.bks | Bin 1212 -> 0 bytes .../luni/tests/java/io/FileTest.golden.ser | Bin 88 -> 0 bytes .../tests/java/io/test_array_integers.ser | Bin 226 -> 0 bytes .../luni/tests/java/io/test_array_strings.ser | Bin 150 -> 0 bytes .../tests/java/lang/EnumTest.golden.0.ser | Bin 113 -> 0 bytes .../tests/java/lang/EnumTest.golden.1.ser | Bin 443 -> 0 bytes .../tests/java/lang/EnumTest.golden.2.ser | Bin 329 -> 0 bytes .../tests/java/lang/EnumTest.golden.3.ser | Bin 288 -> 0 bytes .../luni/tests/java/lang/EnumTest.harmony.ser | Bin 329 -> 0 bytes .../IllegalArgumentExceptionTest.golden.ser | Bin 1356 -> 0 bytes .../lang/IllegalStateExceptionTest.golden.ser | Bin 1347 -> 0 bytes .../lang/SecurityExceptionTest.golden.ser | Bin 1335 -> 0 bytes .../java/lang/StringBufferTest.golden.ser | Bin 154 -> 0 bytes .../java/lang/StringBuilderTest.golden.ser | Bin 126 -> 0 bytes ...supportedOperationExceptionTest.golden.ser | Bin 1371 -> 0 bytes .../net/HttpRetryExceptionTest.golden.ser | Bin 1279 -> 0 bytes .../java/net/Inet4AddressTest.golden.ser | Bin 112 -> 0 bytes .../java/net/Inet6AddressTest.golden.0.ser | Bin 260 -> 0 bytes .../java/net/Inet6AddressTest.golden.1.ser | Bin 261 -> 0 bytes .../tests/java/net/InetAddressTest.golden.ser | Bin 112 -> 0 bytes .../net/InetSocketAddressTest.golden.0.ser | Bin 170 -> 0 bytes .../net/InetSocketAddressTest.golden.1.ser | Bin 252 -> 0 bytes .../Collections_CheckedCollection.golden.ser | Bin 246 -> 0 bytes .../util/Collections_CheckedList.golden.ser | Bin 320 -> 0 bytes ...ections_CheckedListRandomAccess.golden.ser | Bin 390 -> 0 bytes .../util/Collections_CheckedMap.golden.ser | Bin 311 -> 0 bytes .../util/Collections_CheckedSet.golden.ser | Bin 293 -> 0 bytes .../Collections_CheckedSortedMap.golden.ser | Bin 400 -> 0 bytes .../Collections_CheckedSortedSet.golden.ser | Bin 373 -> 0 bytes ...plicateFormatFlagsExceptionTest.golden.ser | Bin 1490 -> 0 bytes ...ConversionMismatchExceptionTest.golden.ser | Bin 1522 -> 0 bytes .../FormatterClosedExceptionTest.golden.ser | Bin 1401 -> 0 bytes .../tests/java/util/HashMapTest.golden.ser | Bin 96 -> 0 bytes .../java/util/IdentityHashMapTest.golden.ser | Bin 112 -> 0 bytes ...galFormatCodePointExceptionTest.golden.ser | Bin 1481 -> 0 bytes ...alFormatConversionExceptionTest.golden.ser | Bin 1541 -> 0 bytes ...IllegalFormatFlagsExceptionTest.golden.ser | Bin 1486 -> 0 bytes ...galFormatPrecisionExceptionTest.golden.ser | Bin 1481 -> 0 bytes ...IllegalFormatWidthExceptionTest.golden.ser | Bin 1469 -> 0 bytes .../InputMismatchExceptionTest.golden.ser | Bin 1644 -> 0 bytes ...singFormatArgumentExceptionTest.golden.ser | Bin 1494 -> 0 bytes ...MissingFormatWidthExceptionTest.golden.ser | Bin 1485 -> 0 bytes .../luni/tests/java/util/UUIDTest.golden.ser | Bin 80 -> 0 bytes ...wnFormatConversionExceptionTest.golden.ser | Bin 1500 -> 0 bytes ...UnknownFormatFlagsExceptionTest.golden.ser | Bin 1489 -> 0 bytes .../api/java/io/testComputeSUIDClass.ser | Bin 798 -> 0 bytes .../java/io/testComputeSUIDConstructors.ser | Bin 890 -> 0 bytes .../api/java/io/testComputeSUIDFields.ser | Bin 1856 -> 0 bytes .../api/java/io/testComputeSUIDInterfaces.ser | Bin 1306 -> 0 bytes .../api/java/io/testComputeSUIDMethods.ser | Bin 1136 -> 0 bytes .../api/java/util/EnumMapTest.golden.ser | Bin 270 -> 0 bytes .../api/java/util/EnumSetTest.golden.ser | Bin 897 -> 0 bytes .../api/java/util/HashSetTest.golden.ser | Bin 69 -> 0 bytes .../java/util/IdentityHashMapTest.golden.ser | Bin 88 -> 0 bytes .../api/java/util/PriorityQueue.golden.ser | Bin 278 -> 0 bytes .../util/PropertyPermissionTest.golden.ser | Bin 190 -> 0 bytes .../tests/api/java/io/testFields.ser | Bin 518 -> 0 bytes .../tests/api/java/io/testFieldsDefaulted.ser | Bin 64 -> 0 bytes .../api/java/io/testFieldsDeprecated.ser | Bin 565 -> 0 bytes .../test/resources/tests/api/java/io/testfile | 1 - .../tests/api/java/io/testfile-utf8.txt | 1 - .../resources/tests/api/java/io/testfile.txt | 1 - .../tests/api/java/lang/reflect/dex1.bytes | Bin 888 -> 0 bytes .../tests/api/java/net/InvalidJar.jar | Bin 3434 -> 0 bytes .../tests/api/java/net/TestCodeSigners.jar | Bin 3381 -> 0 bytes .../resources/tests/api/java/net/file1.cache | 1 - .../test/resources/tests/api/java/net/lf.jar | Bin 33095 -> 0 bytes .../tests/api/java/util/support/B.properties | 1 - libcore/math/MODULE_LICENSE_APACHE2 | 0 .../src/main/java/java/math/BigDecimal.java | 3084 -------- .../math/src/main/java/java/math/BigInt.java | 403 - .../src/main/java/java/math/BigInteger.java | 1499 ---- .../src/main/java/java/math/BitLevel.java | 364 - .../src/main/java/java/math/Conversion.java | 467 -- .../src/main/java/java/math/Division.java | 235 - .../math/src/main/java/java/math/Logical.java | 800 -- .../src/main/java/java/math/MathContext.java | 330 - .../main/java/java/math/Multiplication.java | 197 - .../src/main/java/java/math/Primality.java | 152 - .../src/main/java/java/math/RoundingMode.java | 125 - .../math/src/main/java/java/math/package.html | 13 - .../harmony/math/internal/nls/Messages.java | 140 - .../math/internal/nls/messages.properties | 45 - .../math/tests/java/math/AllTests.java | 60 - .../java/math/BigDecimalArithmeticTest.java | 2960 ------- .../java/math/BigDecimalCompareTest.java | 739 -- .../java/math/BigDecimalConstructorsTest.java | 1600 ---- .../java/math/BigDecimalConvertTest.java | 1704 ---- .../math/BigDecimalScaleOperationsTest.java | 625 -- .../tests/java/math/BigIntegerAddTest.java | 640 -- .../tests/java/math/BigIntegerAndTest.java | 565 -- .../java/math/BigIntegerCompareTest.java | 738 -- .../java/math/BigIntegerConstructorsTest.java | 1175 --- .../java/math/BigIntegerConvertTest.java | 1147 --- .../tests/java/math/BigIntegerDivideTest.java | 891 --- .../java/math/BigIntegerHashCodeTest.java | 104 - .../tests/java/math/BigIntegerModPowTest.java | 421 - .../java/math/BigIntegerMultiplyTest.java | 504 -- .../tests/java/math/BigIntegerNotTest.java | 253 - .../java/math/BigIntegerOperateBitsTest.java | 1986 ----- .../tests/java/math/BigIntegerOrTest.java | 548 -- .../java/math/BigIntegerSubtractTest.java | 704 -- .../java/math/BigIntegerToStringTest.java | 335 - .../tests/java/math/BigIntegerXorTest.java | 398 - .../java/tests/api/java/math/AllTests.java | 41 - .../tests/api/java/math/BigDecimalTest.java | 1351 ---- .../tests/api/java/math/BigIntegerTest.java | 1429 ---- .../tests/api/java/math/MathContextTest.java | 135 - .../tests/api/java/math/RoundingModeTest.java | 61 - .../src/test/java/tests/math/AllTests.java | 39 - libcore/nio/MODULE_LICENSE_APACHE2 | 0 .../main/java/java/nio/BaseByteBuffer.java | 70 - .../nio/src/main/java/java/nio/Buffer.java | 343 - .../src/main/java/java/nio/BufferFactory.java | 208 - .../java/nio/BufferOverflowException.java | 38 - .../java/nio/BufferUnderflowException.java | 38 - .../src/main/java/java/nio/ByteBuffer.java | 1190 --- .../nio/src/main/java/java/nio/ByteOrder.java | 82 - .../main/java/java/nio/CharArrayBuffer.java | 101 - .../src/main/java/java/nio/CharBuffer.java | 877 --- .../java/java/nio/CharSequenceAdapter.java | 152 - .../java/nio/CharToByteBufferAdapter.java | 218 - .../main/java/java/nio/DirectByteBuffer.java | 293 - .../main/java/java/nio/DirectByteBuffers.java | 84 - .../main/java/java/nio/DoubleArrayBuffer.java | 88 - .../src/main/java/java/nio/DoubleBuffer.java | 603 -- .../java/nio/DoubleToByteBufferAdapter.java | 208 - .../main/java/java/nio/FloatArrayBuffer.java | 87 - .../src/main/java/java/nio/FloatBuffer.java | 601 -- .../java/nio/FloatToByteBufferAdapter.java | 208 - .../main/java/java/nio/HeapByteBuffer.java | 250 - .../main/java/java/nio/IntArrayBuffer.java | 87 - .../nio/src/main/java/java/nio/IntBuffer.java | 594 -- .../java/java/nio/IntToByteBufferAdapter.java | 223 - .../java/java/nio/InvalidMarkException.java | 38 - .../main/java/java/nio/LongArrayBuffer.java | 87 - .../src/main/java/java/nio/LongBuffer.java | 598 -- .../java/nio/LongToByteBufferAdapter.java | 208 - .../main/java/java/nio/MappedByteBuffer.java | 115 - .../java/nio/MappedByteBufferAdapter.java | 380 - .../nio/src/main/java/java/nio/NIOAccess.java | 87 - .../java/nio/ReadOnlyBufferException.java | 38 - .../java/nio/ReadOnlyCharArrayBuffer.java | 102 - .../java/nio/ReadOnlyDirectByteBuffer.java | 135 - .../java/nio/ReadOnlyDoubleArrayBuffer.java | 98 - .../java/nio/ReadOnlyFloatArrayBuffer.java | 96 - .../java/java/nio/ReadOnlyHeapByteBuffer.java | 138 - .../java/java/nio/ReadOnlyIntArrayBuffer.java | 96 - .../java/nio/ReadOnlyLongArrayBuffer.java | 96 - .../java/nio/ReadOnlyShortArrayBuffer.java | 96 - .../java/nio/ReadWriteCharArrayBuffer.java | 121 - .../java/nio/ReadWriteDirectByteBuffer.java | 316 - .../java/nio/ReadWriteDoubleArrayBuffer.java | 125 - .../java/nio/ReadWriteFloatArrayBuffer.java | 125 - .../java/nio/ReadWriteHeapByteBuffer.java | 204 - .../java/nio/ReadWriteIntArrayBuffer.java | 122 - .../java/nio/ReadWriteLongArrayBuffer.java | 122 - .../java/nio/ReadWriteShortArrayBuffer.java | 124 - .../main/java/java/nio/ShortArrayBuffer.java | 88 - .../src/main/java/java/nio/ShortBuffer.java | 595 -- .../java/nio/ShortToByteBufferAdapter.java | 223 - .../channels/AlreadyConnectedException.java | 38 - .../channels/AsynchronousCloseException.java | 39 - .../java/java/nio/channels/ByteChannel.java | 33 - .../nio/channels/CancelledKeyException.java | 41 - .../main/java/java/nio/channels/Channel.java | 68 - .../main/java/java/nio/channels/Channels.java | 618 -- .../channels/ClosedByInterruptException.java | 43 - .../nio/channels/ClosedChannelException.java | 41 - .../nio/channels/ClosedSelectorException.java | 40 - .../channels/ConnectionPendingException.java | 40 - .../java/nio/channels/DatagramChannel.java | 474 -- .../java/java/nio/channels/FileChannel.java | 830 -- .../main/java/java/nio/channels/FileLock.java | 224 - .../FileLockInterruptionException.java | 43 - .../nio/channels/GatheringByteChannel.java | 102 - .../IllegalBlockingModeException.java | 39 - .../channels/IllegalSelectorException.java | 39 - .../nio/channels/InterruptibleChannel.java | 58 - .../NoConnectionPendingException.java | 41 - .../channels/NonReadableChannelException.java | 38 - .../channels/NonWritableChannelException.java | 38 - .../nio/channels/NotYetBoundException.java | 38 - .../channels/NotYetConnectedException.java | 39 - .../OverlappingFileLockException.java | 38 - .../src/main/java/java/nio/channels/Pipe.java | 130 - .../nio/channels/ReadableByteChannel.java | 74 - .../nio/channels/ScatteringByteChannel.java | 101 - .../java/nio/channels/SelectableChannel.java | 208 - .../java/java/nio/channels/SelectionKey.java | 249 - .../main/java/java/nio/channels/Selector.java | 187 - .../nio/channels/ServerSocketChannel.java | 126 - .../java/java/nio/channels/SocketChannel.java | 471 -- .../channels/UnresolvedAddressException.java | 38 - .../UnsupportedAddressTypeException.java | 38 - .../nio/channels/WritableByteChannel.java | 71 - .../main/java/java/nio/channels/package.html | 10 - .../spi/AbstractInterruptibleChannel.java | 202 - .../spi/AbstractSelectableChannel.java | 290 - .../channels/spi/AbstractSelectionKey.java | 70 - .../nio/channels/spi/AbstractSelector.java | 189 - .../nio/channels/spi/SelectorProvider.java | 275 - .../java/java/nio/channels/spi/package.html | 8 - .../nio/src/main/java/java/nio/package.html | 16 - .../org/apache/harmony/nio/AddressUtil.java | 86 - .../harmony/nio/FileChannelFactory.java | 56 - .../java/org/apache/harmony/nio/Util.java | 162 - .../nio/internal/DatagramChannelImpl.java | 864 -- .../harmony/nio/internal/DirectBuffer.java | 35 - .../harmony/nio/internal/FileChannelImpl.java | 660 -- .../harmony/nio/internal/FileLockImpl.java | 73 - .../apache/harmony/nio/internal/IOUtil.java | 238 - .../harmony/nio/internal/LockManager.java | 80 - .../nio/internal/MappedByteBufferFactory.java | 60 - .../apache/harmony/nio/internal/PipeImpl.java | 194 - .../nio/internal/ReadOnlyFileChannel.java | 110 - .../nio/internal/ReadWriteFileChannel.java | 55 - .../nio/internal/SelectionKeyImpl.java | 94 - .../harmony/nio/internal/SelectorImpl.java | 407 - .../nio/internal/SelectorProviderImpl.java | 82 - .../nio/internal/ServerSocketChannelImpl.java | 301 - .../nio/internal/SocketChannelImpl.java | 1096 --- .../nio/internal/WriteOnlyFileChannel.java | 115 - .../harmony/nio/internal/nls/Messages.java | 143 - .../nio/internal/nls/messages.properties | 28 - .../org_apache_harmony_nio_AddressUtil.cpp | 73 - libcore/nio/src/main/native/sub.mk | 16 - .../tests/java/nio/AbstractBufferTest.java | 392 - .../harmony/nio/tests/java/nio/AllTests.java | 94 - .../java/nio/BufferOverflowExceptionTest.java | 95 - .../nio/BufferUnderflowExceptionTest.java | 98 - .../nio/tests/java/nio/ByteBufferTest.java | 2822 ------- .../nio/tests/java/nio/ByteOrderTest.java | 61 - .../nio/tests/java/nio/CharBufferTest.java | 1577 ---- .../tests/java/nio/DirectByteBufferTest.java | 113 - .../tests/java/nio/DirectCharBufferTest.java | 97 - .../java/nio/DirectDoubleBufferTest.java | 96 - .../tests/java/nio/DirectFloatBufferTest.java | 97 - .../tests/java/nio/DirectIntBufferTest.java | 166 - .../tests/java/nio/DirectLongBufferTest.java | 97 - .../tests/java/nio/DirectShortBufferTest.java | 167 - .../nio/tests/java/nio/DoubleBufferTest.java | 960 --- .../nio/DuplicateDirectByteBufferTest.java | 33 - .../java/nio/DuplicateHeapByteBufferTest.java | 34 - .../nio/DuplicateWrappedByteBufferTest.java | 34 - .../nio/tests/java/nio/FloatBufferTest.java | 981 --- .../tests/java/nio/HeapByteBufferTest.java | 53 - .../tests/java/nio/HeapCharBufferTest.java | 48 - .../tests/java/nio/HeapDoubleBufferTest.java | 48 - .../tests/java/nio/HeapFloatBufferTest.java | 48 - .../nio/tests/java/nio/HeapIntBufferTest.java | 48 - .../tests/java/nio/HeapLongBufferTest.java | 48 - .../tests/java/nio/HeapShortBufferTest.java | 48 - .../nio/tests/java/nio/IntBufferTest.java | 954 --- .../java/nio/InvalidMarkExceptionTest.java | 77 - .../nio/tests/java/nio/LongBufferTest.java | 936 --- .../tests/java/nio/MappedByteBufferTest.java | 194 - .../java/nio/ReadOnlyBufferExceptionTest.java | 94 - .../java/nio/ReadOnlyCharBufferTest.java | 289 - .../nio/ReadOnlyDirectByteBufferTest.java | 56 - .../java/nio/ReadOnlyDoubleBufferTest.java | 231 - .../java/nio/ReadOnlyFloatBufferTest.java | 232 - .../java/nio/ReadOnlyHeapByteBufferTest.java | 103 - .../java/nio/ReadOnlyHeapCharBufferTest.java | 31 - .../nio/ReadOnlyHeapDoubleBufferTest.java | 31 - .../java/nio/ReadOnlyHeapFloatBufferTest.java | 30 - .../java/nio/ReadOnlyHeapIntBufferTest.java | 30 - .../java/nio/ReadOnlyHeapLongBufferTest.java | 30 - .../java/nio/ReadOnlyHeapShortBufferTest.java | 30 - .../tests/java/nio/ReadOnlyIntBufferTest.java | 232 - .../java/nio/ReadOnlyLongBufferTest.java | 232 - .../java/nio/ReadOnlyShortBufferTest.java | 232 - .../nio/ReadOnlyWrappedByteBufferTest.java | 105 - .../nio/ReadOnlyWrappedCharBufferTest1.java | 38 - .../nio/ReadOnlyWrappedDoubleBufferTest.java | 37 - .../nio/ReadOnlyWrappedFloatBufferTest.java | 37 - .../nio/ReadOnlyWrappedIntBufferTest.java | 37 - .../nio/ReadOnlyWrappedLongBufferTest.java | 37 - .../nio/ReadOnlyWrappedShortBufferTest.java | 37 - .../nio/tests/java/nio/ShortBufferTest.java | 947 --- .../java/nio/SliceDirectByteBufferTest.java | 35 - .../java/nio/SliceHeapByteBufferTest.java | 36 - .../java/nio/SliceWrappedByteBufferTest.java | 36 - .../tests/java/nio/WrappedByteBufferTest.java | 96 - .../java/nio/WrappedCharBufferTest1.java | 94 - .../java/nio/WrappedCharBufferTest2.java | 185 - .../java/nio/WrappedDoubleBufferTest.java | 97 - .../java/nio/WrappedFloatBufferTest.java | 97 - .../tests/java/nio/WrappedIntBufferTest.java | 97 - .../tests/java/nio/WrappedLongBufferTest.java | 97 - .../java/nio/WrappedShortBufferTest.java | 97 - .../nio/tests/java/nio/channels/AllTests.java | 66 - .../AlreadyConnectedExceptionTest.java | 78 - .../AsynchronousCloseExceptionTest.java | 78 - .../channels/CancelledKeyExceptionTest.java | 78 - .../tests/java/nio/channels/ChannelsTest.java | 1141 --- .../ClosedByInterruptExceptionTest.java | 78 - .../channels/ClosedChannelExceptionTest.java | 78 - .../channels/ClosedSelectorExceptionTest.java | 78 - .../ConnectionPendingExceptionTest.java | 78 - .../nio/channels/DatagramChannelTest.java | 4811 ------------ .../java/nio/channels/FileChannelTest.java | 4670 ----------- .../FileLockInterruptionExceptionTest.java | 79 - .../tests/java/nio/channels/FileLockTest.java | 278 - .../IllegalBlockingModeExceptionTest.java | 79 - .../IllegalSelectorExceptionTest.java | 78 - .../tests/java/nio/channels/MapModeTest.java | 69 - .../nio/channels/MockDatagramChannel.java | 81 - .../nio/channels/MockSecurityManager.java | 69 - .../nio/channels/MockServerSocketChannel.java | 46 - .../java/nio/channels/MockSocketChannel.java | 75 - .../NoConnectionPendingExceptionTest.java | 79 - .../NonReadableChannelExceptionTest.java | 78 - .../NonWritableChannelExceptionTest.java | 78 - .../channels/NotYetBoundExceptionTest.java | 78 - .../NotYetConnectedExceptionTest.java | 78 - .../OverlappingFileLockExceptionTest.java | 79 - .../nio/tests/java/nio/channels/PipeTest.java | 87 - .../nio/channels/SelectableChannelTest.java | 110 - .../java/nio/channels/SelectionKeyTest.java | 463 -- .../tests/java/nio/channels/SelectorTest.java | 672 -- .../nio/channels/ServerSocketChannelTest.java | 888 --- .../java/nio/channels/SinkChannelTest.java | 751 -- .../java/nio/channels/SocketChannelTest.java | 4289 ---------- .../java/nio/channels/SourceChannelTest.java | 721 -- .../UnresolvedAddressExceptionTest.java | 78 - .../UnsupportedAddressTypeExceptionTest.java | 79 - .../spi/AbstractInterruptibleChannelTest.java | 199 - .../spi/AbstractSelectableChannelTest.java | 428 - .../spi/AbstractSelectionKeyTest.java | 104 - .../channels/spi/AbstractSelectorTest.java | 281 - .../tests/java/nio/channels/spi/AllTests.java | 37 - .../channels/spi/MockAbstractSelector.java | 134 - .../channels/spi/SelectorProviderTest.java | 203 - .../nio/src/test/java/tests/nio/AllTests.java | 40 - .../BufferOverflowExceptionTest.golden.ser | Bin 1283 -> 0 bytes .../BufferUnderflowExceptionTest.golden.ser | Bin 1369 -> 0 bytes .../nio/InvalidMarkExceptionTest.golden.ser | Bin 1403 -> 0 bytes .../ReadOnlyBufferExceptionTest.golden.ser | Bin 1420 -> 0 bytes .../AlreadyConnectedExceptionTest.golden.ser | Bin 1427 -> 0 bytes .../AsynchronousCloseExceptionTest.golden.ser | Bin 1441 -> 0 bytes .../CancelledKeyExceptionTest.golden.ser | Bin 1424 -> 0 bytes .../ClosedByInterruptExceptionTest.golden.ser | Bin 1500 -> 0 bytes .../ClosedChannelExceptionTest.golden.ser | Bin 1374 -> 0 bytes .../ClosedSelectorExceptionTest.golden.ser | Bin 1430 -> 0 bytes .../ConnectionPendingExceptionTest.golden.ser | Bin 1439 -> 0 bytes ...leLockInterruptionExceptionTest.golden.ser | Bin 1395 -> 0 bytes ...llegalBlockingModeExceptionTest.golden.ser | Bin 1743 -> 0 bytes .../IllegalSelectorExceptionTest.golden.ser | Bin 1734 -> 0 bytes ...oConnectionPendingExceptionTest.golden.ser | Bin 1445 -> 0 bytes ...NonReadableChannelExceptionTest.golden.ser | Bin 1442 -> 0 bytes ...NonWritableChannelExceptionTest.golden.ser | Bin 1442 -> 0 bytes .../NotYetBoundExceptionTest.golden.ser | Bin 1719 -> 0 bytes .../NotYetConnectedExceptionTest.golden.ser | Bin 1731 -> 0 bytes ...verlappingFileLockExceptionTest.golden.ser | Bin 1743 -> 0 bytes .../UnresolvedAddressExceptionTest.golden.ser | Bin 1740 -> 0 bytes ...pportedAddressTypeExceptionTest.golden.ser | Bin 1755 -> 0 bytes libcore/nio_char/MODULE_LICENSE_APACHE2 | 0 .../nio/charset/CharacterCodingException.java | 44 - .../main/java/java/nio/charset/Charset.java | 910 --- .../java/java/nio/charset/CharsetDecoder.java | 789 -- .../java/java/nio/charset/CharsetEncoder.java | 840 -- .../nio/charset/CoderMalfunctionError.java | 44 - .../java/java/nio/charset/CoderResult.java | 312 - .../java/nio/charset/CodingErrorAction.java | 74 - .../charset/IllegalCharsetNameException.java | 62 - .../nio/charset/MalformedInputException.java | 70 - .../charset/UnmappableCharacterException.java | 70 - .../charset/UnsupportedCharsetException.java | 61 - .../main/java/java/nio/charset/package.html | 15 - .../java/nio/charset/spi/CharsetProvider.java | 67 - .../java/java/nio/charset/spi/package.html | 8 - .../niochar/internal/nls/Messages.java | 148 - .../niochar/internal/nls/messages.properties | 32 - .../nio/charset/ASCIICharsetEncoderTest.java | 620 -- .../tests/java/nio/charset/AllTests.java | 45 - .../charset/CharacterCodingExceptionTest.java | 77 - .../java/nio/charset/CharsetDecoderTest.java | 274 - .../java/nio/charset/CharsetEncoderTest.java | 206 - .../tests/java/nio/charset/CharsetTest.java | 333 - .../charset/CoderMalfunctionErrorTest.java | 92 - .../IllegalCharsetNameExceptionTest.java | 126 - .../charset/MalformedInputExceptionTest.java | 123 - .../UnmappableCharacterExceptionTest.java | 124 - .../UnsupportedCharsetExceptionTest.java | 125 - .../tests/java/nio/charset/spi/AllTests.java | 36 - .../nio/charset/spi/CharsetProviderTest.java | 105 - .../nio/charset/ASCCharsetDecoderTest.java | 76 - .../api/java/nio/charset/ASCCharsetTest.java | 77 - .../AbstractCharsetDecoderTestCase.java | 762 -- .../AbstractCharsetEncoderTestCase.java | 1048 --- .../nio/charset/AbstractCharsetTestCase.java | 206 - .../tests/api/java/nio/charset/AllTests.java | 119 - .../java/nio/charset/CharsetDecoderTest.java | 292 - .../CharsetEncoderDecoderBufferTest.java | 182 - .../java/nio/charset/CharsetEncoderTest.java | 593 -- .../java/nio/charset/CharsetProviderTest.java | 608 -- .../api/java/nio/charset/CharsetTest.java | 1249 --- .../nio/charset/Charset_AbstractTest.java | 343 - .../api/java/nio/charset/Charset_GSM0338.java | 69 - .../java/nio/charset/Charset_ISO_8859_10.java | 66 - .../java/nio/charset/Charset_ISO_8859_14.java | 80 - .../java/nio/charset/Charset_ISO_8859_16.java | 66 - .../java/nio/charset/Charset_MultiByte_.java | 54 - .../nio/charset/Charset_MultiByte_Big5.java | 436 -- .../Charset_MultiByte_Big5_Android.java | 305 - .../nio/charset/Charset_MultiByte_EUC_JP.java | 541 -- .../Charset_MultiByte_EUC_JP_Android.java | 535 -- .../nio/charset/Charset_MultiByte_EUC_KR.java | 493 -- .../nio/charset/Charset_MultiByte_GB2312.java | 223 - .../nio/charset/Charset_MultiByte_GBK.java | 526 -- .../Charset_MultiByte_GBK_Android.java | 517 -- .../Charset_MultiByte_ISO_2022_JP.java | 405 - .../nio/charset/Charset_MultiByte_UTF_16.java | 397 - .../charset/Charset_MultiByte_UTF_16BE.java | 394 - .../charset/Charset_MultiByte_UTF_16LE.java | 394 - .../Charset_MultiByte_UTF_16_Android.java | 378 - .../nio/charset/Charset_MultiByte_UTF_8.java | 482 -- .../Charset_MultiByte_x_windows_950.java | 271 - .../Charset_SingleByteAbstractTest.java | 217 - .../java/nio/charset/Charset_SingleByte_.java | 43 - .../charset/Charset_SingleByte_IBM864.java | 90 - .../Charset_SingleByte_ISO_8859_1.java | 58 - .../Charset_SingleByte_ISO_8859_11.java | 62 - .../Charset_SingleByte_ISO_8859_13.java | 58 - .../Charset_SingleByte_ISO_8859_15.java | 58 - .../Charset_SingleByte_ISO_8859_2.java | 58 - .../Charset_SingleByte_ISO_8859_3.java | 110 - .../Charset_SingleByte_ISO_8859_4.java | 58 - .../Charset_SingleByte_ISO_8859_5.java | 58 - .../Charset_SingleByte_ISO_8859_6.java | 58 - .../Charset_SingleByte_ISO_8859_7.java | 58 - .../Charset_SingleByte_ISO_8859_8.java | 58 - .../Charset_SingleByte_ISO_8859_9.java | 58 - .../charset/Charset_SingleByte_KOI8_R.java | 58 - .../charset/Charset_SingleByte_US_ASCII.java | 58 - .../Charset_SingleByte_windows_1250.java | 58 - .../Charset_SingleByte_windows_1251.java | 58 - .../Charset_SingleByte_windows_1252.java | 58 - .../Charset_SingleByte_windows_1253.java | 58 - .../Charset_SingleByte_windows_1254.java | 58 - .../Charset_SingleByte_windows_1255.java | 58 - .../Charset_SingleByte_windows_1256.java | 58 - .../Charset_SingleByte_windows_1257.java | 58 - .../Charset_SingleByte_windows_1258.java | 58 - .../charset/Charset_SingleByte_x_IBM874.java | 54 - .../nio/charset/Charset_TestGenerator.java | 267 - .../charset/Charset_TestGenerator_Res.java | 2683 ------- .../java/nio/charset/Charset_macintosh.java | 78 - .../api/java/nio/charset/CoderResultTest.java | 492 -- .../nio/charset/CodingErrorActionTest.java | 79 - .../nio/charset/GBCharsetDecoderTest.java | 67 - .../nio/charset/GBCharsetEncoderTest.java | 125 - .../nio/charset/ISOCharsetDecoderTest.java | 65 - .../nio/charset/ISOCharsetEncoderTest.java | 178 - .../api/java/nio/charset/ISOCharsetTest.java | 79 - .../charset/UTF16BECharsetDecoderTest.java | 78 - .../charset/UTF16BECharsetEncoderTest.java | 166 - .../java/nio/charset/UTF16BECharsetTest.java | 72 - .../nio/charset/UTF16CharsetDecoderTest.java | 178 - .../nio/charset/UTF16CharsetEncoderTest.java | 196 - .../java/nio/charset/UTF16CharsetTest.java | 70 - .../charset/UTF16LECharsetDecoderTest.java | 80 - .../charset/UTF16LECharsetEncoderTest.java | 168 - .../java/nio/charset/UTF16LECharsetTest.java | 73 - .../api/java/nio/charset/UTF8CharsetTest.java | 72 - .../nio/charset/UTFCharsetDecoderTest.java | 67 - .../nio/charset/UTFCharsetEncoderTest.java | 140 - .../test/java/tests/nio_char/AllTests.java | 40 - .../test/resources/jars/charset_provider.jar | Bin 463 -> 0 bytes .../CharacterCodingExceptionTest.golden.ser | Bin 1822 -> 0 bytes .../CoderMalfunctionErrorTest.golden.ser | Bin 1771 -> 0 bytes ...IllegalCharsetNameExceptionTest.golden.ser | Bin 1924 -> 0 bytes .../MalformedInputExceptionTest.golden.ser | Bin 1893 -> 0 bytes ...nmappableCharacterExceptionTest.golden.ser | Bin 1908 -> 0 bytes ...UnsupportedCharsetExceptionTest.golden.ser | Bin 1924 -> 0 bytes .../src/main/java/org/openssl/NativeBN.java | 184 - libcore/openssl/src/main/native/BNInterface.c | 878 --- libcore/openssl/src/main/native/sub.mk | 18 - libcore/prefs/MODULE_LICENSE_APACHE2 | 0 .../java/util/prefs/AbstractPreferences.java | 947 --- .../util/prefs/BackingStoreException.java | 51 - .../prefs/FilePreferencesFactoryImpl.java | 44 - .../java/util/prefs/FilePreferencesImpl.java | 237 - .../InvalidPreferencesFormatException.java | 63 - .../java/java/util/prefs/NodeChangeEvent.java | 94 - .../java/util/prefs/NodeChangeListener.java | 49 - .../main/java/java/util/prefs/NodeSet.java | 38 - .../util/prefs/PreferenceChangeEvent.java | 112 - .../util/prefs/PreferenceChangeListener.java | 43 - .../java/java/util/prefs/Preferences.java | 1004 --- .../java/util/prefs/PreferencesFactory.java | 43 - .../main/java/java/util/prefs/XMLParser.java | 626 -- .../main/java/java/util/prefs/package.html | 14 - .../harmony/prefs/internal/nls/Messages.java | 140 - .../prefs/internal/nls/messages.properties | 33 - .../java.util.prefs.PreferencesFactory | 1 - .../util/prefs/AbstractPreferencesTest.java | 1491 ---- .../prefs/tests/java/util/prefs/AllTests.java | 48 - .../util/prefs/BackingStoreExceptionTest.java | 96 - .../util/prefs/FilePreferencesImplTest.java | 330 - ...InvalidPreferencesFormatExceptionTest.java | 119 - .../util/prefs/MockAbstractPreferences.java | 254 - .../util/prefs/MockNodeChangeListener.java | 132 - .../prefs/MockPreferenceChangeListener.java | 118 - .../java/util/prefs/MockSecurityManager.java | 62 - .../java/util/prefs/NodeChangeEventTest.java | 168 - .../util/prefs/NodeChangeListenerTest.java | 92 - .../util/prefs/PreferenceChangeEventTest.java | 199 - .../prefs/PreferenceChangeListenerTest.java | 65 - .../util/prefs/PreferencesFactoryTest.java | 78 - .../java/util/prefs/PreferencesTest.java | 1999 ----- .../src/test/java/tests/prefs/AllTests.java | 39 - .../prefs/java/util/prefs/userprefs-ascii.xml | 63 - .../java/util/prefs/userprefs-badencoding.xml | 64 - .../java/util/prefs/userprefs-badform.xml | 54 - .../java/util/prefs/userprefs-badtype.xml | 64 - .../util/prefs/userprefs-higherversion.xml | 64 - .../prefs/java/util/prefs/userprefs.xml | 76 - .../BackingStoreExceptionTest.golden.ser | Bin 1547 -> 0 bytes ...dPreferencesFormatExceptionTest.golden.ser | Bin 1583 -> 0 bytes libcore/regex/MODULE_LICENSE_APACHE2 | 0 .../java/java/util/regex/MatchResult.java | 112 - .../java/java/util/regex/MatchResultImpl.java | 79 - .../main/java/java/util/regex/Matcher.java | 779 -- .../main/java/java/util/regex/Pattern.java | 486 -- .../util/regex/PatternSyntaxException.java | 146 - .../main/java/java/util/regex/package.html | 884 --- .../regex/tests/java/util/regex/AllTests.java | 49 - .../tests/java/util/regex/Matcher2Test.java | 327 - .../tests/java/util/regex/MatcherTest.java | 1471 ---- .../regex/tests/java/util/regex/ModeTest.java | 150 - .../tests/java/util/regex/Pattern2Test.java | 1755 ----- .../java/util/regex/PatternErrorTest.java | 103 - .../regex/PatternSyntaxExceptionTest.java | 122 - .../tests/java/util/regex/PatternTest.java | 2412 ------ .../tests/java/util/regex/ReplaceTest.java | 125 - .../tests/java/util/regex/SplitTest.java | 251 - .../src/test/java/tests/regex/AllTests.java | 38 - .../PatternSyntaxExceptionTest.golden.ser | Bin 1711 -> 0 bytes .../java/util/regex/PatternTest.golden.ser | Bin 94 -> 0 bytes libcore/run-core-tests | 30 - libcore/run-core-tests-on-ri | 23 - .../security-kernel/MODULE_LICENSE_APACHE2 | 0 .../java/security/AccessControlContext.java | 284 - .../java/java/security/AccessController.java | 374 - libcore/security/MODULE_LICENSE_APACHE2 | 1 - libcore/security/MODULE_LICENSE_BSD_LIKE | 1 - libcore/security/bouncycastle-license.txt | 21 - libcore/security/src/main/files/cacerts.bks | Bin 55715 -> 0 bytes .../src/main/files/cacerts/03e16f6c.0 | 28 - .../src/main/files/cacerts/111e6273.0 | 86 - .../src/main/files/cacerts/1155c94b.0 | 87 - .../src/main/files/cacerts/17b51fe6.0 | 85 - .../src/main/files/cacerts/1dac3003.0 | 28 - .../src/main/files/cacerts/1dbdda5b.0 | 22 - .../src/main/files/cacerts/1dcd6f4c.0 | 121 - .../src/main/files/cacerts/219d9499.0 | 84 - .../src/main/files/cacerts/23f4c490.0 | 84 - .../src/main/files/cacerts/256fd83b.0 | 63 - .../src/main/files/cacerts/399e7759.0 | 83 - .../src/main/files/cacerts/3c58f906.0 | 87 - .../src/main/files/cacerts/3e7271e8.0 | 85 - .../src/main/files/cacerts/4d654d1d.0 | 49 - .../src/main/files/cacerts/4e18c148.0 | 26 - .../src/main/files/cacerts/4fbd6bfa.0 | 89 - .../src/main/files/cacerts/54edfa5d.0 | 63 - .../src/main/files/cacerts/594f1775.0 | 70 - .../src/main/files/cacerts/5a5372fc.0 | 74 - .../src/main/files/cacerts/5cf9d536.0 | 104 - .../src/main/files/cacerts/635ccfd5.0 | 74 - .../src/main/files/cacerts/69105f4f.0 | 83 - .../src/main/files/cacerts/6e8bf996.0 | 72 - .../src/main/files/cacerts/72fa7371.0 | 54 - .../src/main/files/cacerts/74c26bd0.0 | 60 - .../src/main/files/cacerts/7651b327.0 | 49 - .../src/main/files/cacerts/7a819ef2.0 | 125 - .../src/main/files/cacerts/7d3cd826.0 | 52 - .../src/main/files/cacerts/81b9768f.0 | 84 - .../src/main/files/cacerts/9339512a.0 | 136 - .../src/main/files/cacerts/97b4211c.0 | 47 - .../src/main/files/cacerts/a3896b44.0 | 77 - .../src/main/files/cacerts/a7605362.0 | 76 - .../src/main/files/cacerts/ab86d4de.0 | 104 - .../src/main/files/cacerts/add67345.0 | 96 - .../src/main/files/cacerts/b0f3e76e.0 | 78 - .../src/main/files/cacerts/bcdd5959.0 | 52 - .../src/main/files/cacerts/bda4cc84.0 | 82 - .../src/main/files/cacerts/bf64f35b.0 | 92 - .../src/main/files/cacerts/c33a80d4.0 | 56 - .../src/main/files/cacerts/cb796bc1.0 | 90 - .../src/main/files/cacerts/cdaebb72.0 | 83 - .../src/main/files/cacerts/d537fba6.0 | 94 - .../src/main/files/cacerts/d777342d.0 | 23 - .../src/main/files/cacerts/d8274e24.0 | 87 - .../src/main/files/cacerts/ddc328ff.0 | 56 - .../src/main/files/cacerts/e60bf0c0.0 | 128 - .../src/main/files/cacerts/e7b8d656.0 | 60 - .../src/main/files/cacerts/ed524cf5.0 | 83 - .../src/main/files/cacerts/ee7cd6fb.0 | 98 - .../src/main/files/cacerts/f4996e82.0 | 52 - .../src/main/files/cacerts/f64d9715.0 | 51 - .../src/main/files/cacerts/f73e89fd.0 | 48 - .../src/main/files/cacerts/ff783690.0 | 89 - libcore/security/src/main/files/certimport.sh | 41 - .../java/security/AccessControlException.java | 74 - .../security/AlgorithmParameterGenerator.java | 261 - .../AlgorithmParameterGeneratorSpi.java | 80 - .../java/security/AlgorithmParameters.java | 341 - .../java/security/AlgorithmParametersSpi.java | 136 - .../java/java/security/AllPermission.java | 130 - .../security/AllPermissionCollection.java | 140 - .../main/java/java/security/AuthProvider.java | 120 - .../java/java/security/BasicPermission.java | 225 - .../security/BasicPermissionCollection.java | 212 - .../main/java/java/security/Certificate.java | 129 - .../main/java/java/security/CodeSigner.java | 154 - .../main/java/java/security/CodeSource.java | 648 -- .../java/java/security/DigestException.java | 79 - .../java/java/security/DigestInputStream.java | 165 - .../java/security/DigestOutputStream.java | 146 - .../java/java/security/DomainCombiner.java | 54 - .../security/GeneralSecurityException.java | 80 - .../src/main/java/java/security/Guard.java | 44 - .../java/java/security/GuardedObject.java | 85 - .../src/main/java/java/security/Identity.java | 461 -- .../java/java/security/IdentityScope.java | 227 - .../InvalidAlgorithmParameterException.java | 81 - .../java/security/InvalidKeyException.java | 79 - .../security/InvalidParameterException.java | 54 - .../src/main/java/java/security/Key.java | 72 - .../main/java/java/security/KeyException.java | 77 - .../main/java/java/security/KeyFactory.java | 245 - .../java/java/security/KeyFactorySpi.java | 95 - .../java/security/KeyManagementException.java | 81 - .../src/main/java/java/security/KeyPair.java | 75 - .../java/java/security/KeyPairGenerator.java | 316 - .../java/security/KeyPairGeneratorSpi.java | 83 - .../src/main/java/java/security/KeyRep.java | 194 - .../src/main/java/java/security/KeyStore.java | 1555 ---- .../java/java/security/KeyStoreException.java | 80 - .../main/java/java/security/KeyStoreSpi.java | 562 -- .../java/java/security/MessageDigest.java | 442 -- .../java/java/security/MessageDigestSpi.java | 167 - .../security/NoSuchAlgorithmException.java | 80 - .../security/NoSuchProviderException.java | 54 - .../main/java/java/security/Permission.java | 176 - .../java/security/PermissionCollection.java | 136 - .../main/java/java/security/Permissions.java | 251 - .../java/java/security/PermissionsHash.java | 91 - .../src/main/java/java/security/Policy.java | 256 - .../main/java/java/security/Principal.java | 75 - .../main/java/java/security/PrivateKey.java | 39 - .../java/java/security/PrivilegedAction.java | 45 - .../security/PrivilegedActionException.java | 101 - .../security/PrivilegedExceptionAction.java | 48 - .../java/java/security/ProtectionDomain.java | 286 - .../src/main/java/java/security/Provider.java | 1182 --- .../java/java/security/ProviderException.java | 80 - .../main/java/java/security/PublicKey.java | 39 - .../java/java/security/SecureClassLoader.java | 177 - .../main/java/java/security/SecureRandom.java | 361 - .../java/java/security/SecureRandomSpi.java | 69 - .../src/main/java/java/security/Security.java | 580 -- .../java/security/SecurityPermission.java | 61 - .../main/java/java/security/Signature.java | 725 -- .../java/security/SignatureException.java | 80 - .../main/java/java/security/SignatureSpi.java | 346 - .../main/java/java/security/SignedObject.java | 169 - .../src/main/java/java/security/Signer.java | 162 - .../main/java/java/security/Timestamp.java | 154 - .../security/UnrecoverableEntryException.java | 57 - .../security/UnrecoverableKeyException.java | 55 - .../java/security/UnresolvedPermission.java | 412 - .../UnresolvedPermissionCollection.java | 204 - .../src/main/java/java/security/acl/Acl.java | 183 - .../main/java/java/security/acl/AclEntry.java | 135 - .../security/acl/AclNotFoundException.java | 39 - .../main/java/java/security/acl/Group.java | 70 - .../java/security/acl/LastOwnerException.java | 39 - .../java/security/acl/NotOwnerException.java | 41 - .../main/java/java/security/acl/Owner.java | 73 - .../java/java/security/acl/Permission.java | 50 - .../main/java/java/security/acl/package.html | 15 - .../src/main/java/java/security/cert/CRL.java | 71 - .../java/java/security/cert/CRLException.java | 78 - .../java/java/security/cert/CRLSelector.java | 53 - .../java/java/security/cert/CertPath.java | 256 - .../java/security/cert/CertPathBuilder.java | 225 - .../cert/CertPathBuilderException.java | 75 - .../security/cert/CertPathBuilderResult.java | 43 - .../security/cert/CertPathBuilderSpi.java | 53 - .../security/cert/CertPathParameters.java | 37 - .../java/security/cert/CertPathValidator.java | 232 - .../cert/CertPathValidatorException.java | 153 - .../cert/CertPathValidatorResult.java | 36 - .../security/cert/CertPathValidatorSpi.java | 60 - .../java/java/security/cert/CertSelector.java | 58 - .../java/java/security/cert/CertStore.java | 303 - .../security/cert/CertStoreException.java | 74 - .../security/cert/CertStoreParameters.java | 35 - .../java/java/security/cert/CertStoreSpi.java | 76 - .../java/java/security/cert/Certificate.java | 273 - .../cert/CertificateEncodingException.java | 75 - .../security/cert/CertificateException.java | 74 - .../cert/CertificateExpiredException.java | 48 - .../security/cert/CertificateFactory.java | 337 - .../security/cert/CertificateFactorySpi.java | 173 - .../cert/CertificateNotYetValidException.java | 49 - .../cert/CertificateParsingException.java | 74 - .../cert/CollectionCertStoreParameters.java | 112 - .../cert/LDAPCertStoreParameters.java | 135 - .../security/cert/PKIXBuilderParameters.java | 142 - .../cert/PKIXCertPathBuilderResult.java | 88 - .../security/cert/PKIXCertPathChecker.java | 127 - .../cert/PKIXCertPathValidatorResult.java | 133 - .../java/security/cert/PKIXParameters.java | 655 -- .../java/java/security/cert/PolicyNode.java | 95 - .../security/cert/PolicyQualifierInfo.java | 126 - .../java/java/security/cert/TrustAnchor.java | 297 - .../main/java/java/security/cert/X509CRL.java | 302 - .../java/java/security/cert/X509CRLEntry.java | 139 - .../java/security/cert/X509CRLSelector.java | 501 -- .../java/security/cert/X509CertSelector.java | 1518 ---- .../java/security/cert/X509Certificate.java | 489 -- .../java/security/cert/X509Extension.java | 72 - .../main/java/java/security/cert/package.html | 23 - .../java/java/security/interfaces/DSAKey.java | 37 - .../interfaces/DSAKeyPairGenerator.java | 72 - .../java/security/interfaces/DSAParams.java | 54 - .../security/interfaces/DSAPrivateKey.java | 45 - .../security/interfaces/DSAPublicKey.java | 45 - .../java/java/security/interfaces/ECKey.java | 36 - .../security/interfaces/ECPrivateKey.java | 44 - .../java/security/interfaces/ECPublicKey.java | 44 - .../java/java/security/interfaces/RSAKey.java | 36 - .../RSAMultiPrimePrivateCrtKey.java | 95 - .../security/interfaces/RSAPrivateCrtKey.java | 83 - .../security/interfaces/RSAPrivateKey.java | 44 - .../security/interfaces/RSAPublicKey.java | 45 - .../java/security/interfaces/package.html | 15 - .../src/main/java/java/security/package.html | 36 - .../java/java/security/security.properties | 120 - .../security/spec/AlgorithmParameterSpec.java | 27 - .../java/security/spec/DSAParameterSpec.java | 82 - .../java/security/spec/DSAPrivateKeySpec.java | 98 - .../java/security/spec/DSAPublicKeySpec.java | 98 - .../main/java/java/security/spec/ECField.java | 34 - .../java/java/security/spec/ECFieldF2m.java | 279 - .../java/java/security/spec/ECFieldFp.java | 104 - .../security/spec/ECGenParameterSpec.java | 57 - .../java/security/spec/ECParameterSpec.java | 122 - .../main/java/java/security/spec/ECPoint.java | 127 - .../java/security/spec/ECPrivateKeySpec.java | 76 - .../java/security/spec/ECPublicKeySpec.java | 81 - .../java/security/spec/EllipticCurve.java | 218 - .../java/security/spec/EncodedKeySpec.java | 68 - .../spec/InvalidKeySpecException.java | 80 - .../spec/InvalidParameterSpecException.java | 56 - .../main/java/java/security/spec/KeySpec.java | 27 - .../java/security/spec/MGF1ParameterSpec.java | 98 - .../security/spec/PKCS8EncodedKeySpec.java | 62 - .../java/security/spec/PSSParameterSpec.java | 171 - .../security/spec/RSAKeyGenParameterSpec.java | 82 - .../spec/RSAMultiPrimePrivateCrtKeySpec.java | 216 - .../java/security/spec/RSAOtherPrimeInfo.java | 100 - .../security/spec/RSAPrivateCrtKeySpec.java | 148 - .../java/security/spec/RSAPrivateKeySpec.java | 72 - .../java/security/spec/RSAPublicKeySpec.java | 71 - .../security/spec/X509EncodedKeySpec.java | 61 - .../main/java/java/security/spec/package.html | 19 - .../java/javax/security/cert/Certificate.java | 172 - .../cert/CertificateEncodingException.java | 56 - .../security/cert/CertificateException.java | 54 - .../cert/CertificateExpiredException.java | 54 - .../cert/CertificateNotYetValidException.java | 54 - .../cert/CertificateParsingException.java | 54 - .../javax/security/cert/X509Certificate.java | 424 - .../java/javax/security/cert/package.html | 15 - .../security/DefaultPolicyScanner.java | 520 -- .../apache/harmony/security/PolicyEntry.java | 97 - .../harmony/security/PrivateKeyImpl.java | 66 - .../harmony/security/PublicKeyImpl.java | 72 - .../apache/harmony/security/SystemScope.java | 162 - .../harmony/security/UnresolvedPrincipal.java | 144 - .../apache/harmony/security/asn1/ASN1Any.java | 126 - .../harmony/security/asn1/ASN1BitString.java | 235 - .../harmony/security/asn1/ASN1Boolean.java | 104 - .../harmony/security/asn1/ASN1Choice.java | 356 - .../harmony/security/asn1/ASN1Constants.java | 96 - .../security/asn1/ASN1Constructured.java | 60 - .../harmony/security/asn1/ASN1Enumerated.java | 104 - .../harmony/security/asn1/ASN1Exception.java | 52 - .../harmony/security/asn1/ASN1Explicit.java | 110 - .../security/asn1/ASN1GeneralizedTime.java | 120 - .../harmony/security/asn1/ASN1Implicit.java | 172 - .../harmony/security/asn1/ASN1Integer.java | 140 - .../security/asn1/ASN1OctetString.java | 104 - .../apache/harmony/security/asn1/ASN1Oid.java | 222 - .../harmony/security/asn1/ASN1OpenType.java | 85 - .../harmony/security/asn1/ASN1Primitive.java | 57 - .../harmony/security/asn1/ASN1Sequence.java | 69 - .../harmony/security/asn1/ASN1SequenceOf.java | 94 - .../apache/harmony/security/asn1/ASN1Set.java | 72 - .../harmony/security/asn1/ASN1SetOf.java | 92 - .../harmony/security/asn1/ASN1StringType.java | 147 - .../harmony/security/asn1/ASN1Time.java | 64 - .../harmony/security/asn1/ASN1Type.java | 214 - .../security/asn1/ASN1TypeCollection.java | 98 - .../harmony/security/asn1/ASN1UTCTime.java | 124 - .../security/asn1/ASN1ValueCollection.java | 68 - .../harmony/security/asn1/BerInputStream.java | 996 --- .../security/asn1/BerOutputStream.java | 224 - .../harmony/security/asn1/BitString.java | 116 - .../harmony/security/asn1/DerInputStream.java | 201 - .../security/asn1/DerOutputStream.java | 258 - .../security/asn1/InformationObjectSet.java | 108 - .../security/asn1/ObjectIdentifier.java | 382 - .../security/fortress/DefaultPolicy.java | 311 - .../fortress/DefaultPolicyParser.java | 498 -- .../harmony/security/fortress/Engine.java | 142 - .../security/fortress/PolicyUtils.java | 588 -- .../security/fortress/SecurityAccess.java | 54 - .../security/fortress/SecurityUtils.java | 114 - .../harmony/security/fortress/Services.java | 256 - .../security/internal/nls/Messages.java | 143 - .../security/internal/nls/messages.properties | 345 - .../security/pkcs10/CertificationRequest.java | 129 - .../pkcs10/CertificationRequestInfo.java | 167 - .../pkcs7/AuthenticatedAttributes.java | 67 - .../harmony/security/pkcs7/ContentInfo.java | 161 - .../harmony/security/pkcs7/SignedData.java | 166 - .../harmony/security/pkcs7/SignerInfo.java | 222 - .../security/pkcs8/PrivateKeyInfo.java | 154 - .../harmony/security/provider/cert/Cache.java | 339 - .../provider/cert/DRLCertFactory.java | 67 - .../provider/cert/X509CRLEntryImpl.java | 181 - .../security/provider/cert/X509CRLImpl.java | 508 -- .../provider/cert/X509CertFactoryImpl.java | 935 --- .../security/provider/cert/X509CertImpl.java | 660 -- .../provider/cert/X509CertPathImpl.java | 433 -- .../provider/crypto/CryptoProvider.java | 96 - .../provider/crypto/DSAKeyFactoryImpl.java | 229 - .../provider/crypto/DSAPrivateKeyImpl.java | 157 - .../provider/crypto/DSAPublicKeyImpl.java | 180 - .../provider/crypto/RandomBitsSupplier.java | 182 - .../security/provider/crypto/SHA1Impl.java | 247 - .../crypto/SHA1PRNG_SecureRandomImpl.java | 537 -- .../security/provider/crypto/SHA1_Data.java | 97 - .../crypto/SHA1_MessageDigestImpl.java | 325 - .../crypto/SHA1withDSA_SignatureImpl.java | 436 -- .../provider/crypto/ThreeIntegerSequence.java | 73 - .../harmony/security/utils/AlgNameMapper.java | 251 - .../apache/harmony/security/utils/Array.java | 107 - .../harmony/security/utils/JarUtils.java | 236 - .../security/utils/ObjectIdentifier.java | 222 - .../harmony/security/x501/AttributeType.java | 46 - .../security/x501/AttributeTypeAndValue.java | 544 -- .../x501/AttributeTypeAndValueComparator.java | 108 - .../harmony/security/x501/AttributeValue.java | 272 - .../harmony/security/x501/Attributes.java | 60 - .../security/x501/DirectoryString.java | 68 - .../apache/harmony/security/x501/Name.java | 265 - .../security/x509/AccessDescription.java | 121 - .../security/x509/AlgorithmIdentifier.java | 185 - .../security/x509/AlternativeName.java | 95 - .../security/x509/AuthorityKeyIdentifier.java | 143 - .../security/x509/BasicConstraints.java | 127 - .../security/x509/CRLDistributionPoints.java | 137 - .../harmony/security/x509/CRLNumber.java | 88 - .../harmony/security/x509/Certificate.java | 166 - .../security/x509/CertificateIssuer.java | 102 - .../security/x509/CertificateList.java | 162 - .../security/x509/CertificatePolicies.java | 151 - .../harmony/security/x509/DNParser.java | 468 -- .../security/x509/DistributionPoint.java | 145 - .../security/x509/DistributionPointName.java | 136 - .../harmony/security/x509/EDIPartyName.java | 136 - .../security/x509/ExtendedKeyUsage.java | 122 - .../harmony/security/x509/Extension.java | 456 -- .../harmony/security/x509/ExtensionValue.java | 75 - .../harmony/security/x509/Extensions.java | 419 - .../harmony/security/x509/GeneralName.java | 945 --- .../harmony/security/x509/GeneralNames.java | 181 - .../harmony/security/x509/GeneralSubtree.java | 178 - .../security/x509/GeneralSubtrees.java | 119 - .../security/x509/InfoAccessSyntax.java | 135 - .../security/x509/InhibitAnyPolicy.java | 85 - .../harmony/security/x509/InvalidityDate.java | 87 - .../x509/IssuingDistributionPoint.java | 240 - .../harmony/security/x509/KeyUsage.java | 116 - .../security/x509/NameConstraints.java | 327 - .../harmony/security/x509/ORAddress.java | 93 - .../harmony/security/x509/OtherName.java | 126 - .../security/x509/PolicyConstraints.java | 176 - .../security/x509/PolicyInformation.java | 118 - .../security/x509/PolicyQualifierInfo.java | 56 - .../security/x509/PrivateKeyUsagePeriod.java | 133 - .../harmony/security/x509/ReasonCode.java | 133 - .../harmony/security/x509/ReasonFlags.java | 112 - .../security/x509/SubjectKeyIdentifier.java | 83 - .../security/x509/SubjectPublicKeyInfo.java | 187 - .../harmony/security/x509/TBSCertList.java | 442 -- .../harmony/security/x509/TBSCertificate.java | 353 - .../apache/harmony/security/x509/Time.java | 65 - .../apache/harmony/security/x509/Utils.java | 51 - .../harmony/security/x509/Validity.java | 110 - .../harmony/security/x509/X509PublicKey.java | 58 - .../security/x509/tsp/MessageImprint.java | 65 - .../security/x509/tsp/PKIFailureInfo.java | 136 - .../harmony/security/x509/tsp/PKIStatus.java | 93 - .../security/x509/tsp/PKIStatusInfo.java | 141 - .../harmony/security/x509/tsp/TSTInfo.java | 306 - .../security/x509/tsp/TimeStampReq.java | 215 - .../security/x509/tsp/TimeStampResp.java | 96 - .../org/bouncycastle/asn1/ASN1Choice.java | 14 - .../org/bouncycastle/asn1/ASN1Collection.java | 298 - .../org/bouncycastle/asn1/ASN1Encodable.java | 81 - .../asn1/ASN1EncodableVector.java | 10 - .../bouncycastle/asn1/ASN1InputStream.java | 531 -- .../java/org/bouncycastle/asn1/ASN1Null.java | 40 - .../bouncycastle/asn1/ASN1OctetString.java | 147 - .../bouncycastle/asn1/ASN1OutputStream.java | 36 - .../org/bouncycastle/asn1/ASN1Sequence.java | 216 - .../java/org/bouncycastle/asn1/ASN1Set.java | 318 - .../bouncycastle/asn1/ASN1TaggedObject.java | 177 - .../asn1/BERConstructedOctetString.java | 172 - .../asn1/BERConstructedSequence.java | 37 - .../org/bouncycastle/asn1/BERInputStream.java | 209 - .../java/org/bouncycastle/asn1/BERNull.java | 35 - .../bouncycastle/asn1/BEROutputStream.java | 36 - .../org/bouncycastle/asn1/BERSequence.java | 59 - .../java/org/bouncycastle/asn1/BERSet.java | 69 - .../bouncycastle/asn1/BERTaggedObject.java | 119 - .../asn1/DERApplicationSpecific.java | 110 - .../org/bouncycastle/asn1/DERBMPString.java | 121 - .../org/bouncycastle/asn1/DERBitString.java | 289 - .../org/bouncycastle/asn1/DERBoolean.java | 132 - .../asn1/DERConstructedSequence.java | 53 - .../bouncycastle/asn1/DERConstructedSet.java | 79 - .../org/bouncycastle/asn1/DEREncodable.java | 6 - .../bouncycastle/asn1/DEREncodableVector.java | 30 - .../org/bouncycastle/asn1/DEREnumerated.java | 113 - .../bouncycastle/asn1/DERGeneralString.java | 87 - .../bouncycastle/asn1/DERGeneralizedTime.java | 202 - .../org/bouncycastle/asn1/DERIA5String.java | 123 - .../org/bouncycastle/asn1/DERInputStream.java | 276 - .../org/bouncycastle/asn1/DERInteger.java | 134 - .../java/org/bouncycastle/asn1/DERNull.java | 46 - .../bouncycastle/asn1/DERNumericString.java | 123 - .../java/org/bouncycastle/asn1/DERObject.java | 20 - .../asn1/DERObjectIdentifier.java | 293 - .../org/bouncycastle/asn1/DEROctetString.java | 29 - .../bouncycastle/asn1/DEROutputStream.java | 81 - .../bouncycastle/asn1/DERPrintableString.java | 134 - .../org/bouncycastle/asn1/DERSequence.java | 79 - .../java/org/bouncycastle/asn1/DERSet.java | 99 - .../java/org/bouncycastle/asn1/DERString.java | 9 - .../org/bouncycastle/asn1/DERT61String.java | 121 - .../bouncycastle/asn1/DERTaggedObject.java | 88 - .../java/org/bouncycastle/asn1/DERTags.java | 36 - .../org/bouncycastle/asn1/DERUTCTime.java | 193 - .../org/bouncycastle/asn1/DERUTF8String.java | 104 - .../bouncycastle/asn1/DERUniversalString.java | 115 - .../org/bouncycastle/asn1/DERUnknownTag.java | 86 - .../bouncycastle/asn1/DERVisibleString.java | 121 - .../org/bouncycastle/asn1/OIDTokenizer.java | 48 - .../org/bouncycastle/asn1/OrderedTable.java | 224 - .../bouncycastle/asn1/cmp/PKIFailureInfo.java | 104 - .../bouncycastle/asn1/cmp/PKIFreeText.java | 91 - .../org/bouncycastle/asn1/cmp/PKIStatus.java | 13 - .../bouncycastle/asn1/cmp/PKIStatusInfo.java | 164 - .../org/bouncycastle/asn1/cms/Attribute.java | 82 - .../bouncycastle/asn1/cms/AttributeTable.java | 173 - .../bouncycastle/asn1/cms/CMSAttributes.java | 12 - .../asn1/cms/CMSObjectIdentifiers.java | 15 - .../bouncycastle/asn1/cms/CompressedData.java | 110 - .../bouncycastle/asn1/cms/ContentInfo.java | 90 - .../asn1/cms/EncryptedContentInfo.java | 106 - .../bouncycastle/asn1/cms/EnvelopedData.java | 179 - .../asn1/cms/IssuerAndSerialNumber.java | 77 - .../bouncycastle/asn1/cms/KEKIdentifier.java | 139 - .../asn1/cms/KEKRecipientInfo.java | 121 - .../asn1/cms/KeyAgreeRecipientInfo.java | 151 - .../asn1/cms/KeyTransRecipientInfo.java | 114 - .../asn1/cms/OriginatorIdentifierOrKey.java | 104 - .../bouncycastle/asn1/cms/OriginatorInfo.java | 129 - .../asn1/cms/OriginatorPublicKey.java | 100 - .../asn1/cms/OtherKeyAttribute.java | 82 - .../asn1/cms/OtherRecipientInfo.java | 98 - .../asn1/cms/PasswordRecipientInfo.java | 143 - .../asn1/cms/RecipientIdentifier.java | 96 - .../bouncycastle/asn1/cms/RecipientInfo.java | 140 - .../asn1/cms/RecipientKeyIdentifier.java | 139 - .../org/bouncycastle/asn1/cms/SignedData.java | 215 - .../asn1/cms/SignerIdentifier.java | 96 - .../org/bouncycastle/asn1/cms/SignerInfo.java | 172 - .../java/org/bouncycastle/asn1/cms/Time.java | 114 - .../cryptopro/CryptoProObjectIdentifiers.java | 45 - .../asn1/esf/CommitmentTypeIdentifier.java | 14 - .../asn1/esf/CommitmentTypeIndication.java | 83 - .../asn1/esf/CommitmentTypeQualifier.java | 108 - .../bouncycastle/asn1/esf/ESFAttributes.java | 11 - .../bouncycastle/asn1/esf/SignerLocation.java | 146 - .../asn1/ess/ContentIdentifier.java | 65 - .../org/bouncycastle/asn1/ess/ESSCertID.java | 97 - .../bouncycastle/asn1/ess/OtherCertID.java | 138 - .../asn1/ess/OtherSigningCertificate.java | 111 - .../asn1/ess/SigningCertificate.java | 111 - .../asn1/gnu/GNUObjectIdentifiers.java | 30 - .../asn1/iana/IANAObjectIdentifiers.java | 20 - .../bouncycastle/asn1/icao/DataGroupHash.java | 100 - .../asn1/icao/ICAOObjectIdentifiers.java | 15 - .../asn1/icao/LDSSecurityObject.java | 125 - .../bouncycastle/asn1/misc/IDEACBCPar.java | 75 - .../asn1/misc/MiscObjectIdentifiers.java | 30 - .../asn1/misc/NetscapeCertType.java | 54 - .../asn1/misc/NetscapeRevocationURL.java | 18 - .../asn1/misc/VerisignCzagExtension.java | 18 - .../asn1/mozilla/PublicKeyAndChallenge.java | 63 - .../asn1/nist/NISTObjectIdentifiers.java | 48 - .../asn1/ocsp/BasicOCSPResponse.java | 112 - .../org/bouncycastle/asn1/ocsp/CertID.java | 105 - .../bouncycastle/asn1/ocsp/CertStatus.java | 111 - .../org/bouncycastle/asn1/ocsp/CrlID.java | 86 - .../asn1/ocsp/OCSPObjectIdentifiers.java | 22 - .../bouncycastle/asn1/ocsp/OCSPRequest.java | 90 - .../bouncycastle/asn1/ocsp/OCSPResponse.java | 92 - .../asn1/ocsp/OCSPResponseStatus.java | 40 - .../org/bouncycastle/asn1/ocsp/Request.java | 91 - .../bouncycastle/asn1/ocsp/ResponderID.java | 83 - .../bouncycastle/asn1/ocsp/ResponseBytes.java | 82 - .../bouncycastle/asn1/ocsp/ResponseData.java | 164 - .../bouncycastle/asn1/ocsp/RevokedInfo.java | 92 - .../asn1/ocsp/ServiceLocator.java | 36 - .../org/bouncycastle/asn1/ocsp/Signature.java | 111 - .../asn1/ocsp/SingleResponse.java | 143 - .../bouncycastle/asn1/ocsp/TBSRequest.java | 150 - .../asn1/oiw/OIWObjectIdentifiers.java | 26 - .../org/bouncycastle/asn1/pkcs/Attribute.java | 82 - .../asn1/pkcs/AuthenticatedSafe.java | 47 - .../org/bouncycastle/asn1/pkcs/CertBag.java | 53 - .../asn1/pkcs/CertificationRequest.java | 76 - .../asn1/pkcs/CertificationRequestInfo.java | 129 - .../bouncycastle/asn1/pkcs/ContentInfo.java | 90 - .../bouncycastle/asn1/pkcs/DHParameter.java | 88 - .../bouncycastle/asn1/pkcs/EncryptedData.java | 104 - .../asn1/pkcs/EncryptedPrivateKeyInfo.java | 86 - .../asn1/pkcs/EncryptionScheme.java | 38 - .../asn1/pkcs/IssuerAndSerialNumber.java | 76 - .../asn1/pkcs/KeyDerivationFunc.java | 23 - .../org/bouncycastle/asn1/pkcs/MacData.java | 89 - .../asn1/pkcs/PBES2Algorithms.java | 77 - .../asn1/pkcs/PBES2Parameters.java | 55 - .../bouncycastle/asn1/pkcs/PBKDF2Params.java | 98 - .../asn1/pkcs/PKCS12PBEParams.java | 69 - .../asn1/pkcs/PKCSObjectIdentifiers.java | 210 - .../java/org/bouncycastle/asn1/pkcs/Pfx.java | 71 - .../asn1/pkcs/PrivateKeyInfo.java | 135 - .../asn1/pkcs/RC2CBCParameter.java | 89 - .../asn1/pkcs/RSAESOAEPparams.java | 153 - .../asn1/pkcs/RSAPrivateKeyStructure.java | 186 - .../asn1/pkcs/RSASSAPSSparams.java | 172 - .../org/bouncycastle/asn1/pkcs/SafeBag.java | 78 - .../bouncycastle/asn1/pkcs/SignedData.java | 166 - .../bouncycastle/asn1/pkcs/SignerInfo.java | 168 - .../teletrust/TeleTrusTObjectIdentifiers.java | 18 - .../org/bouncycastle/asn1/tsp/Accuracy.java | 174 - .../bouncycastle/asn1/tsp/MessageImprint.java | 77 - .../org/bouncycastle/asn1/tsp/TSTInfo.java | 256 - .../bouncycastle/asn1/tsp/TimeStampReq.java | 181 - .../bouncycastle/asn1/tsp/TimeStampResp.java | 86 - .../org/bouncycastle/asn1/util/ASN1Dump.java | 292 - .../org/bouncycastle/asn1/util/DERDump.java | 33 - .../java/org/bouncycastle/asn1/util/Dump.java | 22 - .../asn1/x509/AccessDescription.java | 98 - .../asn1/x509/AlgorithmIdentifier.java | 126 - .../bouncycastle/asn1/x509/AttCertIssuer.java | 89 - .../asn1/x509/AttCertValidityPeriod.java | 84 - .../org/bouncycastle/asn1/x509/Attribute.java | 87 - .../asn1/x509/AttributeCertificate.java | 94 - .../asn1/x509/AttributeCertificateInfo.java | 165 - .../asn1/x509/AuthorityInformationAccess.java | 95 - .../asn1/x509/AuthorityKeyIdentifier.java | 207 - .../asn1/x509/BasicConstraints.java | 168 - .../bouncycastle/asn1/x509/CRLDistPoint.java | 83 - .../org/bouncycastle/asn1/x509/CRLNumber.java | 27 - .../org/bouncycastle/asn1/x509/CRLReason.java | 88 - .../bouncycastle/asn1/x509/CertPolicyId.java | 20 - .../asn1/x509/CertificateList.java | 119 - .../asn1/x509/CertificatePolicies.java | 147 - .../bouncycastle/asn1/x509/DSAParameter.java | 92 - .../bouncycastle/asn1/x509/DigestInfo.java | 86 - .../bouncycastle/asn1/x509/DisplayText.java | 165 - .../asn1/x509/DistributionPoint.java | 121 - .../asn1/x509/DistributionPointName.java | 110 - .../asn1/x509/ExtendedKeyUsage.java | 104 - .../bouncycastle/asn1/x509/GeneralName.java | 201 - .../bouncycastle/asn1/x509/GeneralNames.java | 76 - .../asn1/x509/GeneralSubtree.java | 195 - .../org/bouncycastle/asn1/x509/Holder.java | 126 - .../asn1/x509/IetfAttrSyntax.java | 174 - .../bouncycastle/asn1/x509/IssuerSerial.java | 106 - .../asn1/x509/IssuingDistributionPoint.java | 110 - .../bouncycastle/asn1/x509/KeyPurposeId.java | 37 - .../org/bouncycastle/asn1/x509/KeyUsage.java | 62 - .../asn1/x509/NameConstraints.java | 104 - .../asn1/x509/NoticeReference.java | 155 - .../asn1/x509/ObjectDigestInfo.java | 127 - .../asn1/x509/PolicyInformation.java | 87 - .../asn1/x509/PolicyMappings.java | 68 - .../asn1/x509/PolicyQualifierId.java | 31 - .../asn1/x509/PolicyQualifierInfo.java | 114 - .../asn1/x509/RSAPublicKeyStructure.java | 95 - .../bouncycastle/asn1/x509/ReasonFlags.java | 85 - .../bouncycastle/asn1/x509/RoleSyntax.java | 236 - .../asn1/x509/SubjectDirectoryAttributes.java | 144 - .../asn1/x509/SubjectKeyIdentifier.java | 90 - .../asn1/x509/SubjectPublicKeyInfo.java | 126 - .../bouncycastle/asn1/x509/TBSCertList.java | 212 - .../asn1/x509/TBSCertificateStructure.java | 193 - .../java/org/bouncycastle/asn1/x509/Time.java | 116 - .../bouncycastle/asn1/x509/UserNotice.java | 117 - .../asn1/x509/V1TBSCertificateGenerator.java | 125 - .../V2AttributeCertificateInfoGenerator.java | 146 - .../org/bouncycastle/asn1/x509/V2Form.java | 130 - .../asn1/x509/V2TBSCertListGenerator.java | 213 - .../asn1/x509/V3TBSCertificateGenerator.java | 140 - .../asn1/x509/X509Attributes.java | 8 - .../asn1/x509/X509CertificateStructure.java | 127 - .../asn1/x509/X509DefaultEntryConverter.java | 52 - .../bouncycastle/asn1/x509/X509Extension.java | 64 - .../asn1/x509/X509Extensions.java | 403 - .../org/bouncycastle/asn1/x509/X509Name.java | 1158 --- .../asn1/x509/X509NameElementList.java | 221 - .../asn1/x509/X509NameEntryConverter.java | 154 - .../asn1/x509/X509NameTokenizer.java | 102 - .../asn1/x509/X509ObjectIdentifiers.java | 43 - .../asn1/x509/qualified/BiometricData.java | 124 - .../qualified/ETSIQCObjectIdentifiers.java | 16 - .../x509/qualified/Iso4217CurrencyCode.java | 93 - .../asn1/x509/qualified/MonetaryValue.java | 92 - .../asn1/x509/qualified/QCStatement.java | 95 - .../qualified/RFC3739QCObjectIdentifiers.java | 14 - .../x509/qualified/SemanticsInformation.java | 130 - .../x509/qualified/TypeOfBiometricData.java | 90 - .../asn1/x509/sigi/SigIObjectIdentifiers.java | 49 - .../asn1/x9/X9ObjectIdentifiers.java | 121 - .../crypto/AsymmetricBlockCipher.java | 45 - .../crypto/AsymmetricCipherKeyPair.java | 44 - .../AsymmetricCipherKeyPairGenerator.java | 22 - .../bouncycastle/crypto/BasicAgreement.java | 21 - .../org/bouncycastle/crypto/BlockCipher.java | 56 - .../crypto/BufferedAsymmetricBlockCipher.java | 167 - .../crypto/BufferedBlockCipher.java | 322 - .../crypto/CipherKeyGenerator.java | 38 - .../bouncycastle/crypto/CipherParameters.java | 8 - .../bouncycastle/crypto/CryptoException.java | 26 - .../java/org/bouncycastle/crypto/DSA.java | 36 - .../crypto/DataLengthException.java | 29 - .../crypto/DerivationFunction.java | 17 - .../crypto/DerivationParameters.java | 8 - .../java/org/bouncycastle/crypto/Digest.java | 51 - .../bouncycastle/crypto/ExtendedDigest.java | 13 - .../crypto/InvalidCipherTextException.java | 27 - .../crypto/KeyGenerationParameters.java | 48 - .../java/org/bouncycastle/crypto/Mac.java | 71 - .../crypto/PBEParametersGenerator.java | 144 - .../crypto/RuntimeCryptoException.java | 26 - .../java/org/bouncycastle/crypto/Signer.java | 43 - .../crypto/SignerWithRecovery.java | 23 - .../crypto/StreamBlockCipher.java | 108 - .../org/bouncycastle/crypto/StreamCipher.java | 53 - .../java/org/bouncycastle/crypto/Wrapper.java | 18 - .../crypto/agreement/DHAgreement.java | 86 - .../crypto/agreement/DHBasicAgreement.java | 72 - .../crypto/digests/GeneralDigest.java | 135 - .../crypto/digests/LongDigest.java | 375 - .../crypto/digests/MD4Digest.java | 270 - .../crypto/digests/MD5Digest.java | 302 - .../crypto/digests/SHA1Digest.java | 294 - .../crypto/digests/SHA224Digest.java | 289 - .../crypto/digests/SHA256Digest.java | 291 - .../crypto/digests/SHA384Digest.java | 85 - .../crypto/digests/SHA512Digest.java | 87 - .../crypto/digests/ShortenedDigest.java | 80 - .../crypto/encodings/ISO9796d1Encoding.java | 251 - .../crypto/encodings/OAEPEncoding.java | 342 - .../crypto/encodings/PKCS1Encoding.java | 223 - .../crypto/engines/AESEngine.java | 547 -- .../crypto/engines/AESFastEngine.java | 876 --- .../crypto/engines/AESLightEngine.java | 440 -- .../crypto/engines/AESWrapEngine.java | 167 - .../crypto/engines/DESEngine.java | 494 -- .../crypto/engines/DESedeEngine.java | 126 - .../crypto/engines/DESedeWrapEngine.java | 366 - .../crypto/engines/IESEngine.java | 245 - .../crypto/engines/NullEngine.java | 79 - .../crypto/engines/RC2Engine.java | 316 - .../crypto/engines/RSAEngine.java | 200 - .../generators/BaseKDFBytesGenerator.java | 142 - .../crypto/generators/DESKeyGenerator.java | 23 - .../crypto/generators/DESedeKeyGenerator.java | 55 - .../generators/DHBasicKeyPairGenerator.java | 44 - .../generators/DHKeyGeneratorHelper.java | 68 - .../crypto/generators/DHKeyPairGenerator.java | 45 - .../generators/DHParametersGenerator.java | 81 - .../generators/DSAKeyPairGenerator.java | 58 - .../generators/DSAParametersGenerator.java | 178 - .../crypto/generators/KDF1BytesGenerator.java | 23 - .../crypto/generators/KDF2BytesGenerator.java | 24 - .../crypto/generators/MGF1BytesGenerator.java | 114 - .../OpenSSLPBEParametersGenerator.java | 131 - .../generators/PKCS12ParametersGenerator.java | 221 - .../PKCS5S1ParametersGenerator.java | 119 - .../PKCS5S2ParametersGenerator.java | 151 - .../generators/RSAKeyPairGenerator.java | 142 - .../crypto/io/DigestInputStream.java | 52 - .../crypto/io/DigestOutputStream.java | 43 - .../crypto/io/MacInputStream.java | 52 - .../crypto/io/MacOutputStream.java | 44 - .../crypto/macs/BlockCipherMac.java | 176 - .../crypto/macs/CBCBlockCipherMac.java | 232 - .../crypto/macs/CFBBlockCipherMac.java | 390 - .../org/bouncycastle/crypto/macs/HMac.java | 199 - .../crypto/macs/ISO9797Alg3Mac.java | 289 - .../org/bouncycastle/crypto/macs/OldHMac.java | 138 - .../crypto/modes/CBCBlockCipher.java | 233 - .../crypto/modes/CCMBlockCipher.java | 284 - .../crypto/modes/CFBBlockCipher.java | 250 - .../crypto/modes/CTSBlockCipher.java | 265 - .../crypto/modes/GOFBBlockCipher.java | 226 - .../crypto/modes/OFBBlockCipher.java | 179 - .../crypto/modes/PaddedBlockCipher.java | 253 - .../crypto/modes/SICBlockCipher.java | 115 - .../crypto/paddings/BlockCipherPadding.java | 48 - .../crypto/paddings/ISO10126d2Padding.java | 79 - .../crypto/paddings/ISO7816d4Padding.java | 77 - .../crypto/paddings/PKCS7Padding.java | 76 - .../paddings/PaddedBufferedBlockCipher.java | 298 - .../crypto/paddings/TBCPadding.java | 89 - .../crypto/paddings/X923Padding.java | 80 - .../crypto/paddings/ZeroBytePadding.java | 73 - .../crypto/params/AsymmetricKeyParameter.java | 20 - .../crypto/params/CCMParameters.java | 48 - .../crypto/params/DESParameters.java | 107 - .../crypto/params/DESedeParameters.java | 57 - .../params/DHKeyGenerationParameters.java | 25 - .../crypto/params/DHKeyParameters.java | 54 - .../crypto/params/DHParameters.java | 126 - .../crypto/params/DHPrivateKeyParameters.java | 41 - .../crypto/params/DHPublicKeyParameters.java | 41 - .../crypto/params/DHValidationParameters.java | 58 - .../params/DSAKeyGenerationParameters.java | 25 - .../crypto/params/DSAKeyParameters.java | 21 - .../crypto/params/DSAParameters.java | 74 - .../params/DSAPrivateKeyParameters.java | 23 - .../crypto/params/DSAPublicKeyParameters.java | 23 - .../params/DSAValidationParameters.java | 56 - .../crypto/params/IESParameters.java | 44 - .../params/IESWithCipherParameters.java | 30 - .../crypto/params/ISO18033KDFParameters.java | 23 - .../crypto/params/KDFParameters.java | 31 - .../crypto/params/KeyParameter.java | 30 - .../crypto/params/MGFParameters.java | 32 - .../crypto/params/ParametersWithIV.java | 39 - .../crypto/params/ParametersWithRandom.java | 41 - .../crypto/params/ParametersWithSBox.java | 28 - .../crypto/params/ParametersWithSalt.java | 42 - .../crypto/params/RC2Parameters.java | 36 - .../crypto/params/RC5Parameters.java | 35 - .../params/RSAKeyGenerationParameters.java | 48 - .../crypto/params/RSAKeyParameters.java | 31 - .../params/RSAPrivateCrtKeyParameters.java | 67 - .../crypto/signers/DSASigner.java | 122 - .../crypto/signers/ISO9796d2PSSSigner.java | 611 -- .../crypto/signers/ISO9796d2Signer.java | 495 -- .../crypto/signers/PSSSigner.java | 318 - .../crypto/util/PrivateKeyFactory.java | 136 - .../crypto/util/PublicKeyFactory.java | 138 - .../org/bouncycastle/i18n/ErrorBundle.java | 90 - .../bouncycastle/i18n/LocalizedException.java | 49 - .../bouncycastle/i18n/LocalizedMessage.java | 187 - .../org/bouncycastle/i18n/MessageBundle.java | 62 - .../i18n/MissingEntryException.java | 26 - .../org/bouncycastle/i18n/TextBundle.java | 62 - .../org/bouncycastle/i18n/filter/Filter.java | 14 - .../bouncycastle/i18n/filter/HTMLFilter.java | 63 - .../bouncycastle/i18n/filter/SQLFilter.java | 64 - .../i18n/filter/UntrustedInput.java | 44 - .../jce/PKCS10CertificationRequest.java | 452 -- .../org/bouncycastle/jce/PKCS7SignedData.java | 600 -- .../org/bouncycastle/jce/PrincipalUtil.java | 86 - .../org/bouncycastle/jce/X509KeyUsage.java | 57 - .../org/bouncycastle/jce/X509Principal.java | 151 - .../jce/X509V1CertificateGenerator.java | 265 - .../bouncycastle/jce/X509V2CRLGenerator.java | 331 - .../jce/X509V3CertificateGenerator.java | 345 - .../jce/interfaces/BCKeyStore.java | 14 - .../bouncycastle/jce/interfaces/IESKey.java | 22 - .../interfaces/PKCS12BagAttributeCarrier.java | 21 - .../jce/netscape/NetscapeCertRequest.java | 302 - .../jce/provider/AnnotatedException.java | 32 - .../jce/provider/BouncyCastleProvider.java | 997 --- .../jce/provider/BrokenJCEBlockCipher.java | 624 -- .../provider/BrokenKDF2BytesGenerator.java | 127 - .../bouncycastle/jce/provider/BrokenPBE.java | 448 -- .../provider/CertPathValidatorUtilities.java | 884 --- .../jce/provider/CertStoreCollectionSpi.java | 104 - .../org/bouncycastle/jce/provider/DHUtil.java | 50 - .../bouncycastle/jce/provider/DSAUtil.java | 49 - .../jce/provider/IndexedPKIXParameters.java | 159 - .../jce/provider/JCEBlockCipher.java | 965 --- .../jce/provider/JCEDHKeyAgreement.java | 178 - .../jce/provider/JCEDHPrivateKey.java | 155 - .../jce/provider/JCEDHPublicKey.java | 127 - .../jce/provider/JCEDigestUtil.java | 131 - .../jce/provider/JCEIESCipher.java | 408 - .../jce/provider/JCEKeyGenerator.java | 541 -- .../org/bouncycastle/jce/provider/JCEMac.java | 544 -- .../bouncycastle/jce/provider/JCEPBEKey.java | 151 - .../jce/provider/JCERSACipher.java | 581 -- .../jce/provider/JCERSAPrivateCrtKey.java | 237 - .../jce/provider/JCERSAPrivateKey.java | 184 - .../jce/provider/JCERSAPublicKey.java | 129 - .../jce/provider/JCESecretKeyFactory.java | 616 -- .../jce/provider/JCEStreamCipher.java | 559 -- .../JDKAlgorithmParameterGenerator.java | 446 -- .../jce/provider/JDKAlgorithmParameters.java | 1463 ---- .../jce/provider/JDKDSAPrivateKey.java | 139 - .../jce/provider/JDKDSAPublicKey.java | 125 - .../jce/provider/JDKDSASigner.java | 426 - .../jce/provider/JDKDigestSignature.java | 343 - .../jce/provider/JDKECDSAAlgParameters.java | 75 - .../jce/provider/JDKISOSignature.java | 149 - .../jce/provider/JDKKeyFactory.java | 779 -- .../jce/provider/JDKKeyPairGenerator.java | 621 -- .../jce/provider/JDKKeyStore.java | 1068 --- .../jce/provider/JDKMessageDigest.java | 340 - .../jce/provider/JDKPKCS12KeyStore.java | 1515 ---- .../jce/provider/JDKPSSSigner.java | 289 - .../provider/JDKX509CertificateFactory.java | 475 -- .../org/bouncycastle/jce/provider/PBE.java | 279 - .../jce/provider/PKIXCertPath.java | 393 - .../jce/provider/PKIXCertPathBuilderSpi.java | 353 - .../provider/PKIXCertPathValidatorSpi.java | 1468 ---- .../jce/provider/PKIXPolicyNode.java | 168 - .../bouncycastle/jce/provider/RSAUtil.java | 53 - .../jce/provider/WrapCipherSpi.java | 450 -- .../jce/provider/X509CRLEntryObject.java | 241 - .../jce/provider/X509CRLObject.java | 398 - .../jce/provider/X509CertificateObject.java | 774 -- .../jce/provider/X509SignatureUtil.java | 140 - .../org/bouncycastle/jce/spec/IEKeySpec.java | 70 - .../jce/spec/IESParameterSpec.java | 52 - .../org/bouncycastle/openssl/PEMWriter.java | 295 - .../java/org/bouncycastle/util/Arrays.java | 67 - .../org/bouncycastle/util/BigIntegers.java | 32 - .../java/org/bouncycastle/util/Strings.java | 191 - .../bouncycastle/util/encoders/Base64.java | 118 - .../util/encoders/Base64Encoder.java | 298 - .../util/encoders/BufferedDecoder.java | 96 - .../util/encoders/BufferedEncoder.java | 96 - .../bouncycastle/util/encoders/Encoder.java | 17 - .../org/bouncycastle/util/encoders/Hex.java | 131 - .../util/encoders/HexEncoder.java | 172 - .../util/encoders/HexTranslator.java | 87 - .../util/encoders/Translator.java | 23 - .../bouncycastle/util/encoders/UrlBase64.java | 129 - .../util/encoders/UrlBase64Encoder.java | 25 - .../x509/AttributeCertificateHolder.java | 263 - .../x509/AttributeCertificateIssuer.java | 180 - .../x509/CertPathReviewerException.java | 72 - .../x509/CertPathReviewerMessages.properties | 563 -- .../CertPathReviewerMessages_de.properties | 563 -- .../x509/PKIXCertPathReviewer.java | 2437 ------ .../org/bouncycastle/x509/X509Attribute.java | 78 - .../x509/X509AttributeCertificate.java | 106 - .../java/org/bouncycastle/x509/X509Util.java | 133 - .../x509/X509V1CertificateGenerator.java | 301 - .../x509/X509V2AttributeCertificate.java | 297 - .../X509V2AttributeCertificateGenerator.java | 283 - .../bouncycastle/x509/X509V2CRLGenerator.java | 400 - .../x509/X509V3CertificateGenerator.java | 429 - .../AuthorityKeyIdentifierStructure.java | 126 - .../SubjectKeyIdentifierStructure.java | 58 - .../x509/extension/X509ExtensionUtil.java | 22 - .../security/AccessControlException2Test.java | 106 - .../security/AccessControlExceptionTest.java | 97 - .../java/security/AccessController2Test.java | 292 - .../AlgorithmParameterGenerator1Test.java | 493 -- .../AlgorithmParameterGenerator2Test.java | 284 - .../AlgorithmParameterGenerator3Test.java | 269 - .../security/AlgorithmParametersSpiTest.java | 134 - .../security/AlgorithmParametersTest.java | 846 -- .../java/security/AllPermission2Test.java | 194 - .../tests/java/security/AllTests.java | 139 - .../tests/java/security/AuthProviderTest.java | 110 - .../java/security/BasicPermission2Test.java | 170 - .../tests/java/security/CodeSignerTest.java | 205 - .../tests/java/security/CodeSource2Test.java | 193 - .../tests/java/security/CodeSourceTest.java | 805 -- .../java/security/DigestException2Test.java | 61 - .../java/security/DigestExceptionTest.java | 233 - .../java/security/DigestInputStream2Test.java | 283 - .../java/security/DigestInputStreamTest.java | 680 -- .../java/security/DigestOutputStreamTest.java | 747 -- .../GeneralSecurityException2Test.java | 66 - .../GeneralSecurityExceptionTest.java | 237 - .../java/security/GuardedObjectTest.java | 107 - .../tests/java/security/Identity2Test.java | 566 -- .../java/security/IdentityScope2Test.java | 410 - .../java/security/IdentityScopeTest.java | 187 - ...validAlgorithmParameterException2Test.java | 69 - ...nvalidAlgorithmParameterExceptionTest.java | 247 - .../security/InvalidKeyException2Test.java | 64 - .../security/InvalidKeyExceptionTest.java | 235 - .../InvalidParameterException2Test.java | 66 - .../InvalidParameterExceptionTest.java | 102 - .../KSCallbackHandlerProtectionTest.java | 108 - .../security/KSPasswordProtectionTest.java | 103 - .../java/security/KSPrivateKeyEntryTest.java | 261 - .../java/security/KSSecretKeyEntryTest.java | 115 - .../KSTrustedCertificateEntryTest.java | 107 - .../java/security/KeyException2Test.java | 61 - .../tests/java/security/KeyExceptionTest.java | 233 - .../tests/java/security/KeyFactory2Test.java | 563 -- .../java/security/KeyFactorySpiTest.java | 109 - .../tests/java/security/KeyFactoryTest.java | 644 -- .../security/KeyManagementException2Test.java | 63 - .../security/KeyManagementExceptionTest.java | 237 - .../java/security/KeyPairGenerator1Test.java | 657 -- .../java/security/KeyPairGenerator2Test.java | 511 -- .../java/security/KeyPairGenerator3Test.java | 206 - .../java/security/KeyPairGenerator4Test.java | 198 - .../security/KeyPairGeneratorSpiTest.java | 113 - .../tests/java/security/KeyPairTest.java | 175 - .../tests/java/security/KeyRepTest.java | 271 - .../tests/java/security/KeyRepTypeTest.java | 88 - .../tests/java/security/KeyStore2Test.java | 1375 ---- .../tests/java/security/KeyStore3Test.java | 327 - .../tests/java/security/KeyStore4Test.java | 701 -- .../java/security/KeyStoreBuilderTest.java | 573 -- .../java/security/KeyStoreException2Test.java | 62 - .../java/security/KeyStoreExceptionTest.java | 234 - .../KeyStoreLoadStoreParameterTest.java | 15 - .../tests/java/security/KeyStoreSpiTest.java | 490 -- .../tests/java/security/KeyStoreTest.java | 380 - .../security/tests/java/security/KeyTest.java | 73 - .../java/security/MessageDigest1Test.java | 408 - .../java/security/MessageDigest2Test.java | 679 -- .../java/security/MessageDigestSpiTest.java | 280 - .../NoSuchAlgorithmException2Test.java | 70 - .../NoSuchAlgorithmExceptionTest.java | 237 - .../NoSuchProviderException2Test.java | 71 - .../security/NoSuchProviderExceptionTest.java | 102 - .../tests/java/security/Permission2Test.java | 166 - .../security/PermissionCollectionTest.java | 136 - .../tests/java/security/PermissionTest.java | 158 - .../tests/java/security/Permissions2Test.java | 195 - .../tests/java/security/PermissionsTest.java | 182 - .../tests/java/security/PolicyTest.java | 450 -- .../tests/java/security/PrivateKeyTest.java | 73 - .../PrivilegedActionException2Test.java | 92 - .../PrivilegedActionExceptionTest.java | 92 - .../java/security/PrivilegedActionTest.java | 58 - .../PrivilegedExceptionActionTest.java | 90 - .../java/security/ProtectionDomainTest.java | 364 - .../tests/java/security/Provider2Test.java | 175 - .../java/security/ProviderException2Test.java | 62 - .../java/security/ProviderExceptionTest.java | 234 - .../java/security/ProviderServiceTest.java | 294 - .../tests/java/security/ProviderTest.java | 817 -- .../tests/java/security/PublicKeyTest.java | 68 - .../java/security/SecureRandom2Test.java | 436 -- .../java/security/SecureRandomSpiTest.java | 92 - .../tests/java/security/Security2Test.java | 361 - .../security/SecurityPermission2Test.java | 65 - .../java/security/SecurityPermissionTest.java | 96 - .../tests/java/security/SecurityTest.java | 509 -- .../tests/java/security/Signature2Test.java | 761 -- .../security/SignatureException2Test.java | 62 - .../java/security/SignatureExceptionTest.java | 235 - .../tests/java/security/SignatureSpiTest.java | 529 -- .../tests/java/security/SignatureTest.java | 748 -- .../tests/java/security/SignedObjectTest.java | 234 - .../tests/java/security/SignerTest.java | 255 - .../tests/java/security/TimestampTest.java | 171 - .../UnrecoverableEntryExceptionTest.java | 87 - .../UnrecoverableKeyException2Test.java | 64 - .../UnrecoverableKeyExceptionTest.java | 103 - .../security/UnresolvedPermissionTest.java | 436 -- .../bouncycastle/jce/provider/AllTests.java | 34 - .../PKIXCertPathValidatorSpiTest.java | 65 - .../security/AccessControlContextTest.java | 395 - .../tests/api/java/security/AllTests.java | 43 - .../api/java/security/DomainCombinerTest.java | 133 - .../security/PermissionCollectionTest.java | 282 - .../api/javax/security/auth/AllTests.java | 52 - .../security/auth/AuthPermissionTest.java | 103 - .../security/auth/CallbackHandlerTest.java | 59 - .../auth/DestroyFailedExceptionTest.java | 104 - .../javax/security/auth/DestroyableTest.java | 84 - .../security/auth/LoginExceptionTest.java | 104 - .../security/auth/PasswordCallbackTest.java | 153 - .../auth/PrivateCredentialPermissionTest.java | 261 - .../auth/SubjectDomainCombinerTest.java | 503 -- .../api/javax/security/auth/SubjectTest.java | 786 -- .../UnsupportedCallbackExceptionTest.java | 187 - .../security/auth/X500PrincipalTest.java | 329 - .../api/javax/security/cert/AllTests.java | 47 - .../CertificateEncodingExceptionTest.java | 102 - .../cert/CertificateExceptionTest.java | 103 - .../cert/CertificateExpiredExceptionTest.java | 103 - .../CertificateNotYetValidExceptionTest.java | 105 - .../cert/CertificateParsingExceptionTest.java | 104 - .../javax/security/cert/CertificateTest.java | 198 - .../security/cert/X509CertificateTest.java | 911 --- .../AlgorithmParameterGeneratorSpiTest.java | 105 - .../java/security/AllPermissionTest.java | 126 - .../java/tests/java/security/AllTests.java | 46 - .../java/security/BasicPermissionTest.java | 174 - .../tests/java/security/IdentityTest.java | 575 -- .../java/security/SecureClassLoaderTest.java | 372 - .../tests/java/security/SecureRandomTest.java | 368 - .../tests/security/AccessControllerTest.java | 232 - .../test/java/tests/security/AllTests.java | 55 - .../acl/AclNotFoundException2Test.java | 56 - .../acl/AclNotFoundExceptionTest.java | 60 - .../java/tests/security/acl/AllTests.java | 51 - .../tests/security/acl/IAclEntryTest.java | 213 - .../java/tests/security/acl/IAclTest.java | 230 - .../java/tests/security/acl/IGroupTest.java | 101 - .../java/tests/security/acl/IOwnerTest.java | 148 - .../tests/security/acl/IPermissionTest.java | 80 - .../security/acl/LastOwnerException2Test.java | 52 - .../security/acl/LastOwnerExceptionTest.java | 56 - .../security/acl/NotOwnerException2Test.java | 52 - .../security/acl/NotOwnerExceptionTest.java | 56 - .../java/tests/security/cert/AllTests.java | 88 - .../tests/security/cert/CRLExceptionTest.java | 234 - .../java/tests/security/cert/CRLTest.java | 161 - .../security/cert/CertPathBuilder1Test.java | 574 -- .../security/cert/CertPathBuilder2Test.java | 273 - .../cert/CertPathBuilderExceptionTest.java | 239 - .../security/cert/CertPathBuilderSpiTest.java | 77 - .../cert/CertPathCertPathRepTest.java | 79 - .../tests/security/cert/CertPathTest.java | 385 - .../security/cert/CertPathValidator1Test.java | 550 -- .../security/cert/CertPathValidator2Test.java | 279 - .../security/cert/CertPathValidator3Test.java | 122 - .../cert/CertPathValidatorExceptionTest.java | 571 -- .../cert/CertPathValidatorSpiTest.java | 84 - .../tests/security/cert/CertStore1Test.java | 612 -- .../tests/security/cert/CertStore2Test.java | 409 - .../security/cert/CertStoreExceptionTest.java | 236 - .../tests/security/cert/CertStoreSpiTest.java | 124 - .../cert/CertificateCertificateRepTest.java | 99 - .../CertificateEncodingException2Test.java | 54 - .../CertificateEncodingExceptionTest.java | 243 - .../cert/CertificateException2Test.java | 78 - .../cert/CertificateExceptionTest.java | 238 - .../cert/CertificateExpiredExceptionTest.java | 103 - .../cert/CertificateFactory1Test.java | 905 --- .../cert/CertificateFactory2Test.java | 376 - .../cert/CertificateFactory3Test.java | 225 - .../cert/CertificateFactory4Test.java | 694 -- .../cert/CertificateFactorySpiTest.java | 526 -- .../CertificateNotYetValidExceptionTest.java | 105 - .../cert/CertificateParsingExceptionTest.java | 241 - .../tests/security/cert/CertificateTest.java | 655 -- .../CollectionCertStoreParametersTest.java | 317 - .../cert/LDAPCertStoreParametersTest.java | 272 - .../cert/PKIXBuilderParametersTest.java | 469 -- .../cert/PKIXCertPathBuilderResultTest.java | 300 - .../cert/PKIXCertPathCheckerTest.java | 152 - .../cert/PKIXCertPathValidatorResultTest.java | 405 - .../security/cert/PKIXParametersTest.java | 1879 ----- .../tests/security/cert/PolicyNodeTest.java | 292 - .../cert/PolicyQualifierInfoTest.java | 382 - .../tests/security/cert/TrustAnchorTest.java | 887 --- .../tests/security/cert/X509CRL2Test.java | 258 - .../tests/security/cert/X509CRLEntryTest.java | 274 - .../security/cert/X509CRLSelector2Test.java | 765 -- .../security/cert/X509CRLSelectorTest.java | 169 - .../java/tests/security/cert/X509CRLTest.java | 465 -- .../security/cert/X509CertSelectorTest.java | 2615 ------- .../security/cert/X509Certificate2Test.java | 598 -- .../tests/security/interfaces/AllTests.java | 50 - .../interfaces/DSAKeyPairGeneratorTest.java | 156 - .../tests/security/interfaces/DSAKeyTest.java | 66 - .../security/interfaces/DSAParamsTest.java | 78 - .../interfaces/DSAPrivateKeyTest.java | 53 - .../security/interfaces/DSAPublicKeyTest.java | 72 - .../tests/security/interfaces/RSAKeyTest.java | 60 - .../RSAMultiPrimePrivateCrtKeyTest.java | 150 - .../interfaces/RSAPrivateCrtKeyTest.java | 131 - .../interfaces/RSAPrivateKeyTest.java | 49 - .../security/interfaces/RSAPublicKeyTest.java | 49 - .../java/tests/security/interfaces/Util.java | 109 - .../tests/security/permissions/AllTests.java | 61 - .../JavaIoFileInputStreamTest.java | 127 - .../JavaIoFileOutputStreamTest.java | 149 - .../security/permissions/JavaIoFileTest.java | 530 -- .../JavaIoObjectInputStreamTest.java | 215 - .../JavaIoObjectOutputStreamTest.java | 189 - .../JavaIoRandomAccessFileTest.java | 160 - .../permissions/JavaLangClassLoaderTest.java | 201 - .../permissions/JavaLangClassTest.java | 111 - .../JavaLangReflectAccessibleObjectTest.java | 103 - .../permissions/JavaLangRuntimeTest.java | 308 - .../permissions/JavaLangSystemTest.java | 410 - .../permissions/JavaLangThreadTest.java | 224 - .../JavaNetDatagramSocketTest.java | 188 - .../JavaNetMulticastSocketTest.java | 123 - .../permissions/JavaNetServerSocketTest.java | 126 - .../permissions/JavaNetSocketTest.java | 200 - .../permissions/JavaSecurityPolicyTest.java | 107 - .../permissions/JavaSecuritySecurityTest.java | 192 - .../security/permissions/JavaUtilLocale.java | 83 - .../permissions/JavaUtilZipZipFile.java | 93 - .../permissions/JavaxSecurityAuthSubject.java | 475 -- ...avaxSecurityAuthSubjectDomainCombiner.java | 90 - .../java/tests/security/spec/AllTests.java | 65 - .../security/spec/DSAParameterSpecTest.java | 114 - .../security/spec/DSAPrivateKeySpecTest.java | 138 - .../security/spec/DSAPublicKeySpecTest.java | 137 - .../tests/security/spec/ECFieldF2mTest.java | 730 -- .../tests/security/spec/ECFieldFpTest.java | 274 - .../security/spec/ECGenParameterSpecTest.java | 97 - .../security/spec/ECParameterSpecTest.java | 176 - .../java/tests/security/spec/ECPointTest.java | 302 - .../security/spec/ECPrivateKeySpecTest.java | 123 - .../security/spec/ECPublicKeySpecTest.java | 121 - .../security/spec/EllipticCurveTest.java | 774 -- .../security/spec/EncodedKeySpec2Test.java | 96 - .../security/spec/EncodedKeySpecTest.java | 150 - .../spec/InvalidKeySpecExceptionTest.java | 238 - .../InvalidParameterSpecExceptionTest.java | 105 - .../security/spec/MGF1ParameterSpecTest.java | 144 - .../spec/PKCS8EncodedKeySpecTest.java | 172 - .../security/spec/PSSParameterSpecTest.java | 379 - .../spec/RSAKeyGenParameterSpecTest.java | 120 - .../RSAMultiPrimePrivateCrtKeySpecTest.java | 872 --- .../security/spec/RSAOtherPrimeInfoTest.java | 195 - .../spec/RSAPrivateCrtKeySpecTest.java | 303 - .../security/spec/RSAPrivateKeySpecTest.java | 94 - .../security/spec/RSAPublicKeySpecTest.java | 114 - .../security/spec/X509EncodedKeySpecTest.java | 173 - .../tests/security/special-test-cases.txt | 7 - .../AlgorithmParameterGeneratorTest.java | 71 - .../AlgorithmParameterGeneratorTestAES.java | 28 - .../AlgorithmParameterGeneratorTestDH.java | 54 - .../AlgorithmParameterGeneratorTestDSA.java | 31 - .../security/AlgorithmParametersTest.java | 80 - .../security/AlgorithmParametersTestAES.java | 35 - .../security/AlgorithmParametersTestDES.java | 33 - .../AlgorithmParametersTestDESede.java | 33 - .../security/AlgorithmParametersTestDH.java | 91 - .../security/AlgorithmParametersTestDSA.java | 68 - .../security/AlgorithmParametersTestOAEP.java | 32 - .../java/tests/targets/security/AllTests.java | 78 - .../tests/targets/security/CipherHelper.java | 535 -- .../java/tests/targets/security/DHTest.java | 62 - .../tests/targets/security/DefaultKeys.java | 206 - .../targets/security/KeyFactoryTest.java | 127 - .../targets/security/KeyFactoryTestDH.java | 30 - .../targets/security/KeyFactoryTestDSA.java | 31 - .../targets/security/KeyFactoryTestRSA.java | 32 - .../security/KeyPairGeneratorTest.java | 87 - .../security/KeyPairGeneratorTestDH.java | 52 - .../security/KeyPairGeneratorTestDSA.java | 27 - .../security/KeyPairGeneratorTestRSA.java | 29 - .../tests/targets/security/KeyStoreTest.java | 234 - .../targets/security/KeyStoreTestPKCS12.java | 484 -- .../targets/security/MessageDigestTest.java | 320 - .../security/MessageDigestTestMD2.java | 112 - .../security/MessageDigestTestMD5.java | 38 - .../security/MessageDigestTestSHA1.java | 39 - .../security/MessageDigestTestSHA224.java | 35 - .../security/MessageDigestTestSHA256.java | 39 - .../security/MessageDigestTestSHA384.java | 39 - .../security/MessageDigestTestSHA512.java | 39 - .../targets/security/SecureRandomTest.java | 97 - .../security/SecureRandomTestSHA1PRNG.java | 27 - .../tests/targets/security/SignatureTest.java | 146 - .../security/SignatureTestMD2withRSA.java | 192 - .../security/SignatureTestMD5withRSA.java | 26 - .../security/SignatureTestNONEwithDSA.java | 26 - .../security/SignatureTestSHA1withDSA.java | 26 - .../security/SignatureTestSHA1withRSA.java | 26 - .../security/SignatureTestSHA224withRSA.java | 26 - .../security/SignatureTestSHA256withRSA.java | 26 - .../security/SignatureTestSHA384withRSA.java | 26 - .../security/SignatureTestSHA512withRSA.java | 26 - .../tests/targets/security/cert/AllTests.java | 39 - .../security/cert/CertPathBuilderTest.java | 82 - .../cert/CertPathBuilderTestPKIX.java | 109 - .../security/cert/CertPathValidatorTest.java | 70 - .../cert/CertPathValidatorTestPKIX.java | 121 - .../security/cert/CertificateFactoryTest.java | 70 - .../cert/CertificateFactoryTestX509.java | 52 - .../security/cert/CertificateTest.java | 777 -- .../src/test/resources/PolicyTest.txt | 3 - .../UnresolvedPermissionTest.golden.ser | Bin 1040 -> 0 bytes .../security/cert/CertPathTest.golden.ser | Bin 885 -> 0 bytes .../security/cert/CertificateTest.golden.ser | Bin 936 -> 0 bytes .../resources/tests/resources/hyts_badpem.cer | 31 - .../java/security/cert/CertPath.PkiPath | Bin 805 -> 0 bytes .../resources/tests/resources/testdex.jar | Bin 825 -> 0 bytes .../tests/targets/security/MD5.check | 1 - .../resources/tests/targets/security/MD5.data | 1 - .../tests/targets/security/SHA-1.check | Bin 20 -> 0 bytes .../tests/targets/security/SHA-1.data | 1 - .../tests/targets/security/SHA-224.check | 1 - .../tests/targets/security/SHA-224.data | 1 - .../tests/targets/security/SHA-256.check | 1 - .../tests/targets/security/SHA-256.data | 1 - .../tests/targets/security/SHA-384.check | 2 - .../tests/targets/security/SHA-384.data | 1 - .../tests/targets/security/SHA-512.check | 1 - .../tests/targets/security/SHA-512.data | 1 - libcore/sql/MODULE_LICENSE_APACHE2 | 0 libcore/sql/MODULE_LICENSE_BSD_LIKE | 0 .../sql/src/main/java/SQLite/Authorizer.java | 25 - libcore/sql/src/main/java/SQLite/Blob.java | 323 - .../sql/src/main/java/SQLite/BusyHandler.java | 20 - .../sql/src/main/java/SQLite/Callback.java | 68 - .../sql/src/main/java/SQLite/Constants.java | 157 - .../sql/src/main/java/SQLite/Database.java | 615 -- .../sql/src/main/java/SQLite/Exception.java | 18 - .../sql/src/main/java/SQLite/Function.java | 59 - .../src/main/java/SQLite/FunctionContext.java | 82 - .../java/SQLite/JDBC2y/JDBCConnection.java | 452 -- .../SQLite/JDBC2y/JDBCDatabaseMetaData.java | 1578 ---- .../SQLite/JDBC2y/JDBCPreparedStatement.java | 752 -- .../java/SQLite/JDBC2y/JDBCResultSet.java | 932 --- .../SQLite/JDBC2y/JDBCResultSetMetaData.java | 212 - .../java/SQLite/JDBC2y/JDBCStatement.java | 287 - .../main/java/SQLite/JDBC2y/TableResultX.java | 37 - .../sql/src/main/java/SQLite/JDBCDriver.java | 109 - .../src/main/java/SQLite/ProgressHandler.java | 17 - libcore/sql/src/main/java/SQLite/Shell.java | 669 -- libcore/sql/src/main/java/SQLite/Stmt.java | 288 - .../src/main/java/SQLite/StringEncoder.java | 201 - .../sql/src/main/java/SQLite/TableResult.java | 133 - libcore/sql/src/main/java/SQLite/Trace.java | 17 - libcore/sql/src/main/java/SQLite/Vm.java | 78 - libcore/sql/src/main/java/java/sql/Array.java | 166 - .../java/java/sql/BatchUpdateException.java | 160 - libcore/sql/src/main/java/java/sql/Blob.java | 171 - .../main/java/java/sql/CallableStatement.java | 1384 ---- libcore/sql/src/main/java/java/sql/Clob.java | 179 - .../src/main/java/java/sql/Connection.java | 761 -- .../main/java/java/sql/DataTruncation.java | 127 - .../main/java/java/sql/DatabaseMetaData.java | 3079 -------- libcore/sql/src/main/java/java/sql/Date.java | 247 - .../sql/src/main/java/java/sql/Driver.java | 125 - .../src/main/java/java/sql/DriverManager.java | 452 -- .../java/java/sql/DriverPropertyInfo.java | 73 - .../main/java/java/sql/ParameterMetaData.java | 189 - .../main/java/java/sql/PreparedStatement.java | 690 -- libcore/sql/src/main/java/java/sql/Ref.java | 82 - .../sql/src/main/java/java/sql/ResultSet.java | 1946 ----- .../main/java/java/sql/ResultSetMetaData.java | 282 - .../sql/src/main/java/java/sql/SQLData.java | 114 - .../src/main/java/java/sql/SQLException.java | 161 - .../sql/src/main/java/java/sql/SQLInput.java | 313 - .../sql/src/main/java/java/sql/SQLOutput.java | 293 - .../src/main/java/java/sql/SQLPermission.java | 64 - .../src/main/java/java/sql/SQLWarning.java | 110 - .../sql/src/main/java/java/sql/Savepoint.java | 45 - .../sql/src/main/java/java/sql/Statement.java | 653 -- .../sql/src/main/java/java/sql/Struct.java | 68 - libcore/sql/src/main/java/java/sql/Time.java | 247 - .../sql/src/main/java/java/sql/Timestamp.java | 509 -- libcore/sql/src/main/java/java/sql/Types.java | 185 - .../sql/src/main/java/java/sql/package.html | 8 - .../main/java/javax/sql/ConnectionEvent.java | 74 - .../javax/sql/ConnectionEventListener.java | 57 - .../javax/sql/ConnectionPoolDataSource.java | 126 - .../src/main/java/javax/sql/DataSource.java | 145 - .../main/java/javax/sql/PooledConnection.java | 112 - .../sql/src/main/java/javax/sql/RowSet.java | 917 --- .../src/main/java/javax/sql/RowSetEvent.java | 54 - .../main/java/javax/sql/RowSetInternal.java | 87 - .../main/java/javax/sql/RowSetListener.java | 67 - .../main/java/javax/sql/RowSetMetaData.java | 293 - .../src/main/java/javax/sql/RowSetReader.java | 56 - .../src/main/java/javax/sql/RowSetWriter.java | 58 - .../sql/src/main/java/javax/sql/package.html | 9 - .../harmony/sql/internal/nls/Messages.java | 146 - .../sql/internal/nls/messages.properties | 61 - libcore/sql/src/main/native/sqlite_jni.c | 4400 ----------- libcore/sql/src/main/native/sqlite_jni.h | 657 -- libcore/sql/src/main/native/sqlite_jni_defs.h | 39 - .../src/main/native/sqlite_jni_registration.c | 308 - libcore/sql/src/main/native/sub.mk | 19 - .../harmony/sql/tests/java/sql/AllTests.java | 57 - .../java/sql/BatchUpdateExceptionTest.java | 438 -- .../sql/tests/java/sql/ConnectionTest.java | 101 - .../tests/java/sql/DataTruncationTest.java | 555 -- .../tests/java/sql/DatabaseMetaDataTest.java | 131 - .../harmony/sql/tests/java/sql/DateTest.java | 474 -- .../sql/tests/java/sql/DriverManagerTest.java | 763 -- .../java/sql/DriverPropertyInfoTest.java | 160 - .../tests/java/sql/ParameterMetaDataTest.java | 106 - .../tests/java/sql/ResultSetMetaDataTest.java | 96 - .../sql/tests/java/sql/ResultSetTest.java | 113 - .../sql/tests/java/sql/SQLExceptionTest.java | 619 -- .../sql/tests/java/sql/SQLPermissionTest.java | 91 - .../sql/tests/java/sql/SQLWarningTest.java | 474 -- .../sql/tests/java/sql/StatementTest.java | 104 - .../java/sql/TestHelper_ClassLoader.java | 219 - .../java/sql/TestHelper_Connection1.java | 179 - .../tests/java/sql/TestHelper_Driver1.java | 117 - .../tests/java/sql/TestHelper_Driver2.java | 50 - .../tests/java/sql/TestHelper_Driver3.java | 35 - .../tests/java/sql/TestHelper_Driver4.java | 133 - .../tests/java/sql/TestHelper_Driver5.java | 44 - .../java/sql/TestHelper_DriverManager.java | 112 - .../sql/tests/java/sql/TestMainForDriver.java | 36 - .../harmony/sql/tests/java/sql/TimeTest.java | 402 - .../sql/tests/java/sql/TimestampTest.java | 873 --- .../harmony/sql/tests/java/sql/TypesTest.java | 113 - .../harmony/sql/tests/javax/sql/AllTests.java | 42 - .../tests/javax/sql/ConnectionEventTest.java | 178 - .../javax/sql/Impl_PooledConnection.java | 39 - .../sql/tests/javax/sql/Impl_RowSet.java | 762 -- .../sql/tests/javax/sql/RowSetEventTest.java | 55 - .../java/tests/SQLite/AbstractSqlTest.java | 244 - .../src/test/java/tests/SQLite/AllTests.java | 40 - .../src/test/java/tests/SQLite/BlobTest.java | 229 - .../test/java/tests/SQLite/ConstantsTest.java | 110 - .../test/java/tests/SQLite/DatabaseTest.java | 2039 ----- .../test/java/tests/SQLite/ExceptionTest.java | 60 - .../tests/SQLite/FunctionContextTest.java | 453 -- .../SQLite/JDBCDriverFunctionalTest.java | 110 - .../java/tests/SQLite/JDBCDriverTest.java | 272 - .../test/java/tests/SQLite/SQLiteTest.java | 74 - .../src/test/java/tests/SQLite/ShellTest.java | 147 - .../src/test/java/tests/SQLite/StmtTest.java | 1263 --- .../test/java/tests/java/sql/AllTests.java | 49 - .../sql/DatabaseMetaDataNotSupportedTest.java | 2149 ----- .../tests/java/sql/DatabaseMetaDataTest.java | 2813 ------- .../java/sql/DeleteFunctionalityTest.java | 249 - .../java/sql/InsertFunctionalityTest.java | 292 - .../tests/java/sql/MultiThreadAccessTest.java | 463 -- .../java/tests/java/sql/QueryTimeoutTest.java | 766 -- .../java/sql/SelectFunctionalityTest.java | 620 -- .../test/java/tests/java/sql/StressTest.java | 371 - .../java/sql/UpdateFunctionalityTest.java | 467 -- .../java/sql/UpdateFunctionalityTest2.java | 369 - .../sql/ConnectionEventListenerTest.java | 42 - .../sql/ConnectionPoolDataSourceTest.java | 96 - .../java/tests/javax/sql/DataSourceTest.java | 96 - .../tests/javax/sql/PooledConnectionTest.java | 68 - .../tests/javax/sql/RowSetInternalTest.java | 78 - .../tests/javax/sql/RowSetListenerTest.java | 74 - .../tests/javax/sql/RowSetMetaDataTest.java | 241 - .../tests/javax/sql/RowSetReaderTest.java | 29 - .../test/java/tests/javax/sql/RowSetTest.java | 624 -- .../tests/javax/sql/RowSetWriterTest.java | 29 - .../sql/src/test/java/tests/sql/AllTests.java | 50 - .../src/test/java/tests/sql/ArrayTest.java | 165 - .../sql/src/test/java/tests/sql/BlobTest.java | 151 - .../java/tests/sql/CallableStatementTest.java | 1070 --- .../sql/src/test/java/tests/sql/ClobTest.java | 177 - .../test/java/tests/sql/ConnectionTest.java | 2807 ------- .../java/tests/sql/ParameterMetaDataTest.java | 150 - .../java/tests/sql/PreparedStatementTest.java | 3262 -------- .../sql/src/test/java/tests/sql/RefTest.java | 87 - .../java/tests/sql/ResultSetGetterTests.java | 2194 ------ .../java/tests/sql/ResultSetMetaDataTest.java | 904 --- .../tests/sql/ResultSetNotSupportedTests.java | 1352 ---- .../test/java/tests/sql/ResultSetTest.java | 894 --- .../src/test/java/tests/sql/SQLDataTest.java | 72 - .../src/test/java/tests/sql/SQLInputTest.java | 328 - .../test/java/tests/sql/SQLOutputTest.java | 347 - .../sql/src/test/java/tests/sql/SQLTest.java | 136 - .../test/java/tests/sql/SavepointTest.java | 59 - .../test/java/tests/sql/StatementTest.java | 1902 ----- .../src/test/java/tests/sql/StructTest.java | 72 - .../java/tests/support/DatabaseCreator.java | 401 - .../test/java/tests/support/MockCallback.java | 45 - .../test/java/tests/support/MockFunction.java | 54 - .../test/java/tests/support/Support_SQL.java | 111 - .../test/java/tests/support/ThreadPool.java | 120 - libcore/sql/src/test/resources/blob.c | 2 - .../src/test/resources/connection.properties | 9 - .../sql/BatchUpdateExceptionTest.golden.ser | Bin 1724 -> 0 bytes .../java/sql/DataTruncationTest.golden.ser | Bin 1754 -> 0 bytes .../java/sql/SQLExceptionTest.golden.ser | Bin 2716 -> 0 bytes .../tests/java/sql/SQLWarningTest.golden.ser | Bin 2146 -> 0 bytes .../tests/java/sql/TimestampTest.golden.ser | Bin 91 -> 0 bytes .../javax/sql/ConnectionEventTest.golden.ser | Bin 2229 -> 0 bytes .../rowset/RowSetMetaDataImplTest.golden.ser | Bin 671 -> 0 bytes .../serial/SerialExceptionTest.golden.ser | Bin 1661 -> 0 bytes libcore/suncompat/MODULE_LICENSE_APACHE2 | 0 .../src/main/java/sun/misc/Unsafe.java | 338 - .../src/test/java/sun/misc/AllTests.java | 39 - .../src/test/java/sun/misc/UnsafeTest.java | 67 - .../test/java/tests/suncompat/AllTests.java | 38 - libcore/support/MODULE_LICENSE_APACHE2 | 0 .../tests/support/CertificateStub.java | 109 - .../tests/support/IdentityScopeStub.java | 125 - .../security/tests/support/IdentityStub.java | 84 - .../tests/support/KeyStoreTestSupport.java | 177 - .../security/tests/support/MDGoldenData.java | 201 - .../MyAlgorithmParameterGeneratorSpi.java | 55 - .../tests/support/MyBasicPermission.java | 29 - .../security/tests/support/MyGuard.java | 38 - .../tests/support/MyKeyPairGenerator1.java | 146 - .../tests/support/MyKeyPairGenerator2.java | 68 - .../tests/support/MyKeyPairGenerator3.java | 51 - .../tests/support/MyKeyPairGeneratorSpi.java | 60 - .../security/tests/support/MyKeyStore.java | 238 - .../security/tests/support/MyKeyStoreSpi.java | 171 - .../tests/support/MyLoadStoreParams.java | 42 - .../tests/support/MyMessageDigest1.java | 79 - .../tests/support/MyMessageDigest2.java | 73 - .../security/tests/support/MyPermission.java | 52 - .../tests/support/MyPermissionCollection.java | 53 - .../security/tests/support/MyProvider.java | 12 - .../tests/support/MySSLContextSpi.java | 147 - .../security/tests/support/MySignature1.java | 121 - .../security/tests/support/MySignature2.java | 85 - .../support/MyTrustManagerFactorySpi.java | 71 - .../tests/support/PrivateKeyStub.java | 77 - .../security/tests/support/PublicKeyStub.java | 73 - .../security/tests/support/RandomImpl.java | 57 - .../tests/support/SecurityChecker.java | 58 - .../security/tests/support/SignerStub.java | 64 - .../security/tests/support/SpiEngUtils.java | 69 - .../security/tests/support/TestCertUtils.java | 831 -- .../security/tests/support/TestKeyPair.java | 602 -- .../tests/support/TestKeyStoreSpi.java | 260 - .../security/tests/support/TestUtils.java | 80 - .../tests/support/acl/AclEntryImpl.java | 118 - .../tests/support/acl/AclEnumerator.java | 51 - .../security/tests/support/acl/AclImpl.java | 211 - .../security/tests/support/acl/GroupImpl.java | 112 - .../security/tests/support/acl/OwnerImpl.java | 69 - .../tests/support/acl/PermissionImpl.java | 49 - .../tests/support/acl/PrincipalImpl.java | 53 - .../security/tests/support/cert/MyCRL.java | 60 - .../tests/support/cert/MyCertPath.java | 141 - .../support/cert/MyCertPathBuilderSpi.java | 47 - .../support/cert/MyCertPathValidatorSpi.java | 56 - .../support/cert/MyCertStoreParameters.java | 43 - .../tests/support/cert/MyCertStoreSpi.java | 66 - .../tests/support/cert/MyCertificate.java | 160 - .../support/cert/MyCertificateFactorySpi.java | 139 - .../tests/support/cert/MyFailingCertPath.java | 16 - .../support/cert/MyFailingCertificate.java | 16 - .../tests/support/cert/PolicyNodeImpl.java | 256 - .../tests/support/cert/TestUtils.java | 810 -- .../interfaces/DSAKeyPairGeneratorImpl.java | 84 - .../RSAMultiPrimePrivateCrtKeyImpl.java | 92 - .../tests/support/spec/MyEncodedKeySpec.java | 49 - .../tests/support/tmpCallbackHandler.java | 46 - .../serialization/SerializationTest.java | 606 -- .../support/KeyManagerFactorySpiImpl.java | 49 - .../tests/support/MyKeyManagerFactorySpi.java | 82 - .../xnet/tests/support/MySSLContextSpi.java | 145 - .../support/MyTrustManagerFactorySpi.java | 71 - .../xnet/tests/support/SSLContextSpiImpl.java | 81 - .../tests/support/SSLSocketFactoryImpl.java | 81 - .../support/TrustManagerFactorySpiImpl.java | 52 - .../tests/support/X509KeyManagerImpl.java | 223 - .../tests/support/X509TrustManagerImpl.java | 43 - .../xnet/tests/support/mySSLSession.java | 176 - .../targets/AlgorithmParameterGenerators.java | 35 - .../java/targets/AlgorithmParameters.java | 47 - .../test/java/targets/CertPathBuilders.java | 25 - .../test/java/targets/CertPathValidators.java | 24 - .../java/targets/CertificateFactories.java | 25 - .../src/test/java/targets/Charsets.java | 272 - .../support/src/test/java/targets/Cipher.java | 51 - .../src/test/java/targets/KeyAgreement.java | 36 - .../src/test/java/targets/KeyFactories.java | 35 - .../src/test/java/targets/KeyGenerator.java | 71 - .../test/java/targets/KeyPairGenerators.java | 35 - .../src/test/java/targets/KeyStores.java | 24 - .../support/src/test/java/targets/Mac.java | 56 - .../src/test/java/targets/MessageDigests.java | 49 - .../test/java/targets/SecretKeyFactory.java | 46 - .../src/test/java/targets/SecureRandoms.java | 24 - .../src/test/java/targets/Signatures.java | 64 - .../java/tests/resources/Broken_entry.jar | Bin 972 -> 0 bytes .../tests/resources/Broken_entry_data.jar | Bin 972 -> 0 bytes .../java/tests/resources/Broken_manifest.jar | Bin 972 -> 0 bytes .../java/tests/resources/Created_by_1_4.jar | Bin 2919 -> 0 bytes .../tests/resources/EmptyEntries_signed.jar | Bin 1927 -> 0 bytes .../GZIPInputStream/hyts_gInput.txt.gz | Bin 42 -> 0 bytes .../src/test/java/tests/resources/Harmony.GIF | Bin 5220 -> 0 bytes .../resources/Inserted_Entry_Manifest.jar | Bin 1977 -> 0 bytes ...nserted_Entry_Manifest_with_DigestCode.jar | Bin 1970 -> 0 bytes .../test/java/tests/resources/Integrate.jar | Bin 1963 -> 0 bytes .../java/tests/resources/JarIndex/hyts_11.jar | Bin 1219 -> 0 bytes .../java/tests/resources/JarIndex/hyts_12.jar | Bin 1250 -> 0 bytes .../java/tests/resources/JarIndex/hyts_13.jar | Bin 1698 -> 0 bytes .../java/tests/resources/JarIndex/hyts_14.jar | Bin 414 -> 0 bytes .../java/tests/resources/JarIndex/hyts_21.jar | Bin 1417 -> 0 bytes .../tests/resources/JarIndex/hyts_22-new.jar | Bin 1428 -> 0 bytes .../java/tests/resources/JarIndex/hyts_22.jar | Bin 1430 -> 0 bytes .../java/tests/resources/JarIndex/hyts_23.jar | Bin 2073 -> 0 bytes .../java/tests/resources/JarIndex/hyts_31.jar | Bin 1217 -> 0 bytes .../java/tests/resources/JarIndex/hyts_32.jar | Bin 1421 -> 0 bytes .../java/tests/resources/JarIndex/hyts_33.jar | Bin 1701 -> 0 bytes .../java/tests/resources/JarIndex/hyts_41.jar | Bin 1217 -> 0 bytes .../java/tests/resources/JarIndex/hyts_42.jar | Bin 1239 -> 0 bytes .../java/tests/resources/Modified_Class.jar | Bin 1949 -> 0 bytes .../Modified_Manifest_EntryAttributes.jar | Bin 1963 -> 0 bytes .../Modified_Manifest_MainAttributes.jar | Bin 1970 -> 0 bytes .../resources/Modified_SF_EntryAttributes.jar | Bin 1949 -> 0 bytes .../resources/Package/hyts_all_attributes.jar | Bin 742 -> 0 bytes .../Package/hyts_all_attributes_dex.jar | Bin 701 -> 0 bytes .../java/tests/resources/Package/hyts_c.jar | Bin 745 -> 0 bytes .../tests/resources/Package/hyts_c_dex.jar | Bin 704 -> 0 bytes .../resources/Package/hyts_no_attributes.jar | Bin 704 -> 0 bytes .../Package/hyts_no_attributes_dex.jar | Bin 663 -> 0 bytes .../tests/resources/Package/hyts_no_entry.jar | Bin 693 -> 0 bytes .../resources/Package/hyts_no_entry_dex.jar | Bin 654 -> 0 bytes .../tests/resources/Package/hyts_package.jar | Bin 2731 -> 0 bytes .../resources/Package/hyts_package_dex.jar | Bin 1564 -> 0 bytes .../java/tests/resources/Package/hyts_pq.jar | Bin 841 -> 0 bytes .../tests/resources/Package/hyts_pq_dex.jar | Bin 710 -> 0 bytes .../Package/hyts_some_attributes.jar | Bin 732 -> 0 bytes .../Package/hyts_some_attributes_dex.jar | Bin 692 -> 0 bytes .../java/tests/resources/TestCodeSigners.jar | Bin 3381 -> 0 bytes .../tests/resources/cts_dalvikExecTest.jar | Bin 1698 -> 0 bytes .../resources/cts_dalvikExecTest_classes.dex | Bin 2108 -> 0 bytes .../test/java/tests/resources/hyts_Bar.ser | Bin 414 -> 0 bytes .../test/java/tests/resources/hyts_Foo.ser | Bin 467 -> 0 bytes .../resources/hyts_PropertiesTest.properties | 29 - .../java/tests/resources/hyts_ZipFile.zip | Bin 1136 -> 0 bytes .../test/java/tests/resources/hyts_att.jar | Bin 625 -> 0 bytes .../java/tests/resources/hyts_available.tst | Bin 17 -> 0 bytes .../java/tests/resources/hyts_checkInput.txt | 4 - .../java/tests/resources/hyts_compDiction.txt | Bin 501 -> 0 bytes .../java/tests/resources/hyts_compressD.txt | Bin 500 -> 0 bytes .../java/tests/resources/hyts_constru_O.txt | Bin 25 -> 0 bytes .../java/tests/resources/hyts_constru_OD.txt | Bin 13 -> 0 bytes .../java/tests/resources/hyts_constru_ODI.txt | Bin 18 -> 0 bytes .../hyts_des-ede3-cbc.test1.ciphertext | 1 - .../resources/hyts_des-ede3-cbc.test1.iv | 1 - .../resources/hyts_des-ede3-cbc.test1.key | 1 - .../hyts_des-ede3-cbc.test1.plaintext | 1 - .../hyts_des-ede3-cbc.test2.ciphertext | Bin 128 -> 0 bytes .../resources/hyts_des-ede3-cbc.test2.iv | 1 - .../resources/hyts_des-ede3-cbc.test2.key | 1 - .../hyts_des-ede3-cbc.test2.plaintext | Bin 126 -> 0 bytes .../hyts_des-ede3-cbc.test3.ciphertext | Bin 10008 -> 0 bytes .../resources/hyts_des-ede3-cbc.test3.iv | 1 - .../resources/hyts_des-ede3-cbc.test3.key | 1 - .../hyts_des-ede3-cbc.test3.plaintext | Bin 10000 -> 0 bytes .../java/tests/resources/hyts_htmltest.html | 38 - .../java/tests/resources/hyts_mainClass.ser | Bin 440 -> 0 bytes .../java/tests/resources/hyts_manifest1.jar | Bin 400 -> 0 bytes .../tests/resources/hyts_missingclass.ser | Bin 493 -> 0 bytes .../test/java/tests/resources/hyts_patch.jar | Bin 972 -> 0 bytes .../test/java/tests/resources/hyts_patch2.jar | Bin 667 -> 0 bytes .../tests/resources/hyts_resource.properties | 2 - .../java/tests/resources/hyts_security.jar | Bin 1765 -> 0 bytes .../test/java/tests/resources/hyts_signed.jar | Bin 2375 -> 0 bytes .../java/tests/resources/hyts_signed_inc.jar | Bin 2392 -> 0 bytes .../java/tests/resources/illegalClasses.jar | Bin 1741 -> 0 bytes .../java/tests/resources/junit4-4.3.1.jar | Bin 107080 -> 0 bytes .../tests/resources/manifest/hyts_MANIFEST.MF | 26 - .../tests/resources/morestuff/hyts_patch.jar | Bin 972 -> 0 bytes .../tests/resources/morestuff/hyts_patch2.jar | Bin 667 -> 0 bytes .../java/tests/resources/net/InvalidJar.jar | Bin 3189 -> 0 bytes .../tests/resources/net/TestCodeSigners.jar | Bin 3381 -> 0 bytes .../src/test/java/tests/resources/net/lf.jar | Bin 33095 -> 0 bytes .../tests/resources/hyts_resource.properties | 2 - .../src/test/java/tests/resources/test.cert | 17 - .../support/Support_ASimpleInputStream.java | 76 - .../support/Support_ASimpleOutputStream.java | 99 - .../tests/support/Support_ASimpleReader.java | 70 - .../tests/support/Support_ASimpleWriter.java | 80 - .../java/tests/support/Support_BitSet.java | 202 - .../tests/support/Support_ClassLoader.java | 84 - .../tests/support/Support_CollectionTest.java | 109 - .../tests/support/Support_Configuration.java | 482 -- .../tests/support/Support_DecimalFormat.java | 304 - .../support/Support_DeleteOnExitTest.java | 20 - .../test/java/tests/support/Support_Exec.java | 220 - .../java/tests/support/Support_Field.java | 45 - .../java/tests/support/Support_Format.java | 143 - .../java/tests/support/Support_GetLocal.java | 101 - .../tests/support/Support_GetPutFields.java | 133 - .../Support_GetPutFieldsDefaulted.java | 139 - .../Support_GetPutFieldsDeprecated.java | 134 - .../tests/support/Support_GetResource.java | 25 - .../tests/support/Support_HttpConstants.java | 157 - .../Support_IOTestSecurityManager.java | 43 - .../java/tests/support/Support_ListTest.java | 223 - .../java/tests/support/Support_Locale.java | 48 - .../java/tests/support/Support_MapTest2.java | 66 - .../tests/support/Support_MessageFormat.java | 119 - .../support/Support_NetworkInterface.java | 47 - .../tests/support/Support_OutputStream.java | 110 - .../tests/support/Support_PlatformFile.java | 36 - .../tests/support/Support_PortManager.java | 105 - .../tests/support/Support_ProviderTrust.java | 93 - .../java/tests/support/Support_Proxy_I1.java | 28 - .../java/tests/support/Support_Proxy_I2.java | 27 - .../Support_Proxy_ParentException.java | 22 - .../support/Support_Proxy_SubException.java | 23 - .../java/tests/support/Support_SetTest.java | 51 - .../support/Support_SimpleDateFormat.java | 263 - .../tests/support/Support_StringReader.java | 247 - .../tests/support/Support_StringWriter.java | 178 - .../tests/support/Support_TestProvider.java | 125 - .../tests/support/Support_TestResource.java | 31 - .../support/Support_TestResource_en.java | 30 - .../support/Support_TestResource_en_US.java | 30 - .../support/Support_TestResource_fr.java | 30 - .../support/Support_TestResource_fr_FR.java | 30 - .../Support_TestResource_fr_FR_VAR.java | 31 - .../tests/support/Support_TestWebData.java | 197 - .../tests/support/Support_TestWebServer.java | 979 --- .../java/tests/support/Support_TimeZone.java | 83 - .../Support_UnmodifiableCollectionTest.java | 114 - .../support/Support_UnmodifiableMapTest.java | 164 - .../support/resource/Support_Resources.java | 208 - .../tests/util/CallVerificationStack.java | 353 - .../tests/util/FieldTestFileGenerator.java | 107 - .../src/test/java/tests/util/PrefsTester.java | 73 - .../java/tests/util/SerializationTester.java | 246 - libcore/support/src/test/resources/hyts_Foo.c | 1 - libcore/text/MODULE_LICENSE_APACHE2 | 0 .../src/main/java/java/text/Annotation.java | 69 - .../text/AttributedCharacterIterator.java | 242 - .../main/java/java/text/AttributedString.java | 775 -- .../text/src/main/java/java/text/Bidi.java | 648 -- .../main/java/java/text/BreakIterator.java | 615 -- .../java/java/text/CharacterIterator.java | 116 - .../src/main/java/java/text/ChoiceFormat.java | 474 -- .../java/text/CollationElementIterator.java | 226 - .../src/main/java/java/text/CollationKey.java | 160 - .../src/main/java/java/text/Collator.java | 456 -- .../src/main/java/java/text/DateFormat.java | 998 --- .../java/java/text/DateFormatSymbols.java | 482 -- .../main/java/java/text/DecimalFormat.java | 1493 ---- .../java/java/text/DecimalFormatSymbols.java | 564 -- .../main/java/java/text/FieldPosition.java | 172 - .../text/src/main/java/java/text/Format.java | 328 - .../main/java/java/text/MessageFormat.java | 1379 ---- .../src/main/java/java/text/NumberFormat.java | 900 --- .../main/java/java/text/ParseException.java | 51 - .../main/java/java/text/ParsePosition.java | 114 - .../java/text/RuleBasedBreakIterator.java | 209 - .../java/java/text/RuleBasedCollator.java | 458 -- .../main/java/java/text/SimpleDateFormat.java | 1475 ---- .../java/text/StringCharacterIterator.java | 270 - .../text/src/main/java/java/text/package.html | 17 - .../java/org/apache/harmony/text/BidiRun.java | 55 - .../org/apache/harmony/text/BidiWrapper.java | 88 - .../harmony/text/internal/nls/Messages.java | 146 - .../text/internal/nls/messages.properties | 46 - .../text/tests/java/text/AllTests.java | 64 - .../text/tests/java/text/AnnotationTest.java | 78 - ...ributedCharacterIteratorAttributeTest.java | 252 - .../text/AttributedCharacterIteratorTest.java | 452 -- .../tests/java/text/AttributedStringTest.java | 609 -- .../text/tests/java/text/BidiTest.java | 2077 ----- .../tests/java/text/BreakIteratorTest.java | 803 -- .../tests/java/text/ChoiceFormatTest.java | 592 -- .../text/CollationElementIteratorTest.java | 296 - .../tests/java/text/CollationKeyTest.java | 159 - .../text/tests/java/text/CollatorTest.java | 516 -- .../tests/java/text/DataFormatFieldTest.java | 265 - .../java/text/DateFormatSymbolsTest.java | 510 -- .../text/tests/java/text/DateFormatTest.java | 1120 --- .../java/text/DecimalFormatSymbolsTest.java | 806 -- .../tests/java/text/DecimalFormatTest.java | 2553 ------ .../tests/java/text/DecimalFormatTestICU.java | 218 - .../tests/java/text/FieldPositionTest.java | 338 - .../text/tests/java/text/FormatFieldTest.java | 58 - .../text/tests/java/text/FormatTest.java | 160 - .../java/text/MessageFormatFieldTest.java | 128 - .../tests/java/text/MessageFormatTest.java | 1328 ---- .../java/text/NumberFormatFieldTest.java | 129 - .../tests/java/text/NumberFormatTest.java | 1446 ---- .../tests/java/text/ParseExceptionTest.java | 84 - .../tests/java/text/ParsePositionTest.java | 190 - .../java/text/RuleBasedCollatorTest.java | 495 -- .../tests/java/text/SimpleDateFormatTest.java | 1179 --- .../text/StringCharacterIteratorTest.java | 667 -- .../java/text/Support_DecimalFormat.java | 287 - .../text/tests/java/text/Support_Format.java | 143 - .../java/text/Support_MessageFormat.java | 120 - .../java/text/Support_SimpleDateFormat.java | 266 - .../src/test/java/tests/text/AllTests.java | 40 - .../serialization/java/text/DecimalFormat.ser | Bin 1384 -> 0 bytes .../java/text/DecimalFormatSymbols.ser | Bin 495 -> 0 bytes libcore/tools/integrate/Android.mk | 19 - libcore/tools/integrate/Command.java | 104 - libcore/tools/integrate/Filesystem.java | 63 - libcore/tools/integrate/Git.java | 90 - libcore/tools/integrate/MappedDirectory.java | 41 - libcore/tools/integrate/Module.java | 67 - libcore/tools/integrate/Modules.java | 62 - libcore/tools/integrate/PullHarmonyCode.java | 109 - libcore/tools/integrate/Svn.java | 25 - libcore/x-net/MODULE_LICENSE_APACHE2 | 0 .../javax/net/DefaultServerSocketFactory.java | 49 - .../java/javax/net/DefaultSocketFactory.java | 60 - .../java/javax/net/ServerSocketFactory.java | 109 - .../main/java/javax/net/SocketFactory.java | 153 - .../src/main/java/javax/net/package.html | 16 - .../ssl/CertPathTrustManagerParameters.java | 52 - .../net/ssl/DefaultHostnameVerifier.java | 366 - .../java/javax/net/ssl/DefaultSSLContext.java | 124 - .../ssl/DefaultSSLServerSocketFactory.java | 64 - .../net/ssl/DefaultSSLSocketFactory.java | 76 - .../net/ssl/HandshakeCompletedEvent.java | 141 - .../net/ssl/HandshakeCompletedListener.java | 34 - .../java/javax/net/ssl/HostnameVerifier.java | 40 - .../javax/net/ssl/HttpsURLConnection.java | 222 - .../main/java/javax/net/ssl/KeyManager.java | 27 - .../java/javax/net/ssl/KeyManagerFactory.java | 233 - .../javax/net/ssl/KeyManagerFactorySpi.java | 74 - .../net/ssl/KeyStoreBuilderParameters.java | 79 - .../net/ssl/ManagerFactoryParameters.java | 27 - .../main/java/javax/net/ssl/SSLContext.java | 253 - .../java/javax/net/ssl/SSLContextSpi.java | 109 - .../main/java/javax/net/ssl/SSLEngine.java | 464 -- .../java/javax/net/ssl/SSLEngineResult.java | 172 - .../main/java/javax/net/ssl/SSLException.java | 61 - .../javax/net/ssl/SSLHandshakeException.java | 37 - .../java/javax/net/ssl/SSLKeyException.java | 36 - .../net/ssl/SSLPeerUnverifiedException.java | 38 - .../java/javax/net/ssl/SSLPermission.java | 58 - .../javax/net/ssl/SSLProtocolException.java | 37 - .../java/javax/net/ssl/SSLServerSocket.java | 232 - .../javax/net/ssl/SSLServerSocketFactory.java | 103 - .../main/java/javax/net/ssl/SSLSession.java | 231 - .../javax/net/ssl/SSLSessionBindingEvent.java | 75 - .../net/ssl/SSLSessionBindingListener.java | 44 - .../java/javax/net/ssl/SSLSessionContext.java | 82 - .../main/java/javax/net/ssl/SSLSocket.java | 299 - .../java/javax/net/ssl/SSLSocketFactory.java | 143 - .../main/java/javax/net/ssl/TrustManager.java | 28 - .../javax/net/ssl/TrustManagerFactory.java | 229 - .../javax/net/ssl/TrustManagerFactorySpi.java | 67 - .../javax/net/ssl/X509ExtendedKeyManager.java | 76 - .../java/javax/net/ssl/X509KeyManager.java | 113 - .../java/javax/net/ssl/X509TrustManager.java | 76 - .../src/main/java/javax/net/ssl/package.html | 26 - .../harmony/xnet/internal/nls/Messages.java | 147 - .../xnet/internal/nls/messages.properties | 17 - .../provider/jsse/AbstractSessionContext.java | 212 - .../xnet/provider/jsse/AlertException.java | 66 - .../xnet/provider/jsse/AlertProtocol.java | 286 - .../xnet/provider/jsse/Appendable.java | 33 - .../provider/jsse/CertificateMessage.java | 176 - .../provider/jsse/CertificateRequest.java | 189 - .../xnet/provider/jsse/CertificateVerify.java | 97 - .../xnet/provider/jsse/CipherSuite.java | 610 -- .../provider/jsse/ClientHandshakeImpl.java | 628 -- .../xnet/provider/jsse/ClientHello.java | 206 - .../xnet/provider/jsse/ClientKeyExchange.java | 152 - .../provider/jsse/ClientSessionContext.java | 224 - .../xnet/provider/jsse/ConnectionState.java | 169 - .../provider/jsse/ConnectionStateSSLv3.java | 354 - .../provider/jsse/ConnectionStateTLS.java | 352 - .../xnet/provider/jsse/ContentType.java | 49 - .../xnet/provider/jsse/DHParameters.java | 108 - .../xnet/provider/jsse/DataStream.java | 42 - .../xnet/provider/jsse/DelegatedTask.java | 65 - .../xnet/provider/jsse/DigitalSignature.java | 254 - .../provider/jsse/EndOfBufferException.java | 35 - .../provider/jsse/EndOfSourceException.java | 34 - .../provider/jsse/FileClientSessionCache.java | 374 - .../harmony/xnet/provider/jsse/Finished.java | 82 - .../harmony/xnet/provider/jsse/Handshake.java | 89 - .../provider/jsse/HandshakeIODataStream.java | 464 -- .../xnet/provider/jsse/HandshakeProtocol.java | 534 -- .../xnet/provider/jsse/HelloRequest.java | 77 - .../xnet/provider/jsse/JSSEProvider.java | 135 - .../provider/jsse/KeyManagerFactoryImpl.java | 133 - .../xnet/provider/jsse/KeyManagerImpl.java | 186 - .../harmony/xnet/provider/jsse/Logger.java | 122 - .../harmony/xnet/provider/jsse/Message.java | 74 - .../xnet/provider/jsse/NativeCrypto.java | 91 - .../provider/jsse/OpenSSLMessageDigest.java | 118 - .../jsse/OpenSSLMessageDigestJDK.java | 117 - .../jsse/OpenSSLServerSocketFactoryImpl.java | 71 - .../jsse/OpenSSLServerSocketImpl.java | 331 - .../provider/jsse/OpenSSLSessionImpl.java | 523 -- .../xnet/provider/jsse/OpenSSLSignature.java | 215 - .../jsse/OpenSSLSocketFactoryImpl.java | 85 - .../xnet/provider/jsse/OpenSSLSocketImpl.java | 1050 --- .../jsse/OpenSSLSocketImplWrapper.java | 203 - .../harmony/xnet/provider/jsse/PRF.java | 201 - .../xnet/provider/jsse/ProtocolVersion.java | 158 - .../xnet/provider/jsse/SSLBufferedInput.java | 81 - .../provider/jsse/SSLClientSessionCache.java | 53 - .../xnet/provider/jsse/SSLContextImpl.java | 129 - .../xnet/provider/jsse/SSLEngineAppData.java | 95 - .../provider/jsse/SSLEngineDataStream.java | 91 - .../xnet/provider/jsse/SSLEngineImpl.java | 769 -- .../xnet/provider/jsse/SSLInputStream.java | 134 - .../xnet/provider/jsse/SSLParameters.java | 453 -- .../xnet/provider/jsse/SSLRecordProtocol.java | 482 -- .../provider/jsse/SSLServerSessionCache.java | 52 - .../xnet/provider/jsse/SSLSessionImpl.java | 361 - .../xnet/provider/jsse/SSLStreamedInput.java | 57 - .../xnet/provider/jsse/SSLv3Constants.java | 84 - .../provider/jsse/ServerHandshakeImpl.java | 720 -- .../xnet/provider/jsse/ServerHello.java | 137 - .../xnet/provider/jsse/ServerHelloDone.java | 78 - .../xnet/provider/jsse/ServerKeyExchange.java | 193 - .../provider/jsse/ServerSessionContext.java | 124 - .../jsse/TrustManagerFactoryImpl.java | 134 - .../xnet/provider/jsse/TrustManagerImpl.java | 234 - ...armony_xnet_provider_jsse_NativeCrypto.cpp | 465 -- ..._provider_jsse_OpenSSLServerSocketImpl.cpp | 324 - ..._xnet_provider_jsse_OpenSSLSessionImpl.cpp | 348 - ...y_xnet_provider_jsse_OpenSSLSocketImpl.cpp | 1945 ----- ...apache_harmony_xnet_provider_jsse_common.h | 121 - libcore/x-net/src/main/native/sub.mk | 24 - .../jsse/ClientSessionContextTest.java | 86 - .../xnet/provider/jsse/FakeSession.java | 114 - .../jsse/FileClientSessionCacheTest.java | 57 - .../java/tests/api/javax/net/AllTests.java | 42 - .../javax/net/ServerSocketFactoryTest.java | 251 - .../api/javax/net/SocketFactoryTest.java | 408 - .../tests/api/javax/net/ssl/AllTests.java | 76 - .../CertPathTrustManagerParametersTest.java | 96 - .../javax/net/ssl/CertificatesToPlayWith.java | 478 -- .../net/ssl/HandshakeCompletedEventTest.java | 720 -- .../javax/net/ssl/HostnameVerifierTest.java | 213 - .../javax/net/ssl/HttpsURLConnectionTest.java | 498 -- .../javax/net/ssl/KeyManagerFactory1Test.java | 634 -- .../javax/net/ssl/KeyManagerFactory2Test.java | 287 - .../net/ssl/KeyManagerFactorySpiTest.java | 180 - .../ssl/KeyStoreBuilderParametersTest.java | 150 - .../api/javax/net/ssl/SSLContext1Test.java | 718 -- .../api/javax/net/ssl/SSLContext2Test.java | 323 - .../api/javax/net/ssl/SSLContextSpiTest.java | 323 - .../SSLEngineResultHandshakeStatusTest.java | 100 - .../net/ssl/SSLEngineResultStatusTest.java | 107 - .../javax/net/ssl/SSLEngineResultTest.java | 259 - .../api/javax/net/ssl/SSLEngineTest.java | 1927 ----- .../api/javax/net/ssl/SSLExceptionTest.java | 211 - .../net/ssl/SSLHandshakeExceptionTest.java | 73 - .../javax/net/ssl/SSLKeyExceptionTest.java | 73 - .../ssl/SSLPeerUnverifiedExceptionTest.java | 73 - .../api/javax/net/ssl/SSLPermissionTest.java | 92 - .../net/ssl/SSLProtocolExceptionTest.java | 73 - .../net/ssl/SSLServerSocketFactoryTest.java | 135 - .../javax/net/ssl/SSLServerSocketTest.java | 588 -- .../net/ssl/SSLSessionBindingEventTest.java | 260 - .../ssl/SSLSessionBindingListenerTest.java | 104 - .../javax/net/ssl/SSLSessionContextTest.java | 141 - .../api/javax/net/ssl/SSLSessionTest.java | 875 --- .../javax/net/ssl/SSLSocketFactoryTest.java | 178 - .../api/javax/net/ssl/SSLSocketTest.java | 892 --- .../net/ssl/TrustManagerFactory1Test.java | 712 -- .../net/ssl/TrustManagerFactory2Test.java | 279 - .../net/ssl/TrustManagerFactorySpiTest.java | 168 - .../net/ssl/X509ExtendedKeyManagerTest.java | 200 - .../api/javax/net/ssl/X509KeyManagerTest.java | 794 -- .../javax/net/ssl/X509TrustManagerTest.java | 258 - .../src/test/java/tests/xnet/AllTests.java | 40 - libcore/xml/MODULE_LICENSE_APACHE2 | 0 libcore/xml/MODULE_LICENSE_BSD_LIKE | 1 - libcore/xml/MODULE_LICENSE_W3C | 3 - .../src/main/java/javax/xml/XMLConstants.java | 97 - .../xml/src/main/java/javax/xml/package.html | 8 - .../javax/xml/parsers/DocumentBuilder.java | 252 - .../xml/parsers/DocumentBuilderFactory.java | 405 - .../parsers/FactoryConfigurationError.java | 126 - .../parsers/ParserConfigurationException.java | 47 - .../java/javax/xml/parsers/SAXParser.java | 390 - .../javax/xml/parsers/SAXParserFactory.java | 283 - .../main/java/javax/xml/parsers/package.html | 24 - .../apache/harmony/xml/ExpatAttributes.java | 154 - .../apache/harmony/xml/ExpatException.java | 28 - .../org/apache/harmony/xml/ExpatParser.java | 794 -- .../apache/harmony/xml/ExpatPullParser.java | 964 --- .../org/apache/harmony/xml/ExpatReader.java | 335 - .../org/apache/harmony/xml/dom/AttrImpl.java | 177 - .../harmony/xml/dom/CDATASectionImpl.java | 49 - .../harmony/xml/dom/CharacterDataImpl.java | 93 - .../apache/harmony/xml/dom/CommentImpl.java | 49 - .../xml/dom/DOMImplementationImpl.java | 78 - .../harmony/xml/dom/DocumentFragmentImpl.java | 50 - .../apache/harmony/xml/dom/DocumentImpl.java | 298 - .../harmony/xml/dom/DocumentTypeImpl.java | 110 - .../apache/harmony/xml/dom/ElementImpl.java | 446 -- .../apache/harmony/xml/dom/EntityImpl.java | 71 - .../harmony/xml/dom/EntityReferenceImpl.java | 52 - .../apache/harmony/xml/dom/InnerNodeImpl.java | 221 - .../apache/harmony/xml/dom/LeafNodeImpl.java | 70 - .../harmony/xml/dom/NamedNodeMapImpl.java | 176 - .../org/apache/harmony/xml/dom/NodeImpl.java | 191 - .../apache/harmony/xml/dom/NodeListImpl.java | 63 - .../apache/harmony/xml/dom/NotationImpl.java | 64 - .../xml/dom/ProcessingInstructionImpl.java | 74 - .../org/apache/harmony/xml/dom/TextImpl.java | 70 - .../parsers/DocumentBuilderFactoryImpl.java | 106 - .../xml/parsers/DocumentBuilderImpl.java | 436 -- .../xml/parsers/SAXParserFactoryImpl.java | 123 - .../harmony/xml/parsers/SAXParserImpl.java | 91 - .../main/java/org/kxml2/io/KXmlParser.java | 1440 ---- .../java/org/kxml2/io/KXmlSerializer.java | 562 -- .../main/java/org/kxml2/kdom/Document.java | 129 - .../src/main/java/org/kxml2/kdom/Element.java | 335 - .../src/main/java/org/kxml2/kdom/Node.java | 366 - .../src/main/java/org/kxml2/wap/Wbxml.java | 49 - .../main/java/org/kxml2/wap/WbxmlParser.java | 1075 --- .../java/org/kxml2/wap/WbxmlSerializer.java | 512 -- .../java/org/kxml2/wap/syncml/SyncML.java | 192 - .../src/main/java/org/kxml2/wap/wml/Wml.java | 233 - .../src/main/java/org/kxml2/wap/wv/WV.java | 593 -- .../xml/src/main/java/org/w3c/dom/Attr.java | 134 - .../main/java/org/w3c/dom/CDATASection.java | 48 - .../main/java/org/w3c/dom/CharacterData.java | 171 - .../src/main/java/org/w3c/dom/Comment.java | 24 - .../main/java/org/w3c/dom/DOMException.java | 130 - .../java/org/w3c/dom/DOMImplementation.java | 105 - .../src/main/java/org/w3c/dom/Document.java | 382 - .../java/org/w3c/dom/DocumentFragment.java | 52 - .../main/java/org/w3c/dom/DocumentType.java | 99 - .../src/main/java/org/w3c/dom/Element.java | 314 - .../xml/src/main/java/org/w3c/dom/Entity.java | 82 - .../java/org/w3c/dom/EntityReference.java | 39 - .../main/java/org/w3c/dom/NamedNodeMap.java | 168 - .../xml/src/main/java/org/w3c/dom/Node.java | 454 -- .../src/main/java/org/w3c/dom/NodeList.java | 53 - .../src/main/java/org/w3c/dom/Notation.java | 49 - .../org/w3c/dom/ProcessingInstruction.java | 58 - .../xml/src/main/java/org/w3c/dom/Text.java | 61 - .../src/main/java/org/w3c/dom/package.html | 12 - .../main/java/org/xml/sax/AttributeList.java | 193 - .../src/main/java/org/xml/sax/Attributes.java | 257 - .../main/java/org/xml/sax/ContentHandler.java | 419 - .../src/main/java/org/xml/sax/DTDHandler.java | 117 - .../java/org/xml/sax/DocumentHandler.java | 232 - .../main/java/org/xml/sax/EntityResolver.java | 119 - .../main/java/org/xml/sax/ErrorHandler.java | 139 - .../main/java/org/xml/sax/HandlerBase.java | 369 - .../main/java/org/xml/sax/InputSource.java | 337 - .../src/main/java/org/xml/sax/Locator.java | 136 - .../xml/src/main/java/org/xml/sax/Parser.java | 209 - .../main/java/org/xml/sax/SAXException.java | 153 - .../xml/sax/SAXNotRecognizedException.java | 53 - .../org/xml/sax/SAXNotSupportedException.java | 53 - .../java/org/xml/sax/SAXParseException.java | 269 - .../src/main/java/org/xml/sax/XMLFilter.java | 65 - .../src/main/java/org/xml/sax/XMLReader.java | 404 - .../java/org/xml/sax/ext/Attributes2.java | 132 - .../java/org/xml/sax/ext/Attributes2Impl.java | 320 - .../java/org/xml/sax/ext/DeclHandler.java | 146 - .../java/org/xml/sax/ext/DefaultHandler2.java | 185 - .../java/org/xml/sax/ext/EntityResolver2.java | 197 - .../java/org/xml/sax/ext/LexicalHandler.java | 212 - .../main/java/org/xml/sax/ext/Locator2.java | 75 - .../java/org/xml/sax/ext/Locator2Impl.java | 105 - .../main/java/org/xml/sax/ext/package.html | 48 - .../xml/sax/helpers/AttributeListImpl.java | 314 - .../org/xml/sax/helpers/AttributesImpl.java | 618 -- .../org/xml/sax/helpers/DefaultHandler.java | 467 -- .../java/org/xml/sax/helpers/LocatorImpl.java | 214 - .../org/xml/sax/helpers/NamespaceSupport.java | 840 -- .../java/org/xml/sax/helpers/NewInstance.java | 79 - .../org/xml/sax/helpers/ParserAdapter.java | 1046 --- .../org/xml/sax/helpers/ParserFactory.java | 133 - .../org/xml/sax/helpers/XMLFilterImpl.java | 715 -- .../org/xml/sax/helpers/XMLReaderAdapter.java | 538 -- .../org/xml/sax/helpers/XMLReaderFactory.java | 206 - .../java/org/xml/sax/helpers/package.html | 13 - .../src/main/java/org/xml/sax/package.html | 299 - .../java/org/xmlpull/v1/XmlPullParser.java | 1116 --- .../xmlpull/v1/XmlPullParserException.java | 76 - .../org/xmlpull/v1/XmlPullParserFactory.java | 349 - .../java/org/xmlpull/v1/XmlSerializer.java | 326 - .../main/java/org/xmlpull/v1/sax2/Driver.java | 469 -- .../org_apache_harmony_xml_ExpatParser.cpp | 1530 ---- libcore/xml/src/main/native/sub.mk | 20 - .../apache/harmony/xml/ExpatParserTest.java | 839 -- .../tests/api/javax/xml/parsers/AllTests.java | 49 - .../parsers/DocumentBuilderFactoryTest.java | 1121 --- .../xml/parsers/DocumentBuilderTest.java | 753 -- .../FactoryConfigurationErrorTest.java | 139 - .../ParserConfigurationExceptionTest.java | 55 - .../xml/parsers/SAXParserFactoryTest.java | 547 -- .../api/javax/xml/parsers/SAXParserTest.java | 1177 --- .../xml/parsers/SAXParserTestSupport.java | 492 -- .../java/tests/api/org/xml/sax/AllTests.java | 45 - .../api/org/xml/sax/HandlerBaseTest.java | 226 - .../api/org/xml/sax/InputSourceTest.java | 254 - .../api/org/xml/sax/SAXExceptionTest.java | 131 - .../sax/SAXNotRecognizedExceptionTest.java | 55 - .../xml/sax/SAXNotSupportedExceptionTest.java | 55 - .../org/xml/sax/SAXParseExceptionTest.java | 276 - .../tests/api/org/xml/sax/ext/AllTests.java | 39 - .../org/xml/sax/ext/Attributes2ImplTest.java | 464 -- .../org/xml/sax/ext/DefaultHandler2Test.java | 234 - .../api/org/xml/sax/ext/Locator2ImplTest.java | 153 - .../api/org/xml/sax/helpers/AllTests.java | 45 - .../sax/helpers/AttributeListImplTest.java | 270 - .../xml/sax/helpers/AttributesImplTest.java | 608 -- .../xml/sax/helpers/DefaultHandlerTest.java | 278 - .../org/xml/sax/helpers/LocatorImplTest.java | 172 - .../xml/sax/helpers/NamespaceSupportTest.java | 434 -- .../xml/sax/helpers/ParserAdapterTest.java | 468 -- .../xml/sax/helpers/ParserFactoryTest.java | 161 - .../xml/sax/helpers/XMLFilterImplTest.java | 678 -- .../xml/sax/helpers/XMLReaderAdapterTest.java | 414 - .../xml/sax/helpers/XMLReaderFactoryTest.java | 154 - .../xml/sax/support/BrokenInputStream.java | 50 - .../org/xml/sax/support/DoNothingParser.java | 55 - .../xml/sax/support/DoNothingXMLReader.java | 79 - .../api/org/xml/sax/support/MethodLogger.java | 95 - .../api/org/xml/sax/support/MockFilter.java | 89 - .../api/org/xml/sax/support/MockHandler.java | 147 - .../api/org/xml/sax/support/MockParser.java | 68 - .../api/org/xml/sax/support/MockReader.java | 128 - .../api/org/xml/sax/support/MockResolver.java | 47 - .../org/xml/sax/support/NoAccessParser.java | 55 - .../xml/sax/support/NoAccessXMLReader.java | 79 - .../org/xml/sax/support/NoInstanceParser.java | 58 - .../xml/sax/support/NoInstanceXMLReader.java | 82 - .../org/xml/sax/support/NoSubclassParser.java | 54 - .../xml/sax/support/NoSubclassXMLReader.java | 79 - .../test/java/tests/org/w3c/dom/AllTests.java | 110 - .../org/w3c/dom/AttrGetOwnerElement.java | 156 - .../tests/org/w3c/dom/CreateAttributeNS.java | 229 - .../tests/org/w3c/dom/CreateDocument.java | 317 - .../tests/org/w3c/dom/CreateDocumentType.java | 222 - .../tests/org/w3c/dom/CreateElementNS.java | 251 - .../w3c/dom/DOMDocumentBuilderFactory.java | 94 - .../dom/DOMImplementationCreateDocument.java | 177 - .../DOMImplementationCreateDocumentType.java | 208 - .../w3c/dom/DOMImplementationHasFeature.java | 147 - .../java/tests/org/w3c/dom/DOMTestCase.java | 230 - .../org/w3c/dom/DocumentBuilderSetting.java | 281 - .../dom/DocumentBuilderSettingStrategy.java | 158 - .../w3c/dom/DocumentCreateAttributeNS.java | 313 - .../org/w3c/dom/DocumentCreateElementNS.java | 169 - .../dom/DocumentGetElementsByTagnameNS.java | 150 - .../org/w3c/dom/DocumentGeteEementById.java | 72 - .../tests/org/w3c/dom/DocumentImportNode.java | 699 -- .../w3c/dom/DocumentTypeInternalSubset.java | 76 - .../org/w3c/dom/DocumentTypePublicId.java | 97 - .../org/w3c/dom/DocumentTypeSystemId.java | 95 - .../org/w3c/dom/ElementGetAttributeNS.java | 89 - .../w3c/dom/ElementGetAttributeNodeNS.java | 139 - .../dom/ElementGetElementsByTagNameNS.java | 122 - .../org/w3c/dom/ElementHasAttribute.java | 123 - .../org/w3c/dom/ElementHasAttributeNS.java | 139 - .../org/w3c/dom/ElementRemoveAttributeNS.java | 80 - .../org/w3c/dom/ElementSetAttributeNS.java | 266 - .../w3c/dom/ElementSetAttributeNodeNS.java | 276 - .../tests/org/w3c/dom/GetAttributeNS.java | 187 - .../tests/org/w3c/dom/GetAttributeNodeNS.java | 121 - .../tests/org/w3c/dom/GetElementById.java | 102 - .../org/w3c/dom/GetElementsByTagNameNS.java | 381 - .../tests/org/w3c/dom/GetNamedItemNS.java | 135 - .../w3c/dom/HCEntitiesRemoveNamedItemNS.java | 102 - .../org/w3c/dom/HCEntitiesSetNamedItemNS.java | 86 - .../w3c/dom/HCNamedNodeMapInvalidType.java | 103 - .../dom/HCNodeDocumentFragmentNormalize.java | 108 - .../w3c/dom/HCNotationsRemoveNamedItemNS.java | 110 - .../w3c/dom/HCNotationsSetNamedItemNS.java | 112 - .../java/tests/org/w3c/dom/HasAttribute.java | 119 - .../tests/org/w3c/dom/HasAttributeNS.java | 172 - .../java/tests/org/w3c/dom/HasAttributes.java | 111 - .../java/tests/org/w3c/dom/ImportNode.java | 604 -- .../tests/org/w3c/dom/InternalSubset.java | 92 - .../java/tests/org/w3c/dom/IsSupported.java | 272 - .../java/tests/org/w3c/dom/LocalName.java | 132 - .../w3c/dom/NamedNodeMapGetNamedItemNS.java | 229 - .../dom/NamedNodeMapRemoveNamedItemNS.java | 342 - .../w3c/dom/NamedNodeMapSetNamedItemNS.java | 451 -- .../java/tests/org/w3c/dom/NamespaceURI.java | 153 - .../tests/org/w3c/dom/NodeGetLocalName.java | 107 - .../org/w3c/dom/NodeGetNamespaceURI.java | 111 - .../org/w3c/dom/NodeGetOwnerDocument.java | 128 - .../java/tests/org/w3c/dom/NodeGetPrefix.java | 108 - .../tests/org/w3c/dom/NodeHasAttributes.java | 171 - .../tests/org/w3c/dom/NodeIsSupported.java | 216 - .../java/tests/org/w3c/dom/NodeNormalize.java | 209 - .../java/tests/org/w3c/dom/NodeSetPrefix.java | 314 - .../java/tests/org/w3c/dom/Normalize.java | 106 - .../java/tests/org/w3c/dom/OwnerDocument.java | 88 - .../java/tests/org/w3c/dom/OwnerElement.java | 118 - .../test/java/tests/org/w3c/dom/Prefix.java | 337 - .../test/java/tests/org/w3c/dom/PublicId.java | 91 - .../tests/org/w3c/dom/RemoveAttributeNS.java | 147 - .../tests/org/w3c/dom/RemoveNamedItemNS.java | 178 - .../tests/org/w3c/dom/SetAttributeNS.java | 353 - .../tests/org/w3c/dom/SetAttributeNodeNS.java | 237 - .../tests/org/w3c/dom/SetNamedItemNS.java | 248 - .../test/java/tests/org/w3c/dom/SystemId.java | 94 - .../xml/src/test/java/tests/xml/AllTests.java | 38 - .../java/tests/xml/SimpleBuilderTest.java | 162 - .../test/java/tests/xml/SimpleParserTest.java | 289 - .../src/test/resources/SimpleBuilderTest.xml | 21 - .../src/test/resources/SimpleParserTest.xml | 19 - libcore/xml/src/test/resources/hc_staff.xml | 60 - libcore/xml/src/test/resources/nwf/staff.dtd | 17 - libcore/xml/src/test/resources/nwf/staff.xml | 57 - .../xml/src/test/resources/out_dh/staff.out | 45 - .../xml/src/test/resources/out_hb/staff.out | 45 - libcore/xml/src/test/resources/recipe.xml | 24 - libcore/xml/src/test/resources/recipe1.xml | 24 - libcore/xml/src/test/resources/recipt.dtd | 17 - libcore/xml/src/test/resources/recipt.xml | 24 - .../xml/src/test/resources/reciptWrong.xml | 21 - libcore/xml/src/test/resources/simple.xml | 34 - libcore/xml/src/test/resources/simple_ns.dtd | 45 - libcore/xml/src/test/resources/simple_ns.xml | 59 - libcore/xml/src/test/resources/staff.dtd | 17 - libcore/xml/src/test/resources/staff.xml | 57 - libcore/xml/src/test/resources/staff2.dtd | 24 - libcore/xml/src/test/resources/staff2.xml | 13 - .../xml/src/test/resources/staffEntRes.xml | 60 - libcore/xml/src/test/resources/staffNS.dtd | 45 - libcore/xml/src/test/resources/staffNS.xml | 59 - libcore/xml/src/test/resources/systemid.xml | 24 - .../src/test/resources/systemid/recipt.dtd | 17 - .../xml/src/test/resources/systemid/staff.dtd | 17 - libcore/xml/src/test/resources/wf/staff.dtd | 17 - libcore/xml/src/test/resources/wf/staff.xml | 57 - libcore/xml/src/test/resources/wrong.xml | 1 - .../xml/src/test/resources/xhtml1-strict.dtd | 65 - 5086 files changed, 1127693 deletions(-) delete mode 100644 libcore/Android.mk delete mode 100644 libcore/AndroidManifest.xml delete mode 100644 libcore/NOTICE delete mode 100644 libcore/annotation/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/annotation/src/main/java/java/lang/annotation/Annotation.java delete mode 100644 libcore/annotation/src/main/java/java/lang/annotation/AnnotationFormatError.java delete mode 100644 libcore/annotation/src/main/java/java/lang/annotation/AnnotationTypeMismatchException.java delete mode 100644 libcore/annotation/src/main/java/java/lang/annotation/Documented.java delete mode 100644 libcore/annotation/src/main/java/java/lang/annotation/ElementType.java delete mode 100644 libcore/annotation/src/main/java/java/lang/annotation/IncompleteAnnotationException.java delete mode 100644 libcore/annotation/src/main/java/java/lang/annotation/Inherited.java delete mode 100644 libcore/annotation/src/main/java/java/lang/annotation/Retention.java delete mode 100644 libcore/annotation/src/main/java/java/lang/annotation/RetentionPolicy.java delete mode 100644 libcore/annotation/src/main/java/java/lang/annotation/Target.java delete mode 100644 libcore/annotation/src/main/java/java/lang/annotation/package.html delete mode 100644 libcore/annotation/src/main/java/org/apache/harmony/annotation/internal/nls/Messages.java delete mode 100644 libcore/annotation/src/main/java/org/apache/harmony/annotation/internal/nls/messages.properties delete mode 100644 libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AllTests.java delete mode 100644 libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationFormatErrorTest.java delete mode 100644 libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationTest.java delete mode 100644 libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationTypeMismatchExceptionTest.java delete mode 100644 libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/ElementTypeTest.java delete mode 100644 libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/IncompleteAnnotationExceptionTest.java delete mode 100644 libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/RetentionPolicyTest.java delete mode 100644 libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation1.java delete mode 100644 libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation2.java delete mode 100644 libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation3.java delete mode 100644 libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation3b.java delete mode 100644 libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation4.java delete mode 100644 libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestEnum1.java delete mode 100644 libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestEnum1b.java delete mode 100644 libcore/annotation/src/test/java/tests/annotation/AllTests.java delete mode 100644 libcore/archive/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/archive/src/main/java/java/util/jar/Attributes.java delete mode 100644 libcore/archive/src/main/java/java/util/jar/InitManifest.java delete mode 100644 libcore/archive/src/main/java/java/util/jar/JarEntry.java delete mode 100644 libcore/archive/src/main/java/java/util/jar/JarException.java delete mode 100644 libcore/archive/src/main/java/java/util/jar/JarFile.java delete mode 100644 libcore/archive/src/main/java/java/util/jar/JarInputStream.java delete mode 100644 libcore/archive/src/main/java/java/util/jar/JarOutputStream.java delete mode 100644 libcore/archive/src/main/java/java/util/jar/JarVerifier.java delete mode 100644 libcore/archive/src/main/java/java/util/jar/Manifest.java delete mode 100644 libcore/archive/src/main/java/java/util/jar/Pack200.java delete mode 100644 libcore/archive/src/main/java/java/util/jar/package.html delete mode 100644 libcore/archive/src/main/java/java/util/zip/Adler32.java delete mode 100644 libcore/archive/src/main/java/java/util/zip/CRC32.java delete mode 100644 libcore/archive/src/main/java/java/util/zip/CheckedInputStream.java delete mode 100644 libcore/archive/src/main/java/java/util/zip/CheckedOutputStream.java delete mode 100644 libcore/archive/src/main/java/java/util/zip/Checksum.java delete mode 100644 libcore/archive/src/main/java/java/util/zip/DataFormatException.java delete mode 100644 libcore/archive/src/main/java/java/util/zip/Deflater.java delete mode 100644 libcore/archive/src/main/java/java/util/zip/DeflaterOutputStream.java delete mode 100644 libcore/archive/src/main/java/java/util/zip/GZIPInputStream.java delete mode 100644 libcore/archive/src/main/java/java/util/zip/GZIPOutputStream.java delete mode 100644 libcore/archive/src/main/java/java/util/zip/Inflater.java delete mode 100644 libcore/archive/src/main/java/java/util/zip/InflaterInputStream.java delete mode 100644 libcore/archive/src/main/java/java/util/zip/ZipConstants.java delete mode 100644 libcore/archive/src/main/java/java/util/zip/ZipEntry.java delete mode 100644 libcore/archive/src/main/java/java/util/zip/ZipException.java delete mode 100644 libcore/archive/src/main/java/java/util/zip/ZipFile.java delete mode 100644 libcore/archive/src/main/java/java/util/zip/ZipInputStream.java delete mode 100644 libcore/archive/src/main/java/java/util/zip/ZipOutputStream.java delete mode 100644 libcore/archive/src/main/java/java/util/zip/package.html delete mode 100644 libcore/archive/src/main/java/org/apache/harmony/archive/internal/nls/Messages.java delete mode 100644 libcore/archive/src/main/java/org/apache/harmony/archive/internal/nls/messages.properties delete mode 100644 libcore/archive/src/main/java/org/apache/harmony/archive/util/Util.java delete mode 100644 libcore/archive/src/main/native/hy2sie.h delete mode 100644 libcore/archive/src/main/native/hycomp.h delete mode 100644 libcore/archive/src/main/native/hymutex.h delete mode 100644 libcore/archive/src/main/native/hyport.h delete mode 100644 libcore/archive/src/main/native/java_util_zip_Adler32.c delete mode 100644 libcore/archive/src/main/native/java_util_zip_CRC32.c delete mode 100644 libcore/archive/src/main/native/java_util_zip_Deflater.c delete mode 100644 libcore/archive/src/main/native/java_util_zip_Inflater.c delete mode 100644 libcore/archive/src/main/native/sieb.c delete mode 100644 libcore/archive/src/main/native/sieb.h delete mode 100644 libcore/archive/src/main/native/sub.mk delete mode 100644 libcore/archive/src/main/native/zip.c delete mode 100644 libcore/archive/src/main/native/zip.h delete mode 100644 libcore/archive/src/main/native/zipalloc.c delete mode 100644 libcore/archive/src/main/native/zipsup.c delete mode 100644 libcore/archive/src/main/native/zipsup.h delete mode 100644 libcore/archive/src/test/java-internal/org/apache/harmony/archive/util/UtilTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AllTests.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesNameTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/DalvikExecTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarEntryTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExecTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200PackerTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200Test.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200UnpackerTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ZipExecTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/Adler32Test.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/AllTests.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CRC32Test.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedOutputStreamTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DataFormatExceptionTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPInputStreamTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPOutputStreamTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipEntryTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipExceptionTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java delete mode 100644 libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipOutputStreamTest.java delete mode 100644 libcore/archive/src/test/java/tests/archive/AllTests.java delete mode 100644 libcore/auth/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/auth/src/main/java/javax/security/auth/AuthPermission.java delete mode 100644 libcore/auth/src/main/java/javax/security/auth/DestroyFailedException.java delete mode 100644 libcore/auth/src/main/java/javax/security/auth/Destroyable.java delete mode 100644 libcore/auth/src/main/java/javax/security/auth/PrivateCredentialPermission.java delete mode 100644 libcore/auth/src/main/java/javax/security/auth/Subject.java delete mode 100644 libcore/auth/src/main/java/javax/security/auth/SubjectDomainCombiner.java delete mode 100644 libcore/auth/src/main/java/javax/security/auth/callback/Callback.java delete mode 100644 libcore/auth/src/main/java/javax/security/auth/callback/CallbackHandler.java delete mode 100644 libcore/auth/src/main/java/javax/security/auth/callback/PasswordCallback.java delete mode 100644 libcore/auth/src/main/java/javax/security/auth/callback/UnsupportedCallbackException.java delete mode 100644 libcore/auth/src/main/java/javax/security/auth/callback/package.html delete mode 100644 libcore/auth/src/main/java/javax/security/auth/login/LoginException.java delete mode 100644 libcore/auth/src/main/java/javax/security/auth/login/package.html delete mode 100644 libcore/auth/src/main/java/javax/security/auth/package.html delete mode 100644 libcore/auth/src/main/java/javax/security/auth/x500/X500Principal.java delete mode 100644 libcore/auth/src/main/java/javax/security/auth/x500/package.html delete mode 100644 libcore/auth/src/main/java/org/apache/harmony/auth/internal/nls/Messages.java delete mode 100644 libcore/auth/src/main/java/org/apache/harmony/auth/internal/nls/messages.properties delete mode 100644 libcore/awt-kernel/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/awt-kernel/src/main/java/java/awt/font/NumericShaper.java delete mode 100644 libcore/awt-kernel/src/main/java/java/awt/font/TextAttribute.java delete mode 100644 libcore/awt-kernel/src/main/java/java/beans/IndexedPropertyChangeEvent.java delete mode 100644 libcore/awt-kernel/src/main/java/java/beans/PropertyChangeEvent.java delete mode 100644 libcore/awt-kernel/src/main/java/java/beans/PropertyChangeListener.java delete mode 100644 libcore/awt-kernel/src/main/java/java/beans/PropertyChangeListenerProxy.java delete mode 100644 libcore/awt-kernel/src/main/java/java/beans/PropertyChangeSupport.java delete mode 100644 libcore/concurrent/MODULE_LICENSE_PUBLIC_DOMAIN delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/AbstractExecutorService.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/ArrayBlockingQueue.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/BlockingQueue.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/BrokenBarrierException.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/Callable.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/CancellationException.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/CompletionService.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/ConcurrentHashMap.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/ConcurrentLinkedQueue.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/ConcurrentMap.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/CopyOnWriteArrayList.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/CopyOnWriteArraySet.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/CountDownLatch.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/CyclicBarrier.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/DelayQueue.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/Delayed.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/Exchanger.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/ExecutionException.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/Executor.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/ExecutorCompletionService.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/ExecutorService.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/Executors.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/Future.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/FutureTask.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/Java6Arrays.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/LinkedBlockingQueue.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/PriorityBlockingQueue.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/RejectedExecutionException.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/RejectedExecutionHandler.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/ScheduledExecutorService.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/ScheduledFuture.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/ScheduledThreadPoolExecutor.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/Semaphore.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/SynchronousQueue.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/ThreadFactory.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/ThreadPoolExecutor.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/TimeUnit.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/TimeoutException.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicBoolean.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicInteger.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicIntegerArray.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLong.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLongArray.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLongFieldUpdater.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicMarkableReference.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReference.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReferenceArray.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicStampedReference.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/atomic/UnsafeAccess.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/atomic/package-info.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/locks/AbstractOwnableSynchronizer.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/locks/AbstractQueuedSynchronizer.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/locks/Condition.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/locks/Lock.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/locks/LockSupport.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/locks/ReadWriteLock.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/locks/ReentrantLock.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/locks/ReentrantReadWriteLock.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/locks/UnsafeAccess.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/locks/package-info.java delete mode 100644 libcore/concurrent/src/main/java/java/util/concurrent/package-info.java delete mode 100644 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AbstractExecutorServiceTest.java delete mode 100644 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AbstractQueueTest.java delete mode 100644 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AbstractQueuedSynchronizerTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ArrayBlockingQueueTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicBooleanTest.java delete mode 100644 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicIntegerArrayTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicIntegerFieldUpdaterTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicIntegerTest.java delete mode 100644 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicLongArrayTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicLongFieldUpdaterTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicLongTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicMarkableReferenceTest.java delete mode 100644 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicReferenceArrayTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicReferenceFieldUpdaterTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicReferenceTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicStampedReferenceTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ConcurrentHashMapTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ConcurrentLinkedQueueTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/CopyOnWriteArrayListTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/CopyOnWriteArraySetTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/CountDownLatchTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/CyclicBarrierTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/DelayQueueTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ExchangerTest.java delete mode 100644 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ExecutorCompletionServiceTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ExecutorsTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/FutureTaskTest.java delete mode 100644 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/JSR166TestCase.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/LinkedBlockingQueueTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/LinkedListTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/LockSupportTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/PriorityBlockingQueueTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/PriorityQueueTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ReentrantLockTest.java delete mode 100644 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ReentrantReadWriteLockTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ScheduledExecutorTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/SemaphoreTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/SynchronousQueueTest.java delete mode 100644 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/SystemTest.java delete mode 100644 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ThreadLocalTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ThreadPoolExecutorTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ThreadTest.java delete mode 100755 libcore/concurrent/src/test/java/tests/api/java/util/concurrent/TimeUnitTest.java delete mode 100644 libcore/concurrent/src/test/java/tests/concurrent/AllTests.java delete mode 100644 libcore/crypto/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/crypto/src/main/java/javax/crypto/BadPaddingException.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/Cipher.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/CipherInputStream.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/CipherOutputStream.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/CipherSpi.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/EncryptedPrivateKeyInfo.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/ExemptionMechanism.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/ExemptionMechanismException.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/ExemptionMechanismSpi.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/IllegalBlockSizeException.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/KeyAgreement.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/KeyAgreementSpi.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/KeyGenerator.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/KeyGeneratorSpi.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/Mac.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/MacSpi.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/NoSuchPaddingException.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/NullCipher.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/SealedObject.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/SecretKey.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/SecretKeyFactory.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/SecretKeyFactorySpi.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/ShortBufferException.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/interfaces/DHKey.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/interfaces/DHPrivateKey.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/interfaces/DHPublicKey.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/interfaces/PBEKey.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/interfaces/package.html delete mode 100644 libcore/crypto/src/main/java/javax/crypto/package.html delete mode 100644 libcore/crypto/src/main/java/javax/crypto/spec/DESKeySpec.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/spec/DESedeKeySpec.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/spec/DHGenParameterSpec.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/spec/DHParameterSpec.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/spec/DHPrivateKeySpec.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/spec/DHPublicKeySpec.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/spec/IvParameterSpec.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/spec/OAEPParameterSpec.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/spec/PBEKeySpec.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/spec/PBEParameterSpec.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/spec/PSource.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/spec/RC2ParameterSpec.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/spec/RC5ParameterSpec.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/spec/SecretKeySpec.java delete mode 100644 libcore/crypto/src/main/java/javax/crypto/spec/package.html delete mode 100644 libcore/crypto/src/main/java/org/apache/harmony/crypto/internal/NullCipherSpi.java delete mode 100644 libcore/crypto/src/main/java/org/apache/harmony/crypto/internal/nls/Messages.java delete mode 100644 libcore/crypto/src/main/java/org/apache/harmony/crypto/internal/nls/messages.properties delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/AllTests.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/BadPaddingExceptionTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherInputStream1Test.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherInputStreamTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherOutputStream1Test.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherOutputStreamTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherSpiTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/EncryptedPrivateKeyInfoTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismExceptionTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismSpiTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/IllegalBlockSizeExceptionTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreementSpiTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreementTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGeneratorSpiTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGeneratorTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/MacSpiTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/NoSuchPaddingExceptionTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/NullCipherTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/SealedObjectTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactorySpiTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactoryTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/ShortBufferExceptionTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/AllTests.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesWrapTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeWrapTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDesTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBETest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBEThread.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherRSATest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherRSAThread.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherSymmetricKeyThread.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherThread.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherWrapThread.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementFunctionalTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementThread.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyGeneratorFunctionalTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyGeneratorThread.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/MacFunctionalTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/MacThread.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/SecretKeyFactoryFunctionalTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/SecretKeyFactoryThread.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/TestThread.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/AllTests.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPrivateKeyTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPublicKeyTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/PBEKeyTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/AllTests.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/AllTests.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESKeySpecTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESedeKeySpecTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHGenParameterSpecTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHParameterSpecTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHPrivateKeySpecTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHPublicKeySpecTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/IvParameterSpecTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/OAEPParameterSpecTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/PBEKeySpecTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/PBEParameterSpecTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/PSourceTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC2ParameterSpecTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC5ParameterSpecTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/EncryptedPrivateKeyInfoData.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyCipher.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyExemptionMechanismSpi.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyKeyAgreementSpi.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyKeyGeneratorSpi.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyMacSpi.java delete mode 100644 libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MySecretKeyFactorySpi.java delete mode 100644 libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.0.ser delete mode 100644 libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.1.ser delete mode 100644 libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.2.ser delete mode 100644 libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.golden.0.ser delete mode 100644 libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.golden.1.ser delete mode 100644 libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.golden.2.ser delete mode 100644 libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.golden.0.ser delete mode 100644 libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.golden.1.ser delete mode 100644 libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.golden.2.ser delete mode 100644 libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.golden.0.ser delete mode 100644 libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.golden.1.ser delete mode 100644 libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.golden.2.ser delete mode 100644 libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.golden.0.ser delete mode 100644 libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.golden.1.ser delete mode 100644 libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.golden.2.ser delete mode 100644 libcore/crypto/src/test/java/tests/crypto/AllTests.java delete mode 100644 libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test1.ciphertext delete mode 100644 libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test1.iv delete mode 100644 libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test1.key delete mode 100644 libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test1.plaintext delete mode 100644 libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test2.ciphertext delete mode 100644 libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test2.iv delete mode 100644 libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test2.key delete mode 100644 libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test2.plaintext delete mode 100644 libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test3.ciphertext delete mode 100644 libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test3.iv delete mode 100644 libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test3.key delete mode 100644 libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test3.plaintext delete mode 100644 libcore/dalvik/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/AndroidOnly.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/AnnotationDefault.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/BrokenTest.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/EnclosingClass.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/EnclosingMethod.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/HostController.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/InnerClass.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/KnownFailure.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/MemberClasses.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/SideEffect.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/Signature.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/TestInfo.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/TestLevel.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/TestStatus.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/TestTarget.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/TestTargetClass.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/TestTargetNew.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/TestTargets.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/Throws.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/Timeout.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/ToBeFixed.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/VirtualTestTarget.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/annotation/package.html delete mode 100644 libcore/dalvik/src/main/java/dalvik/bytecode/Opcodes.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/bytecode/package.html delete mode 100644 libcore/dalvik/src/main/java/dalvik/system/AllocationLimitError.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/system/DexClassLoader.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/system/DexFile.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/system/NativeStart.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/system/PathClassLoader.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/system/PotentialDeadlockError.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/system/SamplingProfiler.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/system/StaleDexCacheError.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/system/TemporaryDirectory.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/system/TouchDex.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/system/TouchDexLoader.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/system/VMDebug.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/system/VMRuntime.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/system/VMStack.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/system/Zygote.java delete mode 100644 libcore/dalvik/src/main/java/dalvik/system/package.html delete mode 100644 libcore/dalvik/src/main/java/org/apache/harmony/dalvik/NativeTestTarget.java delete mode 100644 libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/Chunk.java delete mode 100644 libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/ChunkHandler.java delete mode 100644 libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/DdmServer.java delete mode 100644 libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/DdmVmInternal.java delete mode 100644 libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/README.txt delete mode 100644 libcore/dalvik/src/main/native/dalvik_system_TouchDex.cpp delete mode 100644 libcore/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.c delete mode 100644 libcore/dalvik/src/main/native/sub.mk delete mode 100644 libcore/dom/src/test/java/README delete mode 100644 libcore/dom/src/test/java/org/w3c/dom/DOMError.java delete mode 100644 libcore/dom/src/test/java/org/w3c/dom/DOMErrorHandler.java delete mode 100644 libcore/dom/src/test/java/org/w3c/dom/DOMLocator.java delete mode 100644 libcore/dom/src/test/java/org/w3c/dom/UserDataHandler.java delete mode 100644 libcore/dom/src/test/java/org/w3c/dom/events/Event.java delete mode 100644 libcore/dom/src/test/java/org/w3c/dom/events/EventException.java delete mode 100644 libcore/dom/src/test/java/org/w3c/dom/events/EventListener.java delete mode 100644 libcore/dom/src/test/java/org/w3c/dom/events/EventTarget.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/BatikTestDocumentBuilderFactory.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/DOM4JTestDocumentBuilderFactory.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/DOMErrorImpl.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/DOMErrorMonitor.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/DOMLocatorImpl.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/DOMTest.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/DOMTestCase.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/DOMTestDocumentBuilderFactory.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/DOMTestFramework.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/DOMTestIncompatibleException.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/DOMTestInnerClass.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/DOMTestLoadException.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/DOMTestSink.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/DOMTestSuite.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/DocumentBuilderSetting.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/DocumentBuilderSettingStrategy.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/EventMonitor.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/JAXPDOMTestDocumentBuilderFactory.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/JTidyDOMImplementation.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/JTidyDocumentBuilderFactory.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/JUnitTestCaseAdapter.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/JUnitTestSuiteAdapter.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/JunitTestCases.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/LSDocumentBuilderFactory.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/UserDataMonitor.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/UserDataNotification.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/XalanDOMTestDocumentBuilderFactory.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/XercesHTML2DocumentBuilderFactory.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/XercesHTMLDocumentBuilderFactory.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/TestBatik.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/TestCrimson.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/TestCrimsonAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDOM4J.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDefaultLS.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDefaultLSAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDefaultParser.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDefaultParserAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/TestGNUJAXP.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/TestGNUJAXPAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/TestJTidy.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/TestOracle.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/TestOracleAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/TestXerces.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/TestXercesAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/alltests.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/attrcreatedocumentfragment.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/attrcreatetextnode.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/attrcreatetextnode2.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/attrdefaultvalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/attreffectivevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/attrentityreplacement.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/attrname.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/attrnextsiblingnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/attrnotspecifiedvalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/attrparentnodenull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/attrprevioussiblingnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/attrremovechild1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/attrreplacechild1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/attrsetvaluenomodificationallowederr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/attrsetvaluenomodificationallowederrEE.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/attrspecifiedvalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/attrspecifiedvaluechanged.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/attrspecifiedvalueremove.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/cdatasectiongetdata.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/cdatasectionnormalize.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataappenddata.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataappenddatagetdata.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataappenddatanomodificationallowederr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataappenddatanomodificationallowederrEE.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatabegining.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedataend.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedataexceedslength.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatagetlengthanddata.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatamiddle.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatanomodificationallowederr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatanomodificationallowederrEE.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatagetdata.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatagetlength.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrdeletedatacountnegative.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrdeletedataoffsetgreater.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrdeletedataoffsetnegative.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrinsertdataoffsetgreater.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrinsertdataoffsetnegative.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrreplacedatacountnegative.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrreplacedataoffsetgreater.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrreplacedataoffsetnegative.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrsubstringcountnegative.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrsubstringnegativeoffset.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrsubstringoffsetgreater.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdatabeginning.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdataend.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdatamiddle.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdatanomodificationallowederr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdatanomodificationallowederrEE.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedatabegining.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedataend.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedataexceedslengthofarg.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedataexceedslengthofdata.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedatamiddle.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedatanomodificationallowederr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedatanomodificationallowederrEE.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasetdatanomodificationallowederr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasetdatanomodificationallowederrEE.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasetnodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasubstringexceedsvalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasubstringvalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/commentgetcomment.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreatecdatasection.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreatecomment.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreatedocumentfragment.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateelement.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateelementcasesensitive.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateelementdefaultattr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateentityreference.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateentityreferenceknown.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateprocessinginstruction.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreatetextnode.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetdoctype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetdoctypenodtd.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetelementsbytagnamelength.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetelementsbytagnametotallength.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetelementsbytagnamevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetimplementation.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetrootnode.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreateattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreateelement.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreateentref.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreateentref1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreatepi.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreatepi1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetdoctype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetentities.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetentitieslength.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetentitiestype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetnotations.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetnotationstype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/domimplementationfeaturenoversion.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/domimplementationfeaturenull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/domimplementationfeaturexml.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementaddnewattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementassociatedattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementchangeattributevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementcreatenewattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetattributenode.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetattributenodenull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementempty.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementsbytagname.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementsbytagnameaccessnodelist.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementsbytagnamenomatch.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementsbytagnamespecialvalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgettagname.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementinuseattributeerr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementinvalidcharacterexception.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementnormalize.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementnotfounderr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributeaftercreate.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenode.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenodenomodificationallowederr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenodenomodificationallowederrEE.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenomodificationallowederr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenomodificationallowederrEE.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributerestoredefaultvalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementreplaceattributewithself.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementreplaceexistingattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementreplaceexistingattributegevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementretrieveallattributes.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementretrieveattrvalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementretrievetagname.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenodenomodificationallowederr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenodenomodificationallowederrEE.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenodenull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenomodificationallowederr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenomodificationallowederrEE.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/elementwrongdocumenterr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/entitygetentityname.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/entitygetpublicid.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/entitygetpublicidnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild2.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild3.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild4.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild5.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild6.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrchildnodes1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrchildnodes2.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrclonenode1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrcreatedocumentfragment.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrcreatetextnode.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrcreatetextnode2.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attreffectivevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrfirstchild.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrgetvalue1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrgetvalue2.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrhaschildnodes.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore2.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore3.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore4.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore5.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore6.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore7.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrlastchild.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrname.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrnextsiblingnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrnormalize.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrparentnodenull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrprevioussiblingnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrremovechild1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrremovechild2.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrreplacechild1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrreplacechild2.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrsetvalue1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrsetvalue2.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrspecifiedvalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrspecifiedvaluechanged.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataappenddata.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataappenddatagetdata.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedatabegining.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedataend.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedataexceedslength.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedatagetlengthanddata.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedatamiddle.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatagetdata.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatagetlength.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrdeletedatacountnegative.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrdeletedataoffsetgreater.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrdeletedataoffsetnegative.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrinsertdataoffsetgreater.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrinsertdataoffsetnegative.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedatacountnegative.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedataoffsetgreater.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedataoffsetnegative.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrsubstringcountnegative.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrsubstringnegativeoffset.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrsubstringoffsetgreater.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatainsertdatabeginning.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatainsertdataend.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatainsertdatamiddle.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedatabegining.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedataend.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedataexceedslengthofarg.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedataexceedslengthofdata.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedatamiddle.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatasetnodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatasubstringexceedsvalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatasubstringvalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_commentgetcomment.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreateattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreatecomment.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreatedocumentfragment.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreateelement.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreateelementcasesensitive.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreatetextnode.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetdoctype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetelementsbytagnamelength.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetelementsbytagnametotallength.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetelementsbytagnamevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetimplementation.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetrootnode.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentinvalidcharacterexceptioncreateattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentinvalidcharacterexceptioncreateattribute1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentinvalidcharacterexceptioncreateelement.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentinvalidcharacterexceptioncreateelement1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_domimplementationfeaturenoversion.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_domimplementationfeaturenull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_domimplementationfeaturexml.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementaddnewattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementassociatedattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementchangeattributevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementcreatenewattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetattributenode.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetattributenodenull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementempty.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementsbytagname.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementsbytagnameaccessnodelist.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementsbytagnamenomatch.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementsbytagnamespecialvalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgettagname.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementinuseattributeerr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementinvalidcharacterexception.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementinvalidcharacterexception1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementnormalize.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementnormalize2.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementnotfounderr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementremoveattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementremoveattributeaftercreate.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementremoveattributenode.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementreplaceattributewithself.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementreplaceexistingattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementreplaceexistingattributegevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementretrieveallattributes.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementretrieveattrvalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementretrievetagname.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementsetattributenodenull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementwrongdocumenterr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_entitiesremovenameditem1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_entitiessetnameditem1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapchildnoderange.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapgetnameditem.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapinuseattributeerr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapnotfounderr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapnumberofnodes.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapremovenameditem.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapreturnattrnode.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapreturnfirstitem.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapreturnlastitem.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapreturnnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapsetnameditem.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapsetnameditemreturnvalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapsetnameditemthatexists.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapsetnameditemwithnewvalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapwrongdocumenterr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchild.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildchildexists.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchilddocfragment.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildgetnodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildinvalidnodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildnewchilddiffdocument.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildnodeancestor.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeattributenodeattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeattributenodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeattributenodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeattributenodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodechildnodes.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodechildnodesappendchild.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodechildnodesempty.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecloneattributescopied.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonefalsenocopytext.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonegetparentnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonenodefalse.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonenodetrue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonetruecopytext.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecommentnodeattributes.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecommentnodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecommentnodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecommentnodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentfragmentnodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentfragmentnodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentfragmentnodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentnodeattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentnodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentnodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentnodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeelementnodeattributes.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeelementnodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeelementnodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeelementnodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetfirstchild.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetfirstchildnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetlastchild.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetlastchildnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetnextsibling.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetnextsiblingnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetownerdocument.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetownerdocumentnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetprevioussibling.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetprevioussiblingnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodehaschildnodes.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodehaschildnodesfalse.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbefore.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforedocfragment.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforeinvalidnodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforenewchilddiffdocument.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforenewchildexists.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforenodeancestor.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforenodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforerefchildnonexistent.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforerefchildnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistindexequalzero.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistindexgetlength.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistindexgetlengthofemptylist.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistindexnotzero.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistreturnfirstitem.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistreturnlastitem.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelisttraverselist.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeparentnode.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeparentnodenull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_noderemovechild.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_noderemovechildgetnodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_noderemovechildnode.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_noderemovechildoldchildnonexistent.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechild.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildinvalidnodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildnewchilddiffdocument.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildnewchildexists.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildnodeancestor.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildnodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildoldchildnonexistent.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodetextnodeattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodetextnodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodetextnodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodetextnodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue06.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue07.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue08.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_notationsremovenameditem1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_notationssetnameditem1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textindexsizeerrnegativeoffset.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textindexsizeerroffsetoutofbounds.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textparseintolistofelements.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textsplittextfour.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textsplittextone.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textsplittextthree.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textsplittexttwo.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textwithnomarkup.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapchildnoderange.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapgetnameditem.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapinuseattributeerr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapnotfounderr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapnumberofnodes.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapremovenameditem.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapremovenameditemgetvalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapremovenameditemreturnnodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapreturnattrnode.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapreturnfirstitem.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapreturnlastitem.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapreturnnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapsetnameditem.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapsetnameditemreturnvalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapsetnameditemthatexists.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapsetnameditemwithnewvalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapwrongdocumenterr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchild.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildchildexists.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchilddocfragment.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildgetnodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildinvalidnodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildnewchilddiffdocument.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildnodeancestor.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildnomodificationallowederr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildnomodificationallowederrEE.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeattributenodeattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeattributenodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeattributenodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeattributenodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecdatasectionnodeattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecdatasectionnodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecdatasectionnodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecdatasectionnodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodechildnodes.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodechildnodesappendchild.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodechildnodesempty.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecloneattributescopied.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonefalsenocopytext.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonegetparentnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonenodefalse.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonenodetrue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonetruecopytext.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecommentnodeattributes.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecommentnodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecommentnodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecommentnodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentfragmentnodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentfragmentnodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentfragmentnodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentnodeattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentnodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentnodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentnodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumenttypenodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumenttypenodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumenttypenodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeelementnodeattributes.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeelementnodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeelementnodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeelementnodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitynodeattributes.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitynodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitynodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitynodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentityreferencenodeattributes.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentityreferencenodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentityreferencenodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentityreferencenodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitysetnodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetfirstchild.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetfirstchildnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetlastchild.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetlastchildnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetnextsibling.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetnextsiblingnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetownerdocument.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetownerdocumentnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetprevioussibling.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetprevioussiblingnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodehaschildnodes.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodehaschildnodesfalse.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbefore.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforedocfragment.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforeinvalidnodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenewchilddiffdocument.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenewchildexists.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenodeancestor.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenomodificationallowederr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenomodificationallowederrEE.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforerefchildnonexistent.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforerefchildnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistindexequalzero.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistindexgetlength.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistindexgetlengthofemptylist.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistindexnotzero.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistreturnfirstitem.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistreturnlastitem.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelisttraverselist.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodenotationnodeattributes.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodenotationnodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodenotationnodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodenotationnodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeparentnode.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeparentnodenull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionnodeattributes.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionnodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionnodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionnodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionsetnodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechild.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildgetnodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildnode.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildnomodificationallowederr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildnomodificationallowederrEE.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildoldchildnonexistent.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechild.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildinvalidnodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnewchilddiffdocument.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnewchildexists.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnodeancestor.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnomodificationallowederr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnomodificationallowederrEE.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildoldchildnonexistent.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodesetnodevaluenomodificationallowederr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodesetnodevaluenomodificationallowederrEE.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodetextnodeattribute.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodetextnodename.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodetextnodetype.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodetextnodevalue.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue06.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue07.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue08.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue09.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetnotationname.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetpublicid.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetpublicidnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetsystemid.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetsystemidnull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/processinginstructiongetdata.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/processinginstructiongettarget.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/processinginstructionsetdatanomodificationallowederr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/processinginstructionsetdatanomodificationallowederrEE.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/textindexsizeerrnegativeoffset.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/textindexsizeerroffsetoutofbounds.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/textparseintolistofelements.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextfour.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextnomodificationallowederr.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextnomodificationallowederrEE.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextone.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextthree.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittexttwo.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/core/textwithnomarkup.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/html/TestDefaultLS.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/html/TestDefaultLSAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level1/html/TestXercesHTML.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/TestBatik.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/TestCrimson.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/TestCrimsonAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDOM4J.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDefaultLS.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDefaultLSAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDefaultParser.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDefaultParserAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/TestGNUJAXP.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/TestGNUJAXPAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/TestJTidy.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/TestOracle.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/TestOracleAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/TestXerces.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/TestXercesAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/alltests.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS06.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument06.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument07.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument08.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocumentType01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocumentType02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocumentType03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocumentType04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS06.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS06.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS07.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateelementNS01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateelementNS02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateelementNS05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateelementNS06.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementbyid01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode06.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode07.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode08.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode09.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode10.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode11.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode12.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode13.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode14.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode15.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode17.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode18.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode19.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode20.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode21.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode22.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documenttypeinternalSubset01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documenttypepublicid01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/documenttypesystemid01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocument03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocument04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocument05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocument07.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocumenttype01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocumenttype02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocumenttype04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationfeaturecore.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationfeaturexmlversion2.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationhasfeature01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationhasfeature02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetattributenodens01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetattributenodens02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetattributenodens03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetattributens02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetelementsbytagnamens02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetelementsbytagnamens04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetelementsbytagnamens05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattribute01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattribute02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattribute03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattribute04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattributens01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattributens02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattributens03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementremoveattributens01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens06.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens08.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributensurinull.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNodeNS01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNodeNS02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementById01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementById02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS06.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS07.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS08.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS09.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS10.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS11.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS12.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS13.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS14.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getNamedItemNS01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getNamedItemNS02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getNamedItemNS03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/getNamedItemNS04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttribute01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttribute02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttribute03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttribute04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributes01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributes02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_entitiesremovenameditemns1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_entitiessetnameditemns1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_namednodemapinvalidtype1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_nodedocumentfragmentnormalize1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_nodedocumentfragmentnormalize2.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_notationsremovenameditemns1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_notationssetnameditemns1.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode06.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode07.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode08.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode09.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode10.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode11.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode12.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode13.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode14.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode15.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode16.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode17.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/internalSubset01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported06.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported07.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported09.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported10.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported11.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported12.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported13.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported14.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/localName01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/localName02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/localName03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/localName04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns06.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns06.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns07.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns08.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns09.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns06.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns07.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns08.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns09.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns10.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns11.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namespaceURI01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namespaceURI02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namespaceURI03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/namespaceURI04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetlocalname03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetnamespaceuri03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetownerdocument01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetownerdocument02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetprefix03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodehasattributes01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodehasattributes02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodehasattributes03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodehasattributes04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodenormalize01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix06.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix07.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix08.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix09.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/normalize01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/ownerDocument01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/ownerElement01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/ownerElement02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix06.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix07.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix08.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix09.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix10.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix11.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/publicId01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/removeAttributeNS01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/removeAttributeNS02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/removeNamedItemNS01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/removeNamedItemNS02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/removeNamedItemNS03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS06.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS07.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS09.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS10.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS02.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS03.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS04.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS05.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/core/systemId01.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/events/TestBatik.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/events/TestDefaultLS.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/events/TestDefaultLSAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/events/TestDefaultParser.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/events/TestDefaultParserAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/events/TestOracle.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/events/TestOracleAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/events/TestXerces.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/events/TestXercesAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/html/TestDefaultLS.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/html/TestDefaultLSAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level2/html/TestXercesHTML.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/core/TestBatik.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/core/TestDefaultLS.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/core/TestDefaultLSAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/core/TestDefaultParser.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/core/TestDefaultParserAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/core/TestOracle.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/core/TestOracleAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/core/TestXerces.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/core/TestXercesAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestBatik.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestDefaultLS.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestDefaultParser.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestOracle.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestXerces.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestBatik.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestDefaultLS.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestDefaultLSAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestDefaultParser.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestDefaultParserAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestOracle.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestOracleAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestBatik.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestDefaultLS.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestDefaultLSAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestDefaultParser.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestDefaultParserAltConfig.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestXalan.java delete mode 100644 libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestXalanAltConfig.java delete mode 100644 libcore/dom/src/test/java/tests/api/org/w3c/dom/AllTests.java delete mode 100644 libcore/dom/src/test/java/tests/api/org/w3c/dom/AllTests_Level1.java delete mode 100644 libcore/dom/src/test/java/tests/api/org/w3c/dom/AllTests_Level2.java delete mode 100644 libcore/dom/src/test/java/tests/dom/AllTests.java delete mode 100644 libcore/dom/src/test/resources/META-INF/MANIFEST.MF delete mode 100644 libcore/dom/src/test/resources/build.xml delete mode 100644 libcore/dom/src/test/resources/hc_nodtdstaff.html delete mode 100644 libcore/dom/src/test/resources/hc_nodtdstaff.svg delete mode 100644 libcore/dom/src/test/resources/hc_nodtdstaff.xhtml delete mode 100644 libcore/dom/src/test/resources/hc_nodtdstaff.xml delete mode 100644 libcore/dom/src/test/resources/hc_staff.html delete mode 100644 libcore/dom/src/test/resources/hc_staff.svg delete mode 100644 libcore/dom/src/test/resources/hc_staff.xhtml delete mode 100644 libcore/dom/src/test/resources/hc_staff.xml delete mode 100644 libcore/dom/src/test/resources/internalSubset01.js delete mode 100644 libcore/dom/src/test/resources/nodtdstaff.svg delete mode 100644 libcore/dom/src/test/resources/nodtdstaff.xml delete mode 100644 libcore/dom/src/test/resources/staff.dtd delete mode 100644 libcore/dom/src/test/resources/staff.svg delete mode 100644 libcore/dom/src/test/resources/staff.xml delete mode 100644 libcore/dom/src/test/resources/staff2.dtd delete mode 100644 libcore/dom/src/test/resources/staff2.svg delete mode 100644 libcore/dom/src/test/resources/staff2.xml delete mode 100644 libcore/dom/src/test/resources/staffNS.dtd delete mode 100644 libcore/dom/src/test/resources/staffNS.svg delete mode 100644 libcore/dom/src/test/resources/staffNS.xml delete mode 100644 libcore/dom/src/test/resources/svgtest.js delete mode 100644 libcore/dom/src/test/resources/svgunit.js delete mode 100644 libcore/dom/src/test/resources/xhtml1-strict.dtd delete mode 100644 libcore/icu/MODULE_LICENSE_BSD_LIKE delete mode 100644 libcore/icu/license.html delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/charset/CharsetDecoderICU.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/charset/CharsetEncoderICU.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/charset/CharsetICU.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/charset/CharsetProviderICU.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/charset/NativeConverter.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/common/ErrorCode.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/lang/UCharacter.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/regex/NativeRegEx.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/text/BreakIterator.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/text/CollationAttribute.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/text/CollationElementIterator.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/text/CollationKey.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/text/Collator.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/text/DecimalFormat.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/text/DecimalFormatSymbols.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/text/NativeBreakIterator.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/text/NativeCollation.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/text/NativeDecimalFormat.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/text/RuleBasedBreakIterator.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/text/RuleBasedCollator.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/text/RuleBasedNumberFormat.java delete mode 100644 libcore/icu/src/main/java/com/ibm/icu4jni/util/Resources.java delete mode 100644 libcore/icu/src/main/native/BidiWrapperInterface.c delete mode 100644 libcore/icu/src/main/native/BidiWrapperInterface.h delete mode 100644 libcore/icu/src/main/native/BreakIteratorInterface.c delete mode 100644 libcore/icu/src/main/native/CharacterInterface.c delete mode 100644 libcore/icu/src/main/native/CollationInterface.c delete mode 100644 libcore/icu/src/main/native/CollationInterface.h delete mode 100644 libcore/icu/src/main/native/ConverterInterface.c delete mode 100644 libcore/icu/src/main/native/ConverterInterface.h delete mode 100644 libcore/icu/src/main/native/DecimalFormatInterface.cpp delete mode 100644 libcore/icu/src/main/native/ErrorCode.c delete mode 100644 libcore/icu/src/main/native/ErrorCode.h delete mode 100644 libcore/icu/src/main/native/RBNFInterface.cpp delete mode 100644 libcore/icu/src/main/native/RegExInterface.cpp delete mode 100644 libcore/icu/src/main/native/ResourceInterface.cpp delete mode 100644 libcore/icu/src/main/native/sub.mk delete mode 100644 libcore/icu/unicode-license.txt delete mode 100644 libcore/json/MODULE_LICENSE_BSD_LIKE delete mode 100644 libcore/json/src/main/java/org/json/JSONArray.java delete mode 100644 libcore/json/src/main/java/org/json/JSONException.java delete mode 100644 libcore/json/src/main/java/org/json/JSONObject.java delete mode 100644 libcore/json/src/main/java/org/json/JSONStringer.java delete mode 100644 libcore/json/src/main/java/org/json/JSONTokener.java delete mode 100644 libcore/junit/MODULE_LICENSE_CPL delete mode 100644 libcore/junit/src/main/java/junit/extensions/ActiveTestSuite.java delete mode 100644 libcore/junit/src/main/java/junit/extensions/ExceptionTestCase.java delete mode 100644 libcore/junit/src/main/java/junit/extensions/RepeatedTest.java delete mode 100644 libcore/junit/src/main/java/junit/extensions/TestDecorator.java delete mode 100644 libcore/junit/src/main/java/junit/extensions/TestSetup.java delete mode 100644 libcore/junit/src/main/java/junit/extensions/package.html delete mode 100644 libcore/junit/src/main/java/junit/framework/Assert.java delete mode 100644 libcore/junit/src/main/java/junit/framework/AssertionFailedError.java delete mode 100644 libcore/junit/src/main/java/junit/framework/ComparisonFailure.java delete mode 100644 libcore/junit/src/main/java/junit/framework/Protectable.java delete mode 100644 libcore/junit/src/main/java/junit/framework/Test.java delete mode 100644 libcore/junit/src/main/java/junit/framework/TestCase.java delete mode 100644 libcore/junit/src/main/java/junit/framework/TestFailure.java delete mode 100644 libcore/junit/src/main/java/junit/framework/TestListener.java delete mode 100644 libcore/junit/src/main/java/junit/framework/TestResult.java delete mode 100644 libcore/junit/src/main/java/junit/framework/TestSuite.java delete mode 100644 libcore/junit/src/main/java/junit/framework/package.html delete mode 100644 libcore/logging/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/logging/src/main/java/java/util/logging/ConsoleHandler.java delete mode 100644 libcore/logging/src/main/java/java/util/logging/ErrorManager.java delete mode 100644 libcore/logging/src/main/java/java/util/logging/FileHandler.java delete mode 100644 libcore/logging/src/main/java/java/util/logging/Filter.java delete mode 100644 libcore/logging/src/main/java/java/util/logging/Formatter.java delete mode 100644 libcore/logging/src/main/java/java/util/logging/Handler.java delete mode 100644 libcore/logging/src/main/java/java/util/logging/Level.java delete mode 100644 libcore/logging/src/main/java/java/util/logging/LogManager.java delete mode 100644 libcore/logging/src/main/java/java/util/logging/LogRecord.java delete mode 100644 libcore/logging/src/main/java/java/util/logging/Logger.java delete mode 100644 libcore/logging/src/main/java/java/util/logging/LoggingMXBean.java delete mode 100644 libcore/logging/src/main/java/java/util/logging/LoggingPermission.java delete mode 100644 libcore/logging/src/main/java/java/util/logging/MemoryHandler.java delete mode 100644 libcore/logging/src/main/java/java/util/logging/SimpleFormatter.java delete mode 100644 libcore/logging/src/main/java/java/util/logging/SocketHandler.java delete mode 100644 libcore/logging/src/main/java/java/util/logging/StreamHandler.java delete mode 100644 libcore/logging/src/main/java/java/util/logging/XMLFormatter.java delete mode 100644 libcore/logging/src/main/java/java/util/logging/logging.properties delete mode 100644 libcore/logging/src/main/java/java/util/logging/package.html delete mode 100644 libcore/logging/src/main/java/org/apache/harmony/logging/internal/nls/Messages.java delete mode 100644 libcore/logging/src/main/java/org/apache/harmony/logging/internal/nls/messages.properties delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/AllTests.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/ConsoleHandlerTest.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/ErrorManagerTest.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FilterTest.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FormatterTest.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/HandlerTest.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LevelTest.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LevelTestResource.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogRecordTest.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggingMXBeanTest.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggingPermissionTest.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MemoryHandlerTest.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MessagesTest.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/SimpleFormatterTest.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/SocketHandlerTest.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/StreamHandlerTest.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/XMLFormatterTest.java delete mode 100644 libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/util/EnvironmentHelper.java delete mode 100644 libcore/logging/src/test/java/tests/logging/AllTests.java delete mode 100644 libcore/logging/src/test/resources/bundles/java/util/logging/res.properties delete mode 100644 libcore/logging/src/test/resources/bundles/java/util/logging/res2.properties delete mode 100644 libcore/logging/src/test/resources/bundles/java/util/logging/res3.properties delete mode 100644 libcore/logging/src/test/resources/bundles/java/util/logging/res_en_US.properties delete mode 100644 libcore/logging/src/test/resources/bundles/java/util/logging/res_zh_CN.properties delete mode 100644 libcore/logging/src/test/resources/config/java/util/logging/logging.config delete mode 100644 libcore/logging/src/test/resources/config/java/util/logging/logging.properties delete mode 100644 libcore/logging/src/test/resources/serialization/org/apache/harmony/logging/tests/java/util/logging/LevelTest.golden.ser delete mode 100644 libcore/logging/src/test/resources/serialization/org/apache/harmony/logging/tests/java/util/logging/LogRecordTest.golden.ser delete mode 100644 libcore/logging/src/test/resources/serialization/org/apache/harmony/logging/tests/java/util/logging/LoggingPermissionTest.golden.ser delete mode 100644 libcore/luni-kernel/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/Class.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/ClassCache.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/ClassLoader.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/Compiler.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/LangAccessImpl.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/Object.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/Package.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/ProcessManager.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/Runtime.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/StackTraceElement.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/System.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/Thread.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/ThreadGroup.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/Throwable.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/ref/PhantomReference.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/ref/Reference.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/ref/SoftReference.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/ref/WeakReference.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/reflect/AccessibleObject.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/reflect/Array.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/reflect/Constructor.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/reflect/Field.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/reflect/Method.java delete mode 100644 libcore/luni-kernel/src/main/java/java/lang/reflect/ReflectionAccessImpl.java delete mode 100644 libcore/luni-kernel/src/main/java/org/apache/harmony/kernel/vm/LangAccess.java delete mode 100644 libcore/luni-kernel/src/main/java/org/apache/harmony/kernel/vm/ReflectionAccess.java delete mode 100644 libcore/luni-kernel/src/main/java/org/apache/harmony/kernel/vm/StringUtils.java delete mode 100644 libcore/luni-kernel/src/main/java/org/apache/harmony/kernel/vm/VM.java delete mode 100644 libcore/luni-kernel/src/main/java/org/apache/harmony/lang/annotation/AnnotationFactory.java delete mode 100644 libcore/luni-kernel/src/main/java/org/apache/harmony/lang/annotation/AnnotationMember.java delete mode 100644 libcore/luni-kernel/src/main/native/java_lang_ProcessManager.c delete mode 100644 libcore/luni-kernel/src/main/native/java_lang_System.c delete mode 100644 libcore/luni-kernel/src/main/native/sub.mk delete mode 100644 libcore/luni-kernel/src/test/java/tests/api/org/apache/harmony/kernel/dalvik/ThreadsTest.java delete mode 100644 libcore/luni/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/luni/src/main/java/java/io/BufferedInputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/BufferedOutputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/BufferedReader.java delete mode 100644 libcore/luni/src/main/java/java/io/BufferedWriter.java delete mode 100644 libcore/luni/src/main/java/java/io/ByteArrayInputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/ByteArrayOutputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/CharArrayReader.java delete mode 100644 libcore/luni/src/main/java/java/io/CharArrayWriter.java delete mode 100644 libcore/luni/src/main/java/java/io/CharConversionException.java delete mode 100644 libcore/luni/src/main/java/java/io/Closeable.java delete mode 100644 libcore/luni/src/main/java/java/io/DataInput.java delete mode 100644 libcore/luni/src/main/java/java/io/DataInputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/DataOutput.java delete mode 100644 libcore/luni/src/main/java/java/io/DataOutputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/EOFException.java delete mode 100644 libcore/luni/src/main/java/java/io/EmulatedFields.java delete mode 100644 libcore/luni/src/main/java/java/io/EmulatedFieldsForDumping.java delete mode 100644 libcore/luni/src/main/java/java/io/EmulatedFieldsForLoading.java delete mode 100644 libcore/luni/src/main/java/java/io/Externalizable.java delete mode 100644 libcore/luni/src/main/java/java/io/File.java delete mode 100644 libcore/luni/src/main/java/java/io/FileDescriptor.java delete mode 100644 libcore/luni/src/main/java/java/io/FileFilter.java delete mode 100644 libcore/luni/src/main/java/java/io/FileInputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/FileNotFoundException.java delete mode 100644 libcore/luni/src/main/java/java/io/FileOutputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/FilePermission.java delete mode 100644 libcore/luni/src/main/java/java/io/FilePermissionCollection.java delete mode 100644 libcore/luni/src/main/java/java/io/FileReader.java delete mode 100644 libcore/luni/src/main/java/java/io/FileWriter.java delete mode 100644 libcore/luni/src/main/java/java/io/FilenameFilter.java delete mode 100644 libcore/luni/src/main/java/java/io/FilterInputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/FilterOutputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/FilterReader.java delete mode 100644 libcore/luni/src/main/java/java/io/FilterWriter.java delete mode 100644 libcore/luni/src/main/java/java/io/Flushable.java delete mode 100644 libcore/luni/src/main/java/java/io/IOException.java delete mode 100644 libcore/luni/src/main/java/java/io/InputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/InputStreamReader.java delete mode 100644 libcore/luni/src/main/java/java/io/InterruptedIOException.java delete mode 100644 libcore/luni/src/main/java/java/io/InvalidClassException.java delete mode 100644 libcore/luni/src/main/java/java/io/InvalidObjectException.java delete mode 100644 libcore/luni/src/main/java/java/io/LineNumberInputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/LineNumberReader.java delete mode 100644 libcore/luni/src/main/java/java/io/NotActiveException.java delete mode 100644 libcore/luni/src/main/java/java/io/NotSerializableException.java delete mode 100644 libcore/luni/src/main/java/java/io/ObjectInput.java delete mode 100644 libcore/luni/src/main/java/java/io/ObjectInputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/ObjectInputValidation.java delete mode 100644 libcore/luni/src/main/java/java/io/ObjectOutput.java delete mode 100644 libcore/luni/src/main/java/java/io/ObjectOutputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/ObjectStreamClass.java delete mode 100644 libcore/luni/src/main/java/java/io/ObjectStreamConstants.java delete mode 100644 libcore/luni/src/main/java/java/io/ObjectStreamException.java delete mode 100644 libcore/luni/src/main/java/java/io/ObjectStreamField.java delete mode 100644 libcore/luni/src/main/java/java/io/OptionalDataException.java delete mode 100644 libcore/luni/src/main/java/java/io/OutputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/OutputStreamWriter.java delete mode 100644 libcore/luni/src/main/java/java/io/PipedInputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/PipedOutputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/PipedReader.java delete mode 100644 libcore/luni/src/main/java/java/io/PipedWriter.java delete mode 100644 libcore/luni/src/main/java/java/io/PrintStream.java delete mode 100644 libcore/luni/src/main/java/java/io/PrintWriter.java delete mode 100644 libcore/luni/src/main/java/java/io/PushbackInputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/PushbackReader.java delete mode 100644 libcore/luni/src/main/java/java/io/RandomAccessFile.java delete mode 100644 libcore/luni/src/main/java/java/io/Reader.java delete mode 100644 libcore/luni/src/main/java/java/io/SequenceInputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/Serializable.java delete mode 100644 libcore/luni/src/main/java/java/io/SerializablePermission.java delete mode 100644 libcore/luni/src/main/java/java/io/StreamCorruptedException.java delete mode 100644 libcore/luni/src/main/java/java/io/StreamTokenizer.java delete mode 100644 libcore/luni/src/main/java/java/io/StringBufferInputStream.java delete mode 100644 libcore/luni/src/main/java/java/io/StringReader.java delete mode 100644 libcore/luni/src/main/java/java/io/StringWriter.java delete mode 100644 libcore/luni/src/main/java/java/io/SyncFailedException.java delete mode 100644 libcore/luni/src/main/java/java/io/UTFDataFormatException.java delete mode 100644 libcore/luni/src/main/java/java/io/UnsupportedEncodingException.java delete mode 100644 libcore/luni/src/main/java/java/io/WriteAbortedException.java delete mode 100644 libcore/luni/src/main/java/java/io/Writer.java delete mode 100644 libcore/luni/src/main/java/java/io/package.html delete mode 100644 libcore/luni/src/main/java/java/lang/AbstractMethodError.java delete mode 100644 libcore/luni/src/main/java/java/lang/AbstractStringBuilder.java delete mode 100644 libcore/luni/src/main/java/java/lang/Appendable.java delete mode 100644 libcore/luni/src/main/java/java/lang/ArithmeticException.java delete mode 100644 libcore/luni/src/main/java/java/lang/ArrayIndexOutOfBoundsException.java delete mode 100644 libcore/luni/src/main/java/java/lang/ArrayStoreException.java delete mode 100644 libcore/luni/src/main/java/java/lang/AssertionError.java delete mode 100644 libcore/luni/src/main/java/java/lang/Boolean.java delete mode 100644 libcore/luni/src/main/java/java/lang/Byte.java delete mode 100644 libcore/luni/src/main/java/java/lang/CharSequence.java delete mode 100644 libcore/luni/src/main/java/java/lang/Character.java delete mode 100644 libcore/luni/src/main/java/java/lang/ClassCastException.java delete mode 100644 libcore/luni/src/main/java/java/lang/ClassCircularityError.java delete mode 100644 libcore/luni/src/main/java/java/lang/ClassFormatError.java delete mode 100644 libcore/luni/src/main/java/java/lang/ClassNotFoundException.java delete mode 100644 libcore/luni/src/main/java/java/lang/CloneNotSupportedException.java delete mode 100644 libcore/luni/src/main/java/java/lang/Cloneable.java delete mode 100644 libcore/luni/src/main/java/java/lang/Comparable.java delete mode 100644 libcore/luni/src/main/java/java/lang/Deprecated.java delete mode 100644 libcore/luni/src/main/java/java/lang/Double.java delete mode 100644 libcore/luni/src/main/java/java/lang/EmptyEnumeration.java delete mode 100644 libcore/luni/src/main/java/java/lang/Enum.java delete mode 100644 libcore/luni/src/main/java/java/lang/EnumConstantNotPresentException.java delete mode 100644 libcore/luni/src/main/java/java/lang/Error.java delete mode 100644 libcore/luni/src/main/java/java/lang/Exception.java delete mode 100644 libcore/luni/src/main/java/java/lang/ExceptionInInitializerError.java delete mode 100644 libcore/luni/src/main/java/java/lang/Float.java delete mode 100644 libcore/luni/src/main/java/java/lang/IllegalAccessError.java delete mode 100644 libcore/luni/src/main/java/java/lang/IllegalAccessException.java delete mode 100644 libcore/luni/src/main/java/java/lang/IllegalArgumentException.java delete mode 100644 libcore/luni/src/main/java/java/lang/IllegalMonitorStateException.java delete mode 100644 libcore/luni/src/main/java/java/lang/IllegalStateException.java delete mode 100644 libcore/luni/src/main/java/java/lang/IllegalThreadStateException.java delete mode 100644 libcore/luni/src/main/java/java/lang/IncompatibleClassChangeError.java delete mode 100644 libcore/luni/src/main/java/java/lang/IndexOutOfBoundsException.java delete mode 100644 libcore/luni/src/main/java/java/lang/InheritableThreadLocal.java delete mode 100644 libcore/luni/src/main/java/java/lang/InstantiationError.java delete mode 100644 libcore/luni/src/main/java/java/lang/InstantiationException.java delete mode 100644 libcore/luni/src/main/java/java/lang/Integer.java delete mode 100644 libcore/luni/src/main/java/java/lang/InternalError.java delete mode 100644 libcore/luni/src/main/java/java/lang/InterruptedException.java delete mode 100644 libcore/luni/src/main/java/java/lang/Iterable.java delete mode 100644 libcore/luni/src/main/java/java/lang/LinkageError.java delete mode 100644 libcore/luni/src/main/java/java/lang/Long.java delete mode 100644 libcore/luni/src/main/java/java/lang/Math.java delete mode 100644 libcore/luni/src/main/java/java/lang/NegativeArraySizeException.java delete mode 100644 libcore/luni/src/main/java/java/lang/NoClassDefFoundError.java delete mode 100644 libcore/luni/src/main/java/java/lang/NoSuchFieldError.java delete mode 100644 libcore/luni/src/main/java/java/lang/NoSuchFieldException.java delete mode 100644 libcore/luni/src/main/java/java/lang/NoSuchMethodError.java delete mode 100644 libcore/luni/src/main/java/java/lang/NoSuchMethodException.java delete mode 100644 libcore/luni/src/main/java/java/lang/NullPointerException.java delete mode 100644 libcore/luni/src/main/java/java/lang/Number.java delete mode 100644 libcore/luni/src/main/java/java/lang/NumberFormatException.java delete mode 100644 libcore/luni/src/main/java/java/lang/OutOfMemoryError.java delete mode 100644 libcore/luni/src/main/java/java/lang/Override.java delete mode 100644 libcore/luni/src/main/java/java/lang/Process.java delete mode 100644 libcore/luni/src/main/java/java/lang/ProcessBuilder.java delete mode 100644 libcore/luni/src/main/java/java/lang/Readable.java delete mode 100644 libcore/luni/src/main/java/java/lang/Runnable.java delete mode 100644 libcore/luni/src/main/java/java/lang/RuntimeException.java delete mode 100644 libcore/luni/src/main/java/java/lang/RuntimePermission.java delete mode 100644 libcore/luni/src/main/java/java/lang/SecurityException.java delete mode 100644 libcore/luni/src/main/java/java/lang/SecurityManager.java delete mode 100644 libcore/luni/src/main/java/java/lang/Short.java delete mode 100644 libcore/luni/src/main/java/java/lang/StackOverflowError.java delete mode 100644 libcore/luni/src/main/java/java/lang/StrictMath.java delete mode 100644 libcore/luni/src/main/java/java/lang/String.java delete mode 100644 libcore/luni/src/main/java/java/lang/StringBuffer.java delete mode 100644 libcore/luni/src/main/java/java/lang/StringBuilder.java delete mode 100644 libcore/luni/src/main/java/java/lang/StringIndexOutOfBoundsException.java delete mode 100644 libcore/luni/src/main/java/java/lang/SuppressWarnings.java delete mode 100644 libcore/luni/src/main/java/java/lang/ThreadDeath.java delete mode 100644 libcore/luni/src/main/java/java/lang/ThreadLocal.java delete mode 100644 libcore/luni/src/main/java/java/lang/TypeNotPresentException.java delete mode 100644 libcore/luni/src/main/java/java/lang/UnknownError.java delete mode 100644 libcore/luni/src/main/java/java/lang/UnsatisfiedLinkError.java delete mode 100644 libcore/luni/src/main/java/java/lang/UnsupportedClassVersionError.java delete mode 100644 libcore/luni/src/main/java/java/lang/UnsupportedOperationException.java delete mode 100644 libcore/luni/src/main/java/java/lang/VMClassLoader.java delete mode 100644 libcore/luni/src/main/java/java/lang/VMThread.java delete mode 100644 libcore/luni/src/main/java/java/lang/VerifyError.java delete mode 100644 libcore/luni/src/main/java/java/lang/VirtualMachineError.java delete mode 100644 libcore/luni/src/main/java/java/lang/Void.java delete mode 100644 libcore/luni/src/main/java/java/lang/package.html delete mode 100644 libcore/luni/src/main/java/java/lang/ref/ReferenceQueue.java delete mode 100644 libcore/luni/src/main/java/java/lang/ref/package.html delete mode 100644 libcore/luni/src/main/java/java/lang/reflect/AnnotatedElement.java delete mode 100644 libcore/luni/src/main/java/java/lang/reflect/GenericArrayType.java delete mode 100644 libcore/luni/src/main/java/java/lang/reflect/GenericDeclaration.java delete mode 100644 libcore/luni/src/main/java/java/lang/reflect/GenericSignatureFormatError.java delete mode 100644 libcore/luni/src/main/java/java/lang/reflect/InvocationHandler.java delete mode 100644 libcore/luni/src/main/java/java/lang/reflect/InvocationTargetException.java delete mode 100644 libcore/luni/src/main/java/java/lang/reflect/MalformedParameterizedTypeException.java delete mode 100644 libcore/luni/src/main/java/java/lang/reflect/Member.java delete mode 100644 libcore/luni/src/main/java/java/lang/reflect/Modifier.java delete mode 100644 libcore/luni/src/main/java/java/lang/reflect/ParameterizedType.java delete mode 100644 libcore/luni/src/main/java/java/lang/reflect/Proxy.java delete mode 100644 libcore/luni/src/main/java/java/lang/reflect/ReflectPermission.java delete mode 100644 libcore/luni/src/main/java/java/lang/reflect/Type.java delete mode 100644 libcore/luni/src/main/java/java/lang/reflect/TypeVariable.java delete mode 100644 libcore/luni/src/main/java/java/lang/reflect/UndeclaredThrowableException.java delete mode 100644 libcore/luni/src/main/java/java/lang/reflect/WildcardType.java delete mode 100644 libcore/luni/src/main/java/java/lang/reflect/package.html delete mode 100644 libcore/luni/src/main/java/java/net/Authenticator.java delete mode 100644 libcore/luni/src/main/java/java/net/BindException.java delete mode 100644 libcore/luni/src/main/java/java/net/CacheRequest.java delete mode 100644 libcore/luni/src/main/java/java/net/CacheResponse.java delete mode 100644 libcore/luni/src/main/java/java/net/ConnectException.java delete mode 100644 libcore/luni/src/main/java/java/net/ContentHandler.java delete mode 100644 libcore/luni/src/main/java/java/net/ContentHandlerFactory.java delete mode 100644 libcore/luni/src/main/java/java/net/CookieHandler.java delete mode 100644 libcore/luni/src/main/java/java/net/DatagramPacket.java delete mode 100644 libcore/luni/src/main/java/java/net/DatagramSocket.java delete mode 100644 libcore/luni/src/main/java/java/net/DatagramSocketImpl.java delete mode 100644 libcore/luni/src/main/java/java/net/DatagramSocketImplFactory.java delete mode 100644 libcore/luni/src/main/java/java/net/FileNameMap.java delete mode 100644 libcore/luni/src/main/java/java/net/HttpRetryException.java delete mode 100644 libcore/luni/src/main/java/java/net/HttpURLConnection.java delete mode 100644 libcore/luni/src/main/java/java/net/Inet4Address.java delete mode 100644 libcore/luni/src/main/java/java/net/Inet6Address.java delete mode 100644 libcore/luni/src/main/java/java/net/InetAddress.java delete mode 100644 libcore/luni/src/main/java/java/net/InetSocketAddress.java delete mode 100644 libcore/luni/src/main/java/java/net/JarURLConnection.java delete mode 100644 libcore/luni/src/main/java/java/net/MalformedURLException.java delete mode 100644 libcore/luni/src/main/java/java/net/MulticastSocket.java delete mode 100644 libcore/luni/src/main/java/java/net/NegCacheElement.java delete mode 100644 libcore/luni/src/main/java/java/net/NegativeCache.java delete mode 100644 libcore/luni/src/main/java/java/net/NetPermission.java delete mode 100644 libcore/luni/src/main/java/java/net/NetworkInterface.java delete mode 100644 libcore/luni/src/main/java/java/net/NoRouteToHostException.java delete mode 100644 libcore/luni/src/main/java/java/net/PasswordAuthentication.java delete mode 100644 libcore/luni/src/main/java/java/net/PortUnreachableException.java delete mode 100644 libcore/luni/src/main/java/java/net/ProtocolException.java delete mode 100644 libcore/luni/src/main/java/java/net/Proxy.java delete mode 100644 libcore/luni/src/main/java/java/net/ProxySelector.java delete mode 100644 libcore/luni/src/main/java/java/net/ProxySelectorImpl.java delete mode 100644 libcore/luni/src/main/java/java/net/ResponseCache.java delete mode 100644 libcore/luni/src/main/java/java/net/SecureCacheResponse.java delete mode 100644 libcore/luni/src/main/java/java/net/ServerSocket.java delete mode 100644 libcore/luni/src/main/java/java/net/Socket.java delete mode 100644 libcore/luni/src/main/java/java/net/SocketAddress.java delete mode 100644 libcore/luni/src/main/java/java/net/SocketException.java delete mode 100644 libcore/luni/src/main/java/java/net/SocketImpl.java delete mode 100644 libcore/luni/src/main/java/java/net/SocketImplFactory.java delete mode 100644 libcore/luni/src/main/java/java/net/SocketOptions.java delete mode 100644 libcore/luni/src/main/java/java/net/SocketPermission.java delete mode 100644 libcore/luni/src/main/java/java/net/SocketPermissionCollection.java delete mode 100644 libcore/luni/src/main/java/java/net/SocketTimeoutException.java delete mode 100644 libcore/luni/src/main/java/java/net/URI.java delete mode 100644 libcore/luni/src/main/java/java/net/URIEncoderDecoder.java delete mode 100644 libcore/luni/src/main/java/java/net/URISyntaxException.java delete mode 100644 libcore/luni/src/main/java/java/net/URL.java delete mode 100644 libcore/luni/src/main/java/java/net/URLClassLoader.java delete mode 100644 libcore/luni/src/main/java/java/net/URLConnection.java delete mode 100644 libcore/luni/src/main/java/java/net/URLDecoder.java delete mode 100644 libcore/luni/src/main/java/java/net/URLEncoder.java delete mode 100644 libcore/luni/src/main/java/java/net/URLStreamHandler.java delete mode 100644 libcore/luni/src/main/java/java/net/URLStreamHandlerFactory.java delete mode 100644 libcore/luni/src/main/java/java/net/UnknownHostException.java delete mode 100644 libcore/luni/src/main/java/java/net/UnknownServiceException.java delete mode 100644 libcore/luni/src/main/java/java/net/package.html delete mode 100644 libcore/luni/src/main/java/java/util/AbstractCollection.java delete mode 100644 libcore/luni/src/main/java/java/util/AbstractList.java delete mode 100644 libcore/luni/src/main/java/java/util/AbstractMap.java delete mode 100644 libcore/luni/src/main/java/java/util/AbstractQueue.java delete mode 100644 libcore/luni/src/main/java/java/util/AbstractSequentialList.java delete mode 100644 libcore/luni/src/main/java/java/util/AbstractSet.java delete mode 100644 libcore/luni/src/main/java/java/util/ArrayList.java delete mode 100644 libcore/luni/src/main/java/java/util/Arrays.java delete mode 100644 libcore/luni/src/main/java/java/util/BitSet.java delete mode 100644 libcore/luni/src/main/java/java/util/Calendar.java delete mode 100644 libcore/luni/src/main/java/java/util/Collection.java delete mode 100644 libcore/luni/src/main/java/java/util/Collections.java delete mode 100644 libcore/luni/src/main/java/java/util/ComparableTimSort.java delete mode 100644 libcore/luni/src/main/java/java/util/Comparator.java delete mode 100644 libcore/luni/src/main/java/java/util/ConcurrentModificationException.java delete mode 100644 libcore/luni/src/main/java/java/util/Currency.java delete mode 100644 libcore/luni/src/main/java/java/util/Date.java delete mode 100644 libcore/luni/src/main/java/java/util/Dictionary.java delete mode 100644 libcore/luni/src/main/java/java/util/DuplicateFormatFlagsException.java delete mode 100644 libcore/luni/src/main/java/java/util/EmptyStackException.java delete mode 100644 libcore/luni/src/main/java/java/util/EnumMap.java delete mode 100644 libcore/luni/src/main/java/java/util/EnumSet.java delete mode 100644 libcore/luni/src/main/java/java/util/Enumeration.java delete mode 100644 libcore/luni/src/main/java/java/util/EventListener.java delete mode 100644 libcore/luni/src/main/java/java/util/EventListenerProxy.java delete mode 100644 libcore/luni/src/main/java/java/util/EventObject.java delete mode 100644 libcore/luni/src/main/java/java/util/FormatFlagsConversionMismatchException.java delete mode 100644 libcore/luni/src/main/java/java/util/Formattable.java delete mode 100644 libcore/luni/src/main/java/java/util/FormattableFlags.java delete mode 100644 libcore/luni/src/main/java/java/util/Formatter.java delete mode 100644 libcore/luni/src/main/java/java/util/FormatterClosedException.java delete mode 100644 libcore/luni/src/main/java/java/util/GregorianCalendar.java delete mode 100644 libcore/luni/src/main/java/java/util/HashMap.java delete mode 100644 libcore/luni/src/main/java/java/util/HashSet.java delete mode 100644 libcore/luni/src/main/java/java/util/Hashtable.java delete mode 100644 libcore/luni/src/main/java/java/util/HugeEnumSet.java delete mode 100644 libcore/luni/src/main/java/java/util/IdentityHashMap.java delete mode 100644 libcore/luni/src/main/java/java/util/IllegalFormatCodePointException.java delete mode 100644 libcore/luni/src/main/java/java/util/IllegalFormatConversionException.java delete mode 100644 libcore/luni/src/main/java/java/util/IllegalFormatException.java delete mode 100644 libcore/luni/src/main/java/java/util/IllegalFormatFlagsException.java delete mode 100644 libcore/luni/src/main/java/java/util/IllegalFormatPrecisionException.java delete mode 100644 libcore/luni/src/main/java/java/util/IllegalFormatWidthException.java delete mode 100644 libcore/luni/src/main/java/java/util/InputMismatchException.java delete mode 100644 libcore/luni/src/main/java/java/util/InvalidPropertiesFormatException.java delete mode 100644 libcore/luni/src/main/java/java/util/Iterator.java delete mode 100644 libcore/luni/src/main/java/java/util/LinkedHashMap.java delete mode 100644 libcore/luni/src/main/java/java/util/LinkedHashSet.java delete mode 100644 libcore/luni/src/main/java/java/util/LinkedList.java delete mode 100644 libcore/luni/src/main/java/java/util/List.java delete mode 100644 libcore/luni/src/main/java/java/util/ListIterator.java delete mode 100644 libcore/luni/src/main/java/java/util/ListResourceBundle.java delete mode 100644 libcore/luni/src/main/java/java/util/Locale.java delete mode 100644 libcore/luni/src/main/java/java/util/Map.java delete mode 100644 libcore/luni/src/main/java/java/util/MapEntry.java delete mode 100644 libcore/luni/src/main/java/java/util/MiniEnumSet.java delete mode 100644 libcore/luni/src/main/java/java/util/MissingFormatArgumentException.java delete mode 100644 libcore/luni/src/main/java/java/util/MissingFormatWidthException.java delete mode 100644 libcore/luni/src/main/java/java/util/MissingResourceException.java delete mode 100644 libcore/luni/src/main/java/java/util/NoSuchElementException.java delete mode 100644 libcore/luni/src/main/java/java/util/Observable.java delete mode 100644 libcore/luni/src/main/java/java/util/Observer.java delete mode 100644 libcore/luni/src/main/java/java/util/PriorityQueue.java delete mode 100644 libcore/luni/src/main/java/java/util/Properties.java delete mode 100644 libcore/luni/src/main/java/java/util/PropertyPermission.java delete mode 100644 libcore/luni/src/main/java/java/util/PropertyPermissionCollection.java delete mode 100644 libcore/luni/src/main/java/java/util/PropertyResourceBundle.java delete mode 100644 libcore/luni/src/main/java/java/util/Queue.java delete mode 100644 libcore/luni/src/main/java/java/util/Random.java delete mode 100644 libcore/luni/src/main/java/java/util/RandomAccess.java delete mode 100644 libcore/luni/src/main/java/java/util/ResourceBundle.java delete mode 100644 libcore/luni/src/main/java/java/util/Scanner.java delete mode 100644 libcore/luni/src/main/java/java/util/Set.java delete mode 100644 libcore/luni/src/main/java/java/util/SimpleTimeZone.java delete mode 100644 libcore/luni/src/main/java/java/util/SortedMap.java delete mode 100644 libcore/luni/src/main/java/java/util/SortedSet.java delete mode 100644 libcore/luni/src/main/java/java/util/SpecialAccess.java delete mode 100644 libcore/luni/src/main/java/java/util/Stack.java delete mode 100644 libcore/luni/src/main/java/java/util/StringTokenizer.java delete mode 100644 libcore/luni/src/main/java/java/util/TimSort.java delete mode 100644 libcore/luni/src/main/java/java/util/TimeZone.java delete mode 100644 libcore/luni/src/main/java/java/util/Timer.java delete mode 100644 libcore/luni/src/main/java/java/util/TimerTask.java delete mode 100644 libcore/luni/src/main/java/java/util/TooManyListenersException.java delete mode 100644 libcore/luni/src/main/java/java/util/TreeMap.java delete mode 100644 libcore/luni/src/main/java/java/util/TreeSet.java delete mode 100644 libcore/luni/src/main/java/java/util/UUID.java delete mode 100644 libcore/luni/src/main/java/java/util/UnknownFormatConversionException.java delete mode 100644 libcore/luni/src/main/java/java/util/UnknownFormatFlagsException.java delete mode 100644 libcore/luni/src/main/java/java/util/Vector.java delete mode 100644 libcore/luni/src/main/java/java/util/WeakHashMap.java delete mode 100644 libcore/luni/src/main/java/java/util/package.html delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/io/FileCanonPathCache.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/MimeTable.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/FileURLConnection.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/Handler.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/ftp/FtpURLConnection.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/ftp/FtpURLInputStream.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/ftp/Handler.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/Handler.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/Header.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpConfiguration.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpConnection.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpConnectionManager.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/Handler.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/HttpsURLConnection.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/Handler.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/JarURLConnection.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/types.properties delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/nls/Messages.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/nls/messages.properties delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/util/TimezoneGetter.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/util/ZoneInfo.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/internal/util/ZoneInfoDB.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/lang/reflect/GenericSignatureParser.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/lang/reflect/ImplForArray.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/lang/reflect/ImplForType.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/lang/reflect/ImplForVariable.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/lang/reflect/ImplForWildcard.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/lang/reflect/ListOfTypes.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/lang/reflect/ListOfVariables.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/lang/reflect/Types.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/net/GenericIPMreq.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/net/NetUtil.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/net/PlainServerSocketImpl.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/net/SocketInputStream.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/net/SocketOutputStream.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/net/Socks4Message.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/platform/AbstractMemorySpy.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/platform/Endianness.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/platform/FileDescriptorHandler.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/platform/ICommonDataTypes.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/platform/IFileSystem.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/platform/IMemorySpy.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/platform/IMemorySystem.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/platform/INetworkSystem.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/platform/MappedPlatformAddress.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/platform/OSFileSystem.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/platform/OSMemory.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/platform/Platform.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/platform/PlatformAddress.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/platform/PlatformAddressFactory.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/platform/RuntimeMemorySpy.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/Base64.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/BinarySearch.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/DeleteOnExit.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/ErrorCodeException.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/ExposedByteArrayInputStream.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/HexStringParser.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/HistoricalNamesUtil.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/Inet6Util.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/InputStreamExposer.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/InvalidJarIndexException.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/Msg.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/MsgHelp.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/NotImplementedException.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/NumberConverter.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/OIDDatabase.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/PasswordProtectedInputStream.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/PositionedInputStream.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/PriviAction.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/SHAOutputStream.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/ThreadLocalCache.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/TwoKeyHashMap.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/URLUtil.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/luni/util/Util.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/misc/HashCode.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/misc/SystemUtils.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/misc/internal/nls/Messages.java delete mode 100644 libcore/luni/src/main/java/org/apache/harmony/misc/internal/nls/messages.properties delete mode 100644 libcore/luni/src/main/native/cbigint.c delete mode 100644 libcore/luni/src/main/native/cbigint.h delete mode 100644 libcore/luni/src/main/native/commonDblParce.c delete mode 100644 libcore/luni/src/main/native/commonDblParce.h delete mode 100644 libcore/luni/src/main/native/fltconst.h delete mode 100644 libcore/luni/src/main/native/hycomp.h delete mode 100644 libcore/luni/src/main/native/java_io_File.c delete mode 100644 libcore/luni/src/main/native/java_io_FileDescriptor.c delete mode 100644 libcore/luni/src/main/native/java_io_ObjectInputStream.c delete mode 100644 libcore/luni/src/main/native/java_io_ObjectOutputStream.c delete mode 100644 libcore/luni/src/main/native/java_io_ObjectStreamClass.c delete mode 100644 libcore/luni/src/main/native/java_lang_Character.cpp delete mode 100644 libcore/luni/src/main/native/java_lang_Double.c delete mode 100644 libcore/luni/src/main/native/java_lang_Float.c delete mode 100644 libcore/luni/src/main/native/java_lang_Math.c delete mode 100644 libcore/luni/src/main/native/java_lang_StrictMath.c delete mode 100644 libcore/luni/src/main/native/java_net_InetAddress.cpp delete mode 100644 libcore/luni/src/main/native/java_net_NetworkInterface.c delete mode 100644 libcore/luni/src/main/native/org_apache_harmony_luni_platform_OSFileSystem.cpp delete mode 100644 libcore/luni/src/main/native/org_apache_harmony_luni_platform_OSMemory.cpp delete mode 100644 libcore/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp delete mode 100644 libcore/luni/src/main/native/org_apache_harmony_luni_util_NumberConvert.c delete mode 100644 libcore/luni/src/main/native/org_apache_harmony_luni_util_fltparse.c delete mode 100644 libcore/luni/src/main/native/sub.mk delete mode 100644 libcore/luni/src/test/java/com/google/coretests/CoreTestDummy.java delete mode 100644 libcore/luni/src/test/java/com/google/coretests/CoreTestIsolator.java delete mode 100644 libcore/luni/src/test/java/com/google/coretests/CoreTestPrinter.java delete mode 100644 libcore/luni/src/test/java/com/google/coretests/CoreTestResult.java delete mode 100644 libcore/luni/src/test/java/com/google/coretests/CoreTestRunnable.java delete mode 100644 libcore/luni/src/test/java/com/google/coretests/CoreTestRunner.java delete mode 100644 libcore/luni/src/test/java/com/google/coretests/CoreTestSuite.java delete mode 100644 libcore/luni/src/test/java/com/google/coretests/CoreTestTimeout.java delete mode 100644 libcore/luni/src/test/java/com/google/coretests/Main.java delete mode 100644 libcore/luni/src/test/java/com/google/coretests/PerfStatCollector.java delete mode 100644 libcore/luni/src/test/java/com/google/coretests/ResultPrinter.java delete mode 100644 libcore/luni/src/test/java/com/google/coretests/StatTestRunner.java delete mode 100644 libcore/luni/src/test/java/com/google/coretests/StatsStore.java delete mode 100644 libcore/luni/src/test/java/com/google/coretests/Version.java delete mode 100644 libcore/luni/src/test/java/junit/runner/BaseTestRunner.java delete mode 100644 libcore/luni/src/test/java/junit/runner/ClassPathTestCollector.java delete mode 100644 libcore/luni/src/test/java/junit/runner/FailureDetailView.java delete mode 100644 libcore/luni/src/test/java/junit/runner/LoadingTestCollector.java delete mode 100644 libcore/luni/src/test/java/junit/runner/ReloadingTestSuiteLoader.java delete mode 100644 libcore/luni/src/test/java/junit/runner/SimpleTestCollector.java delete mode 100644 libcore/luni/src/test/java/junit/runner/Sorter.java delete mode 100644 libcore/luni/src/test/java/junit/runner/StandardTestSuiteLoader.java delete mode 100644 libcore/luni/src/test/java/junit/runner/TestCaseClassLoader.java delete mode 100644 libcore/luni/src/test/java/junit/runner/TestCollector.java delete mode 100644 libcore/luni/src/test/java/junit/runner/TestRunListener.java delete mode 100644 libcore/luni/src/test/java/junit/runner/TestSuiteLoader.java delete mode 100644 libcore/luni/src/test/java/junit/runner/Version.java delete mode 100644 libcore/luni/src/test/java/junit/runner/excluded.properties delete mode 100644 libcore/luni/src/test/java/junit/runner/logo.gif delete mode 100644 libcore/luni/src/test/java/junit/runner/smalllogo.gif delete mode 100644 libcore/luni/src/test/java/junit/textui/ResultPrinter.java delete mode 100644 libcore/luni/src/test/java/junit/textui/TestRunner.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/platform/AllTests.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/platform/OSMemoryTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/internal/net/www/protocol/http/AllTests.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/internal/net/www/protocol/https/AllTests.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/internal/net/www/protocol/https/HttpsURLConnectionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/io/AllTests.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/io/BufferedReaderTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/io/FileCanonPathCacheTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/io/FilePermissionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/io/FileTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/io/InputStreamReaderTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/io/ObjectInputStreamTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/io/ObjectStreamConstantsTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/io/OutputStreamWriterTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/io/PushBackInputStreamTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/io/ReaderTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/io/WriterTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/AbstractMethodErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/AllTests.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ArithmeticExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ArrayIndexOutOfBoundsExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ArrayStoreExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/AssertionErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/BooleanTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ByteTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/CharacterImplTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/CharacterTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/Character_SubsetTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/Character_UnicodeBlockTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassCastExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassCircularityErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassFormatErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassLoaderTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassNotFoundExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest2.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/CloneNotSupportedExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/CompilerTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/DoubleTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/EnumConstantNotPresentExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/EnumTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ExceptionInInitializerErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ExtendTestClass.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ExtendTestClass1.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/FloatTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalAccessErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalAccessExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalArgumentExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalMonitorStateExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalStateExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalThreadStateExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IncompatibleClassChangeErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IndexOutOfBoundsExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InheritableThreadLocalTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InstantiationErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InstantiationExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IntegerTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InternalErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InterruptedExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/LinkageErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/LongTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MathTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MockEnum.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MockEnum2.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MockSecurityManager.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MutableSecurityManager.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NegativeArraySizeExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoClassDefFoundErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchFieldErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchFieldExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchMethodErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchMethodExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NullPointerExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NumberFormatExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NumberTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ObjectTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/OutOfMemoryErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PackageTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ProcessBuilderTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PublicClassLoader.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PublicTestClass.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimeExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimePermissionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimeTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityManagerTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ShortTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StackOverflowErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StackTraceElementOriginal.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StackTraceElementTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StrictMathTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/String2Test.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBuffer2Test.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBufferTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBuilderTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringIndexOutOfBoundsExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SystemTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestAnnotation.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestAssertions.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestAssertions1.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass1.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass1B.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass1C.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass2.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass3.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass4.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestLibrary.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThreadDeathTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThreadGroupTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThreadLocalTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThreadStateTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThreadTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThrowableTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TypeNotPresentExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/UnknownErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/UnsatisfiedLinkErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/UnsupportedClassVersionErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/UnsupportedOperationExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/VerifyErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/VirtualMachineErrorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/AllTests.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/ContentHandlerFactoryTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/ContentHandlerTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/HttpRetryExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/HttpURLConnectionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/Inet4AddressTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/Inet6AddressTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/InetAddressTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/InetSocketAddressTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URITest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLEncoderTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/test_protocol/Handler.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/AbstractCollectionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/AbstractMapTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/AbstractSetTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/AllTests.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/ArrayListTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/ArraysTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/BitSetTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/CollectionsTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/DateTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/DictionaryTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/DuplicateFormatFlagsExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/EventListenerProxyTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/FormatFlagsConversionMismatchExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/FormattableTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/FormatterClosedExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/FormatterTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/HashMapTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IdentityHashMapTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IllegalFormatCodePointExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IllegalFormatConversionExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IllegalFormatFlagsExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IllegalFormatPrecisionExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IllegalFormatWidthExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/InputMismatchExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/InvalidPropertiesFormatExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/LinkedHashMapTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/ListIteratorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/LocaleTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/MapEntryTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/MissingFormatArgumentExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/MissingFormatWidthExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/ObserverTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/UUIDTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/UnknownFormatConversionExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/UnknownFormatFlagsExceptionTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/VectorTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/util/WeakHashMapTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/pkg1/TestClass.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/pkg2/TestClass.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/util/Base64Test.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/util/MsgHelpTest.java delete mode 100644 libcore/luni/src/test/java/org/apache/harmony/luni/tests/util/NYITest.java delete mode 100644 libcore/luni/src/test/java/tests/AllTests.java delete mode 100644 libcore/luni/src/test/java/tests/TestSuiteFactory.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/AllTests.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/BufferedInputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/BufferedOutputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/BufferedReaderTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/BufferedWriterTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/ByteArrayInputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/ByteArrayOutputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/CharArrayReaderTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/CharArrayWriterTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/CharConversionExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/ComputeSerialVersionUIDTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/DataInputOutputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/DataInputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/DataOutputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/EOFExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/ExternalizableTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/FileDescriptorTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/FileFilterTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/FileInputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/FileNotFoundExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/FileOutputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/FilePermissionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/FileReaderTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/FileTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/FileWriterTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/FilenameFilterTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/FilterInputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/FilterOutputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/FilterReaderTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/FilterWriterTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/IOExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/InputStreamReaderTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/InputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/InterruptedIOExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/InvalidClassExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/InvalidObjectExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/LineNumberInputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/LineNumberReaderTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/NotActiveExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/NotSerializableExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/ObjectInputOutputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/ObjectInputStreamGetFieldTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/ObjectInputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/ObjectInputValidationTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/ObjectOutputStreamPutFieldTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/ObjectOutputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/ObjectStreamClassTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/ObjectStreamExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/ObjectStreamFieldTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/OpenRandomFileTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/OutputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/OutputStreamWriterTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/PipedInputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/PipedOutputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/PipedReaderTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/PipedWriterTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/PrintStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/PrintWriterTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/PushbackInputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/PushbackReaderTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/RandomAccessFileTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/SequenceInputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/SerializablePermissionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/SerializationStressTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/SerializationStressTest0.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/SerializationStressTest1.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/SerializationStressTest2.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/SerializationStressTest3.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/SerializationStressTest4.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/SerializationStressTest5.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/SerializationTestClass.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/StreamCorruptedExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/StreamTokenizerTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/StringBufferInputStreamTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/StringReaderTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/StringWriterTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/SyncFailedExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/UTFDataFormatExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/UnsupportedEncodingExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/WriteAbortedExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/io/WriterTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/AllTests.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/BooleanTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/Process2Test.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/ProcessManagerTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/ProcessTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/StringTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/ref/AllTests.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/ref/PhantomReferenceTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/ref/ReferenceQueueTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/ref/ReferenceTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/ref/SoftReferenceTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/ref/WeakReferenceTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/AccessibleObjectTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/AllTests.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/ArrayTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/BoundedGenericMethodsTests.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/ConstructorTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/FieldTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/GenericArrayTypeTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/GenericMethodsTests.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/GenericReflectionCornerCases.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/GenericReflectionTestsBase.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/GenericSignatureFormatErrorTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/GenericTypesTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/InvocationTargetExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/MalformedParameterizedTypeExceptionTests.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/MethodTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/ModifierTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/ParameterizedTypeTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/ProxyTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/ReflectPermissionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/TypeVariableTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/UndeclaredThrowableExceptionTests.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/lang/reflect/WildcardTypeTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/AllTests.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/AuthenticatorRequestorTypeTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/AuthenticatorTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/BindExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/CacheRequestTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/CacheResponseTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/ConnectExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/CookieHandlerTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/DatagramPacketTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/DatagramSocketImplFactoryTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/DatagramSocketImplTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/ExcludedProxyTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/FileNameMapTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/HttpRetryExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/MalformedURLExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/MulticastSocketTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/NetPermissionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/NetworkInterfaceTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/NoRouteToHostExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/PasswordAuthenticationTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/PortUnreachableExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/ProtocolExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/ProxySelectorTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/ProxyTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/ProxyTypeTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/ResponseCacheTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/SecureCacheResponseTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/ServerSocketTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/SocketExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/SocketImplFactoryTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/SocketImplTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/SocketPermissionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/SocketTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/SocketTestCase.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/SocketTimeoutExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/TestServerSocketInit.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/URISyntaxExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/URITest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/URLClassLoaderTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/URLDecoderTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/URLEncoderTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/URLStreamHandlerFactoryTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/URLStreamHandlerTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/UnknownHostExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/net/UnknownServiceExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/AbstractListTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/AbstractMapTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/AbstractQueueTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/AbstractSequentialListTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/AllTests.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/ArrayListTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/ArraysTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/BitSetTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/CalendarTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/CollectionsTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/ConcurrentModTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/ConcurrentModificationExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/CurrencyTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/DateTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/EmptyStackExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/EnumMapTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/EnumSetTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/EventObjectTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/FormattableFlagsTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/FormatterTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/HashMapTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/HashSetTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/HashtableTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/IdentityHashMapTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/InvalidPropertiesFormatExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/LinkedHashMapTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/LinkedHashSetTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/LinkedListTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/ListResourceBundleTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/LocaleTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/MissingResourceExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/NoSuchElementExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/ObservableTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/PriorityQueueTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/PropertiesTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/PropertyPermissionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/PropertyResourceBundleTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/RandomTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/ResourceBundleTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/SampleBundleClass.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/ScannerTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/SimpleTimeZoneTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/StackTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/StringTokenizerTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/TimeZoneTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/TimerTaskTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/TimerTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/TooManyListenersExceptionTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/TreeMapTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/TreeSetTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/VectorTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/WeakHashMapTest.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/support/A.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/support/B.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/support/I.java delete mode 100644 libcore/luni/src/test/java/tests/api/java/util/support/P.java delete mode 100644 libcore/luni/src/test/java/tests/java/lang/String/Tests.java delete mode 100644 libcore/luni/src/test/java/tests/luni/AllTestsIo.java delete mode 100644 libcore/luni/src/test/java/tests/luni/AllTestsLang.java delete mode 100644 libcore/luni/src/test/java/tests/luni/AllTestsNet.java delete mode 100644 libcore/luni/src/test/java/tests/luni/AllTestsUtil.java delete mode 100644 libcore/luni/src/test/resources/HelloWorld.txt delete mode 100644 libcore/luni/src/test/resources/hyts_Foo.c delete mode 100755 libcore/luni/src/test/resources/libTestLibrary.so delete mode 100644 libcore/luni/src/test/resources/org/apache/harmony/luni/tests/java/lang/A.class delete mode 100644 libcore/luni/src/test/resources/org/apache/harmony/luni/tests/java/lang/HelloWorld.txt delete mode 100644 libcore/luni/src/test/resources/org/apache/harmony/luni/tests/java/lang/HelloWorld1.txt delete mode 100644 libcore/luni/src/test/resources/org/apache/harmony/luni/tests/java/lang/illegalClasses.jar delete mode 100644 libcore/luni/src/test/resources/org/apache/harmony/luni/tests/key_store.bks delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/io/FileTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/io/test_array_integers.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/io/test_array_strings.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/lang/EnumTest.golden.0.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/lang/EnumTest.golden.1.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/lang/EnumTest.golden.2.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/lang/EnumTest.golden.3.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/lang/EnumTest.harmony.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/lang/IllegalArgumentExceptionTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/lang/IllegalStateExceptionTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/lang/SecurityExceptionTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/lang/StringBufferTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/lang/StringBuilderTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/lang/UnsupportedOperationExceptionTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/net/HttpRetryExceptionTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/net/Inet4AddressTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/net/Inet6AddressTest.golden.0.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/net/Inet6AddressTest.golden.1.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/net/InetAddressTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/net/InetSocketAddressTest.golden.0.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/net/InetSocketAddressTest.golden.1.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/Collections_CheckedCollection.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/Collections_CheckedList.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/Collections_CheckedListRandomAccess.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/Collections_CheckedMap.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/Collections_CheckedSet.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/Collections_CheckedSortedMap.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/Collections_CheckedSortedSet.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/DuplicateFormatFlagsExceptionTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/FormatFlagsConversionMismatchExceptionTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/FormatterClosedExceptionTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/HashMapTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/IdentityHashMapTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/IllegalFormatCodePointExceptionTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/IllegalFormatConversionExceptionTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/IllegalFormatFlagsExceptionTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/IllegalFormatPrecisionExceptionTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/IllegalFormatWidthExceptionTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/InputMismatchExceptionTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/MissingFormatArgumentExceptionTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/MissingFormatWidthExceptionTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/UUIDTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/UnknownFormatConversionExceptionTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/UnknownFormatFlagsExceptionTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/tests/api/java/io/testComputeSUIDClass.ser delete mode 100644 libcore/luni/src/test/resources/serialization/tests/api/java/io/testComputeSUIDConstructors.ser delete mode 100644 libcore/luni/src/test/resources/serialization/tests/api/java/io/testComputeSUIDFields.ser delete mode 100644 libcore/luni/src/test/resources/serialization/tests/api/java/io/testComputeSUIDInterfaces.ser delete mode 100644 libcore/luni/src/test/resources/serialization/tests/api/java/io/testComputeSUIDMethods.ser delete mode 100644 libcore/luni/src/test/resources/serialization/tests/api/java/util/EnumMapTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/tests/api/java/util/EnumSetTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/tests/api/java/util/HashSetTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/tests/api/java/util/IdentityHashMapTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/tests/api/java/util/PriorityQueue.golden.ser delete mode 100644 libcore/luni/src/test/resources/serialization/tests/api/java/util/PropertyPermissionTest.golden.ser delete mode 100644 libcore/luni/src/test/resources/tests/api/java/io/testFields.ser delete mode 100644 libcore/luni/src/test/resources/tests/api/java/io/testFieldsDefaulted.ser delete mode 100644 libcore/luni/src/test/resources/tests/api/java/io/testFieldsDeprecated.ser delete mode 100644 libcore/luni/src/test/resources/tests/api/java/io/testfile delete mode 100644 libcore/luni/src/test/resources/tests/api/java/io/testfile-utf8.txt delete mode 100644 libcore/luni/src/test/resources/tests/api/java/io/testfile.txt delete mode 100644 libcore/luni/src/test/resources/tests/api/java/lang/reflect/dex1.bytes delete mode 100644 libcore/luni/src/test/resources/tests/api/java/net/InvalidJar.jar delete mode 100644 libcore/luni/src/test/resources/tests/api/java/net/TestCodeSigners.jar delete mode 100644 libcore/luni/src/test/resources/tests/api/java/net/file1.cache delete mode 100644 libcore/luni/src/test/resources/tests/api/java/net/lf.jar delete mode 100644 libcore/luni/src/test/resources/tests/api/java/util/support/B.properties delete mode 100644 libcore/math/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/math/src/main/java/java/math/BigDecimal.java delete mode 100644 libcore/math/src/main/java/java/math/BigInt.java delete mode 100644 libcore/math/src/main/java/java/math/BigInteger.java delete mode 100644 libcore/math/src/main/java/java/math/BitLevel.java delete mode 100644 libcore/math/src/main/java/java/math/Conversion.java delete mode 100644 libcore/math/src/main/java/java/math/Division.java delete mode 100644 libcore/math/src/main/java/java/math/Logical.java delete mode 100644 libcore/math/src/main/java/java/math/MathContext.java delete mode 100644 libcore/math/src/main/java/java/math/Multiplication.java delete mode 100644 libcore/math/src/main/java/java/math/Primality.java delete mode 100644 libcore/math/src/main/java/java/math/RoundingMode.java delete mode 100644 libcore/math/src/main/java/java/math/package.html delete mode 100644 libcore/math/src/main/java/org/apache/harmony/math/internal/nls/Messages.java delete mode 100644 libcore/math/src/main/java/org/apache/harmony/math/internal/nls/messages.properties delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/AllTests.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigDecimalArithmeticTest.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigDecimalCompareTest.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigDecimalConstructorsTest.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigDecimalConvertTest.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigDecimalScaleOperationsTest.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigIntegerAddTest.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigIntegerAndTest.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigIntegerCompareTest.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigIntegerConstructorsTest.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigIntegerConvertTest.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigIntegerDivideTest.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigIntegerHashCodeTest.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigIntegerModPowTest.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigIntegerMultiplyTest.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigIntegerNotTest.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigIntegerOperateBitsTest.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigIntegerOrTest.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigIntegerSubtractTest.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigIntegerToStringTest.java delete mode 100644 libcore/math/src/test/java/org/apache/harmony/math/tests/java/math/BigIntegerXorTest.java delete mode 100644 libcore/math/src/test/java/tests/api/java/math/AllTests.java delete mode 100644 libcore/math/src/test/java/tests/api/java/math/BigDecimalTest.java delete mode 100644 libcore/math/src/test/java/tests/api/java/math/BigIntegerTest.java delete mode 100644 libcore/math/src/test/java/tests/api/java/math/MathContextTest.java delete mode 100644 libcore/math/src/test/java/tests/api/java/math/RoundingModeTest.java delete mode 100644 libcore/math/src/test/java/tests/math/AllTests.java delete mode 100644 libcore/nio/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/nio/src/main/java/java/nio/BaseByteBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/Buffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/BufferFactory.java delete mode 100644 libcore/nio/src/main/java/java/nio/BufferOverflowException.java delete mode 100644 libcore/nio/src/main/java/java/nio/BufferUnderflowException.java delete mode 100644 libcore/nio/src/main/java/java/nio/ByteBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/ByteOrder.java delete mode 100644 libcore/nio/src/main/java/java/nio/CharArrayBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/CharBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/CharSequenceAdapter.java delete mode 100644 libcore/nio/src/main/java/java/nio/CharToByteBufferAdapter.java delete mode 100644 libcore/nio/src/main/java/java/nio/DirectByteBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/DirectByteBuffers.java delete mode 100644 libcore/nio/src/main/java/java/nio/DoubleArrayBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/DoubleBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/DoubleToByteBufferAdapter.java delete mode 100644 libcore/nio/src/main/java/java/nio/FloatArrayBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/FloatBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/FloatToByteBufferAdapter.java delete mode 100644 libcore/nio/src/main/java/java/nio/HeapByteBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/IntArrayBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/IntBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/IntToByteBufferAdapter.java delete mode 100644 libcore/nio/src/main/java/java/nio/InvalidMarkException.java delete mode 100644 libcore/nio/src/main/java/java/nio/LongArrayBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/LongBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/LongToByteBufferAdapter.java delete mode 100644 libcore/nio/src/main/java/java/nio/MappedByteBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/MappedByteBufferAdapter.java delete mode 100644 libcore/nio/src/main/java/java/nio/NIOAccess.java delete mode 100644 libcore/nio/src/main/java/java/nio/ReadOnlyBufferException.java delete mode 100644 libcore/nio/src/main/java/java/nio/ReadOnlyCharArrayBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/ReadOnlyDirectByteBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/ReadOnlyDoubleArrayBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/ReadOnlyHeapByteBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/ReadOnlyIntArrayBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/ReadOnlyLongArrayBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/ReadOnlyShortArrayBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/ReadWriteCharArrayBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/ReadWriteDirectByteBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/ReadWriteDoubleArrayBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/ReadWriteFloatArrayBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/ReadWriteHeapByteBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/ReadWriteIntArrayBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/ReadWriteLongArrayBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/ReadWriteShortArrayBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/ShortArrayBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/ShortBuffer.java delete mode 100644 libcore/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/AlreadyConnectedException.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/AsynchronousCloseException.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/ByteChannel.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/CancelledKeyException.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/Channel.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/Channels.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/ClosedByInterruptException.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/ClosedChannelException.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/ClosedSelectorException.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/ConnectionPendingException.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/DatagramChannel.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/FileChannel.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/FileLock.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/FileLockInterruptionException.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/GatheringByteChannel.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/IllegalBlockingModeException.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/IllegalSelectorException.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/InterruptibleChannel.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/NoConnectionPendingException.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/NonReadableChannelException.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/NonWritableChannelException.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/NotYetBoundException.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/NotYetConnectedException.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/OverlappingFileLockException.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/Pipe.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/ReadableByteChannel.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/ScatteringByteChannel.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/SelectableChannel.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/SelectionKey.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/Selector.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/ServerSocketChannel.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/SocketChannel.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/UnresolvedAddressException.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/UnsupportedAddressTypeException.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/WritableByteChannel.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/package.html delete mode 100644 libcore/nio/src/main/java/java/nio/channels/spi/AbstractInterruptibleChannel.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/spi/AbstractSelectionKey.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/spi/AbstractSelector.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/spi/SelectorProvider.java delete mode 100644 libcore/nio/src/main/java/java/nio/channels/spi/package.html delete mode 100644 libcore/nio/src/main/java/java/nio/package.html delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/AddressUtil.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/FileChannelFactory.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/Util.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/internal/DatagramChannelImpl.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/internal/DirectBuffer.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/internal/FileLockImpl.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/internal/IOUtil.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/internal/LockManager.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/internal/MappedByteBufferFactory.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/internal/PipeImpl.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/internal/ReadOnlyFileChannel.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/internal/ReadWriteFileChannel.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/internal/SelectionKeyImpl.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/internal/SelectorImpl.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/internal/SelectorProviderImpl.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/internal/SocketChannelImpl.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/internal/WriteOnlyFileChannel.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/internal/nls/Messages.java delete mode 100644 libcore/nio/src/main/java/org/apache/harmony/nio/internal/nls/messages.properties delete mode 100644 libcore/nio/src/main/native/org_apache_harmony_nio_AddressUtil.cpp delete mode 100644 libcore/nio/src/main/native/sub.mk delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AbstractBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AllTests.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferOverflowExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferUnderflowExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteOrderTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/CharBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectByteBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectCharBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectDoubleBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectFloatBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectIntBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectLongBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectShortBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DoubleBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateDirectByteBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateHeapByteBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateWrappedByteBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/FloatBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapByteBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapCharBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapDoubleBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapFloatBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapIntBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapLongBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapShortBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/IntBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/InvalidMarkExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/LongBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/MappedByteBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyBufferExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyCharBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDirectByteBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDoubleBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyFloatBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapByteBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapCharBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapDoubleBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapFloatBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapIntBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapLongBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapShortBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyIntBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyLongBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyShortBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedByteBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedCharBufferTest1.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedDoubleBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedFloatBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedIntBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedLongBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedShortBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ShortBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceDirectByteBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceHeapByteBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceWrappedByteBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedByteBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest1.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest2.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedDoubleBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedFloatBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedIntBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedLongBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedShortBufferTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AllTests.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AlreadyConnectedExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AsynchronousCloseExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/CancelledKeyExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ChannelsTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedByInterruptExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedChannelExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedSelectorExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ConnectionPendingExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockInterruptionExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalBlockingModeExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalSelectorExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/MapModeTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/MockDatagramChannel.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/MockSecurityManager.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/MockServerSocketChannel.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/MockSocketChannel.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NoConnectionPendingExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonReadableChannelExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonWritableChannelExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetBoundExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetConnectedExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/OverlappingFileLockExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/PipeTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectableChannelTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectionKeyTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ServerSocketChannelTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SinkChannelTest.java delete mode 100755 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SourceChannelTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnresolvedAddressExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnsupportedAddressTypeExceptionTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractInterruptibleChannelTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectableChannelTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectionKeyTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectorTest.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AllTests.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/MockAbstractSelector.java delete mode 100644 libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/SelectorProviderTest.java delete mode 100644 libcore/nio/src/test/java/tests/nio/AllTests.java delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/BufferOverflowExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/BufferUnderflowExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/InvalidMarkExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/ReadOnlyBufferExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/channels/AlreadyConnectedExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/channels/AsynchronousCloseExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/channels/CancelledKeyExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/channels/ClosedByInterruptExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/channels/ClosedChannelExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/channels/ClosedSelectorExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/channels/ConnectionPendingExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/channels/FileLockInterruptionExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/channels/IllegalBlockingModeExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/channels/IllegalSelectorExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/channels/NoConnectionPendingExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/channels/NonReadableChannelExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/channels/NonWritableChannelExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/channels/NotYetBoundExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/channels/NotYetConnectedExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/channels/OverlappingFileLockExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/channels/UnresolvedAddressExceptionTest.golden.ser delete mode 100644 libcore/nio/src/test/resources/serialization/org/apache/harmony/nio/tests/java/nio/channels/UnsupportedAddressTypeExceptionTest.golden.ser delete mode 100644 libcore/nio_char/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/nio_char/src/main/java/java/nio/charset/CharacterCodingException.java delete mode 100644 libcore/nio_char/src/main/java/java/nio/charset/Charset.java delete mode 100644 libcore/nio_char/src/main/java/java/nio/charset/CharsetDecoder.java delete mode 100644 libcore/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java delete mode 100644 libcore/nio_char/src/main/java/java/nio/charset/CoderMalfunctionError.java delete mode 100644 libcore/nio_char/src/main/java/java/nio/charset/CoderResult.java delete mode 100644 libcore/nio_char/src/main/java/java/nio/charset/CodingErrorAction.java delete mode 100644 libcore/nio_char/src/main/java/java/nio/charset/IllegalCharsetNameException.java delete mode 100644 libcore/nio_char/src/main/java/java/nio/charset/MalformedInputException.java delete mode 100644 libcore/nio_char/src/main/java/java/nio/charset/UnmappableCharacterException.java delete mode 100644 libcore/nio_char/src/main/java/java/nio/charset/UnsupportedCharsetException.java delete mode 100644 libcore/nio_char/src/main/java/java/nio/charset/package.html delete mode 100644 libcore/nio_char/src/main/java/java/nio/charset/spi/CharsetProvider.java delete mode 100644 libcore/nio_char/src/main/java/java/nio/charset/spi/package.html delete mode 100644 libcore/nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/Messages.java delete mode 100644 libcore/nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/messages.properties delete mode 100644 libcore/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/ASCIICharsetEncoderTest.java delete mode 100644 libcore/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/AllTests.java delete mode 100644 libcore/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/CharacterCodingExceptionTest.java delete mode 100644 libcore/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/CharsetDecoderTest.java delete mode 100644 libcore/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/CharsetEncoderTest.java delete mode 100644 libcore/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/CharsetTest.java delete mode 100644 libcore/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/CoderMalfunctionErrorTest.java delete mode 100644 libcore/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/IllegalCharsetNameExceptionTest.java delete mode 100644 libcore/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/MalformedInputExceptionTest.java delete mode 100644 libcore/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/UnmappableCharacterExceptionTest.java delete mode 100644 libcore/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/UnsupportedCharsetExceptionTest.java delete mode 100644 libcore/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/spi/AllTests.java delete mode 100644 libcore/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/spi/CharsetProviderTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/ASCCharsetDecoderTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/ASCCharsetTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/AbstractCharsetDecoderTestCase.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/AbstractCharsetEncoderTestCase.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/AbstractCharsetTestCase.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/AllTests.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/CharsetDecoderTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/CharsetEncoderDecoderBufferTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/CharsetEncoderTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/CharsetProviderTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/CharsetTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_AbstractTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_GSM0338.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_ISO_8859_10.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_ISO_8859_14.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_ISO_8859_16.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_MultiByte_.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_MultiByte_Big5.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_MultiByte_Big5_Android.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_MultiByte_EUC_JP.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_MultiByte_EUC_JP_Android.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_MultiByte_EUC_KR.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_MultiByte_GB2312.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_MultiByte_GBK.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_MultiByte_GBK_Android.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_MultiByte_ISO_2022_JP.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_MultiByte_UTF_16.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_MultiByte_UTF_16BE.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_MultiByte_UTF_16LE.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_MultiByte_UTF_16_Android.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_MultiByte_UTF_8.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_MultiByte_x_windows_950.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByteAbstractTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_IBM864.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_ISO_8859_1.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_ISO_8859_11.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_ISO_8859_13.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_ISO_8859_15.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_ISO_8859_2.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_ISO_8859_3.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_ISO_8859_4.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_ISO_8859_5.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_ISO_8859_6.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_ISO_8859_7.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_ISO_8859_8.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_ISO_8859_9.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_KOI8_R.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_US_ASCII.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_windows_1250.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_windows_1251.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_windows_1252.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_windows_1253.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_windows_1254.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_windows_1255.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_windows_1256.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_windows_1257.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_windows_1258.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_x_IBM874.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_TestGenerator.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_TestGenerator_Res.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/Charset_macintosh.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/CoderResultTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/CodingErrorActionTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/GBCharsetDecoderTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/GBCharsetEncoderTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/ISOCharsetDecoderTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/ISOCharsetEncoderTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/ISOCharsetTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/UTF16BECharsetDecoderTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/UTF16BECharsetEncoderTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/UTF16BECharsetTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/UTF16CharsetDecoderTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/UTF16CharsetEncoderTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/UTF16CharsetTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/UTF16LECharsetDecoderTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/UTF16LECharsetEncoderTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/UTF16LECharsetTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/UTF8CharsetTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/UTFCharsetDecoderTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/api/java/nio/charset/UTFCharsetEncoderTest.java delete mode 100644 libcore/nio_char/src/test/java/tests/nio_char/AllTests.java delete mode 100644 libcore/nio_char/src/test/resources/jars/charset_provider.jar delete mode 100644 libcore/nio_char/src/test/resources/serialization/org/apache/harmony/nio_char/tests/java/nio/charset/CharacterCodingExceptionTest.golden.ser delete mode 100644 libcore/nio_char/src/test/resources/serialization/org/apache/harmony/nio_char/tests/java/nio/charset/CoderMalfunctionErrorTest.golden.ser delete mode 100644 libcore/nio_char/src/test/resources/serialization/org/apache/harmony/nio_char/tests/java/nio/charset/IllegalCharsetNameExceptionTest.golden.ser delete mode 100644 libcore/nio_char/src/test/resources/serialization/org/apache/harmony/nio_char/tests/java/nio/charset/MalformedInputExceptionTest.golden.ser delete mode 100644 libcore/nio_char/src/test/resources/serialization/org/apache/harmony/nio_char/tests/java/nio/charset/UnmappableCharacterExceptionTest.golden.ser delete mode 100644 libcore/nio_char/src/test/resources/serialization/org/apache/harmony/nio_char/tests/java/nio/charset/UnsupportedCharsetExceptionTest.golden.ser delete mode 100644 libcore/openssl/src/main/java/org/openssl/NativeBN.java delete mode 100644 libcore/openssl/src/main/native/BNInterface.c delete mode 100644 libcore/openssl/src/main/native/sub.mk delete mode 100644 libcore/prefs/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/prefs/src/main/java/java/util/prefs/AbstractPreferences.java delete mode 100644 libcore/prefs/src/main/java/java/util/prefs/BackingStoreException.java delete mode 100644 libcore/prefs/src/main/java/java/util/prefs/FilePreferencesFactoryImpl.java delete mode 100644 libcore/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java delete mode 100644 libcore/prefs/src/main/java/java/util/prefs/InvalidPreferencesFormatException.java delete mode 100644 libcore/prefs/src/main/java/java/util/prefs/NodeChangeEvent.java delete mode 100644 libcore/prefs/src/main/java/java/util/prefs/NodeChangeListener.java delete mode 100644 libcore/prefs/src/main/java/java/util/prefs/NodeSet.java delete mode 100644 libcore/prefs/src/main/java/java/util/prefs/PreferenceChangeEvent.java delete mode 100644 libcore/prefs/src/main/java/java/util/prefs/PreferenceChangeListener.java delete mode 100644 libcore/prefs/src/main/java/java/util/prefs/Preferences.java delete mode 100644 libcore/prefs/src/main/java/java/util/prefs/PreferencesFactory.java delete mode 100644 libcore/prefs/src/main/java/java/util/prefs/XMLParser.java delete mode 100644 libcore/prefs/src/main/java/java/util/prefs/package.html delete mode 100644 libcore/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/Messages.java delete mode 100644 libcore/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/messages.properties delete mode 100644 libcore/prefs/src/main/resources/META-INF/services/java.util.prefs.PreferencesFactory delete mode 100644 libcore/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java delete mode 100644 libcore/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AllTests.java delete mode 100644 libcore/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/BackingStoreExceptionTest.java delete mode 100644 libcore/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java delete mode 100644 libcore/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/InvalidPreferencesFormatExceptionTest.java delete mode 100644 libcore/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockAbstractPreferences.java delete mode 100644 libcore/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockNodeChangeListener.java delete mode 100644 libcore/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockPreferenceChangeListener.java delete mode 100644 libcore/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockSecurityManager.java delete mode 100644 libcore/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/NodeChangeEventTest.java delete mode 100644 libcore/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/NodeChangeListenerTest.java delete mode 100644 libcore/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeEventTest.java delete mode 100644 libcore/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeListenerTest.java delete mode 100644 libcore/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesFactoryTest.java delete mode 100644 libcore/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesTest.java delete mode 100644 libcore/prefs/src/test/java/tests/prefs/AllTests.java delete mode 100644 libcore/prefs/src/test/resources/prefs/java/util/prefs/userprefs-ascii.xml delete mode 100644 libcore/prefs/src/test/resources/prefs/java/util/prefs/userprefs-badencoding.xml delete mode 100644 libcore/prefs/src/test/resources/prefs/java/util/prefs/userprefs-badform.xml delete mode 100644 libcore/prefs/src/test/resources/prefs/java/util/prefs/userprefs-badtype.xml delete mode 100644 libcore/prefs/src/test/resources/prefs/java/util/prefs/userprefs-higherversion.xml delete mode 100644 libcore/prefs/src/test/resources/prefs/java/util/prefs/userprefs.xml delete mode 100644 libcore/prefs/src/test/resources/serialization/org/apache/harmony/prefs/tests/java/util/prefs/BackingStoreExceptionTest.golden.ser delete mode 100644 libcore/prefs/src/test/resources/serialization/org/apache/harmony/prefs/tests/java/util/prefs/InvalidPreferencesFormatExceptionTest.golden.ser delete mode 100644 libcore/regex/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/regex/src/main/java/java/util/regex/MatchResult.java delete mode 100644 libcore/regex/src/main/java/java/util/regex/MatchResultImpl.java delete mode 100644 libcore/regex/src/main/java/java/util/regex/Matcher.java delete mode 100644 libcore/regex/src/main/java/java/util/regex/Pattern.java delete mode 100644 libcore/regex/src/main/java/java/util/regex/PatternSyntaxException.java delete mode 100644 libcore/regex/src/main/java/java/util/regex/package.html delete mode 100644 libcore/regex/src/test/java/org/apache/harmony/regex/tests/java/util/regex/AllTests.java delete mode 100644 libcore/regex/src/test/java/org/apache/harmony/regex/tests/java/util/regex/Matcher2Test.java delete mode 100644 libcore/regex/src/test/java/org/apache/harmony/regex/tests/java/util/regex/MatcherTest.java delete mode 100644 libcore/regex/src/test/java/org/apache/harmony/regex/tests/java/util/regex/ModeTest.java delete mode 100644 libcore/regex/src/test/java/org/apache/harmony/regex/tests/java/util/regex/Pattern2Test.java delete mode 100644 libcore/regex/src/test/java/org/apache/harmony/regex/tests/java/util/regex/PatternErrorTest.java delete mode 100644 libcore/regex/src/test/java/org/apache/harmony/regex/tests/java/util/regex/PatternSyntaxExceptionTest.java delete mode 100644 libcore/regex/src/test/java/org/apache/harmony/regex/tests/java/util/regex/PatternTest.java delete mode 100644 libcore/regex/src/test/java/org/apache/harmony/regex/tests/java/util/regex/ReplaceTest.java delete mode 100644 libcore/regex/src/test/java/org/apache/harmony/regex/tests/java/util/regex/SplitTest.java delete mode 100644 libcore/regex/src/test/java/tests/regex/AllTests.java delete mode 100755 libcore/regex/src/test/resources/serialization/org/apache/harmony/regex/tests/java/util/regex/PatternSyntaxExceptionTest.golden.ser delete mode 100755 libcore/regex/src/test/resources/serialization/org/apache/harmony/regex/tests/java/util/regex/PatternTest.golden.ser delete mode 100755 libcore/run-core-tests delete mode 100755 libcore/run-core-tests-on-ri delete mode 100644 libcore/security-kernel/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/security-kernel/src/main/java/java/security/AccessControlContext.java delete mode 100644 libcore/security-kernel/src/main/java/java/security/AccessController.java delete mode 100644 libcore/security/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/security/MODULE_LICENSE_BSD_LIKE delete mode 100644 libcore/security/bouncycastle-license.txt delete mode 100644 libcore/security/src/main/files/cacerts.bks delete mode 100644 libcore/security/src/main/files/cacerts/03e16f6c.0 delete mode 100644 libcore/security/src/main/files/cacerts/111e6273.0 delete mode 100644 libcore/security/src/main/files/cacerts/1155c94b.0 delete mode 100644 libcore/security/src/main/files/cacerts/17b51fe6.0 delete mode 100644 libcore/security/src/main/files/cacerts/1dac3003.0 delete mode 100644 libcore/security/src/main/files/cacerts/1dbdda5b.0 delete mode 100644 libcore/security/src/main/files/cacerts/1dcd6f4c.0 delete mode 100644 libcore/security/src/main/files/cacerts/219d9499.0 delete mode 100644 libcore/security/src/main/files/cacerts/23f4c490.0 delete mode 100644 libcore/security/src/main/files/cacerts/256fd83b.0 delete mode 100644 libcore/security/src/main/files/cacerts/399e7759.0 delete mode 100644 libcore/security/src/main/files/cacerts/3c58f906.0 delete mode 100644 libcore/security/src/main/files/cacerts/3e7271e8.0 delete mode 100644 libcore/security/src/main/files/cacerts/4d654d1d.0 delete mode 100644 libcore/security/src/main/files/cacerts/4e18c148.0 delete mode 100644 libcore/security/src/main/files/cacerts/4fbd6bfa.0 delete mode 100644 libcore/security/src/main/files/cacerts/54edfa5d.0 delete mode 100644 libcore/security/src/main/files/cacerts/594f1775.0 delete mode 100644 libcore/security/src/main/files/cacerts/5a5372fc.0 delete mode 100644 libcore/security/src/main/files/cacerts/5cf9d536.0 delete mode 100644 libcore/security/src/main/files/cacerts/635ccfd5.0 delete mode 100644 libcore/security/src/main/files/cacerts/69105f4f.0 delete mode 100644 libcore/security/src/main/files/cacerts/6e8bf996.0 delete mode 100644 libcore/security/src/main/files/cacerts/72fa7371.0 delete mode 100644 libcore/security/src/main/files/cacerts/74c26bd0.0 delete mode 100644 libcore/security/src/main/files/cacerts/7651b327.0 delete mode 100644 libcore/security/src/main/files/cacerts/7a819ef2.0 delete mode 100644 libcore/security/src/main/files/cacerts/7d3cd826.0 delete mode 100644 libcore/security/src/main/files/cacerts/81b9768f.0 delete mode 100644 libcore/security/src/main/files/cacerts/9339512a.0 delete mode 100644 libcore/security/src/main/files/cacerts/97b4211c.0 delete mode 100644 libcore/security/src/main/files/cacerts/a3896b44.0 delete mode 100644 libcore/security/src/main/files/cacerts/a7605362.0 delete mode 100644 libcore/security/src/main/files/cacerts/ab86d4de.0 delete mode 100644 libcore/security/src/main/files/cacerts/add67345.0 delete mode 100644 libcore/security/src/main/files/cacerts/b0f3e76e.0 delete mode 100644 libcore/security/src/main/files/cacerts/bcdd5959.0 delete mode 100644 libcore/security/src/main/files/cacerts/bda4cc84.0 delete mode 100644 libcore/security/src/main/files/cacerts/bf64f35b.0 delete mode 100644 libcore/security/src/main/files/cacerts/c33a80d4.0 delete mode 100644 libcore/security/src/main/files/cacerts/cb796bc1.0 delete mode 100644 libcore/security/src/main/files/cacerts/cdaebb72.0 delete mode 100644 libcore/security/src/main/files/cacerts/d537fba6.0 delete mode 100644 libcore/security/src/main/files/cacerts/d777342d.0 delete mode 100644 libcore/security/src/main/files/cacerts/d8274e24.0 delete mode 100644 libcore/security/src/main/files/cacerts/ddc328ff.0 delete mode 100644 libcore/security/src/main/files/cacerts/e60bf0c0.0 delete mode 100644 libcore/security/src/main/files/cacerts/e7b8d656.0 delete mode 100644 libcore/security/src/main/files/cacerts/ed524cf5.0 delete mode 100644 libcore/security/src/main/files/cacerts/ee7cd6fb.0 delete mode 100644 libcore/security/src/main/files/cacerts/f4996e82.0 delete mode 100644 libcore/security/src/main/files/cacerts/f64d9715.0 delete mode 100644 libcore/security/src/main/files/cacerts/f73e89fd.0 delete mode 100644 libcore/security/src/main/files/cacerts/ff783690.0 delete mode 100755 libcore/security/src/main/files/certimport.sh delete mode 100644 libcore/security/src/main/java/java/security/AccessControlException.java delete mode 100644 libcore/security/src/main/java/java/security/AlgorithmParameterGenerator.java delete mode 100644 libcore/security/src/main/java/java/security/AlgorithmParameterGeneratorSpi.java delete mode 100644 libcore/security/src/main/java/java/security/AlgorithmParameters.java delete mode 100644 libcore/security/src/main/java/java/security/AlgorithmParametersSpi.java delete mode 100644 libcore/security/src/main/java/java/security/AllPermission.java delete mode 100644 libcore/security/src/main/java/java/security/AllPermissionCollection.java delete mode 100644 libcore/security/src/main/java/java/security/AuthProvider.java delete mode 100644 libcore/security/src/main/java/java/security/BasicPermission.java delete mode 100644 libcore/security/src/main/java/java/security/BasicPermissionCollection.java delete mode 100644 libcore/security/src/main/java/java/security/Certificate.java delete mode 100644 libcore/security/src/main/java/java/security/CodeSigner.java delete mode 100644 libcore/security/src/main/java/java/security/CodeSource.java delete mode 100644 libcore/security/src/main/java/java/security/DigestException.java delete mode 100644 libcore/security/src/main/java/java/security/DigestInputStream.java delete mode 100644 libcore/security/src/main/java/java/security/DigestOutputStream.java delete mode 100644 libcore/security/src/main/java/java/security/DomainCombiner.java delete mode 100644 libcore/security/src/main/java/java/security/GeneralSecurityException.java delete mode 100644 libcore/security/src/main/java/java/security/Guard.java delete mode 100644 libcore/security/src/main/java/java/security/GuardedObject.java delete mode 100644 libcore/security/src/main/java/java/security/Identity.java delete mode 100644 libcore/security/src/main/java/java/security/IdentityScope.java delete mode 100644 libcore/security/src/main/java/java/security/InvalidAlgorithmParameterException.java delete mode 100644 libcore/security/src/main/java/java/security/InvalidKeyException.java delete mode 100644 libcore/security/src/main/java/java/security/InvalidParameterException.java delete mode 100644 libcore/security/src/main/java/java/security/Key.java delete mode 100644 libcore/security/src/main/java/java/security/KeyException.java delete mode 100644 libcore/security/src/main/java/java/security/KeyFactory.java delete mode 100644 libcore/security/src/main/java/java/security/KeyFactorySpi.java delete mode 100644 libcore/security/src/main/java/java/security/KeyManagementException.java delete mode 100644 libcore/security/src/main/java/java/security/KeyPair.java delete mode 100644 libcore/security/src/main/java/java/security/KeyPairGenerator.java delete mode 100644 libcore/security/src/main/java/java/security/KeyPairGeneratorSpi.java delete mode 100644 libcore/security/src/main/java/java/security/KeyRep.java delete mode 100644 libcore/security/src/main/java/java/security/KeyStore.java delete mode 100644 libcore/security/src/main/java/java/security/KeyStoreException.java delete mode 100644 libcore/security/src/main/java/java/security/KeyStoreSpi.java delete mode 100644 libcore/security/src/main/java/java/security/MessageDigest.java delete mode 100644 libcore/security/src/main/java/java/security/MessageDigestSpi.java delete mode 100644 libcore/security/src/main/java/java/security/NoSuchAlgorithmException.java delete mode 100644 libcore/security/src/main/java/java/security/NoSuchProviderException.java delete mode 100644 libcore/security/src/main/java/java/security/Permission.java delete mode 100644 libcore/security/src/main/java/java/security/PermissionCollection.java delete mode 100644 libcore/security/src/main/java/java/security/Permissions.java delete mode 100644 libcore/security/src/main/java/java/security/PermissionsHash.java delete mode 100644 libcore/security/src/main/java/java/security/Policy.java delete mode 100644 libcore/security/src/main/java/java/security/Principal.java delete mode 100644 libcore/security/src/main/java/java/security/PrivateKey.java delete mode 100644 libcore/security/src/main/java/java/security/PrivilegedAction.java delete mode 100644 libcore/security/src/main/java/java/security/PrivilegedActionException.java delete mode 100644 libcore/security/src/main/java/java/security/PrivilegedExceptionAction.java delete mode 100644 libcore/security/src/main/java/java/security/ProtectionDomain.java delete mode 100644 libcore/security/src/main/java/java/security/Provider.java delete mode 100644 libcore/security/src/main/java/java/security/ProviderException.java delete mode 100644 libcore/security/src/main/java/java/security/PublicKey.java delete mode 100644 libcore/security/src/main/java/java/security/SecureClassLoader.java delete mode 100644 libcore/security/src/main/java/java/security/SecureRandom.java delete mode 100644 libcore/security/src/main/java/java/security/SecureRandomSpi.java delete mode 100644 libcore/security/src/main/java/java/security/Security.java delete mode 100644 libcore/security/src/main/java/java/security/SecurityPermission.java delete mode 100644 libcore/security/src/main/java/java/security/Signature.java delete mode 100644 libcore/security/src/main/java/java/security/SignatureException.java delete mode 100644 libcore/security/src/main/java/java/security/SignatureSpi.java delete mode 100644 libcore/security/src/main/java/java/security/SignedObject.java delete mode 100644 libcore/security/src/main/java/java/security/Signer.java delete mode 100644 libcore/security/src/main/java/java/security/Timestamp.java delete mode 100644 libcore/security/src/main/java/java/security/UnrecoverableEntryException.java delete mode 100644 libcore/security/src/main/java/java/security/UnrecoverableKeyException.java delete mode 100644 libcore/security/src/main/java/java/security/UnresolvedPermission.java delete mode 100644 libcore/security/src/main/java/java/security/UnresolvedPermissionCollection.java delete mode 100644 libcore/security/src/main/java/java/security/acl/Acl.java delete mode 100644 libcore/security/src/main/java/java/security/acl/AclEntry.java delete mode 100644 libcore/security/src/main/java/java/security/acl/AclNotFoundException.java delete mode 100644 libcore/security/src/main/java/java/security/acl/Group.java delete mode 100644 libcore/security/src/main/java/java/security/acl/LastOwnerException.java delete mode 100644 libcore/security/src/main/java/java/security/acl/NotOwnerException.java delete mode 100644 libcore/security/src/main/java/java/security/acl/Owner.java delete mode 100644 libcore/security/src/main/java/java/security/acl/Permission.java delete mode 100644 libcore/security/src/main/java/java/security/acl/package.html delete mode 100644 libcore/security/src/main/java/java/security/cert/CRL.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CRLException.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CRLSelector.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertPath.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertPathBuilder.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertPathBuilderException.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertPathBuilderResult.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertPathBuilderSpi.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertPathParameters.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertPathValidator.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertPathValidatorException.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertPathValidatorResult.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertPathValidatorSpi.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertSelector.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertStore.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertStoreException.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertStoreParameters.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertStoreSpi.java delete mode 100644 libcore/security/src/main/java/java/security/cert/Certificate.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertificateEncodingException.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertificateException.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertificateExpiredException.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertificateFactory.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertificateFactorySpi.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertificateNotYetValidException.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CertificateParsingException.java delete mode 100644 libcore/security/src/main/java/java/security/cert/CollectionCertStoreParameters.java delete mode 100644 libcore/security/src/main/java/java/security/cert/LDAPCertStoreParameters.java delete mode 100644 libcore/security/src/main/java/java/security/cert/PKIXBuilderParameters.java delete mode 100644 libcore/security/src/main/java/java/security/cert/PKIXCertPathBuilderResult.java delete mode 100644 libcore/security/src/main/java/java/security/cert/PKIXCertPathChecker.java delete mode 100644 libcore/security/src/main/java/java/security/cert/PKIXCertPathValidatorResult.java delete mode 100644 libcore/security/src/main/java/java/security/cert/PKIXParameters.java delete mode 100644 libcore/security/src/main/java/java/security/cert/PolicyNode.java delete mode 100644 libcore/security/src/main/java/java/security/cert/PolicyQualifierInfo.java delete mode 100644 libcore/security/src/main/java/java/security/cert/TrustAnchor.java delete mode 100644 libcore/security/src/main/java/java/security/cert/X509CRL.java delete mode 100644 libcore/security/src/main/java/java/security/cert/X509CRLEntry.java delete mode 100644 libcore/security/src/main/java/java/security/cert/X509CRLSelector.java delete mode 100644 libcore/security/src/main/java/java/security/cert/X509CertSelector.java delete mode 100644 libcore/security/src/main/java/java/security/cert/X509Certificate.java delete mode 100644 libcore/security/src/main/java/java/security/cert/X509Extension.java delete mode 100644 libcore/security/src/main/java/java/security/cert/package.html delete mode 100644 libcore/security/src/main/java/java/security/interfaces/DSAKey.java delete mode 100644 libcore/security/src/main/java/java/security/interfaces/DSAKeyPairGenerator.java delete mode 100644 libcore/security/src/main/java/java/security/interfaces/DSAParams.java delete mode 100644 libcore/security/src/main/java/java/security/interfaces/DSAPrivateKey.java delete mode 100644 libcore/security/src/main/java/java/security/interfaces/DSAPublicKey.java delete mode 100644 libcore/security/src/main/java/java/security/interfaces/ECKey.java delete mode 100644 libcore/security/src/main/java/java/security/interfaces/ECPrivateKey.java delete mode 100644 libcore/security/src/main/java/java/security/interfaces/ECPublicKey.java delete mode 100644 libcore/security/src/main/java/java/security/interfaces/RSAKey.java delete mode 100644 libcore/security/src/main/java/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java delete mode 100644 libcore/security/src/main/java/java/security/interfaces/RSAPrivateCrtKey.java delete mode 100644 libcore/security/src/main/java/java/security/interfaces/RSAPrivateKey.java delete mode 100644 libcore/security/src/main/java/java/security/interfaces/RSAPublicKey.java delete mode 100644 libcore/security/src/main/java/java/security/interfaces/package.html delete mode 100644 libcore/security/src/main/java/java/security/package.html delete mode 100644 libcore/security/src/main/java/java/security/security.properties delete mode 100644 libcore/security/src/main/java/java/security/spec/AlgorithmParameterSpec.java delete mode 100644 libcore/security/src/main/java/java/security/spec/DSAParameterSpec.java delete mode 100644 libcore/security/src/main/java/java/security/spec/DSAPrivateKeySpec.java delete mode 100644 libcore/security/src/main/java/java/security/spec/DSAPublicKeySpec.java delete mode 100644 libcore/security/src/main/java/java/security/spec/ECField.java delete mode 100644 libcore/security/src/main/java/java/security/spec/ECFieldF2m.java delete mode 100644 libcore/security/src/main/java/java/security/spec/ECFieldFp.java delete mode 100644 libcore/security/src/main/java/java/security/spec/ECGenParameterSpec.java delete mode 100644 libcore/security/src/main/java/java/security/spec/ECParameterSpec.java delete mode 100644 libcore/security/src/main/java/java/security/spec/ECPoint.java delete mode 100644 libcore/security/src/main/java/java/security/spec/ECPrivateKeySpec.java delete mode 100644 libcore/security/src/main/java/java/security/spec/ECPublicKeySpec.java delete mode 100644 libcore/security/src/main/java/java/security/spec/EllipticCurve.java delete mode 100644 libcore/security/src/main/java/java/security/spec/EncodedKeySpec.java delete mode 100644 libcore/security/src/main/java/java/security/spec/InvalidKeySpecException.java delete mode 100644 libcore/security/src/main/java/java/security/spec/InvalidParameterSpecException.java delete mode 100644 libcore/security/src/main/java/java/security/spec/KeySpec.java delete mode 100644 libcore/security/src/main/java/java/security/spec/MGF1ParameterSpec.java delete mode 100644 libcore/security/src/main/java/java/security/spec/PKCS8EncodedKeySpec.java delete mode 100644 libcore/security/src/main/java/java/security/spec/PSSParameterSpec.java delete mode 100644 libcore/security/src/main/java/java/security/spec/RSAKeyGenParameterSpec.java delete mode 100644 libcore/security/src/main/java/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java delete mode 100644 libcore/security/src/main/java/java/security/spec/RSAOtherPrimeInfo.java delete mode 100644 libcore/security/src/main/java/java/security/spec/RSAPrivateCrtKeySpec.java delete mode 100644 libcore/security/src/main/java/java/security/spec/RSAPrivateKeySpec.java delete mode 100644 libcore/security/src/main/java/java/security/spec/RSAPublicKeySpec.java delete mode 100644 libcore/security/src/main/java/java/security/spec/X509EncodedKeySpec.java delete mode 100644 libcore/security/src/main/java/java/security/spec/package.html delete mode 100644 libcore/security/src/main/java/javax/security/cert/Certificate.java delete mode 100644 libcore/security/src/main/java/javax/security/cert/CertificateEncodingException.java delete mode 100644 libcore/security/src/main/java/javax/security/cert/CertificateException.java delete mode 100644 libcore/security/src/main/java/javax/security/cert/CertificateExpiredException.java delete mode 100644 libcore/security/src/main/java/javax/security/cert/CertificateNotYetValidException.java delete mode 100644 libcore/security/src/main/java/javax/security/cert/CertificateParsingException.java delete mode 100644 libcore/security/src/main/java/javax/security/cert/X509Certificate.java delete mode 100644 libcore/security/src/main/java/javax/security/cert/package.html delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/DefaultPolicyScanner.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/PolicyEntry.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/PrivateKeyImpl.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/PublicKeyImpl.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/SystemScope.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/UnresolvedPrincipal.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1Any.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1BitString.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1Boolean.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1Choice.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1Constants.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1Constructured.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1Enumerated.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1Exception.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1Explicit.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1GeneralizedTime.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1Implicit.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1Integer.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1OctetString.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1Oid.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1OpenType.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1Primitive.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1Sequence.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1SequenceOf.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1Set.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1SetOf.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1StringType.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1Time.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1Type.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1TypeCollection.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1UTCTime.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ASN1ValueCollection.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/BerInputStream.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/BerOutputStream.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/BitString.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/DerInputStream.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/DerOutputStream.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/InformationObjectSet.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/asn1/ObjectIdentifier.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/fortress/DefaultPolicy.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/fortress/DefaultPolicyParser.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/fortress/Engine.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/fortress/PolicyUtils.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/fortress/SecurityAccess.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/fortress/SecurityUtils.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/fortress/Services.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/internal/nls/Messages.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/internal/nls/messages.properties delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/pkcs10/CertificationRequest.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/pkcs10/CertificationRequestInfo.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/pkcs7/AuthenticatedAttributes.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/pkcs7/ContentInfo.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/pkcs7/SignedData.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/pkcs7/SignerInfo.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/pkcs8/PrivateKeyInfo.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/provider/cert/Cache.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/provider/cert/DRLCertFactory.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/provider/cert/X509CRLEntryImpl.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/provider/cert/X509CRLImpl.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/provider/cert/X509CertImpl.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/provider/cert/X509CertPathImpl.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/provider/crypto/CryptoProvider.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/provider/crypto/DSAKeyFactoryImpl.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/provider/crypto/DSAPrivateKeyImpl.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/provider/crypto/DSAPublicKeyImpl.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/provider/crypto/RandomBitsSupplier.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/provider/crypto/SHA1Impl.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/provider/crypto/SHA1PRNG_SecureRandomImpl.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/provider/crypto/SHA1_Data.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/provider/crypto/SHA1_MessageDigestImpl.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/provider/crypto/SHA1withDSA_SignatureImpl.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/provider/crypto/ThreeIntegerSequence.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/utils/AlgNameMapper.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/utils/Array.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/utils/JarUtils.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/utils/ObjectIdentifier.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x501/AttributeType.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x501/AttributeTypeAndValue.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x501/AttributeTypeAndValueComparator.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x501/AttributeValue.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x501/Attributes.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x501/DirectoryString.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x501/Name.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/AccessDescription.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/AlgorithmIdentifier.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/AlternativeName.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/AuthorityKeyIdentifier.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/BasicConstraints.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/CRLDistributionPoints.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/CRLNumber.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/Certificate.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/CertificateIssuer.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/CertificateList.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/CertificatePolicies.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/DNParser.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/DistributionPoint.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/DistributionPointName.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/EDIPartyName.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/ExtendedKeyUsage.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/Extension.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/ExtensionValue.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/Extensions.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/GeneralName.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/GeneralNames.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/GeneralSubtree.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/GeneralSubtrees.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/InfoAccessSyntax.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/InhibitAnyPolicy.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/InvalidityDate.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/IssuingDistributionPoint.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/KeyUsage.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/NameConstraints.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/ORAddress.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/OtherName.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/PolicyConstraints.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/PolicyInformation.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/PolicyQualifierInfo.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/PrivateKeyUsagePeriod.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/ReasonCode.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/ReasonFlags.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/SubjectKeyIdentifier.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/SubjectPublicKeyInfo.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/TBSCertList.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/TBSCertificate.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/Time.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/Utils.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/Validity.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/X509PublicKey.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/tsp/MessageImprint.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/tsp/PKIFailureInfo.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/tsp/PKIStatus.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/tsp/PKIStatusInfo.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/tsp/TSTInfo.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/tsp/TimeStampReq.java delete mode 100644 libcore/security/src/main/java/org/apache/harmony/security/x509/tsp/TimeStampResp.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ASN1Choice.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ASN1Collection.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ASN1Encodable.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ASN1EncodableVector.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ASN1InputStream.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ASN1Null.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ASN1OctetString.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ASN1OutputStream.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ASN1Sequence.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ASN1Set.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ASN1TaggedObject.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/BERConstructedOctetString.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/BERConstructedSequence.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/BERInputStream.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/BERNull.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/BEROutputStream.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/BERSequence.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/BERSet.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/BERTaggedObject.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERApplicationSpecific.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERBMPString.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERBitString.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERBoolean.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERConstructedSequence.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERConstructedSet.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DEREncodable.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DEREncodableVector.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DEREnumerated.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERGeneralString.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERGeneralizedTime.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERIA5String.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERInputStream.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERInteger.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERNull.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERNumericString.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERObject.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERObjectIdentifier.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DEROctetString.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DEROutputStream.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERPrintableString.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERSequence.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERSet.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERString.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERT61String.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERTaggedObject.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERTags.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERUTCTime.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERUTF8String.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERUniversalString.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERUnknownTag.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/DERVisibleString.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/OIDTokenizer.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/OrderedTable.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cmp/PKIFailureInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cmp/PKIFreeText.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cmp/PKIStatus.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cmp/PKIStatusInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/Attribute.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/AttributeTable.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/CMSAttributes.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/CMSObjectIdentifiers.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/CompressedData.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/ContentInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/EncryptedContentInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/EnvelopedData.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/IssuerAndSerialNumber.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/KEKIdentifier.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/KEKRecipientInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/KeyAgreeRecipientInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/KeyTransRecipientInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/OriginatorIdentifierOrKey.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/OriginatorInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/OriginatorPublicKey.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/OtherKeyAttribute.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/OtherRecipientInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/PasswordRecipientInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/RecipientIdentifier.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/RecipientInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/RecipientKeyIdentifier.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/SignedData.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/SignerIdentifier.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/SignerInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cms/Time.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/cryptopro/CryptoProObjectIdentifiers.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/esf/CommitmentTypeIdentifier.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/esf/CommitmentTypeIndication.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/esf/CommitmentTypeQualifier.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/esf/ESFAttributes.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/esf/SignerLocation.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ess/ContentIdentifier.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ess/ESSCertID.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ess/OtherCertID.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ess/OtherSigningCertificate.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ess/SigningCertificate.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/gnu/GNUObjectIdentifiers.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/iana/IANAObjectIdentifiers.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/icao/DataGroupHash.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/icao/ICAOObjectIdentifiers.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/icao/LDSSecurityObject.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/misc/IDEACBCPar.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/misc/MiscObjectIdentifiers.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/misc/NetscapeCertType.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/misc/NetscapeRevocationURL.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/misc/VerisignCzagExtension.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/mozilla/PublicKeyAndChallenge.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/nist/NISTObjectIdentifiers.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ocsp/BasicOCSPResponse.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ocsp/CertID.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ocsp/CertStatus.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ocsp/CrlID.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ocsp/OCSPObjectIdentifiers.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ocsp/OCSPRequest.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ocsp/OCSPResponse.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ocsp/OCSPResponseStatus.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ocsp/Request.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ocsp/ResponderID.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ocsp/ResponseBytes.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ocsp/ResponseData.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ocsp/RevokedInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ocsp/ServiceLocator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ocsp/Signature.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ocsp/SingleResponse.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/ocsp/TBSRequest.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/oiw/OIWObjectIdentifiers.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/Attribute.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/AuthenticatedSafe.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/CertBag.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/CertificationRequest.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/CertificationRequestInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/ContentInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/DHParameter.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/EncryptedData.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/EncryptedPrivateKeyInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/EncryptionScheme.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/IssuerAndSerialNumber.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/KeyDerivationFunc.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/MacData.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/PBES2Algorithms.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/PBES2Parameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/PBKDF2Params.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/PKCS12PBEParams.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/PKCSObjectIdentifiers.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/Pfx.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/PrivateKeyInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/RC2CBCParameter.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/RSAESOAEPparams.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/RSAPrivateKeyStructure.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/RSASSAPSSparams.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/SafeBag.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/SignedData.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/pkcs/SignerInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/teletrust/TeleTrusTObjectIdentifiers.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/tsp/Accuracy.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/tsp/MessageImprint.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/tsp/TSTInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/tsp/TimeStampReq.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/tsp/TimeStampResp.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/util/ASN1Dump.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/util/DERDump.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/util/Dump.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/AccessDescription.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/AlgorithmIdentifier.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/AttCertIssuer.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/AttCertValidityPeriod.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/Attribute.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/AttributeCertificate.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/AttributeCertificateInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/AuthorityInformationAccess.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/AuthorityKeyIdentifier.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/BasicConstraints.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/CRLDistPoint.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/CRLNumber.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/CRLReason.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/CertPolicyId.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/CertificateList.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/CertificatePolicies.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/DSAParameter.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/DigestInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/DisplayText.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/DistributionPoint.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/DistributionPointName.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/ExtendedKeyUsage.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/GeneralName.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/GeneralNames.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/GeneralSubtree.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/Holder.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/IetfAttrSyntax.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/IssuerSerial.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/IssuingDistributionPoint.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/KeyPurposeId.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/KeyUsage.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/NameConstraints.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/NoticeReference.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/ObjectDigestInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/PolicyInformation.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/PolicyMappings.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/PolicyQualifierId.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/PolicyQualifierInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/RSAPublicKeyStructure.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/ReasonFlags.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/RoleSyntax.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/SubjectDirectoryAttributes.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/SubjectKeyIdentifier.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/SubjectPublicKeyInfo.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/TBSCertList.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/TBSCertificateStructure.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/Time.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/UserNotice.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/V1TBSCertificateGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/V2AttributeCertificateInfoGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/V2Form.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/V2TBSCertListGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/V3TBSCertificateGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/X509Attributes.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/X509CertificateStructure.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/X509DefaultEntryConverter.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/X509Extension.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/X509Extensions.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/X509Name.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/X509NameElementList.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/X509NameEntryConverter.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/X509NameTokenizer.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/X509ObjectIdentifiers.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/qualified/BiometricData.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/qualified/ETSIQCObjectIdentifiers.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/qualified/Iso4217CurrencyCode.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/qualified/MonetaryValue.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/qualified/QCStatement.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/qualified/RFC3739QCObjectIdentifiers.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/qualified/SemanticsInformation.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/qualified/TypeOfBiometricData.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x509/sigi/SigIObjectIdentifiers.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/asn1/x9/X9ObjectIdentifiers.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/AsymmetricBlockCipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/AsymmetricCipherKeyPair.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/AsymmetricCipherKeyPairGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/BasicAgreement.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/BlockCipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/BufferedAsymmetricBlockCipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/BufferedBlockCipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/CipherKeyGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/CipherParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/CryptoException.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/DSA.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/DataLengthException.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/DerivationFunction.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/DerivationParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/Digest.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/ExtendedDigest.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/InvalidCipherTextException.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/KeyGenerationParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/Mac.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/PBEParametersGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/RuntimeCryptoException.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/Signer.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/SignerWithRecovery.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/StreamBlockCipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/StreamCipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/Wrapper.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/agreement/DHAgreement.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/agreement/DHBasicAgreement.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/digests/GeneralDigest.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/digests/LongDigest.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/digests/MD4Digest.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/digests/MD5Digest.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/digests/SHA1Digest.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/digests/SHA224Digest.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/digests/SHA256Digest.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/digests/SHA384Digest.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/digests/SHA512Digest.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/digests/ShortenedDigest.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/encodings/ISO9796d1Encoding.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/encodings/OAEPEncoding.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/encodings/PKCS1Encoding.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/engines/AESEngine.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/engines/AESFastEngine.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/engines/AESLightEngine.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/engines/AESWrapEngine.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/engines/DESEngine.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/engines/DESedeEngine.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/engines/DESedeWrapEngine.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/engines/IESEngine.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/engines/NullEngine.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/engines/RC2Engine.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/engines/RSAEngine.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/generators/BaseKDFBytesGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/generators/DESKeyGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/generators/DESedeKeyGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/generators/DHBasicKeyPairGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/generators/DHKeyGeneratorHelper.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/generators/DHKeyPairGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/generators/DHParametersGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/generators/DSAKeyPairGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/generators/DSAParametersGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/generators/KDF1BytesGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/generators/KDF2BytesGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/generators/MGF1BytesGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/generators/OpenSSLPBEParametersGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/generators/PKCS12ParametersGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/generators/PKCS5S1ParametersGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/generators/PKCS5S2ParametersGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/generators/RSAKeyPairGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/io/DigestInputStream.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/io/DigestOutputStream.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/io/MacInputStream.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/io/MacOutputStream.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/macs/BlockCipherMac.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/macs/CBCBlockCipherMac.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/macs/CFBBlockCipherMac.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/macs/HMac.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/macs/ISO9797Alg3Mac.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/macs/OldHMac.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/modes/CBCBlockCipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/modes/CCMBlockCipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/modes/CFBBlockCipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/modes/CTSBlockCipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/modes/GOFBBlockCipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/modes/OFBBlockCipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/modes/PaddedBlockCipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/modes/SICBlockCipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/paddings/BlockCipherPadding.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/paddings/ISO10126d2Padding.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/paddings/ISO7816d4Padding.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/paddings/PKCS7Padding.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/paddings/PaddedBufferedBlockCipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/paddings/TBCPadding.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/paddings/X923Padding.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/paddings/ZeroBytePadding.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/AsymmetricKeyParameter.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/CCMParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/DESParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/DESedeParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/DHKeyGenerationParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/DHKeyParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/DHParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/DHPrivateKeyParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/DHPublicKeyParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/DHValidationParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/DSAKeyGenerationParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/DSAKeyParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/DSAParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/DSAPrivateKeyParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/DSAPublicKeyParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/DSAValidationParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/IESParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/IESWithCipherParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/ISO18033KDFParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/KDFParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/KeyParameter.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/MGFParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/ParametersWithIV.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/ParametersWithRandom.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/ParametersWithSBox.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/ParametersWithSalt.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/RC2Parameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/RC5Parameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/RSAKeyGenerationParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/RSAKeyParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/params/RSAPrivateCrtKeyParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/signers/DSASigner.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/signers/ISO9796d2PSSSigner.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/signers/ISO9796d2Signer.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/signers/PSSSigner.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/util/PrivateKeyFactory.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/crypto/util/PublicKeyFactory.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/i18n/ErrorBundle.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/i18n/LocalizedException.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/i18n/LocalizedMessage.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/i18n/MessageBundle.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/i18n/MissingEntryException.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/i18n/TextBundle.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/i18n/filter/Filter.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/i18n/filter/HTMLFilter.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/i18n/filter/SQLFilter.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/i18n/filter/UntrustedInput.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/PKCS10CertificationRequest.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/PKCS7SignedData.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/PrincipalUtil.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/X509KeyUsage.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/X509Principal.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/X509V1CertificateGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/X509V2CRLGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/X509V3CertificateGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/interfaces/BCKeyStore.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/interfaces/IESKey.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/interfaces/PKCS12BagAttributeCarrier.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/netscape/NetscapeCertRequest.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/AnnotatedException.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/BouncyCastleProvider.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/BrokenJCEBlockCipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/BrokenKDF2BytesGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/BrokenPBE.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/CertPathValidatorUtilities.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/CertStoreCollectionSpi.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/DHUtil.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/DSAUtil.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/IndexedPKIXParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JCEBlockCipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JCEDHKeyAgreement.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JCEDHPrivateKey.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JCEDHPublicKey.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JCEDigestUtil.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JCEIESCipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JCEKeyGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JCEMac.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JCEPBEKey.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JCERSACipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JCERSAPrivateCrtKey.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JCERSAPrivateKey.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JCERSAPublicKey.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JCESecretKeyFactory.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JCEStreamCipher.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JDKAlgorithmParameterGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JDKAlgorithmParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JDKDSAPrivateKey.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JDKDSAPublicKey.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JDKDSASigner.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JDKDigestSignature.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JDKECDSAAlgParameters.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JDKISOSignature.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JDKKeyFactory.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JDKKeyPairGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JDKKeyStore.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JDKMessageDigest.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JDKPKCS12KeyStore.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JDKPSSSigner.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/JDKX509CertificateFactory.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/PBE.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/PKIXCertPath.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/PKIXCertPathBuilderSpi.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/PKIXCertPathValidatorSpi.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/PKIXPolicyNode.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/RSAUtil.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/WrapCipherSpi.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/X509CRLEntryObject.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/X509CRLObject.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/X509CertificateObject.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/provider/X509SignatureUtil.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/spec/IEKeySpec.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/jce/spec/IESParameterSpec.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/openssl/PEMWriter.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/util/Arrays.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/util/BigIntegers.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/util/Strings.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/util/encoders/Base64.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/util/encoders/Base64Encoder.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/util/encoders/BufferedDecoder.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/util/encoders/BufferedEncoder.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/util/encoders/Encoder.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/util/encoders/Hex.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/util/encoders/HexEncoder.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/util/encoders/HexTranslator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/util/encoders/Translator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/util/encoders/UrlBase64.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/util/encoders/UrlBase64Encoder.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/x509/AttributeCertificateHolder.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/x509/AttributeCertificateIssuer.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/x509/CertPathReviewerException.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/x509/CertPathReviewerMessages.properties delete mode 100644 libcore/security/src/main/java/org/bouncycastle/x509/CertPathReviewerMessages_de.properties delete mode 100644 libcore/security/src/main/java/org/bouncycastle/x509/PKIXCertPathReviewer.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/x509/X509Attribute.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/x509/X509AttributeCertificate.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/x509/X509Util.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/x509/X509V1CertificateGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/x509/X509V2AttributeCertificate.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/x509/X509V2AttributeCertificateGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/x509/X509V2CRLGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/x509/X509V3CertificateGenerator.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/x509/extension/AuthorityKeyIdentifierStructure.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/x509/extension/SubjectKeyIdentifierStructure.java delete mode 100644 libcore/security/src/main/java/org/bouncycastle/x509/extension/X509ExtensionUtil.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/AccessControlException2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/AccessControlExceptionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/AccessController2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator1Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator3Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersSpiTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/AllPermission2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/AllTests.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/AuthProviderTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/BasicPermission2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/CodeSignerTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/CodeSource2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/CodeSourceTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/DigestException2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/DigestExceptionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/DigestInputStream2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/DigestInputStreamTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/DigestOutputStreamTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/GeneralSecurityException2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/GeneralSecurityExceptionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/GuardedObjectTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/Identity2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/IdentityScope2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/IdentityScopeTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/InvalidAlgorithmParameterException2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/InvalidAlgorithmParameterExceptionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/InvalidKeyException2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/InvalidKeyExceptionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/InvalidParameterException2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/InvalidParameterExceptionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KSCallbackHandlerProtectionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KSPasswordProtectionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KSPrivateKeyEntryTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KSSecretKeyEntryTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KSTrustedCertificateEntryTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyException2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyExceptionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyFactory2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyFactorySpiTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyFactoryTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyManagementException2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyManagementExceptionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator1Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator3Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator4Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyPairGeneratorSpiTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyPairTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyRepTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyRepTypeTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStore2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStore3Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStore4Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStoreBuilderTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStoreException2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStoreExceptionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStoreLoadStoreParameterTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStoreSpiTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStoreTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/MessageDigest1Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/MessageDigest2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/MessageDigestSpiTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/NoSuchAlgorithmException2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/NoSuchAlgorithmExceptionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/NoSuchProviderException2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/NoSuchProviderExceptionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/Permission2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/PermissionCollectionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/PermissionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/Permissions2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/PermissionsTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/PolicyTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/PrivateKeyTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/PrivilegedActionException2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/PrivilegedActionExceptionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/PrivilegedActionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/PrivilegedExceptionActionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/ProtectionDomainTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/Provider2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/ProviderException2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/ProviderExceptionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/ProviderServiceTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/ProviderTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/PublicKeyTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/SecureRandomSpiTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/Security2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/SecurityPermission2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/SecurityPermissionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/SecurityTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/Signature2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/SignatureException2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/SignatureExceptionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/SignatureSpiTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/SignatureTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/SignedObjectTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/SignerTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/TimestampTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/UnrecoverableEntryExceptionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/UnrecoverableKeyException2Test.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/UnrecoverableKeyExceptionTest.java delete mode 100644 libcore/security/src/test/java/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.java delete mode 100644 libcore/security/src/test/java/org/bouncycastle/jce/provider/AllTests.java delete mode 100644 libcore/security/src/test/java/org/bouncycastle/jce/provider/PKIXCertPathValidatorSpiTest.java delete mode 100644 libcore/security/src/test/java/tests/api/java/security/AccessControlContextTest.java delete mode 100644 libcore/security/src/test/java/tests/api/java/security/AllTests.java delete mode 100644 libcore/security/src/test/java/tests/api/java/security/DomainCombinerTest.java delete mode 100644 libcore/security/src/test/java/tests/api/java/security/PermissionCollectionTest.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/auth/AllTests.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/auth/AuthPermissionTest.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/auth/CallbackHandlerTest.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/auth/DestroyFailedExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/auth/DestroyableTest.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/auth/LoginExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/auth/PasswordCallbackTest.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/auth/PrivateCredentialPermissionTest.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/auth/SubjectDomainCombinerTest.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/auth/SubjectTest.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/auth/UnsupportedCallbackExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/auth/X500PrincipalTest.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/cert/AllTests.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/cert/CertificateEncodingExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/cert/CertificateExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/cert/CertificateExpiredExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/cert/CertificateNotYetValidExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/cert/CertificateParsingExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/cert/CertificateTest.java delete mode 100644 libcore/security/src/test/java/tests/api/javax/security/cert/X509CertificateTest.java delete mode 100644 libcore/security/src/test/java/tests/java/security/AlgorithmParameterGeneratorSpiTest.java delete mode 100644 libcore/security/src/test/java/tests/java/security/AllPermissionTest.java delete mode 100644 libcore/security/src/test/java/tests/java/security/AllTests.java delete mode 100644 libcore/security/src/test/java/tests/java/security/BasicPermissionTest.java delete mode 100644 libcore/security/src/test/java/tests/java/security/IdentityTest.java delete mode 100644 libcore/security/src/test/java/tests/java/security/SecureClassLoaderTest.java delete mode 100644 libcore/security/src/test/java/tests/java/security/SecureRandomTest.java delete mode 100644 libcore/security/src/test/java/tests/security/AccessControllerTest.java delete mode 100644 libcore/security/src/test/java/tests/security/AllTests.java delete mode 100644 libcore/security/src/test/java/tests/security/acl/AclNotFoundException2Test.java delete mode 100644 libcore/security/src/test/java/tests/security/acl/AclNotFoundExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/security/acl/AllTests.java delete mode 100644 libcore/security/src/test/java/tests/security/acl/IAclEntryTest.java delete mode 100644 libcore/security/src/test/java/tests/security/acl/IAclTest.java delete mode 100644 libcore/security/src/test/java/tests/security/acl/IGroupTest.java delete mode 100644 libcore/security/src/test/java/tests/security/acl/IOwnerTest.java delete mode 100644 libcore/security/src/test/java/tests/security/acl/IPermissionTest.java delete mode 100644 libcore/security/src/test/java/tests/security/acl/LastOwnerException2Test.java delete mode 100644 libcore/security/src/test/java/tests/security/acl/LastOwnerExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/security/acl/NotOwnerException2Test.java delete mode 100644 libcore/security/src/test/java/tests/security/acl/NotOwnerExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/AllTests.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CRLExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CRLTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertPathBuilder1Test.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertPathBuilder2Test.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertPathBuilderExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertPathBuilderSpiTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertPathCertPathRepTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertPathTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertPathValidator1Test.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertPathValidator2Test.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertPathValidator3Test.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertPathValidatorExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertPathValidatorSpiTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertStore1Test.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertStore2Test.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertStoreExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertStoreSpiTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertificateCertificateRepTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertificateEncodingException2Test.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertificateEncodingExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertificateException2Test.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertificateExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertificateExpiredExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertificateFactory1Test.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertificateFactory2Test.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertificateFactory3Test.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertificateFactory4Test.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertificateFactorySpiTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertificateNotYetValidExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertificateParsingExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CertificateTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/CollectionCertStoreParametersTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/LDAPCertStoreParametersTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/PKIXBuilderParametersTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/PKIXCertPathBuilderResultTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/PKIXCertPathCheckerTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/PKIXCertPathValidatorResultTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/PKIXParametersTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/PolicyNodeTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/PolicyQualifierInfoTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/TrustAnchorTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/X509CRL2Test.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/X509CRLEntryTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/X509CRLSelector2Test.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/X509CRLSelectorTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/X509CRLTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/X509CertSelectorTest.java delete mode 100644 libcore/security/src/test/java/tests/security/cert/X509Certificate2Test.java delete mode 100644 libcore/security/src/test/java/tests/security/interfaces/AllTests.java delete mode 100644 libcore/security/src/test/java/tests/security/interfaces/DSAKeyPairGeneratorTest.java delete mode 100644 libcore/security/src/test/java/tests/security/interfaces/DSAKeyTest.java delete mode 100644 libcore/security/src/test/java/tests/security/interfaces/DSAParamsTest.java delete mode 100644 libcore/security/src/test/java/tests/security/interfaces/DSAPrivateKeyTest.java delete mode 100644 libcore/security/src/test/java/tests/security/interfaces/DSAPublicKeyTest.java delete mode 100644 libcore/security/src/test/java/tests/security/interfaces/RSAKeyTest.java delete mode 100644 libcore/security/src/test/java/tests/security/interfaces/RSAMultiPrimePrivateCrtKeyTest.java delete mode 100644 libcore/security/src/test/java/tests/security/interfaces/RSAPrivateCrtKeyTest.java delete mode 100644 libcore/security/src/test/java/tests/security/interfaces/RSAPrivateKeyTest.java delete mode 100644 libcore/security/src/test/java/tests/security/interfaces/RSAPublicKeyTest.java delete mode 100644 libcore/security/src/test/java/tests/security/interfaces/Util.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/AllTests.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaIoFileInputStreamTest.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaIoFileOutputStreamTest.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaIoFileTest.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaIoObjectInputStreamTest.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaIoObjectOutputStreamTest.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaIoRandomAccessFileTest.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaLangClassLoaderTest.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaLangClassTest.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaLangReflectAccessibleObjectTest.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaLangRuntimeTest.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaLangSystemTest.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaLangThreadTest.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaNetDatagramSocketTest.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaNetMulticastSocketTest.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaNetServerSocketTest.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaNetSocketTest.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaSecurityPolicyTest.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaSecuritySecurityTest.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaUtilLocale.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaUtilZipZipFile.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaxSecurityAuthSubject.java delete mode 100644 libcore/security/src/test/java/tests/security/permissions/JavaxSecurityAuthSubjectDomainCombiner.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/AllTests.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/DSAParameterSpecTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/DSAPrivateKeySpecTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/DSAPublicKeySpecTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/ECFieldF2mTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/ECFieldFpTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/ECGenParameterSpecTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/ECParameterSpecTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/ECPointTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/ECPrivateKeySpecTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/ECPublicKeySpecTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/EllipticCurveTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/EncodedKeySpec2Test.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/EncodedKeySpecTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/InvalidKeySpecExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/InvalidParameterSpecExceptionTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/MGF1ParameterSpecTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/PKCS8EncodedKeySpecTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/PSSParameterSpecTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/RSAKeyGenParameterSpecTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/RSAMultiPrimePrivateCrtKeySpecTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/RSAOtherPrimeInfoTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/RSAPrivateCrtKeySpecTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/RSAPrivateKeySpecTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/RSAPublicKeySpecTest.java delete mode 100644 libcore/security/src/test/java/tests/security/spec/X509EncodedKeySpecTest.java delete mode 100644 libcore/security/src/test/java/tests/security/special-test-cases.txt delete mode 100644 libcore/security/src/test/java/tests/targets/security/AlgorithmParameterGeneratorTest.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/AlgorithmParameterGeneratorTestAES.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/AlgorithmParameterGeneratorTestDH.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/AlgorithmParameterGeneratorTestDSA.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/AlgorithmParametersTest.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/AlgorithmParametersTestAES.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/AlgorithmParametersTestDES.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/AlgorithmParametersTestDESede.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/AlgorithmParametersTestDH.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/AlgorithmParametersTestDSA.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/AlgorithmParametersTestOAEP.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/AllTests.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/CipherHelper.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/DHTest.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/DefaultKeys.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/KeyFactoryTest.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/KeyFactoryTestDH.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/KeyFactoryTestDSA.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/KeyFactoryTestRSA.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/KeyPairGeneratorTest.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/KeyPairGeneratorTestDH.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/KeyPairGeneratorTestDSA.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/KeyPairGeneratorTestRSA.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/KeyStoreTest.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/KeyStoreTestPKCS12.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/MessageDigestTest.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/MessageDigestTestMD2.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/MessageDigestTestMD5.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/MessageDigestTestSHA1.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/MessageDigestTestSHA224.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/MessageDigestTestSHA256.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/MessageDigestTestSHA384.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/MessageDigestTestSHA512.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/SecureRandomTest.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/SecureRandomTestSHA1PRNG.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/SignatureTest.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/SignatureTestMD2withRSA.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/SignatureTestMD5withRSA.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/SignatureTestNONEwithDSA.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/SignatureTestSHA1withDSA.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/SignatureTestSHA1withRSA.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/SignatureTestSHA224withRSA.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/SignatureTestSHA256withRSA.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/SignatureTestSHA384withRSA.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/SignatureTestSHA512withRSA.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/cert/AllTests.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/cert/CertPathBuilderTest.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/cert/CertPathBuilderTestPKIX.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/cert/CertPathValidatorTest.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/cert/CertPathValidatorTestPKIX.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/cert/CertificateFactoryTest.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/cert/CertificateFactoryTestX509.java delete mode 100644 libcore/security/src/test/java/tests/targets/security/cert/CertificateTest.java delete mode 100644 libcore/security/src/test/resources/PolicyTest.txt delete mode 100755 libcore/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.golden.ser delete mode 100644 libcore/security/src/test/resources/serialization/tests/security/cert/CertPathTest.golden.ser delete mode 100644 libcore/security/src/test/resources/serialization/tests/security/cert/CertificateTest.golden.ser delete mode 100644 libcore/security/src/test/resources/tests/resources/hyts_badpem.cer delete mode 100644 libcore/security/src/test/resources/tests/resources/java/security/cert/CertPath.PkiPath delete mode 100644 libcore/security/src/test/resources/tests/resources/testdex.jar delete mode 100644 libcore/security/src/test/resources/tests/targets/security/MD5.check delete mode 100644 libcore/security/src/test/resources/tests/targets/security/MD5.data delete mode 100644 libcore/security/src/test/resources/tests/targets/security/SHA-1.check delete mode 100644 libcore/security/src/test/resources/tests/targets/security/SHA-1.data delete mode 100644 libcore/security/src/test/resources/tests/targets/security/SHA-224.check delete mode 100644 libcore/security/src/test/resources/tests/targets/security/SHA-224.data delete mode 100644 libcore/security/src/test/resources/tests/targets/security/SHA-256.check delete mode 100644 libcore/security/src/test/resources/tests/targets/security/SHA-256.data delete mode 100644 libcore/security/src/test/resources/tests/targets/security/SHA-384.check delete mode 100644 libcore/security/src/test/resources/tests/targets/security/SHA-384.data delete mode 100644 libcore/security/src/test/resources/tests/targets/security/SHA-512.check delete mode 100644 libcore/security/src/test/resources/tests/targets/security/SHA-512.data delete mode 100644 libcore/sql/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/sql/MODULE_LICENSE_BSD_LIKE delete mode 100644 libcore/sql/src/main/java/SQLite/Authorizer.java delete mode 100644 libcore/sql/src/main/java/SQLite/Blob.java delete mode 100644 libcore/sql/src/main/java/SQLite/BusyHandler.java delete mode 100644 libcore/sql/src/main/java/SQLite/Callback.java delete mode 100644 libcore/sql/src/main/java/SQLite/Constants.java delete mode 100644 libcore/sql/src/main/java/SQLite/Database.java delete mode 100644 libcore/sql/src/main/java/SQLite/Exception.java delete mode 100644 libcore/sql/src/main/java/SQLite/Function.java delete mode 100644 libcore/sql/src/main/java/SQLite/FunctionContext.java delete mode 100644 libcore/sql/src/main/java/SQLite/JDBC2y/JDBCConnection.java delete mode 100644 libcore/sql/src/main/java/SQLite/JDBC2y/JDBCDatabaseMetaData.java delete mode 100644 libcore/sql/src/main/java/SQLite/JDBC2y/JDBCPreparedStatement.java delete mode 100644 libcore/sql/src/main/java/SQLite/JDBC2y/JDBCResultSet.java delete mode 100644 libcore/sql/src/main/java/SQLite/JDBC2y/JDBCResultSetMetaData.java delete mode 100644 libcore/sql/src/main/java/SQLite/JDBC2y/JDBCStatement.java delete mode 100644 libcore/sql/src/main/java/SQLite/JDBC2y/TableResultX.java delete mode 100644 libcore/sql/src/main/java/SQLite/JDBCDriver.java delete mode 100644 libcore/sql/src/main/java/SQLite/ProgressHandler.java delete mode 100644 libcore/sql/src/main/java/SQLite/Shell.java delete mode 100644 libcore/sql/src/main/java/SQLite/Stmt.java delete mode 100644 libcore/sql/src/main/java/SQLite/StringEncoder.java delete mode 100644 libcore/sql/src/main/java/SQLite/TableResult.java delete mode 100644 libcore/sql/src/main/java/SQLite/Trace.java delete mode 100644 libcore/sql/src/main/java/SQLite/Vm.java delete mode 100644 libcore/sql/src/main/java/java/sql/Array.java delete mode 100644 libcore/sql/src/main/java/java/sql/BatchUpdateException.java delete mode 100644 libcore/sql/src/main/java/java/sql/Blob.java delete mode 100644 libcore/sql/src/main/java/java/sql/CallableStatement.java delete mode 100644 libcore/sql/src/main/java/java/sql/Clob.java delete mode 100644 libcore/sql/src/main/java/java/sql/Connection.java delete mode 100644 libcore/sql/src/main/java/java/sql/DataTruncation.java delete mode 100644 libcore/sql/src/main/java/java/sql/DatabaseMetaData.java delete mode 100644 libcore/sql/src/main/java/java/sql/Date.java delete mode 100644 libcore/sql/src/main/java/java/sql/Driver.java delete mode 100644 libcore/sql/src/main/java/java/sql/DriverManager.java delete mode 100644 libcore/sql/src/main/java/java/sql/DriverPropertyInfo.java delete mode 100644 libcore/sql/src/main/java/java/sql/ParameterMetaData.java delete mode 100644 libcore/sql/src/main/java/java/sql/PreparedStatement.java delete mode 100644 libcore/sql/src/main/java/java/sql/Ref.java delete mode 100644 libcore/sql/src/main/java/java/sql/ResultSet.java delete mode 100644 libcore/sql/src/main/java/java/sql/ResultSetMetaData.java delete mode 100644 libcore/sql/src/main/java/java/sql/SQLData.java delete mode 100644 libcore/sql/src/main/java/java/sql/SQLException.java delete mode 100644 libcore/sql/src/main/java/java/sql/SQLInput.java delete mode 100644 libcore/sql/src/main/java/java/sql/SQLOutput.java delete mode 100644 libcore/sql/src/main/java/java/sql/SQLPermission.java delete mode 100644 libcore/sql/src/main/java/java/sql/SQLWarning.java delete mode 100644 libcore/sql/src/main/java/java/sql/Savepoint.java delete mode 100644 libcore/sql/src/main/java/java/sql/Statement.java delete mode 100644 libcore/sql/src/main/java/java/sql/Struct.java delete mode 100644 libcore/sql/src/main/java/java/sql/Time.java delete mode 100644 libcore/sql/src/main/java/java/sql/Timestamp.java delete mode 100644 libcore/sql/src/main/java/java/sql/Types.java delete mode 100644 libcore/sql/src/main/java/java/sql/package.html delete mode 100644 libcore/sql/src/main/java/javax/sql/ConnectionEvent.java delete mode 100644 libcore/sql/src/main/java/javax/sql/ConnectionEventListener.java delete mode 100644 libcore/sql/src/main/java/javax/sql/ConnectionPoolDataSource.java delete mode 100644 libcore/sql/src/main/java/javax/sql/DataSource.java delete mode 100644 libcore/sql/src/main/java/javax/sql/PooledConnection.java delete mode 100644 libcore/sql/src/main/java/javax/sql/RowSet.java delete mode 100644 libcore/sql/src/main/java/javax/sql/RowSetEvent.java delete mode 100644 libcore/sql/src/main/java/javax/sql/RowSetInternal.java delete mode 100644 libcore/sql/src/main/java/javax/sql/RowSetListener.java delete mode 100644 libcore/sql/src/main/java/javax/sql/RowSetMetaData.java delete mode 100644 libcore/sql/src/main/java/javax/sql/RowSetReader.java delete mode 100644 libcore/sql/src/main/java/javax/sql/RowSetWriter.java delete mode 100644 libcore/sql/src/main/java/javax/sql/package.html delete mode 100644 libcore/sql/src/main/java/org/apache/harmony/sql/internal/nls/Messages.java delete mode 100644 libcore/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties delete mode 100644 libcore/sql/src/main/native/sqlite_jni.c delete mode 100644 libcore/sql/src/main/native/sqlite_jni.h delete mode 100644 libcore/sql/src/main/native/sqlite_jni_defs.h delete mode 100644 libcore/sql/src/main/native/sqlite_jni_registration.c delete mode 100644 libcore/sql/src/main/native/sub.mk delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/AllTests.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/BatchUpdateExceptionTest.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ConnectionTest.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DataTruncationTest.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DatabaseMetaDataTest.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DateTest.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverPropertyInfoTest.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ParameterMetaDataTest.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ResultSetMetaDataTest.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ResultSetTest.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLExceptionTest.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLPermissionTest.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLWarningTest.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/StatementTest.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_ClassLoader.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Connection1.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver1.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver2.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver3.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver4.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver5.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_DriverManager.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestMainForDriver.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimeTest.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimestampTest.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TypesTest.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/AllTests.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/ConnectionEventTest.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/Impl_PooledConnection.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/Impl_RowSet.java delete mode 100644 libcore/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/RowSetEventTest.java delete mode 100644 libcore/sql/src/test/java/tests/SQLite/AbstractSqlTest.java delete mode 100644 libcore/sql/src/test/java/tests/SQLite/AllTests.java delete mode 100644 libcore/sql/src/test/java/tests/SQLite/BlobTest.java delete mode 100644 libcore/sql/src/test/java/tests/SQLite/ConstantsTest.java delete mode 100644 libcore/sql/src/test/java/tests/SQLite/DatabaseTest.java delete mode 100644 libcore/sql/src/test/java/tests/SQLite/ExceptionTest.java delete mode 100644 libcore/sql/src/test/java/tests/SQLite/FunctionContextTest.java delete mode 100644 libcore/sql/src/test/java/tests/SQLite/JDBCDriverFunctionalTest.java delete mode 100644 libcore/sql/src/test/java/tests/SQLite/JDBCDriverTest.java delete mode 100644 libcore/sql/src/test/java/tests/SQLite/SQLiteTest.java delete mode 100644 libcore/sql/src/test/java/tests/SQLite/ShellTest.java delete mode 100644 libcore/sql/src/test/java/tests/SQLite/StmtTest.java delete mode 100644 libcore/sql/src/test/java/tests/java/sql/AllTests.java delete mode 100644 libcore/sql/src/test/java/tests/java/sql/DatabaseMetaDataNotSupportedTest.java delete mode 100755 libcore/sql/src/test/java/tests/java/sql/DatabaseMetaDataTest.java delete mode 100755 libcore/sql/src/test/java/tests/java/sql/DeleteFunctionalityTest.java delete mode 100755 libcore/sql/src/test/java/tests/java/sql/InsertFunctionalityTest.java delete mode 100755 libcore/sql/src/test/java/tests/java/sql/MultiThreadAccessTest.java delete mode 100644 libcore/sql/src/test/java/tests/java/sql/QueryTimeoutTest.java delete mode 100755 libcore/sql/src/test/java/tests/java/sql/SelectFunctionalityTest.java delete mode 100755 libcore/sql/src/test/java/tests/java/sql/StressTest.java delete mode 100755 libcore/sql/src/test/java/tests/java/sql/UpdateFunctionalityTest.java delete mode 100755 libcore/sql/src/test/java/tests/java/sql/UpdateFunctionalityTest2.java delete mode 100644 libcore/sql/src/test/java/tests/javax/sql/ConnectionEventListenerTest.java delete mode 100644 libcore/sql/src/test/java/tests/javax/sql/ConnectionPoolDataSourceTest.java delete mode 100644 libcore/sql/src/test/java/tests/javax/sql/DataSourceTest.java delete mode 100644 libcore/sql/src/test/java/tests/javax/sql/PooledConnectionTest.java delete mode 100644 libcore/sql/src/test/java/tests/javax/sql/RowSetInternalTest.java delete mode 100644 libcore/sql/src/test/java/tests/javax/sql/RowSetListenerTest.java delete mode 100644 libcore/sql/src/test/java/tests/javax/sql/RowSetMetaDataTest.java delete mode 100644 libcore/sql/src/test/java/tests/javax/sql/RowSetReaderTest.java delete mode 100644 libcore/sql/src/test/java/tests/javax/sql/RowSetTest.java delete mode 100644 libcore/sql/src/test/java/tests/javax/sql/RowSetWriterTest.java delete mode 100644 libcore/sql/src/test/java/tests/sql/AllTests.java delete mode 100644 libcore/sql/src/test/java/tests/sql/ArrayTest.java delete mode 100644 libcore/sql/src/test/java/tests/sql/BlobTest.java delete mode 100644 libcore/sql/src/test/java/tests/sql/CallableStatementTest.java delete mode 100644 libcore/sql/src/test/java/tests/sql/ClobTest.java delete mode 100755 libcore/sql/src/test/java/tests/sql/ConnectionTest.java delete mode 100644 libcore/sql/src/test/java/tests/sql/ParameterMetaDataTest.java delete mode 100755 libcore/sql/src/test/java/tests/sql/PreparedStatementTest.java delete mode 100644 libcore/sql/src/test/java/tests/sql/RefTest.java delete mode 100644 libcore/sql/src/test/java/tests/sql/ResultSetGetterTests.java delete mode 100755 libcore/sql/src/test/java/tests/sql/ResultSetMetaDataTest.java delete mode 100644 libcore/sql/src/test/java/tests/sql/ResultSetNotSupportedTests.java delete mode 100644 libcore/sql/src/test/java/tests/sql/ResultSetTest.java delete mode 100644 libcore/sql/src/test/java/tests/sql/SQLDataTest.java delete mode 100644 libcore/sql/src/test/java/tests/sql/SQLInputTest.java delete mode 100644 libcore/sql/src/test/java/tests/sql/SQLOutputTest.java delete mode 100755 libcore/sql/src/test/java/tests/sql/SQLTest.java delete mode 100644 libcore/sql/src/test/java/tests/sql/SavepointTest.java delete mode 100755 libcore/sql/src/test/java/tests/sql/StatementTest.java delete mode 100644 libcore/sql/src/test/java/tests/sql/StructTest.java delete mode 100755 libcore/sql/src/test/java/tests/support/DatabaseCreator.java delete mode 100644 libcore/sql/src/test/java/tests/support/MockCallback.java delete mode 100644 libcore/sql/src/test/java/tests/support/MockFunction.java delete mode 100644 libcore/sql/src/test/java/tests/support/Support_SQL.java delete mode 100644 libcore/sql/src/test/java/tests/support/ThreadPool.java delete mode 100644 libcore/sql/src/test/resources/blob.c delete mode 100644 libcore/sql/src/test/resources/connection.properties delete mode 100644 libcore/sql/src/test/resources/serialization/org/apache/harmony/sql/tests/java/sql/BatchUpdateExceptionTest.golden.ser delete mode 100644 libcore/sql/src/test/resources/serialization/org/apache/harmony/sql/tests/java/sql/DataTruncationTest.golden.ser delete mode 100644 libcore/sql/src/test/resources/serialization/org/apache/harmony/sql/tests/java/sql/SQLExceptionTest.golden.ser delete mode 100644 libcore/sql/src/test/resources/serialization/org/apache/harmony/sql/tests/java/sql/SQLWarningTest.golden.ser delete mode 100644 libcore/sql/src/test/resources/serialization/org/apache/harmony/sql/tests/java/sql/TimestampTest.golden.ser delete mode 100644 libcore/sql/src/test/resources/serialization/org/apache/harmony/sql/tests/javax/sql/ConnectionEventTest.golden.ser delete mode 100644 libcore/sql/src/test/resources/serialization/org/apache/harmony/sql/tests/javax/sql/rowset/RowSetMetaDataImplTest.golden.ser delete mode 100644 libcore/sql/src/test/resources/serialization/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialExceptionTest.golden.ser delete mode 100644 libcore/suncompat/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/suncompat/src/main/java/sun/misc/Unsafe.java delete mode 100644 libcore/suncompat/src/test/java/sun/misc/AllTests.java delete mode 100644 libcore/suncompat/src/test/java/sun/misc/UnsafeTest.java delete mode 100644 libcore/suncompat/src/test/java/tests/suncompat/AllTests.java delete mode 100644 libcore/support/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/CertificateStub.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/IdentityScopeStub.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/IdentityStub.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/KeyStoreTestSupport.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MDGoldenData.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MyAlgorithmParameterGeneratorSpi.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MyBasicPermission.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MyGuard.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator1.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator2.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MyKeyPairGenerator3.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MyKeyPairGeneratorSpi.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MyKeyStore.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MyKeyStoreSpi.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MyLoadStoreParams.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MyMessageDigest1.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MyMessageDigest2.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MyPermission.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MyPermissionCollection.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MyProvider.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MySSLContextSpi.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MySignature1.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MySignature2.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/MyTrustManagerFactorySpi.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/PrivateKeyStub.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/PublicKeyStub.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/RandomImpl.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/SecurityChecker.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/SignerStub.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/SpiEngUtils.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/TestCertUtils.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/TestKeyPair.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/TestKeyStoreSpi.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/TestUtils.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclEntryImpl.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclEnumerator.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclImpl.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/GroupImpl.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/OwnerImpl.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/PermissionImpl.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/PrincipalImpl.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/cert/MyCRL.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/cert/MyCertPath.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/cert/MyCertPathBuilderSpi.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/cert/MyCertPathValidatorSpi.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/cert/MyCertStoreParameters.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/cert/MyCertStoreSpi.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/cert/MyCertificate.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/cert/MyCertificateFactorySpi.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/cert/MyFailingCertPath.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/cert/MyFailingCertificate.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/cert/PolicyNodeImpl.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/cert/TestUtils.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/interfaces/DSAKeyPairGeneratorImpl.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/interfaces/RSAMultiPrimePrivateCrtKeyImpl.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/spec/MyEncodedKeySpec.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/security/tests/support/tmpCallbackHandler.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/xnet/tests/support/KeyManagerFactorySpiImpl.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/xnet/tests/support/MyKeyManagerFactorySpi.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/xnet/tests/support/MySSLContextSpi.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/xnet/tests/support/MyTrustManagerFactorySpi.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/xnet/tests/support/SSLContextSpiImpl.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/xnet/tests/support/SSLSocketFactoryImpl.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/xnet/tests/support/TrustManagerFactorySpiImpl.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/xnet/tests/support/X509KeyManagerImpl.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/xnet/tests/support/X509TrustManagerImpl.java delete mode 100644 libcore/support/src/test/java/org/apache/harmony/xnet/tests/support/mySSLSession.java delete mode 100644 libcore/support/src/test/java/targets/AlgorithmParameterGenerators.java delete mode 100644 libcore/support/src/test/java/targets/AlgorithmParameters.java delete mode 100644 libcore/support/src/test/java/targets/CertPathBuilders.java delete mode 100644 libcore/support/src/test/java/targets/CertPathValidators.java delete mode 100644 libcore/support/src/test/java/targets/CertificateFactories.java delete mode 100644 libcore/support/src/test/java/targets/Charsets.java delete mode 100644 libcore/support/src/test/java/targets/Cipher.java delete mode 100644 libcore/support/src/test/java/targets/KeyAgreement.java delete mode 100644 libcore/support/src/test/java/targets/KeyFactories.java delete mode 100644 libcore/support/src/test/java/targets/KeyGenerator.java delete mode 100644 libcore/support/src/test/java/targets/KeyPairGenerators.java delete mode 100644 libcore/support/src/test/java/targets/KeyStores.java delete mode 100644 libcore/support/src/test/java/targets/Mac.java delete mode 100644 libcore/support/src/test/java/targets/MessageDigests.java delete mode 100644 libcore/support/src/test/java/targets/SecretKeyFactory.java delete mode 100644 libcore/support/src/test/java/targets/SecureRandoms.java delete mode 100644 libcore/support/src/test/java/targets/Signatures.java delete mode 100644 libcore/support/src/test/java/tests/resources/Broken_entry.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Broken_entry_data.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Broken_manifest.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Created_by_1_4.jar delete mode 100644 libcore/support/src/test/java/tests/resources/EmptyEntries_signed.jar delete mode 100644 libcore/support/src/test/java/tests/resources/GZIPInputStream/hyts_gInput.txt.gz delete mode 100644 libcore/support/src/test/java/tests/resources/Harmony.GIF delete mode 100644 libcore/support/src/test/java/tests/resources/Inserted_Entry_Manifest.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Inserted_Entry_Manifest_with_DigestCode.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Integrate.jar delete mode 100644 libcore/support/src/test/java/tests/resources/JarIndex/hyts_11.jar delete mode 100644 libcore/support/src/test/java/tests/resources/JarIndex/hyts_12.jar delete mode 100644 libcore/support/src/test/java/tests/resources/JarIndex/hyts_13.jar delete mode 100644 libcore/support/src/test/java/tests/resources/JarIndex/hyts_14.jar delete mode 100644 libcore/support/src/test/java/tests/resources/JarIndex/hyts_21.jar delete mode 100644 libcore/support/src/test/java/tests/resources/JarIndex/hyts_22-new.jar delete mode 100644 libcore/support/src/test/java/tests/resources/JarIndex/hyts_22.jar delete mode 100644 libcore/support/src/test/java/tests/resources/JarIndex/hyts_23.jar delete mode 100644 libcore/support/src/test/java/tests/resources/JarIndex/hyts_31.jar delete mode 100644 libcore/support/src/test/java/tests/resources/JarIndex/hyts_32.jar delete mode 100644 libcore/support/src/test/java/tests/resources/JarIndex/hyts_33.jar delete mode 100644 libcore/support/src/test/java/tests/resources/JarIndex/hyts_41.jar delete mode 100644 libcore/support/src/test/java/tests/resources/JarIndex/hyts_42.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Modified_Class.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Modified_Manifest_EntryAttributes.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Modified_Manifest_MainAttributes.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Modified_SF_EntryAttributes.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Package/hyts_all_attributes.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Package/hyts_all_attributes_dex.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Package/hyts_c.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Package/hyts_c_dex.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Package/hyts_no_attributes.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Package/hyts_no_attributes_dex.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Package/hyts_no_entry.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Package/hyts_no_entry_dex.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Package/hyts_package.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Package/hyts_package_dex.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Package/hyts_pq.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Package/hyts_pq_dex.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Package/hyts_some_attributes.jar delete mode 100644 libcore/support/src/test/java/tests/resources/Package/hyts_some_attributes_dex.jar delete mode 100644 libcore/support/src/test/java/tests/resources/TestCodeSigners.jar delete mode 100644 libcore/support/src/test/java/tests/resources/cts_dalvikExecTest.jar delete mode 100644 libcore/support/src/test/java/tests/resources/cts_dalvikExecTest_classes.dex delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_Bar.ser delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_Foo.ser delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_PropertiesTest.properties delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_ZipFile.zip delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_att.jar delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_available.tst delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_checkInput.txt delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_compDiction.txt delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_compressD.txt delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_constru_O.txt delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_constru_OD.txt delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_constru_ODI.txt delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_des-ede3-cbc.test1.ciphertext delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_des-ede3-cbc.test1.iv delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_des-ede3-cbc.test1.key delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_des-ede3-cbc.test1.plaintext delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_des-ede3-cbc.test2.ciphertext delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_des-ede3-cbc.test2.iv delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_des-ede3-cbc.test2.key delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_des-ede3-cbc.test2.plaintext delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_des-ede3-cbc.test3.ciphertext delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_des-ede3-cbc.test3.iv delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_des-ede3-cbc.test3.key delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_des-ede3-cbc.test3.plaintext delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_htmltest.html delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_mainClass.ser delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_manifest1.jar delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_missingclass.ser delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_patch.jar delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_patch2.jar delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_resource.properties delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_security.jar delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_signed.jar delete mode 100644 libcore/support/src/test/java/tests/resources/hyts_signed_inc.jar delete mode 100644 libcore/support/src/test/java/tests/resources/illegalClasses.jar delete mode 100644 libcore/support/src/test/java/tests/resources/junit4-4.3.1.jar delete mode 100644 libcore/support/src/test/java/tests/resources/manifest/hyts_MANIFEST.MF delete mode 100644 libcore/support/src/test/java/tests/resources/morestuff/hyts_patch.jar delete mode 100644 libcore/support/src/test/java/tests/resources/morestuff/hyts_patch2.jar delete mode 100644 libcore/support/src/test/java/tests/resources/net/InvalidJar.jar delete mode 100644 libcore/support/src/test/java/tests/resources/net/TestCodeSigners.jar delete mode 100644 libcore/support/src/test/java/tests/resources/net/lf.jar delete mode 100644 libcore/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource.properties delete mode 100644 libcore/support/src/test/java/tests/resources/test.cert delete mode 100644 libcore/support/src/test/java/tests/support/Support_ASimpleInputStream.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_ASimpleOutputStream.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_ASimpleReader.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_ASimpleWriter.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_BitSet.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_ClassLoader.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_CollectionTest.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_Configuration.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_DecimalFormat.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_DeleteOnExitTest.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_Exec.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_Field.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_Format.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_GetLocal.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_GetPutFields.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_GetPutFieldsDefaulted.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_GetPutFieldsDeprecated.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_GetResource.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_HttpConstants.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_IOTestSecurityManager.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_ListTest.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_Locale.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_MapTest2.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_MessageFormat.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_NetworkInterface.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_OutputStream.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_PlatformFile.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_PortManager.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_ProviderTrust.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_Proxy_I1.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_Proxy_I2.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_Proxy_ParentException.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_Proxy_SubException.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_SetTest.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_SimpleDateFormat.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_StringReader.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_StringWriter.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_TestProvider.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_TestResource.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_TestResource_en.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_TestResource_en_US.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_TestResource_fr.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_TestResource_fr_FR.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_TestResource_fr_FR_VAR.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_TestWebData.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_TestWebServer.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_TimeZone.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_UnmodifiableCollectionTest.java delete mode 100644 libcore/support/src/test/java/tests/support/Support_UnmodifiableMapTest.java delete mode 100644 libcore/support/src/test/java/tests/support/resource/Support_Resources.java delete mode 100644 libcore/support/src/test/java/tests/util/CallVerificationStack.java delete mode 100644 libcore/support/src/test/java/tests/util/FieldTestFileGenerator.java delete mode 100644 libcore/support/src/test/java/tests/util/PrefsTester.java delete mode 100644 libcore/support/src/test/java/tests/util/SerializationTester.java delete mode 100644 libcore/support/src/test/resources/hyts_Foo.c delete mode 100644 libcore/text/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/text/src/main/java/java/text/Annotation.java delete mode 100644 libcore/text/src/main/java/java/text/AttributedCharacterIterator.java delete mode 100644 libcore/text/src/main/java/java/text/AttributedString.java delete mode 100644 libcore/text/src/main/java/java/text/Bidi.java delete mode 100644 libcore/text/src/main/java/java/text/BreakIterator.java delete mode 100644 libcore/text/src/main/java/java/text/CharacterIterator.java delete mode 100644 libcore/text/src/main/java/java/text/ChoiceFormat.java delete mode 100644 libcore/text/src/main/java/java/text/CollationElementIterator.java delete mode 100644 libcore/text/src/main/java/java/text/CollationKey.java delete mode 100644 libcore/text/src/main/java/java/text/Collator.java delete mode 100644 libcore/text/src/main/java/java/text/DateFormat.java delete mode 100644 libcore/text/src/main/java/java/text/DateFormatSymbols.java delete mode 100644 libcore/text/src/main/java/java/text/DecimalFormat.java delete mode 100644 libcore/text/src/main/java/java/text/DecimalFormatSymbols.java delete mode 100644 libcore/text/src/main/java/java/text/FieldPosition.java delete mode 100644 libcore/text/src/main/java/java/text/Format.java delete mode 100644 libcore/text/src/main/java/java/text/MessageFormat.java delete mode 100644 libcore/text/src/main/java/java/text/NumberFormat.java delete mode 100644 libcore/text/src/main/java/java/text/ParseException.java delete mode 100644 libcore/text/src/main/java/java/text/ParsePosition.java delete mode 100644 libcore/text/src/main/java/java/text/RuleBasedBreakIterator.java delete mode 100644 libcore/text/src/main/java/java/text/RuleBasedCollator.java delete mode 100644 libcore/text/src/main/java/java/text/SimpleDateFormat.java delete mode 100644 libcore/text/src/main/java/java/text/StringCharacterIterator.java delete mode 100644 libcore/text/src/main/java/java/text/package.html delete mode 100644 libcore/text/src/main/java/org/apache/harmony/text/BidiRun.java delete mode 100644 libcore/text/src/main/java/org/apache/harmony/text/BidiWrapper.java delete mode 100644 libcore/text/src/main/java/org/apache/harmony/text/internal/nls/Messages.java delete mode 100644 libcore/text/src/main/java/org/apache/harmony/text/internal/nls/messages.properties delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/AllTests.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/AnnotationTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedCharacterIteratorAttributeTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedCharacterIteratorTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedStringTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/BreakIteratorTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/ChoiceFormatTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/CollationElementIteratorTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/CollationKeyTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/CollatorTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DataFormatFieldTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatSymbolsTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTestICU.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/FieldPositionTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/FormatFieldTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/FormatTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/MessageFormatFieldTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/MessageFormatTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatFieldTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/ParseExceptionTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/ParsePositionTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/SimpleDateFormatTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/StringCharacterIteratorTest.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/Support_DecimalFormat.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/Support_Format.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/Support_MessageFormat.java delete mode 100644 libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/Support_SimpleDateFormat.java delete mode 100644 libcore/text/src/test/java/tests/text/AllTests.java delete mode 100644 libcore/text/src/test/resources/serialization/java/text/DecimalFormat.ser delete mode 100644 libcore/text/src/test/resources/serialization/java/text/DecimalFormatSymbols.ser delete mode 100644 libcore/tools/integrate/Android.mk delete mode 100644 libcore/tools/integrate/Command.java delete mode 100644 libcore/tools/integrate/Filesystem.java delete mode 100644 libcore/tools/integrate/Git.java delete mode 100644 libcore/tools/integrate/MappedDirectory.java delete mode 100644 libcore/tools/integrate/Module.java delete mode 100644 libcore/tools/integrate/Modules.java delete mode 100644 libcore/tools/integrate/PullHarmonyCode.java delete mode 100644 libcore/tools/integrate/Svn.java delete mode 100644 libcore/x-net/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/x-net/src/main/java/javax/net/DefaultServerSocketFactory.java delete mode 100644 libcore/x-net/src/main/java/javax/net/DefaultSocketFactory.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ServerSocketFactory.java delete mode 100644 libcore/x-net/src/main/java/javax/net/SocketFactory.java delete mode 100644 libcore/x-net/src/main/java/javax/net/package.html delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/CertPathTrustManagerParameters.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/DefaultHostnameVerifier.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/DefaultSSLContext.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/DefaultSSLServerSocketFactory.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/DefaultSSLSocketFactory.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/HandshakeCompletedEvent.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/HandshakeCompletedListener.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/HostnameVerifier.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/HttpsURLConnection.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/KeyManager.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/KeyManagerFactory.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/KeyManagerFactorySpi.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/KeyStoreBuilderParameters.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/ManagerFactoryParameters.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/SSLContext.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/SSLContextSpi.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/SSLEngine.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/SSLEngineResult.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/SSLException.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/SSLHandshakeException.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/SSLKeyException.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/SSLPeerUnverifiedException.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/SSLPermission.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/SSLProtocolException.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/SSLServerSocket.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/SSLServerSocketFactory.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/SSLSession.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/SSLSessionBindingEvent.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/SSLSessionBindingListener.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/SSLSessionContext.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/SSLSocket.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/SSLSocketFactory.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/TrustManager.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/TrustManagerFactory.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/TrustManagerFactorySpi.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/X509ExtendedKeyManager.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/X509KeyManager.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/X509TrustManager.java delete mode 100644 libcore/x-net/src/main/java/javax/net/ssl/package.html delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/internal/nls/Messages.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/internal/nls/messages.properties delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/AbstractSessionContext.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/AlertException.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/AlertProtocol.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/Appendable.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/CertificateMessage.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/CertificateRequest.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/CertificateVerify.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/CipherSuite.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/ClientHandshakeImpl.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/ClientHello.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/ClientKeyExchange.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/ClientSessionContext.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/ConnectionState.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/ConnectionStateSSLv3.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/ConnectionStateTLS.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/ContentType.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/DHParameters.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/DataStream.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/DelegatedTask.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/DigitalSignature.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/EndOfBufferException.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/EndOfSourceException.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/FileClientSessionCache.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/Finished.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/Handshake.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/HandshakeIODataStream.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/HandshakeProtocol.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/HelloRequest.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/JSSEProvider.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/KeyManagerFactoryImpl.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/KeyManagerImpl.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/Logger.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/Message.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/NativeCrypto.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLMessageDigest.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLMessageDigestJDK.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLServerSocketFactoryImpl.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLServerSocketImpl.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSessionImpl.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSignature.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketFactoryImpl.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImplWrapper.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/PRF.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/ProtocolVersion.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLBufferedInput.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLClientSessionCache.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLContextImpl.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLEngineAppData.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLEngineDataStream.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLEngineImpl.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLInputStream.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLParameters.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLRecordProtocol.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLServerSessionCache.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSessionImpl.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLStreamedInput.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLv3Constants.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/ServerHandshakeImpl.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/ServerHello.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/ServerHelloDone.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/ServerKeyExchange.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/ServerSessionContext.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/TrustManagerFactoryImpl.java delete mode 100644 libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/TrustManagerImpl.java delete mode 100644 libcore/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp delete mode 100644 libcore/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLServerSocketImpl.cpp delete mode 100644 libcore/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSessionImpl.cpp delete mode 100644 libcore/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSocketImpl.cpp delete mode 100644 libcore/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_common.h delete mode 100644 libcore/x-net/src/main/native/sub.mk delete mode 100644 libcore/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientSessionContextTest.java delete mode 100644 libcore/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/FakeSession.java delete mode 100644 libcore/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/FileClientSessionCacheTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/AllTests.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ServerSocketFactoryTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/SocketFactoryTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/AllTests.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/CertPathTrustManagerParametersTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/CertificatesToPlayWith.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/HandshakeCompletedEventTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/HostnameVerifierTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/HttpsURLConnectionTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/KeyManagerFactory1Test.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/KeyManagerFactory2Test.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/KeyManagerFactorySpiTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/KeyStoreBuilderParametersTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLContext1Test.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLContext2Test.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLContextSpiTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLEngineResultHandshakeStatusTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLEngineResultStatusTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLEngineResultTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLEngineTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLExceptionTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLHandshakeExceptionTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLKeyExceptionTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLPeerUnverifiedExceptionTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLPermissionTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLProtocolExceptionTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLServerSocketFactoryTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLServerSocketTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLSessionBindingEventTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLSessionBindingListenerTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLSessionContextTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLSessionTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLSocketFactoryTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLSocketTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/TrustManagerFactory1Test.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/TrustManagerFactory2Test.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/TrustManagerFactorySpiTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/X509ExtendedKeyManagerTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/X509KeyManagerTest.java delete mode 100644 libcore/x-net/src/test/java/tests/api/javax/net/ssl/X509TrustManagerTest.java delete mode 100644 libcore/x-net/src/test/java/tests/xnet/AllTests.java delete mode 100644 libcore/xml/MODULE_LICENSE_APACHE2 delete mode 100644 libcore/xml/MODULE_LICENSE_BSD_LIKE delete mode 100644 libcore/xml/MODULE_LICENSE_W3C delete mode 100644 libcore/xml/src/main/java/javax/xml/XMLConstants.java delete mode 100644 libcore/xml/src/main/java/javax/xml/package.html delete mode 100644 libcore/xml/src/main/java/javax/xml/parsers/DocumentBuilder.java delete mode 100644 libcore/xml/src/main/java/javax/xml/parsers/DocumentBuilderFactory.java delete mode 100644 libcore/xml/src/main/java/javax/xml/parsers/FactoryConfigurationError.java delete mode 100644 libcore/xml/src/main/java/javax/xml/parsers/ParserConfigurationException.java delete mode 100644 libcore/xml/src/main/java/javax/xml/parsers/SAXParser.java delete mode 100644 libcore/xml/src/main/java/javax/xml/parsers/SAXParserFactory.java delete mode 100644 libcore/xml/src/main/java/javax/xml/parsers/package.html delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/ExpatAttributes.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/ExpatException.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/ExpatParser.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/ExpatPullParser.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/ExpatReader.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/dom/AttrImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/dom/CDATASectionImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/dom/CharacterDataImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/dom/CommentImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/dom/DOMImplementationImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/dom/DocumentFragmentImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/dom/DocumentImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/dom/DocumentTypeImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/dom/ElementImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/dom/EntityImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/dom/EntityReferenceImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/dom/InnerNodeImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/dom/LeafNodeImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/dom/NamedNodeMapImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/dom/NodeImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/dom/NodeListImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/dom/NotationImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/dom/ProcessingInstructionImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/dom/TextImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/parsers/DocumentBuilderFactoryImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/parsers/DocumentBuilderImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/parsers/SAXParserFactoryImpl.java delete mode 100644 libcore/xml/src/main/java/org/apache/harmony/xml/parsers/SAXParserImpl.java delete mode 100644 libcore/xml/src/main/java/org/kxml2/io/KXmlParser.java delete mode 100644 libcore/xml/src/main/java/org/kxml2/io/KXmlSerializer.java delete mode 100644 libcore/xml/src/main/java/org/kxml2/kdom/Document.java delete mode 100644 libcore/xml/src/main/java/org/kxml2/kdom/Element.java delete mode 100644 libcore/xml/src/main/java/org/kxml2/kdom/Node.java delete mode 100644 libcore/xml/src/main/java/org/kxml2/wap/Wbxml.java delete mode 100644 libcore/xml/src/main/java/org/kxml2/wap/WbxmlParser.java delete mode 100644 libcore/xml/src/main/java/org/kxml2/wap/WbxmlSerializer.java delete mode 100644 libcore/xml/src/main/java/org/kxml2/wap/syncml/SyncML.java delete mode 100644 libcore/xml/src/main/java/org/kxml2/wap/wml/Wml.java delete mode 100644 libcore/xml/src/main/java/org/kxml2/wap/wv/WV.java delete mode 100644 libcore/xml/src/main/java/org/w3c/dom/Attr.java delete mode 100644 libcore/xml/src/main/java/org/w3c/dom/CDATASection.java delete mode 100644 libcore/xml/src/main/java/org/w3c/dom/CharacterData.java delete mode 100644 libcore/xml/src/main/java/org/w3c/dom/Comment.java delete mode 100644 libcore/xml/src/main/java/org/w3c/dom/DOMException.java delete mode 100644 libcore/xml/src/main/java/org/w3c/dom/DOMImplementation.java delete mode 100644 libcore/xml/src/main/java/org/w3c/dom/Document.java delete mode 100644 libcore/xml/src/main/java/org/w3c/dom/DocumentFragment.java delete mode 100644 libcore/xml/src/main/java/org/w3c/dom/DocumentType.java delete mode 100644 libcore/xml/src/main/java/org/w3c/dom/Element.java delete mode 100644 libcore/xml/src/main/java/org/w3c/dom/Entity.java delete mode 100644 libcore/xml/src/main/java/org/w3c/dom/EntityReference.java delete mode 100644 libcore/xml/src/main/java/org/w3c/dom/NamedNodeMap.java delete mode 100644 libcore/xml/src/main/java/org/w3c/dom/Node.java delete mode 100644 libcore/xml/src/main/java/org/w3c/dom/NodeList.java delete mode 100644 libcore/xml/src/main/java/org/w3c/dom/Notation.java delete mode 100644 libcore/xml/src/main/java/org/w3c/dom/ProcessingInstruction.java delete mode 100644 libcore/xml/src/main/java/org/w3c/dom/Text.java delete mode 100644 libcore/xml/src/main/java/org/w3c/dom/package.html delete mode 100644 libcore/xml/src/main/java/org/xml/sax/AttributeList.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/Attributes.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/ContentHandler.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/DTDHandler.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/DocumentHandler.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/EntityResolver.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/ErrorHandler.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/HandlerBase.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/InputSource.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/Locator.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/Parser.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/SAXException.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/SAXNotRecognizedException.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/SAXNotSupportedException.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/SAXParseException.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/XMLFilter.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/XMLReader.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/ext/Attributes2.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/ext/Attributes2Impl.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/ext/DeclHandler.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/ext/DefaultHandler2.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/ext/EntityResolver2.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/ext/LexicalHandler.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/ext/Locator2.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/ext/Locator2Impl.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/ext/package.html delete mode 100644 libcore/xml/src/main/java/org/xml/sax/helpers/AttributeListImpl.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/helpers/AttributesImpl.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/helpers/DefaultHandler.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/helpers/LocatorImpl.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/helpers/NamespaceSupport.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/helpers/NewInstance.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/helpers/ParserAdapter.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/helpers/ParserFactory.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/helpers/XMLFilterImpl.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/helpers/XMLReaderAdapter.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/helpers/XMLReaderFactory.java delete mode 100644 libcore/xml/src/main/java/org/xml/sax/helpers/package.html delete mode 100644 libcore/xml/src/main/java/org/xml/sax/package.html delete mode 100644 libcore/xml/src/main/java/org/xmlpull/v1/XmlPullParser.java delete mode 100644 libcore/xml/src/main/java/org/xmlpull/v1/XmlPullParserException.java delete mode 100644 libcore/xml/src/main/java/org/xmlpull/v1/XmlPullParserFactory.java delete mode 100644 libcore/xml/src/main/java/org/xmlpull/v1/XmlSerializer.java delete mode 100644 libcore/xml/src/main/java/org/xmlpull/v1/sax2/Driver.java delete mode 100644 libcore/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp delete mode 100644 libcore/xml/src/main/native/sub.mk delete mode 100644 libcore/xml/src/test/java/org/apache/harmony/xml/ExpatParserTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/javax/xml/parsers/AllTests.java delete mode 100644 libcore/xml/src/test/java/tests/api/javax/xml/parsers/DocumentBuilderFactoryTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/javax/xml/parsers/DocumentBuilderTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/javax/xml/parsers/FactoryConfigurationErrorTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/javax/xml/parsers/ParserConfigurationExceptionTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/javax/xml/parsers/SAXParserFactoryTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/javax/xml/parsers/SAXParserTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/javax/xml/parsers/SAXParserTestSupport.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/AllTests.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/HandlerBaseTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/InputSourceTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/SAXExceptionTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/SAXNotRecognizedExceptionTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/SAXNotSupportedExceptionTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/SAXParseExceptionTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/ext/AllTests.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/ext/Attributes2ImplTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/ext/DefaultHandler2Test.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/ext/Locator2ImplTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/helpers/AllTests.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/helpers/AttributeListImplTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/helpers/AttributesImplTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/helpers/DefaultHandlerTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/helpers/LocatorImplTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/helpers/NamespaceSupportTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/helpers/ParserAdapterTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/helpers/ParserFactoryTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/helpers/XMLFilterImplTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/helpers/XMLReaderAdapterTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/helpers/XMLReaderFactoryTest.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/support/BrokenInputStream.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/support/DoNothingParser.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/support/DoNothingXMLReader.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/support/MethodLogger.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/support/MockFilter.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/support/MockHandler.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/support/MockParser.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/support/MockReader.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/support/MockResolver.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/support/NoAccessParser.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/support/NoAccessXMLReader.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/support/NoInstanceParser.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/support/NoInstanceXMLReader.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/support/NoSubclassParser.java delete mode 100644 libcore/xml/src/test/java/tests/api/org/xml/sax/support/NoSubclassXMLReader.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/AllTests.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/AttrGetOwnerElement.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/CreateAttributeNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/CreateDocument.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/CreateDocumentType.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/CreateElementNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/DOMDocumentBuilderFactory.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/DOMImplementationCreateDocument.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/DOMImplementationCreateDocumentType.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/DOMImplementationHasFeature.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/DOMTestCase.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/DocumentBuilderSetting.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/DocumentBuilderSettingStrategy.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/DocumentCreateAttributeNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/DocumentCreateElementNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/DocumentGetElementsByTagnameNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/DocumentGeteEementById.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/DocumentImportNode.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/DocumentTypeInternalSubset.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/DocumentTypePublicId.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/DocumentTypeSystemId.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/ElementGetAttributeNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/ElementGetAttributeNodeNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/ElementGetElementsByTagNameNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/ElementHasAttribute.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/ElementHasAttributeNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/ElementRemoveAttributeNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/ElementSetAttributeNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/ElementSetAttributeNodeNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/GetAttributeNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/GetAttributeNodeNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/GetElementById.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/GetElementsByTagNameNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/GetNamedItemNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/HCEntitiesRemoveNamedItemNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/HCEntitiesSetNamedItemNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/HCNamedNodeMapInvalidType.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/HCNodeDocumentFragmentNormalize.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/HCNotationsRemoveNamedItemNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/HCNotationsSetNamedItemNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/HasAttribute.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/HasAttributeNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/HasAttributes.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/ImportNode.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/InternalSubset.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/IsSupported.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/LocalName.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/NamedNodeMapGetNamedItemNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/NamedNodeMapRemoveNamedItemNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/NamedNodeMapSetNamedItemNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/NamespaceURI.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/NodeGetLocalName.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/NodeGetNamespaceURI.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/NodeGetOwnerDocument.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/NodeGetPrefix.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/NodeHasAttributes.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/NodeIsSupported.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/NodeNormalize.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/NodeSetPrefix.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/Normalize.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/OwnerDocument.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/OwnerElement.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/Prefix.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/PublicId.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/RemoveAttributeNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/RemoveNamedItemNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/SetAttributeNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/SetAttributeNodeNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/SetNamedItemNS.java delete mode 100644 libcore/xml/src/test/java/tests/org/w3c/dom/SystemId.java delete mode 100644 libcore/xml/src/test/java/tests/xml/AllTests.java delete mode 100644 libcore/xml/src/test/java/tests/xml/SimpleBuilderTest.java delete mode 100644 libcore/xml/src/test/java/tests/xml/SimpleParserTest.java delete mode 100644 libcore/xml/src/test/resources/SimpleBuilderTest.xml delete mode 100644 libcore/xml/src/test/resources/SimpleParserTest.xml delete mode 100644 libcore/xml/src/test/resources/hc_staff.xml delete mode 100644 libcore/xml/src/test/resources/nwf/staff.dtd delete mode 100644 libcore/xml/src/test/resources/nwf/staff.xml delete mode 100644 libcore/xml/src/test/resources/out_dh/staff.out delete mode 100644 libcore/xml/src/test/resources/out_hb/staff.out delete mode 100644 libcore/xml/src/test/resources/recipe.xml delete mode 100644 libcore/xml/src/test/resources/recipe1.xml delete mode 100644 libcore/xml/src/test/resources/recipt.dtd delete mode 100644 libcore/xml/src/test/resources/recipt.xml delete mode 100644 libcore/xml/src/test/resources/reciptWrong.xml delete mode 100644 libcore/xml/src/test/resources/simple.xml delete mode 100644 libcore/xml/src/test/resources/simple_ns.dtd delete mode 100644 libcore/xml/src/test/resources/simple_ns.xml delete mode 100644 libcore/xml/src/test/resources/staff.dtd delete mode 100644 libcore/xml/src/test/resources/staff.xml delete mode 100644 libcore/xml/src/test/resources/staff2.dtd delete mode 100644 libcore/xml/src/test/resources/staff2.xml delete mode 100644 libcore/xml/src/test/resources/staffEntRes.xml delete mode 100644 libcore/xml/src/test/resources/staffNS.dtd delete mode 100644 libcore/xml/src/test/resources/staffNS.xml delete mode 100644 libcore/xml/src/test/resources/systemid.xml delete mode 100644 libcore/xml/src/test/resources/systemid/recipt.dtd delete mode 100644 libcore/xml/src/test/resources/systemid/staff.dtd delete mode 100644 libcore/xml/src/test/resources/wf/staff.dtd delete mode 100644 libcore/xml/src/test/resources/wf/staff.xml delete mode 100644 libcore/xml/src/test/resources/wrong.xml delete mode 100644 libcore/xml/src/test/resources/xhtml1-strict.dtd diff --git a/libcore/Android.mk b/libcore/Android.mk deleted file mode 100644 index 7de73be1b..000000000 --- a/libcore/Android.mk +++ /dev/null @@ -1,163 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -# The core library is divided into modules. Each module has a separate Java -# source directory, and some (hopefully eventually all) also have a directory -# for tests. The two sections below define separate targets to build the -# core and the associated tests. - -define all-core-java-files -$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find */src/$(1)/java -name "*.java")) -endef - -# Redirect ls stderr to /dev/null because the corresponding resources -# directory doesn't always exist. -define all-core-resource-dirs -$(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/{java,resources} 2> /dev/null) -endef - -LOCAL_SRC_FILES := $(call all-core-java-files,main) -LOCAL_JAVA_RESOURCE_DIRS := $(call all-core-resource-dirs,main) - -LOCAL_NO_STANDARD_LIBRARIES := true -LOCAL_DX_FLAGS := --core-library - -LOCAL_NO_EMMA_INSTRUMENT := true -LOCAL_NO_EMMA_COMPILE := true - -LOCAL_MODULE := core - -include $(BUILD_JAVA_LIBRARY) - -core-intermediates := ${intermediates} - -# Definitions to make the core-tests library. - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := $(call all-core-java-files,test) -LOCAL_JAVA_RESOURCE_DIRS := $(call all-core-resource-dirs,test) - -LOCAL_NO_STANDARD_LIBRARIES := true -LOCAL_JAVA_LIBRARIES := core -LOCAL_DX_FLAGS := --core-library - -LOCAL_MODULE_TAGS := tests -LOCAL_MODULE := core-tests - -include $(BUILD_JAVA_LIBRARY) - -# This one's tricky. One of our tests needs to have a -# resource with a "#" in its name, but Perforce doesn't -# allow us to submit such a file. So we create it here -# on-the-fly. -TMP_RESOURCE_DIR := $(OUT_DIR)/tmp/ -TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties - -$(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE): - @mkdir -p $(dir $@) - @echo "Hello, world!" > $@ - -$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C $(TMP_RESOURCE_DIR) $(TMP_RESOURCE_FILE) -$(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE) - -# Definitions for building a version of the core-tests.jar -# that is suitable for execution on the RI. This JAR would -# be better located in $HOST_OUT_JAVA_LIBRARIES, but it is -# not possible to refer to that from a shell script (the -# variable is not exported from envsetup.sh). There is also -# some trickery involved: we need to include some classes -# that reside in core.jar, but since we cannot incldue the -# whole core.jar in the RI classpath, we copy those classses -# over to our new file. -HOST_CORE_JAR := $(HOST_COMMON_OUT_ROOT)/core-tests.jar - -$(HOST_CORE_JAR): PRIVATE_LOCAL_BUILT_MODULE := $(LOCAL_BUILT_MODULE) -$(HOST_CORE_JAR): PRIVATE_CORE_INTERMEDIATES := $(core-intermediates) -$(HOST_CORE_JAR): $(LOCAL_BUILT_MODULE) - @rm -rf $(dir $<)/hostctsclasses - $(call unzip-jar-files,$(dir $<)classes.jar,$(dir $<)hostctsclasses) - @unzip -qx -o $(PRIVATE_CORE_INTERMEDIATES)/classes.jar dalvik/annotation/* -d $(dir $<)hostctsclasses - @cp $< $@ - @jar uf $@ -C $(dir $<)hostctsclasses . - -$(LOCAL_INSTALLED_MODULE): $(HOST_CORE_JAR) - -$(LOCAL_INSTALLED_MODULE): run-core-tests - -# Definitions to copy the core-tests runner script. - -include $(CLEAR_VARS) -LOCAL_SRC_FILES := run-core-tests -LOCAL_MODULE_CLASS := EXECUTABLES -LOCAL_MODULE_TAGS := tests -LOCAL_MODULE := run-core-tests -include $(BUILD_PREBUILT) - -include $(CLEAR_VARS) -LOCAL_SRC_FILES := run-core-tests-on-ri -LOCAL_IS_HOST_MODULE := true -LOCAL_MODULE_CLASS := EXECUTABLES -LOCAL_MODULE_TAGS := tests -LOCAL_MODULE := run-core-tests-on-ri -include $(BUILD_PREBUILT) - -# Build all of the native code, if any is present. - -include $(CLEAR_VARS) - -# Get the list of all native directories that contain sub.mk files. -# We're using "sub.mk" to make it clear that these are not typical -# android makefiles. -define all-core-native-dirs -$(patsubst %/sub.mk,%,$(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/native/sub.mk 2> /dev/null)) -endef - -core_magic_local_target := ...//::default:://... -core_local_path := $(LOCAL_PATH) - -# Include a submakefile, resolve its source file locations, -# and stick them on core_src_files. The submakefiles are -# free to append to LOCAL_C_INCLUDES, LOCAL_SHARED_LIBRARIES, etc. -# -# $(1): directory containing the makefile to include -define include-core-native-dir - LOCAL_SRC_FILES := - include $(LOCAL_PATH)/$(1)/sub.mk - ifneq ($$(LOCAL_MODULE),$(core_magic_local_target)) - $$(error $(LOCAL_PATH)/$(1)/sub.mk should not include CLEAR_VARS \ - or define LOCAL_MODULE) - endif - ifneq ($$(LOCAL_PATH),$(core_local_path)) - $$(error $(LOCAL_PATH)/$(1)/sub.mk should not define LOCAL_PATH) - endif - core_src_files += $$(addprefix $(1)/,$$(LOCAL_SRC_FILES)) - LOCAL_SRC_FILES := -endef - -# Find any native directories containing sub.mk files. -core_native_dirs := $(strip $(call all-core-native-dirs,main)) -ifeq ($(core_native_dirs),) - $(error No native code defined for libcore) -endif - -# Set up the default state. -LOCAL_C_INCLUDES += $(JNI_H_INCLUDE) -LOCAL_MODULE := $(core_magic_local_target) -core_src_files := - -# Include the sub.mk files. -$(foreach dir, \ - $(core_native_dirs), \ - $(eval $(call include-core-native-dir,$(dir)))) - -# Define the rules. -LOCAL_SRC_FILES := $(core_src_files) -LOCAL_MODULE := libjavacore -include $(BUILD_STATIC_LIBRARY) - -# Deal with keystores required for security. Note: The path to this file -# is hardcoded in TrustManagerFactoryImpl.java. -ALL_PREBUILT += $(TARGET_OUT)/etc/security/cacerts.bks -$(TARGET_OUT)/etc/security/cacerts.bks : $(LOCAL_PATH)/security/src/main/files/cacerts.bks | $(ACP) - $(transform-prebuilt-to-target) diff --git a/libcore/AndroidManifest.xml b/libcore/AndroidManifest.xml deleted file mode 100644 index e5321b7c1..000000000 --- a/libcore/AndroidManifest.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/libcore/NOTICE b/libcore/NOTICE deleted file mode 100644 index f51da455a..000000000 --- a/libcore/NOTICE +++ /dev/null @@ -1,437 +0,0 @@ - ========================================================================= - == NOTICE file corresponding to the section 4 d of == - == the Apache License, Version 2.0, == - == in this case for the Android-specific code. == - ========================================================================= - -Android Code -Copyright 2005-2008 The Android Open Source Project - -This product includes software developed as part of -The Android Open Source Project (http://source.android.com). - - ========================================================================= - == NOTICE file corresponding to the section 4 d of == - == the Apache License, Version 2.0, == - == in this case for the Apache Harmony distribution. == - ========================================================================= - -Apache Harmony -Copyright 2006 The Apache Software Foundation - -This product includes software developed at -The Apache Software Foundation (http://www.apache.org/). - -Portions of Harmony were originally developed by -Intel Corporation and are licensed to the Apache Software -Foundation under the "Software Grant and Corporate Contribution -License Agreement", informally known as the "Intel Harmony CLA". - - - ========================================================================= - == NOTICE file for the Bouncy Castle License. == - ========================================================================= - -Copyright (c) 2000 - 2006 The Legion Of The Bouncy Castle -(http://www.bouncycastle.org) - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - ========================================================================= - == NOTICE file for the ICU License. == - ========================================================================= - -Copyright (c) 1995-2006 International Business Machines Corporation and others - -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, and/or sell copies of the Software, and to permit persons -to whom the Software is furnished to do so, provided that the above -copyright notice(s) and this permission notice appear in all copies of -the Software and that both the above copyright notice(s) and this -permission notice appear in supporting documentation. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY -SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER -RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF -CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -Except as contained in this notice, the name of a copyright holder -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -of the copyright holder. - -All trademarks and registered trademarks mentioned herein are the -property of their respective owners. - - - ========================================================================= - == NOTICE file for the JSON License. == - ========================================================================= - -Copyright (c) 2002 JSON.org - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -The Software shall be used for Good, not Evil. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - ========================================================================= - == NOTICE file for the JUnit License. == - ========================================================================= - -Common Public License - v 1.0 - -THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON -PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF -THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. - -1. DEFINITIONS - -"Contribution" means: - - a) in the case of the initial Contributor, the initial code and - documentation distributed under this Agreement, and - b) in the case of each subsequent Contributor: - - i) changes to the Program, and - - ii) additions to the Program; - - where such changes and/or additions to the Program originate - from and are distributed by that particular Contributor. A - Contribution 'originates' from a Contributor if it was added to - the Program by such Contributor itself or anyone acting on such - Contributor's behalf. Contributions do not include additions to - the Program which: (i) are separate modules of software - distributed in conjunction with the Program under their own - license agreement, and (ii) are not derivative works of the - Program. - -"Contributor" means any person or entity that distributes the Program. - -"Licensed Patents " mean patent claims licensable by a Contributor -which are necessarily infringed by the use or sale of its Contribution -alone or when combined with the Program. - -"Program" means the Contributions distributed in accordance with this -Agreement. - -"Recipient" means anyone who receives the Program under this -Agreement, including all Contributors. - -2. GRANT OF RIGHTS - - a) Subject to the terms of this Agreement, each Contributor - hereby grants Recipient a non-exclusive, worldwide, royalty-free - copyright license to reproduce, prepare derivative works of, - publicly display, publicly perform, distribute and sublicense - the Contribution of such Contributor, if any, and such - derivative works, in source code and object code form. - - b) Subject to the terms of this Agreement, each Contributor - hereby grants Recipient a non-exclusive, worldwide, royalty-free - patent license under Licensed Patents to make, use, sell, offer - to sell, import and otherwise transfer the Contribution of such - Contributor, if any, in source code and object code form. This - patent license shall apply to the combination of the - Contribution and the Program if, at the time the Contribution is - added by the Contributor, such addition of the Contribution - causes such combination to be covered by the Licensed Patents. - The patent license shall not apply to any other combinations - which include the Contribution. No hardware per se is licensed - hereunder. - - c) Recipient understands that although each Contributor grants - the licenses to its Contributions set forth herein, no - assurances are provided by any Contributor that the Program does - not infringe the patent or other intellectual property rights of - any other entity. Each Contributor disclaims any liability to - Recipient for claims brought by any other entity based on - infringement of intellectual property rights or otherwise. As a - condition to exercising the rights and licenses granted - hereunder, each Recipient hereby assumes sole responsibility to - secure any other intellectual property rights needed, if any. - For example, if a third party patent license is required to - allow Recipient to distribute the Program, it is Recipient's - responsibility to acquire that license before distributing the - Program. - - d) Each Contributor represents that to its knowledge it has - sufficient copyright rights in its Contribution, if any, to - grant the copyright license set forth in this Agreement. - -3. REQUIREMENTS - -A Contributor may choose to distribute the Program in object code form -under its own license agreement, provided that: - - a) it complies with the terms and conditions of this Agreement; and - - b) its license agreement: - - i) effectively disclaims on behalf of all Contributors all - warranties and conditions, express and implied, including - warranties or conditions of title and non-infringement, and - implied warranties or conditions of merchantability and fitness - for a particular purpose; - - ii) effectively excludes on behalf of all Contributors all - liability for damages, including direct, indirect, special, - incidental and consequential damages, such as lost profits; - - iii) states that any provisions which differ from this Agreement - are offered by that Contributor alone and not by any other - party; and - - iv) states that source code for the Program is available from - such Contributor, and informs licensees how to obtain it in a - reasonable manner on or through a medium customarily used for - software exchange. - -When the Program is made available in source code form: - - a) it must be made available under this Agreement; and - - b) a copy of this Agreement must be included with each copy of - the Program. - -Contributors may not remove or alter any copyright notices contained -within the Program. - -Each Contributor must identify itself as the originator of its -Contribution, if any, in a manner that reasonably allows subsequent -Recipients to identify the originator of the Contribution. - -4. COMMERCIAL DISTRIBUTION - -Commercial distributors of software may accept certain -responsibilities with respect to end users, business partners and the -like. While this license is intended to facilitate the commercial use -of the Program, the Contributor who includes the Program in a -commercial product offering should do so in a manner which does not -create potential liability for other Contributors. Therefore, if a -Contributor includes the Program in a commercial product offering, -such Contributor ("Commercial Contributor") hereby agrees to defend -and indemnify every other Contributor ("Indemnified Contributor") -against any losses, damages and costs (collectively "Losses") arising -from claims, lawsuits and other legal actions brought by a third party -against the Indemnified Contributor to the extent caused by the acts -or omissions of such Commercial Contributor in connection with its -distribution of the Program in a commercial product offering. The -obligations in this section do not apply to any claims or Losses -relating to any actual or alleged intellectual property infringement. -In order to qualify, an Indemnified Contributor must: a) promptly -notify the Commercial Contributor in writing of such claim, and b) -allow the Commercial Contributor to control, and cooperate with the -Commercial Contributor in, the defense and any related settlement -negotiations. The Indemnified Contributor may participate in any such -claim at its own expense. - -For example, a Contributor might include the Program in a commercial -product offering, Product X. That Contributor is then a Commercial -Contributor. If that Commercial Contributor then makes performance -claims, or offers warranties related to Product X, those performance -claims and warranties are such Commercial Contributor's responsibility -alone. Under this section, the Commercial Contributor would have to -defend claims against the other Contributors related to those -performance claims and warranties, and if a court requires any other -Contributor to pay any damages as a result, the Commercial Contributor -must pay those damages. - -5. NO WARRANTY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS -PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY -WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY -OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely -responsible for determining the appropriateness of using and -distributing the Program and assumes all risks associated with its -exercise of rights under this Agreement, including but not limited to -the risks and costs of program errors, compliance with applicable -laws, damage to or loss of data, programs or equipment, and -unavailability or interruption of operations. - -6. DISCLAIMER OF LIABILITY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR -ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING -WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR -DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED -HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -7. GENERAL - -If any provision of this Agreement is invalid or unenforceable under -applicable law, it shall not affect the validity or enforceability of -the remainder of the terms of this Agreement, and without further -action by the parties hereto, such provision shall be reformed to the -minimum extent necessary to make such provision valid and enforceable. - -If Recipient institutes patent litigation against a Contributor with -respect to a patent applicable to software (including a cross-claim or -counterclaim in a lawsuit), then any patent licenses granted by that -Contributor to such Recipient under this Agreement shall terminate as -of the date such litigation is filed. In addition, if Recipient -institutes patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Program -itself (excluding combinations of the Program with other software or -hardware) infringes such Recipient's patent(s), then such Recipient's -rights granted under Section 2(b) shall terminate as of the date such -litigation is filed. - -All Recipient's rights under this Agreement shall terminate if it -fails to comply with any of the material terms or conditions of this -Agreement and does not cure such failure in a reasonable period of -time after becoming aware of such noncompliance. If all Recipient's -rights under this Agreement terminate, Recipient agrees to cease use -and distribution of the Program as soon as reasonably practicable. -However, Recipient's obligations under this Agreement and any licenses -granted by Recipient relating to the Program shall continue and -survive. - -Everyone is permitted to copy and distribute copies of this Agreement, -but in order to avoid inconsistency the Agreement is copyrighted and -may only be modified in the following manner. The Agreement Steward -reserves the right to publish new versions (including revisions) of -this Agreement from time to time. No one other than the Agreement -Steward has the right to modify this Agreement. IBM is the initial -Agreement Steward. IBM may assign the responsibility to serve as the -Agreement Steward to a suitable separate entity. Each new version of -the Agreement will be given a distinguishing version number. The -Program (including Contributions) may always be distributed subject to -the version of the Agreement under which it was received. In addition, -after a new version of the Agreement is published, Contributor may -elect to distribute the Program (including its Contributions) under -the new version. Except as expressly stated in Sections 2(a) and 2(b) -above, Recipient receives no rights or licenses to the intellectual -property of any Contributor under this Agreement, whether expressly, -by implication, estoppel or otherwise. All rights in the Program not -expressly granted under this Agreement are reserved. - -This Agreement is governed by the laws of the State of New York and -the intellectual property laws of the United States of America. No -party to this Agreement will bring a legal action under this Agreement -more than one year after the cause of action arose. Each party waives -its rights to a jury trial in any resulting litigation. - - - ========================================================================= - == NOTICE file for the KXML License. == - ========================================================================= - -Copyright (c) 2002,2003, Stefan Haustein, Oberhausen, Rhld., Germany - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - ========================================================================= - == NOTICE file for the SQLite Java Wrapper License. == - ========================================================================= - -This software is copyrighted by Christian Werner -and others. The following terms apply to all files associated with the -software unless explicitly disclaimed in individual files. - -The authors hereby grant permission to use, copy, modify, distribute, -and license this software and its documentation for any purpose, provided -that existing copyright notices are retained in all copies and that this -notice is included verbatim in any distributions. No written agreement, -license, or royalty fee is required for any of the authorized uses. -Modifications to this software may be copyrighted by their authors -and need not follow the licensing terms described here, provided that -the new terms are clearly indicated on the first page of each file where -they apply. - -IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY -FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES -ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY -DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE -IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE -NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR -MODIFICATIONS. - - - ========================================================================= - == NOTICE file for the W3C License. == - ========================================================================= - -Copyright (c) 2000 World Wide Web Consortium, (Massachusetts Institute -of Technology, Institut National de Recherche en Informatique et en -Automatique, Keio University). All Rights Reserved. This program is -distributed under the W3C's Software Intellectual Property License. -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. diff --git a/libcore/annotation/MODULE_LICENSE_APACHE2 b/libcore/annotation/MODULE_LICENSE_APACHE2 deleted file mode 100644 index e69de29bb..000000000 diff --git a/libcore/annotation/src/main/java/java/lang/annotation/Annotation.java b/libcore/annotation/src/main/java/java/lang/annotation/Annotation.java deleted file mode 100644 index 00707b1d5..000000000 --- a/libcore/annotation/src/main/java/java/lang/annotation/Annotation.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with this - * work for additional information regarding copyright ownership. The ASF - * licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.lang.annotation; - -/** - * Defines the interface implemented by all annotations. Note that the interface - * itself is not an annotation, and neither is an interface that simply - * extends this one. Only the compiler is able to create proper annotation - * types. - * - * @since 1.5 - */ -public interface Annotation { - - /** - * Returns the type of this annotation. - * - * @return A {@code Class} instance representing the annotation type. - */ - Class annotationType(); - - /** - * Determines whether or not this annotation is equivalent to the annotation - * passed. This is determined according to the following rules: - * - * - * - * @param obj - * The object to compare to. - * - * @return {@code true} if {@code obj} is equal to this annotation, - * {@code false} otherwise. - */ - boolean equals(Object obj); - - /** - * Returns the hash code of this annotation. The hash code is determined - * according to the following rules: - * - * - * - * @return the hash code. - */ - int hashCode(); - - /** - * Returns a {@code String} representation of this annotation. It is not - * strictly defined what the representation has to look like, but it usually - * consists of the name of the annotation, preceded by a "@". If the - * annotation contains field members, their names and values are also - * included in the result. - * - * @return the {@code String} that represents this annotation. - */ - String toString(); -} diff --git a/libcore/annotation/src/main/java/java/lang/annotation/AnnotationFormatError.java b/libcore/annotation/src/main/java/java/lang/annotation/AnnotationFormatError.java deleted file mode 100644 index 67775c732..000000000 --- a/libcore/annotation/src/main/java/java/lang/annotation/AnnotationFormatError.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with this - * work for additional information regarding copyright ownership. The ASF - * licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.lang.annotation; - -/** - * Indicates that an annotation in the binary representation of a class is - * syntactically incorrect and the annotation parser is unable to process it. - * This exception is unlikely to ever occur, given that the code has been - * compiled by an ordinary Java compiler. - * - * @since 1.5 - */ -public class AnnotationFormatError extends Error { - - private static final long serialVersionUID = -4256701562333669892L; - - /** - * Constructs an instance with the message provided. - * - * @param message - * the details of the error. - */ - public AnnotationFormatError(String message) { - super(message); - } - - /** - * Constructs an instance with a message and a cause. - * - * @param message - * the details of the error. - * @param cause - * the cause of the error or {@code null} if none. - */ - public AnnotationFormatError(String message, Throwable cause) { - super(message, cause); - } - - /** - * Constructs an instance with a cause. If the cause is not - * {@code null}, then {@code cause.toString()} is used as the - * error's message. - * - * @param cause - * the cause of the error or {@code null} if none. - */ - public AnnotationFormatError(Throwable cause) { - super(cause == null ? null : cause.toString(), cause); - } - -} diff --git a/libcore/annotation/src/main/java/java/lang/annotation/AnnotationTypeMismatchException.java b/libcore/annotation/src/main/java/java/lang/annotation/AnnotationTypeMismatchException.java deleted file mode 100644 index 0ff79ec8f..000000000 --- a/libcore/annotation/src/main/java/java/lang/annotation/AnnotationTypeMismatchException.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with this - * work for additional information regarding copyright ownership. The ASF - * licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.lang.annotation; - -import java.lang.reflect.Method; - -import org.apache.harmony.annotation.internal.nls.Messages; - -/** - * Indicates that an annotation type has changed since it was compiled or - * serialized. - * - * @since 1.5 - */ -public class AnnotationTypeMismatchException extends RuntimeException { - - private static final long serialVersionUID = 8125925355765570191L; - - private Method element; - - private String foundType; - - /** - * Constructs an instance for the given type element and the type found. - * - * @param element - * the annotation type element. - * @param foundType - * the invalid type that was found. This is actually the textual - * type description found in the binary class representation, - * so it may not be human-readable. - */ - public AnnotationTypeMismatchException(Method element, String foundType) { - super(Messages.getString("annotation.1", element, foundType)); //$NON-NLS-1$ - this.element = element; - this.foundType = foundType; - } - - /** - * Returns the method object for the invalid type. - * - * @return a {@link Method} instance. - */ - public Method element() { - return element; - } - - /** - * Returns the invalid type. - * - * @return a string describing the invalid data. - */ - public String foundType() { - return foundType; - } -} diff --git a/libcore/annotation/src/main/java/java/lang/annotation/Documented.java b/libcore/annotation/src/main/java/java/lang/annotation/Documented.java deleted file mode 100644 index 7e7f72f8f..000000000 --- a/libcore/annotation/src/main/java/java/lang/annotation/Documented.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with this - * work for additional information regarding copyright ownership. The ASF - * licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.lang.annotation; - -/** - * Defines a meta-annotation for indicating that an annotation is documented and - * considered part of the public API. - * - * @since 1.5 - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Documented { -} diff --git a/libcore/annotation/src/main/java/java/lang/annotation/ElementType.java b/libcore/annotation/src/main/java/java/lang/annotation/ElementType.java deleted file mode 100644 index f0f52aacf..000000000 --- a/libcore/annotation/src/main/java/java/lang/annotation/ElementType.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with this - * work for additional information regarding copyright ownership. The ASF - * licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.lang.annotation; - -/** - * Defines an enumeration for Java program elements. It is used in conjunction - * with the {@link Target} meta-annotation to restrict the use of an annotation - * to certain program elements. - * - * @since 1.5 - */ -public enum ElementType { - /** - * Class, interface or enum declaration. - */ - TYPE, - /** - * Field declaration. - */ - FIELD, - /** - * Method declaration. - */ - METHOD, - /** - * Parameter declaration. - */ - PARAMETER, - /** - * Constructor declaration. - */ - CONSTRUCTOR, - /** - * Local variable declaration. - */ - LOCAL_VARIABLE, - /** - * Annotation type declaration. - */ - ANNOTATION_TYPE, - /** - * Package declaration. - */ - PACKAGE -} diff --git a/libcore/annotation/src/main/java/java/lang/annotation/IncompleteAnnotationException.java b/libcore/annotation/src/main/java/java/lang/annotation/IncompleteAnnotationException.java deleted file mode 100644 index a5d20688d..000000000 --- a/libcore/annotation/src/main/java/java/lang/annotation/IncompleteAnnotationException.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with this - * work for additional information regarding copyright ownership. The ASF - * licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.lang.annotation; - -import org.apache.harmony.annotation.internal.nls.Messages; - -/** - * Indicates that an element of an annotation type was accessed that was added - * after the type was compiled or serialized. This does not apply to new - * elements that have default values. - * - * @since 1.5 - */ -public class IncompleteAnnotationException extends RuntimeException { - - private static final long serialVersionUID = 8445097402741811912L; - - private Class annotationType; - - private String elementName; - - /** - * Constructs an instance with the incomplete annotation type and the name - * of the element that's missing. - * - * @param annotationType - * the annotation type. - * @param elementName - * the name of the incomplete element. - */ - public IncompleteAnnotationException( - Class annotationType, String elementName) { - super(Messages.getString("annotation.0", elementName, annotationType.getName())); //$NON-NLS-1$ - this.annotationType = annotationType; - this.elementName = elementName; - } - - /** - * Returns the annotation type. - * - * @return a Class instance. - */ - public Class annotationType() { - return annotationType; - } - - /** - * Returns the incomplete element's name. - * - * @return the name of the element. - */ - public String elementName() { - return elementName; - } -} diff --git a/libcore/annotation/src/main/java/java/lang/annotation/Inherited.java b/libcore/annotation/src/main/java/java/lang/annotation/Inherited.java deleted file mode 100644 index 730d30abc..000000000 --- a/libcore/annotation/src/main/java/java/lang/annotation/Inherited.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with this - * work for additional information regarding copyright ownership. The ASF - * licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.lang.annotation; - -/** - * Defines a meta-annotation for indicating that an annotation is automatically - * inherited. - * - * @since 1.5 - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Inherited { -} diff --git a/libcore/annotation/src/main/java/java/lang/annotation/Retention.java b/libcore/annotation/src/main/java/java/lang/annotation/Retention.java deleted file mode 100644 index 275739e8d..000000000 --- a/libcore/annotation/src/main/java/java/lang/annotation/Retention.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with this - * work for additional information regarding copyright ownership. The ASF - * licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.lang.annotation; - -/** - * Defines a meta-annotation for determining the scope of retention for an - * annotation. If the retention annotation is not set {@code - * RetentionPolicy.CLASS} is used as default retention. - * - * @since 1.5 - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Retention { - RetentionPolicy value(); -} diff --git a/libcore/annotation/src/main/java/java/lang/annotation/RetentionPolicy.java b/libcore/annotation/src/main/java/java/lang/annotation/RetentionPolicy.java deleted file mode 100644 index 70de3b0e4..000000000 --- a/libcore/annotation/src/main/java/java/lang/annotation/RetentionPolicy.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with this - * work for additional information regarding copyright ownership. The ASF - * licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.lang.annotation; - -/** - * Defines an enumeration for annotation retention policies. Used in conjunction - * with the {@link Retention} annotation to specify an annotation's time-to-live - * in the overall development life cycle. - * - * @since 1.5 - */ -public enum RetentionPolicy { - /** - * Annotation is only available in the source code. - */ - SOURCE, - /** - * Annotation is available in the source code and in the class file, but not - * at runtime. This is the default policy. - */ - CLASS, - /** - * Annotation is available in the source code, the class file and is - * available at runtime. - */ - RUNTIME -} diff --git a/libcore/annotation/src/main/java/java/lang/annotation/Target.java b/libcore/annotation/src/main/java/java/lang/annotation/Target.java deleted file mode 100644 index 4ba0938b1..000000000 --- a/libcore/annotation/src/main/java/java/lang/annotation/Target.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with this - * work for additional information regarding copyright ownership. The ASF - * licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.lang.annotation; - -/** - * Defines a meta-annotation for determining what {@link ElementType}s an - * annotation can be applied to. - * - * @since 1.5 - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Target { - ElementType[] value(); -} diff --git a/libcore/annotation/src/main/java/java/lang/annotation/package.html b/libcore/annotation/src/main/java/java/lang/annotation/package.html deleted file mode 100644 index 99c98ccdd..000000000 --- a/libcore/annotation/src/main/java/java/lang/annotation/package.html +++ /dev/null @@ -1,10 +0,0 @@ - - -

- Defines interfaces and exceptions necessary for annotation support. Also - provides some predefined annotations that are used throughout the Android - libraries. -

- @since Android 1.0 - - \ No newline at end of file diff --git a/libcore/annotation/src/main/java/org/apache/harmony/annotation/internal/nls/Messages.java b/libcore/annotation/src/main/java/org/apache/harmony/annotation/internal/nls/Messages.java deleted file mode 100644 index 91f35484e..000000000 --- a/libcore/annotation/src/main/java/org/apache/harmony/annotation/internal/nls/Messages.java +++ /dev/null @@ -1,146 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL. - * All changes made to this file manually will be overwritten - * if this tool runs again. Better make changes in the template file. - */ - -// BEGIN android-note -// Redundant code has been removed and is now called from MsgHelp. -// END android-note - -package org.apache.harmony.annotation.internal.nls; - - -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -// BEGIN android-changed -import org.apache.harmony.luni.util.MsgHelp; -// END android-changed - -/** - * This class retrieves strings from a resource bundle and returns them, - * formatting them with MessageFormat when required. - *

- * It is used by the system classes to provide national language support, by - * looking up messages in the - * org.apache.harmony.annotation.internal.nls.messages - * - * resource bundle. Note that if this file is not available, or an invalid key - * is looked up, or resource bundle support is not available, the key itself - * will be returned as the associated message. This means that the KEY - * should a reasonable human-readable (english) string. - * - */ -public class Messages { - - // BEGIN android-changed - private static final String sResource = - "org.apache.harmony.annotation.internal.nls.messages"; - // END android-changed - - /** - * Retrieves a message which has no arguments. - * - * @param msg - * String the key to look up. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg) { - // BEGIN android-changed - return MsgHelp.getString(sResource, msg); - // END android-changed - } - - /** - * Retrieves a message which takes 1 argument. - * - * @param msg - * String the key to look up. - * @param arg - * Object the object to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, Object arg) { - return getString(msg, new Object[] { arg }); - } - - /** - * Retrieves a message which takes 1 integer argument. - * - * @param msg - * String the key to look up. - * @param arg - * int the integer to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, int arg) { - return getString(msg, new Object[] { Integer.toString(arg) }); - } - - /** - * Retrieves a message which takes 1 character argument. - * - * @param msg - * String the key to look up. - * @param arg - * char the character to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, char arg) { - return getString(msg, new Object[] { String.valueOf(arg) }); - } - - /** - * Retrieves a message which takes 2 arguments. - * - * @param msg - * String the key to look up. - * @param arg1 - * Object an object to insert in the formatted output. - * @param arg2 - * Object another object to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, Object arg1, Object arg2) { - return getString(msg, new Object[] { arg1, arg2 }); - } - - /** - * Retrieves a message which takes several arguments. - * - * @param msg - * String the key to look up. - * @param args - * Object[] the objects to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, Object[] args) { - // BEGIN android-changed - return MsgHelp.getString(sResource, msg, args); - // END android-changed - } - - // BEGIN android-note - // Duplicate code was dropped in favor of using MsgHelp. - // END android-note -} diff --git a/libcore/annotation/src/main/java/org/apache/harmony/annotation/internal/nls/messages.properties b/libcore/annotation/src/main/java/org/apache/harmony/annotation/internal/nls/messages.properties deleted file mode 100644 index 613c54dac..000000000 --- a/libcore/annotation/src/main/java/org/apache/harmony/annotation/internal/nls/messages.properties +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# messages for EN locale -annotation.0=The element, {0}, is not complete for the annotation {1}. -annotation.1=The annotation element, {0}, doesn't match the type {1}. diff --git a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AllTests.java b/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AllTests.java deleted file mode 100644 index e306435df..000000000 --- a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AllTests.java +++ /dev/null @@ -1,41 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.annotation.tests.java.lang.annotation; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Test suite for java.nio.charset package. - */ -public class AllTests { - - public static Test suite() { - TestSuite suite = tests.TestSuiteFactory.createTestSuite("Test for java.lang.annotation"); - // $JUnit-BEGIN$ - - suite.addTestSuite(AnnotationTest.class); - suite.addTestSuite(AnnotationFormatErrorTest.class); - suite.addTestSuite(AnnotationTypeMismatchExceptionTest.class); - suite.addTestSuite(ElementTypeTest.class); - suite.addTestSuite(IncompleteAnnotationExceptionTest.class); - suite.addTestSuite(RetentionPolicyTest.class); - - // $JUnit-END$ - return suite; - } -} diff --git a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationFormatErrorTest.java b/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationFormatErrorTest.java deleted file mode 100644 index c2a32b8a0..000000000 --- a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationFormatErrorTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.annotation.tests.java.lang.annotation; - -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import junit.framework.TestCase; - -import java.lang.annotation.AnnotationFormatError; - -/** - * Test case of java.lang.annotation.AnnotationFormatError - */ -@TestTargetClass(AnnotationFormatError.class) -public class AnnotationFormatErrorTest extends TestCase { - /** - * @tests java.lang.annotation.AnnotationFormatError#AnnotationFormatError(String) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "AnnotationFormatError", - args = {java.lang.String.class} - ) - @SuppressWarnings("nls") - public void test_constructorLjava_lang_String() { - AnnotationFormatError e = new AnnotationFormatError("some message"); - assertEquals("some message", e.getMessage()); - } - - /** - * @tests java.lang.annotation.AnnotationFormatError#AnnotationFormatError(Throwable) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "AnnotationFormatError", - args = {java.lang.Throwable.class} - ) - public void test_constructorLjava_lang_Throwable() { - IllegalArgumentException iae = new IllegalArgumentException(); - AnnotationFormatError e = new AnnotationFormatError(iae); - assertSame(iae, e.getCause()); - } - - /** - * @tests java.lang.annotation.AnnotationFormatError#AnnotationFormatError(String,Throwable) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "AnnotationFormatError", - args = {java.lang.String.class, java.lang.Throwable.class} - ) - @SuppressWarnings("nls") - public void test_constructorLjava_lang_StringLjava_lang_Throwable() { - IllegalArgumentException iae = new IllegalArgumentException(); - AnnotationFormatError e = new AnnotationFormatError("some message", iae); - assertEquals("some message", e.getMessage()); - assertSame(iae, e.getCause()); - } -} diff --git a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationTest.java b/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationTest.java deleted file mode 100644 index c50c0e8d3..000000000 --- a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationTest.java +++ /dev/null @@ -1,471 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.annotation.tests.java.lang.annotation; - -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargets; - -import junit.framework.TestCase; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Test case of java.lang.annotation.Annotation - */ -@TestTargetClass(value = Annotation.class, - untestedMethods = { - @TestTargetNew( - level = TestLevel.NOT_NECESSARY, - notes = "the spec does not require any specific output (although @something is probable)", - method = "toString", - args = {} - )} -) -public class AnnotationTest extends TestCase { - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "annotationType", - args = {} - ) - public void test_annotationType() { - Annotation [] annotations = AnnotatedClass.class.getDeclaredAnnotations(); - assertEquals(1, annotations.length); - Annotation anno = annotations[0]; - assertEquals(TestAnnotation1.class, anno.annotationType()); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "equals", - args = { Object.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "hashCode", - args = {} - ) - }) - public void test_equals() throws Exception { - // test type - Method m1 = AnnotatedClass2.class - .getDeclaredMethod("a", new Class[] {}); - Method m2 = AnnotatedClass2.class - .getDeclaredMethod("b", new Class[] {}); - assertFalse("other annotation class type", - m1.getDeclaredAnnotations()[0].equals(m2 - .getDeclaredAnnotations()[0])); - - // test equality / non equality for base types and compound types - List methods = Arrays.asList(AnnotatedClass.class.getDeclaredMethods()); - Map> eqs = new HashMap>(); - Map> neqs = new HashMap>(); - for (Method m : methods) { - String name = m.getName(); - //System.out.println("name "+name); - Map> curT = name.charAt(0) == 'e'? eqs : neqs; - String testNum = name.substring(1,3); // 01 - List mlist = curT.get(testNum); - if (mlist == null) { - mlist = new ArrayList(); - curT.put(testNum, mlist); - } - mlist.add(AnnotatedClass.class.getDeclaredMethod(name, new Class[] {})); - } - - for (List eqList : eqs.values()) { - for (int i = 0; i < eqList.size() -1; i++) { - for (int j = i+1; j < eqList.size(); j++) { - Method me1 = eqList.get(i); - Method me2 = eqList.get(j); - //System.out.println("eq test for "+me1.getName()+", "+me2.getName()); - Annotation a1 = me1.getDeclaredAnnotations()[0]; - Annotation a2 = me2.getDeclaredAnnotations()[0]; - assertEquals("must be equal : method1:"+me1.getName()+", method2: "+me2.getName(), a1, a2); - assertEquals("same hashcode", a1.hashCode(), a2.hashCode()); - } - } - } - - for (List eqList : neqs.values()) { - for (int i = 0; i < eqList.size() -1; i++) { - for (int j = i+1; j < eqList.size(); j++) { - Method me1 = eqList.get(i); - Method me2 = eqList.get(j); - Annotation a1 = me1.getDeclaredAnnotations()[0]; - Annotation a2 = me2.getDeclaredAnnotations()[0]; - //System.out.println("ne test for "+me1.getName()+", "+me2.getName()); - assertFalse("must not be equal : method1:"+me1.getName()+", method2: "+me2.getName(), - a1.equals(a2)); - if (a1.hashCode() != a2.hashCode()) { - assertFalse("not same hashcode -> not equals", a1.equals(a2)); - } - } - - } - } - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "hashCode", - args = {} - ) - public void test_hashCode() throws SecurityException, NoSuchMethodException { - Annotation a1 = AnnotatedClass.class.getDeclaredAnnotations()[0]; - assertEquals(a1.hashCode(), (127 * "value".hashCode() ^ "foobar".hashCode())); - // i+= 127 *(key.hashCode() ^ memberValHashCode(value); - - Method m1 = AnnotatedClass.class.getDeclaredMethod("e34c", new Class[] {}); - int arrHc = Arrays.hashCode(new Object[]{}); - /* - TestAnnotation3[] arrAnno() default {}; - String[] arrString() default {}; - Class[] arrClass() default {}; - TestEnum1[] arrEnum() default {}; - */ - assertEquals( - (127 * "arrAnno".hashCode() ^ arrHc) + - (127 * "arrString".hashCode() ^ arrHc)+ - (127 * "arrClass".hashCode() ^ arrHc) + - (127 * "arrEnum".hashCode() ^ arrHc) - , - m1.getDeclaredAnnotations()[0].hashCode()); - - Method m2 = AnnotatedClass3.class.getDeclaredMethod("a", new Class[] {}); - assertEquals( - (127 * "i".hashCode() ^ 12345), - m2.getDeclaredAnnotations()[0].hashCode()); - - } -} - -class AnnotatedClass2 { - @TestAnnotation3() - void a() {} - @TestAnnotation3b() - void b() {} -} - -class AnnotatedClass3 { - @TestAnnotation4(i = 12345) - void a() {} -} - -@TestAnnotation1("foobar") -class AnnotatedClass { - - // ----- boolean ----- - @TestAnnotation3(z = false) - void e01a() {} - @TestAnnotation3(z = false) - void e01b() {} - @TestAnnotation3() - void e01c() {} - - @TestAnnotation3(z = true) - void e02a() {} - @TestAnnotation3(z = true) - void e02b() {} - - @TestAnnotation3(z = false) - void n03a() {} - @TestAnnotation3(z = true) - void n03b() {} - - - // ----- byte ----- - @TestAnnotation3(b = 0) - void e04a() {} - @TestAnnotation3(b = 0) - void e04b() {} - @TestAnnotation3() - void e04c() {} - - @TestAnnotation3(b= 127) - void e05a() {} - @TestAnnotation3(b = 127) - void e05b() {} - - @TestAnnotation3(b = -128) - void n06a() {} - @TestAnnotation3(b = 127) - void n06b() {} - - - // ----- short ----- - @TestAnnotation3(s = 0) - void e07a() {} - @TestAnnotation3(s = 0) - void e07b() {} - @TestAnnotation3() - void e07c() {} - - @TestAnnotation3(s= 32767) - void e08a() {} - @TestAnnotation3(s = 32767) - void e08b() {} - - @TestAnnotation3(s = -32768) - void n09a() {} - @TestAnnotation3(s = 32767) - void n09b() {} - - - // ----- int ----- - @TestAnnotation3(i = 100) - void e10a() {} - @TestAnnotation3(i = 100) - void e10b() {} - @TestAnnotation3() - void e10c() {} - - @TestAnnotation3(i = Integer.MAX_VALUE) - void e11a() {} - @TestAnnotation3(i = Integer.MAX_VALUE) - void e11b() {} - - @TestAnnotation3(i = Integer.MAX_VALUE) - void n12a() {} - @TestAnnotation3(i = Integer.MIN_VALUE) - void n12b() {} - - - // ----- long ----- - @TestAnnotation3(j = 0) - void e13a() {} - @TestAnnotation3(j = 0) - void e13b() {} - @TestAnnotation3() - void e13c() {} - - @TestAnnotation3(j = Long.MAX_VALUE) - void e14a() {} - @TestAnnotation3(j = Long.MAX_VALUE) - void e14b() {} - - @TestAnnotation3(j = Long.MAX_VALUE) - void n15a() {} - @TestAnnotation3(j = Long.MIN_VALUE) - void n15b() {} - - - // ----- float ----- - @TestAnnotation3(f = 0.0f) - void e16a() {} - @TestAnnotation3(f = 0.0f) - void e16b() {} - @TestAnnotation3() - void e16c() {} - - @TestAnnotation3(f = Float.MAX_VALUE) - void e17a() {} - @TestAnnotation3(f = Float.MAX_VALUE) - void e17b() {} - - @TestAnnotation3(f = Float.NaN) - void e18a() {} - @TestAnnotation3(f = Float.NaN) - void e18b() {} - - @TestAnnotation3(f = Long.MAX_VALUE) - void n19a() {} - @TestAnnotation3(f = Long.MIN_VALUE) - void n19b() {} - - @TestAnnotation3(f = 0.0f) - void n20a() {} - @TestAnnotation3(f = -0.0f) - void n20b() {} - - - // ----- double ----- - @TestAnnotation3(d = 0.0d) - void e21a() {} - @TestAnnotation3(d = 0.0d) - void e21b() {} - @TestAnnotation3() - void e21c() {} - - @TestAnnotation3(d = Double.MAX_VALUE) - void e22a() {} - @TestAnnotation3(d = Double.MAX_VALUE) - void e22b() {} - - @TestAnnotation3(d = Double.NaN) - void e23a() {} - @TestAnnotation3(d = Double.NaN) - void e23b() {} - - - @TestAnnotation3(d = Double.MAX_VALUE) - void n24a() {} - @TestAnnotation3(d = Double.MIN_VALUE) - void n24b() {} - - @TestAnnotation3(d = 0.0d) - void n25a() {} - @TestAnnotation3(d = -0.0d) - void n25b() {} - - - // ----- String ----- - @TestAnnotation3(aString = "") - void e26a() {} - @TestAnnotation3(aString = "") - void e26b() {} - @TestAnnotation3() - void e26c() {} - - @TestAnnotation3(aString = "asjdfk jkls dfjklsd fklsd jklds kflds jfkldsfjd"+"d") - void e27a() {} - @TestAnnotation3(aString = "asjdfk jkls dfjklsd fklsd jklds kflds jfkldsfj"+"dd") - void e27b() {} - - @TestAnnotation3(aString = "a") - void n28a() {} - @TestAnnotation3(aString = "b") - void n28b() {} - - - // ----- Class----- - @TestAnnotation3(aClazz = Void.class) - void e29a() {} - @TestAnnotation3(aClazz = Void.class) - void e29b() {} - @TestAnnotation3() - void e29c() {} - - @TestAnnotation3(aClazz = Integer.class) - void n30a() {} - @TestAnnotation3(aClazz = int.class) - void n30b() {} - - - // ----- Enum----- - @TestAnnotation3(aEnum = TestEnum1.F) - void e31a() {} - @TestAnnotation3(aEnum = TestEnum1.F) - void e31b() {} - @TestAnnotation3() - void e31c() {} - - @TestAnnotation3(aEnum = TestEnum1.F) - void n32a() {} - @TestAnnotation3(aEnum = TestEnum1.A) - void n32b() {} - - @TestAnnotation3(aEnum = TestEnum1.F) - void n33a() {} - @TestAnnotation3(aEnum = TestEnum1.L) - void n33b() {} - - - // ----- String arr----- - @TestAnnotation2(arrString = {}) - void e34a() {} - @TestAnnotation2(arrString = {}) - void e34b() {} - @TestAnnotation2(arrString = {}) - void e34c() {} - - @TestAnnotation2(arrString = { "a", "b"}) - void e35a() {} - @TestAnnotation2(arrString = { "a", "b" }) - void e35b() {} - - @TestAnnotation2(arrString = { "a", "b"}) - void n36a() {} - @TestAnnotation2(arrString = { "a", "c" }) - void n36b() {} - - - // ----- Class arr----- - @TestAnnotation2(arrClass= {}) - void e37a() {} - @TestAnnotation2(arrClass = {}) - void e37b() {} - @TestAnnotation2(arrClass = {}) - void e37c() {} - - @TestAnnotation2(arrClass = { Void.class, Integer.class}) - void e38a() {} - @TestAnnotation2(arrClass = { Void.class, Integer.class}) - void e38b() {} - - @TestAnnotation2(arrClass = { Void.class, Integer.class}) - void n39a() {} - @TestAnnotation2(arrClass = { Void.class, int.class}) - void n39b() {} - - // ----- Enum arr----- - @TestAnnotation2(arrEnum= {}) - void e40a() {} - @TestAnnotation2(arrEnum = {}) - void e40b() {} - @TestAnnotation2(arrEnum = {}) - void e40c() {} - - @TestAnnotation2(arrEnum = { TestEnum1.A, TestEnum1.F }) - void e41a() {} - @TestAnnotation2(arrEnum = { TestEnum1.A, TestEnum1.F }) - void e41b() {} - - @TestAnnotation2(arrEnum = { TestEnum1.A, TestEnum1.F }) - void n42a() {} - @TestAnnotation2(arrEnum = { TestEnum1.A, TestEnum1.L }) - void n42b() {} - - - // ----- Annotation arr----- - @TestAnnotation2(arrAnno= {}) - void e43a() {} - @TestAnnotation2(arrAnno = {}) - void e43b() {} - @TestAnnotation2() - void e43c() {} - - @TestAnnotation2(arrAnno = { @TestAnnotation3(i = 20), @TestAnnotation3(j = 123)}) - void e44a() {} - @TestAnnotation2(arrAnno = { @TestAnnotation3(i = 20), @TestAnnotation3(j = 123)}) - void e44b() {} - - @TestAnnotation2(arrAnno = { @TestAnnotation3(i = 20), @TestAnnotation3(j = 123)}) - void n45a() {} - @TestAnnotation2(arrAnno = { @TestAnnotation3(i = 20), @TestAnnotation3(j = 124)}) - void n45b() {} - - @TestAnnotation2(arrAnno = { @TestAnnotation3(i = 20), @TestAnnotation3(j = 123)}) - void n46a() {} - @TestAnnotation2(arrAnno = { @TestAnnotation3(i = -20), @TestAnnotation3(j = 123)}) - void n46b() {} - -} diff --git a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationTypeMismatchExceptionTest.java b/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationTypeMismatchExceptionTest.java deleted file mode 100644 index 5430286f4..000000000 --- a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationTypeMismatchExceptionTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.annotation.tests.java.lang.annotation; - -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import junit.framework.TestCase; - -import java.lang.annotation.AnnotationTypeMismatchException; -import java.lang.reflect.Method; - -/** - * Test case of java.lang.annotation.AnnotationTypeMismatchException - */ -@TestTargetClass(AnnotationTypeMismatchException.class) -public class AnnotationTypeMismatchExceptionTest extends TestCase { - - /** - * @throws ClassNotFoundException - * @throws SecurityException - * @tests java.lang.annotation.AnnotationTypeMismatchException#AnnotationTypeMismatchException(Method, - * String) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "AnnotationTypeMismatchException", - args = {java.lang.reflect.Method.class, java.lang.String.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "element", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "foundType", - args = {} - ) - }) - @SuppressWarnings("nls") - public void test_constructorLjava_lang_reflect_MethodLjava_lang_String() throws SecurityException, ClassNotFoundException { - Method[] methods = Class.forName("java.lang.String").getMethods(); - Method m = methods[0]; - AnnotationTypeMismatchException e = new AnnotationTypeMismatchException( - m, "some type"); - assertNotNull("can not instantiate AnnotationTypeMismatchException", e); - assertSame("wrong method name", m, e.element()); - assertEquals("wrong found type", "some type", e.foundType()); - } -} diff --git a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/ElementTypeTest.java b/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/ElementTypeTest.java deleted file mode 100644 index dec9bf776..000000000 --- a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/ElementTypeTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.annotation.tests.java.lang.annotation; - -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import junit.framework.TestCase; - -import java.lang.annotation.ElementType; -import java.util.Arrays; - -/** - * Test case of java.lang.annotation.ElementType - */ -@TestTargetClass(ElementType.class) -public class ElementTypeTest extends TestCase { - - /** - * @throws Exception - * @tests java.lang.annotation.ElementType#valueOf(String) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "valueOf", - args = {java.lang.String.class} - ) - @SuppressWarnings("nls") - public void test_valueOfLjava_lang_String() throws Exception { - assertSame(ElementType.ANNOTATION_TYPE, ElementType - .valueOf("ANNOTATION_TYPE")); - assertSame(ElementType.CONSTRUCTOR, ElementType.valueOf("CONSTRUCTOR")); - assertSame(ElementType.FIELD, ElementType.valueOf("FIELD")); - assertSame(ElementType.LOCAL_VARIABLE, ElementType - .valueOf("LOCAL_VARIABLE")); - assertSame(ElementType.METHOD, ElementType.valueOf("METHOD")); - assertSame(ElementType.PACKAGE, ElementType.valueOf("PACKAGE")); - assertSame(ElementType.PARAMETER, ElementType.valueOf("PARAMETER")); - assertSame(ElementType.TYPE, ElementType.valueOf("TYPE")); - try { - ElementType.valueOf("OTHER"); - fail("Should throw an IllegalArgumentException"); - } catch (IllegalArgumentException e) { - // expected - } - } - - /** - * @throws Exception - * @tests java.lang.annotation.ElementType#values() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "values", - args = {} - ) - @SuppressWarnings("nls") - public void test_values() throws Exception { - ElementType[] values = ElementType.values(); - assertTrue(values.length > 1); - Arrays.sort(values); - assertTrue(Arrays.binarySearch(values, ElementType.METHOD) >= 0); - } -} diff --git a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/IncompleteAnnotationExceptionTest.java b/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/IncompleteAnnotationExceptionTest.java deleted file mode 100644 index 5c718ed86..000000000 --- a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/IncompleteAnnotationExceptionTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.annotation.tests.java.lang.annotation; - -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import junit.framework.TestCase; - -import java.lang.annotation.IncompleteAnnotationException; - -@TestTargetClass(IncompleteAnnotationException.class) -public class IncompleteAnnotationExceptionTest extends TestCase { - - /* - * Class under test for void IncompleteAnnotationException(String) - * Regression for HARMONY-2477 - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verifies NullPointerException.", - method = "IncompleteAnnotationException", - args = {java.lang.Class.class, java.lang.String.class} - ) - public void testNullType() { - try { - new IncompleteAnnotationException(null, "str"); - fail("NullPointerException must be thrown"); - } catch (NullPointerException e) { - // Expected - } - } - - /** - * @throws Exception - * @tests java.lang.annotation.IncompleteAnnotationException#IncompleteAnnotationException(Class, - * String) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "IncompleteAnnotationException", - args = {java.lang.Class.class, java.lang.String.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "annotationType", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "elementName", - args = {} - ) - }) - @SuppressWarnings("nls") - public void test_constructorLjava_lang_Class_Ljava_lang_String() - throws Exception { - Class clazz = String.class; - String elementName = "some element"; - IncompleteAnnotationException e = new IncompleteAnnotationException( - clazz, elementName); - assertNotNull("can not instantiate IncompleteAnnotationException", e); - assertSame("wrong annotation type", clazz, e.annotationType()); - assertSame("wrong element name", elementName, e.elementName()); - } -} diff --git a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/RetentionPolicyTest.java b/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/RetentionPolicyTest.java deleted file mode 100644 index 1827b7d60..000000000 --- a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/RetentionPolicyTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.annotation.tests.java.lang.annotation; - -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import junit.framework.TestCase; - -import java.lang.annotation.RetentionPolicy; -import java.util.Arrays; - -/** - * Test case of java.lang.annotation.RetentionPolicy - */ -@TestTargetClass(RetentionPolicy.class) -public class RetentionPolicyTest extends TestCase { - /** - * @throws Exception - * @tests java.lang.annotation.RetentionPolicy#valueOf(String) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "valueOf", - args = {java.lang.String.class} - ) - @SuppressWarnings("nls") - public void test_valueOfLjava_lang_String() throws Exception { - assertSame(RetentionPolicy.CLASS, RetentionPolicy - .valueOf("CLASS")); - assertSame(RetentionPolicy.RUNTIME, RetentionPolicy - .valueOf("RUNTIME")); - assertSame(RetentionPolicy.SOURCE, RetentionPolicy - .valueOf("SOURCE")); - try { - RetentionPolicy.valueOf("OTHER"); - fail("Should throw an IllegalArgumentException"); - } catch (IllegalArgumentException e) { - // expected - } - } - - /** - * @throws Exception - * @tests java.lang.annotation.RetentionPolicy#values() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "values", - args = {} - ) - @SuppressWarnings("nls") - public void test_values() throws Exception { - RetentionPolicy[] values = RetentionPolicy.values(); - assertTrue(values.length > 1); - Arrays.sort(values); - assertTrue(Arrays.binarySearch(values, RetentionPolicy.RUNTIME) >= 0); - } -} diff --git a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation1.java b/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation1.java deleted file mode 100644 index 64393ef20..000000000 --- a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation1.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.annotation.tests.java.lang.annotation; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface TestAnnotation1 { - String value(); -} diff --git a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation2.java b/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation2.java deleted file mode 100644 index d3c7d425c..000000000 --- a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation2.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.apache.harmony.annotation.tests.java.lang.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target( {ElementType.METHOD}) -public @interface TestAnnotation2 { - TestAnnotation3[] arrAnno() default {}; - String[] arrString() default {}; - Class[] arrClass() default {}; - TestEnum1[] arrEnum() default {}; -} diff --git a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation3.java b/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation3.java deleted file mode 100644 index 3228c6636..000000000 --- a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation3.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.apache.harmony.annotation.tests.java.lang.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target( {ElementType.METHOD}) -public @interface TestAnnotation3 { - /* - * only primitive type, String, Class, annotation, - * enumeration are permitted - * or 1-dimensional arrays thereof - */ - boolean z() default false; - byte b() default 0; - short s() default 0; - int i() default 100; - long j() default 0; - - float f() default 0.0f; - double d() default 0.0d; - - String aString() default ""; - Class aClazz() default Void.class; - TestEnum1 aEnum() default TestEnum1.F; -} diff --git a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation3b.java b/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation3b.java deleted file mode 100644 index 5411011ec..000000000 --- a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation3b.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.apache.harmony.annotation.tests.java.lang.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target( {ElementType.METHOD}) -public @interface TestAnnotation3b { - /* - * only primitive type, String, Class, annotation, - * enumeration are permitted - * or 1-dimensional arrays thereof - */ - boolean z() default false; - byte b() default 0; - short s() default 0; - int i() default 100; - long l() default 0; - - float f() default 0.0f; - double d() default 0.0d; - - String aString() default ""; - Class aClazz() default Void.class; - TestEnum1 aEnum() default TestEnum1.F; -} diff --git a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation4.java b/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation4.java deleted file mode 100644 index 2267536dd..000000000 --- a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestAnnotation4.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.apache.harmony.annotation.tests.java.lang.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target( {ElementType.METHOD}) -public @interface TestAnnotation4 { - int i() default 0; -} diff --git a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestEnum1.java b/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestEnum1.java deleted file mode 100644 index f8ed73d36..000000000 --- a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestEnum1.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.apache.harmony.annotation.tests.java.lang.annotation; - -public enum TestEnum1 { - Z, F, L, A, B -} diff --git a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestEnum1b.java b/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestEnum1b.java deleted file mode 100644 index 874d8937f..000000000 --- a/libcore/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/TestEnum1b.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.apache.harmony.annotation.tests.java.lang.annotation; - -public enum TestEnum1b { - Z, F, L, A, B -} diff --git a/libcore/annotation/src/test/java/tests/annotation/AllTests.java b/libcore/annotation/src/test/java/tests/annotation/AllTests.java deleted file mode 100644 index 172cc10aa..000000000 --- a/libcore/annotation/src/test/java/tests/annotation/AllTests.java +++ /dev/null @@ -1,38 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package tests.annotation; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Test suite that includes all tests for the NIO_Char project. - */ -public class AllTests { - - public static void main(String[] args) { - junit.textui.TestRunner.run(AllTests.suite()); - } - - public static Test suite() { - TestSuite suite = tests.TestSuiteFactory.createTestSuite("All Annotation test suites"); - // $JUnit-BEGIN$ - suite.addTest(org.apache.harmony.annotation.tests.java.lang.annotation.AllTests.suite()); - // $JUnit-END$ - return suite; - } -} diff --git a/libcore/archive/MODULE_LICENSE_APACHE2 b/libcore/archive/MODULE_LICENSE_APACHE2 deleted file mode 100644 index e69de29bb..000000000 diff --git a/libcore/archive/src/main/java/java/util/jar/Attributes.java b/libcore/archive/src/main/java/java/util/jar/Attributes.java deleted file mode 100644 index 4ee94dfdd..000000000 --- a/libcore/archive/src/main/java/java/util/jar/Attributes.java +++ /dev/null @@ -1,515 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.jar; - -import java.io.UnsupportedEncodingException; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.apache.harmony.archive.util.Util; - -/** - * The {@code Attributes} class is used to store values for manifest entries. - * Attribute keys are generally instances of {@code Attributes.Name}. Values - * associated with attribute keys are of type {@code String}. - */ -public class Attributes implements Cloneable, Map { - - /** - * The {@code Attributes} as name/value pairs. Maps the attribute names (as - * {@link Attributes.Name}) of a JAR file manifest to arbitrary values. The - * attribute names thus are obtained from the {@link Manifest} for - * convenience. - */ - protected Map map; - - /** - * The name part of the name/value pairs constituting an attribute as - * defined by the specification of the JAR manifest. May be composed of the - * following ASCII signs as defined in the EBNF below: - * - *

-     * name       = alphanum *headerchar
-     * headerchar = alphanum | - | _
-     * alphanum   = {A-Z} | {a-z} | {0-9}
-     * 
- */ - public static class Name { - private final byte[] name; - - private int hashCode; - - /** - * The class path (a main attribute). - */ - public static final Name CLASS_PATH = new Name("Class-Path"); //$NON-NLS-1$ - - /** - * The version of the manifest file (a main attribute). - */ - public static final Name MANIFEST_VERSION = new Name("Manifest-Version"); //$NON-NLS-1$ - - /** - * The main class's name (for stand-alone applications). - */ - public static final Name MAIN_CLASS = new Name("Main-Class"); //$NON-NLS-1$ - - /** - * Defines the signature version of the JAR file. - */ - public static final Name SIGNATURE_VERSION = new Name( - "Signature-Version"); //$NON-NLS-1$ - - /** - * The {@code Content-Type} manifest attribute. - */ - public static final Name CONTENT_TYPE = new Name("Content-Type"); //$NON-NLS-1$ - - /** - * The {@code Sealed} manifest attribute which may have the value - * {@code true} for sealed archives. - */ - public static final Name SEALED = new Name("Sealed"); //$NON-NLS-1$ - - /** - * The {@code Implementation-Title} attribute whose value is a string - * that defines the title of the extension implementation. - */ - public static final Name IMPLEMENTATION_TITLE = new Name( - "Implementation-Title"); //$NON-NLS-1$ - - /** - * The {@code Implementation-Version} attribute defining the version of - * the extension implementation. - */ - public static final Name IMPLEMENTATION_VERSION = new Name( - "Implementation-Version"); //$NON-NLS-1$ - - /** - * The {@code Implementation-Vendor} attribute defining the organization - * that maintains the extension implementation. - */ - public static final Name IMPLEMENTATION_VENDOR = new Name( - "Implementation-Vendor"); //$NON-NLS-1$ - - /** - * The {@code Specification-Title} attribute defining the title of the - * extension specification. - */ - public static final Name SPECIFICATION_TITLE = new Name( - "Specification-Title"); //$NON-NLS-1$ - - /** - * The {@code Specification-Version} attribute defining the version of - * the extension specification. - */ - public static final Name SPECIFICATION_VERSION = new Name( - "Specification-Version"); //$NON-NLS-1$ - - /** - * The {@code Specification-Vendor} attribute defining the organization - * that maintains the extension specification. - */ - public static final Name SPECIFICATION_VENDOR = new Name( - "Specification-Vendor"); //$NON-NLS-1$ - - /** - * The {@code Extension-List} attribute defining the extensions that are - * needed by the applet. - */ - public static final Name EXTENSION_LIST = new Name("Extension-List"); //$NON-NLS-1$ - - /** - * The {@code Extension-Name} attribute which defines the unique name of - * the extension. - */ - public static final Name EXTENSION_NAME = new Name("Extension-Name"); //$NON-NLS-1$ - - /** - * The {@code Extension-Installation} attribute. - */ - public static final Name EXTENSION_INSTALLATION = new Name( - "Extension-Installation"); //$NON-NLS-1$ - - /** - * The {@code Implementation-Vendor-Id} attribute specifies the vendor - * of an extension implementation if the applet requires an - * implementation from a specific vendor. - */ - public static final Name IMPLEMENTATION_VENDOR_ID = new Name( - "Implementation-Vendor-Id"); //$NON-NLS-1$ - - /** - * The {@code Implementation-URL} attribute specifying a URL that can be - * used to obtain the most recent version of the extension if the - * required version is not already installed. - */ - public static final Name IMPLEMENTATION_URL = new Name( - "Implementation-URL"); //$NON-NLS-1$ - - static final Name NAME = new Name("Name"); - - /** - * A String which must satisfy the following EBNF grammar to specify an - * additional attribute: - * - *
-         * name       = alphanum *headerchar
-         * headerchar = alphanum | - | _
-         * alphanum   = {A-Z} | {a-z} | {0-9}
-         * 
- * - * @param s - * The Attribute string. - * @exception IllegalArgumentException - * if the string does not satisfy the EBNF grammar. - */ - public Name(String s) { - int i = s.length(); - if (i == 0 || i > Manifest.LINE_LENGTH_LIMIT - 2) { - throw new IllegalArgumentException(); - } - - name = new byte[i]; - - for (; --i >= 0;) { - char ch = s.charAt(i); - if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') - || ch == '_' || ch == '-' || (ch >= '0' && ch <= '9'))) { - throw new IllegalArgumentException(s); - } - name[i] = (byte) ch; - } - } - - /** - * A private constructor for a trusted attribute name. - */ - Name(byte[] buf) { - name = buf; - } - - byte[] getBytes() { - return name; - } - - /** - * Returns this attribute name. - * - * @return the attribute name. - */ - @Override - public String toString() { - try { - return new String(name, "ISO-8859-1"); - } catch (UnsupportedEncodingException iee) { - throw new InternalError(iee.getLocalizedMessage()); - } - } - - /** - * returns whether the argument provided is the same as the attribute - * name. - * - * @return if the attribute names correspond. - * @param object - * An attribute name to be compared with this name. - */ - @Override - public boolean equals(Object object) { - if (object == null || object.getClass() != getClass() - || object.hashCode() != hashCode()) { - return false; - } - - return Util.equalsIgnoreCase(name, ((Name) object).name); - } - - /** - * Computes a hash code of the name. - * - * @return the hash value computed from the name. - */ - @Override - public int hashCode() { - if (hashCode == 0) { - int hash = 0, multiplier = 1; - for (int i = name.length - 1; i >= 0; i--) { - // 'A' & 0xDF == 'a' & 0xDF, ..., 'Z' & 0xDF == 'z' & 0xDF - hash += (name[i] & 0xDF) * multiplier; - int shifted = multiplier << 5; - multiplier = shifted - multiplier; - } - hashCode = hash; - } - return hashCode; - } - - } - - /** - * Constructs an {@code Attributes} instance. - */ - public Attributes() { - map = new HashMap(); - } - - /** - * Constructs an {@code Attributes} instance obtaining keys and values from - * the parameter {@code attrib}. - * - * @param attrib - * The attributes to obtain entries from. - */ - @SuppressWarnings("unchecked") - public Attributes(Attributes attrib) { - map = (Map) ((HashMap) attrib.map).clone(); - } - - /** - * Constructs an {@code Attributes} instance with initial capacity of size - * {@code size}. - * - * @param size - * Initial size of this {@code Attributes} instance. - */ - public Attributes(int size) { - map = new HashMap(size); - } - - /** - * Removes all key/value pairs from this {@code Attributes}. - */ - public void clear() { - map.clear(); - } - - /** - * Determines whether this {@code Attributes} contains the specified key. - * - * @param key - * The key to search for. - * @return {@code true} if the key is found, {@code false} otherwise. - */ - public boolean containsKey(Object key) { - return map.containsKey(key); - } - - /** - * Determines whether this {@code Attributes} contains the specified value. - * - * @param value - * the value to search for. - * @return {@code true} if the value is found, {@code false} otherwise. - */ - public boolean containsValue(Object value) { - return map.containsValue(value); - } - - /** - * Returns a set containing map entries for each of the key/value pair - * contained in this {@code Attributes}. - * - * @return a set of Map.Entry's - */ - public Set> entrySet() { - return map.entrySet(); - } - - /** - * Returns the value associated with the parameter key. - * - * @param key - * the key to search for. - * @return Object associated with key, or {@code null} if key does not - * exist. - */ - public Object get(Object key) { - return map.get(key); - } - - /** - * Determines whether this {@code Attributes} contains any keys. - * - * @return {@code true} if one or more keys exist, {@code false} otherwise. - */ - public boolean isEmpty() { - return map.isEmpty(); - } - - /** - * Returns a {@code Set} containing all the keys found in this {@code - * Attributes}. - * - * @return a {@code Set} of all keys. - */ - public Set keySet() { - return map.keySet(); - } - - /** - * Stores key/value pairs in this {@code Attributes}. - * - * @param key - * the key to associate with value. - * @param value - * the value to store in this {@code Attributes}. - * @return the value being stored. - * @exception ClassCastException - * when key is not an {@code Attributes.Name} or value is not - * a {@code String}. - */ - @SuppressWarnings("cast") - // Require cast to force ClassCastException - public Object put(Object key, Object value) { - return map.put((Name) key, (String) value); - } - - /** - * Stores all the key/value pairs in the argument in this {@code - * Attributes}. - * - * @param attrib - * the associations to store (must be of type {@code - * Attributes}). - */ - public void putAll(Map attrib) { - if (attrib == null || !(attrib instanceof Attributes)) { - throw new ClassCastException(); - } - this.map.putAll(attrib); - } - - /** - * Deletes the key/value pair with key {@code key} from this {@code - * Attributes}. - * - * @param key - * the key to remove. - * @return the values associated with the removed key, {@code null} if not - * present. - */ - public Object remove(Object key) { - return map.remove(key); - } - - /** - * Returns the number of key/value pairs associated with this {@code - * Attributes}. - * - * @return the size of this {@code Attributes}. - */ - public int size() { - return map.size(); - } - - /** - * Returns a collection of all the values present in this {@code - * Attributes}. - * - * @return a collection of all values present. - */ - public Collection values() { - return map.values(); - } - - @SuppressWarnings("unchecked") - @Override - public Object clone() { - Attributes clone; - try { - clone = (Attributes) super.clone(); - } catch (CloneNotSupportedException e) { - return null; - } - clone.map = (Map) ((HashMap) map).clone(); - return clone; - } - - /** - * Returns the hash code of this {@code Attributes}. - * - * @return the hash code of this object. - */ - @Override - public int hashCode() { - return map.hashCode(); - } - - /** - * Determines if this {@code Attributes} and the parameter {@code - * Attributes} are equal. Two {@code Attributes} instances are equal if they - * contain the same keys and values. - * - * @param obj - * the object with which this {@code Attributes} is compared. - * @return {@code true} if the {@code Attributes} are equal, {@code false} - * otherwise. - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof Attributes) { - return map.equals(((Attributes) obj).map); - } - return false; - } - - /** - * Returns the value associated with the parameter {@code Attributes.Name} - * key. - * - * @param name - * the key to obtain the value for. - * @return the {@code String} associated with name, or {@code null} if name - * is not a valid key. - */ - public String getValue(Attributes.Name name) { - return (String) map.get(name); - } - - /** - * Returns the string associated with the parameter name. - * - * @param name - * the key to obtain the value for. - * @return the string associated with name, or {@code null} if name is not a - * valid key. - */ - public String getValue(String name) { - return (String) map.get(new Attributes.Name(name)); - } - - /** - * Stores the value {@code val} associated with the key {@code name} in this - * {@code Attributes}. - * - * @param name - * the key to store. - * @param val - * the value to store in this {@code Attributes}. - * @return the value being stored. - */ - public String putValue(String name, String val) { - return (String) map.put(new Attributes.Name(name), val); - } -} diff --git a/libcore/archive/src/main/java/java/util/jar/InitManifest.java b/libcore/archive/src/main/java/java/util/jar/InitManifest.java deleted file mode 100644 index bf9c397a6..000000000 --- a/libcore/archive/src/main/java/java/util/jar/InitManifest.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.jar; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.charset.CharsetDecoder; -import java.nio.charset.CoderResult; -import java.util.Map; - -import org.apache.harmony.archive.internal.nls.Messages; -import org.apache.harmony.luni.util.ThreadLocalCache; - -class InitManifest { - - private byte[] buf; - - private int pos; - - Attributes.Name name; - - String value; - - CharsetDecoder decoder = ThreadLocalCache.utf8Decoder.get(); - CharBuffer cBuf = ThreadLocalCache.charBuffer.get(); - - InitManifest(byte[] buf, Attributes main, Attributes.Name ver) - throws IOException { - - this.buf = buf; - - // check a version attribute - if (!readHeader() || (ver != null && !name.equals(ver))) { - throw new IOException(Messages.getString( - "archive.2D", ver)); //$NON-NLS-1$ - } - - main.put(name, value); - while (readHeader()) { - main.put(name, value); - } - } - - void initEntries(Map entries, - Map chunks) throws IOException { - - int mark = pos; - while (readHeader()) { - if (!Attributes.Name.NAME.equals(name)) { - throw new IOException(Messages.getString("archive.23")); //$NON-NLS-1$ - } - String entryNameValue = value; - - Attributes entry = entries.get(entryNameValue); - if (entry == null) { - entry = new Attributes(12); - } - - while (readHeader()) { - entry.put(name, value); - } - - if (chunks != null) { - if (chunks.get(entryNameValue) != null) { - // TODO A bug: there might be several verification chunks for - // the same name. I believe they should be used to update - // signature in order of appearance; there are two ways to fix - // this: either use a list of chunks, or decide on used - // signature algorithm in advance and reread the chunks while - // updating the signature; for now a defensive error is thrown - throw new IOException(Messages.getString("archive.34")); //$NON-NLS-1$ - } - chunks.put(entryNameValue, new Manifest.Chunk(mark, pos)); - mark = pos; - } - - entries.put(entryNameValue, entry); - } - } - - int getPos() { - return pos; - } - - /** - * Number of subsequent line breaks. - */ - int linebreak = 0; - - /** - * Read a single line from the manifest buffer. - */ - private boolean readHeader() throws IOException { - if (linebreak > 1) { - // break a section on an empty line - linebreak = 0; - return false; - } - readName(); - linebreak = 0; - readValue(); - // if the last line break is missed, the line - // is ignored by the reference implementation - return linebreak > 0; - } - - private byte[] wrap(int mark, int pos) { - byte[] buffer = new byte[pos - mark]; - System.arraycopy(buf, mark, buffer, 0, pos - mark); - return buffer; - } - - private void readName() throws IOException { - int i = 0; - int mark = pos; - - while (pos < buf.length) { - byte b = buf[pos++]; - - if (b == ':') { - byte[] nameBuffer = wrap(mark, pos - 1); - - if (buf[pos++] != ' ') { - throw new IOException(Messages.getString( - "archive.30", nameBuffer)); //$NON-NLS-1$ - } - - name = new Attributes.Name(nameBuffer); - return; - } - - if (!((b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || b == '_' - || b == '-' || (b >= '0' && b <= '9'))) { - throw new IOException(Messages.getString("archive.30", b)); //$NON-NLS-1$ - } - } - if (i > 0) { - throw new IOException(Messages.getString( - "archive.30", wrap(mark, buf.length))); //$NON-NLS-1$ - } - } - - private void readValue() throws IOException { - byte next; - boolean lastCr = false; - int mark = pos; - int last = pos; - - decoder.reset(); - cBuf.clear(); - - while (pos < buf.length) { - next = buf[pos++]; - - switch (next) { - case 0: - throw new IOException(Messages.getString("archive.2F")); //$NON-NLS-1$ - case '\n': - if (lastCr) { - lastCr = false; - } else { - linebreak++; - } - continue; - case '\r': - lastCr = true; - linebreak++; - continue; - case ' ': - if (linebreak == 1) { - decode(mark, last, false); - mark = pos; - linebreak = 0; - continue; - } - } - - if (linebreak >= 1) { - pos--; - break; - } - last = pos; - } - - decode(mark, last, true); - while (CoderResult.OVERFLOW == decoder.flush(cBuf)) { - enlargeBuffer(); - } - value = new String(cBuf.array(), cBuf.arrayOffset(), cBuf.position()); - } - - private void decode(int mark, int pos, boolean endOfInput) - throws IOException { - ByteBuffer bBuf = ByteBuffer.wrap(buf, mark, pos - mark); - while (CoderResult.OVERFLOW == decoder.decode(bBuf, cBuf, endOfInput)) { - enlargeBuffer(); - } - } - - private void enlargeBuffer() { - CharBuffer newBuf = CharBuffer.allocate(cBuf.capacity() * 2); - newBuf.put(cBuf.array(), cBuf.arrayOffset(), cBuf.position()); - cBuf = newBuf; - ThreadLocalCache.charBuffer.set(cBuf); - } -} diff --git a/libcore/archive/src/main/java/java/util/jar/JarEntry.java b/libcore/archive/src/main/java/java/util/jar/JarEntry.java deleted file mode 100644 index 869e4b4fb..000000000 --- a/libcore/archive/src/main/java/java/util/jar/JarEntry.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.jar; - -import java.io.IOException; -import java.security.CodeSigner; -import java.security.cert.CertPath; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.List; -import java.util.zip.ZipEntry; - -import javax.security.auth.x500.X500Principal; - -/** - * Represents a single file in a JAR archive together with the manifest - * attributes and digital signatures associated with it. - * - * @see JarFile - * @see JarInputStream - */ -public class JarEntry extends ZipEntry { - private Attributes attributes; - - JarFile parentJar; - - CodeSigner signers[]; - - // Cached factory used to build CertPath-s in getCodeSigners(). - private CertificateFactory factory; - - private boolean isFactoryChecked = false; - - /** - * Creates a new {@code JarEntry} named name. - * - * @param name - * The name of the new {@code JarEntry}. - */ - public JarEntry(String name) { - super(name); - } - - /** - * Creates a new {@code JarEntry} using the values obtained from entry. - * - * @param entry - * The ZipEntry to obtain values from. - */ - public JarEntry(ZipEntry entry) { - super(entry); - } - - /** - * Returns the {@code Attributes} object associated with this entry or - * {@code null} if none exists. - * - * @return the {@code Attributes} for this entry. - * @exception IOException - * If an error occurs obtaining the {@code Attributes}. - * @see Attributes - */ - public Attributes getAttributes() throws IOException { - if (attributes != null || parentJar == null) { - return attributes; - } - Manifest manifest = parentJar.getManifest(); - if (manifest == null) { - return null; - } - return attributes = manifest.getAttributes(getName()); - } - - /** - * Returns an array of {@code Certificate} Objects associated with this - * entry or {@code null} if none exists. Make sure that the everything is - * read from the input stream before calling this method, or else the method - * returns {@code null}. - * - * @return the certificate for this entry. - * @see java.security.cert.Certificate - */ - public Certificate[] getCertificates() { - if (null == parentJar) { - return null; - } - JarVerifier jarVerifier = parentJar.verifier; - if (null == jarVerifier) { - return null; - } - return jarVerifier.getCertificates(getName()); - } - - void setAttributes(Attributes attrib) { - attributes = attrib; - } - - /** - * Create a new {@code JarEntry} using the values obtained from the - * argument. - * - * @param je - * The {@code JarEntry} to obtain values from. - */ - public JarEntry(JarEntry je) { - super(je); - parentJar = je.parentJar; - attributes = je.attributes; - signers = je.signers; - } - - /** - * Returns the code signers for the digital signatures associated with the - * JAR file. If there is no such code signer, it returns {@code null}. Make - * sure that the everything is read from the input stream before calling - * this method, or else the method returns {@code null}. - * - * @return the code signers for the JAR entry. - * @see CodeSigner - */ - public CodeSigner[] getCodeSigners() { - if (null == signers) { - signers = getCodeSigners(getCertificates()); - } - if (null == signers) { - return null; - } - - CodeSigner[] tmp = new CodeSigner[signers.length]; - System.arraycopy(signers, 0, tmp, 0, tmp.length); - return tmp; - } - - private CodeSigner[] getCodeSigners(Certificate[] certs) { - if (null == certs) { - return null; - } - - X500Principal prevIssuer = null; - ArrayList list = new ArrayList(certs.length); - ArrayList asigners = new ArrayList(); - - for (Certificate element : certs) { - if (!(element instanceof X509Certificate)) { - // Only X509Certificate-s are taken into account - see API spec. - continue; - } - X509Certificate x509 = (X509Certificate) element; - if (null != prevIssuer) { - X500Principal subj = x509.getSubjectX500Principal(); - if (!prevIssuer.equals(subj)) { - // Ok, this ends the previous chain, - // so transform this one into CertPath ... - addCodeSigner(asigners, list); - // ... and start a new one - list.clear(); - }// else { it's still the same chain } - - } - prevIssuer = x509.getIssuerX500Principal(); - list.add(x509); - } - if (!list.isEmpty()) { - addCodeSigner(asigners, list); - } - if (asigners.isEmpty()) { - // 'signers' is 'null' already - return null; - } - - CodeSigner[] tmp = new CodeSigner[asigners.size()]; - asigners.toArray(tmp); - return tmp; - - } - - private void addCodeSigner(ArrayList asigners, - List list) { - CertPath certPath = null; - if (!isFactoryChecked) { - try { - factory = CertificateFactory.getInstance("X.509"); //$NON-NLS-1$ - } catch (CertificateException ex) { - // do nothing - } finally { - isFactoryChecked = true; - } - } - if (null == factory) { - return; - } - try { - certPath = factory.generateCertPath(list); - } catch (CertificateException ex) { - // do nothing - } - if (null != certPath) { - asigners.add(new CodeSigner(certPath, null)); - } - } -} diff --git a/libcore/archive/src/main/java/java/util/jar/JarException.java b/libcore/archive/src/main/java/java/util/jar/JarException.java deleted file mode 100644 index d6943c475..000000000 --- a/libcore/archive/src/main/java/java/util/jar/JarException.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.jar; - -import java.util.zip.ZipException; - -/** - * This runtime exception is thrown when a problem occurs while reading a JAR - * file. - */ -public class JarException extends ZipException { - - private static final long serialVersionUID = 7159778400963954473L; - - /** - * Constructs a new {@code JarException} instance. - */ - public JarException() { - super(); - } - - /** - * Constructs a new {@code JarException} instance with the specified - * message. - * - * @param detailMessage - * the detail message for the exception. - */ - public JarException(String detailMessage) { - super(detailMessage); - } -} diff --git a/libcore/archive/src/main/java/java/util/jar/JarFile.java b/libcore/archive/src/main/java/java/util/jar/JarFile.java deleted file mode 100644 index 6f4eb836e..000000000 --- a/libcore/archive/src/main/java/java/util/jar/JarFile.java +++ /dev/null @@ -1,497 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.jar; - -// BEGIN android-removed -// import java.io.ByteArrayInputStream; -// END android-removed -// BEGIN android-added -import java.io.ByteArrayOutputStream; -import java.util.List; -import java.util.ArrayList; -// END android-added -import java.io.File; -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Enumeration; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import org.apache.harmony.archive.util.Util; - -/** - * {@code JarFile} is used to read jar entries and their associated data from - * jar files. - * - * @see JarInputStream - * @see JarEntry - */ -public class JarFile extends ZipFile { - - /** - * The MANIFEST file name. - */ - public static final String MANIFEST_NAME = "META-INF/MANIFEST.MF"; //$NON-NLS-1$ - - static final String META_DIR = "META-INF/"; //$NON-NLS-1$ - - private Manifest manifest; - - private ZipEntry manifestEntry; - - JarVerifier verifier; - - // BEGIN android-added - private boolean closed = false; - // END android-added - - static final class JarFileInputStream extends FilterInputStream { - private long count; - - private ZipEntry zipEntry; - - private JarVerifier.VerifierEntry entry; - - // BEGIN android-added - private boolean done = false; - // END android-added - - JarFileInputStream(InputStream is, ZipEntry ze, - JarVerifier.VerifierEntry e) { - super(is); - zipEntry = ze; - count = zipEntry.getSize(); - entry = e; - } - - @Override - public int read() throws IOException { - // BEGIN android-changed - if (done) { - return -1; - } - if (count > 0) { - int r = super.read(); - if (r != -1) { - entry.write(r); - count--; - } else { - count = 0; - } - if (count == 0) { - done = true; - entry.verify(); - } - return r; - } else { - done = true; - entry.verify(); - return -1; - } - // END android-changed - } - - @Override - public int read(byte[] buf, int off, int nbytes) throws IOException { - // BEGIN android-changed - if (done) { - return -1; - } - if (count > 0) { - int r = super.read(buf, off, nbytes); - if (r != -1) { - int size = r; - if (count < size) { - size = (int) count; - } - entry.write(buf, off, size); - count -= size; - } else { - count = 0; - } - if (count == 0) { - done = true; - entry.verify(); - } - return r; - } else { - done = true; - entry.verify(); - return -1; - } - // END android-changed - } - - // BEGIN android-added - @Override - public int available() throws IOException { - if (done) { - return 0; - } - return super.available(); - } - // END android-added - - @Override - public long skip(long nbytes) throws IOException { - long cnt = 0, rem = 0; - byte[] buf = new byte[4096]; - while (cnt < nbytes) { - int x = read(buf, 0, - (rem = nbytes - cnt) > buf.length ? buf.length - : (int) rem); - if (x == -1) { - return cnt; - } - cnt += x; - } - return cnt; - } - } - - /** - * Create a new {@code JarFile} using the contents of the specified file. - * - * @param file - * the JAR file as {@link File}. - * @throws IOException - * If the file cannot be read. - */ - public JarFile(File file) throws IOException { - this(file, true); - } - - /** - * Create a new {@code JarFile} using the contents of the specified file. - * - * @param file - * the JAR file as {@link File}. - * @param verify - * if this JAR file is signed whether it must be verified. - * @throws IOException - * If the file cannot be read. - */ - public JarFile(File file, boolean verify) throws IOException { - super(file); - if (verify) { - verifier = new JarVerifier(file.getPath()); - } - readMetaEntries(); - } - - /** - * Create a new {@code JarFile} using the contents of file. - * - * @param file - * the JAR file as {@link File}. - * @param verify - * if this JAR filed is signed whether it must be verified. - * @param mode - * the mode to use, either {@link ZipFile#OPEN_READ OPEN_READ} or - * {@link ZipFile#OPEN_DELETE OPEN_DELETE}. - * @throws IOException - * If the file cannot be read. - */ - public JarFile(File file, boolean verify, int mode) throws IOException { - super(file, mode); - if (verify) { - verifier = new JarVerifier(file.getPath()); - } - readMetaEntries(); - } - - /** - * Create a new {@code JarFile} from the contents of the file specified by - * filename. - * - * @param filename - * the file name referring to the JAR file. - * @throws IOException - * if file name cannot be opened for reading. - */ - public JarFile(String filename) throws IOException { - this(filename, true); - - } - - /** - * Create a new {@code JarFile} from the contents of the file specified by - * {@code filename}. - * - * @param filename - * the file name referring to the JAR file. - * @param verify - * if this JAR filed is signed whether it must be verified. - * @throws IOException - * If file cannot be opened or read. - */ - public JarFile(String filename, boolean verify) throws IOException { - super(filename); - if (verify) { - verifier = new JarVerifier(filename); - } - readMetaEntries(); - } - - /** - * Return an enumeration containing the {@code JarEntrys} contained in this - * {@code JarFile}. - * - * @return the {@code Enumeration} containing the JAR entries. - * @throws IllegalStateException - * if this {@code JarFile} is closed. - */ - @Override - public Enumeration entries() { - class JarFileEnumerator implements Enumeration { - Enumeration ze; - - JarFile jf; - - JarFileEnumerator(Enumeration zenum, JarFile jf) { - ze = zenum; - this.jf = jf; - } - - public boolean hasMoreElements() { - return ze.hasMoreElements(); - } - - public JarEntry nextElement() { - JarEntry je = new JarEntry(ze.nextElement()); - je.parentJar = jf; - return je; - } - } - return new JarFileEnumerator(super.entries(), this); - } - - /** - * Return the {@code JarEntry} specified by its name or {@code null} if no - * such entry exists. - * - * @param name - * the name of the entry in the JAR file. - * @return the JAR entry defined by the name. - */ - public JarEntry getJarEntry(String name) { - return (JarEntry) getEntry(name); - } - - - // BEGIN android-added - private byte[] getAllBytesFromStreamAndClose(InputStream is) throws IOException { - ByteArrayOutputStream bs = new ByteArrayOutputStream(); - try { - byte[] buf = new byte[666]; - int iRead; int off; - while (is.available() > 0) { - iRead = is.read(buf, 0, buf.length); - if (iRead > 0) - bs.write(buf, 0, iRead); - } - } finally { - is.close(); - } - return bs.toByteArray(); - } - // END android-added - - /** - * Returns the {@code Manifest} object associated with this {@code JarFile} - * or {@code null} if no MANIFEST entry exists. - * - * @return the MANIFEST. - * @throws IOException - * if an error occurs reading the MANIFEST file. - * @throws IllegalStateException - * if the jar file is closed. - * @see Manifest - */ - public Manifest getManifest() throws IOException { - // BEGIN android-added - if (closed) { - throw new IllegalStateException("JarFile has been closed."); - } - // END android-added - if (manifest != null) { - return manifest; - } - try { - // BEGIN android-modified - InputStream is = super.getInputStream(manifestEntry); - if (verifier != null) { - verifier.addMetaEntry(manifestEntry.getName(), getAllBytesFromStreamAndClose(is)); - is = super.getInputStream(manifestEntry); - } - // END android-modified - try { - manifest = new Manifest(is, verifier != null); - } finally { - is.close(); - } - manifestEntry = null; - } catch(NullPointerException e) { - manifestEntry = null; - } - return manifest; - } - - private void readMetaEntries() throws IOException { - ZipEntry[] metaEntries = getMetaEntriesImpl(null); - int dirLength = META_DIR.length(); - - boolean signed = false; - - if (null != metaEntries) { - for (ZipEntry entry : metaEntries) { - String entryName = entry.getName(); - if (manifestEntry == null - && manifest == null - && Util.ASCIIIgnoreCaseRegionMatches(entryName, - dirLength, MANIFEST_NAME, dirLength, - MANIFEST_NAME.length() - dirLength)) { - manifestEntry = entry; - if (verifier == null) { - break; - } - } else if (verifier != null - && entryName.length() > dirLength - && (Util.ASCIIIgnoreCaseRegionMatches(entryName, - entryName.length() - 3, ".SF", 0, 3) //$NON-NLS-1$ - || Util.ASCIIIgnoreCaseRegionMatches(entryName, - entryName.length() - 4, ".DSA", 0, 4) //$NON-NLS-1$ - || Util.ASCIIIgnoreCaseRegionMatches(entryName, - entryName.length() - 4, ".RSA", 0, 4))) { //$NON-NLS-1$ - signed = true; - InputStream is = super.getInputStream(entry); - // BEGIN android-modified - byte[] buf = getAllBytesFromStreamAndClose(is); - // END android-modified - verifier.addMetaEntry(entryName, buf); - } - } - } - if (!signed) { - verifier = null; - } - } - - /** - * Return an {@code InputStream} for reading the decompressed contents of - * ZIP entry. - * - * @param ze - * the ZIP entry to be read. - * @return the input stream to read from. - * @throws IOException - * if an error occurred while creating the input stream. - */ - @Override - public InputStream getInputStream(ZipEntry ze) throws IOException { - if (manifestEntry != null) { - getManifest(); - } - if (verifier != null) { - verifier.setManifest(getManifest()); - if (manifest != null) { - verifier.mainAttributesEnd = manifest.getMainAttributesEnd(); - } - if (verifier.readCertificates()) { - verifier.removeMetaEntries(); - if (manifest != null) { - manifest.removeChunks(); - } - if (!verifier.isSignedJar()) { - verifier = null; - } - } - } - InputStream in = super.getInputStream(ze); - if (in == null) { - return null; - } - if (verifier == null || ze.getSize() == -1) { - return in; - } - JarVerifier.VerifierEntry entry = verifier.initEntry(ze.getName()); - if (entry == null) { - return in; - } - return new JarFileInputStream(in, ze, entry); - } - - /** - * Return the {@code JarEntry} specified by name or {@code null} if no such - * entry exists. - * - * @param name - * the name of the entry in the JAR file. - * @return the ZIP entry extracted. - */ - @Override - public ZipEntry getEntry(String name) { - ZipEntry ze = super.getEntry(name); - if (ze == null) { - return ze; - } - JarEntry je = new JarEntry(ze); - je.parentJar = this; - return je; - } - - // BEGIN android-modified - private ZipEntry[] getMetaEntriesImpl(byte[] buf) { - int n = 0; - - List list = new ArrayList(); - - Enumeration allEntries = entries(); - while (allEntries.hasMoreElements()) { - ZipEntry ze = allEntries.nextElement(); - if (ze.getName().startsWith("META-INF/") && ze.getName().length() > 9) { - list.add(ze); - } - } - if (list.size() != 0) { - ZipEntry[] result = new ZipEntry[list.size()]; - list.toArray(result); - return result; - } - else { - return null; - } - } - // END android-modified - - // BEGIN android-added - /** - * Closes this {@code JarFile}. - * - * @throws IOException - * if an error occurs. - */ - @Override - public void close() throws IOException { - super.close(); - closed = true; - } - // END android-added - -} diff --git a/libcore/archive/src/main/java/java/util/jar/JarInputStream.java b/libcore/archive/src/main/java/java/util/jar/JarInputStream.java deleted file mode 100644 index c803183c7..000000000 --- a/libcore/archive/src/main/java/java/util/jar/JarInputStream.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.jar; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -import org.apache.harmony.luni.util.Util; - -/** - * The input stream from which the JAR file to be read may be fetched. It is - * used like the {@code ZipInputStream}. - * - * @see ZipInputStream - */ -public class JarInputStream extends ZipInputStream { - - private Manifest manifest; - - private boolean eos = false; - - private JarEntry mEntry; - - private JarEntry jarEntry; - - private boolean isMeta; - - private JarVerifier verifier; - - private OutputStream verStream; - - /** - * Constructs a new {@code JarInputStream} from an input stream. - * - * @param stream - * the input stream containing the JAR file. - * @param verify - * if the file should be verified with a {@code JarVerifier}. - * @throws IOException - * If an error occurs reading entries from the input stream. - * @see ZipInputStream#ZipInputStream(InputStream) - */ - public JarInputStream(InputStream stream, boolean verify) - throws IOException { - super(stream); - if (verify) { - verifier = new JarVerifier("JarInputStream"); //$NON-NLS-1$ - } - if ((mEntry = getNextJarEntry()) == null) { - return; - } - String name = Util.toASCIIUpperCase(mEntry.getName()); - if (name.equals(JarFile.META_DIR)) { - mEntry = null; // modifies behavior of getNextJarEntry() - closeEntry(); - mEntry = getNextJarEntry(); - name = mEntry.getName().toUpperCase(); - } - if (name.equals(JarFile.MANIFEST_NAME)) { - mEntry = null; - manifest = new Manifest(this, verify); - closeEntry(); - if (verify) { - verifier.setManifest(manifest); - if (manifest != null) { - verifier.mainAttributesEnd = manifest - .getMainAttributesEnd(); - } - } - - } else { - Attributes temp = new Attributes(3); - temp.map.put("hidden", null); //$NON-NLS-1$ - mEntry.setAttributes(temp); - /* - * if not from the first entry, we will not get enough - * information,so no verify will be taken out. - */ - verifier = null; - } - } - - /** - * Constructs a new {@code JarInputStream} from an input stream. - * - * @param stream - * the input stream containing the JAR file. - * @throws IOException - * If an error occurs reading entries from the input stream. - * @see ZipInputStream#ZipInputStream(InputStream) - */ - public JarInputStream(InputStream stream) throws IOException { - this(stream, true); - } - - /** - * Returns the {@code Manifest} object associated with this {@code - * JarInputStream} or {@code null} if no manifest entry exists. - * - * @return the MANIFEST specifying the contents of the JAR file. - */ - public Manifest getManifest() { - return manifest; - } - - /** - * Returns the next {@code JarEntry} contained in this stream or {@code - * null} if no more entries are present. - * - * @return the next JAR entry. - * @throws IOException - * if an error occurs while reading the entry. - */ - public JarEntry getNextJarEntry() throws IOException { - return (JarEntry) getNextEntry(); - } - - /** - * Reads up to {@code length} of decompressed data and stores it in - * {@code buffer} starting at {@code offset}. - * - * @param buffer - * Buffer to store into - * @param offset - * offset in buffer to store at - * @param length - * number of bytes to store - * @return Number of uncompressed bytes read - * @throws IOException - * if an IOException occurs. - */ - @Override - public int read(byte[] buffer, int offset, int length) throws IOException { - if (mEntry != null) { - return -1; - } - int r = super.read(buffer, offset, length); - if (verStream != null && !eos) { - if (r == -1) { - eos = true; - if (verifier != null) { - if (isMeta) { - verifier.addMetaEntry(jarEntry.getName(), - ((ByteArrayOutputStream) verStream) - .toByteArray()); - try { - verifier.readCertificates(); - } catch (SecurityException e) { - verifier = null; - throw e; - } - } else { - ((JarVerifier.VerifierEntry) verStream).verify(); - } - } - } else { - verStream.write(buffer, offset, r); - } - } - return r; - } - - /** - * Returns the next {@code ZipEntry} contained in this stream or {@code - * null} if no more entries are present. - * - * @return the next extracted ZIP entry. - * @throws IOException - * if an error occurs while reading the entry. - */ - @Override - public ZipEntry getNextEntry() throws IOException { - if (mEntry != null) { - jarEntry = mEntry; - mEntry = null; - jarEntry.setAttributes(null); - } else { - jarEntry = (JarEntry) super.getNextEntry(); - if (jarEntry == null) { - return null; - } - if (verifier != null) { - isMeta = Util.toASCIIUpperCase(jarEntry.getName()).startsWith( - JarFile.META_DIR); - if (isMeta) { - verStream = new ByteArrayOutputStream(); - } else { - verStream = verifier.initEntry(jarEntry.getName()); - } - } - } - eos = false; - return jarEntry; - } - - @Override - protected ZipEntry createZipEntry(String name) { - JarEntry entry = new JarEntry(name); - if (manifest != null) { - entry.setAttributes(manifest.getAttributes(name)); - } - return entry; - } -} diff --git a/libcore/archive/src/main/java/java/util/jar/JarOutputStream.java b/libcore/archive/src/main/java/java/util/jar/JarOutputStream.java deleted file mode 100644 index e901d87e4..000000000 --- a/libcore/archive/src/main/java/java/util/jar/JarOutputStream.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.jar; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - -/** - * The {@code JarOutputStream} is used to write data in the {@code JarFile} - * format to an arbitrary output stream - */ -public class JarOutputStream extends ZipOutputStream { - - private Manifest manifest; - - /** - * Constructs a new {@code JarOutputStream} using an output stream. The - * content of the {@code Manifest} must match the JAR entry information - * written subsequently to the stream. - * - * @param os - * the {@code OutputStream} to write to - * @param mf - * the {@code Manifest} to output for this JAR file. - * @throws IOException - * if an error occurs creating the {@code JarOutputStream}. - */ - public JarOutputStream(OutputStream os, Manifest mf) throws IOException { - super(os); - if (mf == null) { - throw new NullPointerException(); - } - manifest = mf; - ZipEntry ze = new ZipEntry(JarFile.MANIFEST_NAME); - putNextEntry(ze); - manifest.write(this); - closeEntry(); - } - - /** - * Constructs a new {@code JarOutputStream} using an arbitrary output - * stream. - * - * @param os - * the {@code OutputStream} to write to. - * @throws IOException - * if an error occurs creating the {@code JarOutputStream}. - */ - @SuppressWarnings("unused") - public JarOutputStream(OutputStream os) throws IOException { - super(os); - } - - /** - * Writes the specified ZIP entry to the underlying stream. The previous - * entry is closed if it is still open. - * - * @param ze - * the {@code ZipEntry} to write to. - * @throws IOException - * if an error occurs writing to the entry. - * @see ZipEntry - */ - @Override - public void putNextEntry(ZipEntry ze) throws IOException { - super.putNextEntry(ze); - } -} diff --git a/libcore/archive/src/main/java/java/util/jar/JarVerifier.java b/libcore/archive/src/main/java/java/util/jar/JarVerifier.java deleted file mode 100644 index 6c1ee93c6..000000000 --- a/libcore/archive/src/main/java/java/util/jar/JarVerifier.java +++ /dev/null @@ -1,497 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.jar; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.security.GeneralSecurityException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.security.cert.Certificate; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.Vector; - -import org.apache.harmony.archive.internal.nls.Messages; -import org.apache.harmony.luni.util.Base64; -import org.apache.harmony.security.utils.JarUtils; - -import org.apache.harmony.luni.util.Util; - -// BEGIN android-added -import org.apache.harmony.xnet.provider.jsse.OpenSSLMessageDigestJDK; -// END android-added - -/** - * Non-public class used by {@link JarFile} and {@link JarInputStream} to manage - * the verification of signed JARs. {@code JarFile} and {@code JarInputStream} - * objects are expected to have a {@code JarVerifier} instance member which - * can be used to carry out the tasks associated with verifying a signed JAR. - * These tasks would typically include: - *
    - *
  • verification of all signed signature files - *
  • confirmation that all signed data was signed only by the party or parties - * specified in the signature block data - *
  • verification that the contents of all signature files (i.e. {@code .SF} - * files) agree with the JAR entries information found in the JAR manifest. - *
- */ -class JarVerifier { - - private final String jarName; - - private Manifest man; - - private HashMap metaEntries = new HashMap(5); - - private final Hashtable> signatures = new Hashtable>( - 5); - - private final Hashtable certificates = new Hashtable( - 5); - - private final Hashtable verifiedEntries = new Hashtable(); - - int mainAttributesEnd; - - /** - * Stores and a hash and a message digest and verifies that massage digest - * matches the hash. - */ - class VerifierEntry extends OutputStream { - - private String name; - - private MessageDigest digest; - - private byte[] hash; - - private Certificate[] certificates; - - VerifierEntry(String name, MessageDigest digest, byte[] hash, - Certificate[] certificates) { - this.name = name; - this.digest = digest; - this.hash = hash; - this.certificates = certificates; - } - - /** - * Updates a digest with one byte. - */ - @Override - public void write(int value) { - digest.update((byte) value); - } - - /** - * Updates a digest with byte array. - */ - @Override - public void write(byte[] buf, int off, int nbytes) { - digest.update(buf, off, nbytes); - } - - /** - * Verifies that the digests stored in the manifest match the decrypted - * digests from the .SF file. This indicates the validity of the - * signing, not the integrity of the file, as it's digest must be - * calculated and verified when its contents are read. - * - * @throws SecurityException - * if the digest value stored in the manifest does not - * agree with the decrypted digest as recovered from the - * .SF file. - * @see #initEntry(String) - */ - void verify() { - byte[] d = digest.digest(); - if (!MessageDigest.isEqual(d, Base64.decode(hash))) { - throw new SecurityException(Messages.getString( - "archive.32", new Object[] { //$NON-NLS-1$ - JarFile.MANIFEST_NAME, name, jarName })); - } - verifiedEntries.put(name, certificates); - } - - } - - /** - * Constructs and returns a new instance of {@code JarVerifier}. - * - * @param name - * the name of the JAR file being verified. - */ - JarVerifier(String name) { - jarName = name; - } - - /** - * Invoked for each new JAR entry read operation from the input - * stream. This method constructs and returns a new {@link VerifierEntry} - * which contains the certificates used to sign the entry and its hash value - * as specified in the JAR MANIFEST format. - * - * @param name - * the name of an entry in a JAR file which is not in the - * {@code META-INF} directory. - * @return a new instance of {@link VerifierEntry} which can be used by - * callers as an {@link OutputStream}. - */ - VerifierEntry initEntry(String name) { - // If no manifest is present by the time an entry is found, - // verification cannot occur. If no signature files have - // been found, do not verify. - if (man == null || signatures.size() == 0) { - return null; - } - - Attributes attributes = man.getAttributes(name); - // entry has no digest - if (attributes == null) { - return null; - } - - Vector certs = new Vector(); - Iterator>> it = signatures - .entrySet().iterator(); - while (it.hasNext()) { - Map.Entry> entry = it.next(); - HashMap hm = entry.getValue(); - if (hm.get(name) != null) { - // Found an entry for entry name in .SF file - String signatureFile = entry.getKey(); - - Vector newCerts = getSignerCertificates( - signatureFile, certificates); - Iterator iter = newCerts.iterator(); - while (iter.hasNext()) { - certs.add(iter.next()); - } - } - } - - // entry is not signed - if (certs.size() == 0) { - return null; - } - Certificate[] certificatesArray = new Certificate[certs.size()]; - certs.toArray(certificatesArray); - - String algorithms = attributes.getValue("Digest-Algorithms"); //$NON-NLS-1$ - if (algorithms == null) { - algorithms = "SHA SHA1"; //$NON-NLS-1$ - } - StringTokenizer tokens = new StringTokenizer(algorithms); - while (tokens.hasMoreTokens()) { - String algorithm = tokens.nextToken(); - String hash = attributes.getValue(algorithm + "-Digest"); //$NON-NLS-1$ - if (hash == null) { - continue; - } - byte[] hashBytes; - try { - hashBytes = hash.getBytes("ISO-8859-1"); //$NON-NLS-1$ - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e.toString()); - } - - try { - // BEGIN android-changed - return new VerifierEntry(name, OpenSSLMessageDigestJDK.getInstance(algorithm), - hashBytes, certificatesArray); - // END android-changed - } catch (NoSuchAlgorithmException e) { - // ignored - } - } - return null; - } - - /** - * Add a new meta entry to the internal collection of data held on each JAR - * entry in the {@code META-INF} directory including the manifest - * file itself. Files associated with the signing of a JAR would also be - * added to this collection. - * - * @param name - * the name of the file located in the {@code META-INF} - * directory. - * @param buf - * the file bytes for the file called {@code name}. - * @see #removeMetaEntries() - */ - void addMetaEntry(String name, byte[] buf) { - metaEntries.put(Util.toASCIIUpperCase(name), buf); - } - - /** - * If the associated JAR file is signed, check on the validity of all of the - * known signatures. - * - * @return {@code true} if the associated JAR is signed and an internal - * check verifies the validity of the signature(s). {@code false} if - * the associated JAR file has no entries at all in its {@code - * META-INF} directory. This situation is indicative of an invalid - * JAR file. - *

- * Will also return {@code true} if the JAR file is not - * signed. - * @throws SecurityException - * if the JAR file is signed and it is determined that a - * signature block file contains an invalid signature for the - * corresponding signature file. - */ - synchronized boolean readCertificates() { - if (metaEntries == null) { - return false; - } - Iterator it = metaEntries.keySet().iterator(); - while (it.hasNext()) { - String key = it.next(); - if (key.endsWith(".DSA") || key.endsWith(".RSA")) { //$NON-NLS-1$ //$NON-NLS-2$ - verifyCertificate(key); - // Check for recursive class load - if (metaEntries == null) { - return false; - } - it.remove(); - } - } - return true; - } - - /** - * @param certFile - */ - private void verifyCertificate(String certFile) { - // Found Digital Sig, .SF should already have been read - String signatureFile = certFile.substring(0, certFile.lastIndexOf('.')) - + ".SF"; //$NON-NLS-1$ - byte[] sfBytes = metaEntries.get(signatureFile); - if (sfBytes == null) { - return; - } - - byte[] manifest = metaEntries.get(JarFile.MANIFEST_NAME); - // Manifest entry is required for any verifications. - if (manifest == null) { - return; - } - - byte[] sBlockBytes = metaEntries.get(certFile); - try { - Certificate[] signerCertChain = JarUtils.verifySignature( - new ByteArrayInputStream(sfBytes), - new ByteArrayInputStream(sBlockBytes)); - /* - * Recursive call in loading security provider related class which - * is in a signed JAR. - */ - if (null == metaEntries) { - return; - } - if (signerCertChain != null) { - certificates.put(signatureFile, signerCertChain); - } - } catch (IOException e) { - return; - } catch (GeneralSecurityException e) { - /* [MSG "archive.31", "{0} failed verification of {1}"] */ - throw new SecurityException(Messages.getString( - "archive.31", jarName, signatureFile)); //$NON-NLS-1$ - } - - // Verify manifest hash in .sf file - Attributes attributes = new Attributes(); - HashMap entries = new HashMap(); - try { - InitManifest im = new InitManifest(sfBytes, attributes, Attributes.Name.SIGNATURE_VERSION); - im.initEntries(entries, null); - } catch (IOException e) { - return; - } - - boolean createdBySigntool = false; - String createdBy = attributes.getValue("Created-By"); //$NON-NLS-1$ - if (createdBy != null) { - createdBySigntool = createdBy.indexOf("signtool") != -1; //$NON-NLS-1$ - } - - // Use .SF to verify the mainAttributes of the manifest - // If there is no -Digest-Manifest-Main-Attributes entry in .SF - // file, such as those created before java 1.5, then we ignore - // such verification. - if (mainAttributesEnd > 0 && !createdBySigntool) { - String digestAttribute = "-Digest-Manifest-Main-Attributes"; //$NON-NLS-1$ - if (!verify(attributes, digestAttribute, manifest, 0, - mainAttributesEnd, false, true)) { - /* [MSG "archive.31", "{0} failed verification of {1}"] */ - throw new SecurityException(Messages.getString( - "archive.31", jarName, signatureFile)); //$NON-NLS-1$ - } - } - - // Use .SF to verify the whole manifest. - String digestAttribute = createdBySigntool ? "-Digest" //$NON-NLS-1$ - : "-Digest-Manifest"; //$NON-NLS-1$ - if (!verify(attributes, digestAttribute, manifest, 0, manifest.length, - false, false)) { - Iterator> it = entries.entrySet() - .iterator(); - while (it.hasNext()) { - Map.Entry entry = it.next(); - Manifest.Chunk chunk = man.getChunk(entry.getKey()); - if (chunk == null) { - return; - } - if (!verify(entry.getValue(), "-Digest", manifest, //$NON-NLS-1$ - chunk.start, chunk.end, createdBySigntool, false)) { - throw new SecurityException(Messages.getString( - "archive.32", //$NON-NLS-1$ - new Object[] { signatureFile, entry.getKey(), - jarName })); - } - } - } - metaEntries.put(signatureFile, null); - signatures.put(signatureFile, entries); - } - - /** - * Associate this verifier with the specified {@link Manifest} object. - * - * @param mf - * a {@code java.util.jar.Manifest} object. - */ - void setManifest(Manifest mf) { - man = mf; - } - - /** - * Returns a boolean indication of whether or not the - * associated jar file is signed. - * - * @return {@code true} if the JAR is signed, {@code false} - * otherwise. - */ - boolean isSignedJar() { - return certificates.size() > 0; - } - - private boolean verify(Attributes attributes, String entry, byte[] data, - int start, int end, boolean ignoreSecondEndline, boolean ignorable) { - String algorithms = attributes.getValue("Digest-Algorithms"); //$NON-NLS-1$ - if (algorithms == null) { - algorithms = "SHA SHA1"; //$NON-NLS-1$ - } - StringTokenizer tokens = new StringTokenizer(algorithms); - while (tokens.hasMoreTokens()) { - String algorithm = tokens.nextToken(); - String hash = attributes.getValue(algorithm + entry); - if (hash == null) { - continue; - } - - MessageDigest md; - try { - // BEGIN android-changed - md = OpenSSLMessageDigestJDK.getInstance(algorithm); - // END android-changed - } catch (NoSuchAlgorithmException e) { - continue; - } - if (ignoreSecondEndline && data[end - 1] == '\n' - && data[end - 2] == '\n') { - md.update(data, start, end - 1 - start); - } else { - md.update(data, start, end - start); - } - byte[] b = md.digest(); - byte[] hashBytes; - try { - hashBytes = hash.getBytes("ISO-8859-1"); //$NON-NLS-1$ - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e.toString()); - } - return MessageDigest.isEqual(b, Base64.decode(hashBytes)); - } - return ignorable; - } - - /** - * Returns all of the {@link java.security.cert.Certificate} instances that - * were used to verify the signature on the JAR entry called - * {@code name}. - * - * @param name - * the name of a JAR entry. - * @return an array of {@link java.security.cert.Certificate}. - */ - Certificate[] getCertificates(String name) { - Certificate[] verifiedCerts = verifiedEntries.get(name); - if (verifiedCerts == null) { - return null; - } - return verifiedCerts.clone(); - } - - /** - * Remove all entries from the internal collection of data held about each - * JAR entry in the {@code META-INF} directory. - * - * @see #addMetaEntry(String, byte[]) - */ - void removeMetaEntries() { - metaEntries = null; - } - - /** - * Returns a {@code Vector} of all of the - * {@link java.security.cert.Certificate}s that are associated with the - * signing of the named signature file. - * - * @param signatureFileName - * the name of a signature file. - * @param certificates - * a {@code Map} of all of the certificate chains discovered so - * far while attempting to verify the JAR that contains the - * signature file {@code signatureFileName}. This object is - * previously set in the course of one or more calls to - * {@link #verifyJarSignatureFile(String, String, String, Map, Map)} - * where it was passed as the last argument. - * @return all of the {@code Certificate} entries for the signer of the JAR - * whose actions led to the creation of the named signature file. - */ - public static Vector getSignerCertificates( - String signatureFileName, Map certificates) { - Vector result = new Vector(); - Certificate[] certChain = certificates.get(signatureFileName); - if (certChain != null) { - for (Certificate element : certChain) { - result.add(element); - } - } - return result; - } -} diff --git a/libcore/archive/src/main/java/java/util/jar/Manifest.java b/libcore/archive/src/main/java/java/util/jar/Manifest.java deleted file mode 100644 index b28f3fb67..000000000 --- a/libcore/archive/src/main/java/java/util/jar/Manifest.java +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.jar; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.charset.CharsetEncoder; -import java.nio.charset.CoderResult; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.apache.harmony.archive.internal.nls.Messages; -import org.apache.harmony.luni.util.InputStreamExposer; -import org.apache.harmony.luni.util.ThreadLocalCache; - -/** - * The {@code Manifest} class is used to obtain attribute information for a - * {@code JarFile} and its entries. - */ -public class Manifest implements Cloneable { - static final int LINE_LENGTH_LIMIT = 72; - - private static final byte[] LINE_SEPARATOR = new byte[] { '\r', '\n' }; - - private static final byte[] VALUE_SEPARATOR = new byte[] { ':', ' ' }; - - private static final Attributes.Name NAME_ATTRIBUTE = new Attributes.Name( - "Name"); //$NON-NLS-1$ - - private Attributes mainAttributes = new Attributes(); - - private HashMap entries = new HashMap(); - - static class Chunk { - int start; - int end; - - Chunk(int start, int end) { - this.start = start; - this.end = end; - } - } - - private HashMap chunks; - - /** - * Manifest bytes are used for delayed entry parsing. - */ - private InitManifest im; - - /** - * The end of the main attributes section in the manifest is needed in - * verification. - */ - private int mainEnd; - - /** - * Creates a new {@code Manifest} instance. - */ - public Manifest() { - super(); - } - - /** - * Creates a new {@code Manifest} instance using the attributes obtained - * from the input stream. - * - * @param is - * {@code InputStream} to parse for attributes. - * @throws IOException - * if an IO error occurs while creating this {@code Manifest} - */ - public Manifest(InputStream is) throws IOException { - super(); - read(is); - } - - /** - * Creates a new {@code Manifest} instance. The new instance will have the - * same attributes as those found in the parameter {@code Manifest}. - * - * @param man - * {@code Manifest} instance to obtain attributes from. - */ - @SuppressWarnings("unchecked") - public Manifest(Manifest man) { - mainAttributes = (Attributes) man.mainAttributes.clone(); - entries = (HashMap) ((HashMap) man - .getEntries()).clone(); - } - - Manifest(InputStream is, boolean readChunks) throws IOException { - if (readChunks) { - chunks = new HashMap(); - } - read(is); - } - - /** - * Resets the both the main attributes as well as the entry attributes - * associated with this {@code Manifest}. - */ - public void clear() { - im = null; - entries.clear(); - mainAttributes.clear(); - } - - /** - * Returns the {@code Attributes} associated with the parameter entry - * {@code name}. - * - * @param name - * the name of the entry to obtain {@code Attributes} from. - * @return the Attributes for the entry or {@code null} if the entry does - * not exist. - */ - public Attributes getAttributes(String name) { - return getEntries().get(name); - } - - /** - * Returns a map containing the {@code Attributes} for each entry in the - * {@code Manifest}. - * - * @return the map of entry attributes. - */ - public Map getEntries() { - initEntries(); - return entries; - } - - private void initEntries() { - if (im == null) { - return; - } - // try { - // im.initEntries(entries, chunks); - // } catch (IOException ioe) { - // throw new RuntimeException(ioe); - // } - // im = null; - } - - /** - * Returns the main {@code Attributes} of the {@code JarFile}. - * - * @return main {@code Attributes} associated with the source {@code - * JarFile}. - */ - public Attributes getMainAttributes() { - return mainAttributes; - } - - /** - * Creates a copy of this {@code Manifest}. The returned {@code Manifest} - * will equal the {@code Manifest} from which it was cloned. - * - * @return a copy of this instance. - */ - @Override - public Object clone() { - return new Manifest(this); - } - - /** - * Writes out the attribute information of the receiver to the specified - * {@code OutputStream}. - * - * @param os - * The {@code OutputStream} to write to. - * @throws IOException - * If an error occurs writing the {@code Manifest}. - */ - public void write(OutputStream os) throws IOException { - write(this, os); - } - - /** - * Constructs a new {@code Manifest} instance obtaining attribute - * information from the specified input stream. - * - * @param is - * The {@code InputStream} to read from. - * @throws IOException - * If an error occurs reading the {@code Manifest}. - */ - public void read(InputStream is) throws IOException { - byte[] buf; - // Try to read get a reference to the bytes directly - try { - buf = InputStreamExposer.expose(is); - } catch (UnsupportedOperationException uoe) { - buf = readFully(is); - } - - if (buf.length == 0) { - return; - } - - // a workaround for HARMONY-5662 - // replace EOF and NUL with another new line - // which does not trigger an error - byte b = buf[buf.length - 1]; - if (0 == b || 26 == b) { - buf[buf.length - 1] = '\n'; - } - - // Attributes.Name.MANIFEST_VERSION is not used for - // the second parameter for RI compatibility - im = new InitManifest(buf, mainAttributes, null); - mainEnd = im.getPos(); - // FIXME - im.initEntries(entries, chunks); - im = null; - } - - /* - * Helper to read the entire contents of the manifest from the - * given input stream. Usually we can do this in a single read - * but we need to account for 'infinite' streams, by ensuring we - * have a line feed within a reasonable number of characters. - */ - private byte[] readFully(InputStream is) throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] buffer = new byte[8192]; - - while (true) { - int count = is.read(buffer); - if (count == -1) { - // TODO: Do we need to copy this, or can we live with junk at the end? - return baos.toByteArray(); - } - baos.write(buffer, 0, count); - - if (!containsLine(buffer, count)) { - throw new IOException(Messages.getString("archive.2E")); //$NON-NLS-1$ - } - } - } - - /* - * Check to see if the buffer contains a newline or carriage - * return character within the first 'length' bytes. Used to - * check the validity of the manifest input stream. - */ - private boolean containsLine(byte[] buffer, int length) { - for (int i = 0; i < length; i++) { - if (buffer[i] == 0x0A || buffer[i] == 0x0D) { - return true; - } - } - return false; - } - - /** - * Returns the hash code for this instance. - * - * @return this {@code Manifest}'s hashCode. - */ - @Override - public int hashCode() { - return mainAttributes.hashCode() ^ getEntries().hashCode(); - } - - /** - * Determines if the receiver is equal to the parameter object. Two {@code - * Manifest}s are equal if they have identical main attributes as well as - * identical entry attributes. - * - * @param o - * the object to compare against. - * @return {@code true} if the manifests are equal, {@code false} otherwise - */ - @Override - public boolean equals(Object o) { - if (o == null) { - return false; - } - if (o.getClass() != this.getClass()) { - return false; - } - if (!mainAttributes.equals(((Manifest) o).mainAttributes)) { - return false; - } - return getEntries().equals(((Manifest) o).getEntries()); - } - - Chunk getChunk(String name) { - return chunks.get(name); - } - - void removeChunks() { - chunks = null; - } - - int getMainAttributesEnd() { - return mainEnd; - } - - /** - * Writes out the attribute information of the specified manifest to the - * specified {@code OutputStream} - * - * @param manifest - * the manifest to write out. - * @param out - * The {@code OutputStream} to write to. - * @throws IOException - * If an error occurs writing the {@code Manifest}. - */ - static void write(Manifest manifest, OutputStream out) throws IOException { - CharsetEncoder encoder = ThreadLocalCache.utf8Encoder.get(); - ByteBuffer buffer = ThreadLocalCache.byteBuffer.get(); - - String version = manifest.mainAttributes - .getValue(Attributes.Name.MANIFEST_VERSION); - if (version != null) { - writeEntry(out, Attributes.Name.MANIFEST_VERSION, version, encoder, - buffer); - Iterator entries = manifest.mainAttributes.keySet().iterator(); - while (entries.hasNext()) { - Attributes.Name name = (Attributes.Name) entries.next(); - if (!name.equals(Attributes.Name.MANIFEST_VERSION)) { - writeEntry(out, name, manifest.mainAttributes - .getValue(name), encoder, buffer); - } - } - } - out.write(LINE_SEPARATOR); - Iterator i = manifest.getEntries().keySet().iterator(); - while (i.hasNext()) { - String key = i.next(); - writeEntry(out, NAME_ATTRIBUTE, key, encoder, buffer); - Attributes attrib = manifest.entries.get(key); - Iterator entries = attrib.keySet().iterator(); - while (entries.hasNext()) { - Attributes.Name name = (Attributes.Name) entries.next(); - writeEntry(out, name, attrib.getValue(name), encoder, buffer); - } - out.write(LINE_SEPARATOR); - } - } - - private static void writeEntry(OutputStream os, Attributes.Name name, - String value, CharsetEncoder encoder, ByteBuffer bBuf) - throws IOException { - byte[] out = name.getBytes(); - if (out.length > LINE_LENGTH_LIMIT) { - throw new IOException(Messages.getString( - "archive.33", name, Integer.valueOf(LINE_LENGTH_LIMIT))); //$NON-NLS-1$ - } - - os.write(out); - os.write(VALUE_SEPARATOR); - - encoder.reset(); - bBuf.clear().limit(LINE_LENGTH_LIMIT - out.length - 2); - - CharBuffer cBuf = CharBuffer.wrap(value); - CoderResult r; - - while (true) { - r = encoder.encode(cBuf, bBuf, true); - if (CoderResult.UNDERFLOW == r) { - r = encoder.flush(bBuf); - } - os.write(bBuf.array(), bBuf.arrayOffset(), bBuf.position()); - os.write(LINE_SEPARATOR); - if (CoderResult.UNDERFLOW == r) { - break; - } - os.write(' '); - bBuf.clear().limit(LINE_LENGTH_LIMIT - 1); - } - } -} diff --git a/libcore/archive/src/main/java/java/util/jar/Pack200.java b/libcore/archive/src/main/java/java/util/jar/Pack200.java deleted file mode 100644 index 3e7081d2e..000000000 --- a/libcore/archive/src/main/java/java/util/jar/Pack200.java +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package java.util.jar; - -import java.beans.PropertyChangeListener; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.SortedMap; - -/** - * Class factory for {@link Pack200.Packer} and {@link Pack200.Unpacker}. - */ -public abstract class Pack200 { - - private static final String SYSTEM_PROPERTY_PACKER = "java.util.jar.Pack200.Packer"; //$NON-NLS-1$ - - private static final String SYSTEM_PROPERTY_UNPACKER = "java.util.jar.Pack200.Unpacker"; //$NON-NLS-1$ - - /** - * Prevent this class from being instantiated. - */ - private Pack200() { - // do nothing - } - - /** - * Returns a new instance of a packer engine. - *

- * The implementation of the packer engine is defined by the system property - * {@code 'java.util.jar.Pack200.Packer'}. If this system property is - * defined an instance of the specified class is returned, otherwise the - * system's default implementation is returned. - * - * @return an instance of {@code Packer} - */ - public static Pack200.Packer newPacker() { - return (Packer) AccessController - .doPrivileged(new PrivilegedAction() { - public Object run() { - String className = System - .getProperty(SYSTEM_PROPERTY_PACKER, - "org.apache.harmony.pack200.Pack200PackerAdapter"); //$NON-NLS-1$ - try { - // TODO Not sure if this will cause problems with - // loading the packer - return ClassLoader.getSystemClassLoader() - .loadClass(className).newInstance(); - } catch (Exception e) { - throw new Error("Can't load class " + className, e); - } - } - }); - - } - - /** - * Returns a new instance of a unpacker engine. - *

- * The implementation of the unpacker engine is defined by the system - * property {@code 'java.util.jar.Pack200.Unpacker'}. If this system - * property is defined an instance of the specified class is returned, - * otherwise the system's default implementation is returned. - * - * @return a instance of {@code Unpacker}. - */ - public static Pack200.Unpacker newUnpacker() { - return (Unpacker) AccessController - .doPrivileged(new PrivilegedAction() { - public Object run() { - String className = System - .getProperty(SYSTEM_PROPERTY_UNPACKER, - "org.apache.harmony.unpack200.Pack200UnpackerAdapter");//$NON-NLS-1$ - try { - return ClassLoader.getSystemClassLoader() - .loadClass(className).newInstance(); - } catch (Exception e) { - throw new Error("Can't load class " + className, e); - } - } - }); - } - - /** - * The interface defining the API for converting a JAR file to an output - * stream in the Pack200 format. - */ - public static interface Packer { - - /** - * the format of a class attribute name. - */ - static final String CLASS_ATTRIBUTE_PFX = "pack.class.attribute."; //$NON-NLS-1$ - - /** - * the format of a code attribute name. - */ - static final String CODE_ATTRIBUTE_PFX = "pack.code.attribute."; //$NON-NLS-1$ - - /** - * the deflation hint to set in the output archive. - */ - static final String DEFLATE_HINT = "pack.deflate.hint";//$NON-NLS-1$ - - /** - * the indicated amount of effort to use in compressing the archive. - */ - static final String EFFORT = "pack.effort";//$NON-NLS-1$ - - /** - * a String representation for {@code error}. - */ - static final String ERROR = "error";//$NON-NLS-1$ - - /** - * a String representation of {@code false}. - */ - static final String FALSE = "false";//$NON-NLS-1$ - - /** - * the format of a field attribute name. - */ - static final String FIELD_ATTRIBUTE_PFX = "pack.field.attribute.";//$NON-NLS-1$ - - /** - * a String representation for {@code keep}. - */ - static final String KEEP = "keep";//$NON-NLS-1$ - - /** - * decide if all elements shall transmit in their original order. - */ - static final String KEEP_FILE_ORDER = "pack.keep.file.order";//$NON-NLS-1$ - - /** - * a String representation for {@code latest}. - */ - static final String LATEST = "latest";//$NON-NLS-1$ - - /** - * the format of a method attribute name. - */ - static final String METHOD_ATTRIBUTE_PFX = "pack.method.attribute.";//$NON-NLS-1$ - - /** - * if it shall attempt to determine the latest modification time if this - * is set to {@code LATEST}. - */ - static final String MODIFICATION_TIME = "pack.modification.time";//$NON-NLS-1$ - - /** - * a String representation of {@code pass}. - */ - static final String PASS = "pass";//$NON-NLS-1$ - - /** - * the file that will not be compressed. - */ - static final String PASS_FILE_PFX = "pack.pass.file.";//$NON-NLS-1$ - - /** - * packer progress as a percentage. - */ - static final String PROGRESS = "pack.progress";//$NON-NLS-1$ - - /** - * The number of bytes of each archive segment. - */ - static final String SEGMENT_LIMIT = "pack.segment.limit";//$NON-NLS-1$ - - /** - * a String representation of {@code strip}. - */ - static final String STRIP = "strip";//$NON-NLS-1$ - - /** - * a String representation of {@code true}. - */ - static final String TRUE = "true";//$NON-NLS-1$ - - /** - * the action to take if an unknown attribute is encountered. - */ - static final String UNKNOWN_ATTRIBUTE = "pack.unknown.attribute";//$NON-NLS-1$ - - /** - * Returns a sorted map of the properties of this packer. - * - * @return the properties of the packer. - */ - SortedMap properties(); - - /** - * Pack the specified JAR file to the specified output stream. - * - * @param in - * JAR file to be compressed. - * @param out - * stream of compressed data. - * @throws IOException - * if I/O exception occurs. - */ - void pack(JarFile in, OutputStream out) throws IOException; - - /** - * Pack the data from the specified jar input stream to the specified - * output stream. - * - * @param in - * stream of uncompressed JAR data. - * @param out - * stream of compressed data. - * @throws IOException - * if I/O exception occurs. - */ - void pack(JarInputStream in, OutputStream out) throws IOException; - - /** - * add a listener for PropertyChange events - * - * @param listener - * the listener to listen if PropertyChange events occurs - */ - void addPropertyChangeListener(PropertyChangeListener listener); - - /** - * remove a listener - * - * @param listener - * listener to remove - */ - void removePropertyChangeListener(PropertyChangeListener listener); - } - - /** - * The interface defining the API for converting a packed stream in the - * Pack200 format to a JAR file. - */ - public static interface Unpacker { - - /** - * The String indicating if the unpacker should ignore all transmitted - * values,can be replaced by either {@code true} or {@code false}. - */ - static final String DEFLATE_HINT = "unpack.deflate.hint";//$NON-NLS-1$ - - /** - * a String representation of {@code false}. - */ - static final String FALSE = "false";//$NON-NLS-1$ - - /** - * a String representation of {@code keep}. - */ - static final String KEEP = "keep";//$NON-NLS-1$ - - /** - * the progress as a {@code percentage}. - */ - static final String PROGRESS = "unpack.progress";//$NON-NLS-1$ - - /** - * a String representation of {@code true}. - */ - static final String TRUE = "true";//$NON-NLS-1$ - - /** - * Returns a sorted map of the properties of this unpacker. - * - * @return the properties of unpacker. - */ - SortedMap properties(); - - /** - * Unpack the specified stream to the specified JAR output stream. - * - * @param in - * stream to uncompressed. - * @param out - * JAR output stream of uncompressed data. - * @throws IOException - * if I/O exception occurs. - */ - void unpack(InputStream in, JarOutputStream out) throws IOException; - - /** - * Unpack the contents of the specified {@code File} to the specified - * JAR output stream. - * - * @param in - * file to be uncompressed. - * @param out - * JAR output stream of uncompressed data. - * @throws IOException - * if I/O exception occurs. - */ - void unpack(File in, JarOutputStream out) throws IOException; - - /** - * add a listener for {@code PropertyChange} events. - * - * @param listener - * the listener to listen if {@code PropertyChange} events - * occurs. - */ - void addPropertyChangeListener(PropertyChangeListener listener); - - /** - * remove a listener. - * - * @param listener - * listener to remove. - */ - void removePropertyChangeListener(PropertyChangeListener listener); - } - -} diff --git a/libcore/archive/src/main/java/java/util/jar/package.html b/libcore/archive/src/main/java/java/util/jar/package.html deleted file mode 100644 index 35eabe734..000000000 --- a/libcore/archive/src/main/java/java/util/jar/package.html +++ /dev/null @@ -1,12 +0,0 @@ - - -

- The java.jar package gives access to reading and writing a Java archive, - or JAR, files. These are - actually ZIP files with the possibility to add meta-information in the - form of a MANIFEST file. This manifest can also be used - to sign a JAR file. -

- @since Android 1.0 - - diff --git a/libcore/archive/src/main/java/java/util/zip/Adler32.java b/libcore/archive/src/main/java/java/util/zip/Adler32.java deleted file mode 100644 index a5f77d734..000000000 --- a/libcore/archive/src/main/java/java/util/zip/Adler32.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.zip; - -/** - * The Adler-32 class is used to compute the {@code Adler32} checksum from a set - * of data. Compared to the CRC-32 algorithm it trades reliabilty for speed. - * Refer to RFC 1950 for the specification. - * - * @see CRC32 - */ -public class Adler32 implements java.util.zip.Checksum { - - private long adler = 1; - - /** - * Returns the {@code Adler32} checksum for all input received. - * - * @return The checksum for this instance. - */ - public long getValue() { - return adler; - } - - /** - * Reset this instance to its initial checksum. - */ - public void reset() { - adler = 1; - } - - /** - * Update this {@code Adler32} checksum with the single byte provided as - * argument. - * - * @param i - * the byte to update checksum with. - */ - public void update(int i) { - adler = updateByteImpl(i, adler); - } - - /** - * Update this {@code Adler32} checksum using the contents of {@code buf}. - * - * @param buf - * bytes to update checksum with. - */ - public void update(byte[] buf) { - update(buf, 0, buf.length); - } - - /** - * Update this {@code Adler32} checksum with the contents of {@code buf}, - * starting from the offset provided and reading n bytes of data. - * - * @param buf - * buffer to obtain data from. - * @param off - * offset in {@code buf} to start reading from. - * @param nbytes - * number of bytes from {@code buf} to use. - * @throws ArrayIndexOutOfBoundsException - * if {@code offset > buf.length} or {@code nbytes} is negative - * or {@code offset + nbytes > buf.length}. - */ - public void update(byte[] buf, int off, int nbytes) { - // avoid int overflow, check null buf - if (off <= buf.length && nbytes >= 0 && off >= 0 - && buf.length - off >= nbytes) { - adler = updateImpl(buf, off, nbytes, adler); - } else { - throw new ArrayIndexOutOfBoundsException(); - } - } - - private native long updateImpl(byte[] buf, int off, int nbytes, long adler1); - - private native long updateByteImpl(int val, long adler1); -} diff --git a/libcore/archive/src/main/java/java/util/zip/CRC32.java b/libcore/archive/src/main/java/java/util/zip/CRC32.java deleted file mode 100644 index 59e8f81fc..000000000 --- a/libcore/archive/src/main/java/java/util/zip/CRC32.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.zip; - -/** - * The CRC32 class is used to compute a CRC32 checksum from data provided as - * input value. - */ -public class CRC32 implements java.util.zip.Checksum { - - private long crc = 0L; - - long tbytes = 0L; - - /** - * Returns the CRC32 checksum for all input received. - * - * @return The checksum for this instance. - */ - public long getValue() { - return crc; - } - - /** - * Resets the CRC32 checksum to it initial state. - */ - public void reset() { - tbytes = crc = 0; - - } - - /** - * Updates this checksum with the byte value provided as integer. - * - * @param val - * represents the byte to update the checksum. - */ - public void update(int val) { - crc = updateByteImpl((byte) val, crc); - } - - /** - * Updates this checksum with the bytes contained in buffer {@code buf}. - * - * @param buf - * the buffer holding the data to update the checksum with. - */ - public void update(byte[] buf) { - update(buf, 0, buf.length); - } - - /** - * Updates this checksum with n bytes of data obtained from buffer {@code - * buf}, starting at offset {@code off}. - * - * @param buf - * the buffer to update the checksum. - * @param off - * the offset in {@code buf} to obtain data from. - * @param nbytes - * the number of bytes to read from {@code buf}. - */ - public void update(byte[] buf, int off, int nbytes) { - // avoid int overflow, check null buf - if (off <= buf.length && nbytes >= 0 && off >= 0 - && buf.length - off >= nbytes) { - tbytes += nbytes; - crc = updateImpl(buf, off, nbytes, crc); - } else { - throw new ArrayIndexOutOfBoundsException(); - } - } - - private native long updateImpl(byte[] buf, int off, int nbytes, long crc1); - - private native long updateByteImpl(byte val, long crc1); -} diff --git a/libcore/archive/src/main/java/java/util/zip/CheckedInputStream.java b/libcore/archive/src/main/java/java/util/zip/CheckedInputStream.java deleted file mode 100644 index 6513e66f7..000000000 --- a/libcore/archive/src/main/java/java/util/zip/CheckedInputStream.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.zip; - -import java.io.IOException; -import java.io.InputStream; - -/** - * The {@code CheckedInputStream} class is used to maintain a checksum at the - * same time as the data, on which the checksum is computed, is read from a - * stream. The purpose of this checksum is to establish data integrity, - * comparing the computed checksum against a published checksum value. - */ -public class CheckedInputStream extends java.io.FilterInputStream { - - private final Checksum check; - - /** - * Constructs a new {@code CheckedInputStream} on {@code InputStream} - * {@code is}. The checksum will be calculated using the algorithm - * implemented by {@code csum}. - * - * @param is - * the input stream to calculate checksum from. - * @param csum - * an entity implementing the checksum algorithm. - */ - public CheckedInputStream(InputStream is, Checksum csum) { - super(is); - check = csum; - } - - /** - * Reads one byte of data from the underlying input stream and updates the - * checksum with the byte data. - * - * @return {@code -1} at the end of the stream, a single byte value - * otherwise. - * @throws IOException - * if an {@code IOException} occurs. - */ - @Override - public int read() throws IOException { - int x = in.read(); - if (x != -1) { - check.update(x); - } - return x; - } - - /** - * Reads up to n bytes of data from the underlying input stream, storing it - * into {@code buf}, starting at offset {@code off}. The checksum is - * updated with the bytes read. - * - * @param buf - * the byte array in which to store the bytes read. - * @param off - * the initial position in {@code buf} to store the bytes read - * from this stream. - * @param nbytes - * the maximum number of bytes to store in {@code buf}. - * @return the number of bytes actually read or {@code -1} if arrived at the - * end of the filtered stream while reading the data. - * @throws IOException - * if this stream is closed or some I/O error occurs. - */ - @Override - public int read(byte[] buf, int off, int nbytes) throws IOException { - int x = in.read(buf, off, nbytes); - if (x != -1) { - check.update(buf, off, x); - } - return x; - } - - /** - * Returns the checksum calculated on the stream read so far. - * - * @return the updated checksum. - */ - public Checksum getChecksum() { - return check; - } - - /** - * Skip up to n bytes of data on the underlying input stream. Any skipped - * bytes are added to the running checksum value. - * - * @param nbytes - * the number of bytes to skip. - * @throws IOException - * if this stream is closed or another I/O error occurs. - * @return the number of bytes skipped. - */ - @Override - public long skip(long nbytes) throws IOException { - if (nbytes < 1) { - return 0; - } - long skipped = 0; - byte[] b = new byte[2048]; - int x, v; - while (skipped != nbytes) { - x = in.read(b, 0, - (v = (int) (nbytes - skipped)) > b.length ? b.length : v); - if (x == -1) { - return skipped; - } - check.update(b, 0, x); - skipped += x; - } - return skipped; - } -} diff --git a/libcore/archive/src/main/java/java/util/zip/CheckedOutputStream.java b/libcore/archive/src/main/java/java/util/zip/CheckedOutputStream.java deleted file mode 100644 index 08fe799fd..000000000 --- a/libcore/archive/src/main/java/java/util/zip/CheckedOutputStream.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.zip; - -import java.io.IOException; -import java.io.OutputStream; - -/** - * The {@code CheckedOutputStream} class is used to maintain a running checksum - * of all data written to a stream. The purpose of this checksum is to establish - * data integrity, by publishing the checksum to other parties wanting to read - * the non corrupted data. - */ -public class CheckedOutputStream extends java.io.FilterOutputStream { - - private final Checksum check; - - /** - * Constructs a new {@code CheckedOutputStream} on {@code OutputStream} - * {@code os}. The checksum is calculated using the algorithm implemented - * by {@code csum}. - * - * @param os - * the output stream to calculate checksum for. - * @param cs - * an entity implementing the checksum algorithm. - */ - public CheckedOutputStream(OutputStream os, Checksum cs) { - super(os); - check = cs; - } - - /** - * Returns the checksum calculated on the stream read so far. - * - * @return the updated checksum. - */ - public Checksum getChecksum() { - return check; - } - - /** - * Writes the specified byte to the underlying stream. The checksum is - * updated with {@code val}. - * - * @param val - * the data value to written to the output stream. - * @throws IOException - * if an IO error has occurred. - */ - @Override - public void write(int val) throws IOException { - out.write(val); - check.update(val); - } - - /** - * Writes n bytes of data from {@code buf} starting at offset {@code off} to - * the underlying stream. The checksum is updated with the bytes written. - * - * @param buf - * data written to the output stream. - * @param off - * the offset to start reading the data from {@code buf} written - * to the output stream. - * @param nbytes - * number of bytes to write to the output stream. - * @throws IOException - * if an IO error has occurred. - */ - @Override - public void write(byte[] buf, int off, int nbytes) throws IOException { - out.write(buf, off, nbytes); - check.update(buf, off, nbytes); - } -} diff --git a/libcore/archive/src/main/java/java/util/zip/Checksum.java b/libcore/archive/src/main/java/java/util/zip/Checksum.java deleted file mode 100644 index 901ff7a8d..000000000 --- a/libcore/archive/src/main/java/java/util/zip/Checksum.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.zip; - -/** - * Holds information about a checksum which was computed with the methods - * implementing a checksum algorithm. - */ -public interface Checksum { - - /** - * Returns the current calculated checksum value. - * - * @return the checksum. - */ - public long getValue(); - - /** - * Resets the checksum value applied before beginning calculations on a new - * stream of data. - */ - public void reset(); - - /** - * Updates the checksum with the given bytes. - * - * @param buf - * the byte array from which to read the bytes. - * @param off - * the initial position in {@code buf} to read the bytes from. - * @param nbytes - * the number of bytes to read from {@code buf}. - */ - public void update(byte[] buf, int off, int nbytes); - - /** - * Updates the checksum value with the given byte. - * - * @param val - * the byte to update the checksum with. - */ - public void update(int val); -} diff --git a/libcore/archive/src/main/java/java/util/zip/DataFormatException.java b/libcore/archive/src/main/java/java/util/zip/DataFormatException.java deleted file mode 100644 index 1e9c5a28a..000000000 --- a/libcore/archive/src/main/java/java/util/zip/DataFormatException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.zip; - -/** - * {@code DataFormatException} is used to indicate an error in the format of a - * particular data stream which is to be uncompressed. - */ -public class DataFormatException extends Exception { - - private static final long serialVersionUID = 2219632870893641452L; - - /** - * Constructs a new {@code DataFormatException} instance. - */ - public DataFormatException() { - super(); - } - - /** - * Constructs a new {@code DataFormatException} instance with the specified - * message. - * - * @param detailMessage - * the detail message for the exception. - */ - public DataFormatException(String detailMessage) { - super(detailMessage); - } -} diff --git a/libcore/archive/src/main/java/java/util/zip/Deflater.java b/libcore/archive/src/main/java/java/util/zip/Deflater.java deleted file mode 100644 index 38771a87c..000000000 --- a/libcore/archive/src/main/java/java/util/zip/Deflater.java +++ /dev/null @@ -1,507 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.zip; - -// BEGIN android-changed -// import org.apache.harmony.luni.platform.OSResourcesMonitor; -// END android-changed - -/** - * This class compresses data using the DEFLATE algorithm (see specification). - *

- * Basically this class is part of the API to the stream based ZLIB compression - * library and is used as such by {@code DeflaterOutputStream} and its - * descendants. - *

- * The typical usage of a {@code Deflater} instance outside this package - * consists of a specific call to one of its constructors before being passed to - * an instance of {@code DeflaterOutputStream}. - * - * @see DeflaterOutputStream - * @see Inflater - */ -public class Deflater { - - /** - * Upper bound for the compression level range. - */ - public static final int BEST_COMPRESSION = 9; - - /** - * Lower bound for compression level range. - */ - public static final int BEST_SPEED = 1; - - /** - * Usage of the default compression level. - */ - public static final int DEFAULT_COMPRESSION = -1; - - /** - * Default value for compression strategy. - */ - public static final int DEFAULT_STRATEGY = 0; - - /** - * Default value for compression method. - */ - public static final int DEFLATED = 8; - - /** - * Possible value for compression strategy. - */ - public static final int FILTERED = 1; - - /** - * Possible value for compression strategy. - */ - public static final int HUFFMAN_ONLY = 2; - - /** - * Possible value for compression level. - */ - public static final int NO_COMPRESSION = 0; - - private static final int Z_NO_FLUSH = 0; - - private static final int Z_FINISH = 4; - - // Fill in the JNI id caches - private static native void oneTimeInitialization(); - - // A stub buffer used when deflate() called while inputBuffer has not been - // set. - private static final byte[] STUB_INPUT_BUFFER = new byte[0]; - - static { - oneTimeInitialization(); - } - - private int flushParm = Z_NO_FLUSH; - - private boolean finished; - - private int compressLevel = DEFAULT_COMPRESSION; - - private int strategy = DEFAULT_STRATEGY; - - private long streamHandle = -1; - - private byte[] inputBuffer; - - private int inRead; - - private int inLength; - - /** - * Constructs a new {@code Deflater} instance with default compression - * level. The strategy can be specified with {@link #setStrategy}, only. A - * header is added to the output by default; use constructor {@code - * Deflater(level, boolean)} if you need to omit the header. - */ - public Deflater() { - this(DEFAULT_COMPRESSION, false); - } - - /** - * Constructs a new {@code Deflater} instance with a specific compression - * level. The strategy can be specified with {@code setStrategy}, only. A - * header is added to the output by default; use - * {@code Deflater(level, boolean)} if you need to omit the header. - * - * @param level - * the compression level in the range between 0 and 9. - */ - public Deflater(int level) { - this(level, false); - } - - /** - * Constructs a new {@code Deflater} instance with a specific compression - * level. If noHeader is passed as true no ZLib header is added to the - * output. In a ZIP archive every entry (compressed file) comes with such a - * header. The strategy can be specified with the setStrategy method, only. - * - * @param level - * the compression level in the range between 0 and 9. - * @param noHeader - * {@code true} indicates that no ZLIB header should be written. - */ - public Deflater(int level, boolean noHeader) { - super(); - if (level < DEFAULT_COMPRESSION || level > BEST_COMPRESSION) { - throw new IllegalArgumentException(); - } - compressLevel = level; - streamHandle = createStreamWithMemoryEnsurance(compressLevel, strategy, - noHeader); - } - - /** - * Deflates the data (previously passed to {@code setInput}) into the - * supplied buffer. - * - * @param buf - * buffer to write compressed data to. - * @return number of bytes of compressed data written to {@code buf}. - * @see #deflate(byte[], int, int) - */ - public int deflate(byte[] buf) { - return deflate(buf, 0, buf.length); - } - - /** - * Deflates data (previously passed to {@code setInput}) into a specific - * region within the supplied buffer. - * - * @param buf - * the buffer to write compressed data to. - * @param off - * the offset within {@code buf} at which to start writing to. - * @param nbytes - * maximum number of bytes of compressed data to be written. - * @return the number of bytes of compressed data written to {@code buf}. - */ - public synchronized int deflate(byte[] buf, int off, int nbytes) { - if (streamHandle == -1) { - throw new IllegalStateException(); - } - // avoid int overflow, check null buf - if (off <= buf.length && nbytes >= 0 && off >= 0 - && buf.length - off >= nbytes) { - // put a stub buffer, no effect. - if (null == inputBuffer) { - setInput(STUB_INPUT_BUFFER); - } - return deflateImpl(buf, off, nbytes, streamHandle, flushParm); - } - throw new ArrayIndexOutOfBoundsException(); - } - - private synchronized native int deflateImpl(byte[] buf, int off, - int nbytes, long handle, int flushParm1); - - private synchronized native void endImpl(long handle); - - /** - * Frees all resources held onto by this deflating algorithm. Any unused - * input or output is discarded. While this method is used by {@code - * finalize()}, it can be called explicitly in order to free native - * resources before the next GC cycle. After {@code end()} was called other - * methods will typically throw an {@code IllegalStateException}. - */ - public synchronized void end() { - if (streamHandle != -1) { - endImpl(streamHandle); - inputBuffer = null; - streamHandle = -1; - } - } - - @Override - protected void finalize() { - end(); - } - - /** - * Indicates to the {@code Deflater} that all uncompressed input has been provided - * to it. - * - * @see #finished - */ - public synchronized void finish() { - flushParm = Z_FINISH; - } - - /** - * Returns whether or not all provided data has been successfully - * compressed. - * - * @return true if all data has been compressed, false otherwise. - */ - public synchronized boolean finished() { - return finished; - } - - /** - * Returns the Adler32 checksum of uncompressed data currently read. If a - * preset dictionary is used getAdler() will return the Adler32 checksum of - * the dictionary used. - * - * @return the Adler32 checksum of uncompressed data or preset dictionary if - * used. - * @see #setDictionary(byte[]) - * @see #setDictionary(byte[], int, int) - */ - public synchronized int getAdler() { - if (streamHandle == -1) { - throw new IllegalStateException(); - } - - return getAdlerImpl(streamHandle); - } - - private synchronized native int getAdlerImpl(long handle); - - /** - * Returns the total number of bytes of input consumed by the {@code Deflater}. - * - * @return number of bytes of input read. - */ - public synchronized int getTotalIn() { - if (streamHandle == -1) { - throw new IllegalStateException(); - } - - return (int) getTotalInImpl(streamHandle); - } - - private synchronized native long getTotalInImpl(long handle); - - /** - * Returns the total number of compressed bytes output by this {@code Deflater}. - * - * @return number of compressed bytes output. - */ - public synchronized int getTotalOut() { - if (streamHandle == -1) { - throw new IllegalStateException(); - } - - return (int) getTotalOutImpl(streamHandle); - } - - private synchronized native long getTotalOutImpl(long handle); - - /** - * Counterpart to setInput(). Indicates whether or not all bytes of - * uncompressed input have been consumed by the {@code Deflater}. If needsInput() - * returns true setInput() must be called before deflation can continue. If - * all bytes of uncompressed data have been provided to the {@code Deflater} - * finish() must be called to ensure the compressed data is output. - * - * @return {@code true} if input is required for deflation to continue, - * {@code false} otherwise. - * @see #finished() - * @see #setInput(byte[]) - * @see #setInput(byte[], int, int) - */ - public synchronized boolean needsInput() { - if (inputBuffer == null) { - return true; - } - return inRead == inLength; - } - - /** - * Resets the {@code Deflater} to accept new input without affecting any - * previously made settings for the compression strategy or level. This - * operation must be called after {@code finished()} returns - * {@code true} if the {@code Deflater} is to be reused. - * - * @see #finished - */ - public synchronized void reset() { - if (streamHandle == -1) { - throw new NullPointerException(); - } - - flushParm = Z_NO_FLUSH; - finished = false; - resetImpl(streamHandle); - inputBuffer = null; - } - - private synchronized native void resetImpl(long handle); - - /** - * Sets the dictionary to be used for compression by this {@code Deflater}. - * setDictionary() can only be called if this {@code Deflater} supports the writing - * of ZLIB headers. This is the default behaviour but can be overridden - * using {@code Deflater(int, boolean)}. - * - * @param buf - * the buffer containing the dictionary data bytes. - * @see Deflater#Deflater(int, boolean) - */ - public void setDictionary(byte[] buf) { - setDictionary(buf, 0, buf.length); - } - - /** - * Sets the dictionary to be used for compression by this {@code Deflater}. - * setDictionary() can only be called if this {@code Deflater} supports the writing - * of ZLIB headers. This is the default behaviour but can be overridden - * using {@code Deflater(int, boolean)}. - * - * @param buf - * the buffer containing the dictionary data bytes. - * @param off - * the offset of the data. - * @param nbytes - * the length of the data. - * @see Deflater#Deflater(int, boolean) - */ - public synchronized void setDictionary(byte[] buf, int off, int nbytes) { - if (streamHandle == -1) { - throw new IllegalStateException(); - } - // avoid int overflow, check null buf - if (off <= buf.length && nbytes >= 0 && off >= 0 - && buf.length - off >= nbytes) { - setDictionaryImpl(buf, off, nbytes, streamHandle); - } else { - throw new ArrayIndexOutOfBoundsException(); - } - } - - private synchronized native void setDictionaryImpl(byte[] buf, int off, - int nbytes, long handle); - - /** - * Sets the input buffer the {@code Deflater} will use to extract uncompressed bytes - * for later compression. - * - * @param buf - * the buffer. - */ - public void setInput(byte[] buf) { - setInput(buf, 0, buf.length); - } - - /** - * Sets the input buffer the {@code Deflater} will use to extract uncompressed bytes - * for later compression. Input will be taken from the buffer region - * starting at off and ending at nbytes - 1. - * - * @param buf - * the buffer containing the input data bytes. - * @param off - * the offset of the data. - * @param nbytes - * the length of the data. - */ - public synchronized void setInput(byte[] buf, int off, int nbytes) { - if (streamHandle == -1) { - throw new IllegalStateException(); - } - // avoid int overflow, check null buf - if (off <= buf.length && nbytes >= 0 && off >= 0 - && buf.length - off >= nbytes) { - inLength = nbytes; - inRead = 0; - if (inputBuffer == null) { - setLevelsImpl(compressLevel, strategy, streamHandle); - } - inputBuffer = buf; - setInputImpl(buf, off, nbytes, streamHandle); - } else { - throw new ArrayIndexOutOfBoundsException(); - } - } - - private synchronized native void setLevelsImpl(int level, int strategy, - long handle); - - private synchronized native void setInputImpl(byte[] buf, int off, - int nbytes, long handle); - - /** - * Sets the compression level to be used when compressing data. The - * compression level must be a value between 0 and 9. This value must be set - * prior to calling setInput(). - * - * @param level - * compression level to use - * @exception IllegalArgumentException - * If the compression level is invalid. - */ - public synchronized void setLevel(int level) { - if (level < DEFAULT_COMPRESSION || level > BEST_COMPRESSION) { - throw new IllegalArgumentException(); - } - if (inputBuffer != null) { - throw new IllegalStateException(); - } - compressLevel = level; - } - - /** - * Sets the compression strategy to be used. The strategy must be one of - * FILTERED, HUFFMAN_ONLY or DEFAULT_STRATEGY.This value must be set prior - * to calling setInput(). - * - * @param strategy - * compression strategy to use - * @exception IllegalArgumentException - * If the strategy specified is not one of FILTERED, - * HUFFMAN_ONLY or DEFAULT_STRATEGY. - */ - public synchronized void setStrategy(int strategy) { - if (strategy < DEFAULT_STRATEGY || strategy > HUFFMAN_ONLY) { - throw new IllegalArgumentException(); - } - if (inputBuffer != null) { - throw new IllegalStateException(); - } - this.strategy = strategy; - } - - /** - * Returns a long int of total number of bytes read by the {@code Deflater}. This - * method performs the same as {@code getTotalIn} except it returns a long value - * instead of an integer - * - * @see #getTotalIn() - * @return total number of bytes read by {@code Deflater}. - */ - public synchronized long getBytesRead() { - // Throw NPE here - if (streamHandle == -1) { - throw new NullPointerException(); - } - return getTotalInImpl(streamHandle); - } - - /** - * Returns a long int of total number of bytes of read by the {@code Deflater}. This - * method performs the same as {@code getTotalOut} except it returns a long - * value instead of an integer - * - * @see #getTotalOut() - * @return bytes exactly write by {@code Deflater} - */ - public synchronized long getBytesWritten() { - // Throw NPE here - if (streamHandle == -1) { - throw new NullPointerException(); - } - return getTotalOutImpl(streamHandle); - } - - private long createStreamWithMemoryEnsurance(int level, int strategy1, - boolean noHeader1) { - // BEGIN android-changed - // OSResourcesMonitor.ensurePhysicalMemoryCapacity(); - // END android-changed - return createStream(level, strategy1, noHeader1); - } - - private native long createStream(int level, int strategy1, boolean noHeader1); -} diff --git a/libcore/archive/src/main/java/java/util/zip/DeflaterOutputStream.java b/libcore/archive/src/main/java/java/util/zip/DeflaterOutputStream.java deleted file mode 100644 index 03769fb7b..000000000 --- a/libcore/archive/src/main/java/java/util/zip/DeflaterOutputStream.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.zip; - -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.harmony.archive.internal.nls.Messages; - -/** - * This class provides an implementation of {@code FilterOutputStream} that - * compresses data using the DEFLATE algorithm. Basically it wraps the - * {@code Deflater} class and takes care of the buffering. - * - * @see Deflater - */ -public class DeflaterOutputStream extends FilterOutputStream { - static final int BUF_SIZE = 512; - - /** - * The buffer for the data to be written to. - */ - protected byte[] buf; - - /** - * The deflater used. - */ - protected Deflater def; - - boolean done = false; - - /** - * This constructor lets you pass the {@code Deflater} specifying the - * compression algorithm. - * - * @param os - * is the {@code OutputStream} where to write the compressed data - * to. - * @param def - * is the specific {@code Deflater} that is used to compress - * data. - */ - public DeflaterOutputStream(OutputStream os, Deflater def) { - this(os, def, BUF_SIZE); - } - - /** - * This is the most basic constructor. You only need to pass the {@code - * OutputStream} to which the compressed data shall be written to. The - * default settings for the {@code Deflater} and internal buffer are used. - * In particular the {@code Deflater} produces a ZLIB header in the output - * stream. - * - * @param os - * is the OutputStream where to write the compressed data to. - */ - public DeflaterOutputStream(OutputStream os) { - this(os, new Deflater()); - } - - /** - * This constructor lets you specify both the compression algorithm as well - * as the internal buffer size to be used. - * - * @param os - * is the {@code OutputStream} where to write the compressed data - * to. - * @param def - * is the specific {@code Deflater} that will be used to compress - * data. - * @param bsize - * is the size to be used for the internal buffer. - */ - public DeflaterOutputStream(OutputStream os, Deflater def, int bsize) { - super(os); - if (os == null || def == null) { - throw new NullPointerException(); - } - if (bsize <= 0) { - throw new IllegalArgumentException(); - } - this.def = def; - buf = new byte[bsize]; - } - - /** - * Compress the data in the input buffer and write it to the underlying - * stream. - * - * @throws IOException - * If an error occurs during deflation. - */ - protected void deflate() throws IOException { - int x = 0; - do { - x = def.deflate(buf); - out.write(buf, 0, x); - } while (!def.needsInput()); - } - - /** - * Writes any unwritten compressed data to the underlying stream, the closes - * all underlying streams. This stream can no longer be used after close() - * has been called. - * - * @throws IOException - * If an error occurs while closing the data compression - * process. - */ - @Override - public void close() throws IOException { - if (!def.finished()) { - finish(); - } - def.end(); - out.close(); - } - - /** - * Writes any unwritten data to the underlying stream. Does not close the - * stream. - * - * @throws IOException - * If an error occurs. - */ - public void finish() throws IOException { - if (done) { - return; - } - def.finish(); - int x = 0; - while (!def.finished()) { - if (def.needsInput()) { - def.setInput(buf, 0, 0); - } - x = def.deflate(buf); - out.write(buf, 0, x); - } - done = true; - } - - @Override - public void write(int i) throws IOException { - byte[] b = new byte[1]; - b[0] = (byte) i; - write(b, 0, 1); - } - - /** - * Compresses {@code nbytes} of data from {@code buf} starting at - * {@code off} and writes it to the underlying stream. - * - * @param buffer - * the buffer of data to compress. - * @param off - * offset in buffer to extract data from. - * @param nbytes - * the number of bytes of data to read from the buffer. - * @throws IOException - * If an error occurs during writing. - */ - @Override - public void write(byte[] buffer, int off, int nbytes) throws IOException { - if (done) { - throw new IOException(Messages.getString("archive.26")); //$NON-NLS-1$ - } - // avoid int overflow, check null buf - if (off <= buffer.length && nbytes >= 0 && off >= 0 - && buffer.length - off >= nbytes) { - if (!def.needsInput()) { - throw new IOException(); - } - def.setInput(buffer, off, nbytes); - deflate(); - } else { - throw new ArrayIndexOutOfBoundsException(); - } - } -} diff --git a/libcore/archive/src/main/java/java/util/zip/GZIPInputStream.java b/libcore/archive/src/main/java/java/util/zip/GZIPInputStream.java deleted file mode 100644 index cc7a019a8..000000000 --- a/libcore/archive/src/main/java/java/util/zip/GZIPInputStream.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.zip; - -import java.io.EOFException; -import java.io.IOException; -import java.io.InputStream; - -import org.apache.harmony.archive.internal.nls.Messages; - -/** - * The {@code GZIPInputStream} class is used to read data stored in the GZIP - * format, reading and decompressing GZIP data from the underlying stream into - * its buffer. - */ -public class GZIPInputStream extends InflaterInputStream { - - private static final int FCOMMENT = 16; - - private static final int FEXTRA = 4; - - private static final int FHCRC = 2; - - private static final int FNAME = 8; - - /** - * The magic header for the GZIP format. - */ - public final static int GZIP_MAGIC = 0x8b1f; - - /** - * The checksum algorithm used when handling uncompressed data. - */ - protected CRC32 crc = new CRC32(); - - /** - * Indicates the end of the input stream. - */ - protected boolean eos = false; - - /** - * Construct a {@code GZIPInputStream} to read from GZIP data from the - * underlying stream. - * - * @param is - * the {@code InputStream} to read data from. - * @throws IOException - * if an {@code IOException} occurs. - */ - public GZIPInputStream(InputStream is) throws IOException { - this(is, BUF_SIZE); - } - - /** - * Construct a {@code GZIPInputStream} to read from GZIP data from the - * underlying stream. Set the internal buffer size to {@code size}. - * - * @param is - * the {@code InputStream} to read data from. - * @param size - * the internal read buffer size. - * @throws IOException - * if an {@code IOException} occurs. - */ - public GZIPInputStream(InputStream is, int size) throws IOException { - super(is, new Inflater(true), size); - byte[] header = new byte[10]; - readFully(header, 0, header.length); - if (getShort(header, 0) != GZIP_MAGIC) { - throw new IOException(Messages.getString("archive.1F")); //$NON-NLS-1$; - } - int flags = header[3]; - boolean hcrc = (flags & FHCRC) != 0; - if (hcrc) { - crc.update(header, 0, header.length); - } - if ((flags & FEXTRA) != 0) { - readFully(header, 0, 2); - if (hcrc) { - crc.update(header, 0, 2); - } - int length = getShort(header, 0); - while (length > 0) { - int max = length > buf.length ? buf.length : length; - int result = in.read(buf, 0, max); - if (result == -1) { - throw new EOFException(); - } - if (hcrc) { - crc.update(buf, 0, result); - } - length -= result; - } - } - if ((flags & FNAME) != 0) { - readZeroTerminated(hcrc); - } - if ((flags & FCOMMENT) != 0) { - readZeroTerminated(hcrc); - } - if (hcrc) { - readFully(header, 0, 2); - int crc16 = getShort(header, 0); - if ((crc.getValue() & 0xffff) != crc16) { - throw new IOException(Messages.getString("archive.20")); //$NON-NLS-1$ - } - crc.reset(); - } - } - - /** - * Closes this stream and any underlying streams. - */ - @Override - public void close() throws IOException { - eos = true; - super.close(); - } - - private long getLong(byte[] buffer, int off) { - long l = 0; - l |= (buffer[off] & 0xFF); - l |= (buffer[off + 1] & 0xFF) << 8; - l |= (buffer[off + 2] & 0xFF) << 16; - l |= ((long) (buffer[off + 3] & 0xFF)) << 24; - return l; - } - - private int getShort(byte[] buffer, int off) { - return (buffer[off] & 0xFF) | ((buffer[off + 1] & 0xFF) << 8); - } - - /** - * Reads and decompresses GZIP data from the underlying stream into the - * given buffer. - * - * @param buffer - * Buffer to receive data - * @param off - * Offset in buffer to store data - * @param nbytes - * Number of bytes to read - */ - @Override - public int read(byte[] buffer, int off, int nbytes) throws IOException { - if (closed) { - throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$ - } - // BEGIN android-changed - if (eos) { - return -1; - } - // avoid int overflow, check null buffer - if (off > buffer.length || nbytes < 0 || off < 0 - || buffer.length - off < nbytes) { - throw new ArrayIndexOutOfBoundsException(); - } - - int bytesRead; - try { - bytesRead = super.read(buffer, off, nbytes); - } finally { - eos = eof; // update eos after every read(), even when it throws - } - - if (bytesRead != -1) { - crc.update(buffer, off, bytesRead); - } - - if (eos) { - verifyCrc(); - } - - return bytesRead; - // END android-changed - } - - // BEGIN android-added - private void verifyCrc() throws IOException { - // Get non-compressed bytes read by fill - int size = inf.getRemaining(); - final int trailerSize = 8; // crc (4 bytes) + total out (4 bytes) - byte[] b = new byte[trailerSize]; - int copySize = (size > trailerSize) ? trailerSize : size; - - System.arraycopy(buf, len - size, b, 0, copySize); - readFully(b, copySize, trailerSize - copySize); - - if (getLong(b, 0) != crc.getValue()) { - throw new IOException(Messages.getString("archive.20")); //$NON-NLS-1$ - } - if ((int) getLong(b, 4) != inf.getTotalOut()) { - throw new IOException(Messages.getString("archive.21")); //$NON-NLS-1$ - } - } - // END android-added - - private void readFully(byte[] buffer, int offset, int length) - throws IOException { - int result; - while (length > 0) { - result = in.read(buffer, offset, length); - if (result == -1) { - throw new EOFException(); - } - offset += result; - length -= result; - } - } - - private void readZeroTerminated(boolean hcrc) throws IOException { - int result; - while ((result = in.read()) > 0) { - if (hcrc) { - crc.update(result); - } - } - if (result == -1) { - throw new EOFException(); - } - // Add the zero - if (hcrc) { - crc.update(result); - } - } -} diff --git a/libcore/archive/src/main/java/java/util/zip/GZIPOutputStream.java b/libcore/archive/src/main/java/java/util/zip/GZIPOutputStream.java deleted file mode 100644 index f146da18c..000000000 --- a/libcore/archive/src/main/java/java/util/zip/GZIPOutputStream.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.zip; - -import java.io.IOException; -import java.io.OutputStream; - -/** - * The {@code GZIPOutputStream} class is used to write data to a stream in the - * GZIP storage format. - */ -public class GZIPOutputStream extends DeflaterOutputStream { - - /** - * The checksum algorithm used when treating uncompressed data. - */ - protected CRC32 crc = new CRC32(); - - /** - * Construct a new {@code GZIPOutputStream} to write data in GZIP format to - * the underlying stream. - * - * @param os - * the {@code OutputStream} to write data to. - * @throws IOException - * if an {@code IOException} occurs. - */ - public GZIPOutputStream(OutputStream os) throws IOException { - this(os, BUF_SIZE); - } - - /** - * Construct a new {@code GZIPOutputStream} to write data in GZIP format to - * the underlying stream. Set the internal compression buffer to size - * {@code size}. - * - * @param os - * the {@code OutputStream} to write to. - * @param size - * the internal buffer size. - * @throws IOException - * if an {@code IOException} occurs. - */ - public GZIPOutputStream(OutputStream os, int size) throws IOException { - super(os, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size); - writeShort(GZIPInputStream.GZIP_MAGIC); - out.write(Deflater.DEFLATED); - out.write(0); // flags - writeLong(0); // mod time - out.write(0); // extra flags - out.write(0); // operating system - } - - /** - * Indicates to the stream that all data has been written out, and any GZIP - * terminal data can now be written. - * - * @throws IOException - * if an {@code IOException} occurs. - */ - @Override - public void finish() throws IOException { - super.finish(); - writeLong(crc.getValue()); - writeLong(crc.tbytes); - } - - /** - * Write up to nbytes of data from the given buffer, starting at offset off, - * to the underlying stream in GZIP format. - */ - @Override - public void write(byte[] buffer, int off, int nbytes) throws IOException { - super.write(buffer, off, nbytes); - crc.update(buffer, off, nbytes); - } - - private long writeLong(long i) throws IOException { - // Write out the long value as an unsigned int - int unsigned = (int) i; - out.write(unsigned & 0xFF); - out.write((unsigned >> 8) & 0xFF); - out.write((unsigned >> 16) & 0xFF); - out.write((unsigned >> 24) & 0xFF); - return i; - } - - private int writeShort(int i) throws IOException { - out.write(i & 0xFF); - out.write((i >> 8) & 0xFF); - return i; - } -} diff --git a/libcore/archive/src/main/java/java/util/zip/Inflater.java b/libcore/archive/src/main/java/java/util/zip/Inflater.java deleted file mode 100644 index 048d95979..000000000 --- a/libcore/archive/src/main/java/java/util/zip/Inflater.java +++ /dev/null @@ -1,450 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.zip; - -import org.apache.harmony.archive.internal.nls.Messages; - -// BEGIN android-added -import java.io.FileDescriptor; -// END android-added - -/** - * This class uncompresses data that was compressed using the DEFLATE - * algorithm (see specification). - *

- * Basically this class is part of the API to the stream based ZLIB compression - * library and is used as such by {@code InflaterInputStream} and its - * descendants. - *

- * The typical usage of a {@code Inflater} outside this package consists of a - * specific call to one of its constructors before being passed to an instance - * of {@code InflaterInputStream}. - * - * @see InflaterInputStream - * @see Deflater - */ -public class Inflater { - - private static final byte MAGIC_NUMBER = 120; - - static { - oneTimeInitialization(); - } - - // Fill in the JNI id caches - private static native void oneTimeInitialization(); - - private boolean finished; // Set by the inflateImpl native - - // BEGIN android-removed - // private boolean gotFirstHeaderByte; - // END android-removed - - int inLength; - - int inRead; - - private boolean needsDictionary; // Set by the inflateImpl native - - // BEGIN android-removed - // private boolean pass_magic_number_check = true; - // END android-removed - - private long streamHandle = -1; - - /** - * This constructor creates an inflater that expects a header from the input - * stream. Use {@code Inflater(boolean)} if the input comes without a ZLIB - * header. - */ - public Inflater() { - this(false); - } - - /** - * This constructor allows to create an inflater that expects no header from - * the input stream. - * - * @param noHeader - * {@code true} indicates that no ZLIB header comes with the - * input. - */ - public Inflater(boolean noHeader) { - streamHandle = createStream(noHeader); - // BEGIN android-removed - // gotFirstHeaderByte = noHeader; - // END android-removed - } - - private native long createStream(boolean noHeader1); - - /** - * Release any resources associated with this {@code Inflater}. Any unused - * input/output is discarded. This is also called by the finalize method. - */ - public synchronized void end() { - if (streamHandle != -1) { - endImpl(streamHandle); - inRead = 0; - inLength = 0; - streamHandle = -1; - } - } - - private native synchronized void endImpl(long handle); - - @Override - protected void finalize() { - end(); - } - - /** - * Indicates if the {@code Inflater} has inflated the entire deflated - * stream. If deflated bytes remain and {@code needsInput()} returns {@code - * true} this method will return {@code false}. This method should be - * called after all deflated input is supplied to the {@code Inflater}. - * - * @return {@code true} if all input has been inflated, {@code false} - * otherwise. - */ - public synchronized boolean finished() { - return finished; - } - - /** - * Returns the Adler32 checksum of either all bytes inflated, or the - * checksum of the preset dictionary if one has been supplied. - * - * @return The Adler32 checksum associated with this - * {@code Inflater}. - */ - public synchronized int getAdler() { - if (streamHandle == -1) { - throw new IllegalStateException(); - } - return getAdlerImpl(streamHandle); - } - - private native synchronized int getAdlerImpl(long handle); - - /** - * Returns the total number of bytes read by the {@code Inflater}. This - * method performs the same as {@code getTotalIn()} except that it returns a - * {@code long} value instead of an integer. - * - * @return the total number of bytes read. - */ - public synchronized long getBytesRead() { - // Throw NPE here - if (streamHandle == -1) { - throw new NullPointerException(); - } - return getTotalInImpl(streamHandle); - } - - /** - * Returns a the total number of bytes read by the {@code Inflater}. This - * method performs the same as {@code getTotalOut} except it returns a - * {@code long} value instead of an integer. - * - * @return the total bytes written to the output buffer. - */ - public synchronized long getBytesWritten() { - // Throw NPE here - if (streamHandle == -1) { - throw new NullPointerException(); - } - return getTotalOutImpl(streamHandle); - } - - /** - * Returns the number of bytes of current input remaining to be read by the - * inflater. - * - * @return the number of bytes of unread input. - */ - public synchronized int getRemaining() { - return inLength - inRead; - } - - /** - * Returns total number of bytes of input read by the {@code Inflater}. The - * result value is limited by {@code Integer.MAX_VALUE}. - * - * @return the total number of bytes read. - */ - public synchronized int getTotalIn() { - if (streamHandle == -1) { - throw new IllegalStateException(); - } - long totalIn = getTotalInImpl(streamHandle); - return (totalIn <= Integer.MAX_VALUE ? (int) totalIn - : Integer.MAX_VALUE); - } - - private synchronized native long getTotalInImpl(long handle); - - /** - * Returns total number of bytes written to the output buffer by the {@code - * Inflater}. The result value is limited by {@code Integer.MAX_VALUE}. - * - * @return the total bytes of output data written. - */ - public synchronized int getTotalOut() { - if (streamHandle == -1) { - throw new IllegalStateException(); - } - long totalOut = getTotalOutImpl(streamHandle); - return (totalOut <= Integer.MAX_VALUE ? (int) totalOut - : Integer.MAX_VALUE); - } - - private native synchronized long getTotalOutImpl(long handle); - - /** - * Inflates bytes from current input and stores them in {@code buf}. - * - * @param buf - * the buffer where decompressed data bytes are written. - * @return the number of bytes inflated. - * @throws DataFormatException - * if the underlying stream is corrupted or was not compressed - * using a {@code Deflater}. - */ - public int inflate(byte[] buf) throws DataFormatException { - return inflate(buf, 0, buf.length); - } - - /** - * Inflates up to n bytes from the current input and stores them in {@code - * buf} starting at {@code off}. - * - * @param buf - * the buffer to write inflated bytes to. - * @param off - * the offset in buffer where to start writing decompressed data. - * @param nbytes - * the number of inflated bytes to write to {@code buf}. - * @throws DataFormatException - * if the underlying stream is corrupted or was not compressed - * using a {@code Deflater}. - * @return the number of bytes inflated. - */ - public synchronized int inflate(byte[] buf, int off, int nbytes) - throws DataFormatException { - // avoid int overflow, check null buf - if (off <= buf.length && nbytes >= 0 && off >= 0 - && buf.length - off >= nbytes) { - if (nbytes == 0) - return 0; - - if (streamHandle == -1) { - throw new IllegalStateException(); - } - - // BEGIN android-removed - // if (!pass_magic_number_check) { - // throw new DataFormatException(); - // } - // END android-removed - - if (needsInput()) { - return 0; - } - - boolean neededDict = needsDictionary; - needsDictionary = false; - int result = inflateImpl(buf, off, nbytes, streamHandle); - if (needsDictionary && neededDict) { - throw new DataFormatException(Messages.getString("archive.27")); //$NON-NLS-1$ - } - return result; - } - throw new ArrayIndexOutOfBoundsException(); - } - - private native synchronized int inflateImpl(byte[] buf, int off, - int nbytes, long handle); - - /** - * Indicates whether the input bytes were compressed with a preset - * dictionary. This method should be called prior to {@code inflate()} to - * determine whether a dictionary is required. If so {@code setDictionary()} - * should be called with the appropriate dictionary prior to calling {@code - * inflate()}. - * - * @return {@code true} if a preset dictionary is required for inflation. - * @see #setDictionary(byte[]) - * @see #setDictionary(byte[], int, int) - */ - public synchronized boolean needsDictionary() { - return needsDictionary; - } - - /** - * Indicates that input has to be passed to the inflater. - * - * @return {@code true} if {@code setInput} has to be called before - * inflation can proceed. - * @see #setInput(byte[]) - */ - public synchronized boolean needsInput() { - return inRead == inLength; - } - - /** - * Resets the {@code Inflater}. Should be called prior to inflating a new - * set of data. - */ - public synchronized void reset() { - if (streamHandle == -1) { - throw new NullPointerException(); - } - finished = false; - needsDictionary = false; - inLength = inRead = 0; - resetImpl(streamHandle); - } - - private native synchronized void resetImpl(long handle); - - /** - * Sets the preset dictionary to be used for inflation to {@code buf}. - * {@code needsDictionary()} can be called to determine whether the current - * input was deflated using a preset dictionary. - * - * @param buf - * The buffer containing the dictionary bytes. - * @see #needsDictionary - */ - public synchronized void setDictionary(byte[] buf) { - setDictionary(buf, 0, buf.length); - } - - /** - * Like {@code setDictionary(byte[])}, allowing to define a specific region - * inside {@code buf} to be used as a dictionary. - *

- * The dictionary should be set if the {@link #inflate(byte[])} returned - * zero bytes inflated and {@link #needsDictionary()} returns - * true. - * - * @param buf - * the buffer containing the dictionary data bytes. - * @param off - * the offset of the data. - * @param nbytes - * the length of the data. - * @see #needsDictionary - */ - public synchronized void setDictionary(byte[] buf, int off, int nbytes) { - if (streamHandle == -1) { - throw new IllegalStateException(); - } - // avoid int overflow, check null buf - if (off <= buf.length && nbytes >= 0 && off >= 0 - && buf.length - off >= nbytes) { - setDictionaryImpl(buf, off, nbytes, streamHandle); - } else { - throw new ArrayIndexOutOfBoundsException(); - } - } - - private native synchronized void setDictionaryImpl(byte[] buf, int off, - int nbytes, long handle); - - /** - * Sets the current input to to be decrompressed. This method should only be - * called if {@code needsInput()} returns {@code true}. - * - * @param buf - * the input buffer. - * @see #needsInput - */ - public synchronized void setInput(byte[] buf) { - setInput(buf, 0, buf.length); - } - - /** - * Sets the current input to the region of the input buffer starting at - * {@code off} and ending at {@code nbytes - 1} where data is written after - * decompression. This method should only be called if {@code needsInput()} - * returns {@code true}. - * - * @param buf - * the input buffer. - * @param off - * the offset to read from the input buffer. - * @param nbytes - * the number of bytes to read. - * @see #needsInput - */ - public synchronized void setInput(byte[] buf, int off, int nbytes) { - if (streamHandle == -1) { - throw new IllegalStateException(); - } - // avoid int overflow, check null buf - if (off <= buf.length && nbytes >= 0 && off >= 0 - && buf.length - off >= nbytes) { - inRead = 0; - inLength = nbytes; - setInputImpl(buf, off, nbytes, streamHandle); - } else { - throw new ArrayIndexOutOfBoundsException(); - } - - // BEGIN android-removed - // if (!gotFirstHeaderByte && nbytes > 0) { - // pass_magic_number_check = (buf[off] == MAGIC_NUMBER); - // gotFirstHeaderByte = true; - //} - // END android-removed - } - - // BEGIN android-added - /** - * Sets the current input to the region within a file starting at {@code - * off} and ending at {@code nbytes - 1}. This method should only be called - * if {@code needsInput()} returns {@code true}. - * - * @param fd - * the input file. - * @param off - * the offset to read from in buffer. - * @param nbytes - * the number of bytes to read. - * @see #needsInput - */ - synchronized int setFileInput(FileDescriptor fd, long off, int nbytes) { - if (streamHandle == -1) { - throw new IllegalStateException(); - } - inRead = 0; - inLength = setFileInputImpl(fd, off, nbytes, streamHandle); - return inLength; - } - // END android-added - - private native synchronized void setInputImpl(byte[] buf, int off, - int nbytes, long handle); - - // BEGIN android-added - private native synchronized int setFileInputImpl(FileDescriptor fd, long off, - int nbytes, long handle); - // END android-added -} diff --git a/libcore/archive/src/main/java/java/util/zip/InflaterInputStream.java b/libcore/archive/src/main/java/java/util/zip/InflaterInputStream.java deleted file mode 100644 index 8a7c86b48..000000000 --- a/libcore/archive/src/main/java/java/util/zip/InflaterInputStream.java +++ /dev/null @@ -1,358 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.zip; - -import java.io.EOFException; -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; - -import org.apache.harmony.archive.internal.nls.Messages; - -/** - * This class provides an implementation of {@code FilterInputStream} that - * uncompresses data that was compressed using the DEFLATE algorithm - * (see specification). - * Basically it wraps the {@code Inflater} class and takes care of the - * buffering. - * - * @see Inflater - * @see DeflaterOutputStream - */ -public class InflaterInputStream extends FilterInputStream { - - /** - * The inflater used for this stream. - */ - protected Inflater inf; - - /** - * The input buffer used for decompression. - */ - protected byte[] buf; - - /** - * The length of the buffer. - */ - protected int len; - - boolean closed; - - /** - * True if this stream's last byte has been returned to the user. This - * could be because the underlying stream has been exhausted, or if errors - * were encountered while inflating that stream. - */ - boolean eof; - - static final int BUF_SIZE = 512; - - // BEGIN android-added - int nativeEndBufSize = 0; - // END android-added - - /** - * This is the most basic constructor. You only need to pass the {@code - * InputStream} from which the compressed data is to be read from. Default - * settings for the {@code Inflater} and internal buffer are be used. In - * particular the Inflater expects a ZLIB header from the input stream. - * - * @param is - * the {@code InputStream} to read data from. - */ - public InflaterInputStream(InputStream is) { - this(is, new Inflater(), BUF_SIZE); - } - - /** - * This constructor lets you pass a specifically initialized Inflater, - * for example one that expects no ZLIB header. - * - * @param is - * the {@code InputStream} to read data from. - * @param inf - * the specific {@code Inflater} for uncompressing data. - */ - public InflaterInputStream(InputStream is, Inflater inf) { - this(is, inf, BUF_SIZE); - } - - /** - * This constructor lets you specify both the {@code Inflater} as well as - * the internal buffer size to be used. - * - * @param is - * the {@code InputStream} to read data from. - * @param inf - * the specific {@code Inflater} for uncompressing data. - * @param bsize - * the size to be used for the internal buffer. - */ - public InflaterInputStream(InputStream is, Inflater inf, int bsize) { - super(is); - if (is == null || inf == null) { - throw new NullPointerException(); - } - if (bsize <= 0) { - throw new IllegalArgumentException(); - } - this.inf = inf; - // BEGIN android-changed - if (is instanceof ZipFile.RAFStream) { - nativeEndBufSize = bsize; - } else { - buf = new byte[bsize]; - } - // END android-changed - } - - /** - * Reads a single byte of decompressed data. - * - * @return the byte read. - * @throws IOException - * if an error occurs reading the byte. - */ - @Override - public int read() throws IOException { - byte[] b = new byte[1]; - if (read(b, 0, 1) == -1) { - return -1; - } - return b[0] & 0xff; - } - - /** - * Reads up to {@code nbytes} of decompressed data and stores it in - * {@code buffer} starting at {@code off}. - * - * @param buffer - * the buffer to write data to. - * @param off - * offset in buffer to start writing. - * @param nbytes - * number of bytes to read. - * @return Number of uncompressed bytes read - * @throws IOException - * if an IOException occurs. - */ - @Override - public int read(byte[] buffer, int off, int nbytes) throws IOException { - /* archive.1E=Stream is closed */ - if (closed) { - throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$ - } - - if (null == buffer) { - throw new NullPointerException(); - } - - if (off < 0 || nbytes < 0 || off + nbytes > buffer.length) { - throw new IndexOutOfBoundsException(); - } - - if (nbytes == 0) { - return 0; - } - - // BEGIN android-changed - if (eof) { - return -1; - } - - // avoid int overflow, check null buffer - if (off > buffer.length || nbytes < 0 || off < 0 - || buffer.length - off < nbytes) { - throw new ArrayIndexOutOfBoundsException(); - } - - do { - if (inf.needsInput()) { - fill(); - } - // Invariant: if reading returns -1 or throws, eof must be true. - // It may also be true if the next read() should return -1. - try { - int result = inf.inflate(buffer, off, nbytes); - eof = inf.finished(); - if (result > 0) { - return result; - } else if (eof) { - return -1; - } else if (inf.needsDictionary()) { - eof = true; - return -1; - } else if (len == -1) { - eof = true; - throw new EOFException(); - // If result == 0, fill() and try again - } - } catch (DataFormatException e) { - eof = true; - if (len == -1) { - throw new EOFException(); - } - throw (IOException) (new IOException().initCause(e)); - } - } while (true); - // END android-changed - } - - /** - * Fills the input buffer with data to be decompressed. - * - * @throws IOException - * if an {@code IOException} occurs. - */ - protected void fill() throws IOException { - if (closed) { - throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$ - } - // BEGIN android-changed - if (nativeEndBufSize > 0) { - ZipFile.RAFStream is = (ZipFile.RAFStream)in; - synchronized (is.mSharedRaf) { - long len = is.mLength - is.mOffset; - if (len > nativeEndBufSize) len = nativeEndBufSize; - int cnt = inf.setFileInput(is.mSharedRaf.getFD(), is.mOffset, (int)nativeEndBufSize); - is.skip(cnt); - } - } else { - if ((len = in.read(buf)) > 0) { - inf.setInput(buf, 0, len); - } - } - // END android-changed - } - - /** - * Skips up to n bytes of uncompressed data. - * - * @param nbytes - * the number of bytes to skip. - * @return the number of uncompressed bytes skipped. - * @throws IOException - * if an error occurs skipping. - */ - @Override - public long skip(long nbytes) throws IOException { - if (nbytes >= 0) { - // BEGIN android-changed - if (buf == null) { - buf = new byte[BUF_SIZE]; - } - // END android-changed - long count = 0, rem = 0; - while (count < nbytes) { - int x = read(buf, 0, - (rem = nbytes - count) > buf.length ? buf.length - : (int) rem); - if (x == -1) { - // BEGIN android-removed - // eof = true; - // END android-removed - return count; - } - count += x; - } - return count; - } - throw new IllegalArgumentException(); - } - - /** - * Returns 0 when when this stream has exhausted its input; and 1 otherwise. - * A result of 1 does not guarantee that further bytes can be returned, - * with or without blocking. - * - *

Although consistent with the RI, this behavior is inconsistent with - * {@link InputStream#available()}, and violates the Liskov - * Substitution Principle. This method should not be used. - * - * @return 0 if no further bytes are available. Otherwise returns 1, - * which suggests (but does not guarantee) that additional bytes are - * available. - * @throws IOException - * If an error occurs. - */ - @Override - public int available() throws IOException { - if (closed) { - // archive.1E=Stream is closed - throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$ - } - if (eof) { - return 0; - } - return 1; - } - - /** - * Closes the input stream. - * - * @throws IOException - * If an error occurs closing the input stream. - */ - @Override - public void close() throws IOException { - if (!closed) { - inf.end(); - closed = true; - eof = true; - super.close(); - } - } - - /** - * Marks the current position in the stream. This implementation overrides - * the super type implementation to do nothing at all. - * - * @param readlimit - * of no use. - */ - @Override - public void mark(int readlimit) { - // do nothing - } - - /** - * Reset the position of the stream to the last marked position. This - * implementation overrides the supertype implementation and always throws - * an {@link IOException IOException} when called. - * - * @throws IOException - * if the method is called - */ - @Override - public void reset() throws IOException { - throw new IOException(); - } - - /** - * Returns whether the receiver implements {@code mark} semantics. This type - * does not support {@code mark()}, so always responds {@code false}. - * - * @return false, always - */ - @Override - public boolean markSupported() { - return false; - } - -} diff --git a/libcore/archive/src/main/java/java/util/zip/ZipConstants.java b/libcore/archive/src/main/java/java/util/zip/ZipConstants.java deleted file mode 100644 index d00adc92a..000000000 --- a/libcore/archive/src/main/java/java/util/zip/ZipConstants.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.zip; - -interface ZipConstants { - - public static final long LOCSIG = 0x4034b50, EXTSIG = 0x8074b50, - CENSIG = 0x2014b50, ENDSIG = 0x6054b50; - - public static final int LOCHDR = 30, EXTHDR = 16, CENHDR = 46, ENDHDR = 22, - LOCVER = 4, LOCFLG = 6, LOCHOW = 8, LOCTIM = 10, LOCCRC = 14, - LOCSIZ = 18, LOCLEN = 22, LOCNAM = 26, LOCEXT = 28, EXTCRC = 4, - EXTSIZ = 8, EXTLEN = 12, CENVEM = 4, CENVER = 6, CENFLG = 8, - CENHOW = 10, CENTIM = 12, CENCRC = 16, CENSIZ = 20, CENLEN = 24, - CENNAM = 28, CENEXT = 30, CENCOM = 32, CENDSK = 34, CENATT = 36, - CENATX = 38, CENOFF = 42, ENDSUB = 8, ENDTOT = 10, ENDSIZ = 12, - ENDOFF = 16, ENDCOM = 20; -} diff --git a/libcore/archive/src/main/java/java/util/zip/ZipEntry.java b/libcore/archive/src/main/java/java/util/zip/ZipEntry.java deleted file mode 100644 index 9774b6ac5..000000000 --- a/libcore/archive/src/main/java/java/util/zip/ZipEntry.java +++ /dev/null @@ -1,755 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.zip; - -// BEGIN android-added -import java.io.EOFException; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.RandomAccessFile; -import java.io.UnsupportedEncodingException; -// END android-added -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; - -/** - * An instance of {@code ZipEntry} represents an entry within a ZIP-archive. - * An entry has attributes such as name (= path) or the size of its data. While - * an entry identifies data stored in an archive, it does not hold the data - * itself. For example when reading a ZIP-file you will first retrieve - * all its entries in a collection and then read the data for a specific entry - * through an input stream. - * - * @see ZipFile - * @see ZipOutputStream - */ -public class ZipEntry implements ZipConstants, Cloneable { - String name, comment; - - long compressedSize = -1, crc = -1, size = -1; - // BEGIN android-removed - // long dataOffset = -1; - // END android-removed - - int compressionMethod = -1, time = -1, modDate = -1; - - byte[] extra; - - // BEGIN android-added - /* - * Fields, present in the Central Directory Entry and Local File Entry. - * - * Not all of these are part of the interface, but we need them if we - * want to be able to copy entries from one archive to another without - * losing any meta-data. - * - * We use over-sized fields so we can indicate whether a field has been - * initialized or not. - */ - private int mVersionMadeBy; // CDE - private int mVersionToExtract; // CDE, LFE - private int mGPBitFlag; // CDE, LFE - // private int mCompressionMethod; // CDE, LFE = compressionMethod - // private int mLastModFileTime; // CDE, LFE = time - // private int mLastModFileDate; // CDE, LFE = modDate - // private long mCRC32; // CDE, LFE = crc - // private long mCompressedSize; // CDE, LFE = compressedSize - // private long mUncompressedSize; // CDE, LFE = size - int nameLen, extraLen, commentLen; - //private int mFileNameLength; // CDE, LFE - //private int mExtraFieldLength; // CDE, LFE - //private int mFileCommentLength; // CDE - private int mDiskNumberStart; // CDE - private int mInternalAttrs; // CDE - private long mExternalAttrs; // CDE - long mLocalHeaderRelOffset; // CDE ? dataOffset - // private String mFileName; // CDE, LFE = name - // private byte[] mExtraField; // CDE, LFE = extra - // private String mFileComment; // CDE = comment - - - // GPBitFlag 3: uses a Data Descriptor block (need for deflated data) - /*package*/ static final int USES_DATA_DESCR = 0x0008; - - // private static Calendar mCalendar = Calendar.getInstance(); - // END android-added - - /** - * Zip entry state: Deflated. - */ - public static final int DEFLATED = 8; - - /** - * Zip entry state: Stored. - */ - public static final int STORED = 0; - - /** - * Constructs a new {@code ZipEntry} with the specified name. - * - * @param name - * the name of the ZIP entry. - * @throws IllegalArgumentException - * if the name length is outside the range (> 0xFFFF). - */ - public ZipEntry(String name) { - if (name == null) { - throw new NullPointerException(); - } - if (name.length() > 0xFFFF) { - throw new IllegalArgumentException(); - } - this.name = name; - - // BEGIN android-added - mVersionMadeBy = 0x0317; // 03=UNIX, 17=spec v2.3 - mVersionToExtract = 20; // need deflate, not much else - mGPBitFlag = 0; - compressionMethod = -1; - time = -1; - modDate = -1; - crc = -1L; - compressedSize = -1L; - size = -1L; - extraLen = -1; - nameLen = -1; - mDiskNumberStart = 0; - mInternalAttrs = 0; - mExternalAttrs = 0x81b60020L; // matches WinZip - mLocalHeaderRelOffset = -1; - extra = null; - comment = null; - // END android-added - } - - /** - * Gets the comment for this {@code ZipEntry}. - * - * @return the comment for this {@code ZipEntry}, or {@code null} if there - * is no comment. If we're reading an archive with - * {@code ZipInputStream} the comment is not available. - */ - public String getComment() { - return comment; - } - - /** - * Gets the compressed size of this {@code ZipEntry}. - * - * @return the compressed size, or -1 if the compressed size has not been - * set. - */ - public long getCompressedSize() { - return compressedSize; - } - - /** - * Gets the checksum for this {@code ZipEntry}. - * - * @return the checksum, or -1 if the checksum has not been set. - */ - public long getCrc() { - return crc; - } - - /** - * Gets the extra information for this {@code ZipEntry}. - * - * @return a byte array containing the extra information, or {@code null} if - * there is none. - */ - public byte[] getExtra() { - return extra; - } - - /** - * Gets the compression method for this {@code ZipEntry}. - * - * @return the compression method, either {@code DEFLATED}, {@code STORED} - * or -1 if the compression method has not been set. - */ - public int getMethod() { - return compressionMethod; - } - - /** - * Gets the name of this {@code ZipEntry}. - * - * @return the entry name. - */ - public String getName() { - return name; - } - - /** - * Gets the uncompressed size of this {@code ZipEntry}. - * - * @return the uncompressed size, or {@code -1} if the size has not been - * set. - */ - public long getSize() { - return size; - } - - /** - * Gets the last modification time of this {@code ZipEntry}. - * - * @return the last modification time as the number of milliseconds since - * Jan. 1, 1970. - */ - public long getTime() { - if (time != -1) { - GregorianCalendar cal = new GregorianCalendar(); - cal.set(Calendar.MILLISECOND, 0); - cal.set(1980 + ((modDate >> 9) & 0x7f), ((modDate >> 5) & 0xf) - 1, - modDate & 0x1f, (time >> 11) & 0x1f, (time >> 5) & 0x3f, - (time & 0x1f) << 1); - return cal.getTime().getTime(); - } - return -1; - } - - /** - * Determine whether or not this {@code ZipEntry} is a directory. - * - * @return {@code true} when this {@code ZipEntry} is a directory, {@code - * false} otherwise. - */ - public boolean isDirectory() { - return name.charAt(name.length() - 1) == '/'; - } - - /** - * Sets the comment for this {@code ZipEntry}. - * - * @param string - * the comment for this entry. - */ - public void setComment(String string) { - if (string == null || string.length() <= 0xFFFF) { - comment = string; - } else { - throw new IllegalArgumentException(); - } - } - - /** - * Sets the compressed size for this {@code ZipEntry}. - * - * @param value - * the compressed size (in bytes). - */ - public void setCompressedSize(long value) { - compressedSize = value; - } - - /** - * Sets the checksum for this {@code ZipEntry}. - * - * @param value - * the checksum for this entry. - * @throws IllegalArgumentException - * if {@code value} is < 0 or > 0xFFFFFFFFL. - */ - public void setCrc(long value) { - if (value >= 0 && value <= 0xFFFFFFFFL) { - crc = value; - } else { - throw new IllegalArgumentException(); - } - } - - /** - * Sets the extra information for this {@code ZipEntry}. - * - * @param data - * a byte array containing the extra information. - * @throws IllegalArgumentException - * when the length of data is greater than 0xFFFF bytes. - */ - public void setExtra(byte[] data) { - if (data == null || data.length <= 0xFFFF) { - extra = data; - } else { - throw new IllegalArgumentException(); - } - } - - /** - * Sets the compression method for this {@code ZipEntry}. - * - * @param value - * the compression method, either {@code DEFLATED} or {@code - * STORED}. - * @throws IllegalArgumentException - * when value is not {@code DEFLATED} or {@code STORED}. - */ - public void setMethod(int value) { - if (value != STORED && value != DEFLATED) { - throw new IllegalArgumentException(); - } - compressionMethod = value; - } - - /** - * Sets the uncompressed size of this {@code ZipEntry}. - * - * @param value - * the uncompressed size for this entry. - * @throws IllegalArgumentException - * if {@code value} < 0 or {@code value} > 0xFFFFFFFFL. - */ - public void setSize(long value) { - if (value >= 0 && value <= 0xFFFFFFFFL) { - size = value; - } else { - throw new IllegalArgumentException(); - } - } - - /** - * Sets the modification time of this {@code ZipEntry}. - * - * @param value - * the modification time as the number of milliseconds since Jan. - * 1, 1970. - */ - public void setTime(long value) { - GregorianCalendar cal = new GregorianCalendar(); - cal.setTime(new Date(value)); - int year = cal.get(Calendar.YEAR); - if (year < 1980) { - modDate = 0x21; - time = 0; - } else { - modDate = cal.get(Calendar.DATE); - modDate = (cal.get(Calendar.MONTH) + 1 << 5) | modDate; - modDate = ((cal.get(Calendar.YEAR) - 1980) << 9) | modDate; - time = cal.get(Calendar.SECOND) >> 1; - time = (cal.get(Calendar.MINUTE) << 5) | time; - time = (cal.get(Calendar.HOUR_OF_DAY) << 11) | time; - } - } - - /** - * Returns the string representation of this {@code ZipEntry}. - * - * @return the string representation of this {@code ZipEntry}. - */ - @Override - public String toString() { - return name; - } - - // BEGIN android-removed - // ZipEntry(String name, String comment, byte[] extra, long modTime, - // long size, long compressedSize, long crc, int compressionMethod, - // long modDate, long offset) { - // this.name = name; - // this.comment = comment; - // this.extra = extra; - // time = (int) modTime; - // this.size = size; - // this.compressedSize = compressedSize; - // this.crc = crc; - // this.compressionMethod = compressionMethod; - // this.modDate = (int) modDate; - // dataOffset = offset; - // } - // END android-removed - - /** - * Constructs a new {@code ZipEntry} using the values obtained from {@code - * ze}. - * - * @param ze - * the {@code ZipEntry} from which to obtain values. - */ - public ZipEntry(ZipEntry ze) { - name = ze.name; - comment = ze.comment; - time = ze.time; - size = ze.size; - compressedSize = ze.compressedSize; - crc = ze.crc; - compressionMethod = ze.compressionMethod; - modDate = ze.modDate; - extra = ze.extra; - // BEGIN android-removed - // dataOffset = ze.dataOffset; - // END android-removed - // BEGIN android-added - mVersionMadeBy = ze.mVersionMadeBy; - mVersionToExtract = ze.mVersionToExtract; - mGPBitFlag = ze.mGPBitFlag; - extraLen = ze.extraLen; - nameLen = ze.nameLen; - mDiskNumberStart = ze.mDiskNumberStart; - mInternalAttrs = ze.mInternalAttrs; - mExternalAttrs = ze.mExternalAttrs; - mLocalHeaderRelOffset = ze.mLocalHeaderRelOffset; - // END android-added - } - - /** - * Returns a shallow copy of this entry. - * - * @return a copy of this entry. - */ - @Override - public Object clone() { - return new ZipEntry(this); - } - - /** - * Returns the hash code for this {@code ZipEntry}. - * - * @return the hash code of the entry. - */ - @Override - public int hashCode() { - return name.hashCode(); - } - - // BEGIN android-added - // readShortLE is not used. - // readIntLE is used only once in ZipFile. - /* - * Internal constructor. Creates a new ZipEntry by reading the - * Central Directory Entry from "in", which must be positioned at - * the CDE signature. - * - * On exit, "in" will be positioned at the start of the next entry. - */ - /*package*/ ZipEntry(LittleEndianReader ler, InputStream in) throws IOException { - - /* - * We're seeing performance issues when we call readShortLE and - * readIntLE, so we're going to read the entire header at once - * and then parse the results out without using any function calls. - * Uglier, but should be much faster. - * - * Note that some lines look a bit different, because the corresponding - * fields or locals are long and so we need to do & 0xffffffffl to avoid - * problems induced by sign extension. - */ - - byte[] hdrBuf = ler.hdrBuf; - myReadFully(in, hdrBuf); - - long sig = (hdrBuf[0] & 0xff) | ((hdrBuf[1] & 0xff) << 8) | - ((hdrBuf[2] & 0xff) << 16) | ((hdrBuf[3] << 24) & 0xffffffffL); - if (sig != CENSIG) - throw new ZipException("Central Directory Entry not found"); - - mVersionMadeBy = (hdrBuf[4] & 0xff) | ((hdrBuf[5] & 0xff) << 8); - mVersionToExtract = (hdrBuf[6] & 0xff) | ((hdrBuf[7] & 0xff) << 8); - mGPBitFlag = (hdrBuf[8] & 0xff) | ((hdrBuf[9] & 0xff) << 8); - compressionMethod = (hdrBuf[10] & 0xff) | ((hdrBuf[11] & 0xff) << 8); - time = (hdrBuf[12] & 0xff) | ((hdrBuf[13] & 0xff) << 8); - modDate = (hdrBuf[14] & 0xff) | ((hdrBuf[15] & 0xff) << 8); - crc = (hdrBuf[16] & 0xff) | ((hdrBuf[17] & 0xff) << 8) - | ((hdrBuf[18] & 0xff) << 16) - | ((hdrBuf[19] << 24) & 0xffffffffL); - compressedSize = (hdrBuf[20] & 0xff) | ((hdrBuf[21] & 0xff) << 8) - | ((hdrBuf[22] & 0xff) << 16) - | ((hdrBuf[23] << 24) & 0xffffffffL); - size = (hdrBuf[24] & 0xff) | ((hdrBuf[25] & 0xff) << 8) - | ((hdrBuf[26] & 0xff) << 16) - | ((hdrBuf[27] << 24) & 0xffffffffL); - nameLen = (hdrBuf[28] & 0xff) | ((hdrBuf[29] & 0xff) << 8); - extraLen = (hdrBuf[30] & 0xff) | ((hdrBuf[31] & 0xff) << 8); - commentLen = (hdrBuf[32] & 0xff) | ((hdrBuf[33] & 0xff) << 8); - mDiskNumberStart = (hdrBuf[34] & 0xff) | ((hdrBuf[35] & 0xff) << 8); - mInternalAttrs = (hdrBuf[36] & 0xff) | ((hdrBuf[37] & 0xff) << 8); - mExternalAttrs = (hdrBuf[38] & 0xff) | ((hdrBuf[39] & 0xff) << 8) - | ((hdrBuf[40] & 0xff) << 16) - | ((hdrBuf[41] << 24) & 0xffffffffL); - mLocalHeaderRelOffset = (hdrBuf[42] & 0xff) | ((hdrBuf[43] & 0xff) << 8) - | ((hdrBuf[44] & 0xff) << 16) - | ((hdrBuf[45] << 24) & 0xffffffffL); - - byte[] nameBytes = new byte[nameLen]; - myReadFully(in, nameBytes); - - byte[] commentBytes = null; - if (commentLen > 0) { - commentBytes = new byte[commentLen]; - myReadFully(in, commentBytes); - } - - if (extraLen > 0) { - extra = new byte[extraLen]; - myReadFully(in, extra); - } - - try { - /* - * The actual character set is "IBM Code Page 437". As of - * Sep 2006, the Zip spec (APPNOTE.TXT) supports UTF-8. When - * bit 11 of the GP flags field is set, the file name and - * comment fields are UTF-8. - * - * TODO: add correct UTF-8 support. - */ - name = new String(nameBytes, "ISO-8859-1"); - if (commentBytes != null) - comment = new String(commentBytes, "ISO-8859-1"); - else - comment = null; - } - catch (UnsupportedEncodingException uee) { - throw new InternalError(uee.getMessage()); - } - } - private void myReadFully(InputStream in, byte[] b) throws IOException { - int count; - int len = b.length; - int off = 0; - - while (len > 0) { - count = in.read(b, off, len); - if (count <= 0) - throw new EOFException(); - off += count; - len -= count; - } - } - - /*package*/ void setVersionToExtract(int version) { - mVersionToExtract = version; - } - - /*package*/ int getGPBitFlag() { - return mGPBitFlag; - } - /*package*/ void setGPBitFlag(int flags) { - mGPBitFlag = flags; - } - - /*package*/ long getLocalHeaderRelOffset() { - return mLocalHeaderRelOffset; - } - /*package*/ void setLocalHeaderRelOffset(long offset) { - mLocalHeaderRelOffset = offset; - } - - /*package*/ void setDateTime(int lastModFileDate, int lastModFileTime) { - time = lastModFileTime; - modDate = lastModFileDate; - } - - /* - * Read a two-byte short in little-endian order. - * - * The DataInput interface, which RandomAccessFile implements, provides - * a readInt() function. Unfortunately, it's defined to use big-endian. - */ - /*package*/ static int readShortLE(RandomAccessFile raf) throws IOException - { - int b0, b1; - - b0 = raf.read(); - b1 = raf.read(); - if (b1 < 0) - throw new EOFException("in ZipEntry.readShortLE(RandomAccessFile)"); - return b0 | (b1 << 8); - } - - /* - * Read a four-byte int in little-endian order. - */ - /*package*/ static long readIntLE(RandomAccessFile raf) throws IOException - { - int b0, b1, b2, b3; - - b0 = raf.read(); - b1 = raf.read(); - b2 = raf.read(); - b3 = raf.read(); - if (b3 < 0) - throw new EOFException("in ZipEntry.readIntLE(RandomAccessFile)"); - return b0 | (b1 << 8) | (b2 << 16) | (b3 << 24); // ATTENTION: DOES SIGN EXTENSION: IS THIS WANTED? - } - - static class LittleEndianReader { - private byte[] b = new byte[4]; - byte[] hdrBuf = new byte[CENHDR]; - - /* - * Read a two-byte short in little-endian order. - */ - int readShortLE(InputStream in) throws IOException { - if (in.read(b, 0, 2) == 2) { - return (b[0] & 0XFF) | ((b[1] & 0XFF) << 8); - } else { - throw new EOFException("in ZipEntry.readShortLE(InputStream)"); - } - } - - /* - * Read a four-byte int in little-endian order. - */ - long readIntLE(InputStream in) throws IOException { - if (in.read(b, 0, 4) == 4) { - return ( ((b[0] & 0XFF)) - | ((b[1] & 0XFF) << 8) - | ((b[2] & 0XFF) << 16) - | ((b[3] & 0XFF) << 24)) - & 0XFFFFFFFFL; // Here for sure NO sign extension is wanted. - } else { - throw new EOFException("in ZipEntry.readIntLE(InputStream)"); - } - } - } - - /* - * Write a two-byte short in little-endian order. - */ - /*package*/ static void writeShortLE(OutputStream out, int val) - throws IOException - { - out.write(val & 0xff); - out.write((val >> 8) & 0xff); - } - - /* - * Write a 4-byte int in little-endian order. This takes a long because - * all of our 4-byte values are stored locally in longs. - */ - /*package*/ static void writeIntLE(OutputStream out, long val) - throws IOException - { - if (val < 0) - throw new InternalError(); - out.write((int) val & 0xff); - out.write(((int) val >> 8) & 0xff); - out.write(((int) val >> 16) & 0xff); - out.write(((int) val >> 24) & 0xff); - } - - /* - * Write the Local File Header for this entry to the specified stream. - * - * Returns the #of bytes written. - */ - /*package*/ int writeLFH(OutputStream out) throws IOException { - if (compressionMethod < 0 || - time < 0 || - modDate < 0 || - crc < 0 || - compressedSize < 0 || - size < 0) - throw new InternalError(); - - writeIntLE(out, LOCSIG); - writeShortLE(out, mVersionToExtract); - writeShortLE(out, mGPBitFlag); - writeShortLE(out, compressionMethod); - writeShortLE(out, time); - writeShortLE(out, modDate); - writeIntLE(out, crc); - writeIntLE(out, compressedSize); - writeIntLE(out, size); - - byte[] nameBytes; - try { - nameBytes = name.getBytes("ISO-8859-1"); - } - catch (UnsupportedEncodingException uee) { - throw new InternalError(uee.getMessage()); - } - - int extraLen = 0; - if (extra != null) - extraLen = extra.length; - - writeShortLE(out, nameBytes.length); - writeShortLE(out, extraLen); - out.write(nameBytes); - if (extra != null) - out.write(extra); - - return LOCHDR + nameBytes.length + extraLen; - } - - /* - * Write the Data Descriptor for this entry to the specified stream. - * - * Returns the #of bytes written. - */ - /*package*/ int writeDD(OutputStream out) throws IOException { - writeIntLE(out, EXTSIG); - writeIntLE(out, crc); - writeIntLE(out, compressedSize); - writeIntLE(out, size); - return EXTHDR; - } - - /* - * Write the Central Directory Entry for this entry. - * - * Returns the #of bytes written. - */ - /*package*/ int writeCDE(OutputStream out) throws IOException { - writeIntLE(out, CENSIG); - writeShortLE(out, mVersionMadeBy); - writeShortLE(out, mVersionToExtract); - writeShortLE(out, mGPBitFlag); - writeShortLE(out, compressionMethod); - writeShortLE(out, time); - writeShortLE(out, modDate); - writeIntLE(out, crc); - writeIntLE(out, compressedSize); - writeIntLE(out, size); - - byte[] nameBytes = null, commentBytes = null; - try { - nameBytes = name.getBytes("ISO-8859-1"); - if (comment != null) - commentBytes = comment.getBytes("ISO-8859-1"); - } - catch (UnsupportedEncodingException uee) { - throw new InternalError(uee.getMessage()); - } - - int extraLen = 0, commentLen = 0; - if (extra != null) - extraLen = extra.length; - if (commentBytes != null) - commentLen = commentBytes.length; - - writeShortLE(out, nameBytes.length); - writeShortLE(out, extraLen); - writeShortLE(out, commentLen); - writeShortLE(out, mDiskNumberStart); - writeShortLE(out, mInternalAttrs); - writeIntLE(out, mExternalAttrs); - writeIntLE(out, mLocalHeaderRelOffset); - out.write(nameBytes); - if (extra != null) - out.write(extra); - if (commentBytes != null) - out.write(commentBytes); - - return CENHDR + nameBytes.length + extraLen + commentLen; - } - // END android-added -} diff --git a/libcore/archive/src/main/java/java/util/zip/ZipException.java b/libcore/archive/src/main/java/java/util/zip/ZipException.java deleted file mode 100644 index 6dab26f8c..000000000 --- a/libcore/archive/src/main/java/java/util/zip/ZipException.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.zip; - -import java.io.IOException; - -/** - * This runtime exception is thrown by {@code ZipFile} and {@code - * ZipInputStream} when the file or stream is not a valid ZIP file. - * - * @see ZipFile - * @see ZipInputStream - */ -public class ZipException extends IOException { - - private static final long serialVersionUID = 8000196834066748623L; - - /** - * Constructs a new {@code ZipException} instance. - */ - public ZipException() { - super(); - } - - /** - * Constructs a new {@code ZipException} instance with the specified - * message. - * - * @param detailMessage - * the detail message for the exception. - */ - public ZipException(String detailMessage) { - super(detailMessage); - } - -} diff --git a/libcore/archive/src/main/java/java/util/zip/ZipFile.java b/libcore/archive/src/main/java/java/util/zip/ZipFile.java deleted file mode 100644 index 653b2c963..000000000 --- a/libcore/archive/src/main/java/java/util/zip/ZipFile.java +++ /dev/null @@ -1,426 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.zip; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.RandomAccessFile; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.NoSuchElementException; - -/** - * This class provides random read access to a ZIP-archive file. - *

- * While {@code ZipInputStream} provides stream based read access to a - * ZIP-archive, this class implements more efficient (file based) access - * and makes use of the central directory within a ZIP-archive. - *

- * Use {@code ZipOutputStream} if you want to create an archive. - *

- * A temporary ZIP file can be marked for automatic deletion upon closing it. - * - * @see ZipEntry - * @see ZipOutputStream - */ -public class ZipFile implements ZipConstants { - - String fileName; - - File fileToDeleteOnClose; - - /** - * Open zip file for read. - */ - public static final int OPEN_READ = 1; - - /** - * Delete zip file when closed. - */ - public static final int OPEN_DELETE = 4; - - /** - * Constructs a new {@code ZipFile} with the specified file. - * - * @param file - * the file to read from. - * @throws ZipException - * if a ZIP error occurs. - * @throws IOException - * if an {@code IOException} occurs. - */ - public ZipFile(File file) throws ZipException, IOException { - this(file, OPEN_READ); - } - - /** - * Opens a file as ZIP-archive. "mode" must be {@code OPEN_READ} or - * {@code OPEN_DELETE} . The latter sets the "delete on exit" flag through a - * file. - * - * @param file - * the ZIP file to read. - * @param mode - * the mode of the file open operation. - * @throws IOException - * if an {@code IOException} occurs. - */ - public ZipFile(File file, int mode) throws IOException { - fileName = file.getPath(); - if (mode == OPEN_READ || mode == (OPEN_READ | OPEN_DELETE)) { - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkRead(fileName); - } - if ((mode & OPEN_DELETE) != 0) { - if (security != null) { - security.checkDelete(fileName); - } - fileToDeleteOnClose = file; // file.deleteOnExit(); - } - } else { - throw new IllegalArgumentException(); - } - - mRaf = new RandomAccessFile(fileName, "r"); - - mEntryList = new ArrayList(); - - readCentralDir(); - - /* - * No LinkedHashMap yet, so optimize lookup-by-name by creating - * a parallel data structure. - */ - mFastLookup = new HashMap(mEntryList.size() * 2); - for (int i = 0; i < mEntryList.size(); i++) { - ZipEntry entry = mEntryList.get(i); - - mFastLookup.put(entry.getName(), entry); - } - } - - /** - * Opens a ZIP archived file. - * - * @param name - * the name of the ZIP file. - * @throws IOException - * if an IOException occurs. - */ - public ZipFile(String name) throws IOException { - this(new File(name), OPEN_READ); - } - - @Override - protected void finalize() throws IOException { - close(); - } - - /** - * Closes this ZIP file. - * - * @throws IOException - * if an IOException occurs. - */ - public void close() throws IOException { - RandomAccessFile raf = mRaf; - - if (raf != null) { // Only close initialized instances - synchronized(raf) { - mRaf = null; - raf.close(); - } - if (fileToDeleteOnClose != null) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - new File(fileName).delete(); - return null; - } - }); - // fileToDeleteOnClose.delete(); - fileToDeleteOnClose = null; - } - } - } - - /** - * Returns an enumeration of the entries. The entries are listed in the - * order in which they appear in the ZIP archive. - * - * @return the enumeration of the entries. - */ - public Enumeration entries() { - return new Enumeration() { - private int i = 0; - - public boolean hasMoreElements() { - if (mRaf == null) throw new IllegalStateException("Zip File closed."); - return i < mEntryList.size(); - } - - public ZipEntry nextElement() { - if (mRaf == null) throw new IllegalStateException("Zip File closed."); - if (i >= mEntryList.size()) - throw new NoSuchElementException(); - return (ZipEntry) mEntryList.get(i++); - } - }; - } - - /** - * Gets the ZIP entry with the specified name from this {@code ZipFile}. - * - * @param entryName - * the name of the entry in the ZIP file. - * @return a {@code ZipEntry} or {@code null} if the entry name does not - * exist in the ZIP file. - */ - public ZipEntry getEntry(String entryName) { - if (entryName != null) { - ZipEntry ze = mFastLookup.get(entryName); - if (ze == null) ze = mFastLookup.get(entryName + "/"); - return ze; - } - throw new NullPointerException(); - } - - /** - * Returns an input stream on the data of the specified {@code ZipEntry}. - * - * @param entry - * the ZipEntry. - * @return an input stream of the data contained in the {@code ZipEntry}. - * @throws IOException - * if an {@code IOException} occurs. - */ - public InputStream getInputStream(ZipEntry entry) throws IOException { - /* - * Make sure this ZipEntry is in this Zip file. We run it through - * the name lookup. - */ - entry = getEntry(entry.getName()); - if (entry == null) - return null; - - /* - * Create a ZipInputStream at the right part of the file. - */ - RandomAccessFile raf = mRaf; - if (raf != null) { - synchronized (raf) { - // Unfortunately we don't know the entry data's start position. - // All we have is the position of the entry's local header. - // At position 28 we find the length of the extra data. - // In some cases this length differs from the one coming in - // the central header!!! - RAFStream rafstrm = new RAFStream(raf, entry.mLocalHeaderRelOffset + 28); - int localExtraLenOrWhatever = ler.readShortLE(rafstrm); - // Now we need to skip the name - // and this "extra" data or whatever it is: - rafstrm.skip(entry.nameLen + localExtraLenOrWhatever); - rafstrm.mLength = rafstrm.mOffset + entry.compressedSize; - if (entry.compressionMethod == ZipEntry.DEFLATED) { - return new InflaterInputStream(rafstrm, new Inflater(true)); - } else { - return rafstrm; - } - } - } - throw new IllegalStateException("Zip File closed"); - } - - /** - * Gets the file name of this {@code ZipFile}. - * - * @return the file name of this {@code ZipFile}. - */ - public String getName() { - return fileName; - } - - /** - * Returns the number of {@code ZipEntries} in this {@code ZipFile}. - * - * @return the number of entries in this file. - */ - public int size() { - return mEntryList.size(); - } - - /* - * Find the central directory and read the contents. - * - * The central directory can be followed by a variable-length comment - * field, so we have to scan through it backwards. The comment is at - * most 64K, plus we have 18 bytes for the end-of-central-dir stuff - * itself, plus apparently sometimes people throw random junk on the end - * just for the fun of it. - * - * This is all a little wobbly. If the wrong value ends up in the EOCD - * area, we're hosed. This appears to be the way that everbody handles - * it though, so we're in pretty good company if this fails. - */ - private void readCentralDir() throws IOException { - long scanOffset, stopOffset; - long sig; - - /* - * Scan back, looking for the End Of Central Directory field. If - * the archive doesn't have a comment, we'll hit it on the first - * try. - * - * No need to synchronize mRaf here -- we only do this when we - * first open the Zip file. - */ - scanOffset = mRaf.length() - ENDHDR; - if (scanOffset < 0) - throw new ZipException("too short to be Zip"); - - stopOffset = scanOffset - 65536; - if (stopOffset < 0) - stopOffset = 0; - - while (true) { - mRaf.seek(scanOffset); - if (ZipEntry.readIntLE(mRaf) == 101010256L) - break; - - //System.out.println("not found at " + scanOffset); - scanOffset--; - if (scanOffset < stopOffset) - throw new ZipException("EOCD not found; not a Zip archive?"); - } - - /* - * Found it, read the EOCD. - * - * For performance we want to use buffered I/O when reading the - * file. We wrap a buffered stream around the random-access file - * object. If we just read from the RandomAccessFile we'll be - * doing a read() system call every time. - */ - RAFStream rafs = new RAFStream(mRaf, mRaf.getFilePointer()); - BufferedInputStream bin = new BufferedInputStream(rafs, ENDHDR); - int diskNumber, diskWithCentralDir, numEntries, totalNumEntries; - //long centralDirSize; - long centralDirOffset; - //int commentLen; - - diskNumber = ler.readShortLE(bin); - diskWithCentralDir = ler.readShortLE(bin); - numEntries = ler.readShortLE(bin); - totalNumEntries = ler.readShortLE(bin); - /*centralDirSize =*/ ler.readIntLE(bin); - centralDirOffset = ler.readIntLE(bin); - /*commentLen =*/ ler.readShortLE(bin); - - if (numEntries != totalNumEntries || - diskNumber != 0 || - diskWithCentralDir != 0) - throw new ZipException("spanned archives not supported"); - - /* - * Seek to the first CDE and read all entries. - */ - rafs = new RAFStream(mRaf, centralDirOffset); - bin = new BufferedInputStream(rafs, 4096); - for (int i = 0; i < numEntries; i++) { - ZipEntry newEntry; - - newEntry = new ZipEntry(ler, bin); - mEntryList.add(newEntry); - } - } - - /* - * Local data items. - */ - private RandomAccessFile mRaf; - - ZipEntry.LittleEndianReader ler = new ZipEntry.LittleEndianReader(); - - /* - * What we really want here is a LinkedHashMap, because we want fast - * lookups by name, but we want to preserve the ordering of the archive - * entries. Unfortunately we don't yet have a LinkedHashMap - * implementation. - */ - private ArrayList mEntryList; - private HashMap mFastLookup; - - /* - * Wrap a stream around a RandomAccessFile. The RandomAccessFile - * is shared among all streams returned by getInputStream(), so we - * have to synchronize access to it. (We can optimize this by - * adding buffering here to reduce collisions.) - * - * We could support mark/reset, but we don't currently need them. - */ - static class RAFStream extends InputStream { - public RAFStream(RandomAccessFile raf, long pos) throws IOException { - mSharedRaf = raf; - mOffset = pos; - mLength = raf.length(); - } - - @Override - public int available() throws IOException { - return (mOffset < mLength ? 1 : 0); - } - - public int read() throws IOException { - if (read(singleByteBuf, 0, 1) == 1) return singleByteBuf[0] & 0XFF; - else return -1; - } - - public int read(byte[] b, int off, int len) throws IOException { - int count; - synchronized (mSharedRaf) { - mSharedRaf.seek(mOffset); - if (mOffset + len > mLength) len = (int) (mLength - mOffset); - count = mSharedRaf.read(b, off, len); - if (count > 0) { - mOffset += count; - } - else return -1; - } - return count; - } - - @Override - public long skip(long n) throws IOException { - if (mOffset + n > mLength) - n = mLength - mOffset; - mOffset += n; - return n; - } - - RandomAccessFile mSharedRaf; - long mOffset; - long mLength; - private byte[] singleByteBuf = new byte[1]; - } -} diff --git a/libcore/archive/src/main/java/java/util/zip/ZipInputStream.java b/libcore/archive/src/main/java/java/util/zip/ZipInputStream.java deleted file mode 100644 index f86cbe03c..000000000 --- a/libcore/archive/src/main/java/java/util/zip/ZipInputStream.java +++ /dev/null @@ -1,437 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.zip; - -import java.io.EOFException; -import java.io.IOException; -import java.io.InputStream; -import java.io.PushbackInputStream; -import java.util.jar.Attributes; -import java.util.jar.JarEntry; - -import org.apache.harmony.archive.internal.nls.Messages; -import org.apache.harmony.luni.util.Util; - -/** - * This class provides an implementation of {@code FilterInputStream} that - * uncompresses data from a ZIP-archive input stream. - *

- * A ZIP-archive is a collection of compressed (or uncompressed) files - - * the so called ZIP entries. Therefore when reading from a {@code - * ZipInputStream} first the entry's attributes will be retrieved with {@code - * getNextEntry} before its data is read. - *

- * While {@code InflaterInputStream} can read a compressed ZIP-archive - * entry, this extension can read uncompressed entries as well. - *

- * Use {@code ZipFile} if you can access the archive as a file directly. - * - * @see ZipEntry - * @see ZipFile - */ -public class ZipInputStream extends InflaterInputStream implements ZipConstants { - static final int DEFLATED = 8; - - static final int STORED = 0; - - static final int ZIPDataDescriptorFlag = 8; - - static final int ZIPLocalHeaderVersionNeeded = 20; - - // BEGIN android-removed - // private boolean zipClosed = false; - // END android-removed - - private boolean entriesEnd = false; - - private boolean hasDD = false; - - private int entryIn = 0; - - private int inRead, lastRead = 0; - - ZipEntry currentEntry; - - private final byte[] hdrBuf = new byte[LOCHDR - LOCVER]; - - private final CRC32 crc = new CRC32(); - - private byte[] nameBuf = new byte[256]; - - private char[] charBuf = new char[256]; - - /** - * Constructs a new {@code ZipInputStream} from the specified input stream. - * - * @param stream - * the input stream to representing a ZIP archive. - */ - public ZipInputStream(InputStream stream) { - super(new PushbackInputStream(stream, BUF_SIZE), new Inflater(true)); - if (stream == null) { - throw new NullPointerException(); - } - } - - /** - * Closes this {@code ZipInputStream}. - * - * @throws IOException - * if an {@code IOException} occurs. - */ - @Override - public void close() throws IOException { - // BEGIN android-changed - if (closed != true) { - closeEntry(); // Close the current entry - super.close(); - } - // END android-changed - } - - /** - * Closes the current ZIP entry and positions to read the next entry. - * - * @throws IOException - * if an {@code IOException} occurs. - */ - public void closeEntry() throws IOException { - // BEGIN android-changed - if (closed) { - throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$ - } - // END android-changed - if (currentEntry == null) { - return; - } - if (currentEntry instanceof java.util.jar.JarEntry) { - Attributes temp = ((JarEntry) currentEntry).getAttributes(); - if (temp != null && temp.containsKey("hidden")) { //$NON-NLS-1$ - return; - } - } - - /* - * The following code is careful to leave the ZipInputStream in a - * consistent state, even when close() results in an exception. It does - * so by: - * - pushing bytes back into the source stream - * - reading a data descriptor footer from the source stream - * - resetting fields that manage the entry being closed - */ - - // Ensure all entry bytes are read - Exception failure = null; - try { - skip(Long.MAX_VALUE); - } catch (Exception e) { - failure = e; - } - - int inB, out; - if (currentEntry.compressionMethod == DEFLATED) { - inB = inf.getTotalIn(); - out = inf.getTotalOut(); - } else { - inB = inRead; - out = inRead; - } - int diff = entryIn - inB; - // Pushback any required bytes - if (diff != 0) { - ((PushbackInputStream) in).unread(buf, len - diff, diff); - } - - try { - readAndVerifyDataDescriptor(inB, out); - } catch (Exception e) { - if (failure == null) { // otherwise we're already going to throw - failure = e; - } - } - - inf.reset(); - lastRead = inRead = entryIn = len = 0; - crc.reset(); - currentEntry = null; - - if (failure != null) { - if (failure instanceof IOException) { - throw (IOException) failure; - } else if (failure instanceof RuntimeException) { - throw (RuntimeException) failure; - } - AssertionError error = new AssertionError(); - error.initCause(failure); - throw error; - } - } - - private void readAndVerifyDataDescriptor(int inB, int out) throws IOException { - if (hasDD) { - in.read(hdrBuf, 0, EXTHDR); - if (getLong(hdrBuf, 0) != EXTSIG) { - throw new ZipException(Messages.getString("archive.1F")); //$NON-NLS-1$ - } - currentEntry.crc = getLong(hdrBuf, EXTCRC); - currentEntry.compressedSize = getLong(hdrBuf, EXTSIZ); - currentEntry.size = getLong(hdrBuf, EXTLEN); - } - if (currentEntry.crc != crc.getValue()) { - throw new ZipException(Messages.getString("archive.20")); //$NON-NLS-1$ - } - if (currentEntry.compressedSize != inB || currentEntry.size != out) { - throw new ZipException(Messages.getString("archive.21")); //$NON-NLS-1$ - } - } - - /** - * Reads the next entry from this {@code ZipInputStream} or {@code null} if - * no more entries are present. - * - * @return the next {@code ZipEntry} contained in the input stream. - * @throws IOException - * if an {@code IOException} occurs. - * @see ZipEntry - */ - public ZipEntry getNextEntry() throws IOException { - closeEntry(); - if (entriesEnd) { - return null; - } - - int x = 0, count = 0; - while (count != 4) { - count += x = in.read(hdrBuf, count, 4 - count); - if (x == -1) { - return null; - } - } - long hdr = getLong(hdrBuf, 0); - if (hdr == CENSIG) { - entriesEnd = true; - return null; - } - if (hdr != LOCSIG) { - return null; - } - - // Read the local header - count = 0; - while (count != (LOCHDR - LOCVER)) { - count += x = in.read(hdrBuf, count, (LOCHDR - LOCVER) - count); - if (x == -1) { - throw new EOFException(); - } - } - int version = getShort(hdrBuf, 0) & 0xff; - if (version > ZIPLocalHeaderVersionNeeded) { - throw new ZipException(Messages.getString("archive.22")); //$NON-NLS-1$ - } - int flags = getShort(hdrBuf, LOCFLG - LOCVER); - hasDD = ((flags & ZIPDataDescriptorFlag) == ZIPDataDescriptorFlag); - int cetime = getShort(hdrBuf, LOCTIM - LOCVER); - int cemodDate = getShort(hdrBuf, LOCTIM - LOCVER + 2); - int cecompressionMethod = getShort(hdrBuf, LOCHOW - LOCVER); - long cecrc = 0, cecompressedSize = 0, cesize = -1; - if (!hasDD) { - cecrc = getLong(hdrBuf, LOCCRC - LOCVER); - cecompressedSize = getLong(hdrBuf, LOCSIZ - LOCVER); - cesize = getLong(hdrBuf, LOCLEN - LOCVER); - } - int flen = getShort(hdrBuf, LOCNAM - LOCVER); - if (flen == 0) { - throw new ZipException(Messages.getString("archive.23")); //$NON-NLS-1$ - } - int elen = getShort(hdrBuf, LOCEXT - LOCVER); - - count = 0; - if (flen > nameBuf.length) { - nameBuf = new byte[flen]; - charBuf = new char[flen]; - } - while (count != flen) { - count += x = in.read(nameBuf, count, flen - count); - if (x == -1) { - throw new EOFException(); - } - } - currentEntry = createZipEntry(Util.convertUTF8WithBuf(nameBuf, charBuf, - 0, flen)); - currentEntry.time = cetime; - currentEntry.modDate = cemodDate; - currentEntry.setMethod(cecompressionMethod); - if (cesize != -1) { - currentEntry.setCrc(cecrc); - currentEntry.setSize(cesize); - currentEntry.setCompressedSize(cecompressedSize); - } - if (elen > 0) { - count = 0; - byte[] e = new byte[elen]; - while (count != elen) { - count += x = in.read(e, count, elen - count); - if (x == -1) { - throw new EOFException(); - } - } - currentEntry.setExtra(e); - } - return currentEntry; - } - - /* Read 4 bytes from the buffer and store it as an int */ - - /** - * Reads up to the specified number of uncompressed bytes into the buffer - * starting at the offset. - * - * @param buffer - * a byte array - * @param start - * the starting offset into the buffer - * @param length - * the number of bytes to read - * @return the number of bytes read - */ - @Override - public int read(byte[] buffer, int start, int length) throws IOException { - // BEGIN android-changed - if (closed) { - throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$ - } - if (inf.finished() || currentEntry == null) { - return -1; - } - // avoid int overflow, check null buffer - if (start > buffer.length || length < 0 || start < 0 - || buffer.length - start < length) { - throw new ArrayIndexOutOfBoundsException(); - } - - if (currentEntry.compressionMethod == STORED) { - int csize = (int) currentEntry.size; - if (inRead >= csize) { - return -1; - } - if (lastRead >= len) { - lastRead = 0; - if ((len = in.read(buf)) == -1) { - eof = true; - return -1; - } - entryIn += len; - } - int toRead = length > (len - lastRead) ? len - lastRead : length; - if ((csize - inRead) < toRead) { - toRead = csize - inRead; - } - System.arraycopy(buf, lastRead, buffer, start, toRead); - lastRead += toRead; - inRead += toRead; - crc.update(buffer, start, toRead); - return toRead; - } - if (inf.needsInput()) { - fill(); - if (len > 0) { - entryIn += len; - } - } - int read; - try { - read = inf.inflate(buffer, start, length); - } catch (DataFormatException e) { - throw new ZipException(e.getMessage()); - } - if (read == 0 && inf.finished()) { - return -1; - } - crc.update(buffer, start, read); - return read; - // END android-changed - } - - /** - * Skips up to the specified number of bytes in the current ZIP entry. - * - * @param value - * the number of bytes to skip. - * @return the number of bytes skipped. - * @throws IOException - * if an {@code IOException} occurs. - */ - @Override - public long skip(long value) throws IOException { - if (value >= 0) { - long skipped = 0; - byte[] b = new byte[1024]; - while (skipped != value) { - long rem = value - skipped; - int x = read(b, 0, (int) (b.length > rem ? rem : b.length)); - if (x == -1) { - return skipped; - } - skipped += x; - } - return skipped; - } - throw new IllegalArgumentException(); - } - - /** - * Returns 0 if the {@code EOF} has been reached, otherwise returns 1. - * - * @return 0 after {@code EOF} of current entry, 1 otherwise. - * @throws IOException - * if an IOException occurs. - */ - @Override - public int available() throws IOException { - // BEGIN android-changed - if (closed) { - throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$ - } - return (currentEntry == null || inRead < currentEntry.size) ? 1 : 0; - // END android-changed - } - - /** - * creates a {@link ZipEntry } with the given name. - * - * @param name - * the name of the entry. - * @return the created {@code ZipEntry}. - */ - protected ZipEntry createZipEntry(String name) { - return new ZipEntry(name); - } - - private int getShort(byte[] buffer, int off) { - return (buffer[off] & 0xFF) | ((buffer[off + 1] & 0xFF) << 8); - } - - private long getLong(byte[] buffer, int off) { - long l = 0; - l |= (buffer[off] & 0xFF); - l |= (buffer[off + 1] & 0xFF) << 8; - l |= (buffer[off + 2] & 0xFF) << 16; - l |= ((long) (buffer[off + 3] & 0xFF)) << 24; - return l; - } -} diff --git a/libcore/archive/src/main/java/java/util/zip/ZipOutputStream.java b/libcore/archive/src/main/java/java/util/zip/ZipOutputStream.java deleted file mode 100644 index 58e781f67..000000000 --- a/libcore/archive/src/main/java/java/util/zip/ZipOutputStream.java +++ /dev/null @@ -1,447 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.zip; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Vector; - -import org.apache.harmony.archive.internal.nls.Messages; - -/** - * This class provides an implementation of {@code FilterOutputStream} that - * compresses data entries into a ZIP-archive output stream. - *

- * {@code ZipOutputStream} is used to write {@code ZipEntries} to the underlying - * stream. Output from {@code ZipOutputStream} conforms to the {@code ZipFile} - * file format. - *

- * While {@code DeflaterOutputStream} can write a compressed ZIP-archive - * entry, this extension can write uncompressed entries as well. In this case - * special rules apply, for this purpose refer to the file format - * specification. - * - * @see ZipEntry - * @see ZipFile - */ -public class ZipOutputStream extends DeflaterOutputStream implements - ZipConstants { - - /** - * Indicates deflated entries. - */ - public static final int DEFLATED = 8; - - /** - * Indicates uncompressed entries. - */ - public static final int STORED = 0; - - static final int ZIPDataDescriptorFlag = 8; - - static final int ZIPLocalHeaderVersionNeeded = 20; - - private String comment; - - private final Vector entries = new Vector(); - - private int compressMethod = DEFLATED; - - private int compressLevel = Deflater.DEFAULT_COMPRESSION; - - private ByteArrayOutputStream cDir = new ByteArrayOutputStream(); - - private ZipEntry currentEntry; - - private final CRC32 crc = new CRC32(); - - private int offset = 0, curOffset = 0, nameLength; - - private byte[] nameBytes; - - /** - * Constructs a new {@code ZipOutputStream} with the specified output - * stream. - * - * @param p1 - * the {@code OutputStream} to write the data to. - */ - public ZipOutputStream(OutputStream p1) { - super(p1, new Deflater(Deflater.DEFAULT_COMPRESSION, true)); - } - - /** - * Closes the current {@code ZipEntry}, if any, and the underlying output - * stream. If the stream is already closed this method does nothing. - * - * @throws IOException - * If an error occurs closing the stream. - */ - @Override - public void close() throws IOException { - if (out != null) { - finish(); - out.close(); - out = null; - } - } - - /** - * Closes the current {@code ZipEntry}. Any entry terminal data is written - * to the underlying stream. - * - * @throws IOException - * If an error occurs closing the entry. - */ - public void closeEntry() throws IOException { - if (cDir == null) { - throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$ - } - if (currentEntry == null) { - return; - } - if (currentEntry.getMethod() == DEFLATED) { - super.finish(); - } - - // Verify values for STORED types - if (currentEntry.getMethod() == STORED) { - if (crc.getValue() != currentEntry.crc) { - throw new ZipException(Messages.getString("archive.20")); //$NON-NLS-1$ - } - if (currentEntry.size != crc.tbytes) { - throw new ZipException(Messages.getString("archive.21")); //$NON-NLS-1$ - } - } - curOffset = LOCHDR; - - // Write the DataDescriptor - if (currentEntry.getMethod() != STORED) { - curOffset += EXTHDR; - writeLong(out, EXTSIG); - writeLong(out, currentEntry.crc = crc.getValue()); - writeLong(out, currentEntry.compressedSize = def.getTotalOut()); - writeLong(out, currentEntry.size = def.getTotalIn()); - } - // Update the CentralDirectory - writeLong(cDir, CENSIG); - writeShort(cDir, ZIPLocalHeaderVersionNeeded); // Version created - writeShort(cDir, ZIPLocalHeaderVersionNeeded); // Version to extract - writeShort(cDir, currentEntry.getMethod() == STORED ? 0 - : ZIPDataDescriptorFlag); - writeShort(cDir, currentEntry.getMethod()); - writeShort(cDir, currentEntry.time); - writeShort(cDir, currentEntry.modDate); - writeLong(cDir, crc.getValue()); - if (currentEntry.getMethod() == DEFLATED) { - curOffset += writeLong(cDir, def.getTotalOut()); - writeLong(cDir, def.getTotalIn()); - } else { - curOffset += writeLong(cDir, crc.tbytes); - writeLong(cDir, crc.tbytes); - } - curOffset += writeShort(cDir, nameLength); - if (currentEntry.extra != null) { - curOffset += writeShort(cDir, currentEntry.extra.length); - } else { - writeShort(cDir, 0); - } - String c; - if ((c = currentEntry.getComment()) != null) { - writeShort(cDir, c.length()); - } else { - writeShort(cDir, 0); - } - writeShort(cDir, 0); // Disk Start - writeShort(cDir, 0); // Internal File Attributes - writeLong(cDir, 0); // External File Attributes - writeLong(cDir, offset); - cDir.write(nameBytes); - nameBytes = null; - if (currentEntry.extra != null) { - cDir.write(currentEntry.extra); - } - offset += curOffset; - if (c != null) { - cDir.write(c.getBytes()); - } - currentEntry = null; - crc.reset(); - def.reset(); - done = false; - } - - /** - * Indicates that all entries have been written to the stream. Any terminal - * information is written to the underlying stream. - * - * @throws IOException - * if an error occurs while terminating the stream. - */ - @Override - public void finish() throws IOException { - if (out == null) { - throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$ - } - if (cDir == null) { - return; - } - if (entries.size() == 0) { - throw new ZipException(Messages.getString("archive.28")); //$NON-NLS-1$; - } - if (currentEntry != null) { - closeEntry(); - } - int cdirSize = cDir.size(); - // Write Central Dir End - writeLong(cDir, ENDSIG); - writeShort(cDir, 0); // Disk Number - writeShort(cDir, 0); // Start Disk - writeShort(cDir, entries.size()); // Number of entries - writeShort(cDir, entries.size()); // Number of entries - writeLong(cDir, cdirSize); // Size of central dir - writeLong(cDir, offset); // Offset of central dir - if (comment != null) { - writeShort(cDir, comment.length()); - cDir.write(comment.getBytes()); - } else { - writeShort(cDir, 0); - } - // Write the central dir - out.write(cDir.toByteArray()); - cDir = null; - - } - - /** - * Writes entry information to the underlying stream. Data associated with - * the entry can then be written using {@code write()}. After data is - * written {@code closeEntry()} must be called to complete the writing of - * the entry to the underlying stream. - * - * @param ze - * the {@code ZipEntry} to store. - * @throws IOException - * If an error occurs storing the entry. - * @see #write - */ - public void putNextEntry(ZipEntry ze) throws java.io.IOException { - if (currentEntry != null) { - closeEntry(); - } - if (ze.getMethod() == STORED - || (compressMethod == STORED && ze.getMethod() == -1)) { - if (ze.crc == -1) { - /* [MSG "archive.20", "Crc mismatch"] */ - throw new ZipException(Messages.getString("archive.20")); //$NON-NLS-1$ - } - if (ze.size == -1 && ze.compressedSize == -1) { - /* [MSG "archive.21", "Size mismatch"] */ - throw new ZipException(Messages.getString("archive.21")); //$NON-NLS-1$ - } - if (ze.size != ze.compressedSize && ze.compressedSize != -1 - && ze.size != -1) { - /* [MSG "archive.21", "Size mismatch"] */ - throw new ZipException(Messages.getString("archive.21")); //$NON-NLS-1$ - } - } - /* [MSG "archive.1E", "Stream is closed"] */ - if (cDir == null) { - throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$ - } - if (entries.contains(ze.name)) { - /* [MSG "archive.29", "Entry already exists: {0}"] */ - throw new ZipException(Messages.getString("archive.29", ze.name)); //$NON-NLS-1$ - } - nameLength = utf8Count(ze.name); - if (nameLength > 0xffff) { - /* [MSG "archive.2A", "Name too long: {0}"] */ - throw new IllegalArgumentException(Messages.getString( - "archive.2A", ze.name)); //$NON-NLS-1$ - } - - def.setLevel(compressLevel); - currentEntry = ze; - entries.add(currentEntry.name); - if (currentEntry.getMethod() == -1) { - currentEntry.setMethod(compressMethod); - } - writeLong(out, LOCSIG); // Entry header - writeShort(out, ZIPLocalHeaderVersionNeeded); // Extraction version - writeShort(out, currentEntry.getMethod() == STORED ? 0 - : ZIPDataDescriptorFlag); - writeShort(out, currentEntry.getMethod()); - if (currentEntry.getTime() == -1) { - currentEntry.setTime(System.currentTimeMillis()); - } - writeShort(out, currentEntry.time); - writeShort(out, currentEntry.modDate); - - if (currentEntry.getMethod() == STORED) { - if (currentEntry.size == -1) { - currentEntry.size = currentEntry.compressedSize; - } else if (currentEntry.compressedSize == -1) { - currentEntry.compressedSize = currentEntry.size; - } - writeLong(out, currentEntry.crc); - writeLong(out, currentEntry.size); - writeLong(out, currentEntry.size); - } else { - writeLong(out, 0); - writeLong(out, 0); - writeLong(out, 0); - } - writeShort(out, nameLength); - if (currentEntry.extra != null) { - writeShort(out, currentEntry.extra.length); - } else { - writeShort(out, 0); - } - nameBytes = toUTF8Bytes(currentEntry.name, nameLength); - out.write(nameBytes); - if (currentEntry.extra != null) { - out.write(currentEntry.extra); - } - } - - /** - * Sets the {@code ZipFile} comment associated with the file being written. - * - * @param comment - * the comment associated with the file. - */ - public void setComment(String comment) { - if (comment.length() > 0xFFFF) { - throw new IllegalArgumentException(Messages.getString("archive.2B")); //$NON-NLS-1$ - } - this.comment = comment; - } - - /** - * Sets the compression level to be used for writing entry data. This level - * may be set on a per entry basis. The level must have a value between -1 - * and 8 according to the {@code Deflater} compression level bounds. - * - * @param level - * the compression level (ranging from -1 to 8). - * @see Deflater - */ - public void setLevel(int level) { - if (level < Deflater.DEFAULT_COMPRESSION - || level > Deflater.BEST_COMPRESSION) { - throw new IllegalArgumentException(); - } - compressLevel = level; - } - - /** - * Sets the compression method to be used when compressing entry data. - * method must be one of {@code STORED} (for no compression) or {@code - * DEFLATED}. - * - * @param method - * the compression method to use. - */ - public void setMethod(int method) { - if (method != STORED && method != DEFLATED) { - throw new IllegalArgumentException(); - } - compressMethod = method; - - } - - private long writeLong(OutputStream os, long i) throws java.io.IOException { - // Write out the long value as an unsigned int - os.write((int) (i & 0xFF)); - os.write((int) (i >> 8) & 0xFF); - os.write((int) (i >> 16) & 0xFF); - os.write((int) (i >> 24) & 0xFF); - return i; - } - - private int writeShort(OutputStream os, int i) throws java.io.IOException { - os.write(i & 0xFF); - os.write((i >> 8) & 0xFF); - return i; - - } - - /** - * Writes data for the current entry to the underlying stream. - * - * @exception IOException - * If an error occurs writing to the stream - */ - @Override - public void write(byte[] buffer, int off, int nbytes) - throws java.io.IOException { - // avoid int overflow, check null buf - if ((off < 0 || (nbytes < 0) || off > buffer.length) - || (buffer.length - off < nbytes)) { - throw new IndexOutOfBoundsException(); - } - - if (currentEntry == null) { - /* [MSG "archive.2C", "No active entry"] */ - throw new ZipException(Messages.getString("archive.2C")); //$NON-NLS-1$ - } - - if (currentEntry.getMethod() == STORED) { - out.write(buffer, off, nbytes); - } else { - super.write(buffer, off, nbytes); - } - crc.update(buffer, off, nbytes); - } - - static int utf8Count(String value) { - int total = 0; - for (int i = value.length(); --i >= 0;) { - char ch = value.charAt(i); - if (ch < 0x80) { - total++; - } else if (ch < 0x800) { - total += 2; - } else { - total += 3; - } - } - return total; - } - - static byte[] toUTF8Bytes(String value, int length) { - byte[] result = new byte[length]; - int pos = result.length; - for (int i = value.length(); --i >= 0;) { - char ch = value.charAt(i); - if (ch < 0x80) { - result[--pos] = (byte) ch; - } else if (ch < 0x800) { - result[--pos] = (byte) (0x80 | (ch & 0x3f)); - result[--pos] = (byte) (0xc0 | (ch >> 6)); - } else { - result[--pos] = (byte) (0x80 | (ch & 0x3f)); - result[--pos] = (byte) (0x80 | ((ch >> 6) & 0x3f)); - result[--pos] = (byte) (0xe0 | (ch >> 12)); - } - } - return result; - } -} diff --git a/libcore/archive/src/main/java/java/util/zip/package.html b/libcore/archive/src/main/java/java/util/zip/package.html deleted file mode 100644 index 2a09bf164..000000000 --- a/libcore/archive/src/main/java/java/util/zip/package.html +++ /dev/null @@ -1,9 +0,0 @@ - - -

- This package contains classes for compressing and decompressing data in - ZIP and GZIP file formats. -

- @since Android 1.0 - - diff --git a/libcore/archive/src/main/java/org/apache/harmony/archive/internal/nls/Messages.java b/libcore/archive/src/main/java/org/apache/harmony/archive/internal/nls/Messages.java deleted file mode 100644 index 3ba50fa5a..000000000 --- a/libcore/archive/src/main/java/org/apache/harmony/archive/internal/nls/Messages.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL. - * All changes made to this file manually will be overwritten - * if this tool runs again. Better make changes in the template file. - */ - -// BEGIN android-note -// Redundant code has been removed and is now called from MsgHelp. -// END android-note - -package org.apache.harmony.archive.internal.nls; - -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -// BEGIN android-changed -import org.apache.harmony.luni.util.MsgHelp; -// END android-changed - -/** - * This class retrieves strings from a resource bundle and returns them, - * formatting them with MessageFormat when required. - *

- * It is used by the system classes to provide national language support, by - * looking up messages in the - * org.apache.harmony.archive.internal.nls.messages - * - * resource bundle. Note that if this file is not available, or an invalid key - * is looked up, or resource bundle support is not available, the key itself - * will be returned as the associated message. This means that the KEY - * should a reasonable human-readable (english) string. - * - */ -public class Messages { - - // BEGIN android-changed - private static final String sResource = - "org.apache.harmony.archive.internal.nls.messages"; - // END android-changed - - /** - * Retrieves a message which has no arguments. - * - * @param msg - * String the key to look up. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg) { - // BEGIN android-changed - return MsgHelp.getString(sResource, msg); - // END android-changed - } - - /** - * Retrieves a message which takes 1 argument. - * - * @param msg - * String the key to look up. - * @param arg - * Object the object to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, Object arg) { - return getString(msg, new Object[] { arg }); - } - - /** - * Retrieves a message which takes 1 integer argument. - * - * @param msg - * String the key to look up. - * @param arg - * int the integer to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, int arg) { - return getString(msg, new Object[] { Integer.toString(arg) }); - } - - /** - * Retrieves a message which takes 1 character argument. - * - * @param msg - * String the key to look up. - * @param arg - * char the character to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, char arg) { - return getString(msg, new Object[] { String.valueOf(arg) }); - } - - /** - * Retrieves a message which takes 2 arguments. - * - * @param msg - * String the key to look up. - * @param arg1 - * Object an object to insert in the formatted output. - * @param arg2 - * Object another object to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, Object arg1, Object arg2) { - return getString(msg, new Object[] { arg1, arg2 }); - } - - /** - * Retrieves a message which takes several arguments. - * - * @param msg - * String the key to look up. - * @param args - * Object[] the objects to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, Object[] args) { - // BEGIN android-changed - return MsgHelp.getString(sResource, msg, args); - // END android-changed - } - - // BEGIN android-note - // Duplicate code was dropped in favor of using MsgHelp. - // END android-note -} diff --git a/libcore/archive/src/main/java/org/apache/harmony/archive/internal/nls/messages.properties b/libcore/archive/src/main/java/org/apache/harmony/archive/internal/nls/messages.properties deleted file mode 100644 index e909af038..000000000 --- a/libcore/archive/src/main/java/org/apache/harmony/archive/internal/nls/messages.properties +++ /dev/null @@ -1,70 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# messages for EN locale -archive.00=Canonical encodings have been incorrectly modified -archive.01=Encoding cannot be less than zero -archive.02=End of buffer read whilst trying to decode codec -archive.03=End of buffer read whilst trying to decode codec -archive.04=ADef and BDef should never both be true -archive.05=Invalid codec encoding byte ({0}) found -archive.06=Something has gone wrong during parsing references -archive.07=Bad header -archive.08=Invalid segment major version -archive.09=Invalid segment minor version -archive.0A=There are attribute flags, and I don't know what to do with them -archive.0B=Not yet implemented -archive.0C=No idea what the adc is for yet -archive.0D=Failed to read some data from input stream -archive.0E=Failed to read any data from input stream -archive.0F=L must be between 1..255 -archive.10=Population encoding does not work unless the number of elements are known -archive.11=Cannot calculate token codec from {0} and {1} -archive.12=Cannot have a RunCodec for a negative number of numbers -archive.13=Must supply both codecs for a RunCodec -archive.14=Some unused flags are non-zero -archive.15=1<=b<=5 -archive.16=1<=h<=256 -archive.17=0<=s<=2 -archive.18=0<=d<=1 -archive.19=b=1 -> h=256 -archive.1A=h=256 -> b\!=5 -archive.1B=Delta encoding used without passing in last value; this is a coding error -archive.1C=End of stream reached whilst decoding -archive.1D=Unknown s value -archive.1E=Stream is closed -archive.1F=Unknown format -archive.20=Crc mismatch -archive.21=Size mismatch -archive.22=Cannot read version -archive.23=Entry is not named -archive.24=Unable to open\: {0} -archive.25=Invalid zip file\: {0} -archive.26=attempt to write after finish -archive.27=Needs dictionary -archive.28=No entries -archive.29=Entry already exists: {0} -archive.2A=Name too long: {0} -archive.2B=String is too long -archive.2C=No active entry -archive.2D=Missing version attribute\: {0} -archive.2E=Manifest is too long -archive.2F=NUL character in a manifest -archive.30=Invalid attribute {0} -archive.31={0} failed verification of {1} -archive.32={0} has invalid digest for {1} in {2} -archive.33=A length of the encoded header name "{1}" exceeded maximum length {2} -archive.34=A jar verifier does not support more than one entry with the same name diff --git a/libcore/archive/src/main/java/org/apache/harmony/archive/util/Util.java b/libcore/archive/src/main/java/org/apache/harmony/archive/util/Util.java deleted file mode 100644 index b15108a38..000000000 --- a/libcore/archive/src/main/java/org/apache/harmony/archive/util/Util.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.util; - -public class Util { - - public static boolean ASCIIIgnoreCaseRegionMatches(String s1, int start1, - String s2, int start2, int length) { - - if (s1 != null && s2 != null) { - if (start1 < 0 || length > s1.length() - start1) { - return false; - } - if (start2 < 0 || length > s2.length() - start2) { - return false; - } - - char c1, c2; - for (int i = 0; i < length; i++) { - if ((c1 = s1.charAt(start1++)) != (c2 = s2.charAt(start2++)) - && toASCIIUpperCase(c1) != toASCIIUpperCase(c2)) { - return false; - } - } - return true; - } - throw new NullPointerException(); - } - - public static final boolean equalsIgnoreCase(byte[] buf1, byte[] buf2) { - if (buf1 == buf2) { - return true; - } - - if (buf1 == null || buf2 == null || buf1.length != buf2.length) { - return false; - } - - byte b1, b2; - - for (int i = 0; i < buf1.length; i++) { - if ((b1 = buf1[i]) != (b2 = buf2[i]) - && toASCIIUpperCase(b1) != toASCIIUpperCase(b2)) { - return false; - } - } - return true; - } - - static final char toASCIIUpperCase(char c) { - if ('a' <= c && c <= 'z') { - return (char) (c - ('a' - 'A')); - } - return c; - } - - static final byte toASCIIUpperCase(byte b) { - if ('a' <= b && b <= 'z') { - return (byte) (b - ('a' - 'A')); - } - return b; - } -} diff --git a/libcore/archive/src/main/native/hy2sie.h b/libcore/archive/src/main/native/hy2sie.h deleted file mode 100644 index d40d0e841..000000000 --- a/libcore/archive/src/main/native/hy2sie.h +++ /dev/null @@ -1,114 +0,0 @@ -#if !defined(hy2sie_h) -#define hy2sie_h - - -#include "JNIHelp.h" -#include "jni.h" -#include "sieb.h" - - -typedef int BOOLEAN; -#define TRUE 1 -#define FALSE 0 - - -// mc: Stuff adopted from hyport.h: - -/** HyMaxPath was chosen from unix MAXPATHLEN. Override in platform - * specific hyfile implementations if needed. - */ -#define HyMaxPath 1024 - - - -// Following definitions from hycomp.h: - -/** - * Define common types: - *

    - *
  • U_32 / I_32 - unsigned/signed 32 bits
  • - *
  • U_16 / I_16 - unsigned/signed 16 bits
  • - *
  • U_8 / I_8 - unsigned/signed 8 bits (bytes -- not to be - * confused with char)
  • - *
- */ - -typedef int I_32; -typedef short I_16; -typedef signed char I_8; /* chars can be unsigned */ -typedef unsigned int U_32; -typedef unsigned short U_16; -typedef unsigned char U_8; - -typedef long long I_64; -typedef unsigned long long U_64; - -/** - * Define platform specific types: - *
    - *
  • UDATA - unsigned data, can be used as an integer or - * pointer storage
  • - *
  • IDATA - signed data, can be used as an integer or - * pointer storage
  • - *
- */ -/* FIXME: POINTER64 */ - -typedef I_32 IDATA; -typedef U_32 UDATA; - - -// Further required definitions from Harmony: - -#define HYCONST64(x) x##L - - -#define HY_CFUNC -#define HY_CDATA -#define PROTOTYPE(x) x -#define VMCALL -#define PVMCALL * -#define NORETURN - -#define GLOBAL_DATA(symbol) ((void*)&(symbol)) - - -// Following definitions substitute the HyPortLibrary simply with the JNIEnv - -typedef JNIEnv HyPortLibrary; - -#define PORT_ACCESS_FROM_ENV(env) HyPortLibrary *privatePortLibrary = env -#define PORT_ACCESS_FROM_PORT(portLibrary) HyPortLibrary *privatePortLibrary = portLibrary -#define PORTLIB privatePortLibrary - - -// Following defintion is used to avoide quite a few signedness warnings: -#define mcSignednessBull void * - - -// Following the substitution of hyfile: - -#include - -#define HyOpenRead O_RDONLY -#define hyfile_open(a, b, c) open(a, b, c) - -#define HySeekEnd SEEK_END -#define HySeekSet SEEK_SET -#define HySeekCur SEEK_CUR -#define hyfile_seek(a, b, c) lseek(a, b, c) - -#define hyfile_read(a, b, c) read(a, b, c) - -#define hyfile_close(a) close(a) - - -// And further substitutions: - -#define hymem_allocate_memory(byteCount) sieb_malloc(privatePortLibrary, byteCount) -#define hymem_free_memory(pointer) sieb_free(privatePortLibrary, pointer) - -#define ioh_convertToPlatform(path) sieb_convertToPlatform (path) - - -#endif /* hy2sie_h */ diff --git a/libcore/archive/src/main/native/hycomp.h b/libcore/archive/src/main/native/hycomp.h deleted file mode 100644 index 029d4fe29..000000000 --- a/libcore/archive/src/main/native/hycomp.h +++ /dev/null @@ -1 +0,0 @@ -#include "hy2sie.h" diff --git a/libcore/archive/src/main/native/hymutex.h b/libcore/archive/src/main/native/hymutex.h deleted file mode 100644 index 5c98ebdb1..000000000 --- a/libcore/archive/src/main/native/hymutex.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#if !defined(hymutex_h) -#define hymutex_h - -#include -#include - -typedef pthread_mutex_t MUTEX; - -/* MUTEX_INIT */ -#define MUTEX_INIT(mutex) (pthread_mutex_init(&(mutex), NULL) == 0) - -/* MUTEX_DESTROY */ -#define MUTEX_DESTROY(mutex) pthread_mutex_destroy(&(mutex)) - -/* MUTEX_ENTER */ -#define MUTEX_ENTER(mutex) pthread_mutex_lock(&(mutex)) - -/* - * MUTEX_TRY_ENTER - * returns 0 on success - */ -#define MUTEX_TRY_ENTER(mutex) pthread_mutex_trylock(&(mutex)) - -/* MUTEX_EXIT */ -#define MUTEX_EXIT(mutex) pthread_mutex_unlock(&(mutex)) - -#endif /* hymutex_h */ diff --git a/libcore/archive/src/main/native/hyport.h b/libcore/archive/src/main/native/hyport.h deleted file mode 100644 index 029d4fe29..000000000 --- a/libcore/archive/src/main/native/hyport.h +++ /dev/null @@ -1 +0,0 @@ -#include "hy2sie.h" diff --git a/libcore/archive/src/main/native/java_util_zip_Adler32.c b/libcore/archive/src/main/native/java_util_zip_Adler32.c deleted file mode 100644 index 1b02a11aa..000000000 --- a/libcore/archive/src/main/native/java_util_zip_Adler32.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "jni.h" -#include "hy2sie.h" -#include "zlib.h" -#include "sieb.h" - -JNIEXPORT jlong JNICALL -Java_java_util_zip_Adler32_updateImpl (JNIEnv * env, jobject recv, - jbyteArray buf, int off, int len, - jlong crc) -{ - jbyte *b; - jboolean isCopy; - jlong result; - - b = (*env)->GetPrimitiveArrayCritical (env, buf, &isCopy); - if (b == NULL) { - throwNewOutOfMemoryError(env, ""); - return 0; - } - result = (jlong) adler32 ((uLong) crc, (Bytef *) (b + off), (uInt) len); - (*env)->ReleasePrimitiveArrayCritical (env, buf, b, JNI_ABORT); - - return result; -} - -JNIEXPORT jlong JNICALL -Java_java_util_zip_Adler32_updateByteImpl (JNIEnv * env, jobject recv, - jint val, jlong crc) -{ - Bytef bytefVal = val; - return adler32 ((uLong) crc, (Bytef *) (&bytefVal), 1); -} - - -/* - * JNI registration - */ -static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ - { "updateImpl", "([BIIJ)J", Java_java_util_zip_Adler32_updateImpl }, - { "updateByteImpl", "(IJ)J", Java_java_util_zip_Adler32_updateByteImpl }, -}; -int register_java_util_zip_Adler32(JNIEnv* env) -{ - return jniRegisterNativeMethods(env, "java/util/zip/Adler32", - gMethods, NELEM(gMethods)); -} diff --git a/libcore/archive/src/main/native/java_util_zip_CRC32.c b/libcore/archive/src/main/native/java_util_zip_CRC32.c deleted file mode 100644 index cee25e5e9..000000000 --- a/libcore/archive/src/main/native/java_util_zip_CRC32.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "hy2sie.h" -#include "sieb.h" - -#include "zlib.h" - -JNIEXPORT jlong JNICALL -Java_java_util_zip_CRC32_updateImpl (JNIEnv * env, jobject recv, - jbyteArray buf, int off, int len, - jlong crc) -{ - jbyte *b; - jlong result; - - b = ((*env)->GetPrimitiveArrayCritical (env, buf, 0)); - if (b == NULL) { - throwNewOutOfMemoryError(env, ""); - return -1; - } - result = crc32 ((uLong) crc, (Bytef *) (b + off), (uInt) len); - ((*env)->ReleasePrimitiveArrayCritical (env, buf, b, JNI_ABORT)); - return result; -} - -JNIEXPORT jlong JNICALL -Java_java_util_zip_CRC32_updateByteImpl (JNIEnv * env, jobject recv, - jbyte val, jlong crc) -{ - return crc32 ((uLong) crc, (Bytef *) (&val), 1); -} - - -/* - * JNI registration - */ -static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ - { "updateImpl", "([BIIJ)J", Java_java_util_zip_CRC32_updateImpl }, - { "updateByteImpl", "(BJ)J", Java_java_util_zip_CRC32_updateByteImpl }, -}; -int register_java_util_zip_CRC32(JNIEnv* env) -{ - return jniRegisterNativeMethods(env, "java/util/zip/CRC32", - gMethods, NELEM(gMethods)); -} diff --git a/libcore/archive/src/main/native/java_util_zip_Deflater.c b/libcore/archive/src/main/native/java_util_zip_Deflater.c deleted file mode 100644 index 2e0e268da..000000000 --- a/libcore/archive/src/main/native/java_util_zip_Deflater.c +++ /dev/null @@ -1,321 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "hy2sie.h" - -#include "zlib.h" -#include "zip.h" -#include "jni.h" - -#ifndef HY_ZIP_API -void zfree PROTOTYPE ((void *opaque, void *address)); -void *zalloc PROTOTYPE ((void *opaque, U_32 items, U_32 size)); -#endif - - -static struct { - jfieldID inRead; - jfieldID finished; -} gCachedFields; - - -JNIEXPORT void JNICALL -Java_java_util_zip_Deflater_setDictionaryImpl (JNIEnv * env, jobject recv, - jbyteArray dict, int off, - int len, jlong handle) -{ - PORT_ACCESS_FROM_ENV (env); - int err = 0; - unsigned char *dBytes; - JCLZipStream *stream = (JCLZipStream *) ((IDATA) handle); - - dBytes = jclmem_allocate_memory (env, len); - if (dBytes == NULL) - { - throwNewOutOfMemoryError (env, ""); - return; - } - (*env)->GetByteArrayRegion (env, dict, off, len, (mcSignednessBull)dBytes); - err = deflateSetDictionary (stream->stream, (Bytef *) dBytes, len); - if (err != Z_OK) - { - jclmem_free_memory (env, dBytes); - THROW_ZIP_EXCEPTION(env, err, IllegalArgumentException); - return; - } - stream->dict = (U_8*) dBytes; -} - -JNIEXPORT jlong JNICALL -Java_java_util_zip_Deflater_getTotalInImpl (JNIEnv * env, jobject recv, - jlong handle) -{ - JCLZipStream *stream; - - stream = (JCLZipStream *) ((IDATA) handle); - return stream->stream->total_in; -} - -JNIEXPORT jlong JNICALL -Java_java_util_zip_Deflater_getTotalOutImpl (JNIEnv * env, jobject recv, - jlong handle) -{ - JCLZipStream *stream; - - stream = (JCLZipStream *) ((IDATA) handle); - return stream->stream->total_out; -} - -JNIEXPORT jint JNICALL -Java_java_util_zip_Deflater_getAdlerImpl (JNIEnv * env, jobject recv, - jlong handle) -{ - JCLZipStream *stream; - - stream = (JCLZipStream *) ((IDATA) handle); - - return stream->stream->adler; -} - -/* Create a new stream . This stream cannot be used until it has been properly initialized. */ -JNIEXPORT jlong JNICALL -Java_java_util_zip_Deflater_createStream (JNIEnv * env, jobject recv, - jint level, jint strategy, - jboolean noHeader) -{ - PORT_ACCESS_FROM_ENV (env); - JCLZipStream *jstream; - z_stream *stream; - int err = 0; - // BEGIN android-changed - int wbits = 12; // Was 15, made it 12 to reduce memory consumption. Use MAX - // for fastest. - int mlevel = 5; // Was 9, made it 5 to reduce memory consumption. Might result - // in out-of-memory problems according to some web pages. The - // ZLIB docs are a bit vague, unfortunately. The default - // results in 2 x 128K being allocated per Deflater, which is - // not acceptable. - // END android-changed -#ifdef HY_ZIP_API - VMI_ACCESS_FROM_ENV (env); - VMIZipFunctionTable *zipFuncs; - zipFuncs = (*VMI)->GetZipFunctions(VMI); -#endif - - /*Allocate mem for wrapped struct */ - jstream = jclmem_allocate_memory (env, sizeof (JCLZipStream)); - if (jstream == NULL) - { - throwNewOutOfMemoryError (env, ""); - return -1; - } - /*Allocate the z_stream */ - stream = jclmem_allocate_memory (env, sizeof (z_stream)); - if (stream == NULL) - { - jclmem_free_memory (env, jstream); - throwNewOutOfMemoryError (env, ""); - return -1; - } - stream->opaque = (void *) privatePortLibrary; - stream->zalloc = zalloc; - stream->zfree = zfree; - jstream->stream = stream; - jstream->dict = NULL; - jstream->inaddr = NULL; - - /*Unable to find official doc that this is the way to avoid zlib header use. However doc in zipsup.c claims it is so */ - if (noHeader) - wbits = wbits / -1; - err = deflateInit2 (stream, level, Z_DEFLATED, /*Only supported ZLIB method */ - wbits, /*Window bits to use. 15 is fastest but consumes the most memory */ - // BEGIN android-changed - mlevel, /*Memory allocation for internal compression state. 9 uses the most. */ - // END android-changed - strategy); - if (err != Z_OK) { - THROW_ZIP_EXCEPTION(env, err, IllegalArgumentException); - return -1; - } - - return (jlong) ((IDATA) jstream); -} - -JNIEXPORT void JNICALL -Java_java_util_zip_Deflater_setInputImpl (JNIEnv * env, jobject recv, - jbyteArray buf, jint off, jint len, - jlong handle) -{ - PORT_ACCESS_FROM_ENV (env); - - jbyte *in; - JCLZipStream *stream; - - stream = (JCLZipStream *) ((IDATA) handle); - if (stream->inaddr != NULL) /*Input has already been provided, free the old buffer */ - jclmem_free_memory (env, stream->inaddr); - stream->inaddr = jclmem_allocate_memory (env, len); - if (stream->inaddr == NULL) - { - throwNewOutOfMemoryError (env, ""); - return; - } - in = ((*env)->GetPrimitiveArrayCritical (env, buf, 0)); - if (in == NULL) { - throwNewOutOfMemoryError(env, ""); - return; - } - memcpy (stream->inaddr, (in + off), len); - ((*env)->ReleasePrimitiveArrayCritical (env, buf, in, JNI_ABORT)); - stream->stream->next_in = (Bytef *) stream->inaddr; - stream->stream->avail_in = len; - - return; -} - -JNIEXPORT jint JNICALL -Java_java_util_zip_Deflater_deflateImpl (JNIEnv * env, jobject recv, - jbyteArray buf, int off, int len, - jlong handle, int flushParm) -{ - jbyte *out; - JCLZipStream *stream; - jint err = 0; - jint sin, sout, inBytes = 0; - - /* We need to get the number of bytes already read */ - inBytes = - ((*env)-> - GetIntField (env, recv, - gCachedFields.inRead)); - - stream = (JCLZipStream *) ((IDATA) handle); - stream->stream->avail_out = len; - sin = stream->stream->total_in; - sout = stream->stream->total_out; - out = ((*env)->GetPrimitiveArrayCritical (env, buf, 0)); - if (out == NULL) { - throwNewOutOfMemoryError(env, ""); - return -1; - } - stream->stream->next_out = (Bytef *) out + off; - err = deflate (stream->stream, flushParm); - ((*env)->ReleasePrimitiveArrayCritical (env, buf, out, 0)); - if (err != Z_OK) { - if (err == Z_MEM_ERROR) { - throwNewOutOfMemoryError(env, ""); - return 0; - } - if (err == Z_STREAM_END) - { - ((*env)-> - SetBooleanField (env, recv, - gCachedFields.finished, - JNI_TRUE)); - return stream->stream->total_out - sout; - } - } - if (flushParm != Z_FINISH) - { - /* Need to update the number of input bytes read. */ - ((*env)-> - SetIntField (env, recv, - gCachedFields.inRead, - (jint) stream->stream->total_in - sin + inBytes)); - } - return stream->stream->total_out - sout; -} - -JNIEXPORT void JNICALL -Java_java_util_zip_Deflater_endImpl (JNIEnv * env, jobject recv, jlong handle) -{ - PORT_ACCESS_FROM_ENV (env); - JCLZipStream *stream; - - stream = (JCLZipStream *) ((IDATA) handle); - - deflateEnd (stream->stream); - if (stream->inaddr != NULL) - jclmem_free_memory (env, stream->inaddr); - if (stream->dict != NULL) - jclmem_free_memory (env, stream->dict); - jclmem_free_memory (env, stream->stream); - jclmem_free_memory (env, stream); -} - -JNIEXPORT void JNICALL -Java_java_util_zip_Deflater_resetImpl (JNIEnv * env, jobject recv, - jlong handle) -{ - JCLZipStream *stream; - - stream = (JCLZipStream *) ((IDATA) handle); - deflateReset (stream->stream); -} - -JNIEXPORT void JNICALL -Java_java_util_zip_Deflater_setLevelsImpl (JNIEnv * env, jobject recv, - int level, int strategy, - jlong handle) -{ - JCLZipStream *stream; - jbyte b = 0; - int err = 0; - - if (handle == -1) - { - throwNewIllegalStateException (env, ""); - return; - } - stream = (JCLZipStream *) ((IDATA) handle); - stream->stream->next_out = (Bytef *) & b; - err = deflateParams (stream->stream, level, strategy); - if (err != Z_OK) { - THROW_ZIP_EXCEPTION(env, err, IllegalStateException); - } -} - -JNIEXPORT void JNICALL -Java_java_util_zip_Deflater_oneTimeInitialization (JNIEnv * env, jclass clazz) -{ - memset(&gCachedFields, 0, sizeof(gCachedFields)); - gCachedFields.inRead = (*env)->GetFieldID (env, clazz, "inRead", "I"); - gCachedFields.finished = (*env)->GetFieldID (env, clazz, "finished", "Z"); -} - -/* - * JNI registration - */ -static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ - { "setDictionaryImpl", "([BIIJ)V", Java_java_util_zip_Deflater_setDictionaryImpl }, - { "getTotalInImpl", "(J)J", Java_java_util_zip_Deflater_getTotalInImpl }, - { "getTotalOutImpl", "(J)J", Java_java_util_zip_Deflater_getTotalOutImpl }, - { "getAdlerImpl", "(J)I", Java_java_util_zip_Deflater_getAdlerImpl }, - { "createStream", "(IIZ)J", Java_java_util_zip_Deflater_createStream }, - { "setInputImpl", "([BIIJ)V", Java_java_util_zip_Deflater_setInputImpl }, - { "deflateImpl", "([BIIJI)I", Java_java_util_zip_Deflater_deflateImpl }, - { "endImpl", "(J)V", Java_java_util_zip_Deflater_endImpl }, - { "resetImpl", "(J)V", Java_java_util_zip_Deflater_resetImpl }, - { "setLevelsImpl", "(IIJ)V", Java_java_util_zip_Deflater_setLevelsImpl }, - { "oneTimeInitialization", "()V", Java_java_util_zip_Deflater_oneTimeInitialization }, -}; -int register_java_util_zip_Deflater(JNIEnv* env) -{ - return jniRegisterNativeMethods(env, "java/util/zip/Deflater", - gMethods, NELEM(gMethods)); -} diff --git a/libcore/archive/src/main/native/java_util_zip_Inflater.c b/libcore/archive/src/main/native/java_util_zip_Inflater.c deleted file mode 100644 index 4b30d4e35..000000000 --- a/libcore/archive/src/main/native/java_util_zip_Inflater.c +++ /dev/null @@ -1,352 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "hy2sie.h" -#include "zip.h" - -#include "zlib.h" -#include -#define jclmem_allocate_memory(env, byteCount) sieb_malloc(env, byteCount) -#define jclmem_free_memory(env, pointer) sieb_free(env, pointer) - -#include - -void throwNewDataFormatException (JNIEnv * env, const char *message); - -void zfree PROTOTYPE ((void *opaque, void *address)); -void *zalloc PROTOTYPE ((void *opaque, U_32 items, U_32 size)); - - -static struct { - jfieldID inRead; - jfieldID finished; - jfieldID needsDictionary; -} gCachedFields; - - - -/* Create a new stream . This stream cannot be used until it has been properly initialized. */ -JNIEXPORT jlong JNICALL -Java_java_util_zip_Inflater_createStream (JNIEnv * env, jobject recv, - jboolean noHeader) -{ - PORT_ACCESS_FROM_ENV (env); - - JCLZipStream *jstream; - z_stream *stream; - int err = 0; - int wbits = 15; /*Use MAX for fastest */ -#ifdef HY_ZIP_API - VMI_ACCESS_FROM_ENV (env); - VMIZipFunctionTable *zipFuncs; - zipFuncs = (*VMI)->GetZipFunctions(VMI); -#endif - - /*Allocate mem for wrapped struct */ - jstream = jclmem_allocate_memory (env, sizeof (JCLZipStream)); - if (jstream == NULL) - { - throwNewOutOfMemoryError (env, ""); - return -1; - } - - /*Allocate the z_stream */ - stream = jclmem_allocate_memory (env, sizeof (z_stream)); - if (stream == NULL) - { - jclmem_free_memory (env, jstream); - throwNewOutOfMemoryError (env, ""); - return -1; - } - stream->opaque = (void *) privatePortLibrary; - stream->zalloc = zalloc; - stream->zfree = zfree; - stream->adler = 1; - jstream->stream = stream; - jstream->dict = NULL; - jstream->inaddr = NULL; - jstream->inCap = 0; - - /*Unable to find official doc that this is the way to avoid zlib header use. However doc in zipsup.c claims it is so. */ - if (noHeader) - wbits = wbits / -1; - err = inflateInit2 (stream, wbits); /*Window bits to use. 15 is fastest but consumes the most memory */ - - if (err != Z_OK) - { - jclmem_free_memory (env, stream); - jclmem_free_memory (env, jstream); - THROW_ZIP_EXCEPTION(env, err, IllegalArgumentException); - return -1; - } - - return (jlong) ((IDATA) jstream); -} - -JNIEXPORT void JNICALL -Java_java_util_zip_Inflater_setInputImpl (JNIEnv * env, jobject recv, - jbyteArray buf, jint off, jint len, - jlong handle) -{ - PORT_ACCESS_FROM_ENV (env); - - jbyte *in; - U_8 *baseAddr; - JCLZipStream *stream = (JCLZipStream *) ((IDATA) handle); - - if (stream->inaddr != NULL) /*Input has already been provided, free the old buffer */ - jclmem_free_memory (env, stream->inaddr); - baseAddr = jclmem_allocate_memory (env, len); - if (baseAddr == NULL) - { - throwNewOutOfMemoryError (env, ""); - return; - } - stream->inaddr = baseAddr; - stream->stream->next_in = (Bytef *) baseAddr; - stream->stream->avail_in = len; - in = ((*env)->GetPrimitiveArrayCritical (env, buf, 0)); - if (in == NULL) { - throwNewOutOfMemoryError(env, ""); - return; - } - memcpy (baseAddr, (in + off), len); - ((*env)->ReleasePrimitiveArrayCritical (env, buf, in, JNI_ABORT)); - return; -} - -JNIEXPORT jint JNICALL -Java_java_util_zip_Inflater_setFileInputImpl (JNIEnv * env, jobject recv, - jobject javaFileDescriptor, jlong off, jint len, jlong handle) -{ - PORT_ACCESS_FROM_ENV (env); - - U_8 * baseAddr; - JCLZipStream * stream = (JCLZipStream *) ((IDATA) handle); - - if (stream->inCap < len) { - // No input buffer as yet (or one that is too small). - jclmem_free_memory(env, stream->inaddr); - baseAddr = jclmem_allocate_memory(env, len); - if (baseAddr == NULL) - { - throwNewOutOfMemoryError(env, ""); - return -1; - } - stream->inaddr = baseAddr; - } - stream->stream->next_in = (Bytef *) stream->inaddr; - stream->stream->avail_in = len; - - int fd = jniGetFDFromFileDescriptor(env, javaFileDescriptor); - lseek(fd, off, SEEK_SET); - int cnt = read(fd, stream->inaddr, len); - - return cnt; -} - -JNIEXPORT jint JNICALL -Java_java_util_zip_Inflater_inflateImpl (JNIEnv * env, jobject recv, - jbyteArray buf, int off, int len, - jlong handle) -{ - jbyte *out; - JCLZipStream *stream = (JCLZipStream *) ((IDATA) handle); - jint err = 0; - jfieldID fid = 0, fid2 = 0; - jint sin, sout, inBytes = 0; - - /* We need to get the number of bytes already read */ - fid = gCachedFields.inRead; - inBytes = ((*env)->GetIntField (env, recv, fid)); - - stream->stream->avail_out = len; - sin = stream->stream->total_in; - sout = stream->stream->total_out; - out = ((*env)->GetPrimitiveArrayCritical (env, buf, 0)); - if (out == NULL) { - throwNewOutOfMemoryError(env, ""); - return -1; - } - stream->stream->next_out = (Bytef *) out + off; - err = inflate (stream->stream, Z_SYNC_FLUSH); - ((*env)->ReleasePrimitiveArrayCritical (env, buf, out, 0)); - - if (err != Z_OK) - { - if(err == Z_STREAM_ERROR) { - return 0; - } - if (err == Z_STREAM_END || err == Z_NEED_DICT) - { - ((*env)->SetIntField (env, recv, fid, (jint) stream->stream->total_in - sin + inBytes)); /* Update inRead */ - if (err == Z_STREAM_END) - fid2 = gCachedFields.finished; - else - fid2 = gCachedFields.needsDictionary; - - ((*env)->SetBooleanField (env, recv, fid2, JNI_TRUE)); - return stream->stream->total_out - sout; - } - else - { - THROW_ZIP_EXCEPTION(env, err, DataFormatException); - return -1; - } - } - - /* Need to update the number of input bytes read. Is there a better way - * (Maybe global the fid then delete when end is called)? - */ - ((*env)-> - SetIntField (env, recv, fid, - (jint) stream->stream->total_in - sin + inBytes)); - - return stream->stream->total_out - sout; -} - -JNIEXPORT jint JNICALL -Java_java_util_zip_Inflater_getAdlerImpl (JNIEnv * env, jobject recv, - jlong handle) -{ - JCLZipStream *stream; - - stream = (JCLZipStream *) ((IDATA) handle); - - return stream->stream->adler; -} - -JNIEXPORT void JNICALL -Java_java_util_zip_Inflater_endImpl (JNIEnv * env, jobject recv, jlong handle) -{ - PORT_ACCESS_FROM_ENV (env); - JCLZipStream *stream; - - stream = (JCLZipStream *) ((IDATA) handle); - inflateEnd (stream->stream); - if (stream->inaddr != NULL) /*Input has been provided, free the buffer */ - jclmem_free_memory (env, stream->inaddr); - if (stream->dict != NULL) - jclmem_free_memory (env, stream->dict); - jclmem_free_memory (env, stream->stream); - jclmem_free_memory (env, stream); -} - -JNIEXPORT void JNICALL -Java_java_util_zip_Inflater_setDictionaryImpl (JNIEnv * env, jobject recv, - jbyteArray dict, int off, - int len, jlong handle) -{ - PORT_ACCESS_FROM_ENV (env); - int err = 0; - U_8 *dBytes; - JCLZipStream *stream = (JCLZipStream *) ((IDATA) handle); - - dBytes = jclmem_allocate_memory (env, len); - if (dBytes == NULL) - { - throwNewOutOfMemoryError (env, ""); - return; - } - (*env)->GetByteArrayRegion (env, dict, off, len, (mcSignednessBull)dBytes); - err = inflateSetDictionary (stream->stream, (Bytef *) dBytes, len); - if (err != Z_OK) - { - jclmem_free_memory (env, dBytes); - THROW_ZIP_EXCEPTION(env, err, IllegalArgumentException); - return; - } - stream->dict = dBytes; -} - -JNIEXPORT void JNICALL -Java_java_util_zip_Inflater_resetImpl (JNIEnv * env, jobject recv, - jlong handle) -{ - JCLZipStream *stream; - int err = 0; - stream = (JCLZipStream *) ((IDATA) handle); - - err = inflateReset (stream->stream); - if (err != Z_OK) - { - THROW_ZIP_EXCEPTION(env, err, IllegalArgumentException); - return; - } -} - -/** - * Throw java.util.zip.DataFormatException - */ -void -throwNewDataFormatException (JNIEnv * env, const char *message) -{ - jniThrowException(env, "java/util/zip/DataFormatException", message); -} - -JNIEXPORT jlong JNICALL -Java_java_util_zip_Inflater_getTotalOutImpl (JNIEnv * env, jobject recv, - jlong handle) -{ - JCLZipStream *stream; - - stream = (JCLZipStream *) ((IDATA) handle); - return stream->stream->total_out; - -} - -JNIEXPORT jlong JNICALL -Java_java_util_zip_Inflater_getTotalInImpl (JNIEnv * env, jobject recv, - jlong handle) -{ - JCLZipStream *stream; - - stream = (JCLZipStream *) ((IDATA) handle); - return stream->stream->total_in; -} - -JNIEXPORT void JNICALL -Java_java_util_zip_Inflater_oneTimeInitialization (JNIEnv * env, jclass clazz) -{ - memset(&gCachedFields, 0, sizeof(gCachedFields)); - gCachedFields.inRead = (*env)->GetFieldID (env, clazz, "inRead", "I"); - gCachedFields.finished = (*env)->GetFieldID (env, clazz, "finished", "Z"); - gCachedFields.needsDictionary = (*env)->GetFieldID (env, clazz, "needsDictionary", "Z"); -} - -/* - * JNI registration - */ -static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ - { "createStream", "(Z)J", Java_java_util_zip_Inflater_createStream }, - { "setInputImpl", "([BIIJ)V", Java_java_util_zip_Inflater_setInputImpl }, - { "setFileInputImpl", "(Ljava/io/FileDescriptor;JIJ)I", Java_java_util_zip_Inflater_setFileInputImpl }, - { "inflateImpl", "([BIIJ)I", Java_java_util_zip_Inflater_inflateImpl }, - { "getAdlerImpl", "(J)I", Java_java_util_zip_Inflater_getAdlerImpl }, - { "endImpl", "(J)V", Java_java_util_zip_Inflater_endImpl }, - { "setDictionaryImpl", "([BIIJ)V", Java_java_util_zip_Inflater_setDictionaryImpl }, - { "resetImpl", "(J)V", Java_java_util_zip_Inflater_resetImpl }, - { "getTotalOutImpl", "(J)J", Java_java_util_zip_Inflater_getTotalOutImpl }, - { "getTotalInImpl", "(J)J", Java_java_util_zip_Inflater_getTotalInImpl }, - { "oneTimeInitialization", "()V", Java_java_util_zip_Inflater_oneTimeInitialization }, -}; -int register_java_util_zip_Inflater(JNIEnv* env) -{ - return jniRegisterNativeMethods(env, "java/util/zip/Inflater", - gMethods, NELEM(gMethods)); -} diff --git a/libcore/archive/src/main/native/sieb.c b/libcore/archive/src/main/native/sieb.c deleted file mode 100644 index 6881cf661..000000000 --- a/libcore/archive/src/main/native/sieb.c +++ /dev/null @@ -1,40 +0,0 @@ -#include "sieb.h" -#include "JNIHelp.h" -#include "jni.h" - -#include - -// Throw java.lang.OutOfMemoryError -void throwNewOutOfMemoryError (JNIEnv * env, const char *message) -{ - jniThrowException(env, "java/lang/OutOfMemoryError", message); -} - -void * sieb_malloc (JNIEnv * env, size_t byteCnt) { - void * adr = malloc(byteCnt); - if (adr == 0) { - if (byteCnt == 0) - throwNewOutOfMemoryError(env, "sieb_malloc(0) NOT ALLOWED"); - else - throwNewOutOfMemoryError(env, "sieb_malloc"); - } - return adr; -} - -void sieb_free (JNIEnv * env, void * adr) { - free(adr); -} - - - -void sieb_convertToPlatform (char *path) { - char *pathIndex; - - pathIndex = path; - while (*pathIndex != '\0') { - if(*pathIndex == '\\') { - *pathIndex = '/'; - } - pathIndex++; - } -} diff --git a/libcore/archive/src/main/native/sieb.h b/libcore/archive/src/main/native/sieb.h deleted file mode 100644 index 541ad90a3..000000000 --- a/libcore/archive/src/main/native/sieb.h +++ /dev/null @@ -1,21 +0,0 @@ -#if !defined(sieb_h) -#define sieb_h - - -#include "JNIHelp.h" -#include "jni.h" - - - -void throwNewOutOfMemoryError (JNIEnv * env, - const char *message); - - -void * sieb_malloc (JNIEnv * env, size_t byteCnt); -void sieb_free (JNIEnv * env, void * adr); - -void sieb_convertToPlatform (char *path); - - - -#endif /* sieb_h */ diff --git a/libcore/archive/src/main/native/sub.mk b/libcore/archive/src/main/native/sub.mk deleted file mode 100644 index 694c18575..000000000 --- a/libcore/archive/src/main/native/sub.mk +++ /dev/null @@ -1,24 +0,0 @@ -# This file is included by the top-level libcore Android.mk. -# It's not a normal makefile, so we don't include CLEAR_VARS -# or BUILD_*_LIBRARY. - -LOCAL_SRC_FILES := \ - java_util_zip_Adler32.c \ - java_util_zip_CRC32.c \ - java_util_zip_Deflater.c \ - java_util_zip_Inflater.c \ - zip.c \ - zipalloc.c \ - sieb.c - -LOCAL_C_INCLUDES += \ - external/zlib - -# Any shared/static libs that are listed here must also -# be listed in libs/nativehelper/Android.mk. -# TODO: fix this requirement - -LOCAL_SHARED_LIBRARIES += \ - libz - -LOCAL_STATIC_LIBRARIES += diff --git a/libcore/archive/src/main/native/zip.c b/libcore/archive/src/main/native/zip.c deleted file mode 100644 index 3d15d2a0b..000000000 --- a/libcore/archive/src/main/native/zip.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "zip.h" -#include "jni.h" - -/** - * Throw java.lang.IllegalStateException - */ -void -throwNewIllegalStateException (JNIEnv * env, const char *message) -{ - jniThrowException(env, "java/lang/IllegalStateException", message); -} - -/** - * Throw java.lang.IllegalArgumentException - */ -void -throwNewIllegalArgumentException (JNIEnv * env, const char *message) -{ - jniThrowException(env, "java/lang/IllegalArgumentException", message); -} diff --git a/libcore/archive/src/main/native/zip.h b/libcore/archive/src/main/native/zip.h deleted file mode 100644 index 145207324..000000000 --- a/libcore/archive/src/main/native/zip.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#if !defined(zip_h) -#define zip_h - -#ifndef HY_ZIP_API -#include "zipsup.h" -#else /* HY_ZIP_API */ -#include "vmizip.h" -#endif /* HY_ZIP_API */ - -#include "hymutex.h" - -typedef struct JCLZipFile -{ - struct JCLZipFile *last; - struct JCLZipFile *next; -#ifndef HY_ZIP_API - HyZipFile hyZipFile; -#else - VMIZipFile hyZipFile; -#endif -} JCLZipFile; - -/* Fake JCLZipFile entry. last, next must be in the same position as JCLZipFile */ -typedef struct JCLZipFileLink -{ - JCLZipFile *last; - JCLZipFile *next; - MUTEX mutex; -} JCLZipFileLink; - -// Contents from Harmony's inflater.h was put here: -// -typedef struct JCLZipStream -{ - U_8 *inaddr; - int inCap; - U_8 *dict; - z_stream *stream; -} JCLZipStream; - -#define THROW_ZIP_EXCEPTION(env, err, type) \ - if (err == Z_MEM_ERROR) { \ - throwNewOutOfMemoryError(env, ""); \ - } else { \ - throwNew##type(env, (const char*) zError(err)); \ - } - -void throwNewIllegalStateException PROTOTYPE((JNIEnv* env, - const char* message)); -void throwNewIllegalArgumentException PROTOTYPE((JNIEnv* env, - const char* message)); - -#endif /* zip_h */ diff --git a/libcore/archive/src/main/native/zipalloc.c b/libcore/archive/src/main/native/zipalloc.c deleted file mode 100644 index 2b4966bf1..000000000 --- a/libcore/archive/src/main/native/zipalloc.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "hyport.h" - -#include "zlib.h" - -#define CDEV_CURRENT_FUNCTION _prototypes_private - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION _prototypes_public -void *zalloc PROTOTYPE ((void *opaque, U_32 items, U_32 size)); -void zfree PROTOTYPE ((void *opaque, void *address)); - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION zalloc - -/* - ZLib interface to hymem_allocate_memory. -*/ -void * -zalloc (void *opaque, U_32 items, U_32 size) -{ - PORT_ACCESS_FROM_PORT (((HyPortLibrary *) opaque)); - - return hymem_allocate_memory (items * size); -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION zfree - -/* - ZLib interface to hymem_free_memory. -*/ -void -zfree (void *opaque, void *address) -{ - PORT_ACCESS_FROM_PORT ((HyPortLibrary *) opaque); - - hymem_free_memory (address); -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION - -#undef CDEV_CURRENT_FUNCTION diff --git a/libcore/archive/src/main/native/zipsup.c b/libcore/archive/src/main/native/zipsup.c deleted file mode 100644 index 22ea7e9e1..000000000 --- a/libcore/archive/src/main/native/zipsup.c +++ /dev/null @@ -1,2319 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * @ingroup ZipSupport - * @brief Zip Support for Java VM -*/ - -#include -#include - -#include "hy2sie.h" -#include "zipsup.h" - -#include "zlib.h" - -// zlib is statically linked for Android: -#define checkZipLibrary(dummy) 0 -#ifdef checkZipLibrary -#define inflateInit2Func(a, b, c, d) inflateInit2_ (a, b, c, d) -#define inflateFunc(a, b) inflate (a, b) -#define inflateEndFunc(a) inflateEnd (a) -#else -/* Globals for the zip library */ -UDATA zipDLLDescriptor = 0; -int (*inflateInit2Func) (void *, int, const char *, int); -int (*inflateFunc) (void *, int); -int (*inflateEndFunc) (void *); -#endif - -#define ZIP_NEXT_U8(value, index) (value = *(index++)) -#define ZIP_NEXT_U16(value, index) ((value = (index[1] << 8) | index[0]), index += 2, value) -#define ZIP_NEXT_U32(value, index) ((value = ((U_32)index[3] << 24) | ((U_32)index[2] << 16) | ((U_32)index[1] << 8) | (U_32)index[0]), index += 4, value) - -#define WORK_BUFFER_SIZE 64000 - -#define SCAN_CHUNK_SIZE 1024 - -struct workBuffer -{ - HyPortLibrary *portLib; - UDATA *bufferStart; - UDATA *bufferEnd; - UDATA *currentAlloc; - UDATA cntr; -}; - -#define CDEV_CURRENT_FUNCTION _prototypes_private -I_32 zip_populateCache -PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile)); - -static I_32 inflateData -PROTOTYPE ((struct workBuffer * workBuf, U_8 * inputBuffer, - U_32 inputBufferSize, U_8 * outputBuffer, U_32 outputBufferSize)); - -I_32 checkZipLibrary PROTOTYPE ((HyPortLibrary * portLib)); - -I_32 scanForDataDescriptor -PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, - HyZipEntry * zipEntry)); -void zdatafree PROTOTYPE ((void *opaque, void *address)); -static I_32 readZipEntry -PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, - HyZipEntry * zipEntry, const char *filename, - IDATA * enumerationPointer, IDATA * entryStart, - BOOLEAN findDirectory)); -I_32 scanForCentralEnd -PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, - HyZipCentralEnd * endEntry)); -void *zdataalloc PROTOTYPE ((void *opaque, U_32 items, U_32 size)); - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION _prototypes_public -I_32 zip_getZipEntryData -PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, HyZipEntry * entry, - U_8 * buffer, U_32 bufferSize)); -I_32 zip_getZipEntryFromOffset -PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, HyZipEntry * entry, - IDATA offset)); -I_32 zip_establishCache -PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile)); -void zip_resetZipFile -PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, - IDATA * nextEntryPointer)); -I_32 zip_getNextZipEntry -PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, - HyZipEntry * zipEntry, IDATA * nextEntryPointer)); -I_32 zip_getZipEntry -PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, HyZipEntry * entry, - const char *filename, BOOLEAN findDirectory)); -I_32 zip_getZipEntryExtraField -PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, HyZipEntry * entry, - U_8 * buffer, U_32 bufferSize)); -void zip_initZipEntry -PROTOTYPE ((HyPortLibrary * portLib, HyZipEntry * entry)); -I_32 zip_openZipFile -PROTOTYPE ((HyPortLibrary * portLib, char *filename, HyZipFile * zipFile, - HyZipCachePool * cachePool)); -void zip_freeZipEntry -PROTOTYPE ((HyPortLibrary * portLib, HyZipEntry * entry)); -I_32 VMCALL zip_closeZipFile -PROTOTYPE ((HyPortLibrary * portLib, struct HyZipFile * zipFile)); -I_32 zip_getZipEntryComment -PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, HyZipEntry * entry, - U_8 * buffer, U_32 bufferSize)); - -#undef CDEV_CURRENT_FUNCTION - -//#include "hythread.h" -//#define ENTER() hythread_monitor_enter(hythread_global_monitor()) -//#define EXIT() hythread_monitor_exit(hythread_global_monitor()) - -#include "hymutex.h" -MUTEX zip_globalMutex; -static int initialized = 0; - -#define ENTER() \ - if (!initialized) { MUTEX_INIT(zip_globalMutex); initialized = 1; } \ - MUTEX_ENTER(zip_globalMutex); - -#define EXIT() MUTEX_EXIT(zip_globalMutex); - - -HyZipCachePool * -zipsup_GetZipCachePool(JNIEnv * env) -{ - static HyZipCachePool *pool = 0; - - if (pool == 0) { - pool = zipCachePool_new(env); - } - return pool; -} - - -#ifndef checkZipLibrary -#define CDEV_CURRENT_FUNCTION checkZipLibrary - -/* - Ensure that the zip library is loaded. - Return 0 on success, -1 on failure. -*/ -I_32 -checkZipLibrary (HyPortLibrary * portLib) -{ - PORT_ACCESS_FROM_PORT (portLib); - - /* if the library has already been loaded return success/failure */ - if (zipDLLDescriptor > 1) - return 0; - if (zipDLLDescriptor == 1) - return -1; - - /* open up the zip library by name */ - - if (hysl_open_shared_library (HY_ZIP_DLL_NAME, &zipDLLDescriptor, TRUE)) - goto openFailed; - - /* look up the functions */ - if (hysl_lookup_name - (zipDLLDescriptor, "inflateInit2_", (void *) &inflateInit2Func, - "ILILI")) - goto loadFailed; - if (hysl_lookup_name - (zipDLLDescriptor, "inflate", (void *) &inflateFunc, "IPI")) - goto loadFailed; - if (hysl_lookup_name - (zipDLLDescriptor, "inflateEnd", (void *) &inflateEndFunc, "IP")) - goto loadFailed; - - /* good to go */ - return 0; - -loadFailed: - hysl_close_shared_library (zipDLLDescriptor); - - /* mark the descriptor as a failed load. only report the error once */ - zipDLLDescriptor = 1; - - /* Unable to open %s (Missing export) */ - hynls_printf (PORTLIB, HYNLS_WARNING, HYNLS_ZIP_MISSING_EXPORT, - HY_ZIP_DLL_NAME); - - return -1; - -openFailed: - /* mark the descriptor as a failed load. only report the error once */ - zipDLLDescriptor = 1; - - /* Unable to open %s (%s) */ - hynls_printf (PORTLIB, HYNLS_WARNING, HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL, - HY_ZIP_DLL_NAME, hyerror_last_error_message ()); - return -1; -} - -#undef CDEV_CURRENT_FUNCTION -#endif - -#define CDEV_CURRENT_FUNCTION inflateData - -/* - Returns 0 on success or one of the following: - ZIP_ERR_UNSUPPORTED_FILE_TYPE - ZIP_ERR_FILE_CORRUPT - ZIP_ERR_OUT_OF_MEMORY - ZIP_ERR_INTERNAL_ERROR -*/ -static I_32 -inflateData (struct workBuffer *workBuf, U_8 * inputBuffer, - U_32 inputBufferSize, U_8 * outputBuffer, U_32 outputBufferSize) -{ - PORT_ACCESS_FROM_PORT (workBuf->portLib); - - z_stream stream; - I_32 err; - - stream.next_in = inputBuffer; - stream.avail_in = inputBufferSize; - stream.next_out = outputBuffer; - stream.avail_out = outputBufferSize; - - stream.opaque = workBuf; - stream.zalloc = zdataalloc; - stream.zfree = zdatafree; - - /* Initialize stream. Pass "-15" as max number of window bits, negated - to indicate that no zlib header is present in the data. */ - err = inflateInit2Func (&stream, -15, ZLIB_VERSION, sizeof (z_stream)); - if (err != Z_OK) - return -1; - - /* Inflate the data. */ - err = inflateFunc (&stream, Z_SYNC_FLUSH); - - /* Clean up the stream. */ - inflateEndFunc (&stream); - - /* Check the return code. Did we complete the inflate? */ - if ((err == Z_STREAM_END) || (err == Z_OK)) - { - if (stream.total_out == outputBufferSize) - { - return 0; - } - } - - switch (err) - { - case Z_OK: /* an error if file is incomplete */ - case Z_STREAM_END: /* an error if file is incomplete */ - case Z_ERRNO: /* a random error */ - case Z_STREAM_ERROR: /* stream inconsistent */ - case Z_DATA_ERROR: /* corrupted zip */ - return ZIP_ERR_FILE_CORRUPT; - - case Z_VERSION_ERROR: /* wrong zlib version */ - case Z_NEED_DICT: /* needs a preset dictionary that we can't provide */ - return ZIP_ERR_UNSUPPORTED_FILE_TYPE; - - case Z_MEM_ERROR: /* out of memory */ - return ZIP_ERR_OUT_OF_MEMORY; - - case Z_BUF_ERROR: /* no progress / out of output buffer */ - default: /* jic */ - return ZIP_ERR_INTERNAL_ERROR; - } -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION scanForCentralEnd -/* - Scan backward from end of file for a central end header. Read from zipFile and update the HyZipCentralEnd provided. - - Returns 0 on success or one of the following: - ZIP_ERR_FILE_READ_ERROR - ZIP_ERR_FILE_CORRUPT -*/ -I_32 -scanForCentralEnd (HyPortLibrary * portLib, HyZipFile * zipFile, - HyZipCentralEnd * endEntry) -{ - U_8 *current; - U_8 buffer[SCAN_CHUNK_SIZE]; - I_32 i, size, state; - U_32 dataSize = 0; - I_64 seekResult; - I_32 fileSize; - I_32 bytesAlreadyRead = 0; - - PORT_ACCESS_FROM_PORT (portLib); - - /* Haven't seen anything yet. */ - state = 0; - - seekResult = hyfile_seek (zipFile->fd, 0, HySeekEnd); - if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF))) - { - zipFile->pointer = -1; - return ZIP_ERR_FILE_READ_ERROR; - } - fileSize = (I_32) seekResult; - zipFile->pointer = fileSize; - - while (TRUE) - { - /* Fill the buffer. */ - if (bytesAlreadyRead == fileSize) - { - zipFile->pointer = -1; - return ZIP_ERR_FILE_CORRUPT; - } - - size = SCAN_CHUNK_SIZE; - if (size > fileSize - bytesAlreadyRead) - size = fileSize - bytesAlreadyRead; - bytesAlreadyRead += size; - seekResult = - hyfile_seek (zipFile->fd, fileSize - bytesAlreadyRead, HySeekSet); - if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF))) - { - zipFile->pointer = -1; - return ZIP_ERR_FILE_READ_ERROR; - } - zipFile->pointer = (I_32) seekResult; - - if (hyfile_read (zipFile->fd, buffer, size) != size) - { - zipFile->pointer = -1; - return ZIP_ERR_FILE_READ_ERROR; - } - zipFile->pointer += size; - - /* Scan the buffer (backwards) for CentralEnd signature = PK^E^F. */ - for (i = size; i--; dataSize++) - { - switch (state) - { - case 0: - /* Nothing yet. */ - if (buffer[i] == 6) - state = 1; - break; - - case 1: - /* Seen ^F */ - if (buffer[i] == 5) - state = 2; - else - state = 0; - break; - - case 2: - /* Seen ^E^F */ - if (buffer[i] == 'K') - state = 3; - else - state = 0; - break; - - case 3: - /* Seen K^E^F */ - if (buffer[i] == 'P' && dataSize >= 21) - { - /* Found it. Read the data from the end-of-central-dir record. */ - current = buffer + i + 4; - ZIP_NEXT_U16 (endEntry->diskNumber, current); - ZIP_NEXT_U16 (endEntry->dirStartDisk, current); - ZIP_NEXT_U16 (endEntry->thisDiskEntries, current); - ZIP_NEXT_U16 (endEntry->totalEntries, current); - ZIP_NEXT_U32 (endEntry->dirSize, current); - ZIP_NEXT_U32 (endEntry->dirOffset, current); - ZIP_NEXT_U16 (endEntry->commentLength, current); - - /* Quick test to ensure that the header isn't invalid. - Current dataSize is the number of bytes of data scanned, up to the ^H in the stream. */ - if (dataSize >= (U_32) (21 + endEntry->commentLength)) - return 0; - - /* Header looked invalid. Pretend we didn't see it and keep scanning.. */ - } - state = 0; - break; - } - } - } -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION scanForDataDescriptor -/* - Scan ahead for a data descriptor. Read from zipFile and update the HyZipLocalHeader provided. - - Returns 0 on success or one of the following: - ZIP_ERR_FILE_READ_ERROR - ZIP_ERR_FILE_CORRUPT -*/ -I_32 -scanForDataDescriptor (HyPortLibrary * portLib, HyZipFile * zipFile, - HyZipEntry * zipEntry) -{ - U_8 *current; - U_8 buffer[SCAN_CHUNK_SIZE], descriptor[16]; - I_32 i, size, state; - U_32 dataSize, blockPointer; - I_64 seekResult; - - PORT_ACCESS_FROM_PORT (portLib); - - /* Skip ahead and read the data descriptor. The compressed size should be 0. */ - if (zipFile->pointer != - (IDATA) (zipEntry->dataPointer + zipEntry->compressedSize)) - { - seekResult = - hyfile_seek (zipFile->fd, - zipEntry->dataPointer + zipEntry->compressedSize, - HySeekSet); - if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF))) - { - zipFile->pointer = -1; - return ZIP_ERR_FILE_READ_ERROR; - } - zipFile->pointer = (I_32) seekResult; - } - - /* Haven't seen anything yet. */ - blockPointer = dataSize = zipEntry->compressedSize; - state = 0; - - /* Scan until we find PK^G^H (otherwise it's an error). */ - while (1) - { - /* Fill the buffer. */ - size = hyfile_read (zipFile->fd, buffer, SCAN_CHUNK_SIZE); - if (size == 0) - { - return ZIP_ERR_FILE_CORRUPT; - } - else if (size < 0) - { - zipFile->pointer = -1; - return ZIP_ERR_FILE_READ_ERROR; - } - zipFile->pointer += size; - blockPointer += size; - - /* Scan the buffer. */ - for (i = 0; i < size; i++, dataSize++) - { - switch (state) - { - case 0: - /* Nothing yet. */ - if (buffer[i] == 'P') - { - state = 1; - } - break; - - case 1: - /* Seen P */ - if (buffer[i] == 'K') - { - state = 2; - } - else - state = 0; - break; - - case 2: - /* Seen PK */ - if (buffer[i] == 7) - { - state = 3; - } - else - { - state = 0; - } - break; - - case 3: - /* Seen PK^G */ - if (buffer[i] == 8) - { - /* Found it! Read the descriptor */ - if (i + 12 < size) - { - current = &buffer[i + 1]; - } - else - { - seekResult = - hyfile_seek (zipFile->fd, - zipEntry->dataPointer + dataSize + 1, - HySeekSet); - if ((seekResult < 0) - || (seekResult > HYCONST64 (0x7FFFFFFF))) - { - zipFile->pointer = -1; - return ZIP_ERR_FILE_READ_ERROR; - } - zipFile->pointer = (I_32) seekResult; - if (hyfile_read (zipFile->fd, descriptor, 12) != 12) - { - zipFile->pointer = -1; - return ZIP_ERR_FILE_READ_ERROR; - } - zipFile->pointer += 12; - current = descriptor; - } - - /* Read the data from the descriptor. */ - ZIP_NEXT_U32 (zipEntry->crc32, current); - ZIP_NEXT_U32 (zipEntry->compressedSize, current); - ZIP_NEXT_U32 (zipEntry->uncompressedSize, current); - - /* Quick test to ensure that the header isn't invalid. - Current dataSize is the number of bytes of data scanned, up to the ^H in the stream. */ - if (dataSize - 3 == zipEntry->compressedSize) - { - return 0; - } - - /* Header looked invalid. Reset the pointer and continue scanning. */ - seekResult = - hyfile_seek (zipFile->fd, - zipEntry->dataPointer + blockPointer, - HySeekSet); - if ((seekResult < 0) - || (seekResult > HYCONST64 (0x7FFFFFFF))) - { - zipFile->pointer = -1; - return ZIP_ERR_FILE_READ_ERROR; - } - zipFile->pointer = (I_32) seekResult; - } - else - state = 0; - break; - } - } - } -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION zip_populateCache -/* - Fill in the cache of a given zip file. This should only be called once during zip_openZipFile! - - Returns 0 on success or one of the following: - ZIP_ERR_FILE_READ_ERROR - ZIP_ERR_FILE_OPEN_ERROR - ZIP_ERR_UNKNOWN_FILE_TYPE - ZIP_ERR_UNSUPPORTED_FILE_TYPE - ZIP_ERR_OUT_OF_MEMORY - ZIP_ERR_INTERNAL_ERROR -*/ -I_32 -zip_populateCache (HyPortLibrary * portLib, HyZipFile * zipFile) -{ - PORT_ACCESS_FROM_PORT (portLib); - - I_32 result = 0; - IDATA bufferSize = 65536; - IDATA unreadSize = 0; - IDATA bufferedSize = 0; - IDATA bytesToRead = 0; - IDATA filenameCopied; - HyZipEntry entry; - HyZipCentralEnd endEntry; - U_8 *buffer = NULL; - U_8 *filename = NULL; - IDATA filenameSize = 256; /* Should be sufficient for most filenames */ - U_8 *current; - U_32 sig; - U_32 localHeaderOffset; - IDATA startCentralDir; - I_64 seekResult; - - if (!zipFile->cache) - return ZIP_ERR_INTERNAL_ERROR; - - /* Find and read the end-of-central-dir record. */ - result = scanForCentralEnd (portLib, zipFile, &endEntry); - if (result != 0) - return result; - - unreadSize = endEntry.dirSize + 4 /* slop */ ; - zipFile->cache->startCentralDir = startCentralDir = - (IDATA) ((UDATA) endEntry.dirOffset); - - if (zipFile->pointer != startCentralDir) - { - seekResult = hyfile_seek (zipFile->fd, startCentralDir, HySeekSet); - if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF))) - { - zipFile->pointer = -1; - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - - zipFile->pointer = (I_32) seekResult; - if (zipFile->pointer != startCentralDir) - { - result = ZIP_ERR_FILE_READ_ERROR; - zipFile->pointer = -1; - goto finished; - } - } - - /* No point in allocating more than we'll actually need.. */ - if (bufferSize > unreadSize) - bufferSize = unreadSize; - - filename = hymem_allocate_memory (filenameSize); - if (!filename) - { - result = ZIP_ERR_OUT_OF_MEMORY; - goto finished; - } - - /* Allocate some space to hold central directory goo as we eat through it */ - buffer = hymem_allocate_memory (bufferSize); - if (!buffer && (bufferSize > 4096)) - { - /* Not enough memory, fall back to a smaller buffer! */ - bufferSize = 4096; - buffer = hymem_allocate_memory (bufferSize); - } - if (!buffer) - { - result = ZIP_ERR_OUT_OF_MEMORY; - goto finished; - } - - while (unreadSize) - { - - /* Read as much as needed into buffer. */ - bytesToRead = bufferSize - bufferedSize; - if (bytesToRead > unreadSize) - bytesToRead = unreadSize; - result = hyfile_read (zipFile->fd, buffer + bufferedSize, bytesToRead); - if (result < 0) - { - result = ZIP_ERR_FILE_READ_ERROR; - zipFile->pointer = -1; - goto finished; - } - zipFile->pointer += result; - unreadSize -= result; - bufferedSize += result; - current = buffer; - - /* consume entries until we run out. */ - while (current + 46 < buffer + bufferedSize) - { - IDATA entryPointer; - - entryPointer = - zipFile->pointer + (current - (buffer + bufferedSize)); - - sig = 0; - ZIP_NEXT_U32 (sig, current); - if (sig == ZIP_CentralEnd) - { - /* We're done here. */ - result = 0; - goto finished; - } - if (sig != ZIP_CentralHeader) - { - /* Umm...What the Hell? */ - result = ZIP_ERR_FILE_CORRUPT; - goto finished; - } - - /* Read ZIP_CentralHeader entry */ - ZIP_NEXT_U16 (entry.versionCreated, current); - ZIP_NEXT_U16 (entry.versionNeeded, current); - ZIP_NEXT_U16 (entry.flags, current); - ZIP_NEXT_U16 (entry.compressionMethod, current); - ZIP_NEXT_U16 (entry.lastModTime, current); - ZIP_NEXT_U16 (entry.lastModDate, current); - ZIP_NEXT_U32 (entry.crc32, current); - ZIP_NEXT_U32 (entry.compressedSize, current); - ZIP_NEXT_U32 (entry.uncompressedSize, current); - ZIP_NEXT_U16 (entry.filenameLength, current); - ZIP_NEXT_U16 (entry.extraFieldLength, current); - ZIP_NEXT_U16 (entry.fileCommentLength, current); - current += sizeof (U_16); /* skip disk number field */ - ZIP_NEXT_U16 (entry.internalAttributes, current); - current += sizeof (U_32); /* skip external attributes field */ - ZIP_NEXT_U32 (localHeaderOffset, current); - - /* Increase filename buffer size if necessary. */ - if (filenameSize < entry.filenameLength + 1) - { - hymem_free_memory (filename); - filenameSize = entry.filenameLength + 1; - filename = hymem_allocate_memory (filenameSize); - if (!filename) - { - result = ZIP_ERR_OUT_OF_MEMORY; - goto finished; - } - } - - filenameCopied = 0; - while (filenameCopied < entry.filenameLength) - { - IDATA size; - /* Copy as much of the filename as we can see in the buffer (probably the whole thing). */ - - size = entry.filenameLength - filenameCopied; - if (size > bufferedSize - (current - buffer)) - { - size = bufferedSize - (current - buffer); - } - memcpy (filename + filenameCopied, current, size); - filenameCopied += size; - current += size; - if (filenameCopied >= entry.filenameLength) - break; /* done */ - - /* Otherwise, we ran out of source string. Load another chunk.. */ - bufferedSize = 0; - if (!unreadSize) - { - /* Central header is supposedly done? Bak */ - result = ZIP_ERR_FILE_CORRUPT; - goto finished; - } - bytesToRead = bufferSize - bufferedSize; - if (bytesToRead > unreadSize) - bytesToRead = unreadSize; - result = - hyfile_read (zipFile->fd, buffer + bufferedSize, bytesToRead); - if (result < 0) - { - result = ZIP_ERR_FILE_READ_ERROR; - zipFile->pointer = -1; - goto finished; - } - zipFile->pointer += result; - unreadSize -= result; - bufferedSize += result; - current = buffer; - } - filename[entry.filenameLength] = '\0'; /* null-terminate */ - - if (((entry.compressionMethod == ZIP_CM_Deflated) - && (entry.flags & 0x8)) || (entry.fileCommentLength != 0)) - { - /* Either local header doesn't know the compressedSize, or this entry has a file - comment. In either case, cache the central header instead of the local header - so we can find the information we need later. */ - - result = - zipCache_addElement (zipFile->cache, (char *) filename, - entryPointer); - - } - else - { - result = - zipCache_addElement (zipFile->cache, (char *) filename, - localHeaderOffset); - } - - if (!result) - { - result = ZIP_ERR_OUT_OF_MEMORY; - goto finished; - } - - /* Skip the data and comment. */ - bytesToRead = entry.extraFieldLength + entry.fileCommentLength; - if (bufferedSize - (current - buffer) >= bytesToRead) - { - current += bytesToRead; - } - else - { - /* The rest of the buffer is uninteresting. Skip ahead to where the good stuff is */ - bytesToRead -= (bufferedSize - (current - buffer)); - current = buffer + bufferedSize; - unreadSize -= bytesToRead; - - seekResult = hyfile_seek (zipFile->fd, bytesToRead, HySeekCur); - if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF))) - { - zipFile->pointer = -1; - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - zipFile->pointer = (I_32) seekResult; - } - } - bufferedSize -= (current - buffer); - memmove (buffer, current, bufferedSize); - } - - result = 0; - -finished: - if (filename) - hymem_free_memory (filename); - if (buffer) - hymem_free_memory (buffer); - return result; -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION readZipEntry -/* - Read the next zip entry for the zipFile into the zipEntry provided. If filename is non-NULL, it is expected to match - the filename read for the entry. If (cachePointer != -1) the filename of the entry will be looked up in the cache (assuming - there is one) to help detect use of an invalid cache. If enumerationPointer is non-NULL, sequential access is assumed and - either a local zip entry or a data descriptor will be accepted, but a central zip entry will cause ZIP_ERR_NO_MORE_ENTRIES - to be returned. If enumerationPointer is NULL, random access is assumed and either a local zip entry or a central zip - entry will be accepted. - - Returns 0 on success or one of the following: - ZIP_ERR_FILE_READ_ERROR - ZIP_ERR_FILE_CORRUPT - ZIP_ERR_OUT_OF_MEMORY - ZIP_ERR_NO_MORE_ENTRIES -*/ -static I_32 -readZipEntry (HyPortLibrary * portLib, HyZipFile * zipFile, - HyZipEntry * zipEntry, const char *filename, - IDATA * enumerationPointer, IDATA * entryStart, - BOOLEAN findDirectory) -{ - PORT_ACCESS_FROM_PORT (portLib); - - I_32 result; - U_8 buffer[46 + 128]; - U_8 *current; - U_32 sig; - IDATA readLength; - I_64 seekResult; - U_8 *readBuffer; - IDATA currentEntryPointer, localEntryPointer; - IDATA headerSize; - IDATA filenameLength = filename ? strlen (filename) : 0; - -retry: - if (entryStart) - *entryStart = zipFile->pointer; - readBuffer = NULL; - /* Guess how many bytes we'll need to read. If we guess correctly we will do fewer I/O operations */ - headerSize = 30; /* local zip header size */ - if (zipFile->cache && (zipFile->pointer >= zipFile->cache->startCentralDir)) - { - headerSize = 46; /* central zip header size */ - } - readLength = headerSize + (filename ? filenameLength : 128); - if (findDirectory) - { - /* Extra byte for possible trailing '/' */ - readLength++; - } - - /* Allocate some memory if necessary */ - if (readLength <= sizeof (buffer)) - { - current = buffer; - } - else - { - current = readBuffer = hymem_allocate_memory (readLength); - if (!readBuffer) - return ZIP_ERR_OUT_OF_MEMORY; - } - - currentEntryPointer = localEntryPointer = zipFile->pointer; - - result = hyfile_read (zipFile->fd, current, readLength); - if ((result < 22) - || (filename - && !(result == readLength - || (findDirectory && result == (readLength - 1))))) - { - /* We clearly didn't get enough bytes */ - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - zipFile->pointer += result; - readLength = result; /* If it's not enough, we'll catch that later */ - ZIP_NEXT_U32 (sig, current); - - if (enumerationPointer) - { - if ((sig == ZIP_CentralEnd)) - { - result = ZIP_ERR_NO_MORE_ENTRIES; - goto finished; - } - } - if ((enumerationPointer || (!zipFile->cache)) - && (sig == ZIP_DataDescriptor)) - { - /* We failed to predict a data descriptor here. This should be an error (i.e. only happens in malformed zips?) - but, but we will silently skip over it */ - seekResult = - hyfile_seek (zipFile->fd, currentEntryPointer + 16, HySeekSet); - if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF))) - { - zipFile->pointer = -1; - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - zipFile->pointer = (I_32) seekResult; - - if (zipFile->pointer == currentEntryPointer + 16) - { - if (readBuffer) - { - hymem_free_memory (readBuffer); - } - goto retry; - } - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - - if ((sig != ZIP_CentralHeader) && (sig != ZIP_LocalHeader)) - { - /* Unexpected. */ - result = ZIP_ERR_FILE_CORRUPT; - goto finished; - } - headerSize = ((sig == ZIP_CentralHeader) ? 46 : 30); - if (readLength < headerSize) - { - /* We didn't get the whole header (and none of the filename).. */ - /* NOTE: this could happen in normal use if the assumed filename length above is <16. Since it's 128, we don't - handle the impossible case where we would have to read more header. It could also happen if the caller - supplied a filename of length <16 but that only happens when we have a cache (so we'll know the header size) - */ - result = ZIP_ERR_FILE_READ_ERROR; - } - readLength -= headerSize; - - if (sig == ZIP_CentralHeader) - { - current += 2; /* skip versionCreated field */ - } - ZIP_NEXT_U16 (zipEntry->versionNeeded, current); - ZIP_NEXT_U16 (zipEntry->flags, current); - ZIP_NEXT_U16 (zipEntry->compressionMethod, current); - ZIP_NEXT_U16 (zipEntry->lastModTime, current); - ZIP_NEXT_U16 (zipEntry->lastModDate, current); - ZIP_NEXT_U32 (zipEntry->crc32, current); - ZIP_NEXT_U32 (zipEntry->compressedSize, current); - ZIP_NEXT_U32 (zipEntry->uncompressedSize, current); - ZIP_NEXT_U16 (zipEntry->filenameLength, current); - ZIP_NEXT_U16 (zipEntry->extraFieldLength, current); - zipEntry->fileCommentLength = 0; - - if (sig == ZIP_CentralHeader) - { - ZIP_NEXT_U16 (zipEntry->fileCommentLength, current); - current += 8; /* skip disk number start + internal attrs + external attrs */ - ZIP_NEXT_U32 (localEntryPointer, current); - } - - if (filename) - { - if (zipFile->cache) - { - if (! - (readLength == zipEntry->filenameLength - || (findDirectory - && (readLength - 1) == zipEntry->filenameLength))) - { - /* We knew exactly how much we were supposed to read, and this wasn't it */ - result = ZIP_ERR_FILE_CORRUPT; - goto finished; - } - } - } - - /* Allocate space for filename */ - if (zipEntry->filenameLength >= ZIP_INTERNAL_MAX) - { - zipEntry->filename = - hymem_allocate_memory (zipEntry->filenameLength + 1); - if (!zipEntry->filename) - { - result = ZIP_ERR_OUT_OF_MEMORY; - goto finished; - } - } - else - { - zipEntry->filename = zipEntry->internalFilename; - } - if (readLength > zipEntry->filenameLength) - { - readLength = zipEntry->filenameLength; - } - memcpy (zipEntry->filename, current, readLength); - - /* Read the rest of the filename if necessary. Allocate space in HyZipEntry for it! */ - if (readLength < zipEntry->filenameLength) - { - result = - hyfile_read (zipFile->fd, zipEntry->filename + readLength, - zipEntry->filenameLength - readLength); - if (result != (zipEntry->filenameLength - readLength)) - { - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - zipFile->pointer += result; - } - zipEntry->filename[zipEntry->filenameLength] = '\0'; - - /* If we know what filename is supposed to be, compare it and make sure it matches */ - /* Note: CASE-SENSITIVE COMPARE because filenames in zips are case sensitive (even on platforms with - case-insensitive file systems) */ - if (filename) - { - if (! - ((findDirectory && zipEntry->filenameLength == (filenameLength + 1) - && zipEntry->filename[filenameLength] == '/' - && !strncmp ((char *) zipEntry->filename, (const char *) filename, - filenameLength)) - || !strcmp ((const char *) zipEntry->filename, - (const char *) filename))) - { - /* We seem to have read something totally invalid.. */ - result = ZIP_ERR_FILE_CORRUPT; - goto finished; - } - } - - zipEntry->filenamePointer = currentEntryPointer + headerSize; - zipEntry->extraFieldPointer = - localEntryPointer + 30 + zipEntry->filenameLength; - zipEntry->dataPointer = - zipEntry->extraFieldPointer + zipEntry->extraFieldLength; - zipEntry->extraField = NULL; - zipEntry->fileCommentPointer = 0; - zipEntry->fileComment = NULL; - zipEntry->data = NULL; - - if (sig == ZIP_CentralHeader) - { - U_8 buf[2]; - U_8 *buf2 = buf; - U_16 lost; - /* Also, we know where the comment is */ - zipEntry->fileCommentPointer = currentEntryPointer + headerSize + - zipEntry->filenameLength + zipEntry->extraFieldLength; - if (hyfile_seek (zipFile->fd, localEntryPointer + 28, HySeekSet) == - localEntryPointer + 28) - { - if (hyfile_read (zipFile->fd, buf, 2) == 2) - { - ZIP_NEXT_U16 (lost, buf2); - zipEntry->dataPointer = zipEntry->extraFieldPointer + lost; - zipFile->pointer = localEntryPointer + 30; - } - } - } - - if ((sig == ZIP_LocalHeader) - && (zipEntry->compressionMethod == ZIP_CM_Deflated) - && (zipEntry->flags & 0x8)) - { - /* What we just read doesn't tell us how big the compressed data is. We have to do a heuristic search for a - valid data descriptor at the end of the compressed text */ - result = scanForDataDescriptor (portLib, zipFile, zipEntry); - if (result < 0) - goto finished; - } - - /* Entry read successfully */ - - if (enumerationPointer) - { - /* Work out where the next entry is supposed to be */ - *enumerationPointer = - zipEntry->fileCommentPointer + zipEntry->fileCommentLength; - } - - if (readBuffer) - hymem_free_memory (readBuffer); - return 0; - -finished: - if (readBuffer) - { - hymem_free_memory (readBuffer); - } - if ((zipEntry->filename) - && (zipEntry->filename != zipEntry->internalFilename)) - { - hymem_free_memory (zipEntry->filename); - } - zipEntry->filename = NULL; - if (result == ZIP_ERR_FILE_READ_ERROR) - { - zipFile->pointer = -1; - } - return result; -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION zip_closeZipFile -/** - * Attempt to close the zipfile. - * - * @param[in] portLib the port library - * @param[in] zipFile The zip file to be closed - * - * @return 0 on success - * @return ZIP_ERR_FILE_CLOSE_ERROR if there is an error closing the file - * @return ZIP_ERR_INTERNAL_ERROR if there is an internal error - * -*/ -I_32 VMCALL -zip_closeZipFile (HyPortLibrary * portLib, struct HyZipFile * zipFile) -{ - PORT_ACCESS_FROM_PORT (portLib); -#if defined(HY_NO_THR) - THREAD_ACCESS_FROM_PORT(portLib); -#endif /* HY_NO_THR */ - IDATA fd; - - ENTER (); - - fd = zipFile->fd; - zipFile->fd = -1; - - if (zipFile->cache && zipFile->cachePool) - { - zipCachePool_release (zipFile->cachePool, zipFile->cache); - zipFile->cache = NULL; - } - if ((zipFile->filename) && (zipFile->filename != zipFile->internalFilename)) - { - hymem_free_memory (zipFile->filename); - } - zipFile->filename = NULL; - - if (fd == -1) - { - EXIT (); - return ZIP_ERR_INTERNAL_ERROR; - } - if (hyfile_close (fd)) - { - EXIT (); - return ZIP_ERR_FILE_CLOSE_ERROR; - } - EXIT (); - return 0; -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION zip_establishCache -/** - * Called to set up a cache when a zip file is opened with a cachePool but without a cache, or when the - * current cache is found to be invalid in some way. - * - * @param[in] portLib the port library - * @param[in] zipFile the zip file for which we want to establish a cache - * - * The current cache is marked as invalid such that new instances of zip files - * won't try to use it and an attempt is made to establish a new cache. - * - * @return 0 on success - * @return ZIP_ERR_FILE_READ_ERROR if there is an error reading from zipFile - * @return ZIP_ERR_FILE_OPEN_ERROR if is there is an error opening the file - * @return ZIP_ERR_UNKNOWN_FILE_TYPE if the file type is unknown - * @return ZIP_ERR_UNSUPPORTED_FILE_TYPE if the file type is unsupported - * @return ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call - * @return ZIP_ERR_INTERNAL_ERROR if there was an internal error -*/ - -I_32 -zip_establishCache (HyPortLibrary * portLib, HyZipFile * zipFile) -{ - PORT_ACCESS_FROM_PORT (portLib); - I_32 result; - I_64 timeStamp, actualFileSize; - IDATA fileSize, filenameLength; - - if (zipFile->cache) - { - if (zipFile->cachePool) - { - /* Whack cache timestamp to keep other people from starting to use it (we will create a new one for them - to start to use instead). Once all the current users of the cache have stopped using it, it will go away */ - zipFile->cache->zipTimeStamp = -2; - zipCachePool_release (zipFile->cachePool, zipFile->cache); - } - zipFile->cache = NULL; - } - if (!zipFile->cachePool) - { - return ZIP_ERR_INTERNAL_ERROR; - } - - /* Check the cachePool for a suitable cache. */ - filenameLength = strlen ((const char *) zipFile->filename); - -// timeStamp = hyfile_lastmod ((const char *) zipFile->filename); -// actualFileSize = hyfile_length ((const char *) zipFile->filename); - { - struct stat st; - tzset (); - stat ((mcSignednessBull)zipFile->filename, &st); - timeStamp = (U_64)st.st_mtime * 1000; - actualFileSize = (I_64) st.st_size; - } - - if ((actualFileSize < 0) || (actualFileSize > HYCONST64 (0x7FFFFFFF))) - { - return ZIP_ERR_INTERNAL_ERROR; - } - fileSize = (IDATA) actualFileSize; - - zipFile->cache = - zipCachePool_findCache (zipFile->cachePool, - (const char *) zipFile->filename, filenameLength, - fileSize, timeStamp); - if (!zipFile->cache) - { - /* Build a new cache. Because caller asked for a cache, fail if we can't provide one */ - zipFile->cache = - zipCache_new (portLib, (char *) zipFile->filename, filenameLength); - if (!zipFile->cache) - return ZIP_ERR_OUT_OF_MEMORY; - - zipFile->cache->zipFileSize = fileSize; - zipFile->cache->zipTimeStamp = timeStamp; - - result = zip_populateCache (portLib, zipFile); - if (result != 0) - { - zipCache_kill (zipFile->cache); - zipFile->cache = NULL; - return result; - } - if (!zipCachePool_addCache (zipFile->cachePool, zipFile->cache)) - { - zipCache_kill (zipFile->cache); - zipFile->cache = NULL; - return ZIP_ERR_OUT_OF_MEMORY; - } - } - return 0; -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION zip_initZipEntry -/** - * Initialize a zip entry. - * - * Should be called before the entry is passed to any other zip support functions - * - * @param[in] portLib the port library - * @param[in] entry the zip entry to init - * - * @return none -*/ - -void -zip_initZipEntry (HyPortLibrary * portLib, HyZipEntry * entry) -{ - memset (entry, 0, sizeof (*entry)); -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION zip_freeZipEntry -/** - * Free any memory associated with a zip entry. - * - * @param[in] portLib the port library - * @param[in] entry the zip entry we are freeing - * - * @return none - * - * @note This does not free the entry itself. -*/ - -void -zip_freeZipEntry (HyPortLibrary * portLib, HyZipEntry * entry) -{ - PORT_ACCESS_FROM_PORT (portLib); - - if ((entry->filename) && (entry->filename != entry->internalFilename)) - { - hymem_free_memory (entry->filename); - } - entry->filename = NULL; - if (entry->extraField) - { - hymem_free_memory (entry->extraField); - entry->extraField = NULL; - } - if (entry->data) - { - hymem_free_memory (entry->data); - entry->data = NULL; - } - if (entry->fileComment) - { - hymem_free_memory (entry->fileComment); - entry->fileComment = NULL; - } -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION zip_getNextZipEntry -/** - * Read the next zip entry at nextEntryPointer into zipEntry. - * - * Any memory held onto by zipEntry may be lost, and therefore - * MUST be freed with @ref zip_freeZipEntry first. - * - * @param[in] portLib the port library - * @param[in] zipFile The zip file being read - * @param[out] zipEntry compressed data is placed here - * @param[in] nextEntryPointer - * - * @return 0 on success - * @return ZIP_ERR_FILE_READ_ERROR if there is an error reading zipFile - * @return ZIP_ERR_FILE_CORRUPT if zipFile is corrupt - * @return ZIP_ERR_NO_MORE_ENTRIES if there are no more entries in zipFile - * @return ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call - * - * @see zip_freeZipEntry - * -*/ -I_32 -zip_getNextZipEntry (HyPortLibrary * portLib, HyZipFile * zipFile, - HyZipEntry * zipEntry, IDATA * nextEntryPointer) -{ - PORT_ACCESS_FROM_PORT (portLib); -#if defined(HY_NO_THR) - THREAD_ACCESS_FROM_PORT(portLib); -#endif /* HY_NO_THR */ - IDATA result; - BOOLEAN retryAllowed = TRUE; - IDATA pointer; - IDATA entryStart; - I_64 seekResult; - - ENTER (); - -retry: - pointer = *nextEntryPointer; - - /* Seek to the entry's position in the file. */ - if (pointer != zipFile->pointer) - { - seekResult = hyfile_seek (zipFile->fd, pointer, HySeekSet); - if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF))) - { - zipFile->pointer = -1; - EXIT (); - return ZIP_ERR_FILE_READ_ERROR; - } - zipFile->pointer = (I_32) seekResult; - - if (pointer != zipFile->pointer) - { - zipFile->pointer = -1; - EXIT (); - return ZIP_ERR_FILE_READ_ERROR; - } - } - - /* Read the entry */ - entryStart = *nextEntryPointer; - result = - readZipEntry (portLib, zipFile, zipEntry, NULL, &pointer, &entryStart, - FALSE); - if (result != 0) - { - if (!retryAllowed || (result == ZIP_ERR_NO_MORE_ENTRIES)) - { - EXIT (); - return result; - } - zip_establishCache (portLib, zipFile); - retryAllowed = FALSE; - goto retry; - } - - if (zipFile->cache) - { - /* Validity check: look up filename in the cache... */ - result = - (IDATA) zipCache_findElement (zipFile->cache, - (const char *) zipEntry->filename, - FALSE); - if (result != entryStart) - { - if (result >= zipFile->cache->startCentralDir) - { - /* ! Cache contents are not valid. Invalidate it and make a new one */ - if (!retryAllowed) - { - EXIT (); - return ZIP_ERR_FILE_CORRUPT; /* should never happen! */ - } - result = zip_establishCache (portLib, zipFile); - if (!result) - { - /* (silently start operating without a cache if we couldn't make a new one) */ - } - else - { - retryAllowed = FALSE; - goto retry; - } - } - else - { - /* We know that the central header for this entry contains info that the - local header is missing (comment length and/or uncompressed size) */ - zipEntry->fileCommentPointer = -1; - } - } - } - - *nextEntryPointer = pointer; - EXIT (); - return 0; -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION zip_getZipEntry -/** - * Attempt to find and read the zip entry corresponding to filename. - * If found, read the entry into the parameter entry. - * - * If an uncached entry is found, the filename field will be filled in. This - * memory will have to be freed with @ref zip_freeZipEntry. - * - * @param[in] portLib the port library - * @param[in] zipFile the file being read from - * @param[out] entry the zip entry found in zipFile is read to here - * @param[in] filename the name of the file that corresponds to entry - * @param[in] findDirectory when true, match a directory even if filename does not end in '/'. - * Note findDirectory is only supported (for the JCL) when there is a cache - * - * @return 0 on success or one of the following: - * @return ZIP_ERR_FILE_READ_ERROR if there is an error reading from zipFile - * @return ZIP_ERR_FILE_CORRUPT if zipFile is corrupt - * @return ZIP_ERR_ENTRY_NOT_FOUND if a zip entry with name filename was not found - * @return ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call - * - * @see zip_freeZipEntry -*/ - -I_32 -zip_getZipEntry (HyPortLibrary * portLib, HyZipFile * zipFile, - HyZipEntry * entry, const char *filename, - BOOLEAN findDirectory) -{ - PORT_ACCESS_FROM_PORT (portLib); -#if defined(HY_NO_THR) - THREAD_ACCESS_FROM_PORT(portLib); -#endif /* HY_NO_THR */ - IDATA result, position; - BOOLEAN retryAllowed = TRUE; - I_64 seekResult; - - ENTER (); - -retry: - if (zipFile->cache) - { - /* Look up filename in the cache. */ - position = - (IDATA) zipCache_findElement (zipFile->cache, filename, - findDirectory); - if (position == -1) - { - /* Note: we assume the cache is still valid here */ - EXIT (); - return ZIP_ERR_ENTRY_NOT_FOUND; - } - - /* Seek to the entry's position in the file. */ - if (zipFile->pointer != position) - { - seekResult = hyfile_seek (zipFile->fd, position, HySeekSet); - if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF))) - { - zipFile->pointer = -1; - EXIT (); - return ZIP_ERR_FILE_READ_ERROR; - } - zipFile->pointer = (I_32) seekResult; - - if (zipFile->pointer != position) - { - zipFile->pointer = -1; - EXIT (); - return ZIP_ERR_FILE_READ_ERROR; - } - } - - /* Read the entry */ - result = - readZipEntry (portLib, zipFile, entry, filename, NULL, NULL, - findDirectory); - if (result != 0) - { - if (!retryAllowed) - { - EXIT (); - return result; - } - result = zip_establishCache (portLib, zipFile); /* invalidate existing cache */ - if (result) - { - EXIT (); - return result; - } - retryAllowed = FALSE; - goto retry; - } - EXIT (); - return 0; - } - else - { - /* Uh oh -- random access without a cache (SLOW!) */ - position = 0; - zip_resetZipFile (PORTLIB, zipFile, &position); - while (TRUE) - { - - if (zipFile->pointer != position) - { - seekResult = hyfile_seek (zipFile->fd, position, HySeekSet); - if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF))) - { - zipFile->pointer = -1; - EXIT (); - return ZIP_ERR_FILE_READ_ERROR; - } - zipFile->pointer = (I_32) seekResult; - - if (zipFile->pointer != position) - { - zipFile->pointer = -1; - EXIT (); - return ZIP_ERR_FILE_READ_ERROR; - } - } - - result = - readZipEntry (portLib, zipFile, entry, NULL, &position, NULL, - FALSE); - if (result || !strcmp ((const char *) entry->filename, filename)) - { - EXIT (); - return result; - } - - /* No match. Reset for next entry */ - zip_freeZipEntry (portLib, entry); - zip_initZipEntry (portLib, entry); - } - } -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION zip_getZipEntryData -/** - * Attempt to read and uncompress the data for the zip entry entry. - * - * If buffer is non-NULL it is used, but not explicitly held onto by the entry. - * If buffer is NULL, memory is allocated and held onto by the entry, and thus - * should later be freed with @ref zip_freeZipEntry. - * - * @param[in] portLib the port library - * @param[in] zipFile the zip file being read from. - * @param[in,out] entry the zip entry - * @param[in] buffer may or may not be NULL - * @param[in] bufferSize - - * @return 0 on success - * @return ZIP_ERR_FILE_READ_ERROR if there is an error reading from zipEntry - * @return ZIP_ERR_FILE_CORRUPT if zipFile is corrupt - * @return ZIP_ERR_ENTRY_NOT_FOUND if entry is not found - * @return ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call - * @return ZIP_ERR_BUFFER_TOO_SMALL if buffer is too small to hold the comment for zipFile - * - * @see zip_freeZipEntry - * -*/ -I_32 -zip_getZipEntryData (HyPortLibrary * portLib, HyZipFile * zipFile, - HyZipEntry * entry, U_8 * buffer, U_32 bufferSize) -{ - PORT_ACCESS_FROM_PORT (portLib); -#if defined(HY_NO_THR) - THREAD_ACCESS_FROM_PORT(portLib); -#endif /* HY_NO_THR */ - - I_32 result; - U_8 *dataBuffer; - struct workBuffer wb; - I_64 seekResult; - - ENTER (); - - wb.portLib = portLib; - wb.bufferStart = wb.bufferEnd = wb.currentAlloc = 0; - - if (buffer) - { - if (bufferSize < entry->uncompressedSize) - { - EXIT (); - return ZIP_ERR_BUFFER_TOO_SMALL; - } - dataBuffer = buffer; - } - else - { - /* Note that this is the first zalloc. This memory must be available to the calling method and is freed explicitly in zip_freeZipEntry. */ - /* Note that other allocs freed in zip_freeZipEntry are not alloc'd using zalloc */ - dataBuffer = zdataalloc (&wb, 1, entry->uncompressedSize); - if (!dataBuffer) - { - EXIT (); - return ZIP_ERR_OUT_OF_MEMORY; - } - entry->data = dataBuffer; - } - - if (entry->compressionMethod == ZIP_CM_Stored) - { - /* No compression - just read the data in. */ - if (zipFile->pointer != entry->dataPointer) - { - seekResult = - hyfile_seek (zipFile->fd, entry->dataPointer, HySeekSet); - if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF))) - { - zipFile->pointer = -1; - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - zipFile->pointer = (I_32) seekResult; - - if (zipFile->pointer != entry->dataPointer) - { - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - } - result = hyfile_read (zipFile->fd, dataBuffer, entry->compressedSize); - if (result != (I_32) entry->compressedSize) - { - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - zipFile->pointer += result; - EXIT (); - return 0; - } - - if (entry->compressionMethod == ZIP_CM_Deflated) - { - U_8 *readBuffer; - - /* Ensure that the library is loaded. */ - if (checkZipLibrary (portLib)) - { - result = ZIP_ERR_UNSUPPORTED_FILE_TYPE; - goto finished; - } - - /* Read the file contents. */ - readBuffer = zdataalloc (&wb, 1, entry->compressedSize); - if (!readBuffer) - { - result = ZIP_ERR_OUT_OF_MEMORY; - goto finished; - } - if (zipFile->pointer != entry->dataPointer) - { - seekResult = - hyfile_seek (zipFile->fd, entry->dataPointer, HySeekSet); - if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF))) - { - zipFile->pointer = -1; - zdatafree (&wb, readBuffer); - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - zipFile->pointer = (I_32) seekResult; - - if (zipFile->pointer != entry->dataPointer) - { - zdatafree (&wb, readBuffer); - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - } - if (hyfile_read (zipFile->fd, readBuffer, entry->compressedSize) != - (I_32) entry->compressedSize) - { - zdatafree (&wb, readBuffer); - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - zipFile->pointer += (I_32) entry->compressedSize; - - /* Deflate the data. */ - result = - inflateData (&wb, readBuffer, entry->compressedSize, dataBuffer, - entry->uncompressedSize); - zdatafree (&wb, readBuffer); - if (result) - goto finished; - EXIT (); - return 0; - } - - /* Whatever this is, we can't decompress it */ - result = ZIP_ERR_UNSUPPORTED_FILE_TYPE; - -finished: - if (!buffer) - { - entry->data = NULL; - zdatafree (&wb, dataBuffer); - } - if (result == ZIP_ERR_FILE_READ_ERROR) - { - zipFile->pointer = -1; - } - EXIT (); - return result; -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION zip_getZipEntryExtraField -/** - * Read the extra field of entry from the zip file filename. - * - * buffer is used if non-NULL, but is not held onto by entry. - * - * If buffer is NULL, memory is allocated and held onto by entry, and MUST be freed later with - * @ref zip_freeZipEntry. - * - * @param[in] portLib the port library - * @param[in] zipFile the zip file being read from. - * @param[in,out] entry the zip entry concerned - * @param[in] buffer may or may not be NULL - * @param[in] bufferSize - * - * @return 0 on success or one of the following: - * @return ZIP_ERR_FILE_READ_ERROR if there is an error reading from zipFile - * @return ZIP_ERR_FILE_CORRUPT if zipFile is corrupt - * @return ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call - * @return ZIP_ERR_BUFFER_TOO_SMALL if the buffer was non-Null but not large enough to hold the contents of entry - * - * @see zip_freeZipEntry -*/ -I_32 -zip_getZipEntryExtraField (HyPortLibrary * portLib, HyZipFile * zipFile, - HyZipEntry * entry, U_8 * buffer, U_32 bufferSize) -{ - PORT_ACCESS_FROM_PORT (portLib); -#if defined(HY_NO_THR) - THREAD_ACCESS_FROM_PORT(portLib); -#endif /* HY_NO_THR */ - - I_32 result; - U_8 *extraFieldBuffer; - I_64 seekResult; - - ENTER (); - - if (entry->extraFieldLength == 0) - { - EXIT (); - return 0; - } - - if (buffer) - { - if (bufferSize < entry->extraFieldLength) - { - EXIT (); - return ZIP_ERR_BUFFER_TOO_SMALL; - } - extraFieldBuffer = buffer; - } - else - { - extraFieldBuffer = hymem_allocate_memory (entry->extraFieldLength); - if (!extraFieldBuffer) - { - EXIT (); - return ZIP_ERR_OUT_OF_MEMORY; - } - entry->extraField = extraFieldBuffer; - } - - if (zipFile->pointer != entry->extraFieldPointer) - { - seekResult = - hyfile_seek (zipFile->fd, entry->extraFieldPointer, HySeekSet); - if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF))) - { - zipFile->pointer = -1; - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - zipFile->pointer = (I_32) seekResult; - if (zipFile->pointer != entry->extraFieldPointer) - { - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - } - result = - hyfile_read (zipFile->fd, extraFieldBuffer, entry->extraFieldLength); - if (result != (I_32) entry->extraFieldLength) - { - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - zipFile->pointer += result; - EXIT (); - return 0; - -finished: - if (!buffer) - { - entry->extraField = NULL; - hymem_free_memory (extraFieldBuffer); - } - if (result == ZIP_ERR_FILE_READ_ERROR) - zipFile->pointer = -1; - EXIT (); - return result; - -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION zip_getZipEntryFilename - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION zip_getZipEntryComment -/** - * Read the file comment for entry. - * - * If buffer is non-NULL, it is used, but not held onto by entry. - * - * If buffer is NULL, memory is allocated and - * held onto by entry, and thus should later be freed with @ref zip_freeZipEntry. - * - * @param[in] portLib the port library - * @param[in] zipFile the zip file concerned - * @param[in] entry the entry who's comment we want - * @param[in] buffer may or may not be NULL - * @param[in] bufferSize - - * @return 0 on success or one of the following - * @return ZIP_ERR_FILE_READ_ERROR if there is an error reading the file comment from zipEntry - * @return ZIP_ERR_FILE_CORRUPT if zipFile is corrupt - * @return ZIP_ERR_ENTRY_NOT_FOUND if entry is not found - * @return ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call - * @return ZIP_ERR_BUFFER_TOO_SMALL if buffer is too small to hold the comment for zipFile -*/ - -I_32 -zip_getZipEntryComment (HyPortLibrary * portLib, HyZipFile * zipFile, - HyZipEntry * entry, U_8 * buffer, U_32 bufferSize) -{ - PORT_ACCESS_FROM_PORT (portLib); -#if defined(HY_NO_THR) - THREAD_ACCESS_FROM_PORT(portLib); -#endif /* HY_NO_THR */ - - I_32 result; - U_8 *fileCommentBuffer; - I_64 seekResult; - - ENTER (); - - if (entry->fileCommentLength == 0) - { - if (entry->fileCommentPointer == -1) - { - /* TODO: we don't know where the comment is (or even if there is one)! This only happens if you're running - without a cache, so too bad for now */ - } - EXIT (); - return 0; - } - - if (buffer) - { - if (bufferSize < entry->fileCommentLength) - { - EXIT (); - return ZIP_ERR_BUFFER_TOO_SMALL; - } - fileCommentBuffer = buffer; - } - else - { - fileCommentBuffer = hymem_allocate_memory (entry->fileCommentLength); - if (!fileCommentBuffer) - { - EXIT (); - return ZIP_ERR_OUT_OF_MEMORY; - } - entry->fileComment = fileCommentBuffer; - } - - if (zipFile->pointer != entry->fileCommentPointer) - { - seekResult = - hyfile_seek (zipFile->fd, entry->fileCommentPointer, HySeekSet); - if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF))) - { - zipFile->pointer = -1; - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - zipFile->pointer = (I_32) seekResult; - - if (zipFile->pointer != entry->fileCommentPointer) - { - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - } - result = - hyfile_read (zipFile->fd, fileCommentBuffer, entry->fileCommentLength); - if (result != (I_32) entry->fileCommentLength) - { - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - zipFile->pointer += result; - EXIT (); - return 0; - -finished: - if (!buffer) - { - entry->fileComment = NULL; - hymem_free_memory (fileCommentBuffer); - } - if (result == ZIP_ERR_FILE_READ_ERROR) - { - zipFile->pointer = -1; - } - EXIT (); - return result; - -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION zip_openZipFile -/** - * Attempt to open a zip file. - * - * If the cache pool is non-NULL, the cachePool will be used to find a suitable cache, and if none can be found it will create one and add it to cachePool. - * Zip support is responsible for managing the lifetime of the cache. - * - * @note If cachePool is NULL, zipFile will be opened without a cache. - * - * @param[in] portLib the port library - * @param[in] filename the zip file to open - * @param[out] zipFile the zip file structure to populate - * @param[in] cachePool the cache pool - * - * @return 0 on success - * @return ZIP_ERR_FILE_OPEN_ERROR if is there is an error opening the file - * @return ZIP_ERR_FILE_READ_ERROR if there is an error reading the file - * @return ZIP_ERR_FILE_CORRUPT if the file is corrupt - * @return ZIP_ERR_UNKNOWN_FILE_TYPE if the file type is not known - * @return ZIP_ERR_UNSUPPORTED_FILE_TYPE if the file type is unsupported - * @return ZIP_ERR_OUT_OF_MEMORY if we are out of memory -*/ -I_32 -zip_openZipFile (HyPortLibrary * portLib, char *filename, HyZipFile * zipFile, - HyZipCachePool * cachePool) -{ - PORT_ACCESS_FROM_PORT (portLib); -#if defined(HY_NO_THR) - THREAD_ACCESS_FROM_PORT(portLib); -#endif /* HY_NO_THR */ - - IDATA fd = -1; - I_32 result = 0; - I_64 seekResult; - U_8 buffer[4]; - I_32 len; - - ENTER (); - - len = strlen (filename); - zipFile->fd = -1; - zipFile->type = ZIP_Unknown; - zipFile->cache = NULL; - zipFile->cachePool = NULL; - zipFile->pointer = -1; - /* Allocate space for filename */ - if (len >= ZIP_INTERNAL_MAX) - { - zipFile->filename = hymem_allocate_memory (len + 1); - if (!zipFile->filename) - { - EXIT (); - return ZIP_ERR_OUT_OF_MEMORY; - } - } - else - { - zipFile->filename = zipFile->internalFilename; - } - - strcpy ((char *) zipFile->filename, filename); - - fd = hyfile_open (filename, HyOpenRead, 0); - if (fd == -1) - { - result = ZIP_ERR_FILE_OPEN_ERROR; - goto finished; - } - - if (hyfile_read (fd, buffer, 4) != 4) - { - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - - if ((buffer[0] == 'P') && (buffer[1] == 'K')) - { - /* If not the central header or local file header, its corrupt */ - if (! - ((buffer[2] == 1 && buffer[3] == 2) - || (buffer[2] == 3 && buffer[3] == 4))) - { - result = ZIP_ERR_FILE_CORRUPT; - goto finished; - } - /* PKZIP file. Back up the pointer to the beginning. */ - seekResult = hyfile_seek (fd, 0, HySeekSet); - if (seekResult != 0) - { - result = ZIP_ERR_FILE_READ_ERROR; - goto finished; - } - - zipFile->fd = fd; - zipFile->type = ZIP_PKZIP; - zipFile->pointer = 0; - } - - if ((buffer[0] == 0x1F) && (buffer[1] == 0x8B)) - { - /* GZIP - currently unsupported. - zipFile->fd = fd; - zipFile->type = ZIP_GZIP; - zipFile->pointer = 2; - */ - result = ZIP_ERR_UNSUPPORTED_FILE_TYPE; - goto finished; - } - - if (zipFile->type == ZIP_Unknown) - { - result = ZIP_ERR_UNKNOWN_FILE_TYPE; - goto finished; - } - - result = 0; - - if (cachePool) - { - zipFile->cachePool = cachePool; - result = zip_establishCache (portLib, zipFile); - } - -finished: - if (result == 0) - { - zipFile->fd = fd; - EXIT (); - return 0; - } - if (fd != -1) - { - hyfile_close (fd); - } - if ((zipFile->filename) && (zipFile->filename != zipFile->internalFilename)) - { - hymem_free_memory (zipFile->filename); - } - zipFile->filename = NULL; - EXIT (); - return result; -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION zip_resetZipFile -/** - * Reset nextEntryPointer to the first entry in the file. - * - * @param[in] portLib the port library - * @param[in] zipFile the zip being read from - * @param[out] nextEntryPointer will be reset to the first entry in the file - * - * @return none - * - * -*/ -void -zip_resetZipFile (HyPortLibrary * portLib, HyZipFile * zipFile, - IDATA * nextEntryPointer) -{ - *nextEntryPointer = 0; - if (zipFile) - { - if (zipFile->cache) - *nextEntryPointer = zipFile->cache->startCentralDir; - else - { - I_32 result; - HyZipCentralEnd endEntry; - result = scanForCentralEnd (portLib, zipFile, &endEntry); - if (result != 0) - return; - *nextEntryPointer = (IDATA) ((UDATA) endEntry.dirOffset); - } - } -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION zip_getZipEntryFromOffset -/** - * Attempt to read a zip entry at offset from the zip file provided. - * If found, read into entry. - * - * @note If an uncached entry is found, the filename field will be filled in. This - * memory MUST be freed with @ref zip_freeZipEntry. - * - * @param[in] portLib the port library - * @param[in] zipFile the zip file being read - * @param[in] offset the offset into the zipFile of the desired zip entry - * @param[out] entry the compressed data - * - * @return 0 on success - * @return ZIP_ERR_FILE_READ_ERROR if there is an error reading from @ref zipFile - * @return ZIP_ERR_FILE_CORRUPT if @ref zipFile is corrupt - * @return ZIP_ERR_ENTRY_NOT_FOUND if the entry is not found - * @return ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call - * - * @see zip_freeZipEntry -*/ -I_32 -zip_getZipEntryFromOffset (HyPortLibrary * portLib, HyZipFile * zipFile, - HyZipEntry * entry, IDATA offset) -{ - PORT_ACCESS_FROM_PORT (portLib); -#if defined(HY_NO_THR) - THREAD_ACCESS_FROM_PORT(portLib); -#endif /* HY_NO_THR */ - I_32 result; - I_64 seekResult; - - ENTER (); - - if (zipFile->pointer != offset) - { - seekResult = hyfile_seek (zipFile->fd, offset, HySeekSet); - if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF))) - { - zipFile->pointer = -1; - EXIT (); - return ZIP_ERR_FILE_READ_ERROR; - } - zipFile->pointer = (I_32) seekResult; - if (zipFile->pointer != offset) - { - zipFile->pointer = -1; - EXIT (); - return ZIP_ERR_FILE_READ_ERROR; - } - } - - result = readZipEntry (portLib, zipFile, entry, NULL, NULL, NULL, FALSE); - EXIT (); - return result; -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION zdataalloc -/* - cached alloc management for zip_getZipEntryData. -*/ -void * -zdataalloc (void *opaque, U_32 items, U_32 size) -{ - UDATA *returnVal = 0; - U_32 byteSize = items * size; - U_32 allocSize = WORK_BUFFER_SIZE; - struct workBuffer *wb = (struct workBuffer *) opaque; - - PORT_ACCESS_FROM_PORT (wb->portLib); - - /* Round to UDATA multiple */ - byteSize = (byteSize + (sizeof (UDATA) - 1)) & ~(sizeof (UDATA) - 1); - - if (wb->bufferStart == 0) - { - if (byteSize > WORK_BUFFER_SIZE) - { - allocSize = byteSize; - } - wb->bufferStart = hymem_allocate_memory (allocSize); - if (wb->bufferStart) - { - wb->bufferEnd = (UDATA *) ((UDATA) wb->bufferStart + allocSize); - wb->currentAlloc = wb->bufferStart; - wb->cntr = 0; - } - } - - if ((wb->bufferStart == 0) - || (((UDATA) wb->currentAlloc + byteSize) > (UDATA) wb->bufferEnd)) - { - returnVal = hymem_allocate_memory (byteSize); - } - else - { - ++(wb->cntr); - returnVal = wb->currentAlloc; - wb->currentAlloc = (UDATA *) ((UDATA) wb->currentAlloc + byteSize); - } - return returnVal; -} - -#undef CDEV_CURRENT_FUNCTION - -#define CDEV_CURRENT_FUNCTION zdatafree -/* - cached alloc management for zip_getZipEntryData. -*/ -void -zdatafree (void *opaque, void *address) -{ - struct workBuffer *wb = (struct workBuffer *) opaque; - - PORT_ACCESS_FROM_PORT (wb->portLib); - - if ((address < (void *) wb->bufferStart) - || (address >= (void *) wb->bufferEnd)) - { - hymem_free_memory (address); - } - else if (--(wb->cntr) == 0) - { - hymem_free_memory (wb->bufferStart); - wb->bufferStart = wb->bufferEnd = wb->currentAlloc = 0; - } - -} - -#undef CDEV_CURRENT_FUNCTION diff --git a/libcore/archive/src/main/native/zipsup.h b/libcore/archive/src/main/native/zipsup.h deleted file mode 100644 index 67a2eda2c..000000000 --- a/libcore/archive/src/main/native/zipsup.h +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* Zip Support Header -*/ - -#if !defined(ZIPSUP_H) -#define ZIPSUP_H -#if defined(__cplusplus) -extern "C" -{ -#endif -#include "hy2sie.h" - -#include -#include -#include - -#include "zlib.h" - - -typedef struct HyZipCachePool HyZipCachePool; - -HyZipCachePool * -zipsup_GetZipCachePool(HyPortLibrary * portLib); - - -#if defined(HY_LOCAL_ZLIB) -#define HY_ZIP_DLL_NAME "z" -#else -#define HY_ZIP_DLL_NAME "hyzlib" -#endif - -#define ZIP_INTERNAL_MAX 80 -#define ZIP_CM_Reduced1 2 -#define ZIP_Unknown 0 -#define ZIP_GZIP 2 -#define ZIP_ERR_OUT_OF_MEMORY -3 -#define ZIP_ERR_FILE_CORRUPT -6 -#define ZIP_ERR_INTERNAL_ERROR -11 -#define ZIP_CM_Imploded 6 -#define ZIP_CM_Reduced4 5 -#define ZIP_CM_Shrunk 1 -#define ZIP_CM_Reduced2 3 -#define ZIP_ERR_FILE_READ_ERROR -1 -#define ZIP_CentralHeader 0x2014B50 -#define ZIP_ERR_FILE_CLOSE_ERROR -10 -#define ZIP_ERR_BUFFER_TOO_SMALL -7 -#define ZIP_CM_Reduced3 4 -#define ZIP_CM_Deflated 8 -#define ZIP_LocalHeader 0x4034B50 -#define ZIP_CM_Tokenized 7 -#define ZIP_PKZIP 1 -#define ZIP_CM_Stored 0 -#define ZIP_ERR_UNSUPPORTED_FILE_TYPE -5 -#define ZIP_ERR_NO_MORE_ENTRIES -2 -#define ZIP_CentralEnd 0x6054B50 -#define ZIP_ERR_FILE_OPEN_ERROR -9 -#define ZIP_ERR_UNKNOWN_FILE_TYPE -4 -#define ZIP_ERR_ENTRY_NOT_FOUND -8 -#define ZIP_DataDescriptor 0x8074B50 - - typedef struct HyZipCache - { - U_8 *zipFileName; - IDATA zipFileSize; - I_64 zipTimeStamp; - IDATA startCentralDir; - HyPortLibrary *portLib; - void *cachePool; - void *cachePoolEntry; - } HyZipCache; - - - typedef struct HyZipCentralEnd - { - U_16 diskNumber; - U_16 dirStartDisk; - U_16 thisDiskEntries; - U_16 totalEntries; - U_32 dirSize; - U_32 dirOffset; - U_16 commentLength; - char _hypadding0012[2]; /* 2 bytes of automatic padding */ - U_8 *comment; - } HyZipCentralEnd; - - - typedef struct HyZipDataDescriptor - { - U_32 crc32; - U_32 compressedSize; - U_32 uncompressedSize; - } HyZipDataDescriptor; - - - typedef struct HyZipEntry - { - U_8 *data; - U_8 *filename; - U_8 *extraField; - U_8 *fileComment; - I_32 dataPointer; - I_32 filenamePointer; - I_32 extraFieldPointer; - I_32 fileCommentPointer; - U_32 compressedSize; - U_32 uncompressedSize; - U_32 crc32; - U_16 filenameLength; - U_16 extraFieldLength; - U_16 fileCommentLength; - U_16 internalAttributes; - U_16 versionCreated; - U_16 versionNeeded; - U_16 flags; - U_16 compressionMethod; - U_16 lastModTime; - U_16 lastModDate; - U_8 internalFilename[80]; - } HyZipEntry; - - - typedef struct HyZipFile - { - U_8 *filename; - struct HyZipCache *cache; - void *cachePool; - I_32 fd; - I_32 pointer; - U_8 internalFilename[80]; - U_8 type; - char _hypadding0065[3]; /* 3 bytes of automatic padding */ - } HyZipFile; - - - -#include "hymutex.h" -extern MUTEX zip_GlobalMutex; - - - -#define jclmem_allocate_memory(env, byteCount) sieb_malloc(env, byteCount) -#define jclmem_free_memory(env, pointer) sieb_free(env, pointer) - - -/* HySourceZipSupport*/ - extern HY_CFUNC I_32 zip_getZipEntryData - PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, - HyZipEntry * entry, U_8 * buffer, U_32 bufferSize)); - extern HY_CFUNC I_32 zip_getZipEntryFromOffset - PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, - HyZipEntry * entry, IDATA offset)); - extern HY_CFUNC I_32 zip_establishCache - PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile)); - extern HY_CFUNC void zip_resetZipFile - PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, - IDATA * nextEntryPointer)); - extern HY_CFUNC I_32 zip_getNextZipEntry - PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, - HyZipEntry * zipEntry, IDATA * nextEntryPointer)); - extern HY_CFUNC I_32 zip_getZipEntry - PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, - HyZipEntry * entry, const char *filename, - BOOLEAN findDirectory)); - extern HY_CFUNC I_32 zip_getZipEntryExtraField - PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, - HyZipEntry * entry, U_8 * buffer, U_32 bufferSize)); - extern HY_CFUNC void zip_initZipEntry - PROTOTYPE ((HyPortLibrary * portLib, HyZipEntry * entry)); - extern HY_CFUNC I_32 zip_openZipFile - PROTOTYPE ((HyPortLibrary * portLib, char *filename, HyZipFile * zipFile, - HyZipCachePool * cachePool)); - extern HY_CFUNC void zip_freeZipEntry - PROTOTYPE ((HyPortLibrary * portLib, HyZipEntry * entry)); - struct HyZipFile; - extern HY_CFUNC I_32 VMCALL zip_closeZipFile - PROTOTYPE ((HyPortLibrary * portLib, struct HyZipFile * zipFile)); - extern HY_CFUNC I_32 zip_getZipEntryComment - PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, - HyZipEntry * entry, U_8 * buffer, U_32 bufferSize)); -/* HySourceZipCache*/ - extern HY_CFUNC UDATA zipCache_findElement - PROTOTYPE ((HyZipCache * zipCache, const char *elementName, - BOOLEAN searchDirList)); - extern HY_CFUNC void zipCache_kill PROTOTYPE ((HyZipCache * zipCache)); - extern HY_CFUNC IDATA zipCache_enumGetDirName - PROTOTYPE ((void *handle, char *nameBuf, UDATA nameBufSize)); - extern HY_CFUNC HyZipCache *zipCache_new - PROTOTYPE ((HyPortLibrary * portLib, char *zipName, IDATA zipNameLength)); - extern HY_CFUNC IDATA zipCache_enumNew - PROTOTYPE ((HyZipCache * zipCache, char *directoryName, void **handle)); - extern HY_CFUNC IDATA zipCache_enumElement - PROTOTYPE ((void *handle, char *nameBuf, UDATA nameBufSize, - UDATA * offset)); - extern HY_CFUNC void zipCache_enumKill PROTOTYPE ((void *handle)); - extern HY_CFUNC BOOLEAN zipCache_addElement - PROTOTYPE ((HyZipCache * zipCache, char *elementName, - UDATA elementOffset)); -/* HySourceZipCachePool*/ - extern HY_CFUNC BOOLEAN zipCachePool_release - PROTOTYPE ((HyZipCachePool * zcp, HyZipCache * zipCache)); - extern HY_CFUNC void zipCachePool_kill PROTOTYPE ((HyZipCachePool * zcp)); - extern HY_CFUNC HyZipCache *zipCachePool_findCache - PROTOTYPE ((HyZipCachePool * zcp, char const *zipFileName, - IDATA zipFileNameLength, IDATA zipFileSize, - I_64 zipTimeStamp)); - extern HY_CFUNC HyZipCachePool *zipCachePool_new - PROTOTYPE ((HyPortLibrary * portLib)); - extern HY_CFUNC BOOLEAN zipCachePool_addCache - PROTOTYPE ((HyZipCachePool * zcp, HyZipCache * zipCache)); - extern HY_CFUNC BOOLEAN zipCachePool_addRef - PROTOTYPE ((HyZipCachePool * zcp, HyZipCache * zipCache)); -#if defined(__cplusplus) -} -#endif -#endif /* ZIPSUP_H */ diff --git a/libcore/archive/src/test/java-internal/org/apache/harmony/archive/util/UtilTest.java b/libcore/archive/src/test/java-internal/org/apache/harmony/archive/util/UtilTest.java deleted file mode 100644 index 9c28dc2e0..000000000 --- a/libcore/archive/src/test/java-internal/org/apache/harmony/archive/util/UtilTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.util; - -import junit.framework.TestCase; - -public class UtilTest extends TestCase { - private static final String ASCII_ALPHABET_LC = "abcdefghijklmnopqrstuvwxyz"; - private static final String ASCII_ALPHABET_UC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - private static final byte[] ASCII_ALPHABET_LC_BYTES; - private static final byte[] ASCII_ALPHABET_UC_BYTES; - - static { - ASCII_ALPHABET_LC_BYTES = new byte[ASCII_ALPHABET_LC.length()]; - for (int i = 0; i < ASCII_ALPHABET_LC_BYTES.length; i++) { - final char c = ASCII_ALPHABET_LC.charAt(i); - final byte b = (byte) c; - assert ((char) b) == c; - ASCII_ALPHABET_LC_BYTES[i] = b; - } - - ASCII_ALPHABET_UC_BYTES = new byte[ASCII_ALPHABET_UC.length()]; - for (int i = 0; i < ASCII_ALPHABET_UC_BYTES.length; i++) { - final char c = ASCII_ALPHABET_UC.charAt(i); - final byte b = (byte) c; - assert ((char) b) == c; - ASCII_ALPHABET_UC_BYTES[i] = b; - } - } - - public void testASCIIIgnoreCaseRegionMatches() { - final String s1 = ASCII_ALPHABET_LC; - final String s2 = ASCII_ALPHABET_UC; - for (int i = 0; i < s1.length(); i++) { - assertTrue(Util.ASCIIIgnoreCaseRegionMatches(s1, i, s2, i, s1 - .length() - - i)); - } - } - - public void testToASCIIUpperCaseByte() { - for (int i = 0; i < ASCII_ALPHABET_LC_BYTES.length; i++) { - assertEquals(ASCII_ALPHABET_UC_BYTES[i], Util - .toASCIIUpperCase(ASCII_ALPHABET_LC_BYTES[i])); - } - for (int i = 0; i < ASCII_ALPHABET_UC_BYTES.length; i++) { - assertEquals(ASCII_ALPHABET_UC_BYTES[i], Util - .toASCIIUpperCase(ASCII_ALPHABET_UC_BYTES[i])); - } - } - - public void testToASCIIUpperCaseChar() { - for (int i = 0; i < ASCII_ALPHABET_LC.length(); i++) { - assertEquals(ASCII_ALPHABET_UC.charAt(i), Util - .toASCIIUpperCase(ASCII_ALPHABET_LC.charAt(i))); - } - for (int i = 0; i < ASCII_ALPHABET_UC.length(); i++) { - assertEquals(ASCII_ALPHABET_UC.charAt(i), Util - .toASCIIUpperCase(ASCII_ALPHABET_UC.charAt(i))); - } - } - - public void testEqualsIgnoreCaseByteArrayByteArray() { - assertTrue(Util.equalsIgnoreCase(ASCII_ALPHABET_LC_BYTES, - ASCII_ALPHABET_LC_BYTES)); - assertTrue(Util.equalsIgnoreCase(ASCII_ALPHABET_LC_BYTES, - ASCII_ALPHABET_UC_BYTES)); - assertTrue(Util.equalsIgnoreCase(ASCII_ALPHABET_UC_BYTES, - ASCII_ALPHABET_UC_BYTES)); - } - -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AllTests.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AllTests.java deleted file mode 100644 index 13fe019ae..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AllTests.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.jar; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Test suite for java.util.jar package. - */ -public class AllTests { - - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } - - public static Test suite() { - TestSuite suite = tests.TestSuiteFactory.createTestSuite( - "Suite org.apache.harmony.archive.tests.java.util.jar"); - suite.addTestSuite(AttributesNameTest.class); - suite.addTestSuite(AttributesTest.class); - suite.addTestSuite(JarEntryTest.class); - suite.addTestSuite(JarExceptionTest.class); - suite.addTestSuite(JarExecTest.class); - suite.addTestSuite(JarFileTest.class); - suite.addTestSuite(JarInputStreamTest.class); - suite.addTestSuite(JarOutputStreamTest.class); - suite.addTestSuite(ManifestTest.class); - suite.addTestSuite(Pack200Test.class); - suite.addTestSuite(Pack200PackerTest.class); - suite.addTestSuite(Pack200UnpackerTest.class); - suite.addTestSuite(ZipExecTest.class); - return suite; - } -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesNameTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesNameTest.java deleted file mode 100644 index 067bf49e6..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesNameTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.jar; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.util.jar.Attributes; -import junit.framework.TestCase; - -@TestTargetClass(Attributes.Name.class) -public class AttributesNameTest extends TestCase { - - /** - * @tests java.util.jar.Attributes.Name#Name(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "Name", - args = {java.lang.String.class} - ) - public void test_AttributesName_Constructor() { - // Regression for HARMONY-85 - try { - new Attributes.Name( - "01234567890123456789012345678901234567890123456789012345678901234567890"); - fail("Assert 0: should have thrown IllegalArgumentException"); - } catch (IllegalArgumentException e) { - // expected - } - - try { - new Attributes.Name((String) null); - fail("NullPointerException expected"); - } catch (NullPointerException ee) { - // expected - } - - assertNotNull(new Attributes.Name("Attr")); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "equals", - args = {java.lang.Object.class} - ) - public void test_equalsLjava_lang_Object() { - Attributes.Name attr1 = new Attributes.Name("Attr"); - Attributes.Name attr2 = new Attributes.Name("Attr"); - - assertTrue(attr1.equals(attr2)); - attr2 = new Attributes.Name("Attr1"); - assertFalse(attr1.equals(attr2)); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "hashCode", - args = {} - ) - public void test_hashCode() { - Attributes.Name attr1 = new Attributes.Name("Attr1"); - Attributes.Name attr2 = new Attributes.Name("Attr2"); - - assertNotSame(attr1.hashCode(), attr2.hashCode()); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "toString", - args = {} - ) - public void test_toString() { - String str1 = "Attr1"; - String str2 = "Attr2"; - Attributes.Name attr1 = new Attributes.Name(str1); - Attributes.Name attr2 = new Attributes.Name("Attr2"); - - assertTrue(attr1.toString().equals(str1)); - assertTrue(attr2.toString().equals(str2)); - assertFalse(attr2.toString().equals(str1)); - } -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java deleted file mode 100644 index 0b3d2cf4e..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java +++ /dev/null @@ -1,541 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.jar; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.jar.Attributes; -import junit.framework.TestCase; - -@TestTargetClass(Attributes.class) -public class AttributesTest extends TestCase { - private Attributes a; - - @Override - protected void setUp() { - a = new Attributes(); - a.putValue("1", "one"); - a.putValue("2", "two"); - a.putValue("3", "three"); - a.putValue("4", "four"); - } - - /** - * @tests java.util.jar.Attributes#Attributes(java.util.jar.Attributes) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "Attributes", - args = {java.util.jar.Attributes.class} - ) - public void test_ConstructorLjava_util_jar_Attributes() { - Attributes a2 = new Attributes(a); - assertEquals(a, a2); - a.putValue("1", "one(1)"); - assertTrue("equal", !a.equals(a2)); - } - - /** - * @tests java.util.jar.Attributes#clear() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "clear", - args = {} - ) - public void test_clear() { - a.clear(); - assertNull("a) All entries should be null after clear", a.get("1")); - assertNull("b) All entries should be null after clear", a.get("2")); - assertNull("c) All entries should be null after clear", a.get("3")); - assertNull("d) All entries should be null after clear", a.get("4")); - assertTrue("Should not contain any keys", !a.containsKey("1")); - } - - /** - * @tests java.util.jar.Attributes#containsKey(java.lang.Object) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "containsKey", - args = {java.lang.Object.class} - ) - public void test_containsKeyLjava_lang_Object() { - assertTrue("a) Should have returned false", !a.containsKey(new Integer( - 1))); - assertTrue("b) Should have returned false", !a.containsKey("0")); - assertTrue("Should have returned true", a - .containsKey(new Attributes.Name("1"))); - } - - /** - * @tests java.util.jar.Attributes#containsValue(java.lang.Object) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "containsValue", - args = {java.lang.Object.class} - ) - public void test_containsValueLjava_lang_Object() { - assertTrue("Should have returned false", !a.containsValue("One")); - assertTrue("Should have returned true", a.containsValue("one")); - } - - /** - * @tests java.util.jar.Attributes#entrySet() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "entrySet", - args = {} - ) - public void test_entrySet() { - Set> entrySet = a.entrySet(); - Set keySet = new HashSet(); - Set valueSet = new HashSet(); - Iterator i; - assertEquals(4, entrySet.size()); - i = entrySet.iterator(); - while (i.hasNext()) { - java.util.Map.Entry e; - e = (Map.Entry) i.next(); - keySet.add(e.getKey()); - valueSet.add(e.getValue()); - } - assertTrue("a) Should contain entry", valueSet.contains("one")); - assertTrue("b) Should contain entry", valueSet.contains("two")); - assertTrue("c) Should contain entry", valueSet.contains("three")); - assertTrue("d) Should contain entry", valueSet.contains("four")); - assertTrue("a) Should contain key", keySet - .contains(new Attributes.Name("1"))); - assertTrue("b) Should contain key", keySet - .contains(new Attributes.Name("2"))); - assertTrue("c) Should contain key", keySet - .contains(new Attributes.Name("3"))); - assertTrue("d) Should contain key", keySet - .contains(new Attributes.Name("4"))); - } - - /** - * @tests java.util.jar.Attributes#get(java.lang.Object) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getValue", - args = {java.lang.String.class} - ) - public void test_getLjava_lang_Object() { - assertEquals("a) Incorrect value returned", "one", a.getValue("1")); - assertNull("b) Incorrect value returned", a.getValue("0")); - - try { - a.getValue("IllegalArgumentException expected"); - } catch (IllegalArgumentException ee) { - // expected - } - } - - /** - * @tests java.util.jar.Attributes#isEmpty() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "isEmpty", - args = {} - ) - public void test_isEmpty() { - assertTrue("Should not be empty", !a.isEmpty()); - a.clear(); - assertTrue("a) Should be empty", a.isEmpty()); - a = new Attributes(); - assertTrue("b) Should be empty", a.isEmpty()); - } - - /** - * @tests java.util.jar.Attributes#keySet() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "keySet", - args = {} - ) - public void test_keySet() { - Set s = a.keySet(); - assertEquals(4, s.size()); - assertTrue("a) Should contain entry", s.contains(new Attributes.Name( - "1"))); - assertTrue("b) Should contain entry", s.contains(new Attributes.Name( - "2"))); - assertTrue("c) Should contain entry", s.contains(new Attributes.Name( - "3"))); - assertTrue("d) Should contain entry", s.contains(new Attributes.Name( - "4"))); - } - - /** - * @tests java.util.jar.Attributes#putAll(java.util.Map) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "putAll", - args = {java.util.Map.class} - ) - public void test_putAllLjava_util_Map() { - Attributes b = new Attributes(); - b.putValue("3", "san"); - b.putValue("4", "shi"); - b.putValue("5", "go"); - b.putValue("6", "roku"); - a.putAll(b); - assertEquals("Should not have been replaced", "one", a.getValue("1")); - assertEquals("Should have been replaced", "san", a.getValue("3")); - assertEquals("Should have been added", "go", a.getValue("5")); - Attributes atts = new Attributes(); - assertNull("Assert 0: ", atts.put(Attributes.Name.CLASS_PATH, - "tools.jar")); - assertNull("Assert 1: ", atts - .put(Attributes.Name.MANIFEST_VERSION, "1")); - Attributes atts2 = new Attributes(); - atts2.putAll(atts); - assertEquals("Assert 2:", "tools.jar", atts2 - .get(Attributes.Name.CLASS_PATH)); - assertEquals("Assert 3: ", "1", atts2 - .get(Attributes.Name.MANIFEST_VERSION)); - try { - atts.putAll(Collections.EMPTY_MAP); - fail("Assert 4: no class cast from attrib parameter"); - } catch (ClassCastException e) { - // Expected - } - } - - /** - * @tests java.util.jar.Attributes#putAll(java.util.Map) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Regression test", - method = "putAll", - args = {java.util.Map.class} - ) - public void test_putAllLjava_util_Map2() { - // Regression for HARMONY-464 - try { - new Attributes().putAll((Map) null); - fail("ClassCastException expected"); - } catch (ClassCastException e) { - } - // verify that special care for null is done in the Attributes.putAll() - // method - try { - new Attributes() { - @Override - public void putAll(Map attrib) { - map.putAll(attrib); - } - }.putAll((Map) null); - fail("NullPointerException expected"); - } catch (NullPointerException e) { - } - } - - /** - * @tests java.util.jar.Attributes#remove(java.lang.Object) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "remove", - args = {java.lang.Object.class} - ) - public void test_removeLjava_lang_Object() { - a.remove(new Attributes.Name("1")); - a.remove(new Attributes.Name("3")); - assertNull("Should have been removed", a.getValue("1")); - assertEquals("Should not have been removed", "four", a.getValue("4")); - } - - /** - * @tests java.util.jar.Attributes#size() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "size", - args = {} - ) - public void test_size() { - assertEquals("Incorrect size returned", 4, a.size()); - a.clear(); - assertEquals(0, a.size()); - } - - /** - * @tests java.util.jar.Attributes#values() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "values", - args = {} - ) - public void test_values() { - Collection valueCollection = a.values(); - assertTrue("a) Should contain entry", valueCollection.contains("one")); - assertTrue("b) Should contain entry", valueCollection.contains("two")); - assertTrue("c) Should contain entry", valueCollection.contains("three")); - assertTrue("d) Should contain entry", valueCollection.contains("four")); - } - - /** - * @tests java.util.jar.Attributes#clone() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "clone", - args = {} - ) - public void test_clone() { - Attributes a2 = (Attributes) a.clone(); - assertEquals(a, a2); - a.putValue("1", "one(1)"); - assertTrue("equal", !a.equals(a2)); - } - - /** - * @tests java.util.jar.Attributes#equals(java.lang.Object) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "equals", - args = {java.lang.Object.class} - ) - public void test_equalsLjava_lang_Object() { - Attributes.Name n1 = new Attributes.Name("name"), n2 = new Attributes.Name( - "Name"); - assertEquals(n1, n2); - Attributes a1 = new Attributes(); - a1.putValue("one", "1"); - a1.putValue("two", "2"); - Attributes a2 = new Attributes(); - a2.putValue("One", "1"); - a2.putValue("TWO", "2"); - assertEquals(a1, a2); - } - - /** - * @tests java.util.jar.Attributes.put(java.lang.Object, java.lang.Object) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Regression test. Checks ClassCastException", - method = "put", - args = {java.lang.Object.class, java.lang.Object.class} - ) - public void test_putLjava_lang_ObjectLjava_lang_Object() { - Attributes atts = new Attributes(); - assertNull("Assert 0: ", atts.put(Attributes.Name.CLASS_PATH, - "tools.jar")); - assertEquals("Assert 1: ", "tools.jar", atts - .getValue(Attributes.Name.CLASS_PATH)); - // Regression for HARMONY-79 - try { - atts.put("not a name", "value"); - fail("Assert 2: no class cast from key parameter"); - } catch (ClassCastException e) { - // Expected - } - try { - atts.put(Attributes.Name.CLASS_PATH, Boolean.TRUE); - fail("Assert 3: no class cast from value parameter"); - } catch (ClassCastException e) { - // Expected - } - } - - /** - * @tests java.util.jar.Attributes.put(java.lang.Object, java.lang.Object) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "ClassCastException checking missed.", - method = "put", - args = {java.lang.Object.class, java.lang.Object.class} - ) - public void test_putLjava_lang_ObjectLjava_lang_Object_Null() { - - Attributes attribute = new Attributes(); - - assertFalse(attribute.containsKey(null)); - assertFalse(attribute.containsValue(null)); - attribute.put(null, null); - attribute.put(null, null); - assertEquals(1, attribute.size()); - assertTrue(attribute.containsKey(null)); - assertTrue(attribute.containsValue(null)); - assertNull(attribute.get(null)); - - String value = "It's null"; - attribute.put(null, value); - assertEquals(1, attribute.size()); - assertEquals(value, attribute.get(null)); - - Attributes.Name name = new Attributes.Name("null"); - attribute.put(name, null); - assertEquals(2, attribute.size()); - assertNull(attribute.get(name)); - } - - /** - * @tests java.util.jar.Attributes.hashCode() - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "hashCode", - args = {} - ) - public void test_hashCode_consistent_with_map() { - MockAttributes mockAttr = new MockAttributes(); - mockAttr.putValue("1", "one"); - assertEquals(mockAttr.getMap().hashCode(), mockAttr.hashCode()); - } - - private static class MockAttributes extends Attributes { - public Map getMap() { - return map; - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "Attributes", - args = {} - ) - public void test_Constructor() { - Attributes attr = new Attributes(); - assertTrue(attr.size() >= 0); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "Attributes", - args = {int.class} - ) - public void test_ConstructorI() { - Attributes attr = new Attributes(10); - assertTrue(attr.size() >= 0); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "get", - args = {java.lang.Object.class} - ) - public void test_getLjava_lang_Object_true() { - assertEquals("a) Incorrect value returned", "one", a - .get(new Attributes.Name("1"))); - assertNull("b) Incorrect value returned", a.get("0")); - assertNull("b) Incorrect value returned", a.get("1")); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getValue", - args = {java.util.jar.Attributes.Name.class} - ) - public void test_getValueLjava_util_jar_Attributes_Name() { - assertEquals("a) Incorrect value returned", "one", a - .getValue(new Attributes.Name("1"))); - assertNull("b) Incorrect value returned", a - .getValue(new Attributes.Name("0"))); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "hashCode", - args = {} - ) - public void test_hashCode() { - Attributes b = (Attributes) a.clone(); - b.putValue("33", "Thirty three"); - assertNotSame(a.hashCode(), b.hashCode()); - b = (Attributes) a.clone(); - b.clear(); - assertNotSame(a.hashCode(), b.hashCode()); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "putValue", - args = {java.lang.String.class, java.lang.String.class} - ) - public void test_putValueLjava_lang_StringLjava_lang_String() { - Attributes b = new Attributes(); - b.put(new Attributes.Name("1"), "one"); - b.putValue("2", "two"); - b.put(new Attributes.Name("3"), "three"); - b.putValue("4", "four"); - - assertTrue(a.equals(b)); - - try { - b.putValue(null, "null"); - fail("NullPointerException expected"); - } catch (NullPointerException ee) { - // expected - } - - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < 0x10000; i++) { - sb.append('3'); - } - try { - b.putValue(new String(sb), "wrong name"); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException ee) { - // expected - } - } -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/DalvikExecTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/DalvikExecTest.java deleted file mode 100644 index 77fbb15ea..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/DalvikExecTest.java +++ /dev/null @@ -1,315 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.jar; - -import dalvik.annotation.AndroidOnly; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargets; - -import junit.framework.TestCase; - -import tests.support.Support_Exec; -import tests.support.resource.Support_Resources; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.jar.Attributes; -import java.util.jar.JarEntry; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; -import java.util.jar.JarFile; - - -@TestTargetClass(JarOutputStream.class) -@AndroidOnly("dalvik vm specific") -public class DalvikExecTest extends TestCase { - - String execDalvik1 (String classpath, String mainClass, String arg1) - throws IOException, InterruptedException { - - ArrayList cmdLine = new ArrayList(10); - - String base = System.getenv("OUT"); - cmdLine.add(base + "/system/bin/dalvikvm"); - - cmdLine.add("-Djava.io.tmpdir=/tmp/mc"); - cmdLine.add("-Duser.language=en"); - cmdLine.add("-Duser.region=US"); - - if ("true".equals(System.getenv("TARGET_SIMULATOR"))) { - // Test against SIMULATOR: -// cmdLine.add("-Xmx512M"); -// cmdLine.add("-Xcheck:jni"); - cmdLine.add("-Xbootclasspath:" + System.getProperty("java.boot.class.path")); - } else { - // Test against EMULATOR: - } - - cmdLine.add("-classpath"); - cmdLine.add(classpath); - cmdLine.add(mainClass); - - if (arg1 != null) cmdLine.add(arg1); - - Object[] res = Support_Exec.execAndDigestOutput( - cmdLine.toArray(new String[cmdLine.size()]), - null ); - return Support_Exec.getProcessOutput(res, true); - } - - String execDalvik (String classpath, String mainClass) - throws IOException, InterruptedException { - return execDalvik1(classpath, mainClass, null); - } - - @TestTargets ({ - @TestTargetNew( - level = TestLevel.ADDITIONAL, - notes = "Execute an existing JAR on dalvikvm using -classpath option.", - clazz = Runtime.class, - method = "exec", - args = {java.lang.String[].class} - ) - }) - public void test_execExistingJar () throws IOException, InterruptedException { - String res; - File jarFile; - if (System.getProperty("java.vendor").contains("Android")) { - // - // Test against Android: - // - File tempDir = Support_Resources.createTempFolder(); - jarFile = Support_Resources.copyFile( - tempDir, null, "cts_dalvikExecTest.jar" ); - res = execDalvik(jarFile.getAbsolutePath(), "dalvikExecTest.HelloWorld"); - assertEquals("Hello Android World!", "Hello Android World!\n", res); - - res = execDalvik(jarFile.getAbsolutePath(), "dalvikExecTest.ResourceDumper"); - assertTrue("Android Resource Dumper started", - res.contains("Android Resource Dumper started")); - assertTrue("This Resource contains some text.", - res.contains("This Resource contains some text.")); - } else { - // - // Test against RI: - // - // Do nothing! - } - } - - - @TestTargets ({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - method = "putNextEntry", - args = {java.util.zip.ZipEntry.class} - ), - @TestTargetNew( - level = TestLevel.ADDITIONAL, - method = "JarOutputStream", - args = {java.io.OutputStream.class} - ), - @TestTargetNew( - level = TestLevel.ADDITIONAL, - notes = "Create a temp file, fill it with contents according to Dalvik JAR format, and execute it on dalvikvm using -classpath option.", - clazz = Runtime.class, - method = "exec", - args = {java.lang.String[].class} - ) - }) - public void test_execCreatedJar () throws IOException, InterruptedException { - File jarFile = File.createTempFile("cts_dalvikExecTest_", ".jar"); - jarFile.deleteOnExit(); - - // Create a JAR output stream on the temp file: - JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(jarFile)); - - // Define the entry for the classes.dex: - jarOut.putNextEntry(new JarEntry("classes.dex")); - - // Fill in the classes.dex contents, i.e. the Dalvik executable code: - // (See below for the detailed source code contents.) - Support_Resources.writeResourceToStream("cts_dalvikExecTest_classes.dex", jarOut); - - // Now add a resource file: - // - jarOut.putNextEntry(new JarEntry("dalvikExecTest/myResource")); - jarOut.write("This Resource contains some text.".getBytes()); - - // Close the stream to the completed JAR file. - jarOut.close(); - - // The resulting JAR file contains the classes listed at the end of this text, - // like the 'cts_dalvikExecTest.jar' as part of the resources, too. - - String res; - - res = execDalvik(jarFile.getAbsolutePath(), "dalvikExecTest.HelloWorld"); - assertEquals("Hello Android World!", "Hello Android World!\n", res); - - res = execDalvik(jarFile.getAbsolutePath(), "dalvikExecTest.ResourceDumper"); - assertTrue("Android Resource Dumper started", - res.contains("Android Resource Dumper started")); - assertTrue("This Resource contains some text.", - res.contains("This Resource contains some text.")); - } - - - @TestTargets ({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - method = "putNextEntry", - args = {java.util.zip.ZipEntry.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - method = "JarOutputStream", - args = {java.io.OutputStream.class, java.util.jar.Manifest.class} - ), - @TestTargetNew( - level = TestLevel.ADDITIONAL, - clazz = Runtime.class, - method = "exec", - args = {java.lang.String[].class} - ) - }) - /** - * This test does quite the same as test_execCreatedJar, but includes a manifest. - * Note however that the Dalvik JAR format does not require this manifest. - * We just test whether the manifest is placed correctly within the JAR by - * dumping its contents read as a simple text resource. - * No! We can't do that so easily either, as there are other (parent) JARs - * with a manifest inside, taken with precedence. - * So we will reopen the JAR as a JarFile and check the manifest - * with a top level end-to-end approach. - */ - public void test_execCreatedJarWithManifest () throws IOException, InterruptedException { - File jarFile = File.createTempFile("cts_dalvikExecTest_", ".jar"); - jarFile.deleteOnExit(); - - // Create the manifest: - Manifest manifest = new Manifest(); - Attributes attrs = manifest.getMainAttributes(); - attrs.put(Attributes.Name.MANIFEST_VERSION, "3.1415962"); - attrs.put(Attributes.Name.MAIN_CLASS, "dalvikExecTest.HelloWorld"); - attrs.put(Attributes.Name.CLASS_PATH, jarFile.getName()); - - // Create a JAR output stream on the temp file using the manifest: - JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(jarFile), manifest); - - // Define the entry for the classes.dex: - jarOut.putNextEntry(new JarEntry("classes.dex")); - - // Fill in the classes.dex contents, i.e. the Dalvik executable code: - // (See below for the detailed source code contents.) - Support_Resources.writeResourceToStream("cts_dalvikExecTest_classes.dex", jarOut); - - // Now add a resource file: - // - jarOut.putNextEntry(new JarEntry("dalvikExecTest/myResource")); - jarOut.write("This Resource contains some text.".getBytes()); - - // Close the stream to the completed JAR file. - jarOut.close(); - - // The resulting JAR file contains the classes listed at the end of this text, - // like the 'cts_dalvikExecTest.jar' as part of the resources, too. - - String res; - - res = execDalvik(jarFile.getAbsolutePath(), "dalvikExecTest.HelloWorld"); - assertEquals("Hello Android World!", "Hello Android World!\n", res); - - res = execDalvik(jarFile.getAbsolutePath(), "dalvikExecTest.ResourceDumper"); - assertTrue("Android Resource Dumper started", - res.contains("Android Resource Dumper started")); - assertTrue("This Resource contains some text.", - res.contains("This Resource contains some text.")); - - // And now reread the manifest: - // - JarFile jarIn = new JarFile(jarFile); - manifest = jarIn.getManifest(); - attrs = manifest.getMainAttributes(); - assertEquals("MANIFEST_VERSION must match!", "3.1415962", - attrs.get(Attributes.Name.MANIFEST_VERSION)); - assertEquals("MAIN_CLASS must match!", "dalvikExecTest.HelloWorld", - attrs.get(Attributes.Name.MAIN_CLASS)); - assertEquals("CLASS_PATH must match!", jarFile.getName(), - attrs.get(Attributes.Name.CLASS_PATH)); - } - - - /* - * The following two classes are added, here, only for completeness. - * They form the contents of the dalvikExecTest package contained - * in the 'cts_dalvikExecTest_classes.dex' resource file. - */ - /** - * @hide - */ - public static class HelloWorld { - - public static void main(String[] args) { - System.out.println("Hello Android World!"); - } - - } - - public static class ResourceDumper { - - static ByteArrayOutputStream outputFrom (InputStream input) throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - byte[] buffer = new byte[512]; - int total = 0; - int count; - count = input.read(buffer); - while (count != -1) { - out.write(buffer, 0, count); - total = total + count; - count = input.read(buffer); - } - return out; - } - - public static void main(String[] args) throws IOException { - System.out.print("Android Resource Dumper started "); - String fileName; - if (args.length >= 1) { - fileName = args[0]; - System.out.format("for argument '%s'.\n", fileName); - } else { - System.out.print("standard "); - fileName = "myResource"; - System.out.println("for standard 'myResource'."); - } - InputStream is = ResourceDumper.class.getResourceAsStream(fileName); - if (is != null) { - System.out.println("Resource obtained and being dumped:"); - System.out.println(outputFrom(is).toString()); - } - } - - } - -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarEntryTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarEntryTest.java deleted file mode 100644 index 90144be21..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarEntryTest.java +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.jar; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.security.CodeSigner; -import java.util.Enumeration; -import java.util.List; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.zip.ZipEntry; -import junit.framework.TestCase; -import tests.support.resource.Support_Resources; - - -@TestTargetClass(JarEntry.class) -public class JarEntryTest extends TestCase { - private ZipEntry zipEntry; - - private JarEntry jarEntry; - - private JarFile jarFile; - - private final String jarName = "hyts_patch.jar"; - - private final String entryName = "foo/bar/A.class"; - - private final String entryName2 = "Blah.txt"; - - private final String attJarName = "hyts_att.jar"; - - private final String attEntryName = "HasAttributes.txt"; - - private final String attEntryName2 = "NoAttributes.txt"; - - private File resources; - - @Override - protected void setUp() throws Exception { - resources = Support_Resources.createTempFolder(); - Support_Resources.copyFile(resources, null, jarName); - jarFile = new JarFile(new File(resources, jarName)); - } - - @Override - protected void tearDown() throws Exception { - if (jarFile != null) { - jarFile.close(); - } - } - - /** - * @throws IOException - * @tests java.util.jar.JarEntry#JarEntry(java.util.jar.JarEntry) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "JarEntry", - args = {java.util.jar.JarEntry.class} - ) - public void test_ConstructorLjava_util_jar_JarEntry_on_null() throws IOException { - JarEntry newJarEntry = new JarEntry(jarFile.getJarEntry(entryName)); - assertNotNull(newJarEntry); - - jarEntry = null; - try { - newJarEntry = new JarEntry(jarEntry); - fail("Should throw NullPointerException"); - } catch (NullPointerException e) { - // Expected - } - } - - /** - * @tests java.util.jar.JarEntry#JarEntry(java.util.zip.ZipEntry) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "JarEntry", - args = {java.util.zip.ZipEntry.class} - ) - public void test_ConstructorLjava_util_zip_ZipEntry() { - assertNotNull("Jar file is null", jarFile); - zipEntry = jarFile.getEntry(entryName); - assertNotNull("Zip entry is null", zipEntry); - jarEntry = new JarEntry(zipEntry); - assertNotNull("Jar entry is null", jarEntry); - assertEquals("Wrong entry constructed--wrong name", entryName, jarEntry - .getName()); - assertEquals("Wrong entry constructed--wrong size", 311, jarEntry - .getSize()); - } - - /** - * @tests java.util.jar.JarEntry#getAttributes() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getAttributes", - args = {} - ) - public void test_getAttributes() { - JarFile attrJar = null; - File file = null; - try { - Support_Resources.copyFile(resources, null, attJarName); - file = new File(resources, attJarName); - attrJar = new JarFile(file); - } catch (Exception e) { - assertTrue(file + " does not exist", file.exists()); - fail("Exception opening file: " + e.toString()); - } - try { - jarEntry = attrJar.getJarEntry(attEntryName); - assertNotNull("Should have Manifest attributes", jarEntry - .getAttributes()); - } catch (Exception e) { - fail("Exception during 2nd test: " + e.toString()); - } - try { - jarEntry = attrJar.getJarEntry(attEntryName2); - assertNull("Shouldn't have any Manifest attributes", jarEntry - .getAttributes()); - attrJar.close(); - } catch (Exception e) { - fail("Exception during 1st test: " + e.toString()); - } - - Support_Resources.copyFile(resources, null, "Broken_manifest.jar"); - try { - attrJar = new JarFile(new File(resources, "Broken_manifest.jar")); - jarEntry = attrJar.getJarEntry("META-INF/"); - jarEntry.getAttributes(); - fail("IOException expected"); - } catch (IOException e) { - // expected. - } - } - - /** - * @tests java.util.jar.JarEntry#getCertificates() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getCertificates", - args = {} - ) - public void test_getCertificates() throws Exception { - zipEntry = jarFile.getEntry(entryName2); - jarEntry = new JarEntry(zipEntry); - assertNull("Shouldn't have any Certificates", jarEntry - .getCertificates()); - - // Regression Test for HARMONY-3424 - String jarFileName = "TestCodeSigners.jar"; - Support_Resources.copyFile(resources, null, jarFileName); - File file = new File(resources, jarFileName); - JarFile jarFile = new JarFile(file); - JarEntry jarEntry1 = jarFile.getJarEntry("Test.class"); - JarEntry jarEntry2 = jarFile.getJarEntry("Test.class"); - InputStream in = jarFile.getInputStream(jarEntry1); - byte[] buffer = new byte[1024]; - // BEGIN android-changed - // the certificates are non-null too early and in.available() fails - // while (in.available() > 0) { - // assertNull("getCertificates() should be null until the entry is read", - // jarEntry1.getCertificates()); - // assertNull(jarEntry2.getCertificates()); - // in.read(buffer); - // } - while (in.read(buffer) >= 0); - in.close(); - // END android-changed - assertEquals("the file is fully read", -1, in.read()); - assertNotNull(jarEntry1.getCertificates()); - assertNotNull(jarEntry2.getCertificates()); - in.close(); - } - - /** - * @tests java.util.jar.JarEntry#getCodeSigners() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getCodeSigners", - args = {} - ) - public void test_getCodeSigners() throws IOException { - String jarFileName = "TestCodeSigners.jar"; - Support_Resources.copyFile(resources, null, jarFileName); - File file = new File(resources, jarFileName); - JarFile jarFile = new JarFile(file); - JarEntry jarEntry = jarFile.getJarEntry("Test.class"); - InputStream in = jarFile.getInputStream(jarEntry); - byte[] buffer = new byte[1024]; - while (in.available() > 0) { - // BEGIN android-changed - // the code signers are non-null too early - // assertNull("getCodeSigners() should be null until the entry is read", - // jarEntry.getCodeSigners()); - // END android-changed - in.read(buffer); - } - assertEquals("the file is fully read", -1, in.read()); - CodeSigner[] codeSigners = jarEntry.getCodeSigners(); - assertEquals(2, codeSigners.length); - List certs_bob = codeSigners[0].getSignerCertPath() - .getCertificates(); - List certs_alice = codeSigners[1].getSignerCertPath() - .getCertificates(); - if (1 == certs_bob.size()) { - List temp = certs_bob; - certs_bob = certs_alice; - certs_alice = temp; - } - assertEquals(2, certs_bob.size()); - assertEquals(1, certs_alice.size()); - assertNull( - "getCodeSigners() of a primitive JarEntry should return null", - new JarEntry("aaa").getCodeSigners()); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "JarEntry", - args = {java.lang.String.class} - ) - public void test_ConstructorLjava_lang_String() { - assertNotNull("Jar file is null", jarFile); - zipEntry = jarFile.getEntry(entryName); - assertNotNull("Zip entry is null", zipEntry); - jarEntry = new JarEntry(entryName); - assertNotNull("Jar entry is null", jarEntry); - assertEquals("Wrong entry constructed--wrong name", entryName, jarEntry - .getName()); - try { - jarEntry = new JarEntry((String) null); - fail("NullPointerException expected"); - } catch (NullPointerException ee) { - // expected - } - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < 0x10000; i++) { - sb.append('3'); - } - try { - jarEntry = new JarEntry(new String(sb)); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException ee) { - // expected - } - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "JarEntry", - args = {java.util.jar.JarEntry.class} - ) - public void test_ConstructorLjava_util_jar_JarEntry() { - assertNotNull("Jar file is null", jarFile); - JarEntry je = jarFile.getJarEntry(entryName); - assertNotNull("Jar entry is null", je); - jarEntry = new JarEntry(je); - assertNotNull("Jar entry is null", jarEntry); - assertEquals("Wrong entry constructed--wrong name", entryName, jarEntry - .getName()); - assertEquals("Wrong entry constructed--wrong size", 311, jarEntry - .getSize()); - } -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java deleted file mode 100644 index 7f4834205..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.jar; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.jar.Manifest; -import junit.framework.TestCase; -import java.util.jar.JarException; - -@TestTargetClass(JarException.class) -public class JarExceptionTest extends TestCase { - /** - * @tests java.util.jar.JarException#JarException(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "JarException", - args = {} - ) - public void test_Constructor() throws Exception { - JarException ex = new JarException(); - JarException ex1 = new JarException("Test string"); - JarException ex2 = new JarException(null); - assertNotSame(ex, ex1); - assertNotSame(ex.getMessage(), ex1.getMessage()); - assertNotSame(ex, ex2); - assertSame(ex.getMessage(), ex2.getMessage()); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "JarException", - args = {java.lang.String.class} - ) - public void test_ConstructorLjava_lang_String() throws Exception { - JarException ex1 = new JarException("Test string"); - JarException ex2 = new JarException(null); - assertNotSame(ex1, ex2); - assertNotSame(ex1.getMessage(), ex2.getMessage()); - } -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExecTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExecTest.java deleted file mode 100644 index 4c209d17a..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExecTest.java +++ /dev/null @@ -1,317 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with this - * work for additional information regarding copyright ownership. The ASF - * licenses this file to You under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package org.apache.harmony.archive.tests.java.util.jar; - -import dalvik.annotation.KnownFailure; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; -import tests.support.Support_Exec; -import tests.support.resource.Support_Resources; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.jar.Attributes; -import java.util.jar.JarEntry; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; - -/** - * - * tests for various cases of java -jar ... execution - * - */ - -@TestTargetClass(JarOutputStream.class) -public class JarExecTest extends junit.framework.TestCase { - /** - * regression test for HARMONY-1562 issue - * - */ - @TestTargetNew( - level = TestLevel.ADDITIONAL, - notes = "Regression functional test. Exception checking missed.", - method = "putNextEntry", - args = {java.util.zip.ZipEntry.class} - ) - @KnownFailure("Maybe not a failure, but dalvikvm -jar is not supported (, as yet).") - public void test_1562() throws Exception { - // create the manifest - Manifest man = new Manifest(); - Attributes att = man.getMainAttributes(); - att.put(Attributes.Name.MANIFEST_VERSION, "1.0"); - att.put(Attributes.Name.MAIN_CLASS, "foo.bar.execjartest.Foo"); - - File outputJar = File.createTempFile("hyts_", ".jar"); - outputJar.deleteOnExit(); - JarOutputStream jout = new JarOutputStream(new FileOutputStream( - outputJar), man); - File resources = Support_Resources.createTempFolder(); - - for (String jarClass : new String[] {"Foo", "Bar"}) { - jout.putNextEntry(new JarEntry("foo/bar/execjartest/" + jarClass - + ".class")); - jout.write(getResource(resources, "hyts_" + jarClass + ".ser")); - } - - jout.close(); - - - // set up the VM parameters - String[] args = new String[] {"-jar", outputJar.getAbsolutePath()}; - - // execute the JAR and read the result - String res = Support_Exec.execJava(args, null, false); - - assertTrue("Error executing JAR : result returned was incorrect.", res - .startsWith("FOOBAR")); - } - - /** - * tests Class-Path entry in manifest - * - * @throws Exception in case of troubles - */ - @TestTargetNew( - level = TestLevel.ADDITIONAL, - notes = "Functional test.", - method = "JarOutputStream", - args = {java.io.OutputStream.class, java.util.jar.Manifest.class} - ) - @KnownFailure("Maybe not a failure, but dalvikvm -jar is not supported (, as yet).") - public void test_jar_class_path() throws Exception { - File fooJar = File.createTempFile("hyts_", ".jar"); - File barJar = File.createTempFile("hyts_", ".jar"); - fooJar.deleteOnExit(); - barJar.deleteOnExit(); - - // create the manifest - Manifest man = new Manifest(); - Attributes att = man.getMainAttributes(); - att.put(Attributes.Name.MANIFEST_VERSION, "1.0"); - att.put(Attributes.Name.MAIN_CLASS, "foo.bar.execjartest.Foo"); - att.put(Attributes.Name.CLASS_PATH, barJar.getName()); - - File resources = Support_Resources.createTempFolder(); - - JarOutputStream joutFoo = new JarOutputStream(new FileOutputStream( - fooJar), man); - joutFoo.putNextEntry(new JarEntry("foo/bar/execjartest/Foo.class")); - joutFoo.write(getResource(resources, "hyts_Foo.ser")); - joutFoo.close(); - - JarOutputStream joutBar = new JarOutputStream(new FileOutputStream( - barJar)); - joutBar.putNextEntry(new JarEntry("foo/bar/execjartest/Bar.class")); - joutBar.write(getResource(resources, "hyts_Bar.ser")); - joutBar.close(); - - String[] args = new String[] {"-jar", fooJar.getAbsolutePath()}; - - // execute the JAR and read the result - String res = Support_Exec.execJava(args, null, false); - - assertTrue("Error executing JAR : result returned was incorrect.", res - .startsWith("FOOBAR")); - - // rewrite manifest so it contains not only reference to bar but useless - // entries as well - att.put(Attributes.Name.CLASS_PATH, "xx yy zz " + barJar.getName()); - joutFoo = new JarOutputStream(new FileOutputStream(fooJar), man); - joutFoo.putNextEntry(new JarEntry("foo/bar/execjartest/Foo.class")); - joutFoo.write(getResource(resources, "hyts_Foo.ser")); - joutFoo.close(); - // execute the JAR and read the result - res = Support_Exec.execJava(args, null, false); - assertTrue("Error executing JAR : result returned was incorrect.", res - .startsWith("FOOBAR")); - - - // play with relative file names - put relative path as ..//xx.jar - att.put(Attributes.Name.CLASS_PATH, ".." + File.separator - + barJar.getParentFile().getName() + File.separator - + barJar.getName()); - joutFoo = new JarOutputStream(new FileOutputStream(fooJar), man); - joutFoo.putNextEntry(new JarEntry("foo/bar/execjartest/Foo.class")); - joutFoo.write(getResource(resources, "hyts_Foo.ser")); - joutFoo.close(); - // execute the JAR and read the result - res = Support_Exec.execJava(args, null, false); - assertTrue("Error executing JAR : result returned was incorrect.", res - .startsWith("FOOBAR")); - } - - /** - * tests case when Main-Class is not in the jar launched but in another jar - * referenced by Class-Path - * - * @throws Exception in case of troubles - */ - @TestTargetNew( - level = TestLevel.ADDITIONAL, - notes = "Functional test.", - method = "JarOutputStream", - args = {java.io.OutputStream.class, java.util.jar.Manifest.class} - ) - @KnownFailure("Maybe not a failure, but dalvikvm -jar is not supported (, as yet).") - public void test_main_class_in_another_jar() throws Exception { - File fooJar = File.createTempFile("hyts_", ".jar"); - File barJar = File.createTempFile("hyts_", ".jar"); - fooJar.deleteOnExit(); - barJar.deleteOnExit(); - - // create the manifest - Manifest man = new Manifest(); - Attributes att = man.getMainAttributes(); - att.put(Attributes.Name.MANIFEST_VERSION, "1.0"); - att.put(Attributes.Name.MAIN_CLASS, "foo.bar.execjartest.Foo"); - att.put(Attributes.Name.CLASS_PATH, fooJar.getName()); - - File resources = Support_Resources.createTempFolder(); - - JarOutputStream joutFoo = new JarOutputStream(new FileOutputStream( - fooJar)); - joutFoo.putNextEntry(new JarEntry("foo/bar/execjartest/Foo.class")); - joutFoo.write(getResource(resources, "hyts_Foo.ser")); - joutFoo.close(); - - JarOutputStream joutBar = new JarOutputStream(new FileOutputStream( - barJar), man); - joutBar.putNextEntry(new JarEntry("foo/bar/execjartest/Bar.class")); - joutBar.write(getResource(resources, "hyts_Bar.ser")); - joutBar.close(); - - String[] args = new String[] {"-jar", barJar.getAbsolutePath()}; - - // execute the JAR and read the result - String res = Support_Exec.execJava(args, null, false); - - assertTrue("Error executing JAR : result returned was incorrect.", res - .startsWith("FOOBAR")); - } - - @TestTargetNew( - level = TestLevel.ADDITIONAL, - notes = "Functional test.", - method = "JarOutputStream", - args = {java.io.OutputStream.class, java.util.jar.Manifest.class} - ) - @KnownFailure("Maybe not a failure, but dalvikvm -jar is not supported (, as yet).") - public void test_classpath() throws Exception { - File resources = Support_Resources.createTempFolder(); - - File fooJar = File.createTempFile("hyts_", ".jar"); - fooJar.deleteOnExit(); - - JarOutputStream joutFoo = new JarOutputStream(new FileOutputStream( - fooJar)); - joutFoo.putNextEntry(new JarEntry("foo/bar/execjartest/Foo.class")); - joutFoo.write(getResource(resources, "hyts_Foo.ser")); - joutFoo.putNextEntry(new JarEntry("foo/bar/execjartest/Bar.class")); - joutFoo.write(getResource(resources, "hyts_Bar.ser")); - joutFoo.close(); - - String[] args = new String[] {"foo.bar.execjartest.Foo"}; - - // execute the JAR and read the result - String res = Support_Exec.execJava(args, null, - new String[] {"CLASSPATH=" + fooJar.getAbsolutePath()}, false); - - assertTrue( - "Error executing class from ClassPath : result returned was incorrect.", - res.startsWith("FOOBAR")); - - // ok - next try - add -cp to path - it should override env - File booJar = File.createTempFile("hyts_", ".jar"); - booJar.deleteOnExit(); - - JarOutputStream joutBoo = new JarOutputStream(new FileOutputStream( - booJar)); - joutBoo.putNextEntry(new JarEntry("foo/bar/execjartest/Foo.class")); - String booBody = new String(getResource(resources, "hyts_Foo.ser"), - "iso-8859-1"); - booBody = booBody.replaceFirst("FOO", "BOO"); - joutBoo.write(booBody.getBytes("iso-8859-1")); - joutBoo.putNextEntry(new JarEntry("foo/bar/execjartest/Bar.class")); - String farBody = new String(getResource(resources, "hyts_Bar.ser"), - "iso-8859-1"); - farBody = farBody.replaceFirst("BAR", "FAR"); - joutBoo.write(farBody.getBytes("iso-8859-1")); - joutBoo.close(); - - res = Support_Exec.execJava(args, new String[] {booJar - .getAbsolutePath()}, new String[] {"CLASSPATH=" - + fooJar.getAbsolutePath()}, false); - - assertTrue( - "Error executing class specified by -cp : result returned was incorrect.", - res.startsWith("BOOFAR")); - - // now add -jar option - it should override env and classpath - Manifest man = new Manifest(); - Attributes att = man.getMainAttributes(); - att.put(Attributes.Name.MANIFEST_VERSION, "1.0"); - att.put(Attributes.Name.MAIN_CLASS, "foo.bar.execjartest.Foo"); - - File zooJar = File.createTempFile("hyts_", ".jar"); - zooJar.deleteOnExit(); - - JarOutputStream joutZoo = new JarOutputStream(new FileOutputStream( - zooJar), man); - joutZoo.putNextEntry(new JarEntry("foo/bar/execjartest/Foo.class")); - String zooBody = new String(getResource(resources, "hyts_Foo.ser"), - "iso-8859-1"); - zooBody = zooBody.replaceFirst("FOO", "ZOO"); - joutZoo.write(zooBody.getBytes("iso-8859-1")); - joutZoo.putNextEntry(new JarEntry("foo/bar/execjartest/Bar.class")); - String zarBody = new String(getResource(resources, "hyts_Bar.ser"), - "iso-8859-1"); - zarBody = zarBody.replaceFirst("BAR", "ZAR"); - joutZoo.write(zarBody.getBytes("iso-8859-1")); - joutZoo.close(); - - args = new String[] {"-jar", zooJar.getAbsolutePath()}; - - res = Support_Exec.execJava(args, new String[] {booJar - .getAbsolutePath()}, new String[] {"CLASSPATH=" - + fooJar.getAbsolutePath()}, false); - - assertTrue( - "Error executing class specified by -cp : result returned was incorrect.", - res.startsWith("ZOOZAR")); - } - - private static byte[] getResource(File tempDir, String resourceName) - throws IOException { - Support_Resources.copyFile(tempDir, null, resourceName); - File resourceFile = new File(tempDir, resourceName); - resourceFile.deleteOnExit(); - - // read whole resource data into memory - byte[] resourceBody = new byte[(int) resourceFile.length()]; - FileInputStream fis = new FileInputStream(resourceFile); - fis.read(resourceBody); - fis.close(); - - return resourceBody; - } - -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java deleted file mode 100644 index d2a51109f..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java +++ /dev/null @@ -1,1102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.archive.tests.java.util.jar; - - -import dalvik.annotation.AndroidOnly; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; - -import junit.framework.TestCase; - -import tests.support.Support_PlatformFile; -import tests.support.resource.Support_Resources; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.security.Permission; -import java.security.cert.Certificate; -import java.util.Enumeration; -import java.util.Vector; -import java.util.jar.Attributes; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; -import java.util.zip.ZipEntry; -import java.util.zip.ZipException; -import java.util.zip.ZipFile; - - -@TestTargetClass(JarFile.class) -public class JarFileTest extends TestCase { - - // BEGIN android-added - public byte[] getAllBytesFromStream(InputStream is) throws IOException { - ByteArrayOutputStream bs = new ByteArrayOutputStream(); - byte[] buf = new byte[666]; - int iRead; - int off; - while (is.available() > 0) { - iRead = is.read(buf, 0, buf.length); - if (iRead > 0) bs.write(buf, 0, iRead); - } - return bs.toByteArray(); - } - - // END android-added - - private final String jarName = "hyts_patch.jar"; // a 'normal' jar file - - private final String jarName2 = "hyts_patch2.jar"; - - private final String jarName3 = "hyts_manifest1.jar"; - - private final String jarName4 = "hyts_signed.jar"; - - private final String jarName5 = "hyts_signed_inc.jar"; - - private final String entryName = "foo/bar/A.class"; - - private final String entryName3 = "coucou/FileAccess.class"; - - private final String integrateJar = "Integrate.jar"; - - private final String integrateJarEntry = "Test.class"; - - private final String emptyEntryJar = "EmptyEntries_signed.jar"; - - private final String emptyEntry1 = "subfolder/internalSubset01.js"; - - private final String emptyEntry2 = "svgtest.js"; - - private final String emptyEntry3 = "svgunit.js"; - - private File resources; - - // custom security manager - SecurityManager sm = new SecurityManager() { - final String forbidenPermissionName = "user.dir"; - - public void checkPermission(Permission perm) { - if (perm.getName().equals(forbidenPermissionName)) { - throw new SecurityException(); - } - } - }; - - @Override - protected void setUp() { - resources = Support_Resources.createTempFolder(); - } - - /** - * @tests java.util.jar.JarFile#JarFile(java.io.File) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "JarFile", - args = {java.io.File.class} - ) - public void test_ConstructorLjava_io_File() { - try { - JarFile jarFile = new JarFile(new File("Wrong.file")); - fail("Should throw IOException"); - } catch (IOException e) { - // expected - } - SecurityManager oldSm = System.getSecurityManager(); - System.setSecurityManager(sm); - try { - JarFile jarFile = new JarFile(new File("tmp.jar")); - fail("Should throw SecurityException"); - } catch (IOException e) { - fail("Should throw SecurityException"); - } catch (SecurityException e) { - // expected - } finally { - System.setSecurityManager(oldSm); - } - - try { - Support_Resources.copyFile(resources, null, jarName); - JarFile jarFile = new JarFile(new File(resources, jarName)); - } catch (IOException e) { - fail("Should not throw IOException"); - } - } - - /** - * @tests java.util.jar.JarFile#JarFile(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "JarFile", - args = {java.lang.String.class} - ) - public void test_ConstructorLjava_lang_String() { - try { - JarFile jarFile = new JarFile("Wrong.file"); - fail("Should throw IOException"); - } catch (IOException e) { - // expected - } - SecurityManager oldSm = System.getSecurityManager(); - System.setSecurityManager(sm); - try { - JarFile jarFile = new JarFile("tmp.jar"); - fail("Should throw SecurityException"); - } catch (IOException e) { - fail("Should throw SecurityException"); - } catch (SecurityException e) { - // expected - } finally { - System.setSecurityManager(oldSm); - } - - try { - Support_Resources.copyFile(resources, null, jarName); - String fileName = (new File(resources, jarName)).getCanonicalPath(); - JarFile jarFile = new JarFile(fileName); - } catch (IOException e) { - fail("Should not throw IOException"); - } - } - - /** - * @tests java.util.jar.JarFile#JarFile(java.lang.String, boolean) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "JarFile", - args = {java.lang.String.class, boolean.class} - ) - public void test_ConstructorLjava_lang_StringZ() { - try { - JarFile jarFile = new JarFile("Wrong.file", false); - fail("Should throw IOException"); - } catch (IOException e) { - // expected - } - SecurityManager oldSm = System.getSecurityManager(); - System.setSecurityManager(sm); - try { - JarFile jarFile = new JarFile("tmp.jar", true); - fail("Should throw SecurityException"); - } catch (IOException e) { - fail("Should throw SecurityException"); - } catch (SecurityException e) { - // expected - } finally { - System.setSecurityManager(oldSm); - } - - try { - Support_Resources.copyFile(resources, null, jarName); - String fileName = (new File(resources, jarName)).getCanonicalPath(); - JarFile jarFile = new JarFile(fileName, true); - } catch (IOException e) { - fail("Should not throw IOException"); - } - } - - /** - * @tests java.util.jar.JarFile#JarFile(java.io.File, boolean) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "JarFile", - args = {java.io.File.class, boolean.class} - ) - public void test_ConstructorLjava_io_FileZ() { - try { - JarFile jarFile = new JarFile(new File("Wrong.file"), true); - fail("Should throw IOException"); - } catch (IOException e) { - // expected - } - SecurityManager oldSm = System.getSecurityManager(); - System.setSecurityManager(sm); - try { - JarFile jarFile = new JarFile(new File("tmp.jar"), false); - fail("Should throw SecurityException"); - } catch (IOException e) { - fail("Should throw SecurityException"); - } catch (SecurityException e) { - // expected - } finally { - System.setSecurityManager(oldSm); - } - - try { - Support_Resources.copyFile(resources, null, jarName); - JarFile jarFile = new JarFile(new File(resources, jarName), false); - } catch (IOException e) { - fail("Should not throw IOException"); - } - } - - /** - * @tests java.util.jar.JarFile#JarFile(java.io.File, boolean, int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "JarFile", - args = {java.io.File.class, boolean.class, int.class} - ) - public void test_ConstructorLjava_io_FileZI() { - try { - JarFile jarFile = new JarFile(new File("Wrong.file"), true, - ZipFile.OPEN_READ); - fail("Should throw IOException"); - } catch (IOException e) { - // expected - } - SecurityManager oldSm = System.getSecurityManager(); - System.setSecurityManager(sm); - try { - JarFile jarFile = new JarFile(new File("tmp.jar"), false, - ZipFile.OPEN_READ); - fail("Should throw SecurityException"); - } catch (IOException e) { - fail("Should throw SecurityException"); - } catch (SecurityException e) { - // expected - } finally { - System.setSecurityManager(oldSm); - } - - try { - Support_Resources.copyFile(resources, null, jarName); - JarFile jarFile = new JarFile(new File(resources, jarName), false, - ZipFile.OPEN_READ); - } catch (IOException e) { - fail("Should not throw IOException"); - } - - try { - Support_Resources.copyFile(resources, null, jarName); - JarFile jarFile = new JarFile(new File(resources, jarName), false, - ZipFile.OPEN_READ | ZipFile.OPEN_DELETE + 33); - fail("Should throw IllegalArgumentException"); - } catch (IOException e) { - fail("Should not throw IOException"); - } catch (IllegalArgumentException e) { - // expected - } - } - - /** - * Constructs JarFile object. - * - * @tests java.util.jar.JarFile#JarFile(java.io.File) - * @tests java.util.jar.JarFile#JarFile(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "JarFile", - args = {java.io.File.class} - ) - public void testConstructor_file() throws IOException { - File f = new File(resources, jarName); - Support_Resources.copyFile(resources, null, jarName); - assertTrue(new JarFile(f).getEntry(entryName).getName().equals( - entryName)); - assertTrue(new JarFile(f.getPath()).getEntry(entryName).getName() - .equals(entryName)); - } - - /** - * @tests java.util.jar.JarFile#entries() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "entries", - args = {} - ) - public void test_entries() throws Exception { - /* - * Note only (and all of) the following should be contained in the file - * META-INF/ META-INF/MANIFEST.MF foo/ foo/bar/ foo/bar/A.class Blah.txt - */ - Support_Resources.copyFile(resources, null, jarName); - JarFile jarFile = new JarFile(new File(resources, jarName)); - Enumeration e = jarFile.entries(); - int i; - for (i = 0; e.hasMoreElements(); i++) { - e.nextElement(); - } - assertEquals(jarFile.size(), i); - jarFile.close(); - assertEquals(6, i); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "entries", - args = {} - ) - public void test_entries2() throws Exception { - Support_Resources.copyFile(resources, null, jarName); - JarFile jarFile = new JarFile(new File(resources, jarName)); - Enumeration enumeration = jarFile.entries(); - jarFile.close(); - try { - enumeration.hasMoreElements(); - fail("hasMoreElements() did not detect a closed jar file"); - } catch (IllegalStateException e) { - } - Support_Resources.copyFile(resources, null, jarName); - jarFile = new JarFile(new File(resources, jarName)); - enumeration = jarFile.entries(); - jarFile.close(); - try { - enumeration.nextElement(); - fail("nextElement() did not detect closed jar file"); - } catch (IllegalStateException e) { - } - } - - /** - * @throws IOException - * @tests java.util.jar.JarFile#getJarEntry(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getEntry", - args = {java.lang.String.class} - ) - public void test_getEntryLjava_lang_String() throws IOException { - try { - Support_Resources.copyFile(resources, null, jarName); - JarFile jarFile = new JarFile(new File(resources, jarName)); - assertEquals("Error in returned entry", 311, jarFile.getEntry( - entryName).getSize()); - jarFile.close(); - } catch (Exception e) { - fail("Exception during test: " + e.toString()); - } - - Support_Resources.copyFile(resources, null, jarName); - JarFile jarFile = new JarFile(new File(resources, jarName)); - Enumeration enumeration = jarFile.entries(); - assertTrue(enumeration.hasMoreElements()); - while (enumeration.hasMoreElements()) { - JarEntry je = enumeration.nextElement(); - jarFile.getEntry(je.getName()); - } - - enumeration = jarFile.entries(); - assertTrue(enumeration.hasMoreElements()); - JarEntry je = enumeration.nextElement(); - try { - jarFile.close(); - jarFile.getEntry(je.getName()); - // fail("IllegalStateException expected."); - } catch (IllegalStateException ee) { // Per documentation exception - // may be thrown. - // expected - } - } - - /** - * @throws IOException - * @tests java.util.jar.JarFile#getJarEntry(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getJarEntry", - args = {java.lang.String.class} - ) - public void test_getJarEntryLjava_lang_String() throws IOException { - try { - Support_Resources.copyFile(resources, null, jarName); - JarFile jarFile = new JarFile(new File(resources, jarName)); - assertEquals("Error in returned entry", 311, jarFile.getJarEntry( - entryName).getSize()); - jarFile.close(); - } catch (Exception e) { - fail("Exception during test: " + e.toString()); - } - - Support_Resources.copyFile(resources, null, jarName); - JarFile jarFile = new JarFile(new File(resources, jarName)); - Enumeration enumeration = jarFile.entries(); - assertTrue(enumeration.hasMoreElements()); - while (enumeration.hasMoreElements()) { - JarEntry je = enumeration.nextElement(); - jarFile.getJarEntry(je.getName()); - } - - enumeration = jarFile.entries(); - assertTrue(enumeration.hasMoreElements()); - JarEntry je = enumeration.nextElement(); - try { - jarFile.close(); - jarFile.getJarEntry(je.getName()); - // fail("IllegalStateException expected."); - } catch (IllegalStateException ee) { // Per documentation exception - // may be thrown. - // expected - } - } - - - /** - * @tests java.util.jar.JarFile#getJarEntry(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getEntry", - args = {java.lang.String.class} - ) - public void testGetJarEntry() throws Exception { - Support_Resources.copyFile(resources, null, jarName); - JarFile jarFile = new JarFile(new File(resources, jarName)); - assertEquals("Error in returned entry", 311, jarFile.getEntry( - entryName).getSize()); - jarFile.close(); - - // tests for signed jars - // test all signed jars in the /Testres/Internal/SignedJars directory - String jarDirUrl = Support_Resources - .getResourceURL("/../internalres/signedjars"); - Vector signedJars = new Vector(); - try { - InputStream is = new URL(jarDirUrl + "/jarlist.txt").openStream(); - while (is.available() > 0) { - StringBuilder linebuff = new StringBuilder(80); // Typical line - // length - done: while (true) { - int nextByte = is.read(); - switch (nextByte) { - case -1: - break done; - case (byte) '\r': - if (linebuff.length() == 0) { - // ignore - } - break done; - case (byte) '\n': - if (linebuff.length() == 0) { - // ignore - } - break done; - default: - linebuff.append((char) nextByte); - } - } - if (linebuff.length() == 0) { - break; - } - String line = linebuff.toString(); - signedJars.add(line); - } - is.close(); - } catch (IOException e) { - // no list of jars found - } - - for (int i = 0; i < signedJars.size(); i++) { - String jarName = signedJars.get(i); - try { - File file = Support_Resources.getExternalLocalFile(jarDirUrl - + "/" + jarName); - jarFile = new JarFile(file, true); - boolean foundCerts = false; - Enumeration e = jarFile.entries(); - while (e.hasMoreElements()) { - JarEntry entry = e.nextElement(); - InputStream is = jarFile.getInputStream(entry); - is.skip(100000); - is.close(); - Certificate[] certs = entry.getCertificates(); - if (certs != null && certs.length > 0) { - foundCerts = true; - break; - } - } - assertTrue( - "No certificates found during signed jar test for jar \"" - + jarName + "\"", foundCerts); - } catch (IOException e) { - fail("Exception during signed jar test for jar \"" + jarName - + "\": " + e.toString()); - } - } - } - - /** - * @tests java.util.jar.JarFile#getManifest() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getManifest", - args = {} - ) - public void test_getManifest() { - // Test for method java.util.jar.Manifest - // java.util.jar.JarFile.getManifest() - try { - Support_Resources.copyFile(resources, null, jarName); - JarFile jarFile = new JarFile(new File(resources, jarName)); - assertNotNull("Error--Manifest not returned", jarFile.getManifest()); - jarFile.close(); - } catch (Exception e) { - fail("Exception during 1st test: " + e.toString()); - } - try { - Support_Resources.copyFile(resources, null, jarName2); - JarFile jarFile = new JarFile(new File(resources, jarName2)); - assertNull("Error--should have returned null", jarFile - .getManifest()); - jarFile.close(); - } catch (Exception e) { - fail("Exception during 2nd test: " + e.toString()); - } - - try { - // jarName3 was created using the following test - Support_Resources.copyFile(resources, null, jarName3); - JarFile jarFile = new JarFile(new File(resources, jarName3)); - assertNotNull("Should find manifest without verifying", jarFile - .getManifest()); - jarFile.close(); - } catch (Exception e) { - fail("Exception during 3rd test: " + e.toString()); - } - - try { - // this is used to create jarName3 used in the previous test - Manifest manifest = new Manifest(); - Attributes attributes = manifest.getMainAttributes(); - attributes.put(new Attributes.Name("Manifest-Version"), "1.0"); - ByteArrayOutputStream manOut = new ByteArrayOutputStream(); - manifest.write(manOut); - byte[] manBytes = manOut.toByteArray(); - File file = File.createTempFile( - Support_PlatformFile.getNewPlatformFile("hyts_manifest1", - ""), ".jar"); - JarOutputStream jarOut = new JarOutputStream(new FileOutputStream( - file.getAbsolutePath())); - ZipEntry entry = new ZipEntry("META-INF/"); - entry.setSize(0); - jarOut.putNextEntry(entry); - entry = new ZipEntry(JarFile.MANIFEST_NAME); - entry.setSize(manBytes.length); - jarOut.putNextEntry(entry); - jarOut.write(manBytes); - entry = new ZipEntry("myfile"); - entry.setSize(1); - jarOut.putNextEntry(entry); - jarOut.write(65); - jarOut.close(); - JarFile jar = new JarFile(file.getAbsolutePath(), false); - assertNotNull("Should find manifest without verifying", jar - .getManifest()); - jar.close(); - file.delete(); - } catch (IOException e) { - fail("IOException 3"); - } - try { - Support_Resources.copyFile(resources, null, jarName2); - JarFile jF = new JarFile(new File(resources, jarName2)); - jF.close(); - jF.getManifest(); - fail("FAILED: expected IllegalStateException"); - } catch (IllegalStateException ise) { - // expected; - } catch (Exception e) { - fail("Exception during 4th test: " + e.toString()); - } - - Support_Resources.copyFile(resources, null, "Broken_manifest.jar"); - JarFile jf; - try { - jf = new JarFile(new File(resources, "Broken_manifest.jar")); - jf.getManifest(); - fail("IOException expected."); - } catch (IOException e) { - // expected. - } - } - - /** - * @tests java.util.jar.JarFile#getInputStream(java.util.zip.ZipEntry) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "SecurityException and functionality checked.", - method = "getInputStream", - args = {java.util.zip.ZipEntry.class} - ) - @AndroidOnly("This test doesn't pass on RI. If entry size is set up " + - "incorrectly, SecurityException is thrown. " + - "But SecurityException is thrown on RI only " + - "if jar file is signed incorreclty.") - public void test_getInputStreamLjava_util_jar_JarEntry_subtest0() { - File signedFile = null; - try { - Support_Resources.copyFile(resources, null, jarName4); - signedFile = new File(resources, jarName4); - } catch (Exception e) { - fail("Failed to create local file 2: " + e); - } - - try { - JarFile jar = new JarFile(signedFile); - JarEntry entry = new JarEntry(entryName3); - InputStream in = jar.getInputStream(entry); - in.read(); - } catch (Exception e) { - fail("Exception during test 3: " + e); - } - - try { - JarFile jar = new JarFile(signedFile); - JarEntry entry = new JarEntry(entryName3); - InputStream in = jar.getInputStream(entry); - // BEGIN android-added - byte[] dummy = getAllBytesFromStream(in); - // END android-added - assertNull("found certificates", entry.getCertificates()); - } catch (Exception e) { - fail("Exception during test 4: " + e); - } - - try { - JarFile jar = new JarFile(signedFile); - JarEntry entry = new JarEntry(entryName3); - entry.setSize(1076); - InputStream in = jar.getInputStream(entry); - // BEGIN android-added - byte[] dummy = getAllBytesFromStream(in); - // END android-added - fail("SecurityException should be thrown."); - } catch (SecurityException e) { - // expected - } catch (Exception e) { - fail("Exception during test 5: " + e); - } - - try { - Support_Resources.copyFile(resources, null, jarName5); - signedFile = new File(resources, jarName5); - } catch (Exception e) { - fail("Failed to create local file 5: " + e); - } - - try { - JarFile jar = new JarFile(signedFile); - JarEntry entry = new JarEntry(entryName3); - InputStream in = jar.getInputStream(entry); - fail("SecurityException should be thrown."); - } catch (SecurityException e) { - // expected - } catch (Exception e) { - fail("Exception during test 5: " + e); - } - } - - /* - * The jar created by 1.4 which does not provide a - * algorithm-Digest-Manifest-Main-Attributes entry in .SF file. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "entries", - args = {} - ) - public void test_Jar_created_before_java_5() throws IOException { - String modifiedJarName = "Created_by_1_4.jar"; - Support_Resources.copyFile(resources, null, modifiedJarName); - JarFile jarFile = new JarFile(new File(resources, modifiedJarName), - true); - Enumeration entries = jarFile.entries(); - while (entries.hasMoreElements()) { - ZipEntry zipEntry = entries.nextElement(); - jarFile.getInputStream(zipEntry); - } - } - - /* The jar is intact, then everything is all right. */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "entries", - args = {} - ) - public void test_JarFile_Integrate_Jar() throws IOException { - String modifiedJarName = "Integrate.jar"; - Support_Resources.copyFile(resources, null, modifiedJarName); - JarFile jarFile = new JarFile(new File(resources, modifiedJarName), - true); - Enumeration entries = jarFile.entries(); - while (entries.hasMoreElements()) { - ZipEntry zipEntry = entries.nextElement(); - jarFile.getInputStream(zipEntry).skip(Long.MAX_VALUE); - } - } - - /** - * The jar is intact, but the entry object is modified. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getInputStream", - args = {ZipEntry.class} - ) - public void testJarVerificationModifiedEntry() throws IOException { - Support_Resources.copyFile(resources, null, integrateJar); - File f = new File(resources, integrateJar); - - JarFile jarFile = new JarFile(f); - ZipEntry zipEntry = jarFile.getJarEntry(integrateJarEntry); - zipEntry.setSize(zipEntry.getSize() + 1); - jarFile.getInputStream(zipEntry).skip(Long.MAX_VALUE); - - jarFile = new JarFile(f); - zipEntry = jarFile.getJarEntry(integrateJarEntry); - zipEntry.setSize(zipEntry.getSize() - 1); - try { - //jarFile.getInputStream(zipEntry).skip(Long.MAX_VALUE); - jarFile.getInputStream(zipEntry).read(new byte[5000], 0, 5000); - fail("SecurityException expected"); - } catch (SecurityException e) { - // desired - } - } - - /* - * If another entry is inserted into Manifest, no security exception will be - * thrown out. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "entries", - args = {} - ) - public void test_JarFile_InsertEntry_in_Manifest_Jar() throws IOException { - String modifiedJarName = "Inserted_Entry_Manifest.jar"; - Support_Resources.copyFile(resources, null, modifiedJarName); - JarFile jarFile = new JarFile(new File(resources, modifiedJarName), - true); - Enumeration entries = jarFile.entries(); - int count = 0; - while (entries.hasMoreElements()) { - - ZipEntry zipEntry = entries.nextElement(); - jarFile.getInputStream(zipEntry); - count++; - } - assertEquals(5, count); - } - - /* - * If another entry is inserted into Manifest, no security exception will be - * thrown out. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "entries", - args = {} - ) - public void test_Inserted_Entry_Manifest_with_DigestCode() - throws IOException { - String modifiedJarName = "Inserted_Entry_Manifest_with_DigestCode.jar"; - Support_Resources.copyFile(resources, null, modifiedJarName); - JarFile jarFile = new JarFile(new File(resources, modifiedJarName), - true); - Enumeration entries = jarFile.entries(); - int count = 0; - while (entries.hasMoreElements()) { - ZipEntry zipEntry = entries.nextElement(); - jarFile.getInputStream(zipEntry); - count++; - } - assertEquals(5, count); - } - - /* - * The content of Test.class is modified, jarFile.getInputStream will not - * throw security Exception, but it will anytime before the inputStream got - * from getInputStream method has been read to end. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "SecurityException and functionality checked.", - method = "getInputStream", - args = {java.util.zip.ZipEntry.class} - ) - public void test_JarFile_Modified_Class() throws IOException { - String modifiedJarName = "Modified_Class.jar"; - Support_Resources.copyFile(resources, null, modifiedJarName); - JarFile jarFile = new JarFile(new File(resources, modifiedJarName), - true); - Enumeration entries = jarFile.entries(); - while (entries.hasMoreElements()) { - ZipEntry zipEntry = entries.nextElement(); - jarFile.getInputStream(zipEntry); - } - /* The content of Test.class has been tampered. */ - ZipEntry zipEntry = jarFile.getEntry("Test.class"); - InputStream in = jarFile.getInputStream(zipEntry); - byte[] buffer = new byte[1024]; - try { - while (in.available() > 0) { - in.read(buffer); - } - fail("SecurityException expected"); - } catch (SecurityException e) { - // desired - } - } - - /* - * In the Modified.jar, the main attributes of META-INF/MANIFEST.MF is - * tampered manually. Hence the RI 5.0 JarFile.getInputStream of any - * JarEntry will throw security exception. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "SecurityException and functionality checked.", - method = "getInputStream", - args = {java.util.zip.ZipEntry.class} - ) - public void test_JarFile_Modified_Manifest_MainAttributes() - throws IOException { - String modifiedJarName = "Modified_Manifest_MainAttributes.jar"; - Support_Resources.copyFile(resources, null, modifiedJarName); - JarFile jarFile = new JarFile(new File(resources, modifiedJarName), - true); - Enumeration entries = jarFile.entries(); - while (entries.hasMoreElements()) { - ZipEntry zipEntry = entries.nextElement(); - try { - jarFile.getInputStream(zipEntry); - fail("SecurityException expected"); - } catch (SecurityException e) { - // desired - } - } - } - - /* - * It is all right in our original JarFile. If the Entry Attributes, for - * example Test.class in our jar, the jarFile.getInputStream will throw - * Security Exception. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "SecurityException and functionality checked.", - method = "getInputStream", - args = {java.util.zip.ZipEntry.class} - ) - public void test_JarFile_Modified_Manifest_EntryAttributes() - throws IOException { - String modifiedJarName = "Modified_Manifest_EntryAttributes.jar"; - Support_Resources.copyFile(resources, null, modifiedJarName); - JarFile jarFile = new JarFile(new File(resources, modifiedJarName), - true); - Enumeration entries = jarFile.entries(); - while (entries.hasMoreElements()) { - ZipEntry zipEntry = entries.nextElement(); - try { - jarFile.getInputStream(zipEntry); - fail("should throw Security Exception"); - } catch (SecurityException e) { - // desired - } - } - } - - /* - * If the content of the .SA file is modified, no matter what it resides, - * JarFile.getInputStream of any JarEntry will throw Security Exception. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "SecurityException and functionality checked.", - method = "getInputStream", - args = {java.util.zip.ZipEntry.class} - ) - public void test_JarFile_Modified_SF_EntryAttributes() throws IOException { - String modifiedJarName = "Modified_SF_EntryAttributes.jar"; - Support_Resources.copyFile(resources, null, modifiedJarName); - JarFile jarFile = new JarFile(new File(resources, modifiedJarName), - true); - Enumeration entries = jarFile.entries(); - while (entries.hasMoreElements()) { - ZipEntry zipEntry = entries.nextElement(); - try { - jarFile.getInputStream(zipEntry); - fail("should throw Security Exception"); - } catch (SecurityException e) { - // desired - } - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "close", - args = {} - ) - public void test_close() throws IOException { - String modifiedJarName = "Modified_SF_EntryAttributes.jar"; - Support_Resources.copyFile(resources, null, modifiedJarName); - JarFile jarFile = new JarFile(new File(resources, modifiedJarName), - true); - Enumeration entries = jarFile.entries(); - - jarFile.close(); - jarFile.close(); - - // Can not check IOException - } - - /** - * @throws IOException - * @tests java.util.jar.JarFile#getInputStream(java.util.zip.ZipEntry) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getInputStream", - args = {java.util.zip.ZipEntry.class} - ) - public void test_getInputStreamLjava_util_jar_JarEntry() throws IOException { - File localFile = null; - try { - Support_Resources.copyFile(resources, null, jarName); - localFile = new File(resources, jarName); - } catch (Exception e) { - fail("Failed to create local file: " + e); - } - - byte[] b = new byte[1024]; - try { - JarFile jf = new JarFile(localFile); - java.io.InputStream is = jf.getInputStream(jf.getEntry(entryName)); - // BEGIN android-removed - // jf.close(); - // END android-removed - assertTrue("Returned invalid stream", is.available() > 0); - int r = is.read(b, 0, 1024); - is.close(); - StringBuffer sb = new StringBuffer(r); - for (int i = 0; i < r; i++) { - sb.append((char) (b[i] & 0xff)); - } - String contents = sb.toString(); - assertTrue("Incorrect stream read", contents.indexOf("bar") > 0); - // BEGIN android-added - jf.close(); - // END android-added - } catch (Exception e) { - fail("Exception during test: " + e.toString()); - } - - try { - JarFile jf = new JarFile(localFile); - InputStream in = jf.getInputStream(new JarEntry("invalid")); - assertNull("Got stream for non-existent entry", in); - } catch (Exception e) { - fail("Exception during test 2: " + e); - } - - try { - Support_Resources.copyFile(resources, null, jarName); - File signedFile = new File(resources, jarName); - JarFile jf = new JarFile(signedFile); - JarEntry jre = new JarEntry("foo/bar/A.class"); - jf.getInputStream(jre); - // InputStream returned in any way, exception can be thrown in case - // of reading from this stream only. - // fail("Should throw ZipException"); - } catch (ZipException ee) { - // expected - } - - try { - Support_Resources.copyFile(resources, null, jarName); - File signedFile = new File(resources, jarName); - JarFile jf = new JarFile(signedFile); - JarEntry jre = new JarEntry("foo/bar/A.class"); - jf.close(); - jf.getInputStream(jre); - // InputStream returned in any way, exception can be thrown in case - // of reading from this stream only. - // The same for IOException - fail("Should throw IllegalStateException"); - } catch (IllegalStateException ee) { - // expected - } - } - - /** - * The jar is intact, but the entry object is modified. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Regression test for issue introduced by HAROMNY-4569. " - + "signed archives containing files with size 0 could not get verified", - method = "getInputStream", - args = {ZipEntry.class} - ) - public void testJarVerificationEmptyEntry() throws IOException { - Support_Resources.copyFile(resources, null, emptyEntryJar); - File f = new File(resources, emptyEntryJar); - - JarFile jarFile = new JarFile(f); - - ZipEntry zipEntry = jarFile.getJarEntry(emptyEntry1); - int res = jarFile.getInputStream(zipEntry).read(new byte[100], 0, 100); - assertEquals("Wrong length of empty jar entry", -1, res); - - zipEntry = jarFile.getJarEntry(emptyEntry2); - res = jarFile.getInputStream(zipEntry).read(new byte[100], 0, 100); - assertEquals("Wrong length of empty jar entry", -1, res); - - zipEntry = jarFile.getJarEntry(emptyEntry3); - res = jarFile.getInputStream(zipEntry).read(); - assertEquals("Wrong length of empty jar entry", -1, res); - } -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java deleted file mode 100644 index 5befa77c7..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java +++ /dev/null @@ -1,641 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.jar; - -import dalvik.annotation.KnownFailure; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; -import tests.support.resource.Support_Resources; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; -import java.util.jar.JarEntry; -import java.util.jar.JarInputStream; -import java.util.jar.Manifest; -import java.util.zip.ZipEntry; -import java.util.zip.ZipException; - -@TestTargetClass(JarInputStream.class) -public class JarInputStreamTest extends junit.framework.TestCase { - // a 'normal' jar file - private String jarName; - - // same as patch.jar but without a manifest file - private String jarName2; - - private final String entryName = "foo/bar/A.class"; - - private static final int indexofDSA = 2; - - private static final int indexofTESTCLASS = 4; - - private static final int totalEntries = 4; - - @Override - protected void setUp() { - jarName = Support_Resources.getURL("morestuff/hyts_patch.jar"); - jarName2 = Support_Resources.getURL("morestuff/hyts_patch2.jar"); - } - - /** - * @tests java.util.jar.JarInputStream#JarInputStream(java.io.InputStream) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "JarInputStream", - args = {java.io.InputStream.class} - ) - public void test_ConstructorLjava_io_InputStream() { - // Test for method java.util.jar.JarInputStream(java.io.InputStream) - InputStream is = null; - JarInputStream jis = null; - try { - is = new URL(jarName).openConnection().getInputStream(); - boolean hasCorrectEntry = false; - jis = new JarInputStream(is); - assertNotNull("The jar input stream should have a manifest", jis - .getManifest()); - JarEntry je = jis.getNextJarEntry(); - while (je != null) { - if (je.getName().equals(entryName)) { - hasCorrectEntry = true; - } - je = jis.getNextJarEntry(); - } - assertTrue( - "The jar input stream does not contain the correct entries", - hasCorrectEntry); - } catch (Exception e) { - fail("Exception during test: " + e.toString()); - } - - try { - is.close(); - jis = new JarInputStream(is); - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - } - - /** - * @tests java.util.jar.JarInputStream#getManifest() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getManifest", - args = {} - ) - public void test_getManifest() { - // Test for method java.util.jar.Manifest - // java.util.jar.JarInputStream.getManifest() - try { - Manifest m; - - InputStream is = new URL(jarName2).openConnection() - .getInputStream(); - JarInputStream jis = new JarInputStream(is); - m = jis.getManifest(); - assertNull("The jar input stream should not have a manifest", m); - - is = new URL(jarName).openConnection().getInputStream(); - jis = new JarInputStream(is); - m = jis.getManifest(); - assertNotNull("The jar input stream should have a manifest", m); - } catch (Exception e) { - fail("Exception during test: " + e.toString()); - } - - } - - /** - * @tests java.util.jar.JarInputStream#getNextJarEntry() - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - method = "getNextJarEntry", - args = {} - ) - public void test_getNextJarEntry() throws Exception { - final Set desired = new HashSet(Arrays - .asList(new String[] { - "foo/", "foo/bar/", "foo/bar/A.class", "Blah.txt"})); - Set actual = new HashSet(); - InputStream is = new URL(jarName).openConnection().getInputStream(); - JarInputStream jis = new JarInputStream(is); - JarEntry je = jis.getNextJarEntry(); - while (je != null) { - actual.add(je.toString()); - je = jis.getNextJarEntry(); - } - assertEquals(actual, desired); - jis.close(); - - try { - jis.getNextJarEntry(); - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - - File resources = Support_Resources.createTempFolder(); - Support_Resources.copyFile(resources, null, "Broken_entry.jar"); - is = Support_Resources.getStream("Broken_entry.jar"); - jis = new JarInputStream(is, false); - jis.getNextJarEntry(); - try { - jis.getNextJarEntry(); - fail("ZipException expected"); - } catch (ZipException ee) { - // expected - } - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - method = "getNextJarEntry", - args = {} - ) - public void test_getNextJarEntry_Ex() throws Exception { - final Set desired = new HashSet(Arrays - .asList("foo/", "foo/bar/", "foo/bar/A.class", "Blah.txt")); - Set actual = new HashSet(); - InputStream is = new URL(jarName).openConnection().getInputStream(); - JarInputStream jis = new JarInputStream(is); - JarEntry je = jis.getNextJarEntry(); - while (je != null) { - actual.add(je.toString()); - je = jis.getNextJarEntry(); - } - assertEquals(actual, desired); - jis.close(); - - try { - jis.getNextJarEntry(); - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - - File resources = Support_Resources.createTempFolder(); - Support_Resources.copyFile(resources, null, "Broken_entry.jar"); - is = Support_Resources.getStream("Broken_entry.jar"); - jis = new JarInputStream(is, false); - jis.getNextJarEntry(); - try { - jis.getNextJarEntry(); - fail("ZipException expected"); - } catch (ZipException ee) { - // expected - } - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Exceptions checking missed. Case2", - method = "getNextJarEntry", - args = {} - ) - public void test_JarInputStream_Integrate_Jar_getNextEntry() - throws IOException { - String intJarName = Support_Resources.getURL("Integrate.jar"); - InputStream is = new URL(intJarName).openConnection().getInputStream(); - JarInputStream jin = new JarInputStream(is, true); - ZipEntry entry = null; - int count = 0; - while (count == 0 || entry != null) { - count++; - entry = jin.getNextEntry(); - } - assertEquals(totalEntries + 1, count); - jin.close(); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "IOException & ZipException checking missed.", - method = "getNextEntry", - args = {} - ) - public void test_JarInputStream_Modified_Class_getNextEntry() - throws IOException { - String modJarName = Support_Resources.getURL("Modified_Class.jar"); - InputStream is = new URL(modJarName).openConnection().getInputStream(); - JarInputStream jin = new JarInputStream(is, true); - ZipEntry zipEntry = null; - - int count = 0; - while (count == 0 || zipEntry != null) { - count++; - try { - zipEntry = jin.getNextEntry(); - if (count == indexofTESTCLASS + 1) { - fail("Should throw Security Exception"); - } - } catch (SecurityException e) { - if (count != indexofTESTCLASS + 1) { - throw e; - } - - } - } - assertEquals(totalEntries + 2, count); - jin.close(); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "IOException & ZipException checking missed.", - method = "getNextEntry", - args = {} - ) - public void test_JarInputStream_Modified_Manifest_MainAttributes_getNextEntry() - throws IOException { - String modJarName = Support_Resources.getURL("Modified_Manifest_MainAttributes.jar"); - InputStream is = new URL(modJarName).openConnection() - .getInputStream(); - JarInputStream jin = new JarInputStream(is, true); - - assertEquals("META-INF/TESTROOT.SF", jin.getNextEntry().getName()); - assertEquals("META-INF/TESTROOT.DSA", jin.getNextEntry().getName()); - try { - jin.getNextEntry(); - fail(); - } catch (SecurityException expected) { - } - assertEquals("META-INF/", jin.getNextEntry().getName()); - assertEquals("Test.class", jin.getNextEntry().getName()); - assertNull(jin.getNextEntry()); - jin.close(); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "IOException & ZipException checking missed.", - method = "getNextEntry", - args = {} - ) - public void test_JarInputStream_Modified_Manifest_EntryAttributes_getNextEntry() - throws IOException { - String modJarName = Support_Resources - .getURL("Modified_Manifest_EntryAttributes.jar"); - InputStream is = new URL(modJarName).openConnection().getInputStream(); - JarInputStream jin = new JarInputStream(is, true); - ZipEntry zipEntry = null; - - int count = 0; - while (count == 0 || zipEntry != null) { - count++; - try { - zipEntry = jin.getNextEntry(); - if (count == indexofDSA + 1) { - fail("Should throw Security Exception"); - } - } catch (SecurityException e) { - if (count != indexofDSA + 1) { - throw e; - } - } - } - assertEquals(totalEntries + 2, count); - jin.close(); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "IOException & ZipException checking missed.", - method = "getNextEntry", - args = {} - ) - public void test_JarInputStream_Modified_SF_EntryAttributes_getNextEntry() - throws IOException { - String modJarName = Support_Resources - .getURL("Modified_SF_EntryAttributes.jar"); - InputStream is = new URL(modJarName).openConnection().getInputStream(); - JarInputStream jin = new JarInputStream(is, true); - ZipEntry zipEntry = null; - - int count = 0; - while (count == 0 || zipEntry != null) { - count++; - try { - zipEntry = jin.getNextEntry(); - if (count == indexofDSA + 1) { - fail("Should throw Security Exception"); - } - } catch (SecurityException e) { - if (count != indexofDSA + 1) { - throw e; - } - } - } - assertEquals(totalEntries + 2, count); - jin.close(); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "IOException & ZipException checking missed.", - method = "read", - args = {byte[].class} - ) - public void test_JarInputStream_Modified_Class_read() throws IOException { - String modJarName = Support_Resources.getURL("Modified_Class.jar"); - InputStream is = new URL(modJarName).openConnection().getInputStream(); - JarInputStream jin = new JarInputStream(is, true); - int count = 0; - ZipEntry zipEntry = null; - while (count == 0 || zipEntry != null) { - count++; - zipEntry = jin.getNextEntry(); - byte[] buffer = new byte[1024]; - try { - int length = 0; - while (length >= 0) { - length = jin.read(buffer); - } - if (count == indexofTESTCLASS) { - fail("Should throw Security Exception"); - } - } catch (SecurityException e) { - if (count < indexofTESTCLASS) { - throw e; - } - } - } - assertEquals(totalEntries + 1, count); - jin.close(); - } - - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Exception checking missed.", - method = "read", - args = {byte[].class} - ) - public void test_Integrate_Jar_read() throws IOException { - String intJarName = Support_Resources.getURL("Integrate.jar"); - InputStream is = new URL(intJarName).openConnection().getInputStream(); - JarInputStream jin = new JarInputStream(is, true); - int count = 0; - ZipEntry zipEntry = null; - while (count == 0 || zipEntry != null) { - count++; - zipEntry = jin.getNextEntry(); - byte[] buffer = new byte[1024]; - int length = 0; - while (length >= 0) { - length = jin.read(buffer); - } - - } - assertEquals(totalEntries + 1, count); - jin.close(); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "IOException & ZipException checking missed.", - method = "read", - args = {byte[].class} - ) - public void test_JarInputStream_Modified_Manifest_MainAttributes_read() - throws IOException { - String modJarName = Support_Resources - .getURL("Modified_Manifest_MainAttributes.jar"); - InputStream is = new URL(modJarName).openConnection().getInputStream(); - JarInputStream jin = new JarInputStream(is, true); - int count = 0; - ZipEntry zipEntry = null; - while (count == 0 || zipEntry != null) { - count++; - zipEntry = jin.getNextEntry(); - byte[] buffer = new byte[1024]; - try { - int length = 0; - while (length >= 0) { - length = jin.read(buffer); - } - if (count == indexofDSA) { - fail("Should throw Security Exception"); - } - } catch (SecurityException e) { - if (count != indexofDSA) { - throw e; - } - } - } - assertEquals(totalEntries + 1, count); - jin.close(); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "IOException & ZipException checking missed.", - method = "read", - args = {byte[].class} - ) - public void test_JarInputStream_Modified_SF_EntryAttributes_read() - throws IOException { - String modJarName = Support_Resources - .getURL("Modified_SF_EntryAttributes.jar"); - InputStream is = new URL(modJarName).openConnection().getInputStream(); - JarInputStream jin = new JarInputStream(is, true); - int count = 0; - ZipEntry zipEntry = null; - while (count == 0 || zipEntry != null) { - count++; - zipEntry = jin.getNextEntry(); - byte[] buffer = new byte[1024]; - try { - int length = 0; - while (length >= 0) { - length = jin.read(buffer); - } - if (count == indexofDSA) { - fail("Should throw Security Exception"); - } - } catch (SecurityException e) { - if (count != indexofDSA) { - throw e; - } - } - } - assertEquals(totalEntries + 1, count); - jin.close(); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "JarInputStream", - args = {java.io.InputStream.class, boolean.class} - ) - public void test_ConstructorLjava_io_InputStreamZ() { - // Test for method java.util.jar.JarInputStream(java.io.InputStream) - InputStream is = null; - JarInputStream jis = null; - try { - is = new URL(jarName).openConnection().getInputStream(); - boolean hasCorrectEntry = false; - jis = new JarInputStream(is, true); - assertNotNull("The jar input stream should have a manifest", jis - .getManifest()); - JarEntry je = jis.getNextJarEntry(); - while (je != null) { - if (je.getName().equals(entryName)) { - hasCorrectEntry = true; - } - je = jis.getNextJarEntry(); - } - assertTrue( - "The jar input stream does not contain the correct entries", - hasCorrectEntry); - } catch (Exception e) { - fail("Exception during test: " + e.toString()); - } - - try { - is.close(); - jis = new JarInputStream(is, false); - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - method = "close", - args = {} - ) - public void test_closeAfterException() throws Exception { - File resources = Support_Resources.createTempFolder(); - Support_Resources.copyFile(resources, null, "Broken_entry.jar"); - InputStream is = Support_Resources.getStream("Broken_entry.jar"); - JarInputStream jis = new JarInputStream(is, false); - jis.getNextEntry(); - try { - jis.getNextEntry(); - fail("ZipException expected"); - } catch (ZipException ee) { - // expected - } - jis.close(); - try { - jis.getNextEntry(); - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - method = "getNextEntry", - args = {} - ) - public void test_getNextEntry() throws Exception { - File resources = Support_Resources.createTempFolder(); - Support_Resources.copyFile(resources, null, "Broken_entry.jar"); - InputStream is = Support_Resources.getStream("Broken_entry.jar"); - JarInputStream jis = new JarInputStream(is, false); - jis.getNextEntry(); - try { - jis.getNextEntry(); - fail("ZipException expected"); - } catch (ZipException ee) { - // expected - } - - try { - jis.close(); // Android throws exception here, already! - jis.getNextEntry(); // But RI here, only! - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - } - - class Mock_JarInputStream extends JarInputStream { - - public Mock_JarInputStream(InputStream in) throws IOException { - super(in); - } - - public ZipEntry createZipEntry(String str) { - return super.createZipEntry(str); - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "createZipEntry", - args = {java.lang.String.class} - ) - public void test_createZipEntryLjava_lang_String() throws Exception { - File resources = Support_Resources.createTempFolder(); - Support_Resources.copyFile(resources, null, "Broken_entry.jar"); - InputStream is = Support_Resources.getStream("Broken_entry.jar"); - Mock_JarInputStream mjis = new Mock_JarInputStream(is); - assertNotNull(mjis.createZipEntry("New entry")); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - method = "read", - args = {byte[].class, int.class, int.class} - ) - public void test_read$ZII() throws Exception { - File resources = Support_Resources.createTempFolder(); - Support_Resources.copyFile(resources, null, "Broken_entry_data.jar"); - InputStream is = Support_Resources.getStream("Broken_entry_data.jar"); - JarInputStream jis = new JarInputStream(is, true); - byte b[] = new byte[100]; - - jis.getNextEntry(); - jis.read(b, 0, 100); - jis.getNextEntry(); - jis.getNextEntry(); - jis.getNextEntry(); - - try { - jis.read(b, 0, 100); - fail("ZipException expected"); - } catch (ZipException ee) { - // expected - } - - try { - jis.close(); // Android throws exception here, already! - jis.read(b, 0, 100); // But RI here, only! - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - } -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java deleted file mode 100644 index acdad71d4..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.jar; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URL; -import java.util.jar.Attributes; -import java.util.jar.JarEntry; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; -import java.util.zip.ZipEntry; - -import tests.support.Support_Exec; -import tests.support.resource.Support_Resources; - -@TestTargetClass(JarOutputStream.class) -public class JarOutputStreamTest extends junit.framework.TestCase { - - /** - * @tests java.util.jar.JarOutputStream#putNextEntry(java.util.zip.ZipEntry) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - method = "putNextEntry", - args = {java.util.zip.ZipEntry.class} - ) - public void test_putNextEntryLjava_util_zip_ZipEntry() throws Exception { - // testClass file`s actual extension is .class, since having .class - // extension files in source dir causes - // problems on eclipse, the extension is changed into .ser or it can be - // anything. The file is being - // read by inputstream and being written to other file, - // as long as the content of the file is not changed, the extension does - // not matter - final String testClass = "hyts_mainClass.ser"; - final String entryName = "foo/bar/execjartest/MainClass.class"; - - // test whether specifying the main class in the manifest - // works using either /'s or .'s as a separator - final String[] manifestMain = { - "foo.bar.execjartest.MainClass", - "foo/bar/execjartest/MainClass"}; - - for (String element : manifestMain) { - - // create the manifest - Manifest newman = new Manifest(); - Attributes att = newman.getMainAttributes(); - att.put(Attributes.Name.MANIFEST_VERSION, "1.0"); - att.put(Attributes.Name.MAIN_CLASS, element); - - File outputJar = null; - JarOutputStream jout = null; - - // open the output jarfile - outputJar = File.createTempFile("hyts_", ".jar"); - jout = new JarOutputStream(new FileOutputStream(outputJar), - newman); - jout.putNextEntry(new JarEntry(entryName)); - - File resources = Support_Resources.createTempFolder(); - - // read in the class file, and output it to the jar - Support_Resources.copyFile(resources, null, testClass); - URL jarURL = new URL((new File(resources, testClass)).toURL() - .toString()); - InputStream jis = jarURL.openStream(); - - byte[] bytes = new byte[1024]; - int len; - while ((len = jis.read(bytes)) != -1) { - jout.write(bytes, 0, len); - } - - jout.flush(); - jout.close(); - jis.close(); - - String res = null; - // set up the VM parameters - String[] args = new String[2]; - args[0] = "-jar"; - args[1] = outputJar.getAbsolutePath(); - -// It's not that simple to execute a JAR against Dalvik VM (see DalvikExecTest): -// -// try { -// // execute the JAR and read the result -// res = Support_Exec.execJava(args, null, true); -// } catch (Exception e) { -// fail("Exception executing test JAR: " + e); -// } -// -// assertTrue("Error executing JAR test on: " + element -// + ". Result returned was incorrect.", res -// .startsWith("TEST")); - outputJar.delete(); - - try { - // open the output jarfile - outputJar = File.createTempFile("hyts_", ".jar"); - OutputStream os = new FileOutputStream(outputJar); - jout = new JarOutputStream(os, newman); - os.close(); - jout.putNextEntry(new JarEntry(entryName)); - fail("IOException expected"); - } catch (IOException e) { - // expected - } - } - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks IOException", - method = "JarOutputStream", - args = {java.io.OutputStream.class, java.util.jar.Manifest.class} - ) - public void test_JarOutputStreamLjava_io_OutputStreamLjava_util_jar_Manifest() - throws IOException { - File fooJar = File.createTempFile("hyts_", ".jar"); - File barZip = File.createTempFile("hyts_", ".zip"); - - FileOutputStream fos = new FileOutputStream(fooJar); - - Manifest man = new Manifest(); - Attributes att = man.getMainAttributes(); - att.put(Attributes.Name.MANIFEST_VERSION, "1.0"); - att.put(Attributes.Name.MAIN_CLASS, "foo.bar.execjartest.Foo"); - att.put(Attributes.Name.CLASS_PATH, barZip.getName()); - - fos.close(); - try { - JarOutputStream joutFoo = new JarOutputStream(fos, man); - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Can not check IOException", - method = "JarOutputStream", - args = {java.io.OutputStream.class} - ) - public void test_JarOutputStreamLjava_io_OutputStream() throws IOException { - File fooJar = File.createTempFile("hyts_", ".jar"); - - FileOutputStream fos = new FileOutputStream(fooJar); - ZipEntry ze = new ZipEntry("Test"); - - try { - JarOutputStream joutFoo = new JarOutputStream(fos); - joutFoo.putNextEntry(ze); - joutFoo.write(33); - } catch (IOException ee) { - fail("IOException is not expected"); - } - - fos.close(); - fooJar.delete(); - try { - JarOutputStream joutFoo = new JarOutputStream(fos); - joutFoo.putNextEntry(ze); - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - } - - @Override - protected void setUp() { - } - - @Override - protected void tearDown() { - } - -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java deleted file mode 100644 index 42b254365..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java +++ /dev/null @@ -1,596 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.archive.tests.java.util.jar; - -import dalvik.annotation.KnownFailure; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.net.MalformedURLException; -import java.util.Map; -import java.util.jar.Attributes; -import java.util.jar.JarFile; -import java.util.jar.Manifest; - -import junit.framework.TestCase; - -import tests.support.resource.Support_Resources; - -@TestTargetClass(Manifest.class) -public class ManifestTest extends TestCase { - - private final String jarName = "hyts_patch.jar"; - - private final String attJarName = "hyts_att.jar"; - - private Manifest m; - - private Manifest m2; - - private final String ATT_ENTRY_NAME = "HasAttributes.txt"; - - private final String MANIFEST_NAME = "manifest/hyts_MANIFEST.MF"; - - private File resources; - - @Override - protected void setUp() { - resources = Support_Resources.createTempFolder(); - try { - Support_Resources.copyFile(resources, null, jarName); - JarFile jarFile = new JarFile(new File(resources, jarName)); - m = jarFile.getManifest(); - jarFile.close(); - Support_Resources.copyFile(resources, null, attJarName); - jarFile = new JarFile(new File(resources, attJarName)); - m2 = jarFile.getManifest(); - jarFile.close(); - } catch (Exception e) { - fail("Exception during setup: " + e.toString()); - } - } - - private Manifest getManifest(String fileName) { - try { - Support_Resources.copyFile(resources, null, fileName); - JarFile jarFile = new JarFile(new File(resources, fileName)); - Manifest m = jarFile.getManifest(); - jarFile.close(); - return m; - } catch (Exception e) { - fail("Exception during setup: " + e.toString()); - return null; - } - } - - /** - * @tests java.util.jar.Manifest#Manifest() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "Manifest", - args = {} - ) - public void test_Constructor() { - // Test for method java.util.jar.Manifest() - Manifest emptyManifest = new Manifest(); - assertTrue("Should have no entries", emptyManifest.getEntries() - .isEmpty()); - assertTrue("Should have no main attributes", emptyManifest - .getMainAttributes().isEmpty()); - } - - /** - * @tests java.util.jar.Manifest#Manifest(java.util.jar.Manifest) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "Manifest", - args = {java.util.jar.Manifest.class} - ) - public void testCopyingConstructor() throws IOException { - Manifest firstManifest = new Manifest(new URL(Support_Resources - .getURL(MANIFEST_NAME)).openStream()); - Manifest secondManifest = new Manifest(firstManifest); - assertEquals(firstManifest, secondManifest); - } - - /** - * @tests java.util.jar.Manifest#Manifest(Manifest) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "Manifest", - args = {java.util.jar.Manifest.class} - ) - public void test_ConstructorLjava_util_jar_Manifest() { - // Test for method java.util.jar.Manifest() - Manifest emptyManifest = new Manifest(); - Manifest emptyClone = new Manifest(emptyManifest); - assertTrue("Should have no entries", emptyClone.getEntries().isEmpty()); - assertTrue("Should have no main attributes", emptyClone - .getMainAttributes().isEmpty()); - assertEquals(emptyClone, emptyManifest); - assertEquals(emptyClone, emptyManifest.clone()); - } - - private void assertAttribute(Attributes attr, String name, String value) { - assertEquals("Incorrect " + name, value, attr.getValue(name)); - } - - private void checkManifest(Manifest manifest) { - Attributes main = manifest.getMainAttributes(); - assertAttribute(main, "Bundle-Name", "ClientSupport"); - assertAttribute(main, "Bundle-Description", - "Provides SessionService, AuthenticationService. Extends RegistryService."); - assertAttribute(main, "Bundle-Activator", - "com.ibm.ive.eccomm.client.support.ClientSupportActivator"); - assertAttribute( - main, - "Import-Package", - "com.ibm.ive.eccomm.client.services.log,com.ibm.ive.eccomm.client.services.registry,com.ibm.ive.eccomm.service.registry; specification-version=1.0.0,com.ibm.ive.eccomm.service.session; specification-version=1.0.0,com.ibm.ive.eccomm.service.framework; specification-version=1.2.0,org.osgi.framework; specification-version=1.0.0,org.osgi.service.log; specification-version=1.0.0,com.ibm.ive.eccomm.flash; specification-version=1.2.0,com.ibm.ive.eccomm.client.xml,com.ibm.ive.eccomm.client.http.common,com.ibm.ive.eccomm.client.http.client"); - assertAttribute( - main, - "Import-Service", - "org.osgi.service.log.LogReaderServiceorg.osgi.service.log.LogService,com.ibm.ive.eccomm.service.registry.RegistryService"); - assertAttribute( - main, - "Export-Package", - "com.ibm.ive.eccomm.client.services.authentication; specification-version=1.0.0,com.ibm.ive.eccomm.service.authentication; specification-version=1.0.0,com.ibm.ive.eccomm.common; specification-version=1.0.0,com.ibm.ive.eccomm.client.services.registry.store; specification-version=1.0.0"); - assertAttribute( - main, - "Export-Service", - "com.ibm.ive.eccomm.service.authentication.AuthenticationService,com.ibm.ive.eccomm.service.session.SessionService"); - assertAttribute(main, "Bundle-Vendor", "IBM"); - assertAttribute(main, "Bundle-Version", "1.2.0"); - } - - /** - * @tests java.util.jar.Manifest#Manifest(java.io.InputStream) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "IOException checking missed.", - method = "Manifest", - args = {java.io.InputStream.class} - ) - public void test_ConstructorLjava_io_InputStream() throws IOException { - Manifest m = getManifest(attJarName); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - m.write(baos); - InputStream is = new ByteArrayInputStream(baos.toByteArray()); - Manifest mCopy = new Manifest(is); - assertEquals(m, mCopy); - - Manifest manifest = new Manifest(new URL(Support_Resources - .getURL(MANIFEST_NAME)).openStream()); - checkManifest(manifest); - - // regression test for HARMONY-5424 - String manifestContent = "Manifest-Version: 1.0\nCreated-By: Apache\nPackage: \nBuild-Jdk: 1.4.1_01\n\n" - + "Name: \nSpecification-Title: foo\nSpecification-Version: 1.0\nSpecification-Vendor: \n" - + "Implementation-Title: \nImplementation-Version: 1.0\nImplementation-Vendor: \n\n"; - ByteArrayInputStream bis = new ByteArrayInputStream(manifestContent - .getBytes("ISO-8859-1")); - - - Manifest mf = new Manifest(bis); - assertEquals("Should be 4 main attributes", 4, mf.getMainAttributes() - .size()); - - Map entries = mf.getEntries(); - assertEquals("Should be one named entry", 1, entries.size()); - - Attributes namedEntryAttributes = (Attributes) (entries.get("")); - assertEquals("Should be 6 named entry attributes", 6, - namedEntryAttributes.size()); - } - - /** - * @tests java.util.jar.Manifest#clear() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "clear", - args = {} - ) - public void test_clear() { - m2.clear(); - assertTrue("Should have no entries", m2.getEntries().isEmpty()); - assertTrue("Should have no main attributes", m2.getMainAttributes() - .isEmpty()); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "clone", - args = {} - ) - public void test_clone() throws IOException { - Manifest emptyManifest = new Manifest(); - Manifest emptyClone = (Manifest) emptyManifest.clone(); - assertTrue("Should have no entries", emptyClone.getEntries().isEmpty()); - assertTrue("Should have no main attributes", emptyClone - .getMainAttributes().isEmpty()); - assertEquals(emptyClone, emptyManifest); - assertEquals(emptyManifest.clone().getClass().getName(), - "java.util.jar.Manifest"); - - Manifest manifest = new Manifest(new URL(Support_Resources - .getURL("manifest/hyts_MANIFEST.MF")).openStream()); - Manifest manifestClone = (Manifest) manifest.clone(); - manifestClone.getMainAttributes(); - checkManifest(manifestClone); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "equals", - args = {java.lang.Object.class} - ) - public void test_equals() throws IOException { - Manifest manifest1 = new Manifest(new URL(Support_Resources.getURL( - "manifest/hyts_MANIFEST.MF")).openStream()); - Manifest manifest2 = new Manifest(new URL(Support_Resources.getURL( - "manifest/hyts_MANIFEST.MF")).openStream()); - Manifest manifest3 = new Manifest(); - - assertTrue(manifest1.equals(manifest1)); - assertTrue(manifest1.equals(manifest2)); - assertFalse(manifest1.equals(manifest3)); - assertFalse(manifest1.equals(this)); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "hashCode", - args = {} - ) - public void test_hashCode() throws IOException { - Manifest manifest1 = new Manifest(new URL(Support_Resources - .getURL("manifest/hyts_MANIFEST.MF")).openStream()); - Manifest manifest2 = new Manifest(); - assertEquals(manifest1.hashCode(), manifest1.hashCode()); - assertNotSame(manifest1.hashCode(), manifest2.hashCode()); - } - - /** - * @tests java.util.jar.Manifest#getAttributes(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getAttributes", - args = {String.class} - ) - public void test_getAttributesLjava_lang_String() { - assertNull("Should not exist", - m2.getAttributes("Doesn't Exist")); - assertEquals("Should exist", "OK", m2.getAttributes("HasAttributes.txt").get( - new Attributes.Name("MyAttribute"))); - } - - /** - * @tests java.util.jar.Manifest#getEntries() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getEntries", - args = {} - ) - public void test_getEntries() { - Map myMap = m2.getEntries(); - assertNull("Shouldn't exist", myMap.get("Doesn't exist")); - assertEquals("Should exist", - "OK", myMap.get("HasAttributes.txt").get( - new Attributes.Name("MyAttribute"))); - } - - /** - * @tests java.util.jar.Manifest#getMainAttributes() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getMainAttributes", - args = {} - ) - public void test_getMainAttributes() { - // Test for method java.util.jar.Attributes - // java.util.jar.Manifest.getMainAttributes() - Attributes a = m.getMainAttributes(); - assertEquals("Manifest_Version should return 1.0", "1.0", a.get( - Attributes.Name.MANIFEST_VERSION)); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "write", - args = {java.io.OutputStream.class} - ) - public void test_writeLjava_io_OutputStream() throws IOException { - byte b[] = null; - Manifest manifest1 = null; - Manifest manifest2 = null; - InputStream is = null; - try { - manifest1 = new Manifest(new URL(Support_Resources - .getURL("manifest/hyts_MANIFEST.MF")).openStream()); - } catch (MalformedURLException e) { - fail("Malformed URL"); - } - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - manifest1.write(baos); - - b = baos.toByteArray(); - - File f = File.createTempFile("111", "111"); - FileOutputStream fos = new FileOutputStream(f); - fos.close(); - try { - manifest1.write(fos); - fail("IOException expected"); - } catch (IOException e) { - // expected - } - f.delete(); - - ByteArrayInputStream bais = new ByteArrayInputStream(b); - - try { - manifest2 = new Manifest(bais); - } catch (MalformedURLException e) { - fail("Malformed URL"); - } - - assertTrue(manifest1.equals(manifest2)); - } - - /** - * Ensures compatibility with manifests produced by gcc. - * - * @see HARMONY-5662 - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "Manifest", - args = {InputStream.class} - ) - public void testNul() throws IOException { - String manifestContent = - "Manifest-Version: 1.0\nCreated-By: nasty gcc tool\n\n\0"; - - byte[] bytes = manifestContent.getBytes("ISO-8859-1"); - new Manifest(new ByteArrayInputStream(bytes)); // the last NUL is ok - - bytes[bytes.length - 1] = 26; - new Manifest(new ByteArrayInputStream(bytes)); // the last EOF is ok - - bytes[bytes.length - 1] = 'A'; // the last line ignored - new Manifest(new ByteArrayInputStream(bytes)); - - bytes[2] = 0; // NUL char in Manifest - try { - new Manifest(new ByteArrayInputStream(bytes)); - fail("IOException expected"); - } catch (IOException e) { - // desired - } - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - method = "Manifest", - args = {InputStream.class} - ) - @KnownFailure("CharsetDecoder fails with an IllegalStateException") - public void testDecoding() throws IOException { - Manifest m = getManifest(attJarName); - final byte[] bVendor = new byte[] { (byte) 0xd0, (byte) 0x9C, - (byte) 0xd0, (byte) 0xb8, (byte) 0xd0, (byte) 0xbb, - (byte) 0xd0, (byte) 0xb0, (byte) 0xd1, (byte) 0x8f, ' ', - (byte) 0xd0, (byte) 0xb4, (byte) 0xd0, (byte) 0xbe, - (byte) 0xd1, (byte) 0x87, (byte) 0xd1, (byte) 0x83, - (byte) 0xd0, (byte) 0xbd, (byte) 0xd1, (byte) 0x8C, - (byte) 0xd0, (byte) 0xba, (byte) 0xd0, (byte) 0xb0, ' ', - (byte) 0xd0, (byte) 0x9C, (byte) 0xd0, (byte) 0xb0, - (byte) 0xd1, (byte) 0x88, (byte) 0xd0, (byte) 0xb0 }; - - final byte[] bSpec = new byte[] { (byte) 0xe1, (byte) 0x88, - (byte) 0xb0, (byte) 0xe1, (byte) 0x88, (byte) 0x8b, - (byte) 0xe1, (byte) 0x88, (byte) 0x9d, ' ', (byte) 0xe1, - (byte) 0x9a, (byte) 0xa0, (byte) 0xe1, (byte) 0x9a, - (byte) 0xb1, (byte) 0xe1, (byte) 0x9b, (byte) 0x81, - (byte) 0xe1, (byte) 0x9a, (byte) 0xa6, ' ', (byte) 0xd8, - (byte) 0xb3, (byte) 0xd9, (byte) 0x84, (byte) 0xd8, - (byte) 0xa7, (byte) 0xd9, (byte) 0x85, ' ', (byte) 0xd8, - (byte) 0xb9, (byte) 0xd8, (byte) 0xb3, (byte) 0xd9, - (byte) 0x84, (byte) 0xd8, (byte) 0xa7, (byte) 0xd9, - (byte) 0x85, (byte) 0xd8, (byte) 0xa9, ' ', (byte) 0xdc, - (byte) 0xab, (byte) 0xdc, (byte) 0xa0, (byte) 0xdc, - (byte) 0xa1, (byte) 0xdc, (byte) 0x90, ' ', (byte) 0xe0, - (byte) 0xa6, (byte) 0xb6, (byte) 0xe0, (byte) 0xa6, - (byte) 0xbe, (byte) 0xe0, (byte) 0xa6, (byte) 0xa8, - (byte) 0xe0, (byte) 0xa7, (byte) 0x8d, (byte) 0xe0, - (byte) 0xa6, (byte) 0xa4, (byte) 0xe0, (byte) 0xa6, - (byte) 0xbf, ' ', (byte) 0xd0, (byte) 0xa0, (byte) 0xd0, - (byte) 0xb5, (byte) 0xd0, (byte) 0xba, (byte) 0xd1, - (byte) 0x8a, (byte) 0xd0, (byte) 0xb5, (byte) 0xd0, - (byte) 0xbb, ' ', (byte) 0xd0, (byte) 0x9c, (byte) 0xd0, - (byte) 0xb8, (byte) 0xd1, (byte) 0x80, ' ', (byte) 0xe0, - (byte) 0xa6, (byte) 0xb6, (byte) 0xe0, (byte) 0xa6, - (byte) 0xbe, (byte) 0xe0, (byte) 0xa6, (byte) 0xa8, - (byte) 0xe0, (byte) 0xa7, (byte) 0x8d, (byte) 0xe0, - (byte) 0xa6, (byte) 0xa4, (byte) 0xe0, (byte) 0xa6, - (byte) 0xbf, ' ', (byte) 0xe0, (byte) 0xbd, (byte) 0x9e, - (byte) 0xe0, (byte) 0xbd, (byte) 0xb2, (byte) 0xe0, - (byte) 0xbc, (byte) 0x8b, (byte) 0xe0, (byte) 0xbd, - (byte) 0x96, (byte) 0xe0, (byte) 0xbd, (byte) 0x91, - (byte) 0xe0, (byte) 0xbd, (byte) 0xba, ' ', (byte) 0xd0, - (byte) 0x9c, (byte) 0xd0, (byte) 0xb0, (byte) 0xd1, - (byte) 0x88, (byte) 0xd0, (byte) 0xb0, (byte) 0xd1, - (byte) 0x80, ' ', (byte) 0xe1, (byte) 0x8f, (byte) 0x99, - (byte) 0xe1, (byte) 0x8e, (byte) 0xaf, (byte) 0xe1, - (byte) 0x8f, (byte) 0xb1, ' ', (byte) 0xcf, (byte) 0xa8, - (byte) 0xce, (byte) 0xb9, (byte) 0xcf, (byte) 0x81, - (byte) 0xce, (byte) 0xb7, (byte) 0xce, (byte) 0xbd, - (byte) 0xce, (byte) 0xb7, ' ', (byte) 0xde, (byte) 0x90, - (byte) 0xde, (byte) 0xaa, (byte) 0xde, (byte) 0x85, - (byte) 0xde, (byte) 0xa6, ' ', (byte) 0xe0, (byte) 0xbd, - (byte) 0x82, (byte) 0xe0, (byte) 0xbd, (byte) 0x9e, - (byte) 0xe0, (byte) 0xbd, (byte) 0xb2, (byte) 0xe0, - (byte) 0xbc, (byte) 0x8b, (byte) 0xe0, (byte) 0xbd, - (byte) 0x96, (byte) 0xe0, (byte) 0xbd, (byte) 0x91, - (byte) 0xe0, (byte) 0xbd, (byte) 0xba, ' ', (byte) 0xce, - (byte) 0x95, (byte) 0xce, (byte) 0xb9, (byte) 0xcf, - (byte) 0x81, (byte) 0xce, (byte) 0xae, (byte) 0xce, - (byte) 0xbd, (byte) 0xce, (byte) 0xb7, ' ', (byte) 0xd8, - (byte) 0xb5, (byte) 0xd9, (byte) 0x84, (byte) 0xd8, - (byte) 0xad, ' ', (byte) 0xe0, (byte) 0xaa, (byte) 0xb6, - (byte) 0xe0, (byte) 0xaa, (byte) 0xbe, (byte) 0xe0, - (byte) 0xaa, (byte) 0x82, (byte) 0xe0, (byte) 0xaa, - (byte) 0xa4, (byte) 0xe0, (byte) 0xaa, (byte) 0xbf, ' ', - (byte) 0xe5, (byte) 0xb9, (byte) 0xb3, (byte) 0xe5, - (byte) 0x92, (byte) 0x8c, ' ', (byte) 0xd7, (byte) 0xa9, - (byte) 0xd7, (byte) 0x9c, (byte) 0xd7, (byte) 0x95, - (byte) 0xd7, (byte) 0x9d, ' ', (byte) 0xd7, (byte) 0xa4, - (byte) 0xd7, (byte) 0xa8, (byte) 0xd7, (byte) 0x99, - (byte) 0xd7, (byte) 0x93, (byte) 0xd7, (byte) 0x9f, ' ', - (byte) 0xe5, (byte) 0x92, (byte) 0x8c, (byte) 0xe5, - (byte) 0xb9, (byte) 0xb3, ' ', (byte) 0xe5, (byte) 0x92, - (byte) 0x8c, (byte) 0xe5, (byte) 0xb9, (byte) 0xb3, ' ', - (byte) 0xd8, (byte) 0xaa, (byte) 0xd9, (byte) 0x89, - (byte) 0xd9, (byte) 0x86, (byte) 0xda, (byte) 0x86, - (byte) 0xd9, (byte) 0x84, (byte) 0xd9, (byte) 0x89, - (byte) 0xd9, (byte) 0x82, ' ', (byte) 0xe0, (byte) 0xae, - (byte) 0x85, (byte) 0xe0, (byte) 0xae, (byte) 0xae, - (byte) 0xe0, (byte) 0xaf, (byte) 0x88, (byte) 0xe0, - (byte) 0xae, (byte) 0xa4, (byte) 0xe0, (byte) 0xae, - (byte) 0xbf, ' ', (byte) 0xe0, (byte) 0xb0, (byte) 0xb6, - (byte) 0xe0, (byte) 0xb0, (byte) 0xbe, (byte) 0xe0, - (byte) 0xb0, (byte) 0x82, (byte) 0xe0, (byte) 0xb0, - (byte) 0xa4, (byte) 0xe0, (byte) 0xb0, (byte) 0xbf, ' ', - (byte) 0xe0, (byte) 0xb8, (byte) 0xaa, (byte) 0xe0, - (byte) 0xb8, (byte) 0xb1, (byte) 0xe0, (byte) 0xb8, - (byte) 0x99, (byte) 0xe0, (byte) 0xb8, (byte) 0x95, - (byte) 0xe0, (byte) 0xb8, (byte) 0xb4, (byte) 0xe0, - (byte) 0xb8, (byte) 0xa0, (byte) 0xe0, (byte) 0xb8, - (byte) 0xb2, (byte) 0xe0, (byte) 0xb8, (byte) 0x9e, ' ', - (byte) 0xe1, (byte) 0x88, (byte) 0xb0, (byte) 0xe1, - (byte) 0x88, (byte) 0x8b, (byte) 0xe1, (byte) 0x88, - (byte) 0x9d, ' ', (byte) 0xe0, (byte) 0xb7, (byte) 0x83, - (byte) 0xe0, (byte) 0xb7, (byte) 0x8f, (byte) 0xe0, - (byte) 0xb6, (byte) 0xb8, (byte) 0xe0, (byte) 0xb6, - (byte) 0xba, ' ', (byte) 0xe0, (byte) 0xa4, (byte) 0xb6, - (byte) 0xe0, (byte) 0xa4, (byte) 0xbe, (byte) 0xe0, - (byte) 0xa4, (byte) 0xa8, (byte) 0xe0, (byte) 0xa5, - (byte) 0x8d, (byte) 0xe0, (byte) 0xa4, (byte) 0xa4, - (byte) 0xe0, (byte) 0xa4, (byte) 0xbf, (byte) 0xe0, - (byte) 0xa4, (byte) 0x83, ' ', (byte) 0xe1, (byte) 0x83, - (byte) 0x9b, (byte) 0xe1, (byte) 0x83, (byte) 0xa8, - (byte) 0xe1, (byte) 0x83, (byte) 0x95, (byte) 0xe1, - (byte) 0x83, (byte) 0x98, (byte) 0xe1, (byte) 0x83, - (byte) 0x93, (byte) 0xe1, (byte) 0x83, (byte) 0x9d, - (byte) 0xe1, (byte) 0x83, (byte) 0x91, (byte) 0xe1, - (byte) 0x83, (byte) 0x90 }; - // TODO Cannot make the following word work, encoder changes needed - // (byte) 0xed, (byte) 0xa0, (byte) 0x80, - // (byte) 0xed, (byte) 0xbc, (byte) 0xb2, (byte) 0xed, - // (byte) 0xa0, (byte) 0x80, (byte) 0xed, (byte) 0xbc, - // (byte) 0xb0, (byte) 0xed, (byte) 0xa0, (byte) 0x80, - // (byte) 0xed, (byte) 0xbd, (byte) 0x85, (byte) 0xed, - // (byte) 0xa0, (byte) 0x80, (byte) 0xed, (byte) 0xbc, - // (byte) 0xb0, (byte) 0xed, (byte) 0xa0, (byte) 0x80, - // (byte) 0xed, (byte) 0xbc, (byte) 0xb9, (byte) 0xed, - // (byte) 0xa0, (byte) 0x80, (byte) 0xed, (byte) 0xbc, - // (byte) 0xb8, (byte) 0xed, (byte) 0xa0, (byte) 0x80, - // (byte) 0xed, (byte) 0xbc, (byte) 0xb9, ' ' - - final String vendor = new String(bVendor, "UTF-8"); - final String spec = new String(bSpec, "UTF-8"); - m.getMainAttributes() - .put(Attributes.Name.IMPLEMENTATION_VENDOR, vendor); - m.getAttributes(ATT_ENTRY_NAME).put( - Attributes.Name.IMPLEMENTATION_VENDOR, vendor); - m.getEntries().get(ATT_ENTRY_NAME).put( - Attributes.Name.SPECIFICATION_TITLE, spec); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - m.write(baos); - m = new Manifest(new ByteArrayInputStream(baos.toByteArray())); - - assertEquals(vendor, m.getMainAttributes().get( - Attributes.Name.IMPLEMENTATION_VENDOR)); - assertEquals(vendor, m.getEntries().get(ATT_ENTRY_NAME).get( - Attributes.Name.IMPLEMENTATION_VENDOR)); - assertEquals(spec, m.getAttributes(ATT_ENTRY_NAME).get( - Attributes.Name.SPECIFICATION_TITLE)); - } - - /** - * @tests {@link java.util.jar.Manifest#read(java.io.InputStream) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "", - method = "read", - args = {InputStream.class} - ) - public void testRead() { - // Regression for HARMONY-89 - InputStream is = new InputStreamImpl(); - try { - new Manifest().read(is); - fail("IOException expected"); - } catch (IOException e) { - // desired - } - } - - // helper class - private class InputStreamImpl extends InputStream { - public InputStreamImpl() { - super(); - } - - @Override - public int read() { - return 0; - } - } -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200PackerTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200PackerTest.java deleted file mode 100644 index 0d7210897..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200PackerTest.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.jar; - -import dalvik.annotation.KnownFailure; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; - -import junit.framework.TestCase; - -import tests.support.resource.Support_Resources; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Map; -import java.util.jar.JarFile; -import java.util.jar.JarInputStream; -import java.util.jar.Pack200; -import java.util.jar.Pack200.Packer; - -@TestTargetClass(Pack200.Packer.class) -public class Pack200PackerTest extends TestCase { - Packer packer; - Map properties; - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "properties", - args = {} - ) - @KnownFailure("No Implementation in Android!") - public void testProperties() { - assertTrue(properties.size()>0); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "pack", - args = {java.util.jar.JarFile.class, java.io.OutputStream.class} - ) - @KnownFailure("No Implementation in Android!") - public void testPackJarFileOutputStream() throws IOException { - File resources = Support_Resources.createTempFolder(); - //Use junit4.jar file for testing pack200 compressing rate. - //file can be changed to any other. - Support_Resources.copyFile(resources, null, "junit4-4.3.1.jar"); - File jarFile = new File(resources, "junit4-4.3.1.jar"); - JarFile jf = new JarFile(jarFile); - - File packFile1 = Support_Resources.createTempFile("pack200_1"); - File packFile2 = Support_Resources.createTempFile("pack200_2"); - File packFile3 = Support_Resources.createTempFile("pack200_3"); - FileOutputStream fos1 = new FileOutputStream(packFile1); - FileOutputStream fos2 = new FileOutputStream(packFile2); - FileOutputStream fos3 = new FileOutputStream(packFile3); - properties.put(Packer.EFFORT, "0"); - packer.pack(jf, fos1); - jf.close(); - fos1.close(); - jf = new JarFile(jarFile); - properties.put(Packer.EFFORT, "1"); - packer.pack(jf, fos2); - jf.close(); - fos2.close(); - jf = new JarFile(jarFile); - properties.put(Packer.EFFORT, "9"); - packer.pack(jf, fos3); - jf.close(); - fos3.close(); - assertTrue(jarFile.length()!=packFile1.length()); - assertTrue(packFile1.length()>packFile2.length()); - assertTrue(packFile2.length()>packFile3.length()); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "pack", - args = {java.util.jar.JarInputStream.class, java.io.OutputStream.class} - ) - @KnownFailure("No Implementation in Android!") - public void testPackJarInputStreamOutputStream() throws IOException { - File resources = Support_Resources.createTempFolder(); - //Use junit4.jar file for testing pack200 compressing rate. - //file can be changed to any other. - Support_Resources.copyFile(resources, null, "junit4-4.3.1.jar"); - File jarFile = new File(resources, "junit4-4.3.1.jar"); - JarInputStream jis = new JarInputStream(new FileInputStream(jarFile)); - - File packFile1 = Support_Resources.createTempFile("pack200_1"); - File packFile2 = Support_Resources.createTempFile("pack200_2"); - File packFile3 = Support_Resources.createTempFile("pack200_3"); - FileOutputStream fos1 = new FileOutputStream(packFile1); - FileOutputStream fos2 = new FileOutputStream(packFile2); - FileOutputStream fos3 = new FileOutputStream(packFile3); - properties.put(Packer.EFFORT, "0"); - packer.pack(jis, fos1); - fos1.close(); - jis = new JarInputStream(new FileInputStream(jarFile)); - properties.put(Packer.EFFORT, "1"); - packer.pack(jis, fos2); - fos2.close(); - jis = new JarInputStream(new FileInputStream(jarFile)); - properties.put(Packer.EFFORT, "9"); - packer.pack(jis, fos3); - fos3.close(); - assertTrue(jarFile.length()!=packFile1.length()); - assertTrue(packFile1.length()>packFile2.length()); - assertTrue(packFile2.length()>packFile3.length()); - } - - class MyPCL implements PropertyChangeListener { - boolean flag = false; - - public boolean isCalled() { - return flag; - } - - public void propertyChange(PropertyChangeEvent arg0) { - flag = true; - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "addPropertyChangeListener", - args = {java.beans.PropertyChangeListener.class} - ) - @KnownFailure("No Implementation in Android!") - public void testAddPropertyChangeListener() { - MyPCL pcl = new MyPCL(); - packer.addPropertyChangeListener(pcl); - assertFalse(pcl.isCalled()); - properties.put(Packer.EFFORT, "7"); - assertTrue(pcl.isCalled()); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "removePropertyChangeListener", - args = {java.beans.PropertyChangeListener.class} - ) - @KnownFailure("No Implementation in Android!") - public void testRemovePropertyChangeListener() { - MyPCL pcl = new MyPCL(); - packer.addPropertyChangeListener(pcl); - assertFalse(pcl.isCalled()); - packer.removePropertyChangeListener(pcl); - properties.put(Packer.EFFORT, "7"); - assertFalse(pcl.isCalled()); - } - - @Override - protected void setUp() { - packer = Pack200.newPacker(); - properties = packer.properties(); - } - - @Override - protected void tearDown() { - packer = null; - properties = null; - } -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200Test.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200Test.java deleted file mode 100644 index 9fb3cf97d..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200Test.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.jar; - -import dalvik.annotation.KnownFailure; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; - -import junit.framework.TestCase; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.jar.Pack200; - -@TestTargetClass(Pack200.class) -public class Pack200Test extends TestCase { - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "newPacker", - args = {} - ) - @KnownFailure("No Implementation in Android!") - public void testNewPacker() { - Method[] methodsInt = Pack200.Packer.class.getDeclaredMethods(); - Method[] methodsImpl = Pack200.newPacker().getClass() - .getDeclaredMethods(); - Field[] fieldsInt = Pack200.Packer.class.getFields(); - Field[] fieldsImpl = Pack200.newPacker().getClass().getFields(); - int i, k; - boolean flag; - for (i = 0; i < methodsInt.length; i++) { - flag = false; - for (k = 0; k < methodsImpl.length; k++) { - if (methodsInt[i].getName().equals(methodsImpl[k].getName())) { - flag = true; - break; - } - } - assertTrue("Not all methods were implemented", flag); - } - - for (i = 0; i < fieldsInt.length; i++) { - flag = false; - for (k = 0; k < fieldsImpl.length; k++) { - if (fieldsInt[i].getName().equals(fieldsImpl[k].getName())) { - flag = true; - break; - } - } - assertTrue("Not all fields were existed", flag); - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "newUnpacker", - args = {} - ) - @KnownFailure("No Implementation in Android!") - public void testNewUnpacker() { - assertNotNull(Pack200.newUnpacker().getClass()); - Method[] methodsInt = Pack200.Unpacker.class.getDeclaredMethods(); - Method[] methodsImpl = Pack200.newUnpacker().getClass() - .getDeclaredMethods(); - Field[] fieldsInt = Pack200.Unpacker.class.getFields(); - Field[] fieldsImpl = Pack200.newUnpacker().getClass().getFields(); - int i, k; - boolean flag; - for (i = 0; i < methodsInt.length; i++) { - flag = false; - for (k = 0; k < methodsImpl.length; k++) { - if (methodsInt[i].getName().equals(methodsImpl[k].getName())) { - flag = true; - break; - } - } - assertTrue("Not all methods were implemented", flag); - } - - for (i = 0; i < fieldsInt.length; i++) { - flag = false; - for (k = 0; k < fieldsImpl.length; k++) { - if (fieldsInt[i].getName().equals(fieldsImpl[k].getName())) { - flag = true; - break; - } - } - assertTrue("Not all fields were existed", flag); - } - } - -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200UnpackerTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200UnpackerTest.java deleted file mode 100644 index c1f98133b..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200UnpackerTest.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.jar; - -import dalvik.annotation.KnownFailure; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; - -import junit.framework.TestCase; - -import tests.support.resource.Support_Resources; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Map; -import java.util.jar.JarFile; -import java.util.jar.JarOutputStream; -import java.util.jar.Pack200; -import java.util.jar.Pack200.Packer; -import java.util.jar.Pack200.Unpacker; - -@TestTargetClass(Pack200.Unpacker.class) -public class Pack200UnpackerTest extends TestCase { - Unpacker unpacker; - Map properties; - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "properties", - args = {} - ) - @KnownFailure("No Implementation in Android!") - public void testProperties() { - assertTrue(properties.size()>0); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "unpack", - args = {java.io.File.class, java.util.jar.JarOutputStream.class} - ) - @KnownFailure("No Implementation in Android!") - public void testUnpackInputStreamJarOutputStream() throws IOException { - File resources = Support_Resources.createTempFolder(); - //Use junit4.jar file for testing pack200 compressing rate. - //file can be changed to any other. - Support_Resources.copyFile(resources, null, "junit4-4.3.1.jar"); - File jarFile = new File(resources, "junit4-4.3.1.jar"); - JarFile jf = new JarFile(jarFile); - int jarEntries = jf.size(); - - File packFile1 = Support_Resources.createTempFile("pack200_1"); - File packFile2 = Support_Resources.createTempFile("pack200_2"); - File packFile3 = Support_Resources.createTempFile("pack200_3"); - FileOutputStream fos1 = new FileOutputStream(packFile1); - FileOutputStream fos2 = new FileOutputStream(packFile2); - FileOutputStream fos3 = new FileOutputStream(packFile3); - properties.put(Packer.EFFORT, "0"); - Packer packer = Pack200.newPacker(); - packer.pack(jf, fos1); - jf.close(); - fos1.close(); - jf = new JarFile(jarFile); - properties.put(Packer.EFFORT, "1"); - packer.pack(jf, fos2); - jf.close(); - fos2.close(); - jf = new JarFile(jarFile); - properties.put(Packer.EFFORT, "9"); - packer.pack(jf, fos3); - jf.close(); - fos3.close(); - - File jarFile1 = Support_Resources.createTempFile("jar_1"); - File jarFile2 = Support_Resources.createTempFile("jar_2"); - File jarFile3 = Support_Resources.createTempFile("jar_3"); - JarOutputStream jos1 = new JarOutputStream(new FileOutputStream(jarFile1)); - JarOutputStream jos2 = new JarOutputStream(new FileOutputStream(jarFile2)); - JarOutputStream jos3 = new JarOutputStream(new FileOutputStream(jarFile3)); - - unpacker.unpack(packFile1, jos1); - unpacker.unpack(packFile2, jos2); - unpacker.unpack(packFile3, jos3); - - jos1.close(); - jos2.close(); - jos3.close(); - - assertEquals(jarFile1.length(), jarFile2.length()); - assertEquals(jarFile2.length(), jarFile3.length()); - - assertEquals(jarEntries, new JarFile(jarFile1).size()); - assertEquals(jarEntries, new JarFile(jarFile2).size()); - assertEquals(jarEntries, new JarFile(jarFile3).size()); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "unpack", - args = {java.io.InputStream.class, java.util.jar.JarOutputStream.class} - ) - @KnownFailure("No Implementation in Android!") - public void testUnpackFileJarOutputStream() throws IOException { - File resources = Support_Resources.createTempFolder(); - //Use junit4.jar file for testing pack200 compressing rate. - //file can be changed to any other. - Support_Resources.copyFile(resources, null, "junit4-4.3.1.jar"); - File jarFile = new File(resources, "junit4-4.3.1.jar"); - JarFile jf = new JarFile(jarFile); - int jarEntries = jf.size(); - - File packFile1 = Support_Resources.createTempFile("pack200_1"); - File packFile2 = Support_Resources.createTempFile("pack200_2"); - File packFile3 = Support_Resources.createTempFile("pack200_3"); - FileOutputStream fos1 = new FileOutputStream(packFile1); - FileOutputStream fos2 = new FileOutputStream(packFile2); - FileOutputStream fos3 = new FileOutputStream(packFile3); - properties.put(Packer.EFFORT, "0"); - Packer packer = Pack200.newPacker(); - packer.pack(jf, fos1); - jf.close(); - fos1.close(); - jf = new JarFile(jarFile); - properties.put(Packer.EFFORT, "1"); - packer.pack(jf, fos2); - jf.close(); - fos2.close(); - jf = new JarFile(jarFile); - properties.put(Packer.EFFORT, "9"); - packer.pack(jf, fos3); - jf.close(); - fos3.close(); - - File jarFile1 = Support_Resources.createTempFile("jar_1"); - File jarFile2 = Support_Resources.createTempFile("jar_2"); - File jarFile3 = Support_Resources.createTempFile("jar_3"); - JarOutputStream jos1 = new JarOutputStream(new FileOutputStream(jarFile1)); - JarOutputStream jos2 = new JarOutputStream(new FileOutputStream(jarFile2)); - JarOutputStream jos3 = new JarOutputStream(new FileOutputStream(jarFile3)); - FileInputStream fis1 = new FileInputStream(packFile1); - FileInputStream fis2 = new FileInputStream(packFile2); - FileInputStream fis3 = new FileInputStream(packFile3); - - unpacker.unpack(fis1, jos1); - unpacker.unpack(fis2, jos2); - unpacker.unpack(fis3, jos3); - - jos1.close(); - jos2.close(); - jos3.close(); - - assertEquals(jarFile1.length(), jarFile2.length()); - assertEquals(jarFile2.length(), jarFile3.length()); - - assertEquals(jarEntries, new JarFile(jarFile1).size()); - assertEquals(jarEntries, new JarFile(jarFile2).size()); - assertEquals(jarEntries, new JarFile(jarFile3).size()); - } - - class MyPCL implements PropertyChangeListener { - boolean flag = false; - - public boolean isCalled() { - return flag; - } - - public void propertyChange(PropertyChangeEvent arg0) { - flag = true; - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "addPropertyChangeListener", - args = {java.beans.PropertyChangeListener.class} - ) - @KnownFailure("No Implementation in Android!") - public void testAddPropertyChangeListener() { - MyPCL pcl = new MyPCL(); - unpacker.addPropertyChangeListener(pcl); - assertFalse(pcl.isCalled()); - properties.put(Unpacker.PROGRESS, "0"); - assertTrue(pcl.isCalled()); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "removePropertyChangeListener", - args = {java.beans.PropertyChangeListener.class} - ) - @KnownFailure("No Implementation in Android!") - public void testRemovePropertyChangeListener() { - MyPCL pcl = new MyPCL(); - unpacker.addPropertyChangeListener(pcl); - assertFalse(pcl.isCalled()); - unpacker.removePropertyChangeListener(pcl); - properties.put(Unpacker.PROGRESS, "7"); - assertFalse(pcl.isCalled()); - } - - @Override - protected void setUp() { - unpacker = Pack200.newUnpacker(); - properties = unpacker.properties(); - } - - @Override - protected void tearDown() { - unpacker = null; - properties = null; - } -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ZipExecTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ZipExecTest.java deleted file mode 100644 index c6f07dece..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ZipExecTest.java +++ /dev/null @@ -1,324 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.jar; - -import dalvik.annotation.KnownFailure; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; -import tests.support.Support_Exec; -import tests.support.resource.Support_Resources; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.jar.Attributes; -import java.util.jar.JarEntry; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - -/** - * - * tests for various cases of java -jar ... execution with .zip files as args - * some tests are just copy of JarExecTest ones - */ - -@TestTargetClass(ZipOutputStream.class) -public class ZipExecTest extends junit.framework.TestCase { - @TestTargetNew( - level = TestLevel.ADDITIONAL, - notes = "Regression functional test. Exception checking missed.", - method = "putNextEntry", - args = {java.util.zip.ZipEntry.class} - ) - @KnownFailure("Maybe not a failure, but dalvikvm -jar is not supported (, as yet).") - public void test_1562() throws Exception { - Manifest man = new Manifest(); - Attributes att = man.getMainAttributes(); - att.put(Attributes.Name.MANIFEST_VERSION, "1.0"); - att.put(Attributes.Name.MAIN_CLASS, "foo.bar.execjartest.Foo"); - - File outputZip = File.createTempFile("hyts_", ".zip"); - outputZip.deleteOnExit(); - ZipOutputStream zout = new ZipOutputStream(new FileOutputStream( - outputZip)); - File resources = Support_Resources.createTempFolder(); - - for (String zipClass : new String[] {"Foo", "Bar"}) { - zout.putNextEntry(new ZipEntry("foo/bar/execjartest/" + zipClass - + ".class")); - zout.write(getResource(resources, "hyts_" + zipClass + ".ser")); - } - - zout.putNextEntry(new ZipEntry("META-INF/MANIFEST.MF")); - man.write(zout); - zout.close(); - - - // set up the VM parameters - String[] args = new String[] {"-jar", outputZip.getAbsolutePath()}; - - // execute the JAR and read the result - String res = Support_Exec.execJava(args, null, false); - - assertTrue("Error executing ZIP : result returned was incorrect.", res - .startsWith("FOOBAR")); - } - - /** - * tests Class-Path entry in manifest - * - * @throws Exception in case of troubles - */ - @TestTargetNew( - level = TestLevel.ADDITIONAL, - notes = "Functional test.", - method = "ZipOutputStream", - args = {java.io.OutputStream.class} - ) - @KnownFailure("Maybe not a failure, but dalvikvm -jar is not supported (, as yet).") - public void test_zip_class_path() throws Exception { - File fooZip = File.createTempFile("hyts_", ".zip"); - File barZip = File.createTempFile("hyts_", ".zip"); - fooZip.deleteOnExit(); - barZip.deleteOnExit(); - - // create the manifest - Manifest man = new Manifest(); - Attributes att = man.getMainAttributes(); - att.put(Attributes.Name.MANIFEST_VERSION, "1.0"); - att.put(Attributes.Name.MAIN_CLASS, "foo.bar.execjartest.Foo"); - att.put(Attributes.Name.CLASS_PATH, barZip.getName()); - - File resources = Support_Resources.createTempFolder(); - - ZipOutputStream zoutFoo = new ZipOutputStream(new FileOutputStream( - fooZip)); - zoutFoo.putNextEntry(new ZipEntry("META-INF/MANIFEST.MF")); - man.write(zoutFoo); - zoutFoo.putNextEntry(new ZipEntry("foo/bar/execjartest/Foo.class")); - zoutFoo.write(getResource(resources, "hyts_Foo.ser")); - zoutFoo.close(); - - ZipOutputStream zoutBar = new ZipOutputStream(new FileOutputStream( - barZip)); - zoutBar.putNextEntry(new ZipEntry("foo/bar/execjartest/Bar.class")); - zoutBar.write(getResource(resources, "hyts_Bar.ser")); - zoutBar.close(); - - String[] args = new String[] {"-jar", fooZip.getAbsolutePath()}; - - // execute the JAR and read the result - String res = Support_Exec.execJava(args, null, false); - - assertTrue("Error executing JAR : result returned was incorrect.", res - .startsWith("FOOBAR")); - - // rewrite manifest so it contains not only reference to bar but useless - // entries as well - att.put(Attributes.Name.CLASS_PATH, "xx yy zz " + barZip.getName()); - zoutFoo = new ZipOutputStream(new FileOutputStream(fooZip)); - zoutFoo.putNextEntry(new ZipEntry("META-INF/MANIFEST.MF")); - man.write(zoutFoo); - zoutFoo.putNextEntry(new ZipEntry("foo/bar/execjartest/Foo.class")); - zoutFoo.write(getResource(resources, "hyts_Foo.ser")); - zoutFoo.close(); - // execute the JAR and read the result - res = Support_Exec.execJava(args, null, false); - assertTrue("Error executing JAR : result returned was incorrect.", res - .startsWith("FOOBAR")); - - - // play with relative file names - put relative path as ..//xx.zip - att.put(Attributes.Name.CLASS_PATH, ".." + File.separator - + barZip.getParentFile().getName() + File.separator - + barZip.getName()); - zoutFoo = new ZipOutputStream(new FileOutputStream(fooZip)); - zoutFoo.putNextEntry(new ZipEntry("META-INF/MANIFEST.MF")); - man.write(zoutFoo); - zoutFoo.putNextEntry(new ZipEntry("foo/bar/execjartest/Foo.class")); - zoutFoo.write(getResource(resources, "hyts_Foo.ser")); - zoutFoo.close(); - // execute the ZIP and read the result - res = Support_Exec.execJava(args, null, false); - assertTrue("Error executing JAR : result returned was incorrect.", res - .startsWith("FOOBAR")); - } - - - @TestTargetNew( - level = TestLevel.ADDITIONAL, - notes = "Functional test.", - method = "ZipOutputStream", - args = {java.io.OutputStream.class} - ) - @KnownFailure("Maybe not a failure, but dalvikvm -jar is not supported (, as yet).") - public void test_zip_jar_mix() throws Exception { - File fooJar = File.createTempFile("hyts_", ".jar"); - File barZip = File.createTempFile("hyts_", ".zip"); - fooJar.deleteOnExit(); - barZip.deleteOnExit(); - - // create the manifest - Manifest man = new Manifest(); - Attributes att = man.getMainAttributes(); - att.put(Attributes.Name.MANIFEST_VERSION, "1.0"); - att.put(Attributes.Name.MAIN_CLASS, "foo.bar.execjartest.Foo"); - att.put(Attributes.Name.CLASS_PATH, barZip.getName()); - - File resources = Support_Resources.createTempFolder(); - - JarOutputStream joutFoo = new JarOutputStream(new FileOutputStream( - fooJar), man); - joutFoo.putNextEntry(new JarEntry("foo/bar/execjartest/Foo.class")); - joutFoo.write(getResource(resources, "hyts_Foo.ser")); - joutFoo.close(); - - ZipOutputStream zoutBar = new ZipOutputStream(new FileOutputStream( - barZip)); - zoutBar.putNextEntry(new ZipEntry("foo/bar/execjartest/Bar.class")); - zoutBar.write(getResource(resources, "hyts_Bar.ser")); - zoutBar.close(); - - String[] args = new String[] {"-jar", fooJar.getAbsolutePath()}; - - // execute the JAR and read the result - String res = Support_Exec.execJava(args, null, false); - - assertTrue("Error executing JAR : result returned was incorrect.", res - .startsWith("FOOBAR")); - } - - @TestTargetNew( - level = TestLevel.ADDITIONAL, - notes = "Functional test.", - method = "ZipOutputStream", - args = {java.io.OutputStream.class} - ) - @KnownFailure("Maybe not a failure, but dalvikvm -jar is not supported (, as yet).") - public void test_zip_jar_mix_1() throws Exception { - File fooZip = File.createTempFile("hyts_", ".zip"); - File barJar = File.createTempFile("hyts_", ".jar"); - fooZip.deleteOnExit(); - barJar.deleteOnExit(); - - // create the manifest - Manifest man = new Manifest(); - Attributes att = man.getMainAttributes(); - att.put(Attributes.Name.MANIFEST_VERSION, "1.0"); - att.put(Attributes.Name.MAIN_CLASS, "foo.bar.execjartest.Foo"); - att.put(Attributes.Name.CLASS_PATH, barJar.getName()); - - File resources = Support_Resources.createTempFolder(); - - ZipOutputStream zoutFoo = new ZipOutputStream(new FileOutputStream( - fooZip)); - zoutFoo.putNextEntry(new ZipEntry("META-INF/MANIFEST.MF")); - man.write(zoutFoo); - zoutFoo.putNextEntry(new ZipEntry("foo/bar/execjartest/Foo.class")); - zoutFoo.write(getResource(resources, "hyts_Foo.ser")); - zoutFoo.close(); - - JarOutputStream joutBar = new JarOutputStream(new FileOutputStream( - barJar)); - joutBar.putNextEntry(new ZipEntry("foo/bar/execjartest/Bar.class")); - joutBar.write(getResource(resources, "hyts_Bar.ser")); - joutBar.close(); - - String[] args = new String[] {"-jar", fooZip.getAbsolutePath()}; - - // execute the JAR and read the result - String res = Support_Exec.execJava(args, null, false); - - assertTrue("Error executing ZIP : result returned was incorrect.", res - .startsWith("FOOBAR")); - } - - /** - * tests case when Main-Class is not in the zip launched but in another zip - * referenced by Class-Path - * - * @throws Exception in case of troubles - */ - @TestTargetNew( - level = TestLevel.ADDITIONAL, - notes = "Functional test.", - method = "ZipOutputStream", - args = {java.io.OutputStream.class} - ) - @KnownFailure("Maybe not a failure, but dalvikvm -jar is not supported (, as yet).") - public void test_main_class_in_another_zip() throws Exception { - File fooZip = File.createTempFile("hyts_", ".zip"); - File barZip = File.createTempFile("hyts_", ".zip"); - fooZip.deleteOnExit(); - barZip.deleteOnExit(); - - // create the manifest - Manifest man = new Manifest(); - Attributes att = man.getMainAttributes(); - att.put(Attributes.Name.MANIFEST_VERSION, "1.0"); - att.put(Attributes.Name.MAIN_CLASS, "foo.bar.execjartest.Foo"); - att.put(Attributes.Name.CLASS_PATH, fooZip.getName()); - - File resources = Support_Resources.createTempFolder(); - - ZipOutputStream zoutFoo = new ZipOutputStream(new FileOutputStream( - fooZip)); - zoutFoo.putNextEntry(new ZipEntry("foo/bar/execjartest/Foo.class")); - zoutFoo.write(getResource(resources, "hyts_Foo.ser")); - zoutFoo.close(); - - ZipOutputStream zoutBar = new ZipOutputStream(new FileOutputStream( - barZip)); - zoutBar.putNextEntry(new ZipEntry("META-INF/MANIFEST.MF")); - man.write(zoutBar); - - zoutBar.putNextEntry(new ZipEntry("foo/bar/execjartest/Bar.class")); - zoutBar.write(getResource(resources, "hyts_Bar.ser")); - zoutBar.close(); - - String[] args = new String[] {"-jar", barZip.getAbsolutePath()}; - - // execute the JAR and read the result - String res = Support_Exec.execJava(args, null, false); - - assertTrue("Error executing JAR : result returned was incorrect.", res - .startsWith("FOOBAR")); - } - - - private static byte[] getResource(File tempDir, String resourceName) - throws IOException { - Support_Resources.copyFile(tempDir, null, resourceName); - File resourceFile = new File(tempDir, resourceName); - resourceFile.deleteOnExit(); - - // read whole resource data into memory - byte[] resourceBody = new byte[(int) resourceFile.length()]; - FileInputStream fis = new FileInputStream(resourceFile); - fis.read(resourceBody); - fis.close(); - - return resourceBody; - } - -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/Adler32Test.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/Adler32Test.java deleted file mode 100644 index 532a3a6fe..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/Adler32Test.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.zip; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.util.zip.Adler32; - -@TestTargetClass(Adler32.class) -public class Adler32Test extends junit.framework.TestCase { - - /** - * @tests java.util.zip.Adler32#Adler32() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "Adler32", - args = {} - ) - public void test_Constructor() { - // test method of java.util.zip.Adler32() - Adler32 adl = new Adler32(); - assertEquals("Constructor of adl32 failed", 1, adl.getValue()); - } - - /** - * @tests java.util.zip.Adler32#getValue() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getValue", - args = {} - ) - public void test_getValue() { - // test methods of java.util.zip.getValue() - Adler32 adl = new Adler32(); - assertEquals( - "GetValue should return a zero as a result of construction an object of Adler32", - 1, adl.getValue()); - - adl.reset(); - adl.update(1); - // System.out.print("value of adl"+adl.getValue()); - // The value of the adl should be 131074 - assertEquals( - "update(int) failed to update the checksum to the correct value ", - 131074, adl.getValue()); - adl.reset(); - assertEquals("reset failed to reset the checksum value to zero", 1, adl - .getValue()); - - adl.reset(); - adl.update(Integer.MIN_VALUE); - // System.out.print("value of adl " + adl.getValue()); - // The value of the adl should be 65537 - assertEquals( - "update(min) failed to update the checksum to the correct value ", - 65537L, adl.getValue()); - } - - /** - * @tests java.util.zip.Adler32#reset() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "reset", - args = {} - ) - public void test_reset() { - // test methods of java.util.zip.reset() - Adler32 adl = new Adler32(); - adl.update(1); - // System.out.print("value of adl"+adl.getValue()); - // The value of the adl should be 131074 - assertEquals( - "update(int) failed to update the checksum to the correct value ", - 131074, adl.getValue()); - adl.reset(); - assertEquals("reset failed to reset the checksum value to zero", 1, adl - .getValue()); - } - - /** - * @tests java.util.zip.Adler32#update(int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "update", - args = {int.class} - ) - public void test_updateI() { - // test methods of java.util.zip.update(int) - Adler32 adl = new Adler32(); - adl.update(1); - // The value of the adl should be 131074 - assertEquals( - "update(int) failed to update the checksum to the correct value ", - 131074, adl.getValue()); - - adl.reset(); - adl.update(Integer.MAX_VALUE); - // System.out.print("value of adl " + adl.getValue()); - // The value of the adl should be 16777472 - assertEquals( - "update(max) failed to update the checksum to the correct value ", - 16777472L, adl.getValue()); - - adl.reset(); - adl.update(Integer.MIN_VALUE); - // System.out.print("value of adl " + adl.getValue()); - // The value of the adl should be 65537 - assertEquals( - "update(min) failed to update the checksum to the correct value ", - 65537L, adl.getValue()); - - } - - /** - * @tests java.util.zip.Adler32#update(byte[]) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "update", - args = {byte[].class} - ) - public void test_update$B() { - // test method of java.util.zip.update(byte[]) - byte byteArray[] = {1, 2}; - Adler32 adl = new Adler32(); - adl.update(byteArray); - // System.out.print("value of adl"+adl.getValue()); - // The value of the adl should be 393220 - assertEquals( - "update(byte[]) failed to update the checksum to the correct value ", - 393220, adl.getValue()); - - adl.reset(); - byte byteEmpty[] = new byte[10000]; - adl.update(byteEmpty); - // System.out.print("value of adl"+adl.getValue()); - // The value of the adl should be 655360001 - assertEquals( - "update(byte[]) failed to update the checksum to the correct value ", - 655360001L, adl.getValue()); - - } - - /** - * @tests java.util.zip.Adler32#update(byte[], int, int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "update", - args = {byte[].class, int.class, int.class} - ) - public void test_update$BII() { - // test methods of java.util.zip.update(byte[],int,int) - byte[] byteArray = {1, 2, 3}; - Adler32 adl = new Adler32(); - int off = 2;// accessing the 2nd element of byteArray - int len = 1; - int lenError = 3; - int offError = 4; - adl.update(byteArray, off, len); - // System.out.print("value of adl"+adl.getValue()); - // The value of the adl should be 262148 - assertEquals( - "update(byte[],int,int) failed to update the checksum to the correct value ", - 262148, adl.getValue()); - int r = 0; - - try { - adl.update(byteArray, off, lenError); - } catch (ArrayIndexOutOfBoundsException e) { - r = 1; - } - assertEquals( - "update(byte[],int,int) failed b/c lenError>byte[].length-off", - 1, r); - - try { - adl.update(byteArray, offError, len); - } catch (ArrayIndexOutOfBoundsException e) { - r = 2; - } - assertEquals( - "update(byte[],int,int) failed b/c offError>byte[].length", 2, - r); - - } - - @Override - protected void setUp() { - } - - @Override - protected void tearDown() { - } - -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/AllTests.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/AllTests.java deleted file mode 100644 index acde88991..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/AllTests.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.zip; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Test suite for java.util.zip package. - */ -public class AllTests { - - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } - - public static Test suite() { - TestSuite suite = tests.TestSuiteFactory.createTestSuite( - "Suite org.apache.harmony.archive.tests.java.util.zip"); - // $JUnit-BEGIN$ - suite.addTestSuite(Adler32Test.class); - suite.addTestSuite(CheckedInputStreamTest.class); - suite.addTestSuite(CheckedOutputStreamTest.class); - suite.addTestSuite(CRC32Test.class); - suite.addTestSuite(DataFormatExceptionTest.class); - suite.addTestSuite(DeflaterOutputStreamTest.class); - suite.addTestSuite(DeflaterTest.class); - suite.addTestSuite(GZIPInputStreamTest.class); - suite.addTestSuite(GZIPOutputStreamTest.class); - suite.addTestSuite(InflaterInputStreamTest.class); - suite.addTestSuite(InflaterTest.class); - suite.addTestSuite(ZipEntryTest.class); - suite.addTestSuite(ZipExceptionTest.class); - suite.addTestSuite(ZipFileTest.class); - suite.addTestSuite(ZipInputStreamTest.class); - suite.addTestSuite(ZipOutputStreamTest.class); - // $JUnit-END$ - return suite; - } -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CRC32Test.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CRC32Test.java deleted file mode 100644 index 805cab345..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CRC32Test.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.zip; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.util.zip.CRC32; - -@TestTargetClass(CRC32.class) -public class CRC32Test extends junit.framework.TestCase { - - /** - * @tests java.util.zip.CRC32#CRC32() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "CRC32", - args = {} - ) - public void test_Constructor() { - // test methods of java.util.zip.CRC32() - CRC32 crc = new CRC32(); - assertEquals("Constructor of CRC32 failed", 0, crc.getValue()); - } - - /** - * @tests java.util.zip.CRC32#getValue() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getValue", - args = {} - ) - public void test_getValue() { - // test methods of java.util.zip.crc32.getValue() - CRC32 crc = new CRC32(); - assertEquals( - "getValue() should return a zero as a result of constructing a CRC32 instance", - 0, crc.getValue()); - - crc.reset(); - crc.update(Integer.MAX_VALUE); - // System.out.print("value of crc " + crc.getValue()); - // Ran JDK and discovered that the value of the CRC should be - // 4278190080 - assertEquals( - "update(max) failed to update the checksum to the correct value ", - 4278190080L, crc.getValue()); - - crc.reset(); - byte byteEmpty[] = new byte[10000]; - crc.update(byteEmpty); - // System.out.print("value of crc"+crc.getValue()); - // Ran JDK and discovered that the value of the CRC should be - // 1295764014 - assertEquals( - "update(byte[]) failed to update the checksum to the correct value ", - 1295764014L, crc.getValue()); - - crc.reset(); - crc.update(1); - // System.out.print("value of crc"+crc.getValue()); - // Ran JDK and discovered that the value of the CRC should be - // 2768625435 - // assertEquals("update(int) failed to update the checksum to the - // correct - // value ",2768625435L, crc.getValue()); - crc.reset(); - assertEquals("reset failed to reset the checksum value to zero", 0, crc - .getValue()); - } - - /** - * @tests java.util.zip.CRC32#reset() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "reset", - args = {} - ) - public void test_reset() { - // test methods of java.util.zip.crc32.reset() - CRC32 crc = new CRC32(); - crc.update(1); - // System.out.print("value of crc"+crc.getValue()); - // Ran JDK and discovered that the value of the CRC should be - // 2768625435 - assertEquals( - "update(int) failed to update the checksum to the correct value ", - 2768625435L, crc.getValue()); - crc.reset(); - assertEquals("reset failed to reset the checksum value to zero", 0, crc - .getValue()); - - } - - /** - * @tests java.util.zip.CRC32#update(int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "update", - args = {int.class} - ) - public void test_updateI() { - // test methods of java.util.zip.crc32.update(int) - CRC32 crc = new CRC32(); - crc.update(1); - // System.out.print("value of crc"+crc.getValue()); - // Ran JDK and discovered that the value of the CRC should be - // 2768625435 - assertEquals( - "update(1) failed to update the checksum to the correct value ", - 2768625435L, crc.getValue()); - - crc.reset(); - crc.update(Integer.MAX_VALUE); - // System.out.print("value of crc " + crc.getValue()); - // Ran JDK and discovered that the value of the CRC should be - // 4278190080 - assertEquals( - "update(max) failed to update the checksum to the correct value ", - 4278190080L, crc.getValue()); - - crc.reset(); - crc.update(Integer.MIN_VALUE); - // System.out.print("value of crc " + crc.getValue()); - // Ran JDK and discovered that the value of the CRC should be - // 3523407757 - assertEquals( - "update(min) failed to update the checksum to the correct value ", - 3523407757L, crc.getValue()); - } - - /** - * @tests java.util.zip.CRC32#update(byte[]) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "update", - args = {byte[].class} - ) - public void test_update$B() { - // test methods of java.util.zip.crc32.update(byte[]) - byte byteArray[] = {1, 2}; - CRC32 crc = new CRC32(); - crc.update(byteArray); - // System.out.print("value of crc"+crc.getValue()); - // Ran JDK and discovered that the value of the CRC should be - // 3066839698 - assertEquals( - "update(byte[]) failed to update the checksum to the correct value ", - 3066839698L, crc.getValue()); - - crc.reset(); - byte byteEmpty[] = new byte[10000]; - crc.update(byteEmpty); - // System.out.print("value of crc"+crc.getValue()); - // Ran JDK and discovered that the value of the CRC should be - // 1295764014 - assertEquals( - "update(byte[]) failed to update the checksum to the correct value ", - 1295764014L, crc.getValue()); - } - - /** - * @tests java.util.zip.CRC32#update(byte[], int, int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "update", - args = {byte[].class, int.class, int.class} - ) - public void test_update$BII() { - // test methods of java.util.zip.update(byte[],int,int) - byte[] byteArray = {1, 2, 3}; - CRC32 crc = new CRC32(); - int off = 2;// accessing the 2nd element of byteArray - int len = 1; - int lenError = 3; - int offError = 4; - crc.update(byteArray, off, len); - // System.out.print("value of crc"+crc.getValue()); - // Ran JDK and discovered that the value of the CRC should be - // 1259060791 - assertEquals( - "update(byte[],int,int) failed to update the checksum to the correct value ", - 1259060791L, crc.getValue()); - int r = 0; - try { - crc.update(byteArray, off, lenError); - } catch (ArrayIndexOutOfBoundsException e) { - r = 1; - } - assertEquals( - "update(byte[],int,int) failed b/c lenError>byte[].length-off", - 1, r); - - try { - crc.update(byteArray, offError, len); - } catch (ArrayIndexOutOfBoundsException e) { - r = 2; - } - assertEquals( - "update(byte[],int,int) failed b/c offError>byte[].length", 2, - r); - } - - @Override - protected void setUp() { - - } - - @Override - protected void tearDown() { - } - -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java deleted file mode 100644 index 4450bdfde..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.zip; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.zip.CRC32; -import java.util.zip.CheckedInputStream; -import junit.framework.TestCase; -import tests.support.resource.Support_Resources; - - -@TestTargetClass(CheckedInputStream.class) -public class CheckedInputStreamTest extends TestCase { - - /** - * @tests java.util.zip.CheckedInputStream#CheckedInputStream(java.io.InputStream, - * java.util.zip.Checksum) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "CheckedInputStream", - args = {java.io.InputStream.class, java.util.zip.Checksum.class} - ) - public void test_ConstructorLjava_io_InputStreamLjava_util_zip_Checksum() - throws Exception { - InputStream checkInput = Support_Resources - .getStream("hyts_checkInput.txt"); - CheckedInputStream checkIn = new CheckedInputStream(checkInput, - new CRC32()); - assertEquals("constructor of checkedInputStream has failed", 0, checkIn - .getChecksum().getValue()); - checkInput.close(); - } - - /** - * @tests java.util.zip.CheckedInputStream#getChecksum() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getChecksum", - args = {} - ) - public void test_getChecksum() throws Exception { - byte outBuf[] = new byte[100]; - // testing getChecksum for an empty file - File empty = File.createTempFile("empty", ".txt"); - empty.deleteOnExit(); - FileOutputStream outEmp = new FileOutputStream(empty); - outEmp.close(); - InputStream inEmp = new FileInputStream(empty); - CheckedInputStream checkEmpty = new CheckedInputStream(inEmp, - new CRC32()); - while (checkEmpty.read() >= 0) { - } - assertEquals("the checkSum value of an empty file is not zero", 0, - checkEmpty.getChecksum().getValue()); - inEmp.close(); - - // testing getChecksum for the file checkInput - InputStream checkInput = Support_Resources - .getStream("hyts_checkInput.txt"); - CheckedInputStream checkIn = new CheckedInputStream(checkInput, - new CRC32()); - while (checkIn.read() >= 0) { - } - // ran JDK and found that the checkSum value of this is 2036203193 - // System.out.print(" " + checkIn.getChecksum().getValue()); - assertEquals("the checksum value is incorrect", 2036203193, checkIn - .getChecksum().getValue()); - checkInput.close(); - // testing getChecksum for file checkInput - checkInput = Support_Resources.getStream("hyts_checkInput.txt"); - CheckedInputStream checkIn2 = new CheckedInputStream(checkInput, - new CRC32()); - checkIn2.read(outBuf, 0, 10); - // ran JDK and found that the checkSum value of this is 2235765342 - // System.out.print(" " + checkIn2.getChecksum().getValue()); - assertEquals("the checksum value is incorrect", 2235765342L, checkIn2 - .getChecksum().getValue()); - checkInput.close(); - } - - /** - * @tests java.util.zip.CheckedInputStream#skip(long) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "skip", - args = {long.class} - ) - public void test_skipJ() throws Exception { - // testing that the return by skip is valid - InputStream checkInput = Support_Resources - .getStream("hyts_checkInput.txt"); - CheckedInputStream checkIn = new CheckedInputStream(checkInput, - new CRC32()); - long skipValue = 5; - assertEquals( - "the value returned by skip(n) is not the same as its parameter", - skipValue, checkIn.skip(skipValue)); - checkIn.skip(skipValue); - // ran JDK and found the checkSum value is 2235765342 - // System.out.print(checkIn.getChecksum().getValue()); - assertEquals("checkSum value is not correct", 2235765342L, checkIn - .getChecksum().getValue()); - checkInput.close(); - try { - checkInput.skip(33); - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - } - - /** - * @tests java.util.zip.CheckedInputStream#read() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "read", - args = {} - ) - public void test_read() throws Exception { - // testing that the return by skip is valid - InputStream checkInput = Support_Resources - .getStream("hyts_checkInput.txt"); - CheckedInputStream checkIn = new CheckedInputStream(checkInput, - new CRC32()); - checkIn.read(); - checkIn.close(); - try { - checkIn.read(); - fail("IOException expected."); - } catch (IOException ee) { - // expected - } - long skipValue = 5; - checkInput.close(); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "read", - args = {byte[].class, int.class, int.class} - ) - public void test_read$byteII() throws Exception { - // testing that the return by skip is valid - InputStream checkInput = Support_Resources - .getStream("hyts_checkInput.txt"); - CheckedInputStream checkIn = new CheckedInputStream(checkInput, - new CRC32()); - byte buff[] = new byte[50]; - checkIn.read(buff, 10, 5); - checkIn.close(); - try { - checkIn.read(buff, 10, 5); - fail("IOException expected."); - } catch (IOException ee) { - // expected - } - long skipValue = 5; - checkInput.close(); - } -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedOutputStreamTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedOutputStreamTest.java deleted file mode 100644 index 31974d174..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedOutputStreamTest.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.zip; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.zip.Adler32; -import java.util.zip.CRC32; -import java.util.zip.CheckedOutputStream; - -@TestTargetClass(CheckedOutputStream.class) -public class CheckedOutputStreamTest extends junit.framework.TestCase { - - /** - * @tests java.util.zip.CheckedOutputStream#CheckedOutputStream(java.io.OutputStream, - * java.util.zip.Checksum) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "CheckedOutputStream", - args = {java.io.OutputStream.class, java.util.zip.Checksum.class} - ) - public void test_ConstructorLjava_io_OutputStreamLjava_util_zip_Checksum() { - // test method java.util.zip.checkedOutputStream.constructor - try { - FileOutputStream outFile = new FileOutputStream( - File.createTempFile("chkOut", ".txt")); - CheckedOutputStream chkOut = new CheckedOutputStream(outFile, - new CRC32()); - assertEquals("the checkSum value of the constructor is not 0", 0, - chkOut.getChecksum().getValue()); - outFile.close(); - } catch (IOException e) { - fail("Unable to find file"); - } catch (SecurityException e) { - fail("file cannot be opened for writing due to security reasons"); - } - } - - /** - * @tests java.util.zip.CheckedOutputStream#getChecksum() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getChecksum", - args = {} - ) - public void test_getChecksum() { - // test method java.util.zip.checkedOutputStream.getChecksum() - byte byteArray[] = {1, 2, 3, 'e', 'r', 't', 'g', 3, 6}; - try { - FileOutputStream outFile = new FileOutputStream( - File.createTempFile("chkOut", ".txt")); - CheckedOutputStream chkOut = new CheckedOutputStream(outFile, - new Adler32()); - chkOut.write(byteArray[4]); - // ran JDK and found that checkSum value is 7536755 - // System.out.print(chkOut.getChecksum().getValue()); - - assertEquals("the checkSum value for writeI is incorrect", 7536755, - chkOut.getChecksum().getValue()); - chkOut.getChecksum().reset(); - chkOut.write(byteArray, 5, 4); - // ran JDK and found that checkSum value is 51708133 - // System.out.print(" " +chkOut.getChecksum().getValue()); - - assertEquals("the checkSum value for writeBII is incorrect ", - 51708133, chkOut.getChecksum().getValue()); - outFile.close(); - } catch (IOException e) { - fail("Unable to find file"); - } catch (SecurityException e) { - fail("file cannot be opened for writing due to security reasons"); - } - } - - /** - * @tests java.util.zip.CheckedOutputStream#write(int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "write", - args = {int.class} - ) - public void test_writeI() { - // test method java.util.zip.checkedOutputStream.writeI() - CheckedOutputStream chkOut = null; - byte byteArray[] = {1, 2, 3, 'e', 'r', 't', 'g', 3, 6}; - try { - FileOutputStream outFile = new FileOutputStream( - File.createTempFile("chkOut", ".txt")); - chkOut = new CheckedOutputStream(outFile, new CRC32()); - for (byte element : byteArray) { - chkOut.write(element); - } - assertTrue( - "the checkSum value is zero, no bytes are written to the output file", - chkOut.getChecksum().getValue() != 0); - outFile.close(); - } catch (IOException e) { - fail("Unable to find file"); - } catch (SecurityException e) { - fail("File cannot be opened for writing due to security reasons"); - } - try { - chkOut.write(0); - fail("IOException expected"); - } catch (IOException e) { - // expected. - } - } - - /** - * @tests java.util.zip.CheckedOutputStream#write(byte[], int, int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "write", - args = {byte[].class, int.class, int.class} - ) - public void test_write$BII() { - // test method java.util.zip.checkOutputStream.writeBII() - CheckedOutputStream chkOut = null; - byte byteArray[] = {1, 2, 3, 'e', 'r', 't', 'g', 3, 6}; - try { - FileOutputStream outFile = new FileOutputStream( - File.createTempFile("chkOut", ".txt")); - chkOut = new CheckedOutputStream(outFile, new CRC32()); - chkOut.write(byteArray, 4, 5); - assertTrue( - "the checkSum value is zero, no bytes are written to the output file", - chkOut.getChecksum().getValue() != 0); - int r = 0; - try { - chkOut.write(byteArray, 4, 6); - } catch (IndexOutOfBoundsException e) { - r = 1; - } - assertEquals("boundary check is not performed", 1, r); - outFile.close(); - } catch (IOException e) { - fail("Unable to find file"); - } catch (SecurityException e) { - fail("file cannot be opened for writing due to security reasons"); - } catch (IndexOutOfBoundsException e) { - fail("Index for write is out of bounds"); - } - try { - chkOut.write(byteArray, 4, 5); - fail("IOException expected"); - } catch (IOException e) { - // expected - } - } - - @Override - protected void setUp() { - } - - @Override - protected void tearDown() { - try { - File deletedFile = new File("chkOut.txt"); - deletedFile.delete(); - } catch (SecurityException e) { - fail("Cannot delete file for security reasons"); - } - } - -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DataFormatExceptionTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DataFormatExceptionTest.java deleted file mode 100644 index 6561bbd7a..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DataFormatExceptionTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.zip; - -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import junit.framework.TestCase; - -import java.util.zip.DataFormatException; - -@TestTargetClass(DataFormatException.class) -public class DataFormatExceptionTest extends TestCase { - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "DataFormatException", - args = {} - ) - public void testDataFormatException() { - DataFormatException dfe = new DataFormatException(); - assertEquals(dfe.getMessage(), null); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "DataFormatException", - args = {java.lang.String.class} - ) - public void testDataFormatExceptionString() { - DataFormatException dfe = new DataFormatException("Test"); - assertEquals(dfe.getMessage(), "Test"); - } - -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java deleted file mode 100644 index 738f61020..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java +++ /dev/null @@ -1,462 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.zip; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.io.EOFException; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.zip.Deflater; -import java.util.zip.DeflaterOutputStream; -import java.util.zip.InflaterInputStream; - -import junit.framework.TestCase; - -@TestTargetClass(DeflaterOutputStream.class) -public class DeflaterOutputStreamTest extends TestCase { - - private class MyDeflaterOutputStream extends DeflaterOutputStream { - boolean deflateFlag = false; - - MyDeflaterOutputStream(OutputStream out) { - super(out); - } - - MyDeflaterOutputStream(OutputStream out, Deflater defl) { - super(out, defl); - } - - MyDeflaterOutputStream(OutputStream out, Deflater defl, int size) { - super(out, defl, size); - } - - byte[] getProtectedBuf() { - return buf; - } - - protected void deflate() throws IOException { - deflateFlag = true; - super.deflate(); - } - - boolean getDaflateFlag() { - return deflateFlag; - } - - void cleanDaflateFlag() { - deflateFlag = false; - } - } - - private byte outPutBuf[] = new byte[500]; - - @Override - protected void setUp() { - // setting up a deflater to be used - byte byteArray[] = {1, 3, 4, 7, 8}; - int x = 0; - Deflater deflate = new Deflater(1); - deflate.setInput(byteArray); - while (!(deflate.needsInput())) { - x += deflate.deflate(outPutBuf, x, outPutBuf.length - x); - } - deflate.finish(); - while (!(deflate.finished())) { - x = x + deflate.deflate(outPutBuf, x, outPutBuf.length - x); - } - deflate.end(); - } - - /** - * @tests java.util.zip.DeflaterOutputStream#DeflaterOutputStream(java.io.OutputStream, - * java.util.zip.Deflater) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "DeflaterOutputStream", - args = {java.io.OutputStream.class, java.util.zip.Deflater.class} - ) - public void test_ConstructorLjava_io_OutputStreamLjava_util_zip_Deflater() - throws Exception { - byte byteArray[] = {1, 3, 4, 7, 8}; - File f1 = File.createTempFile("hyts_Constru_OD", ".tst"); - FileOutputStream fos = new FileOutputStream(f1); - Deflater defl = null; - MyDeflaterOutputStream dos; - // Test for a null Deflater. - try { - dos = new MyDeflaterOutputStream(fos, defl); - fail("NullPointerException Not Thrown"); - } catch (NullPointerException e) { - } - defl = new Deflater(); - dos = new MyDeflaterOutputStream(fos, defl); - - // Test to see if DeflaterOutputStream was created with the correct - // buffer. - assertEquals("Incorrect Buffer Size", 512, dos.getProtectedBuf().length); - - dos.write(byteArray); - dos.close(); - f1.delete(); - } - - /** - * @tests java.util.zip.DeflaterOutputStream#DeflaterOutputStream(java.io.OutputStream) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "DeflaterOutputStream", - args = {java.io.OutputStream.class} - ) - public void test_ConstructorLjava_io_OutputStream() throws Exception { - File f1 = File.createTempFile("hyts_Constru_O", ".tst"); - FileOutputStream fos = new FileOutputStream(f1); - MyDeflaterOutputStream dos = new MyDeflaterOutputStream(fos); - - // Test to see if DeflaterOutputStream was created with the correct - // buffer. - assertEquals("Incorrect Buffer Size", 512, dos.getProtectedBuf().length); - - dos.write(outPutBuf); - dos.close(); - f1.delete(); - } - - /** - * @tests java.util.zip.DeflaterOutputStream#DeflaterOutputStream(java.io.OutputStream, - * java.util.zip.Deflater, int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "DeflaterOutputStream", - args = {java.io.OutputStream.class, java.util.zip.Deflater.class, int.class} - ) - public void test_ConstructorLjava_io_OutputStreamLjava_util_zip_DeflaterI() - throws Exception { - int buf = 5; - int negBuf = -5; - int zeroBuf = 0; - byte byteArray[] = {1, 3, 4, 7, 8, 3, 6}; - File f1 = File.createTempFile("hyts_Constru_ODI", ".tst"); - FileOutputStream fos = new FileOutputStream(f1); - Deflater defl = null; - MyDeflaterOutputStream dos; - - // Test for a null Deflater. - try { - dos = new MyDeflaterOutputStream(fos, defl, buf); - fail("NullPointerException Not Thrown"); - } catch (NullPointerException e) { - } - defl = new Deflater(); - - // Test for a negative buf. - try { - dos = new MyDeflaterOutputStream(fos, defl, negBuf); - fail("IllegalArgumentException Not Thrown"); - } catch (IllegalArgumentException e) { - } - - // Test for a zero buf. - try { - dos = new MyDeflaterOutputStream(fos, defl, zeroBuf); - fail("IllegalArgumentException Not Thrown"); - } catch (IllegalArgumentException e) { - } - - // Test to see if DeflaterOutputStream was created with the correct - // buffer. - dos = new MyDeflaterOutputStream(fos, defl, buf); - assertEquals("Incorrect Buffer Size", 5, dos.getProtectedBuf().length); - - dos.write(byteArray); - dos.close(); - f1.delete(); - } - - /** - * @tests java.util.zip.DeflaterOutputStream#close() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "IOException can not be checked.", - method = "close", - args = {} - ) - public void test_close() throws Exception { - File f1 = File.createTempFile("close", ".tst"); - - InflaterInputStream iis = new InflaterInputStream(new FileInputStream(f1)); - try { - iis.read(); - fail("EOFException Not Thrown"); - } catch (EOFException e) { - } - - FileOutputStream fos = new FileOutputStream(f1); - DeflaterOutputStream dos = new DeflaterOutputStream(fos); - byte byteArray[] = {1, 3, 4, 6}; - dos.write(byteArray); - dos.close(); - - iis = new InflaterInputStream(new FileInputStream(f1)); - - // Test to see if the finish method wrote the bytes to the file. - assertEquals("Incorrect Byte Returned.", 1, iis.read()); - assertEquals("Incorrect Byte Returned.", 3, iis.read()); - assertEquals("Incorrect Byte Returned.", 4, iis.read()); - assertEquals("Incorrect Byte Returned.", 6, iis.read()); - assertEquals("Incorrect Byte Returned.", -1, iis.read()); - assertEquals("Incorrect Byte Returned.", -1, iis.read()); - iis.close(); - - // Not sure if this test will stay. - FileOutputStream fos2 = new FileOutputStream(f1); - DeflaterOutputStream dos2 = new DeflaterOutputStream(fos2); - fos2.close(); - try { - dos2.close(); - fail("IOException not thrown"); - } catch (IOException e) { - } - - // Test to write to a closed DeflaterOutputStream - try { - dos.write(5); - fail("DeflaterOutputStream Able To Write After Being Closed."); - } catch (IOException e) { - } - - // Test to write to a FileOutputStream that should have been closed - // by - // the DeflaterOutputStream. - try { - fos.write(("testing").getBytes()); - fail("FileOutputStream Able To Write After Being Closed."); - } catch (IOException e) { - } - - f1.delete(); - } - - /** - * @tests java.util.zip.DeflaterOutputStream#finish() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "finish", - args = {} - ) - public void test_finish() throws Exception { - // Need test to see if method finish() actually finishes - // Only testing possible errors, not if it actually works - - File f1 = File.createTempFile("finish", ".tst"); - FileOutputStream fos1 = new FileOutputStream(f1); - DeflaterOutputStream dos = new DeflaterOutputStream(fos1); - byte byteArray[] = {1, 3, 4, 6}; - dos.write(byteArray); - dos.finish(); - - // Test to see if the same FileOutputStream can be used with the - // DeflaterOutputStream after finish is called. - try { - dos.write(1); - fail("IOException not thrown"); - } catch (IOException e) { - } - - // Test for writing with a new FileOutputStream using the same - // DeflaterOutputStream. - FileOutputStream fos2 = new FileOutputStream(f1); - dos = new DeflaterOutputStream(fos2); - dos.write(1); - - // Test for writing to FileOutputStream fos1, which should be open. - fos1.write(("testing").getBytes()); - - // Test for writing to FileOutputStream fos2, which should be open. - fos2.write(("testing").getBytes()); - - // Not sure if this test will stay. - FileOutputStream fos3 = new FileOutputStream(f1); - DeflaterOutputStream dos3 = new DeflaterOutputStream(fos3); - fos3.close(); - try { - dos3.finish(); - fail("IOException not thrown"); - } catch (IOException e) { - } - - // dos.close() won't close fos1 because it has been re-assigned to - // fos2 - fos1.close(); - dos.close(); - f1.delete(); - } - - /** - * @tests java.util.zip.DeflaterOutputStream#write(int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "write", - args = {int.class} - ) - public void test_writeI() throws Exception { - File f1 = File.createTempFile("writeI1", ".tst"); - FileOutputStream fos = new FileOutputStream(f1); - DeflaterOutputStream dos = new DeflaterOutputStream(fos); - for (int i = 0; i < 3; i++) { - dos.write(i); - } - dos.close(); - FileInputStream fis = new FileInputStream(f1); - InflaterInputStream iis = new InflaterInputStream(fis); - for (int i = 0; i < 3; i++) { - assertEquals("Incorrect Byte Returned.", i, iis.read()); - } - assertEquals("Incorrect Byte Returned (EOF).", -1, iis.read()); - assertEquals("Incorrect Byte Returned (EOF).", -1, iis.read()); - iis.close(); - - // Not sure if this test is that important. - // Checks to see if you can write using the DeflaterOutputStream - // after - // the FileOutputStream has been closed. - FileOutputStream fos2 = new FileOutputStream(f1); - DeflaterOutputStream dos2 = new DeflaterOutputStream(fos2); - fos2.close(); - try { - dos2.write(2); - fail("IOException not thrown"); - } catch (IOException e) { - } - - f1.delete(); - } - - /** - * @tests java.util.zip.DeflaterOutputStream#write(byte[], int, int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "write", - args = {byte[].class, int.class, int.class} - ) - public void test_write$BII() throws Exception { - byte byteArray[] = {1, 3, 4, 7, 8, 3, 6}; - - // Test to see if the correct bytes are saved. - File f1 = File.createTempFile("writeBII", ".tst"); - FileOutputStream fos1 = new FileOutputStream(f1); - DeflaterOutputStream dos1 = new DeflaterOutputStream(fos1); - dos1.write(byteArray, 2, 3); - dos1.close(); - FileInputStream fis = new FileInputStream(f1); - InflaterInputStream iis = new InflaterInputStream(fis); - assertEquals("Incorrect Byte Returned.", 4, iis.read()); - assertEquals("Incorrect Byte Returned.", 7, iis.read()); - assertEquals("Incorrect Byte Returned.", 8, iis.read()); - assertEquals("Incorrect Byte Returned (EOF).", -1, iis.read()); - assertEquals("Incorrect Byte Returned (EOF).", -1, iis.read()); - iis.close(); - f1.delete(); - - // Test for trying to write more bytes than available from the array - File f2 = File.createTempFile("writeBII", ".tst"); - FileOutputStream fos2 = new FileOutputStream(f2); - DeflaterOutputStream dos2 = new DeflaterOutputStream(fos2); - try { - dos2.write(byteArray, 2, 10); - fail("IndexOutOfBoundsException not thrown"); - } catch (IndexOutOfBoundsException e) { - } - - // Test for trying to write a negative number of bytes. - try { - dos2.write(byteArray, 2, Integer.MIN_VALUE); - fail("IndexOutOfBoundsException not thrown"); - } catch (IndexOutOfBoundsException e) { - } - - // Test for trying to start writing from a byte < 0 from the array. - try { - dos2.write(byteArray, Integer.MIN_VALUE, 2); - fail("IndexOutOfBoundsException not thrown"); - } catch (IndexOutOfBoundsException e) { - } - - // Test for trying to start writing from a byte > than the array - // size. - try { - dos2.write(byteArray, 10, 2); - fail("IndexOutOfBoundsException not thrown"); - } catch (IndexOutOfBoundsException e) { - } - dos2.close(); - - // Not sure if this test is that important. - // Checks to see if you can write using the DeflaterOutputStream - // after - // the FileOutputStream has been closed. - FileOutputStream fos3 = new FileOutputStream(f2); - DeflaterOutputStream dos3 = new DeflaterOutputStream(fos3); - fos3.close(); - try { - dos3.write(byteArray, 2, 3); - fail("IOException not thrown"); - } catch (IOException e) { - } - - f2.delete(); - } - - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "deflate", - args = {} - ) - public void test_deflate() throws Exception { - File f1 = File.createTempFile("writeI1", ".tst"); - FileOutputStream fos = new FileOutputStream(f1); - MyDeflaterOutputStream dos = new MyDeflaterOutputStream(fos); - assertFalse(dos.getDaflateFlag()); - for (int i = 0; i < 3; i++) { - dos.write(i); - } - assertTrue(dos.getDaflateFlag()); - dos.close(); - } -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterTest.java deleted file mode 100644 index ae77450e1..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterTest.java +++ /dev/null @@ -1,1243 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.zip; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.util.zip.Adler32; - -import java.util.zip.DataFormatException; -import java.util.zip.Deflater; -import java.util.zip.Inflater; - -import junit.framework.TestCase; -import tests.support.resource.Support_Resources; - -@TestTargetClass(Deflater.class) -public class DeflaterTest extends TestCase { - - class MyDeflater extends Deflater { - MyDeflater() { - super(); - } - - MyDeflater(int lvl) { - super(lvl); - } - - MyDeflater(int lvl, boolean noHeader) { - super(lvl, noHeader); - } - - void myFinalize() { - finalize(); - } - - int getDefCompression() { - return DEFAULT_COMPRESSION; - } - - int getDefStrategy() { - return DEFAULT_STRATEGY; - } - - int getHuffman() { - return HUFFMAN_ONLY; - } - - int getFiltered() { - return FILTERED; - } - } - - /** - * @tests java.util.zip.Deflater#deflate(byte[]) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "deflate", - args = {byte[].class} - ) - public void test_deflate$B() { - byte outPutBuf[] = new byte[50]; - byte byteArray[] = {1, 3, 4, 7, 8}; - byte outPutInf[] = new byte[50]; - int x = 0; - - Deflater defl = new Deflater(); - defl.setInput(byteArray); - defl.finish(); - while (!defl.finished()) { - x += defl.deflate(outPutBuf); - } - assertEquals("Deflater at end of stream, should return 0", 0, defl - .deflate(outPutBuf)); - int totalOut = defl.getTotalOut(); - int totalIn = defl.getTotalIn(); - assertEquals(x, totalOut); - assertEquals(byteArray.length, totalIn); - defl.end(); - - Inflater infl = new Inflater(); - try { - infl.setInput(outPutBuf); - while (!infl.finished()) { - infl.inflate(outPutInf); - } - } catch (DataFormatException e) { - fail("Invalid input to be decompressed"); - } - assertEquals(totalIn, infl.getTotalOut()); - assertEquals(totalOut, infl.getTotalIn()); - for (int i = 0; i < byteArray.length; i++) { - assertEquals(byteArray[i], outPutInf[i]); - } - assertEquals( - "Final decompressed data contained more bytes than original", - 0, outPutInf[byteArray.length]); - infl.end(); - } - - /** - * @tests java.util.zip.Deflater#deflate(byte[], int, int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "deflate", - args = {byte[].class, int.class, int.class} - ) - public void test_deflate$BII() { - byte outPutBuf[] = new byte[50]; - byte byteArray[] = {5, 2, 3, 7, 8}; - byte outPutInf[] = new byte[50]; - int offSet = 1; - int length = outPutBuf.length - 1; - int x = 0; - - Deflater defl = new Deflater(); - defl.setInput(byteArray); - defl.finish(); - while (!defl.finished()) { - x += defl.deflate(outPutBuf, offSet, length); - } - assertEquals("Deflater at end of stream, should return 0", 0, defl - .deflate(outPutBuf, offSet, length)); - int totalOut = defl.getTotalOut(); - int totalIn = defl.getTotalIn(); - assertEquals(x, totalOut); - assertEquals(byteArray.length, totalIn); - defl.end(); - - Inflater infl = new Inflater(); - try { - infl.setInput(outPutBuf, offSet, length); - while (!infl.finished()) { - infl.inflate(outPutInf); - } - } catch (DataFormatException e) { - fail("Invalid input to be decompressed"); - } - assertEquals(totalIn, infl.getTotalOut()); - assertEquals(totalOut, infl.getTotalIn()); - for (int i = 0; i < byteArray.length; i++) { - assertEquals(byteArray[i], outPutInf[i]); - } - assertEquals( - "Final decompressed data contained more bytes than original", - 0, outPutInf[byteArray.length]); - infl.end(); - - // Set of tests testing the boundaries of the offSet/length - defl = new Deflater(); - outPutBuf = new byte[100]; - defl.setInput(byteArray); - for (int i = 0; i < 2; i++) { - if (i == 0) { - offSet = outPutBuf.length + 1; - length = outPutBuf.length; - } else { - offSet = 0; - length = outPutBuf.length + 1; - } - try { - defl.deflate(outPutBuf, offSet, length); - fail("Test " + i - + ": ArrayIndexOutOfBoundsException not thrown"); - } catch (ArrayIndexOutOfBoundsException e) { - } - } - defl.end(); - } - - /** - * @tests java.util.zip.Deflater#end() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "end", - args = {} - ) - public void test_end() { - byte byteArray[] = {5, 2, 3, 7, 8}; - byte outPutBuf[] = new byte[100]; - - Deflater defl = new Deflater(); - defl.setInput(byteArray); - defl.finish(); - while (!defl.finished()) { - defl.deflate(outPutBuf); - } - defl.end(); - helper_end_test(defl, "end"); - } - - /** - * @tests java.util.zip.Deflater#finalize() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "finalize", - args = {} - ) - public void test_finalize() { - MyDeflater mdefl = new MyDeflater(); - mdefl.myFinalize(); - System.gc(); - helper_end_test(mdefl, "finalize"); - } - - /** - * @tests java.util.zip.Deflater#finish() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "finish", - args = {} - ) - public void test_finish() throws Exception { - // This test already here, its the same as test_deflate() - byte byteArray[] = {5, 2, 3, 7, 8}; - byte outPutBuf[] = new byte[100]; - byte outPutInf[] = new byte[100]; - int x = 0; - Deflater defl = new Deflater(); - defl.setInput(byteArray); - defl.finish(); - - // needsInput should never return true after finish() is called - if (System.getProperty("java.vendor").startsWith("IBM")) { - assertFalse( - "needsInput() should return false after finish() is called", - defl.needsInput()); - } - - while (!defl.finished()) { - x += defl.deflate(outPutBuf); - } - int totalOut = defl.getTotalOut(); - int totalIn = defl.getTotalIn(); - assertEquals(x, totalOut); - assertEquals(byteArray.length, totalIn); - defl.end(); - - Inflater infl = new Inflater(); - infl.setInput(outPutBuf); - while (!infl.finished()) { - infl.inflate(outPutInf); - } - assertEquals(totalIn, infl.getTotalOut()); - assertEquals(totalOut, infl.getTotalIn()); - for (int i = 0; i < byteArray.length; i++) { - assertEquals(byteArray[i], outPutInf[i]); - } - assertEquals( - "Final decompressed data contained more bytes than original", - 0, outPutInf[byteArray.length]); - infl.end(); - } - - /** - * @tests java.util.zip.Deflater#finished() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "finished", - args = {} - ) - public void test_finished() { - byte byteArray[] = {5, 2, 3, 7, 8}; - byte outPutBuf[] = new byte[100]; - Deflater defl = new Deflater(); - assertTrue("Test 1: Deflater should not be finished.", !defl.finished()); - defl.setInput(byteArray); - assertTrue("Test 2: Deflater should not be finished.", !defl.finished()); - defl.finish(); - assertTrue("Test 3: Deflater should not be finished.", !defl.finished()); - while (!defl.finished()) { - defl.deflate(outPutBuf); - } - assertTrue("Test 4: Deflater should be finished.", defl.finished()); - defl.end(); - assertTrue("Test 5: Deflater should be finished.", defl.finished()); - } - - /** - * @tests java.util.zip.Deflater#getAdler() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getAdler", - args = {} - ) - public void test_getAdler() { - byte byteArray[] = {'a', 'b', 'c', 1, 2, 3}; - byte outPutBuf[] = new byte[100]; - Deflater defl = new Deflater(); - - // getting the checkSum value using the Adler - defl.setInput(byteArray); - defl.finish(); - while (!defl.finished()) { - defl.deflate(outPutBuf); - } - long checkSumD = defl.getAdler(); - defl.end(); - - // getting the checkSum value through the Adler32 class - Adler32 adl = new Adler32(); - adl.update(byteArray); - long checkSumR = adl.getValue(); - assertEquals( - "The checksum value returned by getAdler() is not the same as the checksum returned by creating the adler32 instance", - checkSumD, checkSumR); - } - - /** - * @tests java.util.zip.Deflater#getTotalIn() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getTotalIn", - args = {} - ) - public void test_getTotalIn() { - byte outPutBuf[] = new byte[5]; - byte byteArray[] = {1, 3, 4, 7, 8}; - - Deflater defl = new Deflater(); - defl.setInput(byteArray); - defl.finish(); - while (!defl.finished()) { - defl.deflate(outPutBuf); - } - assertEquals(byteArray.length, defl.getTotalIn()); - defl.end(); - - defl = new Deflater(); - int offSet = 2; - int length = 3; - outPutBuf = new byte[5]; - defl.setInput(byteArray, offSet, length); - defl.finish(); - while (!defl.finished()) { - defl.deflate(outPutBuf); - } - assertEquals(length, defl.getTotalIn()); - defl.end(); - } - - /** - * @tests java.util.zip.Deflater#getTotalOut() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getTotalOut", - args = {} - ) - public void test_getTotalOut() { - // the getTotalOut should equal the sum of value returned by deflate() - byte outPutBuf[] = new byte[5]; - byte byteArray[] = {5, 2, 3, 7, 8}; - int x = 0; - Deflater defl = new Deflater(); - defl.setInput(byteArray); - defl.finish(); - while (!defl.finished()) { - x += defl.deflate(outPutBuf); - } - assertEquals(x, defl.getTotalOut()); - defl.end(); - - x = 0; - int offSet = 2; - int length = 3; - defl = new Deflater(); - outPutBuf = new byte[5]; - defl.setInput(byteArray, offSet, length); - defl.finish(); - while (!defl.finished()) { - x += defl.deflate(outPutBuf); - } - assertEquals(x, defl.getTotalOut()); - } - - /** - * @tests java.util.zip.Deflater#needsInput() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "needsInput", - args = {} - ) - public void test_needsInput() { - Deflater defl = new Deflater(); - assertTrue( - "needsInput give the wrong boolean value as a result of no input buffer", - defl.needsInput()); - byte byteArray[] = {1, 2, 3}; - defl.setInput(byteArray); - assertFalse( - "needsInput give wrong boolean value as a result of a full input buffer", - defl.needsInput()); - byte[] outPutBuf = new byte[50]; - while (!defl.needsInput()) { - defl.deflate(outPutBuf); - } - byte emptyByteArray[] = new byte[0]; - defl.setInput(emptyByteArray); - assertTrue( - "needsInput give wrong boolean value as a result of an empty input buffer", - defl.needsInput()); - defl.setInput(byteArray); - defl.finish(); - while (!defl.finished()) { - defl.deflate(outPutBuf); - } - // needsInput should NOT return true after finish() has been - // called. - if (System.getProperty("java.vendor").startsWith("IBM")) { - assertFalse( - "needsInput gave wrong boolean value as a result of finish() being called", - defl.needsInput()); - } - defl.end(); - } - - /** - * @tests java.util.zip.Deflater#reset() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "reset", - args = {} - ) - public void test_reset() { - byte outPutBuf[] = new byte[100]; - byte outPutInf[] = new byte[100]; - byte curArray[] = new byte[5]; - byte byteArray[] = {1, 3, 4, 7, 8}; - byte byteArray2[] = {8, 7, 4, 3, 1}; - int x = 0; - int orgValue = 0; - Deflater defl = new Deflater(); - - for (int i = 0; i < 3; i++) { - if (i == 0) { - curArray = byteArray; - } else if (i == 1) { - curArray = byteArray2; - } else { - defl.reset(); - } - - defl.setInput(curArray); - defl.finish(); - while (!defl.finished()) { - x += defl.deflate(outPutBuf); - } - - if (i == 0) { - assertEquals(x, defl.getTotalOut()); - } else if (i == 1) { - assertEquals(x, orgValue); - } else { - assertEquals(x, orgValue * 2); - } - - if (i == 0) { - orgValue = x; - } - - try { - Inflater infl = new Inflater(); - infl.setInput(outPutBuf); - while (!infl.finished()) { - infl.inflate(outPutInf); - } - infl.end(); - } catch (DataFormatException e) { - fail("Test " + i + ": Invalid input to be decompressed"); - } - - if (i == 1) { - curArray = byteArray; - } - - for (int j = 0; j < curArray.length; j++) { - assertEquals(curArray[j], outPutInf[j]); - } - assertEquals(0, outPutInf[curArray.length]); - } - } - - /** - * @tests java.util.zip.Deflater#setDictionary(byte[]) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setDictionary", - args = {byte[].class} - ) - public void test_setDictionary$B() { - // This test is very close to getAdler() - byte dictionaryArray[] = {'e', 'r', 't', 'a', 'b', 2, 3}; - byte byteArray[] = { - 4, 5, 3, 2, 'a', 'b', 6, 7, 8, 9, 0, 's', '3', 'w', 'r'}; - byte outPutBuf[] = new byte[100]; - - Deflater defl = new Deflater(); - long deflAdler = defl.getAdler(); - assertEquals( - "No dictionary set, no data deflated, getAdler should return 1", - 1, deflAdler); - defl.setDictionary(dictionaryArray); - deflAdler = defl.getAdler(); - - // getting the checkSum value through the Adler32 class - Adler32 adl = new Adler32(); - adl.update(dictionaryArray); - long realAdler = adl.getValue(); - assertEquals(deflAdler, realAdler); - - defl.setInput(byteArray); - defl.finish(); - while (!defl.finished()) { - defl.deflate(outPutBuf); - } - deflAdler = defl.getAdler(); - adl = new Adler32(); - adl.update(byteArray); - realAdler = adl.getValue(); - // Deflate is finished and there were bytes deflated that did not occur - // in the dictionaryArray, therefore a new dictionary was automatically - // set. - assertEquals(realAdler, deflAdler); - defl.end(); - } - - /** - * @tests java.util.zip.Deflater#setDictionary(byte[], int, int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setDictionary", - args = {byte[].class, int.class, int.class} - ) - public void test_setDictionary$BII() { - // This test is very close to getAdler() - byte dictionaryArray[] = {'e', 'r', 't', 'a', 'b', 2, 3, 'o', 't'}; - byte byteArray[] = { - 4, 5, 3, 2, 'a', 'b', 6, 7, 8, 9, 0, 's', '3', 'w', 'r', 't', - 'u', 'i', 'o', 4, 5, 6, 7}; - byte outPutBuf[] = new byte[500]; - - int offSet = 4; - int length = 5; - - Deflater defl = new Deflater(); - long deflAdler = defl.getAdler(); - assertEquals( - "No dictionary set, no data deflated, getAdler should return 1", - 1, deflAdler); - defl.setDictionary(dictionaryArray, offSet, length); - deflAdler = defl.getAdler(); - - // getting the checkSum value through the Adler32 class - Adler32 adl = new Adler32(); - adl.update(dictionaryArray, offSet, length); - long realAdler = adl.getValue(); - assertEquals(deflAdler, realAdler); - - defl.setInput(byteArray); - while (!defl.needsInput()) { - defl.deflate(outPutBuf); - } - deflAdler = defl.getAdler(); - adl = new Adler32(); - adl.update(byteArray); - realAdler = adl.getValue(); - // Deflate is finished and there were bytes deflated that did not occur - // in the dictionaryArray, therefore a new dictionary was automatically - // set. - assertEquals(realAdler, deflAdler); - defl.end(); - - // boundary check - defl = new Deflater(); - for (int i = 0; i < 2; i++) { - if (i == 0) { - offSet = 0; - length = dictionaryArray.length + 1; - } else { - offSet = dictionaryArray.length + 1; - length = 1; - } - try { - defl.setDictionary(dictionaryArray, offSet, length); - fail("Test " - + i - + ": boundary check for setDictionary failed for offset " - + offSet + " and length " + length); - } catch (ArrayIndexOutOfBoundsException e) { - } - } - } - - /** - * @tests java.util.zip.Deflater#setInput(byte[]) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setInput", - args = {byte[].class} - ) - public void test_setInput$B() { - byte[] byteArray = {1, 2, 3}; - byte[] outPutBuf = new byte[50]; - byte[] outPutInf = new byte[50]; - - Deflater defl = new Deflater(); - defl.setInput(byteArray); - assertTrue("the array buffer in setInput() is empty", !defl - .needsInput()); - // The second setInput() should be ignored since needsInput() return - // false - defl.setInput(byteArray); - defl.finish(); - while (!defl.finished()) { - defl.deflate(outPutBuf); - } - defl.end(); - - Inflater infl = new Inflater(); - try { - infl.setInput(outPutBuf); - while (!infl.finished()) { - infl.inflate(outPutInf); - } - } catch (DataFormatException e) { - fail("Invalid input to be decompressed"); - } - for (int i = 0; i < byteArray.length; i++) { - assertEquals(byteArray[i], outPutInf[i]); - } - assertEquals(byteArray.length, infl.getTotalOut()); - infl.end(); - } - - /** - * @tests java.util.zip.Deflater#setInput(byte[], int, int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setInput", - args = {byte[].class, int.class, int.class} - ) - public void test_setInput$BII() throws Exception { - byte[] byteArray = {1, 2, 3, 4, 5}; - byte[] outPutBuf = new byte[50]; - byte[] outPutInf = new byte[50]; - int offSet = 1; - int length = 3; - - Deflater defl = new Deflater(); - defl.setInput(byteArray, offSet, length); - assertFalse("the array buffer in setInput() is empty", defl - .needsInput()); - // The second setInput() should be ignored since needsInput() return - // false - defl.setInput(byteArray, offSet, length); - defl.finish(); - while (!defl.finished()) { - defl.deflate(outPutBuf); - } - defl.end(); - - Inflater infl = new Inflater(); - infl.setInput(outPutBuf); - while (!infl.finished()) { - infl.inflate(outPutInf); - } - for (int i = 0; i < length; i++) { - assertEquals(byteArray[i + offSet], outPutInf[i]); - } - assertEquals(length, infl.getTotalOut()); - infl.end(); - - // boundary check - defl = new Deflater(); - for (int i = 0; i < 2; i++) { - if (i == 0) { - offSet = 0; - length = byteArray.length + 1; - } else { - offSet = byteArray.length + 1; - length = 1; - } - try { - defl.setInput(byteArray, offSet, length); - fail("Test " + i - + ": boundary check for setInput failed for offset " - + offSet + " and length " + length); - } catch (ArrayIndexOutOfBoundsException e) { - } - } - } - - /** - * @tests java.util.zip.Deflater#setLevel(int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setLevel", - args = {int.class} - ) - public void test_setLevelI() throws Exception { - // Very similar to test_Constructor(int) - byte[] byteArray = new byte[100]; - InputStream inFile = Support_Resources.getStream("hyts_checkInput.txt"); - inFile.read(byteArray); - inFile.close(); - - byte[] outPutBuf; - int totalOut; - for (int i = 0; i < 10; i++) { - Deflater defl = new Deflater(); - defl.setLevel(i); - outPutBuf = new byte[500]; - defl.setInput(byteArray); - while (!defl.needsInput()) { - defl.deflate(outPutBuf); - } - defl.finish(); - while (!defl.finished()) { - defl.deflate(outPutBuf); - } - totalOut = defl.getTotalOut(); - defl.end(); - - outPutBuf = new byte[500]; - defl = new Deflater(i); - defl.setInput(byteArray); - while (!defl.needsInput()) { - defl.deflate(outPutBuf); - } - defl.finish(); - while (!defl.finished()) { - defl.deflate(outPutBuf); - } - assertEquals(totalOut, defl.getTotalOut()); - defl.end(); - } - - // testing boundaries - try { - Deflater boundDefl = new Deflater(); - // Level must be between 0-9 - boundDefl.setLevel(-2); - fail("IllegalArgumentException not thrown when setting level to a number < 0."); - } catch (IllegalArgumentException e) { - } - try { - Deflater boundDefl = new Deflater(); - boundDefl.setLevel(10); - fail("IllegalArgumentException not thrown when setting level to a number > 9."); - } catch (IllegalArgumentException e) { - } - } - - /** - * @tests java.util.zip.Deflater#setStrategy(int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setStrategy", - args = {int.class} - ) - public void test_setStrategyI() throws Exception { - byte[] byteArray = new byte[100]; - InputStream inFile = Support_Resources.getStream("hyts_checkInput.txt"); - inFile.read(byteArray); - inFile.close(); - - for (int i = 0; i < 3; i++) { - byte outPutBuf[] = new byte[500]; - MyDeflater mdefl = new MyDeflater(); - - if (i == 0) { - mdefl.setStrategy(mdefl.getDefStrategy()); - } else if (i == 1) { - mdefl.setStrategy(mdefl.getHuffman()); - } else { - mdefl.setStrategy(mdefl.getFiltered()); - } - - mdefl.setInput(byteArray); - while (!mdefl.needsInput()) { - mdefl.deflate(outPutBuf); - } - mdefl.finish(); - while (!mdefl.finished()) { - mdefl.deflate(outPutBuf); - } - - if (i == 0) { - // System.out.println(mdefl.getTotalOut()); - // ran JDK and found that getTotalOut() = 86 for this particular - // file - assertEquals( - "getTotalOut() for the default strategy did not correspond with JDK", - 86, mdefl.getTotalOut()); - } else if (i == 1) { - // System.out.println(mdefl.getTotalOut()); - // ran JDK and found that getTotalOut() = 100 for this - // particular file - assertEquals( - "getTotalOut() for the Huffman strategy did not correspond with JDK", - 100, mdefl.getTotalOut()); - } else { - // System.out.println(mdefl.getTotalOut()); - // ran JDK and found that totalOut = 93 for this particular file - assertEquals( - "Total Out for the Filtered strategy did not correspond with JDK", - 93, mdefl.getTotalOut()); - } - mdefl.end(); - } - - // Attempting to setStrategy to an invalid value - try { - Deflater defl = new Deflater(); - defl.setStrategy(-412); - fail("IllegalArgumentException not thrown when setting strategy to an invalid value."); - } catch (IllegalArgumentException e) { - } - } - - /** - * @tests java.util.zip.Deflater#Deflater() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "Deflater", - args = {} - ) - public void test_Constructor() throws Exception { - byte[] byteArray = new byte[100]; - InputStream inFile = Support_Resources.getStream("hyts_checkInput.txt"); - inFile.read(byteArray); - inFile.close(); - - Deflater defl = new Deflater(); - byte[] outPutBuf = new byte[500]; - defl.setInput(byteArray); - while (!defl.needsInput()) { - defl.deflate(outPutBuf); - } - defl.finish(); - while (!defl.finished()) { - defl.deflate(outPutBuf); - } - int totalOut = defl.getTotalOut(); - defl.end(); - - // creating a Deflater using the DEFAULT_COMPRESSION as the int - MyDeflater mdefl = new MyDeflater(); - mdefl = new MyDeflater(mdefl.getDefCompression()); - outPutBuf = new byte[500]; - mdefl.setInput(byteArray); - while (!mdefl.needsInput()) { - mdefl.deflate(outPutBuf); - } - mdefl.finish(); - while (!mdefl.finished()) { - mdefl.deflate(outPutBuf); - } - assertEquals(totalOut, mdefl.getTotalOut()); - mdefl.end(); - } - - /** - * @tests java.util.zip.Deflater#Deflater(int, boolean) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "Deflater", - args = {int.class, boolean.class} - ) - public void test_ConstructorIZ() throws Exception { - byte byteArray[] = { - 4, 5, 3, 2, 'a', 'b', 6, 7, 8, 9, 0, 's', '3', 'w', 'r'}; - - Deflater defl = new Deflater(); - byte outPutBuf[] = new byte[500]; - defl.setLevel(2); - defl.setInput(byteArray); - while (!defl.needsInput()) { - defl.deflate(outPutBuf); - } - defl.finish(); - while (!defl.finished()) { - defl.deflate(outPutBuf); - } - int totalOut = defl.getTotalOut(); - defl.end(); - - outPutBuf = new byte[500]; - defl = new Deflater(2, false); - defl.setInput(byteArray); - while (!defl.needsInput()) { - defl.deflate(outPutBuf); - } - defl.finish(); - while (!defl.finished()) { - defl.deflate(outPutBuf); - } - assertEquals(totalOut, defl.getTotalOut()); - defl.end(); - - outPutBuf = new byte[500]; - defl = new Deflater(2, true); - defl.setInput(byteArray); - while (!defl.needsInput()) { - defl.deflate(outPutBuf); - } - defl.finish(); - while (!defl.finished()) { - defl.deflate(outPutBuf); - } - assertTrue( - "getTotalOut() should not be equal comparing two Deflaters with different header options.", - defl.getTotalOut() != totalOut); - defl.end(); - - byte outPutInf[] = new byte[500]; - Inflater infl = new Inflater(true); - while (!infl.finished()) { - if (infl.needsInput()) { - infl.setInput(outPutBuf); - } - infl.inflate(outPutInf); - } - for (int i = 0; i < byteArray.length; i++) { - assertEquals(byteArray[i], outPutInf[i]); - } - assertEquals( - "final decompressed data contained more bytes than original - constructorIZ", - 0, outPutInf[byteArray.length]); - infl.end(); - - infl = new Inflater(false); - outPutInf = new byte[500]; - int r = 0; - try { - while (!infl.finished()) { - if (infl.needsInput()) { - infl.setInput(outPutBuf); - } - infl.inflate(outPutInf); - } - } catch (DataFormatException e) { - r = 1; - } - assertEquals("header option did not correspond", 1, r); - - // testing boundaries - try { - Deflater boundDefl = new Deflater(); - // Level must be between 0-9 - boundDefl.setLevel(-2); - fail("IllegalArgumentException not thrown when setting level to a number < 0."); - } catch (IllegalArgumentException e) { - } - try { - Deflater boundDefl = new Deflater(); - boundDefl.setLevel(10); - fail("IllegalArgumentException not thrown when setting level to a number > 9."); - } catch (IllegalArgumentException e) { - } - } - - /** - * @tests java.util.zip.Deflater#Deflater(int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "Deflater", - args = {int.class} - ) - public void test_ConstructorI() throws Exception { - byte[] byteArray = new byte[100]; - InputStream inFile = Support_Resources.getStream("hyts_checkInput.txt"); - inFile.read(byteArray); - inFile.close(); - - byte outPutBuf[] = new byte[500]; - Deflater defl = new Deflater(3); - defl.setInput(byteArray); - while (!defl.needsInput()) { - defl.deflate(outPutBuf); - } - defl.finish(); - while (!defl.finished()) { - defl.deflate(outPutBuf); - } - int totalOut = defl.getTotalOut(); - defl.end(); - - // test to see if the compression ratio is the same as setting the level - // on a deflater - outPutBuf = new byte[500]; - defl = new Deflater(); - defl.setLevel(3); - defl.setInput(byteArray); - while (!defl.needsInput()) { - defl.deflate(outPutBuf); - } - defl.finish(); - while (!defl.finished()) { - defl.deflate(outPutBuf); - } - assertEquals(totalOut, defl.getTotalOut()); - defl.end(); - - // testing boundaries - try { - Deflater boundDefl = new Deflater(); - // Level must be between 0-9 - boundDefl.setLevel(-2); - fail("IllegalArgumentException not thrown when setting level to a number < 0."); - } catch (IllegalArgumentException e) { - } - try { - Deflater boundDefl = new Deflater(); - boundDefl.setLevel(10); - fail("IllegalArgumentException not thrown when setting level to a number > 9."); - } catch (IllegalArgumentException e) { - } - } - - private void helper_end_test(Deflater defl, String desc) { - // Help tests for test_end() and test_reset(). - byte byteArray[] = {5, 2, 3, 7, 8}; - - // Methods where we expect IllegalStateException or NullPointerException - // to be thrown - try { - defl.getTotalOut(); - fail("defl.getTotalOut() can still be used after " + desc - + " is called in test_" + desc); - } catch (IllegalStateException e) { - } catch (NullPointerException e) { - } - try { - defl.getTotalIn(); - fail("defl.getTotalIn() can still be used after " + desc - + " is called in test_" + desc); - } catch (IllegalStateException e) { - } catch (NullPointerException e) { - } - try { - defl.getAdler(); - fail("defl.getAdler() can still be used after " + desc - + " is called in test_" + desc); - } catch (IllegalStateException e) { - } catch (NullPointerException e) { - } - try { - byte[] dict = {'a', 'b', 'c'}; - defl.setDictionary(dict); - fail("defl.setDictionary() can still be used after " + desc - + " is called in test_" + desc); - } catch (IllegalStateException e) { - } catch (NullPointerException e) { - } - try { - defl.getTotalIn(); - fail("defl.getTotalIn() can still be used after " + desc - + " is called in test_" + desc); - } catch (IllegalStateException e) { - } catch (NullPointerException e) { - } - try { - defl.getTotalIn(); - fail("defl.getTotalIn() can still be used after " + desc - + " is called in test_" + desc); - } catch (IllegalStateException e) { - } catch (NullPointerException e) { - } - try { - defl.deflate(byteArray); - fail("defl.deflate() can still be used after " + desc - + " is called in test_" + desc); - } catch (IllegalStateException e) { - } catch (NullPointerException e) { - } - - // Methods where we expect NullPointerException to be thrown - try { - defl.reset(); - fail("defl.reset() can still be used after " + desc - + " is called in test_" + desc); - } catch (NullPointerException e) { - } - - // Methods that should be allowed to be called after end() is called - defl.needsInput(); - defl.setStrategy(1); - defl.setLevel(1); - defl.end(); - - // Methods where exceptions should be thrown - String vendor = System.getProperty("java.vendor"); - if (vendor.indexOf("IBM") != -1) { - try { - defl.setInput(byteArray); - fail("defl.setInput() can still be used after " + desc - + " is called in test_" + desc); - } catch (IllegalStateException e) { - } - } - } - - /** - * @throws DataFormatException - * @throws UnsupportedEncodingException - * @tests java.util.zip.Deflater#getBytesRead() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getBytesRead", - args = {} - ) - public void test_getBytesRead() throws DataFormatException, - UnsupportedEncodingException { - // Regression test for HARMONY-158 - Deflater def = new Deflater(); - assertEquals(0, def.getTotalIn()); - assertEquals(0, def.getTotalOut()); - assertEquals(0, def.getBytesRead()); - // Encode a String into bytes - String inputString = "blahblahblah??"; - byte[] input = inputString.getBytes("UTF-8"); - - // Compress the bytes - byte[] output = new byte[100]; - def.setInput(input); - def.finish(); - int compressedDataLength = def.deflate(output); - assertEquals(14, def.getTotalIn()); - assertEquals(compressedDataLength, def.getTotalOut()); - assertEquals(14, def.getBytesRead()); - } - - /** - * @throws DataFormatException - * @throws UnsupportedEncodingException - * @tests java.util.zip.Deflater#getBytesRead() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getBytesWritten", - args = {} - ) - public void test_getBytesWritten() throws DataFormatException, - UnsupportedEncodingException { - // Regression test for HARMONY-158 - Deflater def = new Deflater(); - assertEquals(0, def.getTotalIn()); - assertEquals(0, def.getTotalOut()); - assertEquals(0, def.getBytesWritten()); - // Encode a String into bytes - String inputString = "blahblahblah??"; - byte[] input = inputString.getBytes("UTF-8"); - - // Compress the bytes - byte[] output = new byte[100]; - def.setInput(input); - def.finish(); - int compressedDataLength = def.deflate(output); - assertEquals(14, def.getTotalIn()); - assertEquals(compressedDataLength, def.getTotalOut()); - assertEquals(compressedDataLength, def.getBytesWritten()); - } - - // BEGIN android-removed - // We use different default settings for deflating, so our output won't be - // the - // same. - // //Regression Test for HARMONY-2481 - // public void test_deflate_beforeSetInput() throws Exception { - // Deflater deflater = new Deflater(); - // deflater.finish(); - // byte[] buffer = new byte[1024]; - // assertEquals(8, deflater.deflate(buffer)); - // byte[] expectedBytes = { 120, -100, 3, 0, 0, 0, 0, 1 }; - // for (int i = 0; i < expectedBytes.length; i++) { - // assertEquals(expectedBytes[i], buffer[i]); - // } - // } - // END android-removed -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPInputStreamTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPInputStreamTest.java deleted file mode 100644 index 1e8ddb430..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPInputStreamTest.java +++ /dev/null @@ -1,360 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.zip; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.zip.Checksum; - -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; - -import tests.support.resource.Support_Resources; - -@TestTargetClass(GZIPInputStream.class) -public class GZIPInputStreamTest extends junit.framework.TestCase { - File resources; - - class TestGZIPInputStream extends GZIPInputStream { - TestGZIPInputStream(InputStream in) throws IOException { - super(in); - } - - TestGZIPInputStream(InputStream in, int size) throws IOException { - super(in, size); - } - - Checksum getChecksum() { - return crc; - } - - boolean endofInput() { - return eos; - } - } - - /** - * @tests java.util.zip.GZIPInputStream#GZIPInputStream(java.io.InputStream) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "GZIPInputStream", - args = {java.io.InputStream.class} - ) - public void test_ConstructorLjava_io_InputStream() { - // test method java.util.zip.GZIPInputStream.constructor - try { - Support_Resources.copyFile(resources, "GZIPInputStream", - "hyts_gInput.txt.gz"); - final URL gInput = new File(resources.toString() - + "/GZIPInputStream/hyts_gInput.txt.gz").toURL(); - TestGZIPInputStream inGZIP = new TestGZIPInputStream(gInput - .openConnection().getInputStream()); - assertNotNull("the constructor for GZIPInputStream is null", inGZIP); - assertEquals("the CRC value of the inputStream is not zero", 0, - inGZIP.getChecksum().getValue()); - inGZIP.close(); - } catch (IOException e) { - fail("an IO error occured while trying to open the input file"); - } - } - - /** - * @tests java.util.zip.GZIPInputStream#GZIPInputStream(java.io.InputStream, - * int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "GZIPInputStream", - args = {java.io.InputStream.class, int.class} - ) - public void test_ConstructorLjava_io_InputStreamI() { - // test method java.util.zip.GZIPInputStream.constructorI - try { - Support_Resources.copyFile(resources, "GZIPInputStream", - "hyts_gInput.txt.gz"); - final URL gInput = new File(resources.toString() - + "/GZIPInputStream/hyts_gInput.txt.gz").toURL(); - TestGZIPInputStream inGZIP = new TestGZIPInputStream(gInput - .openConnection().getInputStream(), 200); - assertNotNull("the constructor for GZIPInputStream is null", inGZIP); - assertEquals("the CRC value of the inputStream is not zero", 0, - inGZIP.getChecksum().getValue()); - inGZIP.close(); - } catch (IOException e) { - fail("an IO error occured while trying to open the input file"); - } - try { - Support_Resources.copyFile(resources, "GZIPInputStream", - "hyts_gInput.txt.gz"); - final URL gInput = new File(resources.toString() - + "/GZIPInputStream/hyts_gInput.txt.gz").toURL(); - TestGZIPInputStream inGZIP = new TestGZIPInputStream(gInput - .openConnection().getInputStream(), 0); - fail("Expected IllegalArgumentException"); - } catch (IOException e) { - fail("an IO error occured while trying to open the input file"); - } catch (IllegalArgumentException ee) { - // expected - } - try { - Support_Resources.copyFile(resources, "GZIPInputStream", - "hyts_gInput.txt.gz"); - final URL gInput = new File(resources.toString() - + "/GZIPInputStream/hyts_gInput.txt.gz").toURL(); - TestGZIPInputStream inGZIP = new TestGZIPInputStream(gInput - .openConnection().getInputStream(), -1); - fail("Expected IllegalArgumentException"); - } catch (IOException e) { - fail("an IO error occured while trying to open the input file"); - } catch (IllegalArgumentException ee) { - // expected - } - } - - /** - * @tests java.util.zip.GZIPInputStream#read(byte[], int, int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "read", - args = {byte[].class, int.class, int.class} - ) - public void test_read$BII() throws IOException { - // test method java.util.zip.GZIPInputStream.readBII - byte orgBuf[] = {'3', '5', '2', 'r', 'g', 'e', 'f', 'd', 'e', 'w'}; - byte outBuf[] = new byte[100]; - int result = 0; - Support_Resources.copyFile(resources, "GZIPInputStream", - "hyts_gInput.txt.gz"); - String resPath = resources.toString(); - if (resPath.charAt(0) == '/' || resPath.charAt(0) == '\\') { - resPath = resPath.substring(1); - } - final URL gInput = new URL("file:/" + resPath - + "/GZIPInputStream/hyts_gInput.txt.gz"); - TestGZIPInputStream inGZIP = new TestGZIPInputStream(gInput - .openConnection().getInputStream()); - while (!(inGZIP.endofInput())) { - result += inGZIP.read(outBuf, result, outBuf.length - result); - } - assertEquals( - "the checkSum value of the compressed and decompressed data does not equal", - 2074883667L, inGZIP.getChecksum().getValue()); - for (int i = 0; i < orgBuf.length; i++) { - assertTrue( - "the decompressed data does not equal the original data decompressed", - orgBuf[i] == outBuf[i]); - // System.out.println(orgBuf[i] + " " + outBuf[i]); - } - int r = 0; - try { - inGZIP.read(outBuf, 100, 1); - } catch (IndexOutOfBoundsException e) { - r = 1; - } - inGZIP.close(); - // line below fails on RI also, comment out. - // assertEquals("Boundary Check was not present", 1, r); - - // Create compressed data which is exactly 512 bytes (after the - // header), - // the size of the InflaterStream internal buffer - byte[] test = new byte[507]; - for (int i = 0; i < 256; i++) { - test[i] = (byte) i; - } - for (int i = 256; i < test.length; i++) { - test[i] = (byte) (256 - i); - } - ByteArrayOutputStream bout = new ByteArrayOutputStream(); - GZIPOutputStream out = new GZIPOutputStream(bout); - out.write(test); - out.close(); - byte[] comp = bout.toByteArray(); - GZIPInputStream gin2 = new GZIPInputStream(new ByteArrayInputStream( - comp), 512); - int total = 0; - while ((result = gin2.read(test)) != -1) { - total += result; - } - assertEquals("Should return -1", -1, gin2.read()); - gin2.close(); - assertTrue("Incorrectly decompressed", total == test.length); - - gin2 = new GZIPInputStream(new ByteArrayInputStream(comp), 512); - total = 0; - while ((result = gin2.read(new byte[200])) != -1) { - total += result; - } - assertEquals("Should return -1", -1, gin2.read()); - gin2.close(); - assertTrue("Incorrectly decompressed", total == test.length); - - gin2 = new GZIPInputStream(new ByteArrayInputStream(comp), 516); - total = 0; - while ((result = gin2.read(new byte[200])) != -1) { - total += result; - } - assertEquals("Should return -1", -1, gin2.read()); - gin2.close(); - assertTrue("Incorrectly decompressed", total == test.length); - - comp[40] = 0; - gin2 = new GZIPInputStream(new ByteArrayInputStream(comp), 512); - boolean exception = false; - try { - while (gin2.read(test) != -1) { - ; - } - } catch (IOException e) { - exception = true; - } - assertTrue("Exception expected", exception); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - GZIPOutputStream zipout = new GZIPOutputStream(baos); - zipout.write(test); - zipout.close(); - outBuf = new byte[530]; - GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(baos - .toByteArray())); - try { - in.read(outBuf, 530, 1); - fail("Test failed IOOBE was not thrown"); - } catch (IndexOutOfBoundsException e) { - } - while (true) { - result = in.read(outBuf, 0, 5); - if (result == -1) { - // "EOF was reached"; - break; - } - } - result = -10; - result = in.read(null, 100, 1); - result = in.read(outBuf, -100, 1); - result = in.read(outBuf, -1, 1);// 100, 1); - } - - /** - * @tests java.util.zip.GZIPInputStream#close() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "close", - args = {} - ) - public void test_close() { - // test method java.util.zip.GZIPInputStream.close - byte outBuf[] = new byte[100]; - try { - int result = 0; - Support_Resources.copyFile(resources, "GZIPInputStream", - "hyts_gInput.txt.gz"); - String resPath = resources.toString(); - if (resPath.charAt(0) == '/' || resPath.charAt(0) == '\\') { - resPath = resPath.substring(1); - } - final URL gInput = new URL("file:/" + resPath - + "/GZIPInputStream/hyts_gInput.txt.gz"); - TestGZIPInputStream inGZIP = new TestGZIPInputStream(gInput - .openConnection().getInputStream()); - while (!(inGZIP.endofInput())) { - result += inGZIP.read(outBuf, result, outBuf.length - result); - } - assertEquals( - "the checkSum value of the compressed and decompressed data does not equal", - 2074883667L, inGZIP.getChecksum().getValue()); - inGZIP.close(); - int r = 0; - try { - inGZIP.read(outBuf, 0, 1); - } catch (IOException e) { - r = 1; - } - assertEquals( - "GZIPInputStream can still be used after close is called", - 1, r); - } catch (IOException e) { - e.printStackTrace(); - fail("unexpected: " + e); - } - } - - /** - * Regression test for HARMONY-3703. - * @tests java.util.zip.GZIPInputStream#read() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "read", - args = {byte[].class} - ) - public void test_read() throws IOException { - GZIPInputStream gis = null; - int result = 0; - byte[] buffer = new byte[] {1,2,3,4,5,6,7,8,9,10}; - File f = new File(resources.getAbsolutePath() + "test.gz"); - FileOutputStream out = new FileOutputStream(f); - GZIPOutputStream gout = new GZIPOutputStream(out); - - // write 100 bytes to the stream - for(int i = 0; i < 10; i++) { - gout.write(buffer); - } - gout.finish(); - out.write(1); - out.close(); - - gis = new GZIPInputStream(new FileInputStream(f)); - buffer = new byte[100]; - gis.read(buffer); - result = gis.read(); - gis.close(); - f.delete(); - - assertEquals("Incorrect value returned at the end of the file", -1, result); - } - - @Override - protected void setUp() { - resources = Support_Resources.createTempFolder(); - } - - @Override - protected void tearDown() { - } - -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPOutputStreamTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPOutputStreamTest.java deleted file mode 100644 index b71ce63b3..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPOutputStreamTest.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.zip; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.zip.Checksum; -import java.util.zip.GZIPOutputStream; - -@TestTargetClass(GZIPOutputStream.class) -public class GZIPOutputStreamTest extends junit.framework.TestCase { - - class TestGZIPOutputStream extends GZIPOutputStream { - TestGZIPOutputStream(OutputStream out) throws IOException { - super(out); - } - - TestGZIPOutputStream(OutputStream out, int size) throws IOException { - super(out, size); - } - - Checksum getChecksum() { - return crc; - } - } - - /** - * @tests java.util.zip.GZIPOutputStream#GZIPOutputStream(java.io.OutputStream) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "GZIPOutputStream", - args = {java.io.OutputStream.class} - ) - public void test_ConstructorLjava_io_OutputStream() { - try { - FileOutputStream outFile = new FileOutputStream( - File.createTempFile("GZIPOutCon", ".txt")); - TestGZIPOutputStream outGZIP = new TestGZIPOutputStream(outFile); - assertNotNull("the constructor for GZIPOutputStream is null", - outGZIP); - assertEquals("the CRC value of the outputStream is not zero", 0, - outGZIP.getChecksum().getValue()); - outGZIP.close(); - } catch (IOException e) { - fail("an IO error occured while trying to find the output file or creating GZIP constructor"); - } - } - - /** - * @tests java.util.zip.GZIPOutputStream#GZIPOutputStream(java.io.OutputStream, - * int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "GZIPOutputStream", - args = {java.io.OutputStream.class, int.class} - ) - public void test_ConstructorLjava_io_OutputStreamI() { - try { - FileOutputStream outFile = new FileOutputStream( - File.createTempFile("GZIPOutCon", ".txt")); - TestGZIPOutputStream outGZIP = new TestGZIPOutputStream(outFile, - 100); - assertNotNull("the constructor for GZIPOutputStream is null", - outGZIP); - assertEquals("the CRC value of the outputStream is not zero", 0, - outGZIP.getChecksum().getValue()); - outGZIP.close(); - } catch (IOException e) { - fail("an IO error occured while trying to find the output file or creating GZIP constructor"); - } - } - - /** - * @tests java.util.zip.GZIPOutputStream#finish() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "finish", - args = {} - ) - public void test_finish() { - // test method java.util.zip.GZIPOutputStream.finish() - byte byteArray[] = {3, 5, 2, 'r', 'g', 'e', 'f', 'd', 'e', 'w'}; - TestGZIPOutputStream outGZIP = null; - FileOutputStream outFile = null; - try { - outFile = new FileOutputStream( - File.createTempFile("GZIPOutCon", ".txt")); - outGZIP = new TestGZIPOutputStream(outFile); - - outGZIP.finish(); - int r = 0; - try { - outGZIP.write(byteArray, 0, 1); - } catch (IOException e) { - r = 1; - } - - assertEquals( - "GZIP instance can still be used after finish is called", - 1, r); - outGZIP.close(); - } catch (IOException e) { - fail("an IO error occured while trying to find the output file or creating GZIP constructor"); - } - try { - outFile = new FileOutputStream("GZIPOutFinish.txt"); - outGZIP = new TestGZIPOutputStream(outFile); - outFile.close(); - - outGZIP.finish(); - fail("Expected IOException"); - } catch (IOException e) { - // expected - } - } - - /** - * @tests java.util.zip.GZIPOutputStream#close() - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "IOException checking missed.", - method = "close", - args = {} - ) - public void test_close() { - // test method java.util.zip.GZIPOutputStream.close() - byte byteArray[] = {3, 5, 2, 'r', 'g', 'e', 'f', 'd', 'e', 'w'}; - try { - FileOutputStream outFile = new FileOutputStream( - File.createTempFile("GZIPOutCon", ".txt")); - TestGZIPOutputStream outGZIP = new TestGZIPOutputStream(outFile); - outGZIP.close(); - int r = 0; - try { - outGZIP.write(byteArray, 0, 1); - } catch (IOException e) { - r = 1; - } - assertEquals( - "GZIP instance can still be used after close is called", 1, - r); - } catch (IOException e) { - fail("an IO error occured while trying to find the output file or creating GZIP constructor"); - } - } - - /** - * @tests java.util.zip.GZIPOutputStream#write(byte[], int, int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "write", - args = {byte[].class, int.class, int.class} - ) - public void test_write$BII() { - // test method java.util.zip.GZIPOutputStream.writeBII - byte byteArray[] = {3, 5, 2, 'r', 'g', 'e', 'f', 'd', 'e', 'w'}; - TestGZIPOutputStream outGZIP = null; - try { - FileOutputStream outFile = new FileOutputStream( - File.createTempFile("GZIPOutCon", ".txt")); - outGZIP = new TestGZIPOutputStream(outFile); - outGZIP.write(byteArray, 0, 10); - // ran JDK and found this CRC32 value is 3097700292 - // System.out.print(outGZIP.getChecksum().getValue()); - assertEquals( - "the checksum value was incorrect result of write from GZIP", - 3097700292L, outGZIP.getChecksum().getValue()); - - // test for boundary check - int r = 0; - try { - outGZIP.write(byteArray, 0, 11); - } catch (IndexOutOfBoundsException ee) { - r = 1; - } - assertEquals("out of bounds exception is not present", 1, r); - outGZIP.close(); - } catch (IOException e) { - fail("an IO error occured while trying to find the output file or creating GZIP constructor"); - } - try { - outGZIP.write(byteArray, 0, 10); - fail("Expected IOException"); - } catch (IOException e) { - // expected - } - } - - @Override - protected void setUp() { - } - - @Override - protected void tearDown() { - - try { - File dFile = new File("GZIPOutCon.txt"); - dFile.delete(); - File dFile2 = new File("GZIPOutFinish.txt"); - dFile2.delete(); - File dFile3 = new File("GZIPOutWrite.txt"); - dFile3.delete(); - File dFile4 = new File("GZIPOutClose2.txt"); - dFile4.delete(); - } catch (SecurityException e) { - fail("Cannot delete file for security reasons"); - } - } - -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java deleted file mode 100644 index 707f13bbf..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java +++ /dev/null @@ -1,549 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.zip; - -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargets; - -import junit.framework.TestCase; - -import tests.support.resource.Support_Resources; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.FileOutputStream; -import java.io.EOFException; -import java.util.zip.DeflaterOutputStream; -import java.util.zip.Inflater; -import java.util.zip.InflaterInputStream; - -@TestTargetClass(InflaterInputStream.class) -public class InflaterInputStreamTest extends TestCase { - - // files hyts_constru(O),hyts_constru(OD),hyts_constru(ODI) needs to be - // included as resources - byte outPutBuf[] = new byte[500]; - - class MyInflaterInputStream extends InflaterInputStream { - MyInflaterInputStream(InputStream in) { - super(in); - } - - MyInflaterInputStream(InputStream in, Inflater infl) { - super(in, infl); - } - - MyInflaterInputStream(InputStream in, Inflater infl, int size) { - super(in, infl, size); - } - - void myFill() throws IOException { - fill(); - } - } - - /** - * @tests java.util.zip.InflaterInputStream#InflaterInputStream(java.io.InputStream) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "InflaterInputStream", - args = {java.io.InputStream.class} - ) - public void test_ConstructorLjava_io_InputStream() throws IOException { - byte byteArray[] = new byte[100]; - InputStream infile = Support_Resources.getStream("hyts_constru_OD.txt"); - InflaterInputStream inflatIP = new InflaterInputStream(infile); - - inflatIP.read(byteArray, 0, 5);// only suppose to read in 5 bytes - inflatIP.close(); - } - - /** - * @tests java.util.zip.InflaterInputStream#InflaterInputStream(java.io.InputStream, - * java.util.zip.Inflater) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "InflaterInputStream", - args = {java.io.InputStream.class, java.util.zip.Inflater.class} - ) - public void test_ConstructorLjava_io_InputStreamLjava_util_zip_Inflater() - throws IOException { - byte byteArray[] = new byte[100]; - InputStream infile = Support_Resources.getStream("hyts_constru_OD.txt"); - Inflater inflate = new Inflater(); - InflaterInputStream inflatIP = new InflaterInputStream(infile, inflate); - - inflatIP.read(byteArray, 0, 5);// only suppose to read in 5 bytes - inflatIP.close(); - } - - /** - * @tests java.util.zip.InflaterInputStream#InflaterInputStream(java.io.InputStream, - * java.util.zip.Inflater, int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "IllegalArgumentException checking missed.", - method = "InflaterInputStream", - args = {java.io.InputStream.class, java.util.zip.Inflater.class, int.class} - ) - public void test_ConstructorLjava_io_InputStreamLjava_util_zip_InflaterI() - throws IOException { - int result = 0; - int buffer[] = new int[500]; - InputStream infile = Support_Resources - .getStream("hyts_constru_ODI.txt"); - Inflater inflate = new Inflater(); - InflaterInputStream inflatIP = new InflaterInputStream(infile, inflate, - 1); - - int i = 0; - while ((result = inflatIP.read()) != -1) { - buffer[i] = result; - i++; - } - inflatIP.close(); - - try { - inflatIP = new InflaterInputStream(infile, inflate, -1); - fail("IllegalArgumentException expected."); - } catch (IllegalArgumentException ee) { - // expected - } - - } - - /** - * @tests java.util.zip.InflaterInputStream#mark(int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "mark", - args = {int.class} - ) - public void test_markI() { - InputStream is = new ByteArrayInputStream(new byte[10]); - InflaterInputStream iis = new InflaterInputStream(is); - // mark do nothing, do no check - iis.mark(0); - iis.mark(-1); - iis.mark(10000000); - } - - /** - * @tests java.util.zip.InflaterInputStream#markSupported() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "markSupported", - args = {} - ) - public void test_markSupported() { - InputStream is = new ByteArrayInputStream(new byte[10]); - InflaterInputStream iis = new InflaterInputStream(is); - assertFalse(iis.markSupported()); - assertTrue(is.markSupported()); - } - - /** - * @tests java.util.zip.InflaterInputStream#read() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "read", - args = {} - ) - public void test_read() throws IOException { - int result = 0; - int buffer[] = new int[500]; - byte orgBuffer[] = {1, 3, 4, 7, 8}; - InputStream infile = Support_Resources.getStream("hyts_constru_OD.txt"); - Inflater inflate = new Inflater(); - InflaterInputStream inflatIP = new InflaterInputStream(infile, inflate); - - int i = 0; - while ((result = inflatIP.read()) != -1) { - buffer[i] = result; - i++; - } - inflatIP.close(); - - for (int j = 0; j < orgBuffer.length; j++) { - assertTrue( - "original compressed data did not equal decompressed data", - buffer[j] == orgBuffer[j]); - } - inflatIP.close(); - try { - inflatIP.read(); - fail("IOException expected"); - } catch (IOException ee) { - // expected. - } - } - - public void testAvailableNonEmptySource() throws Exception { - // this byte[] is a deflation of these bytes: { 1, 3, 4, 6 } - byte[] deflated = { 72, -119, 99, 100, 102, 97, 3, 0, 0, 31, 0, 15, 0 }; - InputStream in = new InflaterInputStream(new ByteArrayInputStream(deflated)); - // InflaterInputStream.available() returns either 1 or 0, even though - // that contradicts the behavior defined in InputStream.available() - assertEquals(1, in.read()); - assertEquals(1, in.available()); - assertEquals(3, in.read()); - assertEquals(1, in.available()); - assertEquals(4, in.read()); - assertEquals(1, in.available()); - assertEquals(6, in.read()); - assertEquals(0, in.available()); - assertEquals(-1, in.read()); - assertEquals(-1, in.read()); - } - - public void testAvailableSkip() throws Exception { - // this byte[] is a deflation of these bytes: { 1, 3, 4, 6 } - byte[] deflated = { 72, -119, 99, 100, 102, 97, 3, 0, 0, 31, 0, 15, 0 }; - InputStream in = new InflaterInputStream(new ByteArrayInputStream(deflated)); - assertEquals(1, in.available()); - assertEquals(4, in.skip(4)); - assertEquals(0, in.available()); - } - - public void testAvailableEmptySource() throws Exception { - // this byte[] is a deflation of the empty file - byte[] deflated = { 120, -100, 3, 0, 0, 0, 0, 1 }; - InputStream in = new InflaterInputStream(new ByteArrayInputStream(deflated)); - assertEquals(-1, in.read()); - assertEquals(-1, in.read()); - assertEquals(0, in.available()); - } - - /** - * @tests java.util.zip.InflaterInputStream#read(byte[], int, int) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "IOException & ZipException checking missed. Additional tests for fill method is not needed.", - method = "read", - args = {byte[].class, int.class, int.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "IOException & ZipException checking missed. Additional tests for fill method is not needed.", - method = "fill", - args = {} - ) - }) - public void test_read$BII() throws IOException { - byte[] test = new byte[507]; - for (int i = 0; i < 256; i++) { - test[i] = (byte) i; - } - for (int i = 256; i < test.length; i++) { - test[i] = (byte) (256 - i); - } - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DeflaterOutputStream dos = new DeflaterOutputStream(baos); - dos.write(test); - dos.close(); - InputStream is = new ByteArrayInputStream(baos.toByteArray()); - InflaterInputStream iis = new InflaterInputStream(is); - byte[] outBuf = new byte[530]; - int result = 0; - while (true) { - result = iis.read(outBuf, 0, 5); - if (result == -1) { - // "EOF was reached"; - break; - } - } - try { - iis.read(outBuf, -1, 10); - fail("should throw IOOBE."); - } catch (IndexOutOfBoundsException e) { - // expected; - } - iis.close(); - } - - /** - * @tests java.util.zip.InflaterInputStream#read(byte[], int, int) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "IOException checking.", - method = "read", - args = {byte[].class, int.class, int.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "IOException checking.", - method = "fill", - args = {} - ) - }) - public void test_read$BII2() throws IOException { - File resources = Support_Resources.createTempFolder(); - Support_Resources.copyFile(resources, null, "Broken_manifest.jar"); - FileInputStream fis = new FileInputStream(new File(resources, - "Broken_manifest.jar")); - InflaterInputStream iis = new InflaterInputStream(fis); - byte[] outBuf = new byte[530]; - - iis.close(); - try { - iis.read(outBuf, 0, 5); - fail("IOException expected"); - } catch (IOException ee) { - // expected. - } - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "IOException checking.", - method = "read", - args = {byte[].class, int.class, int.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "IOException checking.", - method = "fill", - args = {} - ) - }) - public void test_read$BII3() throws IOException { - File resources = Support_Resources.createTempFolder(); - Support_Resources.copyFile(resources, null, "Broken_manifest.jar"); - FileInputStream fis = new FileInputStream(new File(resources, - "Broken_manifest.jar")); - InflaterInputStream iis = new InflaterInputStream(fis); - byte[] outBuf = new byte[530]; - - try { - iis.read(); - fail("IOException expected."); - } catch (IOException ee) { - // expected - } - } - - /** - * @tests java.util.zip.InflaterInputStream#reset() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "reset", - args = {} - ) - public void test_reset() { - InputStream is = new ByteArrayInputStream(new byte[10]); - InflaterInputStream iis = new InflaterInputStream(is); - try { - iis.reset(); - fail("Should throw IOException"); - } catch (IOException e) { - // correct - } - } - - /** - * @tests java.util.zip.InflaterInputStream#skip(long) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "IOException checking missed.", - method = "skip", - args = {long.class} - ) - public void test_skipJ() throws IOException { - InputStream is = Support_Resources.getStream("hyts_available.tst"); - InflaterInputStream iis = new InflaterInputStream(is); - - // Tests for skipping a negative number of bytes. - try { - iis.skip(-3); - fail("IllegalArgumentException not thrown"); - } catch (IllegalArgumentException e) { - // Expected - } - assertEquals("Incorrect Byte Returned.", 5, iis.read()); - - try { - iis.skip(Integer.MIN_VALUE); - fail("IllegalArgumentException not thrown"); - } catch (IllegalArgumentException e) { - // Expected - } - assertEquals("Incorrect Byte Returned.", 4, iis.read()); - - // Test to make sure the correct number of bytes were skipped - assertEquals("Incorrect Number Of Bytes Skipped.", 3, iis.skip(3)); - - // Test to see if the number of bytes skipped returned is true. - assertEquals("Incorrect Byte Returned.", 7, iis.read()); - - assertEquals("Incorrect Number Of Bytes Skipped.", 0, iis.skip(0)); - assertEquals("Incorrect Byte Returned.", 0, iis.read()); - - // Test for skipping more bytes than available in the stream - assertEquals("Incorrect Number Of Bytes Skipped.", 2, iis.skip(4)); - assertEquals("Incorrect Byte Returned.", -1, iis.read()); - iis.close(); - } - - /** - * @tests java.util.zip.InflaterInputStream#skip(long) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "IOException checking missed.", - method = "skip", - args = {long.class} - ) - public void test_skipJ2() throws IOException { - int result = 0; - int buffer[] = new int[100]; - byte orgBuffer[] = {1, 3, 4, 7, 8}; - - // testing for negative input to skip - InputStream infile = Support_Resources.getStream("hyts_constru_OD.txt"); - Inflater inflate = new Inflater(); - InflaterInputStream inflatIP = new InflaterInputStream(infile, inflate, - 10); - long skip; - try { - skip = inflatIP.skip(Integer.MIN_VALUE); - fail("Expected IllegalArgumentException when skip() is called with negative parameter"); - } catch (IllegalArgumentException e) { - // Expected - } - inflatIP.close(); - - // testing for number of bytes greater than input. - InputStream infile2 = Support_Resources - .getStream("hyts_constru_OD.txt"); - InflaterInputStream inflatIP2 = new InflaterInputStream(infile2); - - // looked at how many bytes the skip skipped. It is - // 5 and its supposed to be the entire input stream. - - skip = inflatIP2.skip(Integer.MAX_VALUE); - // System.out.println(skip); - assertEquals("method skip() returned wrong number of bytes skipped", 5, - skip); - - // test for skipping of 2 bytes - InputStream infile3 = Support_Resources - .getStream("hyts_constru_OD.txt"); - InflaterInputStream inflatIP3 = new InflaterInputStream(infile3); - skip = inflatIP3.skip(2); - assertEquals( - "the number of bytes returned by skip did not correspond with its input parameters", - 2, skip); - int i = 0; - result = 0; - while ((result = inflatIP3.read()) != -1) { - buffer[i] = result; - i++; - } - inflatIP2.close(); - - for (int j = 2; j < orgBuffer.length; j++) { - assertTrue( - "original compressed data did not equal decompressed data", - buffer[j - 2] == orgBuffer[j]); - } - - try { - inflatIP2.skip(4); - fail("IOException expected."); - } catch (IOException ee) { - // expected - } - } - - /** - * @tests java.util.zip.InflaterInputStream#available() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "available", - args = {} - ) - public void test_available() throws IOException { - InputStream is = Support_Resources.getStream("hyts_available.tst"); - InflaterInputStream iis = new InflaterInputStream(is); - - int available; - for (int i = 0; i < 11; i++) { - iis.read(); - available = iis.available(); - if (available == 0) { - assertEquals("Expected no more bytes to read", -1, iis.read()); - } else { - assertEquals("Bytes Available Should Return 1.", 1, available); - } - } - - iis.close(); - try { - iis.available(); - fail("available after close should throw IOException."); - } catch (IOException e) { - // Expected - } - } - - /** - * @tests java.util.zip.InflaterInputStream#close() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "IOException can not be tested.", - method = "close", - args = {} - ) - public void test_close() throws IOException { - InflaterInputStream iin = new InflaterInputStream( - new ByteArrayInputStream(new byte[0])); - iin.close(); - - // test for exception - iin.close(); - - } -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java deleted file mode 100644 index cd5d538fa..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java +++ /dev/null @@ -1,1116 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.zip; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.io.BufferedInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.zip.Adler32; -import java.io.UnsupportedEncodingException; -import java.util.zip.DataFormatException; -import java.util.zip.Deflater; -import java.util.zip.Inflater; -import java.util.zip.ZipException; - -import tests.support.resource.Support_Resources; - -@TestTargetClass(Inflater.class) -public class InflaterTest extends junit.framework.TestCase { - byte outPutBuff1[] = new byte[500]; - - byte outPutDiction[] = new byte[500]; - - /** - * @tests java.util.zip.Inflater#end() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "end", - args = {} - ) - public void test_end() { - // test method of java.util.zip.inflater.end() - byte byteArray[] = {5, 2, 3, 7, 8}; - - int r = 0; - Inflater inflate = new Inflater(); - inflate.setInput(byteArray); - inflate.end(); - try { - inflate.reset(); - inflate.setInput(byteArray); - } catch (NullPointerException e) { - r = 1; - } - assertEquals("inflate can still be used after end is called", 1, r); - - Inflater i = new Inflater(); - i.end(); - // check for exception - i.end(); - } - - /** - * @tests java.util.zip.Inflater#finished() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "finished", - args = {} - ) - public void test_finished() { - // test method of java.util.zip.inflater.finished() - byte byteArray[] = {1, 3, 4, 7, 8, 'e', 'r', 't', 'y', '5'}; - Inflater inflate = new Inflater(false); - byte outPutInf[] = new byte[500]; - try { - while (!(inflate.finished())) { - if (inflate.needsInput()) { - inflate.setInput(outPutBuff1); - } - - inflate.inflate(outPutInf); - } - assertTrue( - "the method finished() returned false when no more data needs to be decompressed", - inflate.finished()); - } catch (DataFormatException e) { - fail("Invalid input to be decompressed"); - } - for (int i = 0; i < byteArray.length; i++) { - assertTrue( - "Final decompressed data does not equal the original data", - byteArray[i] == outPutInf[i]); - } - assertEquals( - "final decompressed data contained more bytes than original - finished()", - 0, outPutInf[byteArray.length]); - } - - /** - * @tests java.util.zip.Inflater#getAdler() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getAdler", - args = {} - ) - public void test_getAdler() { - // test method of java.util.zip.inflater.getAdler() - byte dictionaryArray[] = {'e', 'r', 't', 'a', 'b', 2, 3}; - - Inflater inflateDiction = new Inflater(); - inflateDiction.setInput(outPutDiction); - if (inflateDiction.needsDictionary() == true) { - // getting the checkSum value through the Adler32 class - Adler32 adl = new Adler32(); - adl.update(dictionaryArray); - long checkSumR = adl.getValue(); - assertTrue( - "the checksum value returned by getAdler() is not the same as the checksum returned by creating the adler32 instance", - checkSumR == inflateDiction.getAdler()); - } - } - - /** - * @tests java.util.zip.Inflater#getRemaining() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getRemaining", - args = {} - ) - public void test_getRemaining() { - // test method of java.util.zip.inflater.getRemaining() - byte byteArray[] = {1, 3, 5, 6, 7}; - Inflater inflate = new Inflater(); - assertEquals( - "upon creating an instance of inflate, getRemaining returned a non zero value", - 0, inflate.getRemaining()); - inflate.setInput(byteArray); - assertTrue( - "getRemaining returned zero when there is input in the input buffer", - inflate.getRemaining() != 0); - } - - /** - * @tests java.util.zip.Inflater#getTotalIn() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getTotalIn", - args = {} - ) - public void test_getTotalIn() { - // test method of java.util.zip.inflater.getTotalIn() - // creating the decompressed data - byte outPutBuf[] = new byte[500]; - byte byteArray[] = {1, 3, 4, 7, 8}; - byte outPutInf[] = new byte[500]; - int x = 0; - Deflater deflate = new Deflater(1); - deflate.setInput(byteArray); - while (!(deflate.needsInput())) { - x += deflate.deflate(outPutBuf, x, outPutBuf.length - x); - } - deflate.finish(); - while (!(deflate.finished())) { - x = x + deflate.deflate(outPutBuf, x, outPutBuf.length - x); - } - - Inflater inflate = new Inflater(); - try { - while (!(inflate.finished())) { - if (inflate.needsInput()) { - inflate.setInput(outPutBuf); - } - - inflate.inflate(outPutInf); - } - } catch (DataFormatException e) { - fail("Input to inflate is invalid or corrupted - getTotalIn"); - } - // System.out.print(deflate.getTotalOut() + " " + inflate.getTotalIn()); - assertTrue( - "the total byte in outPutBuf did not equal the byte returned in getTotalIn", - inflate.getTotalIn() == deflate.getTotalOut()); - - Inflater inflate2 = new Inflater(); - int offSet = 0;// seems only can start as 0 - int length = 4; - try { - // seems no while loops allowed - if (inflate2.needsInput()) { - inflate2.setInput(outPutBuff1, offSet, length); - } - - inflate2.inflate(outPutInf); - - } catch (DataFormatException e) { - fail("Input to inflate is invalid or corrupted - getTotalIn"); - } - // System.out.print(inflate2.getTotalIn() + " " + length); - assertTrue( - "total byte dictated by length did not equal byte returned in getTotalIn", - inflate2.getTotalIn() == length); - } - - /** - * @tests java.util.zip.Inflater#getTotalOut() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getTotalOut", - args = {} - ) - public void test_getTotalOut() { - // test method of java.util.zip.inflater.Inflater() - // creating the decompressed data - byte outPutBuf[] = new byte[500]; - byte byteArray[] = {1, 3, 4, 7, 8}; - int y = 0; - int x = 0; - Deflater deflate = new Deflater(1); - deflate.setInput(byteArray); - while (!(deflate.needsInput())) { - x += deflate.deflate(outPutBuf, x, outPutBuf.length - x); - } - deflate.finish(); - while (!(deflate.finished())) { - x = x + deflate.deflate(outPutBuf, x, outPutBuf.length - x); - } - - Inflater inflate = new Inflater(); - byte outPutInf[] = new byte[500]; - try { - while (!(inflate.finished())) { - if (inflate.needsInput()) { - inflate.setInput(outPutBuf); - } - - y += inflate.inflate(outPutInf); - } - } catch (DataFormatException e) { - fail("Input to inflate is invalid or corrupted - getTotalIn"); - } - - assertTrue( - "the sum of the bytes returned from inflate does not equal the bytes of getTotalOut()", - y == inflate.getTotalOut()); - assertTrue( - "the total number of bytes to be compressed does not equal the total bytes decompressed", - inflate.getTotalOut() == deflate.getTotalIn()); - - // testing inflate(byte,int,int) - inflate.reset(); - y = 0; - int offSet = 0;// seems only can start as 0 - int length = 4; - try { - while (!(inflate.finished())) { - if (inflate.needsInput()) { - inflate.setInput(outPutBuf); - } - - y += inflate.inflate(outPutInf, offSet, length); - } - } catch (DataFormatException e) { - System.out - .println("Input to inflate is invalid or corrupted - getTotalIn"); - } - assertTrue( - "the sum of the bytes returned from inflate does not equal the bytes of getTotalOut()", - y == inflate.getTotalOut()); - assertTrue( - "the total number of bytes to be compressed does not equal the total bytes decompressed", - inflate.getTotalOut() == deflate.getTotalIn()); - } - - /** - * @tests java.util.zip.Inflater#inflate(byte[]) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "DataFormatException checking missed.", - method = "inflate", - args = {byte[].class} - ) - public void test_inflate$B() { - // test method of java.util.zip.inflater.inflate(byte) - - byte byteArray[] = {1, 3, 4, 7, 8, 'e', 'r', 't', 'y', '5'}; - byte outPutInf[] = new byte[500]; - Inflater inflate = new Inflater(); - try { - while (!(inflate.finished())) { - if (inflate.needsInput()) { - inflate.setInput(outPutBuff1); - } - inflate.inflate(outPutInf); - } - } catch (DataFormatException e) { - fail("Invalid input to be decompressed"); - } - for (int i = 0; i < byteArray.length; i++) { - assertTrue( - "Final decompressed data does not equal the original data", - byteArray[i] == outPutInf[i]); - } - assertEquals( - "final decompressed data contained more bytes than original - inflateB", - 0, outPutInf[byteArray.length]); - // testing for an empty input array - byte outPutBuf[] = new byte[500]; - byte emptyArray[] = new byte[11]; - int x = 0; - Deflater defEmpty = new Deflater(3); - defEmpty.setInput(emptyArray); - while (!(defEmpty.needsInput())) { - x += defEmpty.deflate(outPutBuf, x, outPutBuf.length - x); - } - defEmpty.finish(); - while (!(defEmpty.finished())) { - x += defEmpty.deflate(outPutBuf, x, outPutBuf.length - x); - } - assertTrue( - "the total number of byte from deflate did not equal getTotalOut - inflate(byte)", - x == defEmpty.getTotalOut()); - assertTrue( - "the number of input byte from the array did not correspond with getTotalIn - inflate(byte)", - defEmpty.getTotalIn() == emptyArray.length); - Inflater infEmpty = new Inflater(); - try { - while (!(infEmpty.finished())) { - if (infEmpty.needsInput()) { - infEmpty.setInput(outPutBuf); - } - infEmpty.inflate(outPutInf); - } - } catch (DataFormatException e) { - fail("Invalid input to be decompressed"); - } - for (int i = 0; i < emptyArray.length; i++) { - assertTrue( - "Final decompressed data does not equal the original data", - emptyArray[i] == outPutInf[i]); - assertEquals("Final decompressed data does not equal zero", 0, - outPutInf[i]); - } - assertEquals( - "Final decompressed data contains more element than original data", - 0, outPutInf[emptyArray.length]); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "inflate", - args = {byte[].class} - ) - public void test_inflate$B1() { - byte codedData[] = { - 120, -38, 75, -54, 73, -52, 80, 40, 46, 41, -54, -52, 75, 87, - 72, -50, -49, 43, 73, -52, -52, 43, 86, 72, 2, 10, 34, 99, - -123, -60, -68, 20, -80, 32, 0, -101, -69, 17, 84}; - String codedString = "blah string contains blahblahblahblah and blah"; - - Inflater infl1 = new Inflater(); - Inflater infl2 = new Inflater(); - - byte[] result = new byte[100]; - int decLen = 0; - - infl1.setInput(codedData, 0, codedData.length); - try { - decLen = infl1.inflate(result); - } catch (DataFormatException e) { - fail("Unexpected DataFormatException"); - } - - infl1.end(); - assertEquals(codedString, new String(result, 0, decLen)); - codedData[5] = 0; - - infl2.setInput(codedData, 0, codedData.length); - try { - decLen = infl2.inflate(result); - fail("Expected DataFormatException"); - } catch (DataFormatException e) { - // expected - } - - infl2.end(); - } - - /** - * @tests java.util.zip.Inflater#Inflater() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "Inflater", - args = {} - ) - public void test_Constructor() { - // test method of java.util.zip.inflater.Inflater() - Inflater inflate = new Inflater(); - assertNotNull("failed to create the instance of inflater", - inflate); - } - - /** - * @tests java.util.zip.Inflater#inflate(byte[], int, int) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "DataFormatException checking missed.", - method = "inflate", - args = {byte[].class, int.class, int.class} - ) - public void test_inflate$BII() { - // test method of java.util.zip.inflater.inflate(byte,int,int) - - byte byteArray[] = {1, 3, 4, 7, 8, 'e', 'r', 't', 'y', '5'}; - byte outPutInf[] = new byte[100]; - int y = 0; - Inflater inflate = new Inflater(); - try { - while (!(inflate.finished())) { - if (inflate.needsInput()) { - inflate.setInput(outPutBuff1); - } - y += inflate.inflate(outPutInf, y, outPutInf.length - y); - } - } catch (DataFormatException e) { - fail("Invalid input to be decompressed"); - } - for (int i = 0; i < byteArray.length; i++) { - assertTrue( - "Final decompressed data does not equal the original data", - byteArray[i] == outPutInf[i]); - } - assertEquals( - "final decompressed data contained more bytes than original - inflateB", - 0, outPutInf[byteArray.length]); - - // test boundary checks - inflate.reset(); - int r = 0; - int offSet = 0; - int lengthError = 101; - try { - if (inflate.needsInput()) { - inflate.setInput(outPutBuff1); - } - inflate.inflate(outPutInf, offSet, lengthError); - - } catch (DataFormatException e) { - fail("Invalid input to be decompressed"); - } catch (ArrayIndexOutOfBoundsException e) { - r = 1; - } - assertEquals("out of bounds error did not get caught", 1, r); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "inflate", - args = {byte[].class, int.class, int.class} - ) - public void test_inflate$BII1() { - byte codedData[] = { - 120, -38, 75, -54, 73, -52, 80, 40, 46, 41, -54, -52, 75, 87, - 72, -50, -49, 43, 73, -52, -52, 43, 86, 72, 2, 10, 34, 99, - -123, -60, -68, 20, -80, 32, 0, -101, -69, 17, 84}; - String codedString = "blah string"; - - Inflater infl1 = new Inflater(); - Inflater infl2 = new Inflater(); - - byte[] result = new byte[100]; - int decLen = 0; - - infl1.setInput(codedData, 0, codedData.length); - try { - decLen = infl1.inflate(result, 10, 11); - } catch (DataFormatException e) { - fail("Unexpected DataFormatException"); - } - - infl1.end(); - assertEquals(codedString, new String(result, 10, decLen)); - codedData[5] = 0; - - infl2.setInput(codedData, 0, codedData.length); - try { - decLen = infl2.inflate(result, 10, 11); - fail("Expected DataFormatException"); - } catch (DataFormatException e) { - // expected - } - - infl2.end(); - } - - /** - * @tests java.util.zip.Inflater#Inflater(boolean) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "Inflater", - args = {boolean.class} - ) - public void test_ConstructorZ() { - // test method of java.util.zip.inflater.Inflater(boolean) - // note does not throw exception if deflater has a header, but inflater - // doesn't or vice versa. - byte byteArray[] = {1, 3, 4, 7, 8, 'e', 'r', 't', 'y', '5'}; - Inflater inflate = new Inflater(true); - assertNotNull("failed to create the instance of inflater", inflate); - byte outPutInf[] = new byte[500]; - int r = 0; - try { - while (!(inflate.finished())) { - if (inflate.needsInput()) { - inflate.setInput(outPutBuff1); - } - - inflate.inflate(outPutInf); - } - for (int i = 0; i < byteArray.length; i++) { - assertEquals( - "the output array from inflate should contain 0 because the header of inflate and deflate did not match, but this failed", - 0, outPutBuff1[i]); - } - } catch (DataFormatException e) { - r = 1; - } - assertEquals( - "Error: exception should be thrown because of header inconsistency", - 1, r); - - } - - /** - * @tests java.util.zip.Inflater#needsDictionary() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "needsDictionary", - args = {} - ) - public void test_needsDictionary() { - // test method of java.util.zip.inflater.needsDictionary() - // note: this flag is set after inflate is called - byte outPutInf[] = new byte[500]; - - // testing with dictionary set. - Inflater inflateDiction = new Inflater(); - if (inflateDiction.needsInput()) { - inflateDiction.setInput(outPutDiction); - } - try { - assertEquals("should return 0 because needs dictionary", 0, - inflateDiction.inflate(outPutInf)); - } catch (DataFormatException e) { - fail("Should not cause exception"); - } - assertTrue( - "method needsDictionary returned false when dictionary was used in deflater", - inflateDiction.needsDictionary()); - - // testing without dictionary - Inflater inflate = new Inflater(); - try { - inflate.setInput(outPutBuff1); - inflate.inflate(outPutInf); - assertFalse( - "method needsDictionary returned true when dictionary was not used in deflater", - inflate.needsDictionary()); - } catch (DataFormatException e) { - fail("Input to inflate is invalid or corrupted - needsDictionary"); - } - - // Regression test for HARMONY-86 - Inflater inf = new Inflater(); - assertFalse(inf.needsDictionary()); - assertEquals(0, inf.getTotalIn()); - assertEquals(0, inf.getTotalOut()); - assertEquals(0, inf.getBytesRead()); - assertEquals(0, inf.getBytesWritten()); - } - - /** - * @tests java.util.zip.Inflater#needsInput() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "needsInput", - args = {} - ) - public void test_needsInput() { - // test method of java.util.zip.inflater.needsInput() - Inflater inflate = new Inflater(); - assertTrue( - "needsInput give the wrong boolean value as a result of no input buffer", - inflate.needsInput()); - - byte byteArray[] = {2, 3, 4, 't', 'y', 'u', 'e', 'w', 7, 6, 5, 9}; - inflate.setInput(byteArray); - assertFalse( - "methodNeedsInput returned true when the input buffer is full", - inflate.needsInput()); - - inflate.reset(); - byte byteArrayEmpty[] = new byte[0]; - inflate.setInput(byteArrayEmpty); - assertTrue( - "needsInput give wrong boolean value as a result of an empty input buffer", - inflate.needsInput()); - } - - /** - * @tests java.util.zip.Inflater#reset() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "reset", - args = {} - ) - public void test_reset() { - // test method of java.util.zip.inflater.reset() - byte byteArray[] = {1, 3, 4, 7, 8, 'e', 'r', 't', 'y', '5'}; - byte outPutInf[] = new byte[100]; - int y = 0; - Inflater inflate = new Inflater(); - try { - while (!(inflate.finished())) { - if (inflate.needsInput()) { - inflate.setInput(outPutBuff1); - } - y += inflate.inflate(outPutInf, y, outPutInf.length - y); - } - } catch (DataFormatException e) { - fail("Invalid input to be decompressed"); - } - for (int i = 0; i < byteArray.length; i++) { - assertTrue( - "Final decompressed data does not equal the original data", - byteArray[i] == outPutInf[i]); - } - assertEquals( - "final decompressed data contained more bytes than original - reset", - 0, outPutInf[byteArray.length]); - - // testing that resetting the inflater will also return the correct - // decompressed data - - inflate.reset(); - try { - while (!(inflate.finished())) { - if (inflate.needsInput()) { - inflate.setInput(outPutBuff1); - } - inflate.inflate(outPutInf); - } - } catch (DataFormatException e) { - fail("Invalid input to be decompressed"); - } - for (int i = 0; i < byteArray.length; i++) { - assertTrue( - "Final decompressed data does not equal the original data", - byteArray[i] == outPutInf[i]); - } - assertEquals( - "final decompressed data contained more bytes than original - reset", - 0, outPutInf[byteArray.length]); - - } - - - /** - * @tests java.util.zip.Inflater#setInput(byte[]) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setInput", - args = {byte[].class} - ) - public void test_setInput$B() { - // test method of java.util.zip.inflater.setInput(byte) - byte byteArray[] = {2, 3, 4, 't', 'y', 'u', 'e', 'w', 7, 6, 5, 9}; - Inflater inflate = new Inflater(); - inflate.setInput(byteArray); - assertTrue("setInputB did not deliver any byte to the input buffer", - inflate.getRemaining() != 0); - } - - /** - * @tests java.util.zip.Inflater#setInput(byte[], int, int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setInput", - args = {byte[].class, int.class, int.class} - ) - public void test_setInput$BII() { - // test method of java.util.zip.inflater.setInput(byte,int,int) - byte byteArray[] = {2, 3, 4, 't', 'y', 'u', 'e', 'w', 7, 6, 5, 9}; - int offSet = 6; - int length = 6; - Inflater inflate = new Inflater(); - inflate.setInput(byteArray, offSet, length); - assertTrue( - "setInputBII did not deliver the right number of bytes to the input buffer", - inflate.getRemaining() == length); - // boundary check - inflate.reset(); - int r = 0; - try { - inflate.setInput(byteArray, 100, 100); - } catch (ArrayIndexOutOfBoundsException e) { - r = 1; - } - assertEquals("boundary check is not present for setInput", 1, r); - } - - @Override - protected void setUp() { - try { - java.io.InputStream infile = Support_Resources - .getStream("hyts_compressD.txt"); - BufferedInputStream inflatIP = new BufferedInputStream(infile); - inflatIP.read(outPutBuff1, 0, outPutBuff1.length); - inflatIP.close(); - - java.io.InputStream infile2 = Support_Resources - .getStream("hyts_compDiction.txt"); - BufferedInputStream inflatIP2 = new BufferedInputStream(infile2); - inflatIP2.read(outPutDiction, 0, outPutDiction.length); - inflatIP2.close(); - - } catch (FileNotFoundException e) { - fail("input file to test InflaterInputStream constructor is not found"); - } catch (ZipException e) { - fail("read() threw an zip exception while testing constructor"); - } catch (IOException e) { - fail("read() threw an exception while testing constructor"); - } - } - - @Override - protected void tearDown() { - } - - /** - * @tests java.util.zip.Deflater#getBytesRead() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getBytesRead", - args = {} - ) - public void test_getBytesRead() throws DataFormatException, - UnsupportedEncodingException { - // Regression test for HARMONY-158 - Deflater def = new Deflater(); - Inflater inf = new Inflater(); - assertEquals(0, def.getTotalIn()); - assertEquals(0, def.getTotalOut()); - assertEquals(0, def.getBytesRead()); - // Encode a String into bytes - String inputString = "blahblahblah??"; - byte[] input = inputString.getBytes("UTF-8"); - - // Compress the bytes - byte[] output = new byte[100]; - def.setInput(input); - def.finish(); - def.deflate(output); - inf.setInput(output); - int compressedDataLength = inf.inflate(input); - assertEquals(16, inf.getTotalIn()); - assertEquals(compressedDataLength, inf.getTotalOut()); - assertEquals(16, inf.getBytesRead()); - } - - /** - * @tests java.util.zip.Deflater#getBytesRead() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getBytesWritten", - args = {} - ) - public void test_getBytesWritten() throws DataFormatException, - UnsupportedEncodingException { - // Regression test for HARMONY-158 - Deflater def = new Deflater(); - Inflater inf = new Inflater(); - assertEquals(0, def.getTotalIn()); - assertEquals(0, def.getTotalOut()); - assertEquals(0, def.getBytesWritten()); - // Encode a String into bytes - String inputString = "blahblahblah??"; - byte[] input = inputString.getBytes("UTF-8"); - - // Compress the bytes - byte[] output = new byte[100]; - def.setInput(input); - def.finish(); - def.deflate(output); - inf.setInput(output); - int compressedDataLength = inf.inflate(input); - assertEquals(16, inf.getTotalIn()); - assertEquals(compressedDataLength, inf.getTotalOut()); - assertEquals(14, inf.getBytesWritten()); - } - - /** - * @tests java.util.zip.Deflater#inflate(byte[], int, int) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Regression test", - method = "inflate", - args = {byte[].class, int.class, int.class} - ) - public void testInflate() throws Exception { - // Regression for HARMONY-81 - Inflater inf = new Inflater(); - int res = inf.inflate(new byte[0], 0, 0); - - assertEquals(0, res); - - // Regression for HARMONY-2508 - Inflater inflater = new Inflater(); - byte[] b = new byte[1024]; - assertEquals(0, inflater.inflate(b)); - inflater.end(); - } - - /** - * @tests java.util.zip.Deflater#inflate(byte[], int, int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Can not be checked. Should be tested in DX test package.", - method = "finalize", - args = {} - ) - public void testFinalize() throws Exception { - } - - /** - * @tests java.util.zip.Inflater#setDictionary(byte[]) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks setDictionary. Can be splitted for 2 separate tests for Deflater & Inflater. Can be used as a base for setDictionary with additional params.", - method = "setDictionary", - args = {byte[].class} - ) - public void testsetDictionary$B() throws Exception { - int i = 0; - String inputString = "blah string contains blahblahblahblah and blah"; - String dictionary1 = "blah"; - String dictionary2 = "1234"; - - byte[] outputNo = new byte[100]; - byte[] output1 = new byte[100]; - byte[] output2 = new byte[100]; - Deflater defDictNo = new Deflater(9); - Deflater defDict1 = new Deflater(9); - Deflater defDict2 = new Deflater(9); - - defDict1.setDictionary(dictionary1.getBytes()); - defDict2.setDictionary(dictionary2.getBytes()); - - defDictNo.setInput(inputString.getBytes()); - defDict1.setInput(inputString.getBytes()); - defDict2.setInput(inputString.getBytes()); - - defDictNo.finish(); - defDict1.finish(); - defDict2.finish(); - - int dataLenNo = defDictNo.deflate(outputNo); - int dataLen1 = defDict1.deflate(output1); - int dataLen2 = defDict2.deflate(output2); - - boolean passNo1 = false; - boolean passNo2 = false; - boolean pass12 = false; - - for (i = 0; i < (dataLenNo < dataLen1 ? dataLenNo : dataLen1); i++) { - if (outputNo[i] != output1[i]) { - passNo1 = true; - break; - } - } - for (i = 0; i < (dataLenNo < dataLen1 ? dataLenNo : dataLen2); i++) { - if (outputNo[i] != output2[i]) { - passNo2 = true; - break; - } - } - for (i = 0; i < (dataLen1 < dataLen2 ? dataLen1 : dataLen2); i++) { - if (output1[i] != output2[i]) { - pass12 = true; - break; - } - } - - assertTrue( - "Compressed data the same for stream with dictionary and without it.", - passNo1); - assertTrue( - "Compressed data the same for stream with dictionary and without it.", - passNo2); - assertTrue( - "Compressed data the same for stream with different dictionaries.", - pass12); - - Inflater inflNo = new Inflater(); - Inflater infl1 = new Inflater(); - Inflater infl2 = new Inflater(); - - byte[] result = new byte[100]; - int decLen; - - inflNo.setInput(outputNo, 0, dataLenNo); - decLen = inflNo.inflate(result); - - assertFalse(inflNo.needsDictionary()); - inflNo.end(); - assertEquals(inputString, new String(result, 0, decLen)); - - infl1.setInput(output1, 0, dataLen1); - decLen = infl1.inflate(result); - - assertTrue(infl1.needsDictionary()); - infl1.setDictionary(dictionary1.getBytes()); - decLen = infl1.inflate(result); - infl1.end(); - assertEquals(inputString, new String(result, 0, decLen)); - - infl2.setInput(output2, 0, dataLen2); - decLen = infl2.inflate(result); - - assertTrue(infl2.needsDictionary()); - infl2.setDictionary(dictionary2.getBytes()); - decLen = infl2.inflate(result); - infl2.end(); - assertEquals(inputString, new String(result, 0, decLen)); - - - inflNo = new Inflater(); - infl1 = new Inflater(); - inflNo.setInput(outputNo, 0, dataLenNo); - try { - infl1.setDictionary(dictionary1.getBytes()); - fail("IllegalArgumentException expected."); - } catch (IllegalArgumentException ee) { - // expected. - } - inflNo.end(); - - infl1.setInput(output1, 0, dataLen1); - decLen = infl1.inflate(result); - - assertTrue(infl1.needsDictionary()); - try { - infl1.setDictionary(dictionary2.getBytes()); - fail("IllegalArgumentException expected."); - } catch (IllegalArgumentException ee) { - // expected. - } - infl1.end(); - } - - /** - * @tests java.util.zip.Inflater#setDictionary(byte[]) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks setDictionary. Can be splitted for 2 separate tests for Deflater & Inflater. Can be used as a base for setDictionary with additional params.", - method = "setDictionary", - args = {byte[].class, int.class, int.class} - ) - public void testsetDictionary$BII() throws Exception { - int i = 0; - String inputString = "blah string contains blahblahblahblah and blah"; - String dictionary1 = "blah"; - String dictionary2 = "blahblahblah"; - - byte[] output1 = new byte[100]; - byte[] output2 = new byte[100]; - byte[] output3 = new byte[100]; - - Deflater defDict1 = new Deflater(9); - Deflater defDict2 = new Deflater(9); - Deflater defDict3 = new Deflater(9); - - defDict1.setDictionary(dictionary1.getBytes()); - defDict2.setDictionary(dictionary2.getBytes()); - defDict3.setDictionary(dictionary2.getBytes(), 4, 4); - - defDict1.setInput(inputString.getBytes()); - defDict2.setInput(inputString.getBytes()); - defDict3.setInput(inputString.getBytes()); - - defDict1.finish(); - defDict2.finish(); - defDict3.finish(); - - int dataLen1 = defDict1.deflate(output1); - int dataLen2 = defDict2.deflate(output2); - int dataLen3 = defDict3.deflate(output3); - - boolean pass12 = false; - boolean pass23 = false; - boolean pass13 = true; - - for (i = 0; i < (dataLen1 < dataLen2 ? dataLen1 : dataLen2); i++) { - if (output1[i] != output2[i]) { - pass12 = true; - break; - } - } - for (i = 0; i < (dataLen2 < dataLen3 ? dataLen2 : dataLen3); i++) { - if (output2[i] != output3[i]) { - pass23 = true; - break; - } - } - for (i = 0; i < (dataLen1 < dataLen3 ? dataLen1 : dataLen3); i++) { - if (output1[i] != output3[i]) { - pass13 = false; - break; - } - } - - assertTrue( - "Compressed data the same for stream with different dictionaries.", - pass12); - assertTrue( - "Compressed data the same for stream with different dictionaries.", - pass23); - assertTrue( - "Compressed data the differs for stream with the same dictionaries.", - pass13); - - Inflater infl1 = new Inflater(); - Inflater infl2 = new Inflater(); - Inflater infl3 = new Inflater(); - - byte[] result = new byte[100]; - int decLen; - - infl1.setInput(output1, 0, dataLen1); - decLen = infl1.inflate(result); - - assertTrue(infl1.needsDictionary()); - infl1.setDictionary(dictionary2.getBytes(), 4, 4); - decLen = infl1.inflate(result); - infl1.end(); - assertEquals(inputString, new String(result, 0, decLen)); - - infl2.setInput(output2, 0, dataLen2); - decLen = infl2.inflate(result); - - assertTrue(infl2.needsDictionary()); - try { - infl2.setDictionary(dictionary1.getBytes()); - fail("IllegalArgumentException expected."); - } catch (IllegalArgumentException ee) { - // expected - } - infl2.end(); - - infl3.setInput(output3, 0, dataLen3); - decLen = infl3.inflate(result); - - assertTrue(infl3.needsDictionary()); - infl3.setDictionary(dictionary1.getBytes()); - decLen = infl3.inflate(result); - infl3.end(); - assertEquals(inputString, new String(result, 0, decLen)); - - } -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipEntryTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipEntryTest.java deleted file mode 100644 index ee7aceb04..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipEntryTest.java +++ /dev/null @@ -1,647 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.zip; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import tests.support.resource.Support_Resources; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.TimeZone; -import java.util.zip.ZipEntry; - -@TestTargetClass(ZipEntry.class) -public class ZipEntryTest extends junit.framework.TestCase { - - // BEGIN android-added - public byte[] getAllBytesFromStream(InputStream is) throws IOException { - ByteArrayOutputStream bs = new ByteArrayOutputStream(); - byte[] buf = new byte[512]; - int iRead; - int off; - while (is.available() > 0) { - iRead = is.read(buf, 0, buf.length); - if (iRead > 0) bs.write(buf, 0, iRead); - } - return bs.toByteArray(); - } - - // END android-added - - // zip file hyts_ZipFile.zip must be included as a resource - java.util.zip.ZipEntry zentry; - - java.util.zip.ZipFile zfile; - - private static final String platformId = System.getProperty( - "com.ibm.oti.configuration", "JDK") - + System.getProperty("java.vm.version"); - - static final String tempFileName = platformId + "zipentrytest.zip"; - - long orgSize; - - long orgCompressedSize; - - long orgCrc; - - long orgTime; - - String orgComment; - - /** - * @tests java.util.zip.ZipEntry#ZipEntry(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "ZipEntry", - args = {java.lang.String.class} - ) - public void test_ConstructorLjava_lang_String() { - // Test for method java.util.zip.ZipEntry(java.lang.String) - zentry = zfile.getEntry("File3.txt"); - assertNotNull("Failed to create ZipEntry", zentry); - try { - zentry = zfile.getEntry(null); - fail("NullPointerException not thrown"); - } catch (NullPointerException e) { - } - StringBuffer s = new StringBuffer(); - for (int i = 0; i < 65535; i++) { - s.append('a'); - } - try { - zentry = new ZipEntry(s.toString()); - } catch (IllegalArgumentException e) { - fail("Unexpected IllegalArgumentException During Test."); - } - try { - s.append('a'); - zentry = new ZipEntry(s.toString()); - fail("IllegalArgumentException not thrown"); - } catch (IllegalArgumentException e) { - } - try { - String n = null; - zentry = new ZipEntry(n); - fail("NullPointerException not thrown"); - } catch (NullPointerException e) { - } - } - - /** - * @tests java.util.zip.ZipEntry#getComment() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getComment", - args = {} - ) - public void test_getComment() { - // Test for method java.lang.String java.util.zip.ZipEntry.getComment() - ZipEntry zipEntry = new ZipEntry("zippy.zip"); - assertNull("Incorrect Comment Returned.", zipEntry.getComment()); - zipEntry.setComment("This Is A Comment"); - assertEquals("Incorrect Comment Returned.", "This Is A Comment", - zipEntry.getComment()); - } - - /** - * @tests java.util.zip.ZipEntry#getCompressedSize() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getCompressedSize", - args = {} - ) - public void test_getCompressedSize() { - // Test for method long java.util.zip.ZipEntry.getCompressedSize() - assertTrue("Incorrect compressed size returned", zentry - .getCompressedSize() == orgCompressedSize); - } - - /** - * @tests java.util.zip.ZipEntry#getCrc() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getCrc", - args = {} - ) - public void test_getCrc() { - // Test for method long java.util.zip.ZipEntry.getCrc() - assertTrue("Failed to get Crc", zentry.getCrc() == orgCrc); - } - - /** - * @tests java.util.zip.ZipEntry#getExtra() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getExtra", - args = {} - ) - public void test_getExtra() { - // Test for method byte [] java.util.zip.ZipEntry.getExtra() - assertNull("Incorrect extra information returned", zentry.getExtra()); - byte[] ba = {'T', 'E', 'S', 'T'}; - zentry = new ZipEntry("test.tst"); - zentry.setExtra(ba); - assertTrue("Incorrect Extra Information Returned.", - zentry.getExtra() == ba); - } - - /** - * @tests java.util.zip.ZipEntry#getMethod() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getMethod", - args = {} - ) - public void test_getMethod() { - // Test for method int java.util.zip.ZipEntry.getMethod() - zentry = zfile.getEntry("File1.txt"); - assertTrue("Incorrect compression method returned", - zentry.getMethod() == java.util.zip.ZipEntry.STORED); - zentry = zfile.getEntry("File3.txt"); - assertTrue("Incorrect compression method returned", - zentry.getMethod() == java.util.zip.ZipEntry.DEFLATED); - zentry = new ZipEntry("test.tst"); - assertEquals("Incorrect Method Returned.", -1, zentry.getMethod()); - } - - /** - * @tests java.util.zip.ZipEntry#getName() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getName", - args = {} - ) - public void test_getName() { - // Test for method java.lang.String java.util.zip.ZipEntry.getName() - assertEquals( - "Incorrect name returned - Note return result somewhat ambiguous in spec", - "File1.txt", zentry.getName()); - } - - /** - * @tests java.util.zip.ZipEntry#getSize() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getSize", - args = {} - ) - public void test_getSize() { - // Test for method long java.util.zip.ZipEntry.getSize() - assertTrue("Incorrect size returned", zentry.getSize() == orgSize); - } - - /** - * @tests java.util.zip.ZipEntry#getTime() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getTime", - args = {} - ) - public void test_getTime() { - // Test for method long java.util.zip.ZipEntry.getTime() - assertTrue("Failed to get time", zentry.getTime() == orgTime); - } - - /** - * @tests java.util.zip.ZipEntry#isDirectory() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "isDirectory", - args = {} - ) - public void test_isDirectory() { - // Test for method boolean java.util.zip.ZipEntry.isDirectory() - assertTrue("Entry should not answer true to isDirectory", !zentry - .isDirectory()); - zentry = new ZipEntry("Directory/"); - assertTrue("Entry should answer true to isDirectory", zentry - .isDirectory()); - } - - /** - * @tests java.util.zip.ZipEntry#setComment(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setComment", - args = {java.lang.String.class} - ) - public void test_setCommentLjava_lang_String() { - // Test for method void - // java.util.zip.ZipEntry.setComment(java.lang.String) - zentry = zfile.getEntry("File1.txt"); - zentry.setComment("Set comment using api"); - assertEquals("Comment not correctly set", "Set comment using api", - zentry.getComment()); - String n = null; - zentry.setComment(n); - assertNull("Comment not correctly set", zentry.getComment()); - StringBuffer s = new StringBuffer(); - for (int i = 0; i < 0xFFFF; i++) { - s.append('a'); - } - try { - zentry.setComment(s.toString()); - } catch (IllegalArgumentException e) { - fail("Unexpected IllegalArgumentException During Test."); - } - try { - s.append('a'); - zentry.setComment(s.toString()); - fail("IllegalArgumentException not thrown"); - } catch (IllegalArgumentException e) { - } - } - - /** - * @tests java.util.zip.ZipEntry#setCompressedSize(long) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setCompressedSize", - args = {long.class} - ) - public void test_setCompressedSizeJ() { - // Test for method void java.util.zip.ZipEntry.setCompressedSize(long) - zentry.setCompressedSize(orgCompressedSize + 10); - assertTrue("Set compressed size failed", - zentry.getCompressedSize() == (orgCompressedSize + 10)); - zentry.setCompressedSize(0); - assertEquals("Set compressed size failed", 0, zentry - .getCompressedSize()); - zentry.setCompressedSize(-25); - assertEquals("Set compressed size failed", -25, zentry - .getCompressedSize()); - zentry.setCompressedSize(4294967296l); - assertTrue("Set compressed size failed", - zentry.getCompressedSize() == 4294967296l); - } - - /** - * @tests java.util.zip.ZipEntry#setCrc(long) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setCrc", - args = {long.class} - ) - public void test_setCrcJ() { - // Test for method void java.util.zip.ZipEntry.setCrc(long) - zentry.setCrc(orgCrc + 100); - assertTrue("Failed to set Crc", zentry.getCrc() == (orgCrc + 100)); - zentry.setCrc(0); - assertEquals("Failed to set Crc", 0, zentry.getCrc()); - try { - zentry.setCrc(-25); - fail("IllegalArgumentException not thrown"); - } catch (IllegalArgumentException e) { - } - try { - zentry.setCrc(4294967295l); - } catch (IllegalArgumentException e) { - fail("Unexpected IllegalArgumentException during test"); - } - try { - zentry.setCrc(4294967296l); - fail("IllegalArgumentException not thrown"); - } catch (IllegalArgumentException e) { - } - } - - /** - * @tests java.util.zip.ZipEntry#setExtra(byte[]) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setExtra", - args = {byte[].class} - ) - public void test_setExtra$B() { - // Test for method void java.util.zip.ZipEntry.setExtra(byte []) - zentry = zfile.getEntry("File1.txt"); - zentry.setExtra("Test setting extra information".getBytes()); - assertEquals("Extra information not written properly", - "Test setting extra information", new String(zentry.getExtra(), - 0, zentry.getExtra().length)); - zentry = new ZipEntry("test.tst"); - byte[] ba = new byte[0xFFFF]; - try { - zentry.setExtra(ba); - } catch (IllegalArgumentException e) { - fail("Unexpected IllegalArgumentException during test"); - } - try { - ba = new byte[0xFFFF + 1]; - zentry.setExtra(ba); - fail("IllegalArgumentException not thrown"); - } catch (IllegalArgumentException e) { - } - - // One constructor - ZipEntry zeInput = new ZipEntry("InputZIP"); - byte[] extraB = {'a', 'b', 'd', 'e'}; - zeInput.setExtra(extraB); - assertEquals(extraB, zeInput.getExtra()); - assertEquals(extraB[3], zeInput.getExtra()[3]); - assertEquals(extraB.length, zeInput.getExtra().length); - - // test another constructor - ZipEntry zeOutput = new ZipEntry(zeInput); - assertEquals(zeInput.getExtra()[3], zeOutput.getExtra()[3]); - assertEquals(zeInput.getExtra().length, zeOutput.getExtra().length); - assertEquals(extraB[3], zeOutput.getExtra()[3]); - assertEquals(extraB.length, zeOutput.getExtra().length); - } - - /** - * @tests java.util.zip.ZipEntry#setMethod(int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setMethod", - args = {int.class} - ) - public void test_setMethodI() { - // Test for method void java.util.zip.ZipEntry.setMethod(int) - zentry = zfile.getEntry("File3.txt"); - zentry.setMethod(ZipEntry.STORED); - assertTrue("Failed to set compression method", - zentry.getMethod() == ZipEntry.STORED); - zentry.setMethod(ZipEntry.DEFLATED); - assertTrue("Failed to set compression method", - zentry.getMethod() == ZipEntry.DEFLATED); - try { - int error = 1; - zentry = new ZipEntry("test.tst"); - zentry.setMethod(error); - fail("IllegalArgumentException not thrown"); - } catch (IllegalArgumentException e) { - } - } - - /** - * @tests java.util.zip.ZipEntry#setSize(long) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setSize", - args = {long.class} - ) - public void test_setSizeJ() { - // Test for method void java.util.zip.ZipEntry.setSize(long) - zentry.setSize(orgSize + 10); - assertTrue("Set size failed", zentry.getSize() == (orgSize + 10)); - zentry.setSize(0); - assertEquals("Set size failed", 0, zentry.getSize()); - try { - zentry.setSize(-25); - fail("IllegalArgumentException not thrown"); - } catch (IllegalArgumentException e) { - } - try { - zentry.setCrc(4294967295l); - } catch (IllegalArgumentException e) { - fail("Unexpected IllegalArgumentException during test"); - } - try { - zentry.setCrc(4294967296l); - fail("IllegalArgumentException not thrown"); - } catch (IllegalArgumentException e) { - } - } - - /** - * @tests java.util.zip.ZipEntry#setTime(long) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setTime", - args = {long.class} - ) - public void test_setTimeJ() { - // Test for method void java.util.zip.ZipEntry.setTime(long) - zentry.setTime(orgTime + 10000); - assertTrue("Test 1: Failed to set time: " + zentry.getTime(), zentry - .getTime() == (orgTime + 10000)); - zentry.setTime(orgTime - 10000); - assertTrue("Test 2: Failed to set time: " + zentry.getTime(), zentry - .getTime() == (orgTime - 10000)); - TimeZone zone = TimeZone.getDefault(); - try { - TimeZone.setDefault(TimeZone.getTimeZone("EST")); - zentry.setTime(0); - assertTrue("Test 3: Failed to set time: " + zentry.getTime(), - zentry.getTime() == 315550800000L); - TimeZone.setDefault(TimeZone.getTimeZone("GMT")); - assertTrue("Test 3a: Failed to set time: " + zentry.getTime(), - zentry.getTime() == 315532800000L); - zentry.setTime(0); - TimeZone.setDefault(TimeZone.getTimeZone("EST")); - assertTrue("Test 3b: Failed to set time: " + zentry.getTime(), - zentry.getTime() == 315550800000L); - - zentry.setTime(-25); - assertTrue("Test 4: Failed to set time: " + zentry.getTime(), - zentry.getTime() == 315550800000L); - zentry.setTime(4354837200000L); - assertTrue("Test 5: Failed to set time: " + zentry.getTime(), - zentry.getTime() == 315550800000L); - } finally { - TimeZone.setDefault(zone); - } - } - - /** - * @tests java.util.zip.ZipEntry#toString() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "toString", - args = {} - ) - public void test_toString() { - // Test for method java.lang.String java.util.zip.ZipEntry.toString() - assertTrue("Returned incorrect entry name", zentry.toString().indexOf( - "File1.txt") >= 0); - } - - /** - * @tests java.util.zip.ZipEntry#ZipEntry(java.util.zip.ZipEntry) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "ZipEntry", - args = {java.util.zip.ZipEntry.class} - ) - public void test_ConstructorLjava_util_zip_ZipEntry() { - // Test for method java.util.zip.ZipEntry(util.zip.ZipEntry) - zentry.setSize(2); - zentry.setCompressedSize(4); - zentry.setComment("Testing"); - ZipEntry zentry2 = new ZipEntry(zentry); - assertEquals("ZipEntry Created With Incorrect Size.", 2, zentry2 - .getSize()); - assertEquals("ZipEntry Created With Incorrect Compressed Size.", 4, - zentry2.getCompressedSize()); - assertEquals("ZipEntry Created With Incorrect Comment.", "Testing", - zentry2.getComment()); - assertTrue("ZipEntry Created With Incorrect Crc.", - zentry2.getCrc() == orgCrc); - assertTrue("ZipEntry Created With Incorrect Time.", - zentry2.getTime() == orgTime); - } - - /** - * @tests java.util.zip.ZipEntry#clone() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "clone", - args = {} - ) - public void test_clone() { - // Test for method java.util.zip.ZipEntry.clone() - Object obj = zentry.clone(); - assertTrue("toString()", obj.toString().equals(zentry.toString())); - assertTrue("hashCode()", obj.hashCode() == zentry.hashCode()); - - // One constructor - ZipEntry zeInput = new ZipEntry("InputZIP"); - byte[] extraB = {'a', 'b', 'd', 'e'}; - zeInput.setExtra(extraB); - assertEquals(extraB, zeInput.getExtra()); - assertEquals(extraB[3], zeInput.getExtra()[3]); - assertEquals(extraB.length, zeInput.getExtra().length); - - // test Clone() - ZipEntry zeOutput = (ZipEntry) zeInput.clone(); - assertEquals(zeInput.getExtra()[3], zeOutput.getExtra()[3]); - assertEquals(zeInput.getExtra().length, zeOutput.getExtra().length); - assertEquals(extraB[3], zeOutput.getExtra()[3]); - assertEquals(extraB.length, zeOutput.getExtra().length); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "hashCode", - args = {} - ) - public void test_hashCode() { - try { - zentry.hashCode(); - } catch (Exception ee) { - fail("Unexpected exception " + ee); - } - } - - /** - * Sets up the fixture, for example, open a network connection. This method - * is called before a test is executed. - */ - - @Override - protected void setUp() { - java.io.File f = null; - try { - // BEGIN android-changed - // Create a local copy of the file since some tests want to alter - // information. - f = File.createTempFile(tempFileName, ".zip"); - // Create absolute filename as ZipFile does not resolve using - // user.dir - f = new java.io.File(f.getAbsolutePath()); - f.delete(); - java.io.InputStream is = Support_Resources - .getStream("hyts_ZipFile.zip"); - java.io.FileOutputStream fos = new java.io.FileOutputStream(f); - byte[] rbuf = getAllBytesFromStream(is); - // END android-changed - fos.write(rbuf, 0, rbuf.length); - is.close(); - fos.close(); - zfile = new java.util.zip.ZipFile(f); - zentry = zfile.getEntry("File1.txt"); - orgSize = zentry.getSize(); - orgCompressedSize = zentry.getCompressedSize(); - orgCrc = zentry.getCrc(); - orgTime = zentry.getTime(); - orgComment = zentry.getComment(); - } catch (Exception e) { - System.out.println("Exception during ZipFile setup <" - + f.getAbsolutePath() + ">: "); - e.printStackTrace(); - } - } - - /** - * Tears down the fixture, for example, close a network connection. This - * method is called after a test is executed. - */ - - @Override - protected void tearDown() { - try { - if (zfile != null) { - zfile.close(); - } - java.io.File f = new java.io.File(tempFileName); - f.delete(); - } catch (java.io.IOException e) { - System.out.println("Exception during tearDown"); - } - } - -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipExceptionTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipExceptionTest.java deleted file mode 100644 index eb0477785..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipExceptionTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.zip; - -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import junit.framework.TestCase; - -import java.util.zip.ZipException; - -@TestTargetClass(ZipException.class) -public class ZipExceptionTest extends TestCase { - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "ZipException", - args = {} - ) - public void testZipException() { - ZipException zz = new ZipException(); - assertEquals(zz.getMessage(), null); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "ZipException", - args = {java.lang.String.class} - ) - public void testZipExceptionLjava_lang_String() { - ZipException zz = new ZipException("Test"); - assertEquals(zz.getMessage(), "Test"); - } - -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java deleted file mode 100644 index b025e1192..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java +++ /dev/null @@ -1,608 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.zip; - -import dalvik.annotation.KnownFailure; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; -import tests.support.Support_PlatformFile; -import tests.support.resource.Support_Resources; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FilePermission; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.security.Permission; -import java.util.Enumeration; -import java.util.zip.ZipEntry; -import java.util.zip.ZipException; -import java.util.zip.ZipFile; - -@TestTargetClass(ZipFile.class) -public class ZipFileTest extends junit.framework.TestCase { - - public byte[] getAllBytesFromStream(InputStream is) throws IOException { - ByteArrayOutputStream bs = new ByteArrayOutputStream(); - byte[] buf = new byte[512]; - int iRead; - int off; - while (is.available() > 0) { - iRead = is.read(buf, 0, buf.length); - if (iRead > 0) bs.write(buf, 0, iRead); - } - return bs.toByteArray(); - } - - // the file hyts_zipFile.zip in setup must be included as a resource - private String tempFileName; - - private ZipFile zfile; - - // custom security manager - SecurityManager sm = new SecurityManager() { - final String forbidenPermissionAction = "read"; - - - - public void checkPermission(Permission perm) { - // only check if it's a FilePermission because Locale checks - // for a PropertyPermission with action"read" to get system props. - if (perm instanceof FilePermission - && perm.getActions().equals(forbidenPermissionAction)) { - throw new SecurityException(); - } - } - }; - - /** - * @tests java.util.zip.ZipFile#ZipFile(java.io.File) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "setUp procedure checks this type of constructor.", - method = "ZipFile", - args = {java.io.File.class} - ) - public void test_ConstructorLjava_io_File() { - // Test for method java.util.zip.ZipFile(java.io.File) - assertTrue("Used to test", true); - } - - /** - * @tests java.util.zip.ZipFile#ZipFile(java.io.File, int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - method = "ZipFile", - args = {java.io.File.class, int.class} - ) - public void test_ConstructorLjava_io_FileI() throws IOException { - zfile.close(); // about to reopen the same temp file - File file = new File(tempFileName); - ZipFile zip = new ZipFile(file, ZipFile.OPEN_DELETE | ZipFile.OPEN_READ); - zip.close(); - assertTrue("Zip should not exist", !file.exists()); - file = new File(tempFileName); - file.delete(); - try { - zip = new ZipFile(file, ZipFile.OPEN_READ); - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - // IOException can not be checked throws ZipException in case of IO - // problems. - SecurityManager oldSm = System.getSecurityManager(); - System.setSecurityManager(sm); - try { - file = new File(tempFileName); - zip = new ZipFile(file, ZipFile.OPEN_READ); - fail("SecurityException expected"); - } catch (SecurityException e) { - // expected - } finally { - System.setSecurityManager(oldSm); - } - file = new File(tempFileName); - try { - zip = new ZipFile(file, -1); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException ee) { - // expected - } - } - - /** - * @throws IOException - * @tests java.util.zip.ZipFile#ZipFile(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Test contains empty brackets.", - method = "ZipFile", - args = {java.lang.String.class} - ) - public void test_ConstructorLjava_lang_String() throws IOException { - String oldUserDir = System.getProperty("user.dir"); - System.setProperty("user.dir", System.getProperty("java.io.tmpdir")); - - zfile.close(); // about to reopen the same temp file - ZipFile zip = new ZipFile(tempFileName); - zip.close(); - File file = File.createTempFile("zip", "tmp"); - try { - zip = new ZipFile(file.getName()); - fail("ZipException expected"); - } catch (ZipException ee) { - // expected - } - file.delete(); - // IOException can not be checked throws ZipException in case of IO - // problems. - SecurityManager oldSm = System.getSecurityManager(); - System.setSecurityManager(sm); - try { - zip = new ZipFile(tempFileName); - fail("SecurityException expected"); - } catch (SecurityException e) { - // expected - } finally { - System.setSecurityManager(oldSm); - System.setProperty("user.dir", oldUserDir); - } - } - - protected ZipEntry test_finalize1(ZipFile zip) { - return zip.getEntry("File1.txt"); - } - - protected ZipFile test_finalize2(File file) throws IOException { - return new ZipFile(file); - } - - /** - * @tests java.util.zip.ZipFile#finalize() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "finalize", - args = {} - ) - public void test_finalize() throws IOException { - InputStream in = Support_Resources.getStream("hyts_ZipFile.zip"); - File file = Support_Resources.createTempFile(".jar"); - OutputStream out = new FileOutputStream(file); - int result; - byte[] buf = new byte[4096]; - while ((result = in.read(buf)) != -1) { - out.write(buf, 0, result); - } - in.close(); - out.close(); - /* - * ZipFile zip = new ZipFile(file); ZipEntry entry1 = - * zip.getEntry("File1.txt"); assertNotNull("Did not find entry", - * entry1); entry1 = null; zip = null; - */ - - assertNotNull("Did not find entry", - test_finalize1(test_finalize2(file))); - System.gc(); - System.gc(); - System.runFinalization(); - file.delete(); - assertTrue("Zip should not exist", !file.exists()); - } - - /** - * @throws IOException - * @tests java.util.zip.ZipFile#close() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - method = "close", - args = {} - ) - public void test_close() throws IOException { - // Test for method void java.util.zip.ZipFile.close() - File fl = new File(tempFileName); - ZipFile zf = new ZipFile(fl); - InputStream is1 = zf.getInputStream(zf.getEntry("File1.txt")); - InputStream is2 = zf.getInputStream(zf.getEntry("File2.txt")); - - is1.read(); - is2.read(); - - zf.close(); - - try { - is1.read(); - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - - try { - is2.read(); - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - } - - /** - * @tests java.util.zip.ZipFile#entries() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "entries", - args = {} - ) - public void test_entries() throws Exception { - // Test for method java.util.Enumeration java.util.zip.ZipFile.entries() - Enumeration enumer = zfile.entries(); - int c = 0; - while (enumer.hasMoreElements()) { - ++c; - enumer.nextElement(); - } - assertTrue("Incorrect number of entries returned: " + c, c == 6); - - Enumeration enumeration = zfile.entries(); - zfile.close(); - zfile = null; - boolean pass = false; - try { - enumeration.hasMoreElements(); - } catch (IllegalStateException e) { - pass = true; - } - assertTrue("did not detect closed jar file", pass); - } - - /** - * @tests java.util.zip.ZipFile#getEntry(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - method = "getEntry", - args = {java.lang.String.class} - ) - public void test_getEntryLjava_lang_String() throws IOException { - // Test for method java.util.zip.ZipEntry - // java.util.zip.ZipFile.getEntry(java.lang.String) - java.util.zip.ZipEntry zentry = zfile.getEntry("File1.txt"); - assertNotNull("Could not obtain ZipEntry", zentry); - int r; - InputStream in; - - zentry = zfile.getEntry("testdir1/File1.txt"); - assertNotNull("Could not obtain ZipEntry: testdir1/File1.txt", zentry); - zentry = zfile.getEntry("testdir1/"); - assertNotNull("Could not obtain ZipEntry: testdir1/", zentry); - in = zfile.getInputStream(zentry); - assertNotNull("testdir1/ should not have null input stream", in); - r = in.read(); - in.close(); - assertEquals("testdir1/ should not contain data", -1, r); - - zentry = zfile.getEntry("testdir1/testdir1"); - assertNotNull("Could not obtain ZipEntry: testdir1/testdir1", zentry); - in = zfile.getInputStream(zentry); - byte[] buf = new byte[256]; - r = in.read(buf); - in.close(); - assertEquals("incorrect contents", "This is also text", new String(buf, - 0, r)); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - method = "getEntry", - args = {java.lang.String.class} - ) - public void test_getEntryLjava_lang_String_AndroidOnly() throws IOException { - java.util.zip.ZipEntry zentry = zfile.getEntry("File1.txt"); - assertNotNull("Could not obtain ZipEntry", zentry); - int r; - InputStream in; - - zentry = zfile.getEntry("testdir1"); - assertNotNull("Must be able to obtain ZipEntry: testdir1", zentry); - in = zfile.getInputStream(zentry); - /* - * Android delivers empty InputStream, RI no InputStream at all. The - * spec doesn't clarify this, so we need to deal with both situations. - */ - int data = -1; - if (in != null) { - data = in.read(); - in.close(); - } - assertEquals("Must not be able to read directory data", -1, data); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "IllegalStateException checking.", - method = "getEntry", - args = {java.lang.String.class} - ) - @KnownFailure("Android does not throw IllegalStateException when using " - + "getEntry() after close().") - public void test_getEntryLjava_lang_String_Ex() throws IOException { - java.util.zip.ZipEntry zentry = zfile.getEntry("File1.txt"); - assertNotNull("Could not obtain ZipEntry", zentry); - int r; - InputStream in; - - zfile.close(); - try { - zentry = zfile.getEntry("File2.txt"); - fail("IllegalStateException expected"); // Android fails here! - } catch (IllegalStateException ee) { - // expected - } - } - - /** - * @throws IOException - * @tests java.util.zip.ZipFile#getInputStream(java.util.zip.ZipEntry) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getInputStream", - args = {java.util.zip.ZipEntry.class} - ) - public void test_getInputStreamLjava_util_zip_ZipEntry() throws IOException { - // Test for method java.io.InputStream - // java.util.zip.ZipFile.getInputStream(java.util.zip.ZipEntry) - ZipEntry zentry = null; - InputStream is = null; - try { - zentry = zfile.getEntry("File1.txt"); - is = zfile.getInputStream(zentry); - byte[] rbuf = new byte[1000]; - int r; - is.read(rbuf, 0, r = (int) zentry.getSize()); - assertEquals("getInputStream read incorrect data", "This is text", - new String(rbuf, 0, r)); - } catch (java.io.IOException e) { - fail("IOException during getInputStream"); - } finally { - try { - is.close(); - } catch (java.io.IOException e) { - fail("Failed to close input stream"); - } - } - - zentry = zfile.getEntry("File2.txt"); - zfile.close(); - try { - is = zfile.getInputStream(zentry); - fail("IllegalStateException expected"); - } catch (IllegalStateException ee) { - // expected - } - - // ZipException can not be checked. Stream object returned or null. - } - - /** - * @tests java.util.zip.ZipFile#getName() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getName", - args = {} - ) - public void test_getName() { - // Test for method java.lang.String java.util.zip.ZipFile.getName() - assertTrue("Returned incorrect name: " + zfile.getName(), zfile - .getName().equals(tempFileName)); - } - - /** - * @throws IOException - * @tests java.util.zip.ZipFile#size() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - method = "size", - args = {} - ) - @KnownFailure("IllegalStateException not thrown when using ZipFile.size() " - + "after close().") - public void test_size() throws IOException { - assertEquals(6, zfile.size()); - zfile.close(); - try { - zfile.size(); - fail("IllegalStateException expected"); // Android fails here! - } catch (IllegalStateException ee) { - // expected - } - } - - /** - * @tests java.io.InputStream#reset() - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - method = "getInputStream", - args = {java.util.zip.ZipEntry.class} - ) - @KnownFailure("ZipEntry.getInputStream().reset() fails with an IOException") - public void test_reset() throws IOException { - // read an uncompressed entry - ZipEntry zentry = zfile.getEntry("File1.txt"); - InputStream is = zfile.getInputStream(zentry); - byte[] rbuf1 = new byte[6]; - byte[] rbuf2 = new byte[6]; - int r1, r2; - r1 = is.read(rbuf1); - assertEquals(rbuf1.length, r1); - r2 = is.read(rbuf2); - assertEquals(rbuf2.length, r2); - - is.reset(); - r2 = is.read(rbuf2); - assertEquals(rbuf2.length, r2); - is.close(); - - // read a compressed entry - byte[] rbuf3 = new byte[4185]; - ZipEntry zentry2 = zfile.getEntry("File3.txt"); - is = zfile.getInputStream(zentry2); - r1 = is.read(rbuf3); - assertEquals(4183, r1); - is.reset(); - - r1 = is.read(rbuf3); - assertEquals(4183, r1); - is.close(); - - is = zfile.getInputStream(zentry2); - r1 = is.read(rbuf3, 0, 3000); - assertEquals(3000, r1); - is.reset(); - r1 = is.read(rbuf3, 0, 3000); - assertEquals(3000, r1); - is.close(); - } - - /** - * @tests java.io.InputStream#reset() - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - method = "getInputStream", - args = {java.util.zip.ZipEntry.class} - ) - @KnownFailure("ZipEntry.getInputStream().reset() fails with an IOException") - public void test_reset_subtest0() throws IOException { - // read an uncompressed entry - ZipEntry zentry = zfile.getEntry("File1.txt"); - InputStream is = zfile.getInputStream(zentry); - byte[] rbuf1 = new byte[12]; - byte[] rbuf2 = new byte[12]; - int r = is.read(rbuf1, 0, 4); - assertEquals(4, r); - is.mark(0); - r = is.read(rbuf1); - assertEquals(8, r); - assertEquals(-1, is.read()); - - is.reset(); - r = is.read(rbuf2); - assertEquals(8, r); - assertEquals(-1, is.read()); - is.close(); - - // read a compressed entry - byte[] rbuf3 = new byte[4185]; - ZipEntry zentry2 = zfile.getEntry("File3.txt"); - is = zfile.getInputStream(zentry2); - r = is.read(rbuf3, 0, 3000); - assertEquals(3000, r); - is.mark(0); - r = is.read(rbuf3); - assertEquals(1183, r); - assertEquals(-1, is.read()); - - is.reset(); - r = is.read(rbuf3); - assertEquals(1183, r); - assertEquals(-1, is.read()); - is.close(); - } - - /** - * Sets up the fixture, for example, open a network connection. This method - * is called before a test is executed. - */ - @Override - protected void setUp() { - try { - // Create a local copy of the file since some tests want to alter - // information. - tempFileName = System.getProperty("java.io.tmpdir"); - String separator = System.getProperty("file.separator"); - if (tempFileName.charAt(tempFileName.length() - 1) == separator - .charAt(0)) { - tempFileName = Support_PlatformFile.getNewPlatformFile( - tempFileName, "gabba.zip"); - } else { - tempFileName = Support_PlatformFile.getNewPlatformFile( - tempFileName + separator, "gabba.zip"); - } - - File f = new File(tempFileName); - f.delete(); - InputStream is = Support_Resources.getStream("hyts_ZipFile.zip"); - FileOutputStream fos = new FileOutputStream(f); - byte[] rbuf = getAllBytesFromStream(is); - fos.write(rbuf, 0, rbuf.length); - is.close(); - fos.close(); - zfile = new ZipFile(f); - } catch (Exception e) { - System.out.println("Exception during ZipFile setup:"); - e.printStackTrace(); - } - } - - /** - * Tears down the fixture, for example, close a network connection. This - * method is called after a test is executed. - */ - @Override - protected void tearDown() { - try { - if (zfile != null) { - // Note zfile is a user-defined zip file used by other tests and - // should not be deleted - zfile.close(); - tempFileName = System.getProperty("java.io.tmpdir"); - String separator = System.getProperty("file.separator"); - if (tempFileName.charAt(tempFileName.length() - 1) == separator - .charAt(0)) { - tempFileName = Support_PlatformFile.getNewPlatformFile( - tempFileName, "gabba.zip"); - } else { - tempFileName = Support_PlatformFile.getNewPlatformFile( - tempFileName + separator, "gabba.zip"); - } - - File f = new File(tempFileName); - f.delete(); - } - } catch (Exception e) { - } - } - -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java deleted file mode 100644 index c5efedcd5..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java +++ /dev/null @@ -1,443 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.zip; - -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; - -import junit.framework.TestCase; - -import tests.support.resource.Support_Resources; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipException; -import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; - -@TestTargetClass(ZipInputStream.class) -public class ZipInputStreamTest extends TestCase { - // the file hyts_zipFile.zip used in setup needs to included as a resource - private ZipEntry zentry; - - private ZipInputStream zis; - - private byte[] zipBytes; - - private byte[] dataBytes = "Some data in my file".getBytes(); - - @Override - protected void setUp() { - try { - InputStream is = Support_Resources.getStream("hyts_ZipFile.zip"); - if (is == null) { - System.out.println("file hyts_ZipFile.zip can not be found"); - } - zis = new ZipInputStream(is); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - ZipOutputStream zos = new ZipOutputStream(bos); - ZipEntry entry = new ZipEntry("myFile"); - zos.putNextEntry(entry); - zos.write(dataBytes); - zos.closeEntry(); - zos.close(); - zipBytes = bos.toByteArray(); - } catch (Exception e) { - System.out.println("Exception during ZipFile setup:"); - e.printStackTrace(); - } - } - - @Override - protected void tearDown() { - if (zis != null) { - try { - zis.close(); - } catch (Exception e) { - } - } - } - - /** - * @tests java.util.zip.ZipInputStream#ZipInputStream(java.io.InputStream) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "ZipInputStream", - args = {java.io.InputStream.class} - ) - public void test_ConstructorLjava_io_InputStream() throws Exception { - zentry = zis.getNextEntry(); - zis.closeEntry(); - } - - /** - * @tests java.util.zip.ZipInputStream#close() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "close", - args = {} - ) - public void test_close() { - try { - zis.close(); - byte[] rbuf = new byte[10]; - zis.read(rbuf, 0, 1); - } catch (IOException e) { - return; - } - fail("Read data after stream was closed"); - } - - /** - * @tests java.util.zip.ZipInputStream#close() - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks calling method two times", - method = "close", - args = {} - ) - public void test_close2() throws Exception { - // Regression for HARMONY-1101 - zis.close(); - // another call to close should NOT cause an exception - zis.close(); - } - - /** - * @tests java.util.zip.ZipInputStream#closeEntry() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "closeEntry", - args = {} - ) - public void test_closeEntry() throws Exception { - zentry = zis.getNextEntry(); - zis.closeEntry(); - zentry = zis.getNextEntry(); - zis.close(); - try { - zis.closeEntry(); - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - File resources = Support_Resources.createTempFolder(); - Support_Resources.copyFile(resources, null, "Broken_manifest.jar"); - FileInputStream fis = new FileInputStream(new File(resources, - "Broken_manifest.jar")); - - ZipInputStream zis1 = new ZipInputStream(fis); - - try { - for (int i = 0; i < 6; i++) { - zis1.getNextEntry(); - zis1.closeEntry(); - } - fail("ZipException expected"); - } catch (ZipException ee) { - // expected - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - method = "close", - args = {} - ) - public void test_closeAfterException() throws Exception { - File resources = Support_Resources.createTempFolder(); - Support_Resources.copyFile(resources, null, "Broken_manifest.jar"); - FileInputStream fis = new FileInputStream(new File(resources, - "Broken_manifest.jar")); - - ZipInputStream zis1 = new ZipInputStream(fis); - - try { - for (int i = 0; i < 6; i++) { - zis1.getNextEntry(); - } - fail("ZipException expected"); - } catch (ZipException ee) { - // expected - } - - zis1.close(); - try { - zis1.getNextEntry(); - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - } - - /** - * @tests java.util.zip.ZipInputStream#getNextEntry() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - method = "getNextEntry", - args = {} - ) - public void test_getNextEntry() throws Exception { - assertNotNull("getNextEntry failed", zis.getNextEntry()); - - File resources = Support_Resources.createTempFolder(); - Support_Resources.copyFile(resources, null, "Broken_manifest.jar"); - FileInputStream fis = new FileInputStream(new File(resources, - "Broken_manifest.jar")); - - ZipInputStream zis1 = new ZipInputStream(fis); - - try { - for (int i = 0; i < 6; i++) { - zis1.getNextEntry(); - } - fail("ZipException expected"); - } catch (ZipException ee) { - // expected - } - - try { - zis1.close(); // Android throws exception here, already! - zis1.getNextEntry(); // But RI here, only! - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - } - - /** - * @tests java.util.zip.ZipInputStream#read(byte[], int, int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - method = "read", - args = {byte[].class, int.class, int.class} - ) - public void test_read$BII() throws Exception { - zentry = zis.getNextEntry(); - byte[] rbuf = new byte[(int) zentry.getSize()]; - int r = zis.read(rbuf, 0, rbuf.length); - new String(rbuf, 0, r); - assertEquals("Failed to read entry", 12, r); - - File resources = Support_Resources.createTempFolder(); - Support_Resources.copyFile(resources, null, "Broken_manifest.jar"); - FileInputStream fis = new FileInputStream(new File(resources, - "Broken_manifest.jar")); - - ZipInputStream zis1 = new ZipInputStream(fis); - - zis1.getNextEntry(); - zis1.getNextEntry(); - - rbuf = new byte[100]; - - try { - zis1.read(rbuf, 10, 90); - fail("ZipException expected"); - } catch (ZipException ee) { - // expected - } - - try { - zis1.close(); // Android throws exception here, already! - zis1.read(rbuf, 10, 90); // But RI here, only! - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - method = "read", - args = {byte[].class, int.class, int.class} - ) - public void testReadOneByteAtATime() throws IOException { - InputStream in = new FilterInputStream(Support_Resources.getStream("hyts_ZipFile.zip")) { - @Override - public int read(byte[] buffer, int offset, int count) throws IOException { - return super.read(buffer, offset, 1); // one byte at a time - } - - @Override - public int read(byte[] buffer) throws IOException { - return super.read(buffer, 0, 1); // one byte at a time - } - }; - - zis = new ZipInputStream(in); - while ((zentry = zis.getNextEntry()) != null) { - zentry.getName(); - } - zis.close(); - } - - /** - * @tests java.util.zip.ZipInputStream#skip(long) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - method = "skip", - args = {long.class} - ) - public void test_skipJ() throws Exception { - zentry = zis.getNextEntry(); - byte[] rbuf = new byte[(int) zentry.getSize()]; - zis.skip(2); - int r = zis.read(rbuf, 0, rbuf.length); - assertEquals("Failed to skip data", 10, r); - - zentry = zis.getNextEntry(); - zentry = zis.getNextEntry(); - long s = zis.skip(1025); - assertTrue("invalid skip: " + s, s == 1025); - - ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream( - zipBytes)); - zis.getNextEntry(); - long skipLen = dataBytes.length / 2; - assertEquals("Assert 0: failed valid skip", skipLen, zis.skip(skipLen)); - zis.skip(dataBytes.length); - assertEquals("Assert 1: performed invalid skip", 0, zis.skip(1)); - assertEquals("Assert 2: failed zero len skip", 0, zis.skip(0)); - try { - zis.skip(-1); - fail("Assert 3: Expected Illegal argument exception"); - } catch (IllegalArgumentException e) { - // Expected - } - - File resources = Support_Resources.createTempFolder(); - Support_Resources.copyFile(resources, null, "Broken_manifest.jar"); - FileInputStream fis = new FileInputStream(new File(resources, - "Broken_manifest.jar")); - - ZipInputStream zis1 = new ZipInputStream(fis); - - zis1.getNextEntry(); - zis1.getNextEntry(); - - try { - zis1.skip(10); - fail("ZipException expected"); - } catch (ZipException ee) { - // expected - } - - try { - zis1.close(); // Android throws exception here, already! - zis1.skip(10); // But RI here, only! - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - method = "available", - args = {} - ) - public void test_available() throws Exception { - - File resources = Support_Resources.createTempFolder(); - Support_Resources.copyFile(resources, null, "hyts_ZipFile.zip"); - File fl = new File(resources, "hyts_ZipFile.zip"); - FileInputStream fis = new FileInputStream(fl); - - ZipInputStream zis1 = new ZipInputStream(fis); - ZipEntry entry = zis1.getNextEntry(); - assertNotNull("No entry in the archive.", entry); - long entrySize = entry.getSize(); - assertTrue("Entry size was < 1", entrySize > 0); - int i = 0; - while (zis1.available() > 0) { - zis1.skip(1); - i++; - } - if (i != entrySize) { - fail("ZipInputStream.available or ZipInputStream.skip does not " + - "working properly. Only skipped " + i + - " bytes instead of " + entrySize); - } - assertEquals(0, zis1.skip(1)); - assertEquals(0, zis1.available()); - zis1.closeEntry(); - assertEquals(1, zis.available()); - zis1.close(); - try { - zis1.available(); - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - } - - class Mock_ZipInputStream extends ZipInputStream { - boolean createFlag = false; - - public Mock_ZipInputStream(InputStream arg0) { - super(arg0); - } - - boolean getCreateFlag() { - return createFlag; - } - - protected ZipEntry createZipEntry(String name) { - createFlag = true; - return super.createZipEntry(name); - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "createZipEntry", - args = {java.lang.String.class} - ) - public void test_createZipEntryLjava_lang_String() throws Exception { - - File resources = Support_Resources.createTempFolder(); - Support_Resources.copyFile(resources, null, "Broken_manifest.jar"); - File fl = new File(resources, "Broken_manifest.jar"); - FileInputStream fis = new FileInputStream(fl); - - Mock_ZipInputStream zis1 = new Mock_ZipInputStream(fis); - assertFalse(zis1.getCreateFlag()); - zis1.getNextEntry(); - assertTrue(zis1.getCreateFlag()); - } -} diff --git a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipOutputStreamTest.java b/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipOutputStreamTest.java deleted file mode 100644 index 0398f03fd..000000000 --- a/libcore/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipOutputStreamTest.java +++ /dev/null @@ -1,381 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.archive.tests.java.util.zip; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.zip.CRC32; -import java.util.zip.ZipEntry; -import java.util.zip.ZipException; -import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; - -@TestTargetClass(ZipOutputStream.class) -public class ZipOutputStreamTest extends junit.framework.TestCase { - - ZipOutputStream zos; - - ByteArrayOutputStream bos; - - ZipInputStream zis; - - static final String data = "HelloWorldHelloWorldHelloWorldHelloWorldHelloWorldHelloWorldHelloWorldHelloWorldHelloWorldHelloWorldHelloWorldHelloWorldHelloWorld"; - - /** - * @tests java.util.zip.ZipOutputStream#close() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Can not check IOException.", - method = "close", - args = {} - ) - public void test_close() throws Exception { - try { - zos.close(); - fail("Close on empty stream failed to throw exception"); - } catch (ZipException e) { - // expected - } - - zos = new ZipOutputStream(bos); - zos.putNextEntry(new ZipEntry("XX")); - zos.closeEntry(); - zos.close(); - - // Regression for HARMONY-97 - ZipOutputStream zos = new ZipOutputStream(new ByteArrayOutputStream()); - zos.putNextEntry(new ZipEntry("myFile")); - zos.close(); - zos.close(); // Should be a no-op - } - - /** - * @tests java.util.zip.ZipOutputStream#closeEntry() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "ZipException can not be checked.", - method = "closeEntry", - args = {} - ) - public void test_closeEntry() throws IOException { - ZipEntry ze = new ZipEntry("testEntry"); - ze.setTime(System.currentTimeMillis()); - zos.putNextEntry(ze); - zos.write("Hello World".getBytes("UTF-8")); - zos.closeEntry(); - assertTrue("closeEntry failed to update required fields", - ze.getSize() == 11 && ze.getCompressedSize() == 13); - ze = new ZipEntry("testEntry1"); - zos.close(); - try { - zos.closeEntry(); - fail("IOException expected"); - } catch (IOException ee) { - // expected - } - } - - /** - * @tests java.util.zip.ZipOutputStream#finish() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "ZipException can not be checked.", - method = "finish", - args = {} - ) - public void test_finish() throws Exception { - ZipEntry ze = new ZipEntry("test"); - zos.putNextEntry(ze); - zos.write("Hello World".getBytes()); - zos.finish(); - assertEquals("Finish failed to closeCurrentEntry", 11, ze.getSize()); - - ZipOutputStream zos = new ZipOutputStream(new ByteArrayOutputStream()); - zos.putNextEntry(new ZipEntry("myFile")); - zos.finish(); - zos.close(); - try { - zos.finish(); - fail("Assert 0: Expected IOException"); - } catch (IOException e) { - // Expected - } - } - - /** - * @tests java.util.zip.ZipOutputStream#putNextEntry(java.util.zip.ZipEntry) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "ZipException can not be checked.", - method = "putNextEntry", - args = {java.util.zip.ZipEntry.class} - ) - public void test_putNextEntryLjava_util_zip_ZipEntry() throws IOException { - ZipEntry ze = new ZipEntry("testEntry"); - ze.setTime(System.currentTimeMillis()); - zos.putNextEntry(ze); - zos.write("Hello World".getBytes()); - zos.closeEntry(); - zos.close(); - zis = new ZipInputStream(new ByteArrayInputStream(bos.toByteArray())); - ZipEntry ze2 = zis.getNextEntry(); - zis.closeEntry(); - assertTrue("Failed to write correct entry", ze.getName().equals( - ze2.getName()) - && ze.getCrc() == ze2.getCrc()); - try { - zos.putNextEntry(ze); - fail("Entry with incorrect setting failed to throw exception"); - } catch (IOException e) { - // expected - } - } - - /** - * @tests java.util.zip.ZipOutputStream#setComment(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setComment", - args = {java.lang.String.class} - ) - public void test_setCommentLjava_lang_String() { - // There is no way to get the comment back, so no way to determine if - // the comment is set correct - zos.setComment("test setComment"); - - try { - zos.setComment(new String(new byte[0xFFFF + 1])); - fail("Comment over 0xFFFF in length should throw exception"); - } catch (IllegalArgumentException e) { - // Passed - } - } - - /** - * @tests java.util.zip.ZipOutputStream#setLevel(int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setLevel", - args = {int.class} - ) - public void test_setLevelI() throws IOException { - ZipEntry ze = new ZipEntry("test"); - zos.putNextEntry(ze); - zos.write(data.getBytes()); - zos.closeEntry(); - long csize = ze.getCompressedSize(); - zos.setLevel(9); // Max Compression - zos.putNextEntry(ze = new ZipEntry("test2")); - zos.write(data.getBytes()); - zos.closeEntry(); - assertTrue("setLevel failed", csize <= ze.getCompressedSize()); - try { - zos.setLevel(-9); // Max Compression - fail("IllegalArgumentException ecpected."); - } catch (IllegalArgumentException ee) { - // expected - } - } - - /** - * @tests java.util.zip.ZipOutputStream#setMethod(int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setMethod", - args = {int.class} - ) - public void test_setMethodI() throws IOException { - ZipEntry ze = new ZipEntry("test"); - zos.setMethod(ZipOutputStream.STORED); - CRC32 tempCrc = new CRC32(); - tempCrc.update(data.getBytes()); - ze.setCrc(tempCrc.getValue()); - ze.setSize(new String(data).length()); - zos.putNextEntry(ze); - zos.write(data.getBytes()); - zos.closeEntry(); - long csize = ze.getCompressedSize(); - zos.setMethod(ZipOutputStream.DEFLATED); - zos.putNextEntry(ze = new ZipEntry("test2")); - zos.write(data.getBytes()); - zos.closeEntry(); - assertTrue("setLevel failed", csize >= ze.getCompressedSize()); - try { - zos.setMethod(-ZipOutputStream.DEFLATED); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException ee) { - // expected - } - } - - /** - * @tests java.util.zip.ZipOutputStream#write(byte[], int, int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "write", - args = {byte[].class, int.class, int.class} - ) - public void test_write$BII() throws IOException { - ZipEntry ze = new ZipEntry("test"); - zos.putNextEntry(ze); - zos.write(data.getBytes()); - zos.closeEntry(); - zos.close(); - zos = null; - zis = new ZipInputStream(new ByteArrayInputStream(bos.toByteArray())); - zis.getNextEntry(); - byte[] b = new byte[data.length()]; - int r = 0; - int count = 0; - while (count != b.length && (r = zis.read(b, count, b.length)) != -1) { - count += r; - } - zis.closeEntry(); - assertTrue("Write failed to write correct bytes", new String(b) - .equals(data)); - - File f = File.createTempFile("testZip", "tst"); - f.deleteOnExit(); - FileOutputStream stream = new FileOutputStream(f); - ZipOutputStream zip = new ZipOutputStream(stream); - zip.setMethod(ZipEntry.STORED); - - try { - zip.putNextEntry(new ZipEntry("Second")); - fail("Not set an entry. Should have thrown ZipException."); - } catch (ZipException e) { - // expected -- We have not set an entry - } - - try { - // We try to write data without entry - zip.write(new byte[2]); - fail("Writing data without an entry. Should have thrown IOException"); - } catch (IOException e) { - // expected - } - - try { - // Try to write without an entry and with nonsense offset and - // length - zip.write(new byte[2], 0, 12); - fail("Writing data without an entry. Should have thrown IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - // expected - } - - // Regression for HARMONY-4405 - try { - zip.write(null, 0, -2); - fail("Should throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - // expected - } - - // Close stream because ZIP is invalid - stream.close(); - } - - /** - * @tests java.util.zip.ZipOutputStream#write(byte[], int, int) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Regression", - method = "write", - args = {byte[].class, int.class, int.class} - ) - public void test_write$BII_2() throws IOException { - // Regression for HARMONY-577 - File f1 = File.createTempFile("testZip1", "tst"); - f1.deleteOnExit(); - FileOutputStream stream1 = new FileOutputStream(f1); - ZipOutputStream zip1 = new ZipOutputStream(stream1); - zip1.putNextEntry(new ZipEntry("one")); - zip1.setMethod(ZipOutputStream.STORED); - zip1.setMethod(ZipEntry.STORED); - - zip1.write(new byte[2]); - - try { - zip1.putNextEntry(new ZipEntry("Second")); - fail("ZipException expected"); - } catch (ZipException e) { - // expected - We have not set an entry - } - - try { - zip1.write(new byte[2]); // try to write data without entry - fail("expected IOE there"); - } catch (IOException e2) { - // expected - } - - zip1.close(); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - zos = new ZipOutputStream(bos = new ByteArrayOutputStream()); - } - - @Override - protected void tearDown() throws Exception { - try { - if (zos != null) { - zos.close(); - } - if (zis != null) { - zis.close(); - } - } catch (Exception e) { - } - super.tearDown(); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "See setUp procedure for more info.", - method = "ZipOutputStream", - args = {java.io.OutputStream.class} - ) - public void test_ConstructorLjava_io_OutputStream() { - assertTrue(true); - } -} diff --git a/libcore/archive/src/test/java/tests/archive/AllTests.java b/libcore/archive/src/test/java/tests/archive/AllTests.java deleted file mode 100644 index a5c461cf0..000000000 --- a/libcore/archive/src/test/java/tests/archive/AllTests.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package tests.archive; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class AllTests { - - public static void main(String[] args) { - junit.textui.TestRunner.run(AllTests.suite()); - } - - public static Test suite() { - TestSuite suite = tests.TestSuiteFactory.createTestSuite("All Archive test suites"); - // $JUnit-BEGIN$ - suite.addTest(org.apache.harmony.archive.tests.java.util.jar.AllTests - .suite()); - suite.addTest(org.apache.harmony.archive.tests.java.util.zip.AllTests - .suite()); - // $JUnit-END$ - return suite; - } -} diff --git a/libcore/auth/MODULE_LICENSE_APACHE2 b/libcore/auth/MODULE_LICENSE_APACHE2 deleted file mode 100644 index e69de29bb..000000000 diff --git a/libcore/auth/src/main/java/javax/security/auth/AuthPermission.java b/libcore/auth/src/main/java/javax/security/auth/AuthPermission.java deleted file mode 100644 index 697d5c7bd..000000000 --- a/libcore/auth/src/main/java/javax/security/auth/AuthPermission.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.security.auth; - -import java.security.BasicPermission; - -import org.apache.harmony.auth.internal.nls.Messages; - -/** - * Governs the use of methods in this package and also its subpackages. A - * target name of the permission specifies which methods are allowed - * without specifying the concrete action lists. Possible target names and - * associated authentication permissions are: - * - *
- *    doAs                      invoke Subject.doAs methods.
- *    doAsPrivileged            invoke the Subject.doAsPrivileged methods.
- *    getSubject                invoke Subject.getSubject().
- *    getSubjectFromDomainCombiner    invoke SubjectDomainCombiner.getSubject().
- *    setReadOnly               invoke Subject.setReadonly().
- *    modifyPrincipals          modify the set of principals
- *                              associated with a Subject.
- *    modifyPublicCredentials   modify the set of public credentials
- *                              associated with a Subject.
- *    modifyPrivateCredentials  modify the set of private credentials
- *                              associated with a Subject.
- *    refreshCredential         invoke the refresh method on a credential of a
- *                              refreshable credential class.
- *    destroyCredential         invoke the destroy method on a credential of a
- *                              destroyable credential class.
- *    createLoginContext.name   instantiate a LoginContext with the
- *                              specified name. The wildcard name ('*')
- *                              allows to a LoginContext of any name.
- *    getLoginConfiguration     invoke the getConfiguration method of
- *                              javax.security.auth.login.Configuration.
- *    refreshLoginConfiguration Invoke the refresh method of
- *                              javax.security.auth.login.Configuration.
- * 
- */ -public final class AuthPermission extends BasicPermission { - - private static final long serialVersionUID = 5806031445061587174L; - - private static final String CREATE_LOGIN_CONTEXT = "createLoginContext"; //$NON-NLS-1$ - - private static final String CREATE_LOGIN_CONTEXT_ANY = "createLoginContext.*"; //$NON-NLS-1$ - - // inits permission name. - private static String init(String name) { - - if (name == null) { - throw new NullPointerException(Messages.getString("auth.13")); //$NON-NLS-1$ - } - - if (CREATE_LOGIN_CONTEXT.equals(name)) { - return CREATE_LOGIN_CONTEXT_ANY; - } - return name; - } - - /** - * Creates an authentication permission with the specified target name. - * - * @param name - * the target name of this authentication permission. - */ - public AuthPermission(String name) { - super(init(name)); - } - - /** - * Creates an authentication permission with the specified target name. - * - * @param name - * the target name of this authentication permission. - * @param actions - * this parameter is ignored and should be {@code null}. - */ - public AuthPermission(String name, String actions) { - super(init(name), actions); - } -} \ No newline at end of file diff --git a/libcore/auth/src/main/java/javax/security/auth/DestroyFailedException.java b/libcore/auth/src/main/java/javax/security/auth/DestroyFailedException.java deleted file mode 100644 index 27d4dfdcf..000000000 --- a/libcore/auth/src/main/java/javax/security/auth/DestroyFailedException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.security.auth; - -/** - * Signals that the {@link Destroyable#destroy()} method failed. - */ -public class DestroyFailedException extends Exception { - - private static final long serialVersionUID = -7790152857282749162L; - - /** - * Creates an exception of type {@code DestroyFailedException}. - */ - public DestroyFailedException() { - super(); - } - - /** - * Creates an exception of type {@code DestroyFailedException}. - * - * @param message - * A detail message that describes the reason for this exception. - */ - public DestroyFailedException(String message) { - super(message); - } - -} diff --git a/libcore/auth/src/main/java/javax/security/auth/Destroyable.java b/libcore/auth/src/main/java/javax/security/auth/Destroyable.java deleted file mode 100644 index b4d0fa2aa..000000000 --- a/libcore/auth/src/main/java/javax/security/auth/Destroyable.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.security.auth; - -/** - * Allows for special treatment of sensitive information, when it comes to - * destroying or clearing of the data. - */ -public interface Destroyable { - - /** - * Erases the sensitive information. Once an object is destroyed any calls - * to its methods will throw an {@code IllegalStateException}. If it does - * not succeed a DestroyFailedException is thrown. - * - * @throws DestroyFailedException - * if the information cannot be erased. - */ - void destroy() throws DestroyFailedException; - - /** - * Returns {@code true} once an object has been safely destroyed. - * - * @return whether the object has been safely destroyed. - */ - boolean isDestroyed(); - -} diff --git a/libcore/auth/src/main/java/javax/security/auth/PrivateCredentialPermission.java b/libcore/auth/src/main/java/javax/security/auth/PrivateCredentialPermission.java deleted file mode 100644 index 35072b85a..000000000 --- a/libcore/auth/src/main/java/javax/security/auth/PrivateCredentialPermission.java +++ /dev/null @@ -1,388 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.security.auth; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.Serializable; -import java.security.Permission; -import java.security.PermissionCollection; -import java.security.Principal; -import java.util.Set; - -import org.apache.harmony.auth.internal.nls.Messages; - -/** - * Protects private credential objects belonging to a {@code Subject}. It has - * only one action which is "read". The target name of this permission has a - * special syntax: - * - *
- * targetName = CredentialClass {PrincipalClass "PrincipalName"}*
- * 
- * - * First it states a credential class and is followed then by a list of one or - * more principals identifying the subject. - *

- * The principals on their part are specified as the name of the {@code - * Principal} class followed by the principal name in quotes. For example, the - * following file may define permission to read the private credentials of a - * principal named "Bob": "com.sun.PrivateCredential com.sun.Principal \"Bob\"" - *

- * The syntax also allows the use of the wildcard "*" in place of {@code - * CredentialClass} or {@code PrincipalClass} and/or {@code PrincipalName}. - * - * @see Principal - */ -public final class PrivateCredentialPermission extends Permission { - - private static final long serialVersionUID = 5284372143517237068L; - - // allowed action - private static final String READ = "read"; //$NON-NLS-1$ - - private String credentialClass; - - // current offset - private transient int offset; - - // owners set - private transient CredOwner[] set; - - /** - * Creates a new permission for private credentials specified by the target - * name {@code name} and an {@code action}. The action is always - * {@code "read"}. - * - * @param name - * the target name of the permission. - * @param action - * the action {@code "read"}. - */ - public PrivateCredentialPermission(String name, String action) { - super(name); - if (READ.equalsIgnoreCase(action)) { - initTargetName(name); - } else { - throw new IllegalArgumentException(Messages.getString("auth.11")); //$NON-NLS-1$ - } - } - - /** - * Creates a {@code PrivateCredentialPermission} from the {@code Credential} - * class and set of principals. - * - * @param credentialClass - * the credential class name. - * @param principals - * the set of principals. - */ - PrivateCredentialPermission(String credentialClass, Set principals) { - super(credentialClass); - this.credentialClass = credentialClass; - - set = new CredOwner[principals.size()]; - for (Principal p : principals) { - CredOwner element = new CredOwner(p.getClass().getName(), p.getName()); - // check for duplicate elements - boolean found = false; - for (int ii = 0; ii < offset; ii++) { - if (set[ii].equals(element)) { - found = true; - break; - } - } - if (!found) { - set[offset++] = element; - } - } - } - - /** - * Initialize a PrivateCredentialPermission object and checks that a target - * name has a correct format: CredentialClass 1*(PrincipalClass - * "PrincipalName") - */ - private void initTargetName(String name) { - - if (name == null) { - throw new NullPointerException(Messages.getString("auth.0E")); //$NON-NLS-1$ - } - - // check empty string - name = name.trim(); - if (name.length() == 0) { - throw new IllegalArgumentException(Messages.getString("auth.0F")); //$NON-NLS-1$ - } - - // get CredentialClass - int beg = name.indexOf(' '); - if (beg == -1) { - throw new IllegalArgumentException(Messages.getString("auth.10")); //$NON-NLS-1$ - } - credentialClass = name.substring(0, beg); - - // get a number of pairs: PrincipalClass "PrincipalName" - beg++; - int count = 0; - int nameLength = name.length(); - for (int i, j = 0; beg < nameLength; beg = j + 2, count++) { - i = name.indexOf(' ', beg); - j = name.indexOf('"', i + 2); - - if (i == -1 || j == -1 || name.charAt(i + 1) != '"') { - throw new IllegalArgumentException(Messages.getString("auth.10")); //$NON-NLS-1$ - } - } - - // name MUST have one pair at least - if (count < 1) { - throw new IllegalArgumentException(Messages.getString("auth.10")); //$NON-NLS-1$ - } - - beg = name.indexOf(' '); - beg++; - - // populate principal set with instances of CredOwner class - String principalClass; - String principalName; - - set = new CredOwner[count]; - for (int index = 0, i, j; index < count; beg = j + 2, index++) { - i = name.indexOf(' ', beg); - j = name.indexOf('"', i + 2); - - principalClass = name.substring(beg, i); - principalName = name.substring(i + 2, j); - - CredOwner element = new CredOwner(principalClass, principalName); - // check for duplicate elements - boolean found = false; - for (int ii = 0; ii < offset; ii++) { - if (set[ii].equals(element)) { - found = true; - break; - } - } - if (!found) { - set[offset++] = element; - } - } - } - - private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { - ois.defaultReadObject(); - initTargetName(getName()); - } - - /** - * Returns the principal's classes and names associated with this {@code - * PrivateCredentialPermission} as a two dimensional array. The first - * dimension of the array corresponds to the number of principals. The - * second dimension defines either the name of the {@code PrincipalClass} - * [x][0] or the value of {@code PrincipalName} [x][1]. - *

- * This corresponds to the the target name's syntax: - * - *

-     * targetName = CredentialClass {PrincipalClass "PrincipalName"}*
-     * 
- * - * @return the principal classes and names associated with this {@code - * PrivateCredentialPermission}. - */ - public String[][] getPrincipals() { - - String[][] s = new String[offset][2]; - - for (int i = 0; i < s.length; i++) { - s[i][0] = set[i].principalClass; - s[i][1] = set[i].principalName; - } - return s; - } - - @Override - public String getActions() { - return READ; - } - - /** - * Returns the class name of the credential associated with this permission. - * - * @return the class name of the credential associated with this permission. - */ - public String getCredentialClass() { - return credentialClass; - } - - @Override - public int hashCode() { - int hash = 0; - for (int i = 0; i < offset; i++) { - hash = hash + set[i].hashCode(); - } - return getCredentialClass().hashCode() + hash; - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - - if (obj == null || this.getClass() != obj.getClass()) { - return false; - } - - PrivateCredentialPermission that = (PrivateCredentialPermission) obj; - - return credentialClass.equals(that.credentialClass) && (offset == that.offset) - && sameMembers(set, that.set, offset); - } - - @Override - public boolean implies(Permission permission) { - - if (permission == null || this.getClass() != permission.getClass()) { - return false; - } - - PrivateCredentialPermission that = (PrivateCredentialPermission) permission; - - if (!("*".equals(credentialClass) || credentialClass //$NON-NLS-1$ - .equals(that.getCredentialClass()))) { - return false; - } - - if (that.offset == 0) { - return true; - } - - CredOwner[] thisCo = set; - CredOwner[] thatCo = that.set; - int thisPrincipalsSize = offset; - int thatPrincipalsSize = that.offset; - for (int i = 0, j; i < thisPrincipalsSize; i++) { - for (j = 0; j < thatPrincipalsSize; j++) { - if (thisCo[i].implies(thatCo[j])) { - break; - } - } - if (j == thatCo.length) { - return false; - } - } - return true; - } - - @Override - public PermissionCollection newPermissionCollection() { - return null; - } - - /** - * Returns true if the two arrays have the same length, and every member of - * one array is contained in another array - */ - private boolean sameMembers(Object[] ar1, Object[] ar2, int length) { - if (ar1 == null && ar2 == null) { - return true; - } - if (ar1 == null || ar2 == null) { - return false; - } - boolean found; - for (int i = 0; i < length; i++) { - found = false; - for (int j = 0; j < length; j++) { - if (ar1[i].equals(ar2[j])) { - found = true; - break; - } - } - if (!found) { - return false; - } - } - return true; - } - - private static final class CredOwner implements Serializable { - - private static final long serialVersionUID = -5607449830436408266L; - - String principalClass; - - String principalName; - - // whether class name contains wildcards - private transient boolean isClassWildcard; - - // whether pname contains wildcards - private transient boolean isPNameWildcard; - - // Creates a new CredOwner with the specified Principal Class and Principal Name - CredOwner(String principalClass, String principalName) { - super(); - if ("*".equals(principalClass)) { //$NON-NLS-1$ - isClassWildcard = true; - } - - if ("*".equals(principalName)) { //$NON-NLS-1$ - isPNameWildcard = true; - } - - if (isClassWildcard && !isPNameWildcard) { - throw new IllegalArgumentException(Messages.getString("auth.12")); //$NON-NLS-1$ - } - - this.principalClass = principalClass; - this.principalName = principalName; - } - - // Checks if this CredOwner implies the specified Object. - boolean implies(Object obj) { - if (obj == this) { - return true; - } - - CredOwner co = (CredOwner) obj; - - if (isClassWildcard || principalClass.equals(co.principalClass)) { - if (isPNameWildcard || principalName.equals(co.principalName)) { - return true; - } - } - return false; - } - - // Checks two CredOwner objects for equality. - @Override - public boolean equals(Object obj) { - return principalClass.equals(((CredOwner) obj).principalClass) - && principalName.equals(((CredOwner) obj).principalName); - } - - // Returns the hash code value for this object. - @Override - public int hashCode() { - return principalClass.hashCode() + principalName.hashCode(); - } - } -} diff --git a/libcore/auth/src/main/java/javax/security/auth/Subject.java b/libcore/auth/src/main/java/javax/security/auth/Subject.java deleted file mode 100644 index 5bf6bba25..000000000 --- a/libcore/auth/src/main/java/javax/security/auth/Subject.java +++ /dev/null @@ -1,782 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.security.auth; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.DomainCombiner; -import java.security.Permission; -import java.security.Principal; -import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; -import java.security.ProtectionDomain; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Set; - -import org.apache.harmony.auth.internal.nls.Messages; - -/** - * The central class of the {@code javax.security.auth} package representing an - * authenticated user or entity (both referred to as "subject"). IT defines also - * the static methods that allow code to be run, and do modifications according - * to the subject's permissions. - *

- * A subject has the following features: - *

    - *
  • A set of {@code Principal} objects specifying the identities bound to a - * {@code Subject} that distinguish it.
  • - *
  • Credentials (public and private) such as certificates, keys, or - * authentication proofs such as tickets
  • - *
- */ -public final class Subject implements Serializable { - - private static final long serialVersionUID = -8308522755600156056L; - - private static final AuthPermission _AS = new AuthPermission("doAs"); //$NON-NLS-1$ - - private static final AuthPermission _AS_PRIVILEGED = new AuthPermission( - "doAsPrivileged"); //$NON-NLS-1$ - - private static final AuthPermission _SUBJECT = new AuthPermission( - "getSubject"); //$NON-NLS-1$ - - private static final AuthPermission _PRINCIPALS = new AuthPermission( - "modifyPrincipals"); //$NON-NLS-1$ - - private static final AuthPermission _PRIVATE_CREDENTIALS = new AuthPermission( - "modifyPrivateCredentials"); //$NON-NLS-1$ - - private static final AuthPermission _PUBLIC_CREDENTIALS = new AuthPermission( - "modifyPublicCredentials"); //$NON-NLS-1$ - - private static final AuthPermission _READ_ONLY = new AuthPermission( - "setReadOnly"); //$NON-NLS-1$ - - private final Set principals; - - private boolean readOnly; - - // set of private credentials - private transient SecureSet privateCredentials; - - // set of public credentials - private transient SecureSet publicCredentials; - - /** - * The default constructor initializing the sets of public and private - * credentials and principals with the empty set. - */ - public Subject() { - super(); - principals = new SecureSet(_PRINCIPALS); - publicCredentials = new SecureSet(_PUBLIC_CREDENTIALS); - privateCredentials = new SecureSet(_PRIVATE_CREDENTIALS); - - readOnly = false; - } - - /** - * The constructor for the subject, setting its public and private - * credentials and principals according to the arguments. - * - * @param readOnly - * {@code true} if this {@code Subject} is read-only, thus - * preventing any modifications to be done. - * @param subjPrincipals - * the set of Principals that are attributed to this {@code - * Subject}. - * @param pubCredentials - * the set of public credentials that distinguish this {@code - * Subject}. - * @param privCredentials - * the set of private credentials that distinguish this {@code - * Subject}. - */ - public Subject(boolean readOnly, Set subjPrincipals, - Set pubCredentials, Set privCredentials) { - - if (subjPrincipals == null || pubCredentials == null || privCredentials == null) { - throw new NullPointerException(); - } - - principals = new SecureSet(_PRINCIPALS, subjPrincipals); - publicCredentials = new SecureSet(_PUBLIC_CREDENTIALS, pubCredentials); - privateCredentials = new SecureSet(_PRIVATE_CREDENTIALS, privCredentials); - - this.readOnly = readOnly; - } - - /** - * Runs the code defined by {@code action} using the permissions granted to - * the {@code Subject} itself and to the code as well. - * - * @param subject - * the distinguished {@code Subject}. - * @param action - * the code to be run. - * @return the {@code Object} returned when running the {@code action}. - */ - @SuppressWarnings("unchecked") - public static Object doAs(Subject subject, PrivilegedAction action) { - - checkPermission(_AS); - - return doAs_PrivilegedAction(subject, action, AccessController.getContext()); - } - - /** - * Run the code defined by {@code action} using the permissions granted to - * the {@code Subject} and to the code itself, additionally providing a more - * specific context. - * - * @param subject - * the distinguished {@code Subject}. - * @param action - * the code to be run. - * @param context - * the specific context in which the {@code action} is invoked. - * if {@code null} a new {@link AccessControlContext} is - * instantiated. - * @return the {@code Object} returned when running the {@code action}. - */ - @SuppressWarnings("unchecked") - public static Object doAsPrivileged(Subject subject, PrivilegedAction action, - AccessControlContext context) { - - checkPermission(_AS_PRIVILEGED); - - if (context == null) { - return doAs_PrivilegedAction(subject, action, new AccessControlContext( - new ProtectionDomain[0])); - } - return doAs_PrivilegedAction(subject, action, context); - } - - // instantiates a new context and passes it to AccessController - @SuppressWarnings("unchecked") - private static Object doAs_PrivilegedAction(Subject subject, PrivilegedAction action, - final AccessControlContext context) { - - AccessControlContext newContext; - - final SubjectDomainCombiner combiner; - if (subject == null) { - // performance optimization - // if subject is null there is nothing to combine - combiner = null; - } else { - combiner = new SubjectDomainCombiner(subject); - } - - PrivilegedAction dccAction = new PrivilegedAction() { - public Object run() { - - return new AccessControlContext(context, combiner); - } - }; - - newContext = (AccessControlContext) AccessController.doPrivileged(dccAction); - - return AccessController.doPrivileged(action, newContext); - } - - /** - * Runs the code defined by {@code action} using the permissions granted to - * the subject and to the code itself. - * - * @param subject - * the distinguished {@code Subject}. - * @param action - * the code to be run. - * @return the {@code Object} returned when running the {@code action}. - * @throws PrivilegedActionException - * if running the {@code action} throws an exception. - */ - @SuppressWarnings("unchecked") - public static Object doAs(Subject subject, PrivilegedExceptionAction action) - throws PrivilegedActionException { - - checkPermission(_AS); - - return doAs_PrivilegedExceptionAction(subject, action, AccessController.getContext()); - } - - /** - * Runs the code defined by {@code action} using the permissions granted to - * the subject and to the code itself, additionally providing a more - * specific context. - * - * @param subject - * the distinguished {@code Subject}. - * @param action - * the code to be run. - * @param context - * the specific context in which the {@code action} is invoked. - * if {@code null} a new {@link AccessControlContext} is - * instantiated. - * @return the {@code Object} returned when running the {@code action}. - * @throws PrivilegedActionException - * if running the {@code action} throws an exception. - */ - @SuppressWarnings("unchecked") - public static Object doAsPrivileged(Subject subject, - PrivilegedExceptionAction action, AccessControlContext context) - throws PrivilegedActionException { - - checkPermission(_AS_PRIVILEGED); - - if (context == null) { - return doAs_PrivilegedExceptionAction(subject, action, - new AccessControlContext(new ProtectionDomain[0])); - } - return doAs_PrivilegedExceptionAction(subject, action, context); - } - - // instantiates a new context and passes it to AccessController - @SuppressWarnings("unchecked") - private static Object doAs_PrivilegedExceptionAction(Subject subject, - PrivilegedExceptionAction action, final AccessControlContext context) - throws PrivilegedActionException { - - AccessControlContext newContext; - - final SubjectDomainCombiner combiner; - if (subject == null) { - // performance optimization - // if subject is null there is nothing to combine - combiner = null; - } else { - combiner = new SubjectDomainCombiner(subject); - } - - PrivilegedAction dccAction = new PrivilegedAction() { - public AccessControlContext run() { - return new AccessControlContext(context, combiner); - } - }; - - newContext = AccessController.doPrivileged(dccAction); - - return AccessController.doPrivileged(action, newContext); - } - - /** - * Checks two Subjects for equality. More specifically if the principals, - * public and private credentials are equal, equality for two {@code - * Subjects} is implied. - * - * @param obj - * the {@code Object} checked for equality with this {@code - * Subject}. - * @return {@code true} if the specified {@code Subject} is equal to this - * one. - */ - @Override - public boolean equals(Object obj) { - - if (this == obj) { - return true; - } - - if (obj == null || this.getClass() != obj.getClass()) { - return false; - } - - Subject that = (Subject) obj; - - if (principals.equals(that.principals) - && publicCredentials.equals(that.publicCredentials) - && privateCredentials.equals(that.privateCredentials)) { - return true; - } - return false; - } - - /** - * Returns this {@code Subject}'s {@link Principal}. - * - * @return this {@code Subject}'s {@link Principal}. - */ - public Set getPrincipals() { - return principals; - } - - - /** - * Returns this {@code Subject}'s {@link Principal} which is a subclass of - * the {@code Class} provided. - * - * @param c - * the {@code Class} as a criteria which the {@code Principal} - * returned must satisfy. - * @return this {@code Subject}'s {@link Principal}. Modifications to the - * returned set of {@code Principal}s do not affect this {@code - * Subject}'s set. - */ - public Set getPrincipals(Class c) { - return ((SecureSet) principals).get(c); - } - - /** - * Returns the private credentials associated with this {@code Subject}. - * - * @return the private credentials associated with this {@code Subject}. - */ - public Set getPrivateCredentials() { - return privateCredentials; - } - - /** - * Returns this {@code Subject}'s private credentials which are a subclass - * of the {@code Class} provided. - * - * @param c - * the {@code Class} as a criteria which the private credentials - * returned must satisfy. - * @return this {@code Subject}'s private credentials. Modifications to the - * returned set of credentials do not affect this {@code Subject}'s - * credentials. - */ - public Set getPrivateCredentials(Class c) { - return privateCredentials.get(c); - } - - /** - * Returns the public credentials associated with this {@code Subject}. - * - * @return the public credentials associated with this {@code Subject}. - */ - public Set getPublicCredentials() { - return publicCredentials; - } - - - /** - * Returns this {@code Subject}'s public credentials which are a subclass of - * the {@code Class} provided. - * - * @param c - * the {@code Class} as a criteria which the public credentials - * returned must satisfy. - * @return this {@code Subject}'s public credentials. Modifications to the - * returned set of credentials do not affect this {@code Subject}'s - * credentials. - */ - public Set getPublicCredentials(Class c) { - return publicCredentials.get(c); - } - - /** - * Returns a hash code of this {@code Subject}. - * - * @return a hash code of this {@code Subject}. - */ - @Override - public int hashCode() { - return principals.hashCode() + privateCredentials.hashCode() - + publicCredentials.hashCode(); - } - - /** - * Prevents from modifications being done to the credentials and {@link - * Principal} sets. After setting it to read-only this {@code Subject} can - * not be made writable again. The destroy method on the credentials still - * works though. - */ - public void setReadOnly() { - checkPermission(_READ_ONLY); - - readOnly = true; - } - - /** - * Returns whether this {@code Subject} is read-only or not. - * - * @return whether this {@code Subject} is read-only or not. - */ - public boolean isReadOnly() { - return readOnly; - } - - /** - * Returns a {@code String} representation of this {@code Subject}. - * - * @return a {@code String} representation of this {@code Subject}. - */ - @Override - public String toString() { - - StringBuffer buf = new StringBuffer("Subject:\n"); //$NON-NLS-1$ - - Iterator it = principals.iterator(); - while (it.hasNext()) { - buf.append("\tPrincipal: "); //$NON-NLS-1$ - buf.append(it.next()); - buf.append('\n'); - } - - it = publicCredentials.iterator(); - while (it.hasNext()) { - buf.append("\tPublic Credential: "); //$NON-NLS-1$ - buf.append(it.next()); - buf.append('\n'); - } - - int offset = buf.length() - 1; - it = privateCredentials.iterator(); - try { - while (it.hasNext()) { - buf.append("\tPrivate Credential: "); //$NON-NLS-1$ - buf.append(it.next()); - buf.append('\n'); - } - } catch (SecurityException e) { - buf.delete(offset, buf.length()); - buf.append("\tPrivate Credentials: no accessible information\n"); //$NON-NLS-1$ - } - return buf.toString(); - } - - private void readObject(ObjectInputStream in) throws IOException, - ClassNotFoundException { - - in.defaultReadObject(); - - publicCredentials = new SecureSet(_PUBLIC_CREDENTIALS); - privateCredentials = new SecureSet(_PRIVATE_CREDENTIALS); - } - - private void writeObject(ObjectOutputStream out) throws IOException { - out.defaultWriteObject(); - } - - /** - * Returns the {@code Subject} that was last associated with the {@code - * context} provided as argument. - * - * @param context - * the {@code context} that was associated with the - * {@code Subject}. - * @return the {@code Subject} that was last associated with the {@code - * context} provided as argument. - */ - public static Subject getSubject(final AccessControlContext context) { - checkPermission(_SUBJECT); - if (context == null) { - throw new NullPointerException(Messages.getString("auth.09")); //$NON-NLS-1$ - } - PrivilegedAction action = new PrivilegedAction() { - public DomainCombiner run() { - return context.getDomainCombiner(); - } - }; - DomainCombiner combiner = AccessController.doPrivileged(action); - - if ((combiner == null) || !(combiner instanceof SubjectDomainCombiner)) { - return null; - } - return ((SubjectDomainCombiner) combiner).getSubject(); - } - - // checks passed permission - private static void checkPermission(Permission p) { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(p); - } - } - - // FIXME is used only in two places. remove? - private void checkState() { - if (readOnly) { - throw new IllegalStateException(Messages.getString("auth.0A")); //$NON-NLS-1$ - } - } - - private final class SecureSet extends AbstractSet implements Serializable { - - /** - * Compatibility issue: see comments for setType variable - */ - private static final long serialVersionUID = 7911754171111800359L; - - private LinkedList elements; - - /* - * Is used to define a set type for serialization. - * - * A type can be principal, priv. or pub. credential set. The spec. - * doesn't clearly says that priv. and pub. credential sets can be - * serialized and what classes they are. It is only possible to figure - * out from writeObject method comments that priv. credential set is - * serializable and it is an instance of SecureSet class. So pub. - * credential was implemented by analogy - * - * Compatibility issue: the class follows its specified serial form. - * Also according to the serialization spec. adding new field is a - * compatible change. So is ok for principal set (because the default - * value for integer is zero). But priv. or pub. credential set it is - * not compatible because most probably other implementations resolve - * this issue in other way - */ - private int setType; - - // Defines principal set for serialization. - private static final int SET_Principal = 0; - - // Defines private credential set for serialization. - private static final int SET_PrivCred = 1; - - // Defines public credential set for serialization. - private static final int SET_PubCred = 2; - - // permission required to modify set - private transient AuthPermission permission; - - protected SecureSet(AuthPermission perm) { - permission = perm; - elements = new LinkedList(); - } - - // creates set from specified collection with specified permission - // all collection elements are verified before adding - protected SecureSet(AuthPermission perm, Collection s) { - this(perm); - - // Subject's constructor receives a Set, we can trusts if a set is from bootclasspath, - // and not to check whether it contains duplicates or not - boolean trust = s.getClass().getClassLoader() == null; - - Iterator it = s.iterator(); - while (it.hasNext()) { - SST o = it.next(); - verifyElement(o); - if (trust || !elements.contains(o)) { - elements.add(o); - } - } - } - - // verifies new set element - private void verifyElement(Object o) { - - if (o == null) { - throw new NullPointerException(); - } - if (permission == _PRINCIPALS && !(Principal.class.isAssignableFrom(o.getClass()))) { - throw new IllegalArgumentException(Messages.getString("auth.0B")); //$NON-NLS-1$ - } - } - - /* - * verifies specified element, checks set state, and security permission - * to modify set before adding new element - */ - @Override - public boolean add(SST o) { - - verifyElement(o); - - checkState(); - checkPermission(permission); - - if (!elements.contains(o)) { - elements.add(o); - return true; - } - return false; - } - - // returns an instance of SecureIterator - @Override - public Iterator iterator() { - - if (permission == _PRIVATE_CREDENTIALS) { - /* - * private credential set requires iterator with additional - * security check (PrivateCredentialPermission) - */ - return new SecureIterator(elements.iterator()) { - /* - * checks permission to access next private credential moves - * to the next element even SecurityException was thrown - */ - @Override - public SST next() { - SST obj = iterator.next(); - checkPermission(new PrivateCredentialPermission(obj - .getClass().getName(), principals)); - return obj; - } - }; - } - return new SecureIterator(elements.iterator()); - } - - @Override - public boolean retainAll(Collection c) { - - if (c == null) { - throw new NullPointerException(); - } - return super.retainAll(c); - } - - @Override - public int size() { - return elements.size(); - } - - /** - * return set with elements that are instances or subclasses of the - * specified class - */ - protected final Set get(final Class c) { - - if (c == null) { - throw new NullPointerException(); - } - - AbstractSet s = new AbstractSet() { - private LinkedList elements = new LinkedList(); - - @Override - public boolean add(E o) { - - if (!c.isAssignableFrom(o.getClass())) { - throw new IllegalArgumentException( - Messages.getString("auth.0C", c.getName())); //$NON-NLS-1$ - } - - if (elements.contains(o)) { - return false; - } - elements.add(o); - return true; - } - - @Override - public Iterator iterator() { - return elements.iterator(); - } - - @Override - public boolean retainAll(Collection c) { - - if (c == null) { - throw new NullPointerException(); - } - return super.retainAll(c); - } - - @Override - public int size() { - return elements.size(); - } - }; - - // FIXME must have permissions for requested priv. credentials - for (Iterator it = iterator(); it.hasNext();) { - SST o = it.next(); - if (c.isAssignableFrom(o.getClass())) { - s.add(c.cast(o)); - } - } - return s; - } - - private void readObject(ObjectInputStream in) throws IOException, - ClassNotFoundException { - in.defaultReadObject(); - - switch (setType) { - case SET_Principal: - permission = _PRINCIPALS; - break; - case SET_PrivCred: - permission = _PRIVATE_CREDENTIALS; - break; - case SET_PubCred: - permission = _PUBLIC_CREDENTIALS; - break; - default: - throw new IllegalArgumentException(); - } - - Iterator it = elements.iterator(); - while (it.hasNext()) { - verifyElement(it.next()); - } - } - - private void writeObject(ObjectOutputStream out) throws IOException { - - if (permission == _PRIVATE_CREDENTIALS) { - // does security check for each private credential - for (Iterator it = iterator(); it.hasNext();) { - it.next(); - } - setType = SET_PrivCred; - } else if (permission == _PRINCIPALS) { - setType = SET_Principal; - } else { - setType = SET_PubCred; - } - - out.defaultWriteObject(); - } - - /** - * Represents iterator for subject's secure set - */ - private class SecureIterator implements Iterator { - protected Iterator iterator; - - protected SecureIterator(Iterator iterator) { - this.iterator = iterator; - } - - public boolean hasNext() { - return iterator.hasNext(); - } - - public SST next() { - return iterator.next(); - } - - /** - * checks set state, and security permission to modify set before - * removing current element - */ - public void remove() { - checkState(); - checkPermission(permission); - iterator.remove(); - } - } - } -} \ No newline at end of file diff --git a/libcore/auth/src/main/java/javax/security/auth/SubjectDomainCombiner.java b/libcore/auth/src/main/java/javax/security/auth/SubjectDomainCombiner.java deleted file mode 100644 index 4b9108415..000000000 --- a/libcore/auth/src/main/java/javax/security/auth/SubjectDomainCombiner.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.security.auth; - -import java.security.DomainCombiner; -import java.security.Principal; -import java.security.ProtectionDomain; -import java.util.Set; - -/** - * Merges permissions based on code source and code signers with permissions - * granted to the specified {@link Subject}. - */ -public class SubjectDomainCombiner implements DomainCombiner { - - // subject to be associated - private Subject subject; - - // permission required to get a subject object - private static final AuthPermission _GET = new AuthPermission( - "getSubjectFromDomainCombiner"); //$NON-NLS-1$ - - /** - * Creates a domain combiner for the entity provided in {@code subject}. - * - * @param subject - * the entity to which this domain combiner is associated. - */ - public SubjectDomainCombiner(Subject subject) { - super(); - if (subject == null) { - throw new NullPointerException(); - } - this.subject = subject; - } - - /** - * Returns the entity to which this domain combiner is associated. - * - * @return the entity to which this domain combiner is associated. - */ - public Subject getSubject() { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(_GET); - } - - return subject; - } - - /** - * Merges the {@code ProtectionDomain} with the {@code Principal}s - * associated with the subject of this {@code SubjectDomainCombiner}. - * - * @param currentDomains - * the {@code ProtectionDomain}s associated with the context of - * the current thread. The domains must be sorted according to - * the execution order, the most recent residing at the - * beginning. - * @param assignedDomains - * the {@code ProtectionDomain}s from the parent thread based on - * code source and signers. - * @return a single {@code ProtectionDomain} array computed from the two - * provided arrays, or {@code null}. - * @see ProtectionDomain - */ - public ProtectionDomain[] combine(ProtectionDomain[] currentDomains, - ProtectionDomain[] assignedDomains) { - // get array length for combining protection domains - int len = 0; - if (currentDomains != null) { - len += currentDomains.length; - } - if (assignedDomains != null) { - len += assignedDomains.length; - } - if (len == 0) { - return null; - } - - ProtectionDomain[] pd = new ProtectionDomain[len]; - - // for each current domain substitute set of principal with subject's - int cur = 0; - if (currentDomains != null) { - - Set s = subject.getPrincipals(); - Principal[] p = s.toArray(new Principal[s.size()]); - - for (cur = 0; cur < currentDomains.length; cur++) { - ProtectionDomain newPD; - newPD = new ProtectionDomain(currentDomains[cur].getCodeSource(), - currentDomains[cur].getPermissions(), currentDomains[cur] - .getClassLoader(), p); - pd[cur] = newPD; - } - } - - // copy assigned domains - if (assignedDomains != null) { - System.arraycopy(assignedDomains, 0, pd, cur, assignedDomains.length); - } - - return pd; - } -} diff --git a/libcore/auth/src/main/java/javax/security/auth/callback/Callback.java b/libcore/auth/src/main/java/javax/security/auth/callback/Callback.java deleted file mode 100644 index 4854d3f4a..000000000 --- a/libcore/auth/src/main/java/javax/security/auth/callback/Callback.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.security.auth.callback; - -/** - * Defines an empty base interface for all {@code Callback}s used during - * authentication. - */ -public interface Callback { -} \ No newline at end of file diff --git a/libcore/auth/src/main/java/javax/security/auth/callback/CallbackHandler.java b/libcore/auth/src/main/java/javax/security/auth/callback/CallbackHandler.java deleted file mode 100644 index 21bf30b0b..000000000 --- a/libcore/auth/src/main/java/javax/security/auth/callback/CallbackHandler.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.security.auth.callback; - -import java.io.IOException; - -/** - * Needs to be implemented by classes that want to handle authentication - * {@link Callback}s. A single method {@link #handle(Callback[])} must be - * provided that checks the type of the incoming {@code Callback}s and reacts - * accordingly. {@code CallbackHandler}s can be installed per application. It is - * also possible to configure a system-default {@code CallbackHandler} by - * setting the {@code auth.login.defaultCallbackHandler} property in the - * standard {@code security.properties} file. - */ -public interface CallbackHandler { - - /** - * Handles the actual {@link Callback}. A {@code CallbackHandler} needs to - * implement this method. In the method, it is free to select which {@code - * Callback}s it actually wants to handle and in which way. For example, a - * console-based {@code CallbackHandler} might choose to sequentially ask - * the user for login and password, if it implements these {@code Callback} - * s, whereas a GUI-based one might open a single dialog window for both - * values. If a {@code CallbackHandler} is not able to handle a specific - * {@code Callback}, it needs to throw an - * {@link UnsupportedCallbackException}. - * - * @param callbacks - * the array of {@code Callback}s that need handling - * @throws IOException - * if an I/O related error occurs - * @throws UnsupportedCallbackException - * if the {@code CallbackHandler} is not able to handle a - * specific {@code Callback} - */ - void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException; - -} diff --git a/libcore/auth/src/main/java/javax/security/auth/callback/PasswordCallback.java b/libcore/auth/src/main/java/javax/security/auth/callback/PasswordCallback.java deleted file mode 100644 index 3617b75b1..000000000 --- a/libcore/auth/src/main/java/javax/security/auth/callback/PasswordCallback.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.security.auth.callback; - -import java.io.Serializable; -import java.util.Arrays; - -import org.apache.harmony.auth.internal.nls.Messages; - -/** - * Is used in conjunction with a {@link CallbackHandler} to retrieve a password - * when needed. - */ -public class PasswordCallback implements Callback, Serializable { - - private static final long serialVersionUID = 2267422647454909926L; - - private String prompt; - - boolean echoOn; - - private char[] inputPassword; - - private void setPrompt(String prompt) throws IllegalArgumentException { - if (prompt == null || prompt.length() == 0) { - throw new IllegalArgumentException(Messages.getString("auth.14")); //$NON-NLS-1$ - } - this.prompt = prompt; - } - - /** - * Creates a new {@code PasswordCallback} instance. - * - * @param prompt - * the message that should be displayed to the user - * @param echoOn - * determines whether the user input should be echoed - */ - public PasswordCallback(String prompt, boolean echoOn) { - super(); - setPrompt(prompt); - this.echoOn = echoOn; - } - - /** - * Returns the prompt that was specified when creating this {@code - * PasswordCallback} - * - * @return the prompt - */ - public String getPrompt() { - return prompt; - } - - /** - * Queries whether this {@code PasswordCallback} expects user input to be - * echoed, which is specified during the creation of the object. - * - * @return {@code true} if (and only if) user input should be echoed - */ - public boolean isEchoOn() { - return echoOn; - } - - /** - * Sets the password. The {@link CallbackHandler} that performs the actual - * provisioning or input of the password needs to call this method to hand - * back the password to the security service that requested it. - * - * @param password - * the password. A copy of this is stored, so subsequent changes - * to the input array do not affect the {@code PasswordCallback}. - */ - public void setPassword(char[] password) { - if (password == null) { - this.inputPassword = password; - } else { - inputPassword = new char[password.length]; - System.arraycopy(password, 0, inputPassword, 0, inputPassword.length); - } - } - - /** - * Returns the password. The security service that needs the password - * usually calls this method once the {@link CallbackHandler} has finished - * its work. - * - * @return the password. A copy of the internal password is created and - * returned, so subsequent changes to the internal password do not - * affect the result. - */ - public char[] getPassword() { - if (inputPassword != null) { - char[] tmp = new char[inputPassword.length]; - System.arraycopy(inputPassword, 0, tmp, 0, tmp.length); - return tmp; - } - return null; - } - - /** - * Clears the password stored in this {@code PasswordCallback}. - */ - public void clearPassword() { - if (inputPassword != null) { - Arrays.fill(inputPassword, '\u0000'); - } - } -} diff --git a/libcore/auth/src/main/java/javax/security/auth/callback/UnsupportedCallbackException.java b/libcore/auth/src/main/java/javax/security/auth/callback/UnsupportedCallbackException.java deleted file mode 100644 index bee7bd388..000000000 --- a/libcore/auth/src/main/java/javax/security/auth/callback/UnsupportedCallbackException.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.security.auth.callback; - -/** - * Thrown when a {@link CallbackHandler} does not support a particular {@link - * Callback}. - */ -public class UnsupportedCallbackException extends Exception { - - private static final long serialVersionUID = -6873556327655666839L; - - private Callback callback; - - /** - * Creates a new exception instance and initializes it with just the - * unsupported {@code Callback}, but no error message. - * - * @param callback - * the {@code Callback} - */ - public UnsupportedCallbackException(Callback callback) { - super(); - this.callback = callback; - } - - /** - * Creates a new exception instance and initializes it with both the - * unsupported {@code Callback} and an error message. - * - * @param callback - * the {@code Callback} - * @param message - * the error message - */ - public UnsupportedCallbackException(Callback callback, String message) { - super(message); - this.callback = callback; - } - - /** - * Returns the unsupported {@code Callback} that triggered this exception. - * - * @return the {@code Callback} - */ - public Callback getCallback() { - return callback; - } -} diff --git a/libcore/auth/src/main/java/javax/security/auth/callback/package.html b/libcore/auth/src/main/java/javax/security/auth/callback/package.html deleted file mode 100644 index 5446ab8e4..000000000 --- a/libcore/auth/src/main/java/javax/security/auth/callback/package.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - -

-This package provides classes and interfaces needed to interact with the -application in order to execute the authentification and authorization -processes. It is a classical callback mechanism: one retrieves information (i.e. -for authentification purposes) and one display some messages (for example error -messages). -

-

-Note that the current implementation of this package is not complete, that is, -not compatible with desktop implementations of the Java programming language. -It contains only what was needed to make the compiler happy, that is, classes -required by other packages. -

-@since Android 1.0 - - \ No newline at end of file diff --git a/libcore/auth/src/main/java/javax/security/auth/login/LoginException.java b/libcore/auth/src/main/java/javax/security/auth/login/LoginException.java deleted file mode 100644 index 9433c43fe..000000000 --- a/libcore/auth/src/main/java/javax/security/auth/login/LoginException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.security.auth.login; - -import java.security.GeneralSecurityException; - -/** - * Base class for exceptions that are thrown when a login error occurs. - */ -public class LoginException extends GeneralSecurityException { - - private static final long serialVersionUID = -4679091624035232488L; - - /** - * Creates a new exception instance and initializes it with default values. - */ - public LoginException() { - super(); - } - - /** - * Creates a new exception instance and initializes it with a given message. - * - * @param message the error message - */ - public LoginException(String message) { - super(message); - } - -} diff --git a/libcore/auth/src/main/java/javax/security/auth/login/package.html b/libcore/auth/src/main/java/javax/security/auth/login/package.html deleted file mode 100644 index 382b48723..000000000 --- a/libcore/auth/src/main/java/javax/security/auth/login/package.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - -

-This package provides a pluggable and stackable authentication system based on -ideas and concepts from the Unix-PAM module. New authentication methods can be -specified simply via a new LoginModule and chained together with the existing -ones. -

-Note that the current implementation of this package is not complete, that is, -not compatible with desktop implementations of the Java programming language. -It contains only what was needed to make the compiler happy, that is, classes -required by other packages. -

-@since Android 1.0 - - \ No newline at end of file diff --git a/libcore/auth/src/main/java/javax/security/auth/package.html b/libcore/auth/src/main/java/javax/security/auth/package.html deleted file mode 100644 index 2bca2db81..000000000 --- a/libcore/auth/src/main/java/javax/security/auth/package.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - -

-This package provides the classes and interfaces needed to implemenet and program -different methods of users' authentification and role based users' authorization. - -All subjects' authentification and role based authorization are strongly coupled with -the java.security file that, as always, is the ultimate arbiter of all matters secure in Android. -For example the class javax.security.auth.SubjectDomainCombiner updates the -ProtectionDomains associated with the actual class with the subjects defined therein. -

-@since Android 1.0 - - diff --git a/libcore/auth/src/main/java/javax/security/auth/x500/X500Principal.java b/libcore/auth/src/main/java/javax/security/auth/x500/X500Principal.java deleted file mode 100644 index 19254a0d2..000000000 --- a/libcore/auth/src/main/java/javax/security/auth/x500/X500Principal.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.security.auth.x500; - -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.security.Principal; - -import org.apache.harmony.auth.internal.nls.Messages; -import org.apache.harmony.security.x501.Name; - -/** - * Represents an X.500 principal, which holds the distinguished name of some - * network entity. An example of a distinguished name is {@code "O=SomeOrg, - * OU=SomeOrgUnit, C=US"}. The class can be instantiated from a byte representation - * of an object identifier (OID), an ASN.1 DER-encoded version, or a simple - * string holding the distinguished name. The representations must follow either - * RFC 2253, RFC 1779, or RFC2459. - */ -public final class X500Principal implements Serializable, Principal { - - private static final long serialVersionUID = -500463348111345721L; - - /** - * Defines a constant for the canonical string format of distinguished - * names. - */ - public static final String CANONICAL = "CANONICAL"; //$NON-NLS-1$ - - /** - * Defines a constant for the RFC 1779 string format of distinguished - * names. - */ - public static final String RFC1779 = "RFC1779"; //$NON-NLS-1$ - - /** - * Defines a constant for the RFC 2253 string format of distinguished - * names. - */ - public static final String RFC2253 = "RFC2253"; //$NON-NLS-1$ - - //Distinguished Name - private transient Name dn; - - /** - * Creates a new X500Principal from a given ASN.1 DER encoding of a - * distinguished name. - * - * @param name - * the ASN.1 DER-encoded distinguished name - * - * @throws IllegalArgumentException - * if the ASN.1 DER-encoded distinguished name is incorrect - */ - public X500Principal(byte[] name) { - super(); - if (name == null) { - throw new IllegalArgumentException(Messages.getString("auth.00")); //$NON-NLS-1$ - } - try { - // FIXME dn = new Name(name); - dn = (Name) Name.ASN1.decode(name); - } catch (IOException e) { - IllegalArgumentException iae = new IllegalArgumentException(Messages - .getString("auth.2B")); //$NON-NLS-1$ - iae.initCause(e); - throw iae; - } - } - - /** - * Creates a new X500Principal from a given ASN.1 DER encoding of a - * distinguished name. - * - * @param in - * an {@code InputStream} holding the ASN.1 DER-encoded - * distinguished name - * - * @throws IllegalArgumentException - * if the ASN.1 DER-encoded distinguished name is incorrect - */ - public X500Principal(InputStream in) { - super(); - if (in == null) { - throw new NullPointerException(Messages.getString("auth.2C")); //$NON-NLS-1$ - } - try { - // FIXME dn = new Name(is); - dn = (Name) Name.ASN1.decode(in); - } catch (IOException e) { - IllegalArgumentException iae = new IllegalArgumentException(Messages - .getString("auth.2B")); //$NON-NLS-1$ - iae.initCause(e); - throw iae; - } - } - - /** - * Creates a new X500Principal from a string representation of a - * distinguished name. - * - * @param name - * the string representation of the distinguished name - * - * @throws IllegalArgumentException - * if the string representation of the distinguished name is - * incorrect - */ - public X500Principal(String name) { - super(); - if (name == null) { - throw new NullPointerException(Messages.getString("auth.00")); //$NON-NLS-1$ - } - try { - dn = new Name(name); - } catch (IOException e) { - IllegalArgumentException iae = new IllegalArgumentException(Messages - .getString("auth.2D")); //$NON-NLS-1$ - iae.initCause(e); - throw iae; - } - } - -// BEGIN android-added - private transient String canonicalName; - private synchronized String getCanonicalName() { - if (canonicalName == null) { - canonicalName = dn.getName(CANONICAL); - } - return canonicalName; - } -// END android-added - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || this.getClass() != o.getClass()) { - return false; - } - X500Principal principal = (X500Principal) o; -// BEGIN android-changed - return getCanonicalName().equals(principal.getCanonicalName()); -// END android-changed - } - - /** - * Returns an ASN.1 DER-encoded representation of the distinguished name - * contained in this X.500 principal. - * - * @return the ASN.1 DER-encoded representation - */ - public byte[] getEncoded() { - byte[] src = dn.getEncoded(); - byte[] dst = new byte[src.length]; - System.arraycopy(src, 0, dst, 0, dst.length); - return dst; - } - - /** - * Returns a human-readable string representation of the distinguished name - * contained in this X.500 principal. - * - * @return the string representation - */ - public String getName() { - return dn.getName(RFC2253); - } - - /** - * Returns a string representation of the distinguished name contained in - * this X.500 principal. The format of the representation can be chosen. - * Valid arguments are {@link #RFC1779}, {@link #RFC2253}, and - * {@link #CANONICAL}. The representations are specified in RFC 1779 and RFC - * 2253, respectively. The canonical form is based on RFC 2253, but adds - * some canonicalizing operations like removing leading and trailing - * whitespace, lower-casing the whole name, and bringing it into a - * normalized Unicode representation. - * - * @param format - * the name of the format to use for the representation - * - * @return the string representation - * - * @throws IllegalArgumentException - * if the {@code format} argument is not one of the three - * mentioned above - */ - public String getName(String format) { -// BEGIN android-changed - if (CANONICAL.equals(format)) { - return getCanonicalName(); - } - - return dn.getName(format); - } - - @Override - public int hashCode() { - return getCanonicalName().hashCode(); - } -// END android-changed - - @Override - public String toString() { - return dn.getName(RFC1779); - } - - private void writeObject(ObjectOutputStream out) throws IOException { - out.writeObject(dn.getEncoded()); - } - - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - - dn = (Name) Name.ASN1.decode((byte[]) in.readObject()); - } -} diff --git a/libcore/auth/src/main/java/javax/security/auth/x500/package.html b/libcore/auth/src/main/java/javax/security/auth/x500/package.html deleted file mode 100644 index 58d27ac6c..000000000 --- a/libcore/auth/src/main/java/javax/security/auth/x500/package.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - -

-This package provides classes needed to store X.500 principals and their -credentials. -

-Note that the current implementation of this package is not complete, that is, -not compatible with desktop implementations of the Java programming language. -It contains only what was needed to make the compiler happy, that is, classes -required by other packages. -

-@since Android 1.0 - - diff --git a/libcore/auth/src/main/java/org/apache/harmony/auth/internal/nls/Messages.java b/libcore/auth/src/main/java/org/apache/harmony/auth/internal/nls/Messages.java deleted file mode 100644 index 511aa7abc..000000000 --- a/libcore/auth/src/main/java/org/apache/harmony/auth/internal/nls/Messages.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL. - * All changes made to this file manually will be overwritten - * if this tool runs again. Better make changes in the template file. - */ - -// BEGIN android-note -// Redundant code has been removed and is now called from MsgHelp. -// END android-note - -package org.apache.harmony.auth.internal.nls; - - -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -// BEGIN android-changed -import org.apache.harmony.luni.util.MsgHelp; -// END android-changed - -/** - * This class retrieves strings from a resource bundle and returns them, - * formatting them with MessageFormat when required. - *

- * It is used by the system classes to provide national language support, by - * looking up messages in the - * org.apache.harmony.auth.internal.nls.messages - * - * resource bundle. Note that if this file is not available, or an invalid key - * is looked up, or resource bundle support is not available, the key itself - * will be returned as the associated message. This means that the KEY - * should a reasonable human-readable (english) string. - * - */ -public class Messages { - - // BEGIN android-changed - private static final String sResource = - "org.apache.harmony.auth.internal.nls.messages"; - // END android-changed - - /** - * Retrieves a message which has no arguments. - * - * @param msg - * String the key to look up. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg) { - // BEGIN android-changed - return MsgHelp.getString(sResource, msg); - // END android-changed - } - - /** - * Retrieves a message which takes 1 argument. - * - * @param msg - * String the key to look up. - * @param arg - * Object the object to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, Object arg) { - return getString(msg, new Object[] { arg }); - } - - /** - * Retrieves a message which takes 1 integer argument. - * - * @param msg - * String the key to look up. - * @param arg - * int the integer to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, int arg) { - return getString(msg, new Object[] { Integer.toString(arg) }); - } - - /** - * Retrieves a message which takes 1 character argument. - * - * @param msg - * String the key to look up. - * @param arg - * char the character to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, char arg) { - return getString(msg, new Object[] { String.valueOf(arg) }); - } - - /** - * Retrieves a message which takes 2 arguments. - * - * @param msg - * String the key to look up. - * @param arg1 - * Object an object to insert in the formatted output. - * @param arg2 - * Object another object to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, Object arg1, Object arg2) { - return getString(msg, new Object[] { arg1, arg2 }); - } - - /** - * Retrieves a message which takes several arguments. - * - * @param msg - * String the key to look up. - * @param args - * Object[] the objects to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, Object[] args) { - // BEGIN android-changed - return MsgHelp.getString(sResource, msg, args); - // END android-changed - } - - // BEGIN android-note - // Duplicate code was dropped in favor of using MsgHelp. - // END android-note -} diff --git a/libcore/auth/src/main/java/org/apache/harmony/auth/internal/nls/messages.properties b/libcore/auth/src/main/java/org/apache/harmony/auth/internal/nls/messages.properties deleted file mode 100644 index c8d1b0fc0..000000000 --- a/libcore/auth/src/main/java/org/apache/harmony/auth/internal/nls/messages.properties +++ /dev/null @@ -1,101 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# messages for EN locale -auth.00=Name can not be null -auth.01=sid can not be null -auth.02=sid can not be empty -auth.03=Subject can not be null -auth.04=options can not be null -auth.05=Read-only Subject -auth.06=uid can not be null -auth.07=gid can not be null -auth.08=Failed to load Subject-based policy -auth.09=invalid AccessControlContext -auth.0A=Set is read only -auth.0B=Element is not instance of java.security.Principal -auth.0C=Invalid argument class. MUST be instance of {0} -auth.0D=Null oids were provided -auth.0E=target name is null -auth.0F=target name has a length of 0 -auth.10=Target name MUST have the following syntax: CredentialClass 1*(PrincipalClass "PrincipalName") -auth.11=Action must be "read" only -auth.12=invalid syntax: Principal Class can not be a wildcard (*) value if Principal Name is not a wildcard (*) value -auth.13=name is null -auth.14=Invalid prompt -auth.15=Invalid default text -auth.16=Invalid message type -auth.17=invalid defaultOption -auth.18=Invalid option type -auth.19=invalid selection -auth.1A=Invalid options -auth.1B=specified selection is out of bounds -auth.1C=Invalid choices -auth.1D=Invalid default choices -auth.1E=Invalid default name -auth.1F=Invalid message -auth.20=Name must have the following syntax: "subordinate service" "target service" -auth.21=collection is read-only -auth.22=invalid permission: {0} -auth.23=Invalid principal name -auth.24=Illegal character in realm name; one of: '/', ':', null -auth.25=Invalid name type -auth.26=name of the LoginModule is null or has a length of 0 -auth.27=invalid control flag -auth.28=X509 certificate is null -auth.29=Private key is null -auth.2A=Alias is null -auth.2B=Incorrect input encoding -auth.2C=Input stream can not be null -auth.2D=Incorrect input name -auth.2E=Invalid actions mask -auth.2F=service principal is null -auth.30=service principal is empty -auth.31=Implementation was not found for: -auth.32=mechanism is null -auth.33=mechanisms is null -auth.34=CallbackHandler can not be null -auth.35=There is no "{0}" in Configuration or it's empty. -auth.36=Could not get default callback handler. -auth.37=Login attempt failed. -auth.38=This LoginContext is not logged. -auth.39=Could not load module {0} -auth.3A=Could not instantiate module {0} -auth.3B=ASN.1 encoding of this ticket is null -auth.3C=client is null -auth.3D=server is null -auth.3E=session key is null -auth.3F=authentication time is null -auth.40=expiration time is null -auth.41=An absolute expiration time can not be null for renewable tickets -auth.42=Incorrect start or end time -auth.43=This ticket is already destroyed -auth.44=The ticket is not renewable -auth.45=The allowable renew time is passed for this ticket -auth.46=InetAddress is null -auth.47=key is null -auth.48=The key is destroyed -auth.49=Unsupported algorithm -auth.4A=Failed to generate DES key from password. -auth.4B=\n\tApplication name [{0}] already exists -auth.4C=\n\tInvalid application name {0} -auth.4D=\nAppname: {0} -auth.4E=\n\tInvalid LoginModule name {0} -auth.4F=\n\tInvalid control flag: {0} -auth.50=\n\tInvalid options format {0} -auth.51=\n\tInvalid token: {0} -auth.52=Error code: {0} -auth.53=Unable to locate a login configuration diff --git a/libcore/awt-kernel/MODULE_LICENSE_APACHE2 b/libcore/awt-kernel/MODULE_LICENSE_APACHE2 deleted file mode 100644 index e69de29bb..000000000 diff --git a/libcore/awt-kernel/src/main/java/java/awt/font/NumericShaper.java b/libcore/awt-kernel/src/main/java/java/awt/font/NumericShaper.java deleted file mode 100644 index e8ea693ec..000000000 --- a/libcore/awt-kernel/src/main/java/java/awt/font/NumericShaper.java +++ /dev/null @@ -1,885 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @author Ilya S. Okomin - * @version $Revision$ - */ -package java.awt.font; - -import java.io.IOException; -import java.io.Serializable; - -// BEGIN android-deleted -//import org.apache.harmony.awt.internal.nls.Messages; -// END android-deleted -import org.apache.harmony.misc.HashCode; - - -/** - * The Class NumericShaper provides methods to convert latin character codes - * to unicode character codes. - * For tables of the character codes used, - * see unicode.org. - */ -public final class NumericShaper implements Serializable { - - /** The Constant serialVersionUID. */ - private static final long serialVersionUID = -8022764705923730308L; - - /** - * The Constant EUROPEAN indicates the latin and extended range, - * and latin decimal base. - */ - public static final int EUROPEAN = 1; - - /** The Constant ARABIC indicates the ARABIC range and decimal base. */ - public static final int ARABIC = 2; - - /** - * The Constant EASTERN_ARABIC indicates the ARABIC range and - * ARABIC_EXTENDED decimal base. - */ - public static final int EASTERN_ARABIC = 4; - - /** - * The Constant DEVANAGARI indicates the DEVANAGARI range and - * decimal base. - */ - public static final int DEVANAGARI = 8; - - /** The Constant BENGALI indicates the BENGALI range and decimal base. */ - public static final int BENGALI = 16; - - /** The Constant GURMUKHI indicates the GURMUKHI range and decimal base. */ - public static final int GURMUKHI = 32; - - /** The Constant GUJARATI indicates the GUJARATI range and decimal base. */ - public static final int GUJARATI = 64; - - /** The Constant ORIYA indicates the ORIYA range and decimal base. */ - public static final int ORIYA = 128; - - /** The Constant TAMIL indicates the TAMIL range and decimal base. */ - public static final int TAMIL = 256; - - /** The Constant TELUGU indicates the TELUGU range and decimal base. */ - public static final int TELUGU = 512; - - /** The Constant KANNADA indicates the KANNADA range and decimal base. */ - public static final int KANNADA = 1024; - - /** - * The Constant MALAYALAM indicates the MALAYALAM range and decimal base. - */ - public static final int MALAYALAM = 2048; - - /** The Constant THAI indicates the THAI range and decimal base. */ - public static final int THAI = 4096; - - /** The Constant LAO indicates the LAO range and decimal base. */ - public static final int LAO = 8192; - - /** The Constant TIBETAN indicates the TIBETAN range and decimal base. */ - public static final int TIBETAN = 16384; - - /** The Constant MYANMAR indicates the MYANMAR range and decimal base. */ - public static final int MYANMAR = 32768; - - /** - * The Constant ETHIOPIC indicates the ETHIOPIC range and decimal base. - */ - public static final int ETHIOPIC = 65536; - - /** The Constant KHMER indicates the KHMER range and decimal base. */ - public static final int KHMER = 131072; - - /** - * The Constant MONGOLIAN indicates the MONGOLIAN range and - * decimal base. - */ - public static final int MONGOLIAN = 262144; - - /** The Constant ALL_RANGES indicates all ranges. */ - public static final int ALL_RANGES = 524287; - - /* Further one can find the set of script indices. - * Index is the power you need the 2 to raise to to get corresponding - * range constant value. Also script ranges, context names and digits low - * ranges are indexed with these indices. - */ - - // Index of the EUROPEAN range - /** The Constant INDEX_EUROPEAN. */ - private static final int INDEX_EUROPEAN = 0; - - // Index of the ARABIC range - /** The Constant INDEX_ARABIC. */ - private static final int INDEX_ARABIC = 1; - - // Index of the EASTERN_ARABIC range - /** The Constant INDEX_EASTERN_ARABIC. */ - private static final int INDEX_EASTERN_ARABIC = 2; - - // Index of the DEVANAGARI range - /** The Constant INDEX_DEVANAGARI. */ - private static final int INDEX_DEVANAGARI = 3; - - // Index of the BENGALI range - /** The Constant INDEX_BENGALI. */ - private static final int INDEX_BENGALI = 4; - - // Index of the GURMUKHI range - /** The Constant INDEX_GURMUKHI. */ - private static final int INDEX_GURMUKHI = 5; - - // Index of the GUJARTI range - /** The Constant INDEX_GUJARATI. */ - private static final int INDEX_GUJARATI = 6; - - // Index of the ORIYA range - /** The Constant INDEX_ORIYA. */ - private static final int INDEX_ORIYA = 7; - - // Index of the TAMIL range - /** The Constant INDEX_TAMIL. */ - private static final int INDEX_TAMIL = 8; - - // Index of the TELUGU range - /** The Constant INDEX_TELUGU. */ - private static final int INDEX_TELUGU = 9; - - // Index of the KANNADA range - /** The Constant INDEX_KANNADA. */ - private static final int INDEX_KANNADA = 10; - - // Index of the MALAYALAM range - /** The Constant INDEX_MALAYALAM. */ - private static final int INDEX_MALAYALAM = 11; - - // Index of the THAI range - /** The Constant INDEX_THAI. */ - private static final int INDEX_THAI = 12; - - // Index of the LAO range - /** The Constant INDEX_LAO. */ - private static final int INDEX_LAO = 13; - - // Index of the TIBETAN range - /** The Constant INDEX_TIBETAN. */ - private static final int INDEX_TIBETAN = 14; - - // Index of the MYANMAR range - /** The Constant INDEX_MYANMAR. */ - private static final int INDEX_MYANMAR = 15; - - // Index of the ETHIOPIC range - /** The Constant INDEX_ETHIOPIC. */ - private static final int INDEX_ETHIOPIC = 16; - - // Index of the KHMER range - /** The Constant INDEX_KHMER. */ - private static final int INDEX_KHMER = 17; - - // Index of the MONGOLIAN range - /** The Constant INDEX_MONGOLIAN. */ - private static final int INDEX_MONGOLIAN = 18; - - // Maximum index that range can't exceed - /** The Constant MAX_INDEX. */ - private static final int MAX_INDEX = 19; - - /* - * Scripts ranges array. Array represents ranges as pairs of - * lowest and highest range bounds. - * Data is taken from the UnicodeData.txt file from - * http://www.unicode.org/Public/UNIDATA/ - */ - /** The scripts ranges. */ - private final int[] scriptsRanges = { - 0x0000, 0x024F, // EUROPEAN (basic latin + latin-1 + extended) - 0x0600, 0x06FF, // ARABIC - 0x0600, 0x06FF, // EASTERN_ARABIC (XXX: diff with ARABIC ? ) - 0x0900, 0x097F, // DEVANAGARI - 0x0980, 0x09FF, // BENGALI - 0x0A00, 0x0A7F, // GURMUKHI - 0x0A80, 0x0AFF, // GUJARATI - 0x0B00, 0x0B7F, // ORIYA - 0x0B80, 0x0BFF, // TAMIL - 0x0C00, 0x0C7F, // TELUGU - 0x0C80, 0x0CFF, // KANNADA - 0x0D00, 0x0D7F, // MALAYALAM - 0x0E00, 0x0E7F, // THAI - 0x0E80, 0x0EFF, // LAO - 0x0F00, 0x0FFF, // TIBETAN - 0x1000, 0x109F, // MYANMAR - 0x1200, 0x137F, // ETHIOPIC - 0x1780, 0x17FF, // KHMER - 0x1800, 0x18AF // MONGOLIAN - }; - - /* - * Digit low ranges values decreased by 0x0030. Each low range - * value decreased by 0x0030 for easy obtaing unicode value of the - * context dependent digit. European digits starts from 0x0030 hence - * context dependent unicode digit value equals to - * digitsLowRanges[script index] + european digit char unicode value. - * !! the only exception is ETHIOPIC script where there is no '0' digit - * Data is taken from the UnicodeData.txt file from - * http://www.unicode.org/Public/UNIDATA/ - */ - /** The digits low ranges. */ - private final int[] digitsLowRanges = { - 0x0000, // EUROPEAN - 0x0630, // ARABIC - 0x0630, // EASTERN_ARABIC - 0x0936, // DEVANAGARI - 0x09B6, // BENGALI - 0x0A36, // GURMUKHI - 0x0AB6, // GUJARATI - 0x0B36, // ORIYA - 0x0BB6, // TAMIL - 0x0C36, // TELUGU - 0x0CB6, // KANNADA - 0x0D36, // MALAYALAM - 0x0E20, // THAI - 0x0EA0, // LAO - 0x0EF0, // TIBETAN - 0x1010, // MYANMAR - 0x1338, // ETHIOPIC - (low range-1) no ETHIOPIC '0' DIGIT! - 0x17B0, // KHMER - 0x17E0 // MONGOLIAN - }; - - // Set of context names used in toString method - /** The contexts. */ - private final String[] contexts = { - "EUROPEAN", //$NON-NLS-1$ - "ARABIC", //$NON-NLS-1$ - "EASTERN_ARABIC", //$NON-NLS-1$ - "DEVANAGARI", //$NON-NLS-1$ - "BENGALI", //$NON-NLS-1$ - "GURMUKHI", //$NON-NLS-1$ - "GUJARATI", //$NON-NLS-1$ - "ORIYA", //$NON-NLS-1$ - "TAMIL", //$NON-NLS-1$ - "TELUGU", //$NON-NLS-1$ - "KANNADA", //$NON-NLS-1$ - "MALAYALAM", //$NON-NLS-1$ - "THAI", //$NON-NLS-1$ - "LAO", //$NON-NLS-1$ - "TIBETAN", //$NON-NLS-1$ - "MYANMAR", //$NON-NLS-1$ - "ETHIOPIC", //$NON-NLS-1$ - "KHMER", //$NON-NLS-1$ - "MONGOLIAN" //$NON-NLS-1$ - }; - - /* - * Strong characters flags array is to determine if the - * unicode bidirectional category of the character is strong, - * according to Unicode specification. If the bit with index equals to - * character's unicode value is 1 - the character is strong. - * This array was generated using UnicodeData.txt file from - * http://www.unicode.org/Public/UNIDATA/ - */ - - /** The Constant STRONG_TEXT_FLAGS. */ - private static final int[] STRONG_TEXT_FLAGS = { 0, 0, 134217726, 134217726, - 0, 69207040, -8388609, -8388609, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -65533, -1, -1, -100663297, 196611, 16415, 0, 0, 0, - 67108864, -10432, -5, -32769, -4194305, -1, -1, -1, -1, -1017, -1, - -32769, 67108863, 65535, -131072, -25165825, -2, 767, 1073741824, - -65463, 2033663, -939513841, 134217726, 2047, -73728, -1, -1, - 541065215, -67059616, -180225, 65535, -8192, 16383, -1, 131135, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, -8, -469762049, -16703999, 537001971, - -417812, -473563649, -1333765759, 133431235, -423960, -1016201729, - 1577058305, 1900480, -278552, -470942209, 72193, 65475, -417812, - 1676541439, -1333782143, 262083, -700594200, -1006647528, 8396230, - 524224, -139282, 66059775, 30, 65475, -139284, -470811137, - 1080036831, 65475, -139284, -1006633473, 8396225, 65475, -58720276, - 805044223, -16547713, 1835008, -2, 917503, 268402815, 0, -17816170, - 537783470, 872349791, 0, -50331649, -1050673153, -257, -2147481601, - 3872, -1073741824, 237503, 0, -1, 16914171, 16777215, 0, 0, -1, - -65473, 536870911, -1, -1, -2080374785, -1, -1, -249, -1, 67108863, - -1, -1, 1031749119, -1, -49665, 2134769663, -8388803, -1, - -12713985, -1, 134217727, 536870911, 65535, -1, -1, 2097151, -2, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 8388607, 134217726, -1, -1, 131071, 253951, 6553599, 262143, - 122879, -1, -1065353217, 401605055, 1023, 67043328, -1, -1, - 16777215, -1, 511, 0, 0, 536870911, 33226872, -64, 2047999, -1, - -64513, 67044351, 0, -830472193, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, 0, 0, - -1, -1, -1, -1, 268435455, -1, -1, 67108863, 1061158911, -1, - -1426112705, 1073741823, -1, 1608515583, 265232348, 534519807, - 49152, 27648, 0, -2147352576, 2031616, 0, 0, 0, 1043332228, - -201605808, 992, -1, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - -4194304, -1, 134217727, 2097152, 0, 0, 0, 0, 0, 0, 0, -268435456, - -1, -1, 1023, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4096, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, - -32769, 2147483647, 0, -1, -1, -1, 31, -1, -65473, -1, 32831, - 8388607, 2139062143, 2139062143, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 224, 524157950, -2, -1, -528482305, -2, -1, - -134217729, -32, -122881, -1, -1, -32769, 16777215, 0, -65536, - 536870911, -1, 15, -1879048193, -1, 131071, -61441, 2147483647, -1, - -1, -1, -125829121, -1, -1, 1073741823, 2147483647, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 2097152, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 134217728, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 8191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2117, 159, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 8, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2147483648, 1, 0, 0, -2147483648, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, -2147483648, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2147483648, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -49153, -1, -63489, -1, -1, 67108863, 0, - -1594359681, 1602223615, -37, -1, -1, 262143, -524288, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 1073741823, -65536, -1, -196609, -1, - 255, 536805376, 0, 0, 0, -2162688, -1, -1, -1, 536870911, 0, - 134217726, 134217726, -64, -1, 2147483647, 486341884, 0 - - }; - - // index of context range (Serialization support) - /** The key. */ - private int key; - - // flag, true if shaping contextual (Serialization support) - /** The mask. */ - private int mask; - - // ranges to be shaped - /** The ranges. */ - private int fRanges; - - // index of the default context - /** The default context index. */ - private int fDefaultContextIndex; - - // flag if NumericShaper shapes contextually - /** The contextual. */ - private boolean fContextual; - - // uses for non-context dependent case only - /** The single range index. */ - private int fSingleRangeIndex; - - /** - * Creates NumericShaper with specified parameters. - * - * @param ranges specified ranges to be shaped - * @param defaultContext default context range - * @param isContextual specifies if the instance is contextual - */ - private NumericShaper(int ranges, int defaultContext, boolean isContextual){ - this.fRanges = ranges; - this.fDefaultContextIndex = getIndexFromRange(defaultContext); - this.fContextual = isContextual; - - if (!fContextual){ - fSingleRangeIndex = getIndexFromRange(ranges); - } - } - - /** - * Returns script index of the specified context range. - * - * @param range specified range - * - * @return one of the script indices according to the specified range. - */ - private int getIndexFromRange(int range){ - if (range == 0){ - // BEGIN android-changed - throwRange(range); - // END android-changed - } - - int index = 0; - while (index < MAX_INDEX){ - if (range == (1 << index)){ - return index; - } - index++; - } - - // BEGIN android-changed - throwRange(range); - return -1; // Never executed; quiets the compiler. - // END android-changed - } - - /** - * Returns range corresponding to the specified script index. - * - * @param index specified script index - * - * @return one of the range constants according to the specified script index. - */ - private int getRangeFromIndex(int index){ - if (index < 0 || index >= MAX_INDEX){ - // BEGIN android-changed - throwRange(index); - // END android-changed - } - - return 1 << index; - } - - // BEGIN android-added - /** - * Throws a standard "out of range" exception. - * - * @param value the bogus value - */ - private static void throwRange(int value) { - throw new IllegalArgumentException( - "Illegal range argument value: " + value); - } - // END android-added - - /** - * Returns a hash code of this NumericShaper. - * - * @return a hash code of this NumericShaper. - */ - @Override - public int hashCode() { - HashCode hash = new HashCode(); - - hash.append(fRanges); - hash.append(fDefaultContextIndex); - hash.append(fContextual); - - return hash.hashCode(); - - } - - /** - * Compares this NumericShaper object with the specified Object. - * - * @param obj the Object to be compared. - * - * @return true, if this NumericShaper object is equal to - * the specified Object, false otherwise. - */ - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - - if (obj == this) { - return true; - } - - try { - NumericShaper ns = (NumericShaper)obj; - return (fRanges == ns.fRanges && - fDefaultContextIndex == ns.fDefaultContextIndex && - fContextual == ns.fContextual); - } catch (ClassCastException e){ - } - - return false; - } - - /** - * Returns a string representation of this NumericShaper. - * - * @return the string representation of this NumericShaper. - */ - @Override - public String toString() { - /* !! There is no description in the documentation what this method must - * return. Thus format of toString method is based on 1.5 release - * behavior and can be obtained using next test sample: - * - * // Simple shapers toString format - * System.out.println(NumericShaper.getShaper(NumericShaper.EASTERN_ARABIC)); - * - * // Context shapers with default context toString format - * System.out.println(NumericShaper.getContextualShaper( - * NumericShaper.ARABIC | NumericShaper.TAMIL)); - * - * // Context shapers with context - * System.out.println(NumericShaper.getContextualShaper( - * NumericShaper.ARABIC | NumericShaper.TAMIL, - * NumericShaper.EASTERN_ARABIC)); - */ - StringBuffer sb = new StringBuffer(super.toString()); - - sb.append("[contextual:"); //$NON-NLS-1$ - sb.append(fContextual); - - if (fContextual){ - sb.append(", context:"); //$NON-NLS-1$ - sb.append(contexts[fDefaultContextIndex]); - } - - sb.append(", range(s): "); //$NON-NLS-1$ - if (fContextual) { - int index = 0; - boolean isFirst = true; - while (index < MAX_INDEX){ - if ((fRanges & (1 << index)) != 0){ - if (isFirst){ - isFirst = false; - } else { - sb.append(", "); //$NON-NLS-1$ - } - sb.append(contexts[index]); - } - index++; - } - } else { - sb.append(contexts[fSingleRangeIndex]); - } - sb.append("]"); //$NON-NLS-1$ - - return sb.toString(); - } - - /** - * Gets the NumericShaper for the specified unicode ranges - * and default unicode range. The defaultContext parameter - * is used as the starting context (which indicates the - * language/script being used). The OR logical operation - * should be used for multiple ranges: - * NumericShaper.DEVANAGARI | NumericShaper.BENGALI. - * The NumericShaper returned by this method is contextual - * in that it supports multiple character ranges, depending - * on the context. - * - * @param ranges the unicode ranges. - * @param defaultContext the default, starting context. - * - * @return the NumericShaper for the specified ranges. - */ - public static NumericShaper getContextualShaper(int ranges, - int defaultContext) { - ranges &= ALL_RANGES; - defaultContext &= ALL_RANGES; - return new NumericShaper(ranges, defaultContext, true); - } - - /** - * Gets the NumericShaper for the specified unicode ranges. - * The OR logical operation should be used for multiple ranges: - * NumericShaper.DEVANAGARI | NumericShaper.BENGALI. - * The NumericShaper returned by this method is contextual - * in that it supports multiple character ranges, depending - * on the context. - * - * @param ranges the unicode ranges. - * - * @return the NumericShaper for the specified ranges. - */ - public static NumericShaper getContextualShaper(int ranges) { - ranges &= ALL_RANGES; - return new NumericShaper(ranges, EUROPEAN, true); - } - - /** - * Gets the masks for all of the ranges supported by this NumericShaper, - * packed into an int value using the logical OR logical operation - * for multiple ranges: - * NumericShaper.DEVANAGARI | NumericShaper.BENGALI. - * - * @return all ranges of this NumericShaper. - */ - public int getRanges() { - return fRanges; - } - - /** - * Gets a NumericShaper for the specified unicode range. - * The NumericShaper supports only a single range and - * hence is not contextual. - * - * @param singleRange the specified unicode single range. - * - * @return the NumericShaper for the specified unicode range. - */ - public static NumericShaper getShaper(int singleRange) { - singleRange &= ALL_RANGES; - return new NumericShaper(singleRange, EUROPEAN, false); - } - - /** - * Checks if this NumericShaper is contextual (supporting - * multiple script ranges) or not. - * - * @return true, if this NumericShaper is contextual, false otherwise. - */ - public boolean isContextual() { - return fContextual; - } - - /** - * Transforms the encoding of the text, starting from the character - * at index start and transforming count characters, - * using the specified context. - * - * @param text the text to be shaped. - * @param start the start offset of the text. - * @param count the number of characters to be shaped. - * @param context the context to be used for shaping. - */ - public void shape(char[] text, int start, int count, int context) { - if (isContextual()){ - contextualShape(text, start, count, getIndexFromRange(context)); - } else { - nonContextualShape(text, start, count); - } - } - - /** - * Transforms the encoding of the text, starting from the character - * at index start and transforming count characters. - * - * @param text the text to be shaped. - * @param start the start offset of the text. - * @param count the number of characters to be shaped. - */ - public void shape(char[] text, int start, int count) { - if (isContextual()){ - contextualShape(text, start, count, fDefaultContextIndex); - } else { - nonContextualShape(text, start, count); - } - } - - /** - * Converts count of digits of the given array of characters from the start - * index using specified context. This method is applied for the contextual - * shaping, if the shaper instance is not contextual use nonContextualShape - * method. - * - * @param text an array of chars - * @param start index of the first character to convert - * @param count a number of characters to convert - * @param contextIndex index of the script index to use in shaper - */ - private void contextualShape(char[] text, int start, int count, - int contextIndex){ - char maxDigit = (char)0x0039; - char minDigit = (char)0x0030; - - int currIndex; - if (((1 << contextIndex) & fRanges) == 0 ){ - currIndex = INDEX_EUROPEAN; - } else { - currIndex = contextIndex; - } - - for (int ind = start; ind < start + count; ind++){ - if (minDigit <= text[ind] && text[ind] <= maxDigit){ - if (currIndex != INDEX_ETHIOPIC || text[ind] != '0'){ - text[ind] = (char)(digitsLowRanges[currIndex] + text[ind]); - } - } else { - if(isCharStrong(text[ind])){ - int index = getCharIndex(text[ind]); - if (currIndex != index){ - if (((1 << index) & fRanges) != 0){ - currIndex = index; - } else { - currIndex = INDEX_EUROPEAN; - } - } - } - } - } - - } - - /** - * Converts count of digits of the given array of characters from the start - * index. Method is applied for non-contextual shaper. - * - * @param text an array of chars - * @param start index of the first character to convert - * @param count a number of characters to convert - */ - private void nonContextualShape(char[] text, int start, int count){ - char maxDigit = (char)0x0039; - char minDigit = (char)((fRanges == ETHIOPIC) ? 0x0031 : 0x0030); - for (int ind = start; ind < start + count; ind++){ - if (minDigit <= text[ind] && text[ind] <= maxDigit){ - text[ind] = (char)(digitsLowRanges[fSingleRangeIndex] + text[ind]); - } - } - - } - - /** - * Returns the index of the script of the specified char. - * - * @param ch specified unicode character - * - * @return script index corresponding to the given char - */ - private int getCharIndex(char ch){ - int index = INDEX_EUROPEAN; - for (int i=0; i < MAX_INDEX; i++){ - int j = i * 2; - if (scriptsRanges[j] <= ch && ch <= scriptsRanges[j+1]){ - return i; - } - } - - return index; - } - - /** - * Returns true if the bidirectional category of the character - * is strong. - * - * @param chr the chr - * - * @return true, if the character is strong, false otherwise - */ - private boolean isCharStrong(int chr) { - return (STRONG_TEXT_FLAGS[chr >> 5] & (1 << (chr % 32))) != 0; - } - - /** - * Updates all private serialized fields for object to be correctly serialized - * according to the serialized form of this class mentioned in the - * documentation. - */ - private void updateRangesFields(){ - fRanges = (mask & ~(1 << 31)); - fContextual = ((mask &(1 << 31)) != 0); - if (fContextual){ - fRanges = (mask & ~(1 << 31)); - fDefaultContextIndex = key; - } else { - fRanges = mask; - fSingleRangeIndex = key; - } - } - - /** - * Updates private fields for object after deserialization - * according to the serialized form of this class mentioned in the - * documentation. - */ - private void updateKeyMaskFields(){ - mask = fRanges; - if (fContextual){ - mask |= (1 << 31); - key = fDefaultContextIndex; - } else{ - key = fSingleRangeIndex; - } - } - - /** - * Write object. - * - * @param out the out - * - * @throws IOException Signals that an I/O exception has occurred. - */ - private void writeObject(java.io.ObjectOutputStream out) - throws IOException{ - updateKeyMaskFields(); - out.defaultWriteObject(); - } - - /** - * Read object. - * - * @param in the in - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws ClassNotFoundException the class not found exception - */ - private void readObject(java.io.ObjectInputStream in) - throws IOException, ClassNotFoundException{ - in.defaultReadObject(); - updateRangesFields(); - } - -} - diff --git a/libcore/awt-kernel/src/main/java/java/awt/font/TextAttribute.java b/libcore/awt-kernel/src/main/java/java/awt/font/TextAttribute.java deleted file mode 100644 index aa1394aae..000000000 --- a/libcore/awt-kernel/src/main/java/java/awt/font/TextAttribute.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @author Ilya S. Okomin - * @version $Revision$ - */ -package java.awt.font; - -import java.io.InvalidObjectException; -import java.text.AttributedCharacterIterator.Attribute; -import java.util.HashMap; -import java.util.Map; - -// BEGIN android-deleted -//import org.apache.harmony.awt.internal.nls.Messages; -// END android-deleted - -/** - * The TextAttribute class defines attribute keys and attribute values - * for text rendering. Each TextAttributes should have the following - * information: - *

    - *
  • key name;
  • - *
  • valid values;
  • - *
  • relevant constants;
  • - *
  • default action if the attribute is absent;
  • - *
  • default action's description.
  • - *
- */ -public final class TextAttribute extends Attribute { - - /** The Constant serialVersionUID. */ - private static final long serialVersionUID = 7744112784117861702L; - - // set of available text attributes - /** The Constant attrMap. */ - private static final Map attrMap = new HashMap(); - - /** - * Instantiates a new TextAttribute with the specified name. - * - * @param name the name of TextAttribute. - */ - protected TextAttribute(String name) { - super(name); - attrMap.put(name, this); - } - - /** - * Resolves the instance being deserialized. - * - * @return the Object. - * - * @throws InvalidObjectException the InvalidObjectException. - */ - @Override - protected Object readResolve() throws InvalidObjectException { - TextAttribute result = attrMap.get(this.getName()); - if (result != null) { - return result; - } - // BEGIN android-changed - throw new InvalidObjectException("Unknown attribute name"); - // END android-changed - } - - /** - * The BACKGROUND text attribute. - */ - public static final TextAttribute BACKGROUND = new TextAttribute("background"); //$NON-NLS-1$ - - /** The BIDI_EMBEDDING text attribute key. */ - public static final TextAttribute BIDI_EMBEDDING = new TextAttribute("bidi_embedding"); //$NON-NLS-1$ - - /** The CHAR_REPLACEMENT text attribute key. */ - public static final TextAttribute CHAR_REPLACEMENT = new TextAttribute("char_replacement"); //$NON-NLS-1$ - - /** The FAMILY text attribute key. */ - public static final TextAttribute FAMILY = new TextAttribute("family"); //$NON-NLS-1$ - - /** The FONT text attribute key. */ - public static final TextAttribute FONT = new TextAttribute("font"); //$NON-NLS-1$ - - /** The FOREGROUND text attribute key. */ - public static final TextAttribute FOREGROUND = new TextAttribute("foreground"); //$NON-NLS-1$ - - /** The INPUT_METHOD_HIGHLIGHT text attribute key. */ - public static final TextAttribute INPUT_METHOD_HIGHLIGHT = new TextAttribute( - "input method highlight"); //$NON-NLS-1$ - - /** The INPUT_METHOD_UNDERLINE text attribute key. */ - public static final TextAttribute INPUT_METHOD_UNDERLINE = new TextAttribute( - "input method underline"); //$NON-NLS-1$ - - /** The JUSTIFICATION text attribute key. */ - public static final TextAttribute JUSTIFICATION = new TextAttribute("justification"); //$NON-NLS-1$ - - /** The Constant JUSTIFICATION_indicates the full requested width. */ - public static final Float JUSTIFICATION_FULL = new Float(1.0f); - - /** - * The Constant JUSTIFICATION_NONE indicates that line is not - * allowed for justification. - */ - public static final Float JUSTIFICATION_NONE = new Float(0.0f); - - /** The NUMERIC_SHAPING text attribute. */ - public static final TextAttribute NUMERIC_SHAPING = new TextAttribute("numeric_shaping"); //$NON-NLS-1$ - - /** The POSTURE text attribute. */ - public static final TextAttribute POSTURE = new TextAttribute("posture"); //$NON-NLS-1$ - - /** The Constant POSTURE_REGULAR indicates regular posture. */ - public static final Float POSTURE_REGULAR = new Float(0.0f); - - /** The Constant POSTURE_OBLIQUE indicates italic posture. */ - public static final Float POSTURE_OBLIQUE = new Float(0.20f); - - /** The RUN_DIRECTION text attribute. */ - public static final TextAttribute RUN_DIRECTION = new TextAttribute("run_direction"); //$NON-NLS-1$ - - /** - * The Constant RUN_DIRECTION_LTR indicates left-to-right run - * direction. - */ - public static final Boolean RUN_DIRECTION_LTR = new Boolean(false); - - /** - * The Constant RUN_DIRECTION_RTL indicates right-to-left run - * direction. - */ - public static final Boolean RUN_DIRECTION_RTL = new Boolean(true); - - /** The SIZE text attribute. */ - public static final TextAttribute SIZE = new TextAttribute("size"); //$NON-NLS-1$ - - /** The STRIKETHROUGH text attribute. */ - public static final TextAttribute STRIKETHROUGH = new TextAttribute("strikethrough"); //$NON-NLS-1$ - - /** The Constant STRIKETHROUGH_ON indicates a single strikethrough. */ - public static final Boolean STRIKETHROUGH_ON = new Boolean(true); - - /** The SUPERSCRIPT text attribute. */ - public static final TextAttribute SUPERSCRIPT = new TextAttribute("superscript"); //$NON-NLS-1$ - - /** The Constant SUPERSCRIPT_SUB indicates a standard subscript. */ - public static final Integer SUPERSCRIPT_SUB = new Integer(-1); - - /** The Constant SUPERSCRIPT_SUPER indicates a standard superscript. */ - public static final Integer SUPERSCRIPT_SUPER = new Integer(1); - - /** The SWAP_COLORS text attribute. */ - public static final TextAttribute SWAP_COLORS = new TextAttribute("swap_colors"); //$NON-NLS-1$ - - /** - * The Constant SWAP_COLORS_ON indicates a swap of foreground - * and background. - */ - public static final Boolean SWAP_COLORS_ON = new Boolean(true); - - /** The TRANSFORM text attribute. */ - public static final TextAttribute TRANSFORM = new TextAttribute("transform"); //$NON-NLS-1$ - - /** The Constant UNDERLINE text attribute. */ - public static final TextAttribute UNDERLINE = new TextAttribute("underline"); //$NON-NLS-1$ - - /** - * The Constant UNDERLINE_ON indicates a standard underline - * at the roman baseline for roman text. - */ - public static final Integer UNDERLINE_ON = new Integer(0); - - /** - * The Constant UNDERLINE_LOW_ONE_PIXEL indicates a single - * pixel solid low underline. - */ - public static final Integer UNDERLINE_LOW_ONE_PIXEL = new Integer(1); - - /** - * The Constant UNDERLINE_LOW_TWO_PIXEL indicates a double - * pixel solid low underline. - */ - public static final Integer UNDERLINE_LOW_TWO_PIXEL = new Integer(2); - - /** - * The Constant UNDERLINE_LOW_DOTTED indicates a - * single pixel dotted low underline. - */ - public static final Integer UNDERLINE_LOW_DOTTED = new Integer(3); - - /** - * The Constant UNDERLINE_LOW_GRAY indicates double pixel - * gray low underline. - */ - public static final Integer UNDERLINE_LOW_GRAY = new Integer(4); - - /** - * The Constant UNDERLINE_LOW_DASHED indicates single pixel dashed - * low underline. - */ - public static final Integer UNDERLINE_LOW_DASHED = new Integer(5); - - /** The WEIGHT text attribute. */ - public static final TextAttribute WEIGHT = new TextAttribute("weight"); //$NON-NLS-1$ - - /** - * The Constant WEIGHT_EXTRA_LIGHT indicates the lightest - * predefined weight. - */ - public static final Float WEIGHT_EXTRA_LIGHT = new Float(0.5f); - - /** - * The Constant WEIGHT_LIGHT indicates the standard light weight. - */ - public static final Float WEIGHT_LIGHT = new Float(0.75f); - - /** - * The Constant WEIGHT_DEMILIGHT indicates an intermediate weight - * between LIGHT and STANDARD. - */ - public static final Float WEIGHT_DEMILIGHT = new Float(0.875f); - - /** - * The Constant WEIGHT_REGULAR indicates the standart weight. - */ - public static final Float WEIGHT_REGULAR = new Float(1.0f); - - /** - * The Constant WEIGHT_SEMIBOLD indicates a semi weight - * of REGULAR. - */ - public static final Float WEIGHT_SEMIBOLD = new Float(1.25f); - - /** The Constant WEIGHT_MEDIUM indicates average weight - * between the REGULAR and BOLD. */ - public static final Float WEIGHT_MEDIUM = new Float(1.5f); - - /** The Constant WEIGHT_DEMIBOLD indicates - * a lighter weight than BOLD. */ - public static final Float WEIGHT_DEMIBOLD = new Float(1.75f); - - /** The Constant WEIGHT_BOLD indicates the standard bold weight. */ - public static final Float WEIGHT_BOLD = new Float(2.0f); - - /** The Constant WEIGHT_HEAVY indicates a heavier weight than BOLD. */ - public static final Float WEIGHT_HEAVY = new Float(2.25f); - - /** The Constant WEIGHT_EXTRABOLD indicates an extra heavy weight. */ - public static final Float WEIGHT_EXTRABOLD = new Float(2.5f); - - /** - * The Constant WEIGHT_ULTRABOLD indicates the heaviest predefined - * weight. - */ - public static final Float WEIGHT_ULTRABOLD = new Float(2.75f); - - /** The WIDTH text attribute. */ - public static final TextAttribute WIDTH = new TextAttribute("width"); //$NON-NLS-1$ - - /** - * The Constant WIDTH_CONDENSED indicates the most condensed - * predefined width. - */ - public static final Float WIDTH_CONDENSED = new Float(0.75f); - - /** - * The Constant WIDTH_SEMI_CONDENSED indicates - * a semi condensed width. - */ - public static final Float WIDTH_SEMI_CONDENSED = new Float(0.875f); - - /** - * The Constant WIDTH_REGULAR indicates the standard width. - */ - public static final Float WIDTH_REGULAR = new Float(1.0f); - - /** - * The Constant WIDTH_SEMI_EXTENDED indicates semi extended width. - */ - public static final Float WIDTH_SEMI_EXTENDED = new Float(1.25f); - - /** - * The Constant WIDTH_EXTENDED indicates extended width. - */ - public static final Float WIDTH_EXTENDED = new Float(1.5f); - -} diff --git a/libcore/awt-kernel/src/main/java/java/beans/IndexedPropertyChangeEvent.java b/libcore/awt-kernel/src/main/java/java/beans/IndexedPropertyChangeEvent.java deleted file mode 100644 index 5bd4b2e4f..000000000 --- a/libcore/awt-kernel/src/main/java/java/beans/IndexedPropertyChangeEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.beans; - -/** - * A type of {@link PropertyChangeEvent} that indicates that an indexed property - * has changed. - * - * @since Android 1.0 - */ -public class IndexedPropertyChangeEvent extends PropertyChangeEvent { - - private static final long serialVersionUID = -320227448495806870L; - - private final int index; - - /** - * Creates a new property changed event with an indication of the property - * index. - * - * @param source - * the changed bean. - * @param propertyName - * the changed property, or null to indicate an - * unspecified set of the properties has changed. - * @param oldValue - * the previous value of the property, or null if - * the propertyName is null or the - * previous value is unknown. - * @param newValue - * the new value of the property, or null if the - * propertyName is null or the new - * value is unknown.. - * @param index - * the index of the property. - */ - public IndexedPropertyChangeEvent(Object source, String propertyName, - Object oldValue, Object newValue, int index) { - super(source, propertyName, oldValue, newValue); - this.index = index; - } - - /** - * Answer the index of the property that was changed in this event. - * - * @return the property element index. - */ - public int getIndex() { - return index; - } -} diff --git a/libcore/awt-kernel/src/main/java/java/beans/PropertyChangeEvent.java b/libcore/awt-kernel/src/main/java/java/beans/PropertyChangeEvent.java deleted file mode 100644 index 04caed88c..000000000 --- a/libcore/awt-kernel/src/main/java/java/beans/PropertyChangeEvent.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.beans; - -import java.util.EventObject; - -/** - * An event that indicates that a constraint or a boundary of a property has - * changed. - * - * @since Android 1.0 - */ -public class PropertyChangeEvent extends EventObject { - - private static final long serialVersionUID = 7042693688939648123L; - - String propertyName; - - Object oldValue; - - Object newValue; - - Object propagationId; - - /** - * The constructor used to create a new {@code PropertyChangeEvent}. - * - * @param source - * the changed bean. - * @param propertyName - * the changed property, or null to indicate an - * unspecified set of the properties has changed. - * @param oldValue - * the previous value of the property, or null if - * the propertyName is null or the - * previous value is unknown. - * @param newValue - * the new value of the property, or null if the - * propertyName is null or the new - * value is unknown. - */ - public PropertyChangeEvent(Object source, String propertyName, - Object oldValue, Object newValue) { - super(source); - - this.propertyName = propertyName; - this.oldValue = oldValue; - this.newValue = newValue; - } - - /** - * Returns the name of the property that has changed. If an unspecified set - * of properties has changed it returns null. - * - * @return the name of the property that has changed, or null. - */ - public String getPropertyName() { - return propertyName; - } - - /** - * Sets the propagationId object. - * - * @see #getPropagationId() - */ - public void setPropagationId(Object propagationId) { - this.propagationId = propagationId; - } - - /** - * Returns the propagationId object. This is reserved for future use. Beans - * 1.0 demands that a listener receiving this property and then sending its - * own PropertyChangeEvent sets the received propagationId on the new - * PropertyChangeEvent's propagationId field. - * - * @return the propagationId object. - */ - public Object getPropagationId() { - return propagationId; - } - - /** - * Returns the old value that the property had. If the old value is unknown - * this method returns null. - * - * @return the old property value or null. - */ - public Object getOldValue() { - return oldValue; - } - - /** - * Returns the new value that the property now has. If the new value is - * unknown this method returns null. - * - * @return the old property value or null. - */ - public Object getNewValue() { - return newValue; - } -} diff --git a/libcore/awt-kernel/src/main/java/java/beans/PropertyChangeListener.java b/libcore/awt-kernel/src/main/java/java/beans/PropertyChangeListener.java deleted file mode 100644 index 251579290..000000000 --- a/libcore/awt-kernel/src/main/java/java/beans/PropertyChangeListener.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.beans; - -import java.util.EventListener; - -/** - * A PropertyChangeListener can subscribe with a event source. Whenever that - * source raises a PropertyChangeEvent this listener will get notified. - * - * @since Android 1.0 - */ -public interface PropertyChangeListener extends EventListener { - - /** - * The source bean calls this method when an event is raised. - * - * @param event - * the {@link PropertyChangeEvent} object which contains the name - * and the old and new value of the property that has changed. - */ - public void propertyChange(PropertyChangeEvent event); -} diff --git a/libcore/awt-kernel/src/main/java/java/beans/PropertyChangeListenerProxy.java b/libcore/awt-kernel/src/main/java/java/beans/PropertyChangeListenerProxy.java deleted file mode 100644 index d27e4ebce..000000000 --- a/libcore/awt-kernel/src/main/java/java/beans/PropertyChangeListenerProxy.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.beans; - -import java.util.EventListenerProxy; - -/** - * The implementation of this listener proxy just delegates the received events - * to its listener. - * - * @since Android 1.0 - */ -public class PropertyChangeListenerProxy extends EventListenerProxy implements - PropertyChangeListener { - - String propertyName; - - /** - * Creates a new listener proxy that associates a listener with a property - * name. - * - * @param propertyName - * the name of the associated property. - * @param listener - * the listener to delegate incoming events to. - */ - public PropertyChangeListenerProxy(String propertyName, - PropertyChangeListener listener) { - super(listener); - this.propertyName = propertyName; - } - - /** - * Returns the name of the property associated with this listener proxy. - * - * @return the name of the associated property. - */ - public String getPropertyName() { - return propertyName; - } - - public void propertyChange(PropertyChangeEvent event) { - PropertyChangeListener listener = (PropertyChangeListener) getListener(); - listener.propertyChange(event); - } -} diff --git a/libcore/awt-kernel/src/main/java/java/beans/PropertyChangeSupport.java b/libcore/awt-kernel/src/main/java/java/beans/PropertyChangeSupport.java deleted file mode 100644 index 9225d955a..000000000 --- a/libcore/awt-kernel/src/main/java/java/beans/PropertyChangeSupport.java +++ /dev/null @@ -1,501 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.beans; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * This utility class - * - */ -public class PropertyChangeSupport implements Serializable { - - private static final long serialVersionUID = 6401253773779951803l; - - private transient Object sourceBean; - - private transient List allPropertiesChangeListeners = - new ArrayList(); - - private transient Map> - selectedPropertiesChangeListeners = - new HashMap>(); - - // fields for serialization compatibility - private Hashtable> children; - - private Object source; - - private int propertyChangeSupportSerializedDataVersion = 1; - - /** - * Creates a new instance that uses the source bean as source for any event. - * - * @param sourceBean - * the bean used as source for all events. - */ - public PropertyChangeSupport(Object sourceBean) { - if (sourceBean == null) { - throw new NullPointerException(); - } - this.sourceBean = sourceBean; - } - - /** - * Fires a {@link PropertyChangeEvent} with the given name, old value and - * new value. As source the bean used to initialize this instance is used. - * If the old value and the new value are not null and equal the event will - * not be fired. - * - * @param propertyName - * the name of the property - * @param oldValue - * the old value of the property - * @param newValue - * the new value of the property - */ - public void firePropertyChange(String propertyName, Object oldValue, - Object newValue) { - PropertyChangeEvent event = createPropertyChangeEvent(propertyName, - oldValue, newValue); - doFirePropertyChange(event); - } - - /** - * Fires an {@link IndexedPropertyChangeEvent} with the given name, old - * value, new value and index. As source the bean used to initialize this - * instance is used. If the old value and the new value are not null and - * equal the event will not be fired. - * - * @param propertyName - * the name of the property - * @param index - * the index - * @param oldValue - * the old value of the property - * @param newValue - * the new value of the property - */ - public void fireIndexedPropertyChange(String propertyName, int index, - Object oldValue, Object newValue) { - - // nulls and equals check done in doFire... - doFirePropertyChange(new IndexedPropertyChangeEvent(sourceBean, - propertyName, oldValue, newValue, index)); - } - - /** - * Removes the listener from the specific property. This only happens if it - * was registered to this property. Nothing happens if it was not - * registered with this property or if the property name or the listener is - * null. - * - * @param propertyName - * the property name the listener is listening to - * @param listener - * the listener to remove - */ - public synchronized void removePropertyChangeListener(String propertyName, - PropertyChangeListener listener) { - if ((propertyName != null) && (listener != null)) { - List listeners = - selectedPropertiesChangeListeners.get(propertyName); - - if (listeners != null) { - listeners.remove(listener); - } - } - } - - /** - * Adds a listener to a specific property. Nothing happens if the property - * name or the listener is null. - * - * @param propertyName - * the name of the property - * @param listener - * the listener to register for the property with the given name - */ - public synchronized void addPropertyChangeListener(String propertyName, - PropertyChangeListener listener) { - if ((listener != null) && (propertyName != null)) { - List listeners = - selectedPropertiesChangeListeners.get(propertyName); - - if (listeners == null) { - listeners = new ArrayList(); - selectedPropertiesChangeListeners.put(propertyName, listeners); - } - - // RI compatibility - if (listener instanceof PropertyChangeListenerProxy) { - PropertyChangeListenerProxy proxy = - (PropertyChangeListenerProxy) listener; - - listeners.add(new PropertyChangeListenerProxy( - proxy.getPropertyName(), - (PropertyChangeListener) proxy.getListener())); - } else { - listeners.add(listener); - } - } - } - - /** - * Returns an array of listeners that registered to the property with the - * given name. If the property name is null an empty array is returned. - * - * @param propertyName - * the name of the property whose listeners should be returned - * @return the array of listeners to the property with the given name. - */ - public synchronized PropertyChangeListener[] getPropertyChangeListeners( - String propertyName) { - List listeners = null; - - if (propertyName != null) { - listeners = selectedPropertiesChangeListeners.get(propertyName); - } - - return (listeners == null) ? new PropertyChangeListener[] {} - : listeners.toArray( - new PropertyChangeListener[listeners.size()]); - } - - /** - * Fires a property change of a boolean property with the given name. If the - * old value and the new value are not null and equal the event will not be - * fired. - * - * @param propertyName - * the property name - * @param oldValue - * the old value - * @param newValue - * the new value - */ - public void firePropertyChange(String propertyName, boolean oldValue, - boolean newValue) { - PropertyChangeEvent event = createPropertyChangeEvent(propertyName, - oldValue, newValue); - doFirePropertyChange(event); - } - - /** - * Fires a property change of a boolean property with the given name. If the - * old value and the new value are not null and equal the event will not be - * fired. - * - * @param propertyName - * the property name - * @param index - * the index of the changed property - * @param oldValue - * the old value - * @param newValue - * the new value - */ - public void fireIndexedPropertyChange(String propertyName, int index, - boolean oldValue, boolean newValue) { - - if (oldValue != newValue) { - fireIndexedPropertyChange(propertyName, index, Boolean - .valueOf(oldValue), Boolean.valueOf(newValue)); - } - } - - /** - * Fires a property change of an integer property with the given name. If - * the old value and the new value are not null and equal the event will not - * be fired. - * - * @param propertyName - * the property name - * @param oldValue - * the old value - * @param newValue - * the new value - */ - public void firePropertyChange(String propertyName, int oldValue, - int newValue) { - PropertyChangeEvent event = createPropertyChangeEvent(propertyName, - oldValue, newValue); - doFirePropertyChange(event); - } - - /** - * Fires a property change of an integer property with the given name. If - * the old value and the new value are not null and equal the event will not - * be fired. - * - * @param propertyName - * the property name - * @param index - * the index of the changed property - * @param oldValue - * the old value - * @param newValue - * the new value - */ - public void fireIndexedPropertyChange(String propertyName, int index, - int oldValue, int newValue) { - - if (oldValue != newValue) { - fireIndexedPropertyChange(propertyName, index, - new Integer(oldValue), new Integer(newValue)); - } - } - - /** - * Returns true if there are listeners registered to the property with the - * given name. - * - * @param propertyName - * the name of the property - * @return true if there are listeners registered to that property, false - * otherwise. - */ - public synchronized boolean hasListeners(String propertyName) { - boolean result = allPropertiesChangeListeners.size() > 0; - if (!result && (propertyName != null)) { - List listeners = - selectedPropertiesChangeListeners.get(propertyName); - if (listeners != null) { - result = listeners.size() > 0; - } - } - return result; - } - - /** - * removes a property change listener that was registered to all properties. - * - * @param listener - * the listener to remove - */ - public synchronized void removePropertyChangeListener( - PropertyChangeListener listener) { - if (listener != null) { - if (listener instanceof PropertyChangeListenerProxy) { - String name = ((PropertyChangeListenerProxy) listener) - .getPropertyName(); - PropertyChangeListener lst = (PropertyChangeListener) - ((PropertyChangeListenerProxy) listener).getListener(); - - removePropertyChangeListener(name, lst); - } else { - allPropertiesChangeListeners.remove(listener); - } - } - } - - /** - * Registers a listener with all properties. - * - * @param listener - * the listener to register - */ - public synchronized void addPropertyChangeListener( - PropertyChangeListener listener) { - if (listener != null) { - if (listener instanceof PropertyChangeListenerProxy) { - String name = ((PropertyChangeListenerProxy) listener) - .getPropertyName(); - PropertyChangeListener lst = (PropertyChangeListener) - ((PropertyChangeListenerProxy) listener).getListener(); - addPropertyChangeListener(name, lst); - } else { - allPropertiesChangeListeners.add(listener); - } - } - } - - /** - * Returns an array with the listeners that registered to all properties. - * - * @return the array of listeners - */ - public synchronized PropertyChangeListener[] getPropertyChangeListeners() { - ArrayList result = - new ArrayList( - allPropertiesChangeListeners); - - for (String propertyName : selectedPropertiesChangeListeners.keySet()) { - List selectedListeners = - selectedPropertiesChangeListeners.get(propertyName); - - if (selectedListeners != null) { - - for (PropertyChangeListener listener : selectedListeners) { - result.add(new PropertyChangeListenerProxy(propertyName, - listener)); - } - } - } - - return result.toArray(new PropertyChangeListener[result.size()]); - } - - private void writeObject(ObjectOutputStream oos) throws IOException { - List allSerializedPropertiesChangeListeners = - new ArrayList(); - - for (PropertyChangeListener pcl : allPropertiesChangeListeners) { - if (pcl instanceof Serializable) { - allSerializedPropertiesChangeListeners.add(pcl); - } - } - - Map> - selectedSerializedPropertiesChangeListeners = - new HashMap>(); - - for (String propertyName : selectedPropertiesChangeListeners.keySet()) { - List keyValues = - selectedPropertiesChangeListeners.get(propertyName); - - if (keyValues != null) { - List serializedPropertiesChangeListeners - = new ArrayList(); - - for (PropertyChangeListener pcl : keyValues) { - if (pcl instanceof Serializable) { - serializedPropertiesChangeListeners.add(pcl); - } - } - - if (!serializedPropertiesChangeListeners.isEmpty()) { - selectedSerializedPropertiesChangeListeners.put( - propertyName, serializedPropertiesChangeListeners); - } - } - } - - children = new Hashtable>( - selectedSerializedPropertiesChangeListeners); - children.put("", allSerializedPropertiesChangeListeners); //$NON-NLS-1$ - oos.writeObject(children); - - Object source = null; - if (sourceBean instanceof Serializable) { - source = sourceBean; - } - oos.writeObject(source); - - oos.writeInt(propertyChangeSupportSerializedDataVersion); - } - - @SuppressWarnings("unchecked") - private void readObject(ObjectInputStream ois) throws IOException, - ClassNotFoundException { - children = (Hashtable>) ois - .readObject(); - - selectedPropertiesChangeListeners = new HashMap>( - children); - allPropertiesChangeListeners = selectedPropertiesChangeListeners - .remove(""); //$NON-NLS-1$ - if (allPropertiesChangeListeners == null) { - allPropertiesChangeListeners = new ArrayList(); - } - - sourceBean = ois.readObject(); - propertyChangeSupportSerializedDataVersion = ois.readInt(); - } - - /** - * Fires a property change event to all listeners of that property. - * - * @param event - * the event to fire - */ - public void firePropertyChange(PropertyChangeEvent event) { - doFirePropertyChange(event); - } - - private PropertyChangeEvent createPropertyChangeEvent(String propertyName, - Object oldValue, Object newValue) { - return new PropertyChangeEvent(sourceBean, propertyName, oldValue, - newValue); - } - - private PropertyChangeEvent createPropertyChangeEvent(String propertyName, - boolean oldValue, boolean newValue) { - return new PropertyChangeEvent(sourceBean, propertyName, oldValue, - newValue); - } - - private PropertyChangeEvent createPropertyChangeEvent(String propertyName, - int oldValue, int newValue) { - return new PropertyChangeEvent(sourceBean, propertyName, oldValue, - newValue); - } - - private void doFirePropertyChange(PropertyChangeEvent event) { - String propertyName = event.getPropertyName(); - Object oldValue = event.getOldValue(); - Object newValue = event.getNewValue(); - - if ((newValue != null) && (oldValue != null) - && newValue.equals(oldValue)) { - return; - } - - /* - * Copy the listeners collections so they can be modified while we fire - * events. - */ - - // Listeners to all property change events - PropertyChangeListener[] listensToAll; - // Listens to a given property change - PropertyChangeListener[] listensToOne = null; - synchronized (this) { - listensToAll = allPropertiesChangeListeners - .toArray(new PropertyChangeListener[allPropertiesChangeListeners - .size()]); - - List listeners = selectedPropertiesChangeListeners - .get(propertyName); - if (listeners != null) { - listensToOne = listeners - .toArray(new PropertyChangeListener[listeners.size()]); - } - } - - // Fire the listeners - for (PropertyChangeListener listener : listensToAll) { - listener.propertyChange(event); - } - if (listensToOne != null) { - for (PropertyChangeListener listener : listensToOne) { - listener.propertyChange(event); - } - } - } - -} diff --git a/libcore/concurrent/MODULE_LICENSE_PUBLIC_DOMAIN b/libcore/concurrent/MODULE_LICENSE_PUBLIC_DOMAIN deleted file mode 100644 index e69de29bb..000000000 diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/AbstractExecutorService.java b/libcore/concurrent/src/main/java/java/util/concurrent/AbstractExecutorService.java deleted file mode 100644 index f7ed15cc3..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/AbstractExecutorService.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; -import java.util.*; - -/** - * Provides default implementations of {@link ExecutorService} - * execution methods. This class implements the submit, - * invokeAny and invokeAll methods using the default - * {@link FutureTask} class provided in this package. For example, - * the implementation of submit(Runnable) creates an - * associated FutureTask that is executed and - * returned. Subclasses overriding these methods to use different - * {@link Future} implementations should do so consistently for each - * of these methods. - * - * @since 1.5 - * @author Doug Lea - */ -public abstract class AbstractExecutorService implements ExecutorService { - - /** - * @throws RejectedExecutionException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - */ - public Future submit(Runnable task) { - if (task == null) throw new NullPointerException(); - FutureTask ftask = new FutureTask(task, null); - execute(ftask); - return ftask; - } - - /** - * @throws RejectedExecutionException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - */ - public Future submit(Runnable task, T result) { - if (task == null) throw new NullPointerException(); - FutureTask ftask = new FutureTask(task, result); - execute(ftask); - return ftask; - } - - /** - * @throws RejectedExecutionException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - */ - public Future submit(Callable task) { - if (task == null) throw new NullPointerException(); - FutureTask ftask = new FutureTask(task); - execute(ftask); - return ftask; - } - - /** - * the main mechanics of invokeAny. - */ - private T doInvokeAny(Collection> tasks, - boolean timed, long nanos) - throws InterruptedException, ExecutionException, TimeoutException { - if (tasks == null) - throw new NullPointerException(); - int ntasks = tasks.size(); - if (ntasks == 0) - throw new IllegalArgumentException(); - List> futures= new ArrayList>(ntasks); - ExecutorCompletionService ecs = - new ExecutorCompletionService(this); - - // For efficiency, especially in executors with limited - // parallelism, check to see if previously submitted tasks are - // done before submitting more of them. This interleaving - // plus the exception mechanics account for messiness of main - // loop. - - try { - // Record exceptions so that if we fail to obtain any - // result, we can throw the last exception we got. - ExecutionException ee = null; - long lastTime = (timed)? System.nanoTime() : 0; - Iterator> it = tasks.iterator(); - - // Start one task for sure; the rest incrementally - futures.add(ecs.submit(it.next())); - --ntasks; - int active = 1; - - for (;;) { - Future f = ecs.poll(); - if (f == null) { - if (ntasks > 0) { - --ntasks; - futures.add(ecs.submit(it.next())); - ++active; - } - else if (active == 0) - break; - else if (timed) { - f = ecs.poll(nanos, TimeUnit.NANOSECONDS); - if (f == null) - throw new TimeoutException(); - long now = System.nanoTime(); - nanos -= now - lastTime; - lastTime = now; - } - else - f = ecs.take(); - } - if (f != null) { - --active; - try { - return f.get(); - } catch (InterruptedException ie) { - throw ie; - } catch (ExecutionException eex) { - ee = eex; - } catch (RuntimeException rex) { - ee = new ExecutionException(rex); - } - } - } - - if (ee == null) - ee = new ExecutionException(); - throw ee; - - } finally { - for (Future f : futures) - f.cancel(true); - } - } - - public T invokeAny(Collection> tasks) - throws InterruptedException, ExecutionException { - try { - return doInvokeAny(tasks, false, 0); - } catch (TimeoutException cannotHappen) { - assert false; - return null; - } - } - - public T invokeAny(Collection> tasks, - long timeout, TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException { - return doInvokeAny(tasks, true, unit.toNanos(timeout)); - } - - public List> invokeAll(Collection> tasks) - throws InterruptedException { - if (tasks == null) - throw new NullPointerException(); - List> futures = new ArrayList>(tasks.size()); - boolean done = false; - try { - for (Callable t : tasks) { - FutureTask f = new FutureTask(t); - futures.add(f); - execute(f); - } - for (Future f : futures) { - if (!f.isDone()) { - try { - f.get(); - } catch (CancellationException ignore) { - } catch (ExecutionException ignore) { - } - } - } - done = true; - return futures; - } finally { - if (!done) - for (Future f : futures) - f.cancel(true); - } - } - - public List> invokeAll(Collection> tasks, - long timeout, TimeUnit unit) - throws InterruptedException { - if (tasks == null || unit == null) - throw new NullPointerException(); - long nanos = unit.toNanos(timeout); - List> futures = new ArrayList>(tasks.size()); - boolean done = false; - try { - for (Callable t : tasks) - futures.add(new FutureTask(t)); - - long lastTime = System.nanoTime(); - - // Interleave time checks and calls to execute in case - // executor doesn't have any/much parallelism. - Iterator> it = futures.iterator(); - while (it.hasNext()) { - execute((Runnable)(it.next())); - long now = System.nanoTime(); - nanos -= now - lastTime; - lastTime = now; - if (nanos <= 0) - return futures; - } - - for (Future f : futures) { - if (!f.isDone()) { - if (nanos <= 0) - return futures; - try { - f.get(nanos, TimeUnit.NANOSECONDS); - } catch (CancellationException ignore) { - } catch (ExecutionException ignore) { - } catch (TimeoutException toe) { - return futures; - } - long now = System.nanoTime(); - nanos -= now - lastTime; - lastTime = now; - } - } - done = true; - return futures; - } finally { - if (!done) - for (Future f : futures) - f.cancel(true); - } - } - -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/ArrayBlockingQueue.java b/libcore/concurrent/src/main/java/java/util/concurrent/ArrayBlockingQueue.java deleted file mode 100644 index 0082f0731..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/ArrayBlockingQueue.java +++ /dev/null @@ -1,778 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; -import java.util.concurrent.locks.*; -import java.util.*; - -// BEGIN android-note -// removed link to collections framework docs -// END android-note - -/** - * A bounded {@linkplain BlockingQueue blocking queue} backed by an - * array. This queue orders elements FIFO (first-in-first-out). The - * head of the queue is that element that has been on the - * queue the longest time. The tail of the queue is that - * element that has been on the queue the shortest time. New elements - * are inserted at the tail of the queue, and the queue retrieval - * operations obtain elements at the head of the queue. - * - *

This is a classic "bounded buffer", in which a - * fixed-sized array holds elements inserted by producers and - * extracted by consumers. Once created, the capacity cannot be - * increased. Attempts to put an element into a full queue - * will result in the operation blocking; attempts to take an - * element from an empty queue will similarly block. - * - *

This class supports an optional fairness policy for ordering - * waiting producer and consumer threads. By default, this ordering - * is not guaranteed. However, a queue constructed with fairness set - * to true grants threads access in FIFO order. Fairness - * generally decreases throughput but reduces variability and avoids - * starvation. - * - *

This class and its iterator implement all of the - * optional methods of the {@link Collection} and {@link - * Iterator} interfaces. - * - * @since 1.5 - * @author Doug Lea - * @param the type of elements held in this collection - */ -public class ArrayBlockingQueue extends AbstractQueue - implements BlockingQueue, java.io.Serializable { - - /** - * Serialization ID. This class relies on default serialization - * even for the items array, which is default-serialized, even if - * it is empty. Otherwise it could not be declared final, which is - * necessary here. - */ - private static final long serialVersionUID = -817911632652898426L; - - /** The queued items */ - private final E[] items; - /** items index for next take, poll or remove */ - private int takeIndex; - /** items index for next put, offer, or add. */ - private int putIndex; - /** Number of items in the queue */ - private int count; - - /* - * Concurrency control uses the classic two-condition algorithm - * found in any textbook. - */ - - /** Main lock guarding all access */ - private final ReentrantLock lock; - /** Condition for waiting takes */ - private final Condition notEmpty; - /** Condition for waiting puts */ - private final Condition notFull; - - // Internal helper methods - - /** - * Circularly increment i. - */ - final int inc(int i) { - return (++i == items.length)? 0 : i; - } - - /** - * Inserts element at current put position, advances, and signals. - * Call only when holding lock. - */ - private void insert(E x) { - items[putIndex] = x; - putIndex = inc(putIndex); - ++count; - notEmpty.signal(); - } - - /** - * Extracts element at current take position, advances, and signals. - * Call only when holding lock. - */ - private E extract() { - final E[] items = this.items; - E x = items[takeIndex]; - items[takeIndex] = null; - takeIndex = inc(takeIndex); - --count; - notFull.signal(); - return x; - } - - /** - * Utility for remove and iterator.remove: Delete item at position i. - * Call only when holding lock. - */ - void removeAt(int i) { - final E[] items = this.items; - // if removing front item, just advance - if (i == takeIndex) { - items[takeIndex] = null; - takeIndex = inc(takeIndex); - } else { - // slide over all others up through putIndex. - for (;;) { - int nexti = inc(i); - if (nexti != putIndex) { - items[i] = items[nexti]; - i = nexti; - } else { - items[i] = null; - putIndex = i; - break; - } - } - } - --count; - notFull.signal(); - } - - /** - * Creates an ArrayBlockingQueue with the given (fixed) - * capacity and default access policy. - * - * @param capacity the capacity of this queue - * @throws IllegalArgumentException if capacity is less than 1 - */ - public ArrayBlockingQueue(int capacity) { - this(capacity, false); - } - - /** - * Creates an ArrayBlockingQueue with the given (fixed) - * capacity and the specified access policy. - * - * @param capacity the capacity of this queue - * @param fair if true then queue accesses for threads blocked - * on insertion or removal, are processed in FIFO order; - * if false the access order is unspecified. - * @throws IllegalArgumentException if capacity is less than 1 - */ - public ArrayBlockingQueue(int capacity, boolean fair) { - if (capacity <= 0) - throw new IllegalArgumentException(); - this.items = (E[]) new Object[capacity]; - lock = new ReentrantLock(fair); - notEmpty = lock.newCondition(); - notFull = lock.newCondition(); - } - - /** - * Creates an ArrayBlockingQueue with the given (fixed) - * capacity, the specified access policy and initially containing the - * elements of the given collection, - * added in traversal order of the collection's iterator. - * - * @param capacity the capacity of this queue - * @param fair if true then queue accesses for threads blocked - * on insertion or removal, are processed in FIFO order; - * if false the access order is unspecified. - * @param c the collection of elements to initially contain - * @throws IllegalArgumentException if capacity is less than - * c.size(), or less than 1. - * @throws NullPointerException if the specified collection or any - * of its elements are null - */ - public ArrayBlockingQueue(int capacity, boolean fair, - Collection c) { - this(capacity, fair); - if (capacity < c.size()) - throw new IllegalArgumentException(); - - for (Iterator it = c.iterator(); it.hasNext();) - add(it.next()); - } - - /** - * Inserts the specified element at the tail of this queue if it is - * possible to do so immediately without exceeding the queue's capacity, - * returning true upon success and throwing an - * IllegalStateException if this queue is full. - * - * @param e the element to add - * @return true (as specified by {@link Collection#add}) - * @throws IllegalStateException if this queue is full - * @throws NullPointerException if the specified element is null - */ - public boolean add(E e) { - return super.add(e); - } - - /** - * Inserts the specified element at the tail of this queue if it is - * possible to do so immediately without exceeding the queue's capacity, - * returning true upon success and false if this queue - * is full. This method is generally preferable to method {@link #add}, - * which can fail to insert an element only by throwing an exception. - * - * @throws NullPointerException if the specified element is null - */ - public boolean offer(E e) { - if (e == null) throw new NullPointerException(); - final ReentrantLock lock = this.lock; - lock.lock(); - try { - if (count == items.length) - return false; - else { - insert(e); - return true; - } - } finally { - lock.unlock(); - } - } - - /** - * Inserts the specified element at the tail of this queue, waiting - * for space to become available if the queue is full. - * - * @throws InterruptedException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - */ - public void put(E e) throws InterruptedException { - if (e == null) throw new NullPointerException(); - final E[] items = this.items; - final ReentrantLock lock = this.lock; - lock.lockInterruptibly(); - try { - try { - while (count == items.length) - notFull.await(); - } catch (InterruptedException ie) { - notFull.signal(); // propagate to non-interrupted thread - throw ie; - } - insert(e); - } finally { - lock.unlock(); - } - } - - /** - * Inserts the specified element at the tail of this queue, waiting - * up to the specified wait time for space to become available if - * the queue is full. - * - * @throws InterruptedException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - */ - public boolean offer(E e, long timeout, TimeUnit unit) - throws InterruptedException { - - if (e == null) throw new NullPointerException(); - long nanos = unit.toNanos(timeout); - final ReentrantLock lock = this.lock; - lock.lockInterruptibly(); - try { - for (;;) { - if (count != items.length) { - insert(e); - return true; - } - if (nanos <= 0) - return false; - try { - nanos = notFull.awaitNanos(nanos); - } catch (InterruptedException ie) { - notFull.signal(); // propagate to non-interrupted thread - throw ie; - } - } - } finally { - lock.unlock(); - } - } - - public E poll() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - if (count == 0) - return null; - E x = extract(); - return x; - } finally { - lock.unlock(); - } - } - - public E take() throws InterruptedException { - final ReentrantLock lock = this.lock; - lock.lockInterruptibly(); - try { - try { - while (count == 0) - notEmpty.await(); - } catch (InterruptedException ie) { - notEmpty.signal(); // propagate to non-interrupted thread - throw ie; - } - E x = extract(); - return x; - } finally { - lock.unlock(); - } - } - - public E poll(long timeout, TimeUnit unit) throws InterruptedException { - long nanos = unit.toNanos(timeout); - final ReentrantLock lock = this.lock; - lock.lockInterruptibly(); - try { - for (;;) { - if (count != 0) { - E x = extract(); - return x; - } - if (nanos <= 0) - return null; - try { - nanos = notEmpty.awaitNanos(nanos); - } catch (InterruptedException ie) { - notEmpty.signal(); // propagate to non-interrupted thread - throw ie; - } - - } - } finally { - lock.unlock(); - } - } - - public E peek() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return (count == 0) ? null : items[takeIndex]; - } finally { - lock.unlock(); - } - } - - // this doc comment is overridden to remove the reference to collections - // greater in size than Integer.MAX_VALUE - /** - * Returns the number of elements in this queue. - * - * @return the number of elements in this queue - */ - public int size() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return count; - } finally { - lock.unlock(); - } - } - - // this doc comment is a modified copy of the inherited doc comment, - // without the reference to unlimited queues. - /** - * Returns the number of additional elements that this queue can ideally - * (in the absence of memory or resource constraints) accept without - * blocking. This is always equal to the initial capacity of this queue - * less the current size of this queue. - * - *

Note that you cannot always tell if an attempt to insert - * an element will succeed by inspecting remainingCapacity - * because it may be the case that another thread is about to - * insert or remove an element. - */ - public int remainingCapacity() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return items.length - count; - } finally { - lock.unlock(); - } - } - - /** - * Removes a single instance of the specified element from this queue, - * if it is present. More formally, removes an element e such - * that o.equals(e), if this queue contains one or more such - * elements. - * Returns true if this queue contained the specified element - * (or equivalently, if this queue changed as a result of the call). - * - * @param o element to be removed from this queue, if present - * @return true if this queue changed as a result of the call - */ - public boolean remove(Object o) { - if (o == null) return false; - final E[] items = this.items; - final ReentrantLock lock = this.lock; - lock.lock(); - try { - int i = takeIndex; - int k = 0; - for (;;) { - if (k++ >= count) - return false; - if (o.equals(items[i])) { - removeAt(i); - return true; - } - i = inc(i); - } - - } finally { - lock.unlock(); - } - } - - /** - * Returns true if this queue contains the specified element. - * More formally, returns true if and only if this queue contains - * at least one element e such that o.equals(e). - * - * @param o object to be checked for containment in this queue - * @return true if this queue contains the specified element - */ - public boolean contains(Object o) { - if (o == null) return false; - final E[] items = this.items; - final ReentrantLock lock = this.lock; - lock.lock(); - try { - int i = takeIndex; - int k = 0; - while (k++ < count) { - if (o.equals(items[i])) - return true; - i = inc(i); - } - return false; - } finally { - lock.unlock(); - } - } - - /** - * Returns an array containing all of the elements in this queue, in - * proper sequence. - * - *

The returned array will be "safe" in that no references to it are - * maintained by this queue. (In other words, this method must allocate - * a new array). The caller is thus free to modify the returned array. - * - *

This method acts as bridge between array-based and collection-based - * APIs. - * - * @return an array containing all of the elements in this queue - */ - public Object[] toArray() { - final E[] items = this.items; - final ReentrantLock lock = this.lock; - lock.lock(); - try { - Object[] a = new Object[count]; - int k = 0; - int i = takeIndex; - while (k < count) { - a[k++] = items[i]; - i = inc(i); - } - return a; - } finally { - lock.unlock(); - } - } - - /** - * Returns an array containing all of the elements in this queue, in - * proper sequence; the runtime type of the returned array is that of - * the specified array. If the queue fits in the specified array, it - * is returned therein. Otherwise, a new array is allocated with the - * runtime type of the specified array and the size of this queue. - * - *

If this queue fits in the specified array with room to spare - * (i.e., the array has more elements than this queue), the element in - * the array immediately following the end of the queue is set to - * null. - * - *

Like the {@link #toArray()} method, this method acts as bridge between - * array-based and collection-based APIs. Further, this method allows - * precise control over the runtime type of the output array, and may, - * under certain circumstances, be used to save allocation costs. - * - *

Suppose x is a queue known to contain only strings. - * The following code can be used to dump the queue into a newly - * allocated array of String: - * - *

-     *     String[] y = x.toArray(new String[0]);
- * - * Note that toArray(new Object[0]) is identical in function to - * toArray(). - * - * @param a the array into which the elements of the queue are to - * be stored, if it is big enough; otherwise, a new array of the - * same runtime type is allocated for this purpose - * @return an array containing all of the elements in this queue - * @throws ArrayStoreException if the runtime type of the specified array - * is not a supertype of the runtime type of every element in - * this queue - * @throws NullPointerException if the specified array is null - */ - public T[] toArray(T[] a) { - final E[] items = this.items; - final ReentrantLock lock = this.lock; - lock.lock(); - try { - if (a.length < count) - a = (T[])java.lang.reflect.Array.newInstance( - a.getClass().getComponentType(), - count - ); - - int k = 0; - int i = takeIndex; - while (k < count) { - a[k++] = (T)items[i]; - i = inc(i); - } - if (a.length > count) - a[count] = null; - return a; - } finally { - lock.unlock(); - } - } - - public String toString() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return super.toString(); - } finally { - lock.unlock(); - } - } - - /** - * Atomically removes all of the elements from this queue. - * The queue will be empty after this call returns. - */ - public void clear() { - final E[] items = this.items; - final ReentrantLock lock = this.lock; - lock.lock(); - try { - int i = takeIndex; - int k = count; - while (k-- > 0) { - items[i] = null; - i = inc(i); - } - count = 0; - putIndex = 0; - takeIndex = 0; - notFull.signalAll(); - } finally { - lock.unlock(); - } - } - - /** - * @throws UnsupportedOperationException {@inheritDoc} - * @throws ClassCastException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - * @throws IllegalArgumentException {@inheritDoc} - */ - public int drainTo(Collection c) { - if (c == null) - throw new NullPointerException(); - if (c == this) - throw new IllegalArgumentException(); - final E[] items = this.items; - final ReentrantLock lock = this.lock; - lock.lock(); - try { - int i = takeIndex; - int n = 0; - int max = count; - while (n < max) { - c.add(items[i]); - items[i] = null; - i = inc(i); - ++n; - } - if (n > 0) { - count = 0; - putIndex = 0; - takeIndex = 0; - notFull.signalAll(); - } - return n; - } finally { - lock.unlock(); - } - } - - /** - * @throws UnsupportedOperationException {@inheritDoc} - * @throws ClassCastException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - * @throws IllegalArgumentException {@inheritDoc} - */ - public int drainTo(Collection c, int maxElements) { - if (c == null) - throw new NullPointerException(); - if (c == this) - throw new IllegalArgumentException(); - if (maxElements <= 0) - return 0; - final E[] items = this.items; - final ReentrantLock lock = this.lock; - lock.lock(); - try { - int i = takeIndex; - int n = 0; - int sz = count; - int max = (maxElements < count)? maxElements : count; - while (n < max) { - c.add(items[i]); - items[i] = null; - i = inc(i); - ++n; - } - if (n > 0) { - count -= n; - takeIndex = i; - notFull.signalAll(); - } - return n; - } finally { - lock.unlock(); - } - } - - - /** - * Returns an iterator over the elements in this queue in proper sequence. - * The returned Iterator is a "weakly consistent" iterator that - * will never throw {@link ConcurrentModificationException}, - * and guarantees to traverse elements as they existed upon - * construction of the iterator, and may (but is not guaranteed to) - * reflect any modifications subsequent to construction. - * - * @return an iterator over the elements in this queue in proper sequence - */ - public Iterator iterator() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return new Itr(); - } finally { - lock.unlock(); - } - } - - /** - * Iterator for ArrayBlockingQueue - */ - private class Itr implements Iterator { - /** - * Index of element to be returned by next, - * or a negative number if no such. - */ - private int nextIndex; - - /** - * nextItem holds on to item fields because once we claim - * that an element exists in hasNext(), we must return it in - * the following next() call even if it was in the process of - * being removed when hasNext() was called. - */ - private E nextItem; - - /** - * Index of element returned by most recent call to next. - * Reset to -1 if this element is deleted by a call to remove. - */ - private int lastRet; - - Itr() { - lastRet = -1; - if (count == 0) - nextIndex = -1; - else { - nextIndex = takeIndex; - nextItem = items[takeIndex]; - } - } - - public boolean hasNext() { - /* - * No sync. We can return true by mistake here - * only if this iterator passed across threads, - * which we don't support anyway. - */ - return nextIndex >= 0; - } - - /** - * Checks whether nextIndex is valid; if so setting nextItem. - * Stops iterator when either hits putIndex or sees null item. - */ - private void checkNext() { - if (nextIndex == putIndex) { - nextIndex = -1; - nextItem = null; - } else { - nextItem = items[nextIndex]; - if (nextItem == null) - nextIndex = -1; - } - } - - public E next() { - final ReentrantLock lock = ArrayBlockingQueue.this.lock; - lock.lock(); - try { - if (nextIndex < 0) - throw new NoSuchElementException(); - lastRet = nextIndex; - E x = nextItem; - nextIndex = inc(nextIndex); - checkNext(); - return x; - } finally { - lock.unlock(); - } - } - - public void remove() { - final ReentrantLock lock = ArrayBlockingQueue.this.lock; - lock.lock(); - try { - int i = lastRet; - if (i == -1) - throw new IllegalStateException(); - lastRet = -1; - - int ti = takeIndex; - removeAt(i); - // back up cursor (reset to front if was first element) - nextIndex = (i == ti) ? takeIndex : i; - checkNext(); - } finally { - lock.unlock(); - } - } - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/BlockingQueue.java b/libcore/concurrent/src/main/java/java/util/concurrent/BlockingQueue.java deleted file mode 100644 index d01c097f5..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/BlockingQueue.java +++ /dev/null @@ -1,344 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; - -import java.util.Collection; -import java.util.Queue; - -// BEGIN android-note -// removed link to collections framework docs -// END android-note - -/** - * A {@link java.util.Queue} that additionally supports operations - * that wait for the queue to become non-empty when retrieving an - * element, and wait for space to become available in the queue when - * storing an element. - * - *

BlockingQueue methods come in four forms, with different ways - * of handling operations that cannot be satisfied immediately, but may be - * satisfied at some point in the future: - * one throws an exception, the second returns a special value (either - * null or false, depending on the operation), the third - * blocks the current thread indefinitely until the operation can succeed, - * and the fourth blocks for only a given maximum time limit before giving - * up. These methods are summarized in the following table: - * - *

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Throws exceptionSpecial valueBlocksTimes out
Insert{@link #add add(e)}{@link #offer offer(e)}{@link #put put(e)}{@link #offer offer(e, time, unit)}
Remove{@link #remove remove()}{@link #poll poll()}{@link #take take()}{@link #poll(long, TimeUnit) poll(time, unit)}
Examine{@link #element element()}{@link #peek peek()}not applicablenot applicable
- * - *

A BlockingQueue does not accept null elements. - * Implementations throw NullPointerException on attempts - * to add, put or offer a null. A - * null is used as a sentinel value to indicate failure of - * poll operations. - * - *

A BlockingQueue may be capacity bounded. At any given - * time it may have a remainingCapacity beyond which no - * additional elements can be put without blocking. - * A BlockingQueue without any intrinsic capacity constraints always - * reports a remaining capacity of Integer.MAX_VALUE. - * - *

BlockingQueue implementations are designed to be used - * primarily for producer-consumer queues, but additionally support - * the {@link java.util.Collection} interface. So, for example, it is - * possible to remove an arbitrary element from a queue using - * remove(x). However, such operations are in general - * not performed very efficiently, and are intended for only - * occasional use, such as when a queued message is cancelled. - * - *

BlockingQueue implementations are thread-safe. All - * queuing methods achieve their effects atomically using internal - * locks or other forms of concurrency control. However, the - * bulk Collection operations addAll, - * containsAll, retainAll and removeAll are - * not necessarily performed atomically unless specified - * otherwise in an implementation. So it is possible, for example, for - * addAll(c) to fail (throwing an exception) after adding - * only some of the elements in c. - * - *

A BlockingQueue does not intrinsically support - * any kind of "close" or "shutdown" operation to - * indicate that no more items will be added. The needs and usage of - * such features tend to be implementation-dependent. For example, a - * common tactic is for producers to insert special - * end-of-stream or poison objects, that are - * interpreted accordingly when taken by consumers. - * - *

- * Usage example, based on a typical producer-consumer scenario. - * Note that a BlockingQueue can safely be used with multiple - * producers and multiple consumers. - *

- * class Producer implements Runnable {
- *   private final BlockingQueue queue;
- *   Producer(BlockingQueue q) { queue = q; }
- *   public void run() {
- *     try {
- *       while (true) { queue.put(produce()); }
- *     } catch (InterruptedException ex) { ... handle ...}
- *   }
- *   Object produce() { ... }
- * }
- *
- * class Consumer implements Runnable {
- *   private final BlockingQueue queue;
- *   Consumer(BlockingQueue q) { queue = q; }
- *   public void run() {
- *     try {
- *       while (true) { consume(queue.take()); }
- *     } catch (InterruptedException ex) { ... handle ...}
- *   }
- *   void consume(Object x) { ... }
- * }
- *
- * class Setup {
- *   void main() {
- *     BlockingQueue q = new SomeQueueImplementation();
- *     Producer p = new Producer(q);
- *     Consumer c1 = new Consumer(q);
- *     Consumer c2 = new Consumer(q);
- *     new Thread(p).start();
- *     new Thread(c1).start();
- *     new Thread(c2).start();
- *   }
- * }
- * 
- * - *

Memory consistency effects: As with other concurrent - * collections, actions in a thread prior to placing an object into a - * {@code BlockingQueue} - * happen-before - * actions subsequent to the access or removal of that element from - * the {@code BlockingQueue} in another thread. - * - * @since 1.5 - * @author Doug Lea - * @param the type of elements held in this collection - */ -public interface BlockingQueue extends Queue { - /** - * Inserts the specified element into this queue if it is possible to do - * so immediately without violating capacity restrictions, returning - * true upon success and throwing an - * IllegalStateException if no space is currently available. - * When using a capacity-restricted queue, it is generally preferable to - * use {@link #offer offer}. - * - * @param e the element to add - * @return true (as specified by {@link Collection#add}) - * @throws IllegalStateException if the element cannot be added at this - * time due to capacity restrictions - * @throws ClassCastException if the class of the specified element - * prevents it from being added to this queue - * @throws NullPointerException if the specified element is null - * @throws IllegalArgumentException if some property of the specified - * element prevents it from being added to this queue - */ - boolean add(E e); - - /** - * Inserts the specified element into this queue if it is possible to do - * so immediately without violating capacity restrictions, returning - * true upon success and false if no space is currently - * available. When using a capacity-restricted queue, this method is - * generally preferable to {@link #add}, which can fail to insert an - * element only by throwing an exception. - * - * @param e the element to add - * @return true if the element was added to this queue, else - * false - * @throws ClassCastException if the class of the specified element - * prevents it from being added to this queue - * @throws NullPointerException if the specified element is null - * @throws IllegalArgumentException if some property of the specified - * element prevents it from being added to this queue - */ - boolean offer(E e); - - /** - * Inserts the specified element into this queue, waiting if necessary - * for space to become available. - * - * @param e the element to add - * @throws InterruptedException if interrupted while waiting - * @throws ClassCastException if the class of the specified element - * prevents it from being added to this queue - * @throws NullPointerException if the specified element is null - * @throws IllegalArgumentException if some property of the specified - * element prevents it from being added to this queue - */ - void put(E e) throws InterruptedException; - - /** - * Inserts the specified element into this queue, waiting up to the - * specified wait time if necessary for space to become available. - * - * @param e the element to add - * @param timeout how long to wait before giving up, in units of - * unit - * @param unit a TimeUnit determining how to interpret the - * timeout parameter - * @return true if successful, or false if - * the specified waiting time elapses before space is available - * @throws InterruptedException if interrupted while waiting - * @throws ClassCastException if the class of the specified element - * prevents it from being added to this queue - * @throws NullPointerException if the specified element is null - * @throws IllegalArgumentException if some property of the specified - * element prevents it from being added to this queue - */ - boolean offer(E e, long timeout, TimeUnit unit) - throws InterruptedException; - - /** - * Retrieves and removes the head of this queue, waiting if necessary - * until an element becomes available. - * - * @return the head of this queue - * @throws InterruptedException if interrupted while waiting - */ - E take() throws InterruptedException; - - /** - * Retrieves and removes the head of this queue, waiting up to the - * specified wait time if necessary for an element to become available. - * - * @param timeout how long to wait before giving up, in units of - * unit - * @param unit a TimeUnit determining how to interpret the - * timeout parameter - * @return the head of this queue, or null if the - * specified waiting time elapses before an element is available - * @throws InterruptedException if interrupted while waiting - */ - E poll(long timeout, TimeUnit unit) - throws InterruptedException; - - /** - * Returns the number of additional elements that this queue can ideally - * (in the absence of memory or resource constraints) accept without - * blocking, or Integer.MAX_VALUE if there is no intrinsic - * limit. - * - *

Note that you cannot always tell if an attempt to insert - * an element will succeed by inspecting remainingCapacity - * because it may be the case that another thread is about to - * insert or remove an element. - * - * @return the remaining capacity - */ - int remainingCapacity(); - - /** - * Removes a single instance of the specified element from this queue, - * if it is present. More formally, removes an element e such - * that o.equals(e), if this queue contains one or more such - * elements. - * Returns true if this queue contained the specified element - * (or equivalently, if this queue changed as a result of the call). - * - * @param o element to be removed from this queue, if present - * @return true if this queue changed as a result of the call - * @throws ClassCastException if the class of the specified element - * is incompatible with this queue (optional) - * @throws NullPointerException if the specified element is null (optional) - */ - boolean remove(Object o); - - /** - * Returns true if this queue contains the specified element. - * More formally, returns true if and only if this queue contains - * at least one element e such that o.equals(e). - * - * @param o object to be checked for containment in this queue - * @return true if this queue contains the specified element - * @throws ClassCastException if the class of the specified element - * is incompatible with this queue (optional) - * @throws NullPointerException if the specified element is null (optional) - */ - public boolean contains(Object o); - - /** - * Removes all available elements from this queue and adds them - * to the given collection. This operation may be more - * efficient than repeatedly polling this queue. A failure - * encountered while attempting to add elements to - * collection c may result in elements being in neither, - * either or both collections when the associated exception is - * thrown. Attempts to drain a queue to itself result in - * IllegalArgumentException. Further, the behavior of - * this operation is undefined if the specified collection is - * modified while the operation is in progress. - * - * @param c the collection to transfer elements into - * @return the number of elements transferred - * @throws UnsupportedOperationException if addition of elements - * is not supported by the specified collection - * @throws ClassCastException if the class of an element of this queue - * prevents it from being added to the specified collection - * @throws NullPointerException if the specified collection is null - * @throws IllegalArgumentException if the specified collection is this - * queue, or some property of an element of this queue prevents - * it from being added to the specified collection - */ - int drainTo(Collection c); - - /** - * Removes at most the given number of available elements from - * this queue and adds them to the given collection. A failure - * encountered while attempting to add elements to - * collection c may result in elements being in neither, - * either or both collections when the associated exception is - * thrown. Attempts to drain a queue to itself result in - * IllegalArgumentException. Further, the behavior of - * this operation is undefined if the specified collection is - * modified while the operation is in progress. - * - * @param c the collection to transfer elements into - * @param maxElements the maximum number of elements to transfer - * @return the number of elements transferred - * @throws UnsupportedOperationException if addition of elements - * is not supported by the specified collection - * @throws ClassCastException if the class of an element of this queue - * prevents it from being added to the specified collection - * @throws NullPointerException if the specified collection is null - * @throws IllegalArgumentException if the specified collection is this - * queue, or some property of an element of this queue prevents - * it from being added to the specified collection - */ - int drainTo(Collection c, int maxElements); -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/BrokenBarrierException.java b/libcore/concurrent/src/main/java/java/util/concurrent/BrokenBarrierException.java deleted file mode 100644 index 3f93fbb9d..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/BrokenBarrierException.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; - -/** - * Exception thrown when a thread tries to wait upon a barrier that is - * in a broken state, or which enters the broken state while the thread - * is waiting. - * - * @see CyclicBarrier - * - * @since 1.5 - * @author Doug Lea - * - */ -public class BrokenBarrierException extends Exception { - private static final long serialVersionUID = 7117394618823254244L; - - /** - * Constructs a BrokenBarrierException with no specified detail - * message. - */ - public BrokenBarrierException() {} - - /** - * Constructs a BrokenBarrierException with the specified - * detail message. - * - * @param message the detail message - */ - public BrokenBarrierException(String message) { - super(message); - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/Callable.java b/libcore/concurrent/src/main/java/java/util/concurrent/Callable.java deleted file mode 100644 index abc4d0407..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/Callable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; - -/** - * A task that returns a result and may throw an exception. - * Implementors define a single method with no arguments called - * call. - * - *

The Callable interface is similar to {@link - * java.lang.Runnable}, in that both are designed for classes whose - * instances are potentially executed by another thread. A - * Runnable, however, does not return a result and cannot - * throw a checked exception. - * - *

The {@link Executors} class contains utility methods to - * convert from other common forms to Callable classes. - * - * @see Executor - * @since 1.5 - * @author Doug Lea - * @param the result type of method call - */ -public interface Callable { - /** - * Computes a result, or throws an exception if unable to do so. - * - * @return computed result - * @throws Exception if unable to compute a result - */ - V call() throws Exception; -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/CancellationException.java b/libcore/concurrent/src/main/java/java/util/concurrent/CancellationException.java deleted file mode 100644 index 2c29544a0..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/CancellationException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; - -/** - * Exception indicating that the result of a value-producing task, - * such as a {@link FutureTask}, cannot be retrieved because the task - * was cancelled. - * - * @since 1.5 - * @author Doug Lea - */ -public class CancellationException extends IllegalStateException { - private static final long serialVersionUID = -9202173006928992231L; - - /** - * Constructs a CancellationException with no detail message. - */ - public CancellationException() {} - - /** - * Constructs a CancellationException with the specified detail - * message. - * - * @param message the detail message - */ - public CancellationException(String message) { - super(message); - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/CompletionService.java b/libcore/concurrent/src/main/java/java/util/concurrent/CompletionService.java deleted file mode 100644 index df9f719c4..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/CompletionService.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; - -/** - * A service that decouples the production of new asynchronous tasks - * from the consumption of the results of completed tasks. Producers - * submit tasks for execution. Consumers take - * completed tasks and process their results in the order they - * complete. A CompletionService can for example be used to - * manage asynchronous IO, in which tasks that perform reads are - * submitted in one part of a program or system, and then acted upon - * in a different part of the program when the reads complete, - * possibly in a different order than they were requested. - * - *

Typically, a CompletionService relies on a separate - * {@link Executor} to actually execute the tasks, in which case the - * CompletionService only manages an internal completion - * queue. The {@link ExecutorCompletionService} class provides an - * implementation of this approach. - * - *

Memory consistency effects: Actions in a thread prior to - * submitting a task to a {@code CompletionService} - * happen-before - * actions taken by that task, which in turn happen-before - * actions following a successful return from the corresponding {@code take()}. - * - */ -public interface CompletionService { - /** - * Submits a value-returning task for execution and returns a Future - * representing the pending results of the task. Upon completion, - * this task may be taken or polled. - * - * @param task the task to submit - * @return a Future representing pending completion of the task - * @throws RejectedExecutionException if the task cannot be - * scheduled for execution - * @throws NullPointerException if the task is null - */ - Future submit(Callable task); - - /** - * Submits a Runnable task for execution and returns a Future - * representing that task. Upon completion, this task may be - * taken or polled. - * - * @param task the task to submit - * @param result the result to return upon successful completion - * @return a Future representing pending completion of the task, - * and whose get() method will return the given - * result value upon completion - * @throws RejectedExecutionException if the task cannot be - * scheduled for execution - * @throws NullPointerException if the task is null - */ - Future submit(Runnable task, V result); - - /** - * Retrieves and removes the Future representing the next - * completed task, waiting if none are yet present. - * - * @return the Future representing the next completed task - * @throws InterruptedException if interrupted while waiting - */ - Future take() throws InterruptedException; - - - /** - * Retrieves and removes the Future representing the next - * completed task or null if none are present. - * - * @return the Future representing the next completed task, or - * null if none are present - */ - Future poll(); - - /** - * Retrieves and removes the Future representing the next - * completed task, waiting if necessary up to the specified wait - * time if none are yet present. - * - * @param timeout how long to wait before giving up, in units of - * unit - * @param unit a TimeUnit determining how to interpret the - * timeout parameter - * @return the Future representing the next completed task or - * null if the specified waiting time elapses - * before one is present - * @throws InterruptedException if interrupted while waiting - */ - Future poll(long timeout, TimeUnit unit) throws InterruptedException; -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/ConcurrentHashMap.java b/libcore/concurrent/src/main/java/java/util/concurrent/ConcurrentHashMap.java deleted file mode 100644 index cb5fb3f0d..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/ConcurrentHashMap.java +++ /dev/null @@ -1,1324 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; -import java.util.concurrent.locks.*; -import java.util.*; -import java.io.Serializable; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; - -// BEGIN android-note -// removed link to collections framework docs -// END android-note - -/** - * A hash table supporting full concurrency of retrievals and - * adjustable expected concurrency for updates. This class obeys the - * same functional specification as {@link java.util.Hashtable}, and - * includes versions of methods corresponding to each method of - * Hashtable. However, even though all operations are - * thread-safe, retrieval operations do not entail locking, - * and there is not any support for locking the entire table - * in a way that prevents all access. This class is fully - * interoperable with Hashtable in programs that rely on its - * thread safety but not on its synchronization details. - * - *

Retrieval operations (including get) generally do not - * block, so may overlap with update operations (including - * put and remove). Retrievals reflect the results - * of the most recently completed update operations holding - * upon their onset. For aggregate operations such as putAll - * and clear, concurrent retrievals may reflect insertion or - * removal of only some entries. Similarly, Iterators and - * Enumerations return elements reflecting the state of the hash table - * at some point at or since the creation of the iterator/enumeration. - * They do not throw {@link ConcurrentModificationException}. - * However, iterators are designed to be used by only one thread at a time. - * - *

The allowed concurrency among update operations is guided by - * the optional concurrencyLevel constructor argument - * (default 16), which is used as a hint for internal sizing. The - * table is internally partitioned to try to permit the indicated - * number of concurrent updates without contention. Because placement - * in hash tables is essentially random, the actual concurrency will - * vary. Ideally, you should choose a value to accommodate as many - * threads as will ever concurrently modify the table. Using a - * significantly higher value than you need can waste space and time, - * and a significantly lower value can lead to thread contention. But - * overestimates and underestimates within an order of magnitude do - * not usually have much noticeable impact. A value of one is - * appropriate when it is known that only one thread will modify and - * all others will only read. Also, resizing this or any other kind of - * hash table is a relatively slow operation, so, when possible, it is - * a good idea to provide estimates of expected table sizes in - * constructors. - * - *

This class and its views and iterators implement all of the - * optional methods of the {@link Map} and {@link Iterator} - * interfaces. - * - *

Like {@link Hashtable} but unlike {@link HashMap}, this class - * does not allow null to be used as a key or value. - * - * @since 1.5 - * @author Doug Lea - * @param the type of keys maintained by this map - * @param the type of mapped values - */ -public class ConcurrentHashMap extends AbstractMap - implements ConcurrentMap, Serializable { - private static final long serialVersionUID = 7249069246763182397L; - - /* - * The basic strategy is to subdivide the table among Segments, - * each of which itself is a concurrently readable hash table. - */ - - /* ---------------- Constants -------------- */ - - /** - * The default initial capacity for this table, - * used when not otherwise specified in a constructor. - */ - static final int DEFAULT_INITIAL_CAPACITY = 16; - - /** - * The default load factor for this table, used when not - * otherwise specified in a constructor. - */ - static final float DEFAULT_LOAD_FACTOR = 0.75f; - - /** - * The default concurrency level for this table, used when not - * otherwise specified in a constructor. - */ - static final int DEFAULT_CONCURRENCY_LEVEL = 16; - - /** - * The maximum capacity, used if a higher value is implicitly - * specified by either of the constructors with arguments. MUST - * be a power of two <= 1<<30 to ensure that entries are indexable - * using ints. - */ - static final int MAXIMUM_CAPACITY = 1 << 30; - - /** - * The maximum number of segments to allow; used to bound - * constructor arguments. - */ - static final int MAX_SEGMENTS = 1 << 16; // slightly conservative - - /** - * Number of unsynchronized retries in size and containsValue - * methods before resorting to locking. This is used to avoid - * unbounded retries if tables undergo continuous modification - * which would make it impossible to obtain an accurate result. - */ - static final int RETRIES_BEFORE_LOCK = 2; - - /* ---------------- Fields -------------- */ - - /** - * Mask value for indexing into segments. The upper bits of a - * key's hash code are used to choose the segment. - */ - final int segmentMask; - - /** - * Shift value for indexing within segments. - */ - final int segmentShift; - - /** - * The segments, each of which is a specialized hash table - */ - final Segment[] segments; - - transient Set keySet; - transient Set> entrySet; - transient Collection values; - - /* ---------------- Small Utilities -------------- */ - - /** - * Applies a supplemental hash function to a given hashCode, which - * defends against poor quality hash functions. This is critical - * because ConcurrentHashMap uses power-of-two length hash tables, - * that otherwise encounter collisions for hashCodes that do not - * differ in lower or upper bits. - */ - private static int hash(int h) { - // Spread bits to regularize both segment and index locations, - // using variant of single-word Wang/Jenkins hash. - h += (h << 15) ^ 0xffffcd7d; - h ^= (h >>> 10); - h += (h << 3); - h ^= (h >>> 6); - h += (h << 2) + (h << 14); - return h ^ (h >>> 16); - } - - /** - * Returns the segment that should be used for key with given hash - * @param hash the hash code for the key - * @return the segment - */ - final Segment segmentFor(int hash) { - return segments[(hash >>> segmentShift) & segmentMask]; - } - - /* ---------------- Inner Classes -------------- */ - - /** - * ConcurrentHashMap list entry. Note that this is never exported - * out as a user-visible Map.Entry. - * - * Because the value field is volatile, not final, it is legal wrt - * the Java Memory Model for an unsynchronized reader to see null - * instead of initial value when read via a data race. Although a - * reordering leading to this is not likely to ever actually - * occur, the Segment.readValueUnderLock method is used as a - * backup in case a null (pre-initialized) value is ever seen in - * an unsynchronized access method. - */ - static final class HashEntry { - final K key; - final int hash; - volatile V value; - final HashEntry next; - - HashEntry(K key, int hash, HashEntry next, V value) { - this.key = key; - this.hash = hash; - this.next = next; - this.value = value; - } - - @SuppressWarnings("unchecked") - static final HashEntry[] newArray(int i) { - return new HashEntry[i]; - } - } - - /** - * Segments are specialized versions of hash tables. This - * subclasses from ReentrantLock opportunistically, just to - * simplify some locking and avoid separate construction. - */ - static final class Segment extends ReentrantLock implements Serializable { - /* - * Segments maintain a table of entry lists that are ALWAYS - * kept in a consistent state, so can be read without locking. - * Next fields of nodes are immutable (final). All list - * additions are performed at the front of each bin. This - * makes it easy to check changes, and also fast to traverse. - * When nodes would otherwise be changed, new nodes are - * created to replace them. This works well for hash tables - * since the bin lists tend to be short. (The average length - * is less than two for the default load factor threshold.) - * - * Read operations can thus proceed without locking, but rely - * on selected uses of volatiles to ensure that completed - * write operations performed by other threads are - * noticed. For most purposes, the "count" field, tracking the - * number of elements, serves as that volatile variable - * ensuring visibility. This is convenient because this field - * needs to be read in many read operations anyway: - * - * - All (unsynchronized) read operations must first read the - * "count" field, and should not look at table entries if - * it is 0. - * - * - All (synchronized) write operations should write to - * the "count" field after structurally changing any bin. - * The operations must not take any action that could even - * momentarily cause a concurrent read operation to see - * inconsistent data. This is made easier by the nature of - * the read operations in Map. For example, no operation - * can reveal that the table has grown but the threshold - * has not yet been updated, so there are no atomicity - * requirements for this with respect to reads. - * - * As a guide, all critical volatile reads and writes to the - * count field are marked in code comments. - */ - - private static final long serialVersionUID = 2249069246763182397L; - - /** - * The number of elements in this segment's region. - */ - transient volatile int count; - - /** - * Number of updates that alter the size of the table. This is - * used during bulk-read methods to make sure they see a - * consistent snapshot: If modCounts change during a traversal - * of segments computing size or checking containsValue, then - * we might have an inconsistent view of state so (usually) - * must retry. - */ - transient int modCount; - - /** - * The table is rehashed when its size exceeds this threshold. - * (The value of this field is always (int)(capacity * - * loadFactor).) - */ - transient int threshold; - - /** - * The per-segment table. - */ - transient volatile HashEntry[] table; - - /** - * The load factor for the hash table. Even though this value - * is same for all segments, it is replicated to avoid needing - * links to outer object. - * @serial - */ - final float loadFactor; - - Segment(int initialCapacity, float lf) { - loadFactor = lf; - setTable(HashEntry.newArray(initialCapacity)); - } - - @SuppressWarnings("unchecked") - static final Segment[] newArray(int i) { - return new Segment[i]; - } - - /** - * Sets table to new HashEntry array. - * Call only while holding lock or in constructor. - */ - void setTable(HashEntry[] newTable) { - threshold = (int)(newTable.length * loadFactor); - table = newTable; - } - - /** - * Returns properly casted first entry of bin for given hash. - */ - HashEntry getFirst(int hash) { - HashEntry[] tab = table; - return tab[hash & (tab.length - 1)]; - } - - /** - * Reads value field of an entry under lock. Called if value - * field ever appears to be null. This is possible only if a - * compiler happens to reorder a HashEntry initialization with - * its table assignment, which is legal under memory model - * but is not known to ever occur. - */ - V readValueUnderLock(HashEntry e) { - lock(); - try { - return e.value; - } finally { - unlock(); - } - } - - /* Specialized implementations of map methods */ - - V get(Object key, int hash) { - if (count != 0) { // read-volatile - HashEntry e = getFirst(hash); - while (e != null) { - if (e.hash == hash && key.equals(e.key)) { - V v = e.value; - if (v != null) - return v; - return readValueUnderLock(e); // recheck - } - e = e.next; - } - } - return null; - } - - boolean containsKey(Object key, int hash) { - if (count != 0) { // read-volatile - HashEntry e = getFirst(hash); - while (e != null) { - if (e.hash == hash && key.equals(e.key)) - return true; - e = e.next; - } - } - return false; - } - - boolean containsValue(Object value) { - if (count != 0) { // read-volatile - HashEntry[] tab = table; - int len = tab.length; - for (int i = 0 ; i < len; i++) { - for (HashEntry e = tab[i]; e != null; e = e.next) { - V v = e.value; - if (v == null) // recheck - v = readValueUnderLock(e); - if (value.equals(v)) - return true; - } - } - } - return false; - } - - boolean replace(K key, int hash, V oldValue, V newValue) { - lock(); - try { - HashEntry e = getFirst(hash); - while (e != null && (e.hash != hash || !key.equals(e.key))) - e = e.next; - - boolean replaced = false; - if (e != null && oldValue.equals(e.value)) { - replaced = true; - e.value = newValue; - } - return replaced; - } finally { - unlock(); - } - } - - V replace(K key, int hash, V newValue) { - lock(); - try { - HashEntry e = getFirst(hash); - while (e != null && (e.hash != hash || !key.equals(e.key))) - e = e.next; - - V oldValue = null; - if (e != null) { - oldValue = e.value; - e.value = newValue; - } - return oldValue; - } finally { - unlock(); - } - } - - - V put(K key, int hash, V value, boolean onlyIfAbsent) { - lock(); - try { - int c = count; - if (c++ > threshold) // ensure capacity - rehash(); - HashEntry[] tab = table; - int index = hash & (tab.length - 1); - HashEntry first = tab[index]; - HashEntry e = first; - while (e != null && (e.hash != hash || !key.equals(e.key))) - e = e.next; - - V oldValue; - if (e != null) { - oldValue = e.value; - if (!onlyIfAbsent) - e.value = value; - } - else { - oldValue = null; - ++modCount; - tab[index] = new HashEntry(key, hash, first, value); - count = c; // write-volatile - } - return oldValue; - } finally { - unlock(); - } - } - - void rehash() { - HashEntry[] oldTable = table; - int oldCapacity = oldTable.length; - if (oldCapacity >= MAXIMUM_CAPACITY) - return; - - /* - * Reclassify nodes in each list to new Map. Because we are - * using power-of-two expansion, the elements from each bin - * must either stay at same index, or move with a power of two - * offset. We eliminate unnecessary node creation by catching - * cases where old nodes can be reused because their next - * fields won't change. Statistically, at the default - * threshold, only about one-sixth of them need cloning when - * a table doubles. The nodes they replace will be garbage - * collectable as soon as they are no longer referenced by any - * reader thread that may be in the midst of traversing table - * right now. - */ - - HashEntry[] newTable = HashEntry.newArray(oldCapacity<<1); - threshold = (int)(newTable.length * loadFactor); - int sizeMask = newTable.length - 1; - for (int i = 0; i < oldCapacity ; i++) { - // We need to guarantee that any existing reads of old Map can - // proceed. So we cannot yet null out each bin. - HashEntry e = oldTable[i]; - - if (e != null) { - HashEntry next = e.next; - int idx = e.hash & sizeMask; - - // Single node on list - if (next == null) - newTable[idx] = e; - - else { - // Reuse trailing consecutive sequence at same slot - HashEntry lastRun = e; - int lastIdx = idx; - for (HashEntry last = next; - last != null; - last = last.next) { - int k = last.hash & sizeMask; - if (k != lastIdx) { - lastIdx = k; - lastRun = last; - } - } - newTable[lastIdx] = lastRun; - - // Clone all remaining nodes - for (HashEntry p = e; p != lastRun; p = p.next) { - int k = p.hash & sizeMask; - HashEntry n = newTable[k]; - newTable[k] = new HashEntry(p.key, p.hash, - n, p.value); - } - } - } - } - table = newTable; - } - - /** - * Remove; match on key only if value null, else match both. - */ - V remove(Object key, int hash, Object value) { - lock(); - try { - int c = count - 1; - HashEntry[] tab = table; - int index = hash & (tab.length - 1); - HashEntry first = tab[index]; - HashEntry e = first; - while (e != null && (e.hash != hash || !key.equals(e.key))) - e = e.next; - - V oldValue = null; - if (e != null) { - V v = e.value; - if (value == null || value.equals(v)) { - oldValue = v; - // All entries following removed node can stay - // in list, but all preceding ones need to be - // cloned. - ++modCount; - HashEntry newFirst = e.next; - for (HashEntry p = first; p != e; p = p.next) - newFirst = new HashEntry(p.key, p.hash, - newFirst, p.value); - tab[index] = newFirst; - count = c; // write-volatile - } - } - return oldValue; - } finally { - unlock(); - } - } - - void clear() { - if (count != 0) { - lock(); - try { - HashEntry[] tab = table; - for (int i = 0; i < tab.length ; i++) - tab[i] = null; - ++modCount; - count = 0; // write-volatile - } finally { - unlock(); - } - } - } - } - - - - /* ---------------- Public operations -------------- */ - - /** - * Creates a new, empty map with the specified initial - * capacity, load factor and concurrency level. - * - * @param initialCapacity the initial capacity. The implementation - * performs internal sizing to accommodate this many elements. - * @param loadFactor the load factor threshold, used to control resizing. - * Resizing may be performed when the average number of elements per - * bin exceeds this threshold. - * @param concurrencyLevel the estimated number of concurrently - * updating threads. The implementation performs internal sizing - * to try to accommodate this many threads. - * @throws IllegalArgumentException if the initial capacity is - * negative or the load factor or concurrencyLevel are - * nonpositive. - */ - public ConcurrentHashMap(int initialCapacity, - float loadFactor, int concurrencyLevel) { - if (!(loadFactor > 0) || initialCapacity < 0 || concurrencyLevel <= 0) - throw new IllegalArgumentException(); - - if (concurrencyLevel > MAX_SEGMENTS) - concurrencyLevel = MAX_SEGMENTS; - - // Find power-of-two sizes best matching arguments - int sshift = 0; - int ssize = 1; - while (ssize < concurrencyLevel) { - ++sshift; - ssize <<= 1; - } - segmentShift = 32 - sshift; - segmentMask = ssize - 1; - this.segments = Segment.newArray(ssize); - - if (initialCapacity > MAXIMUM_CAPACITY) - initialCapacity = MAXIMUM_CAPACITY; - int c = initialCapacity / ssize; - if (c * ssize < initialCapacity) - ++c; - int cap = 1; - while (cap < c) - cap <<= 1; - - for (int i = 0; i < this.segments.length; ++i) - this.segments[i] = new Segment(cap, loadFactor); - } - - /** - * Creates a new, empty map with the specified initial capacity, - * and with default load factor (0.75) and concurrencyLevel (16). - * - * @param initialCapacity the initial capacity. The implementation - * performs internal sizing to accommodate this many elements. - * @throws IllegalArgumentException if the initial capacity of - * elements is negative. - */ - public ConcurrentHashMap(int initialCapacity) { - this(initialCapacity, DEFAULT_LOAD_FACTOR, DEFAULT_CONCURRENCY_LEVEL); - } - - /** - * Creates a new, empty map with a default initial capacity (16), - * load factor (0.75) and concurrencyLevel (16). - */ - public ConcurrentHashMap() { - this(DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR, DEFAULT_CONCURRENCY_LEVEL); - } - - /** - * Creates a new map with the same mappings as the given map. - * The map is created with a capacity of 1.5 times the number - * of mappings in the given map or 16 (whichever is greater), - * and a default load factor (0.75) and concurrencyLevel (16). - * - * @param m the map - */ - public ConcurrentHashMap(Map m) { - this(Math.max((int) (m.size() / DEFAULT_LOAD_FACTOR) + 1, - DEFAULT_INITIAL_CAPACITY), - DEFAULT_LOAD_FACTOR, DEFAULT_CONCURRENCY_LEVEL); - putAll(m); - } - - /** - * Returns true if this map contains no key-value mappings. - * - * @return true if this map contains no key-value mappings - */ - public boolean isEmpty() { - final Segment[] segments = this.segments; - /* - * We keep track of per-segment modCounts to avoid ABA - * problems in which an element in one segment was added and - * in another removed during traversal, in which case the - * table was never actually empty at any point. Note the - * similar use of modCounts in the size() and containsValue() - * methods, which are the only other methods also susceptible - * to ABA problems. - */ - int[] mc = new int[segments.length]; - int mcsum = 0; - for (int i = 0; i < segments.length; ++i) { - if (segments[i].count != 0) - return false; - else - mcsum += mc[i] = segments[i].modCount; - } - // If mcsum happens to be zero, then we know we got a snapshot - // before any modifications at all were made. This is - // probably common enough to bother tracking. - if (mcsum != 0) { - for (int i = 0; i < segments.length; ++i) { - if (segments[i].count != 0 || - mc[i] != segments[i].modCount) - return false; - } - } - return true; - } - - /** - * Returns the number of key-value mappings in this map. If the - * map contains more than Integer.MAX_VALUE elements, returns - * Integer.MAX_VALUE. - * - * @return the number of key-value mappings in this map - */ - public int size() { - final Segment[] segments = this.segments; - long sum = 0; - long check = 0; - int[] mc = new int[segments.length]; - // Try a few times to get accurate count. On failure due to - // continuous async changes in table, resort to locking. - for (int k = 0; k < RETRIES_BEFORE_LOCK; ++k) { - check = 0; - sum = 0; - int mcsum = 0; - for (int i = 0; i < segments.length; ++i) { - sum += segments[i].count; - mcsum += mc[i] = segments[i].modCount; - } - if (mcsum != 0) { - for (int i = 0; i < segments.length; ++i) { - check += segments[i].count; - if (mc[i] != segments[i].modCount) { - check = -1; // force retry - break; - } - } - } - if (check == sum) - break; - } - if (check != sum) { // Resort to locking all segments - sum = 0; - for (int i = 0; i < segments.length; ++i) - segments[i].lock(); - for (int i = 0; i < segments.length; ++i) - sum += segments[i].count; - for (int i = 0; i < segments.length; ++i) - segments[i].unlock(); - } - if (sum > Integer.MAX_VALUE) - return Integer.MAX_VALUE; - else - return (int)sum; - } - - /** - * Returns the value to which the specified key is mapped, - * or {@code null} if this map contains no mapping for the key. - * - *

More formally, if this map contains a mapping from a key - * {@code k} to a value {@code v} such that {@code key.equals(k)}, - * then this method returns {@code v}; otherwise it returns - * {@code null}. (There can be at most one such mapping.) - * - * @throws NullPointerException if the specified key is null - */ - public V get(Object key) { - int hash = hash(key.hashCode()); - return segmentFor(hash).get(key, hash); - } - - /** - * Tests if the specified object is a key in this table. - * - * @param key possible key - * @return true if and only if the specified object - * is a key in this table, as determined by the - * equals method; false otherwise. - * @throws NullPointerException if the specified key is null - */ - public boolean containsKey(Object key) { - int hash = hash(key.hashCode()); - return segmentFor(hash).containsKey(key, hash); - } - - /** - * Returns true if this map maps one or more keys to the - * specified value. Note: This method requires a full internal - * traversal of the hash table, and so is much slower than - * method containsKey. - * - * @param value value whose presence in this map is to be tested - * @return true if this map maps one or more keys to the - * specified value - * @throws NullPointerException if the specified value is null - */ - public boolean containsValue(Object value) { - if (value == null) - throw new NullPointerException(); - - // See explanation of modCount use above - - final Segment[] segments = this.segments; - int[] mc = new int[segments.length]; - - // Try a few times without locking - for (int k = 0; k < RETRIES_BEFORE_LOCK; ++k) { - int sum = 0; - int mcsum = 0; - for (int i = 0; i < segments.length; ++i) { - int c = segments[i].count; - mcsum += mc[i] = segments[i].modCount; - if (segments[i].containsValue(value)) - return true; - } - boolean cleanSweep = true; - if (mcsum != 0) { - for (int i = 0; i < segments.length; ++i) { - int c = segments[i].count; - if (mc[i] != segments[i].modCount) { - cleanSweep = false; - break; - } - } - } - if (cleanSweep) - return false; - } - // Resort to locking all segments - for (int i = 0; i < segments.length; ++i) - segments[i].lock(); - boolean found = false; - try { - for (int i = 0; i < segments.length; ++i) { - if (segments[i].containsValue(value)) { - found = true; - break; - } - } - } finally { - for (int i = 0; i < segments.length; ++i) - segments[i].unlock(); - } - return found; - } - - /** - * Legacy method testing if some key maps into the specified value - * in this table. This method is identical in functionality to - * {@link #containsValue}, and exists solely to ensure - * full compatibility with class {@link java.util.Hashtable}, - * which supported this method prior to introduction of the - * Java Collections framework. - - * @param value a value to search for - * @return true if and only if some key maps to the - * value argument in this table as - * determined by the equals method; - * false otherwise - * @throws NullPointerException if the specified value is null - */ - public boolean contains(Object value) { - return containsValue(value); - } - - /** - * Maps the specified key to the specified value in this table. - * Neither the key nor the value can be null. - * - *

The value can be retrieved by calling the get method - * with a key that is equal to the original key. - * - * @param key key with which the specified value is to be associated - * @param value value to be associated with the specified key - * @return the previous value associated with key, or - * null if there was no mapping for key - * @throws NullPointerException if the specified key or value is null - */ - public V put(K key, V value) { - if (value == null) - throw new NullPointerException(); - int hash = hash(key.hashCode()); - return segmentFor(hash).put(key, hash, value, false); - } - - /** - * {@inheritDoc} - * - * @return the previous value associated with the specified key, - * or null if there was no mapping for the key - * @throws NullPointerException if the specified key or value is null - */ - public V putIfAbsent(K key, V value) { - if (value == null) - throw new NullPointerException(); - int hash = hash(key.hashCode()); - return segmentFor(hash).put(key, hash, value, true); - } - - /** - * Copies all of the mappings from the specified map to this one. - * These mappings replace any mappings that this map had for any of the - * keys currently in the specified map. - * - * @param m mappings to be stored in this map - */ - public void putAll(Map m) { - for (Map.Entry e : m.entrySet()) - put(e.getKey(), e.getValue()); - } - - /** - * Removes the key (and its corresponding value) from this map. - * This method does nothing if the key is not in the map. - * - * @param key the key that needs to be removed - * @return the previous value associated with key, or - * null if there was no mapping for key - * @throws NullPointerException if the specified key is null - */ - public V remove(Object key) { - int hash = hash(key.hashCode()); - return segmentFor(hash).remove(key, hash, null); - } - - /** - * {@inheritDoc} - * - * @throws NullPointerException if the specified key is null - */ - public boolean remove(Object key, Object value) { - int hash = hash(key.hashCode()); - if (value == null) - return false; - return segmentFor(hash).remove(key, hash, value) != null; - } - - /** - * {@inheritDoc} - * - * @throws NullPointerException if any of the arguments are null - */ - public boolean replace(K key, V oldValue, V newValue) { - if (oldValue == null || newValue == null) - throw new NullPointerException(); - int hash = hash(key.hashCode()); - return segmentFor(hash).replace(key, hash, oldValue, newValue); - } - - /** - * {@inheritDoc} - * - * @return the previous value associated with the specified key, - * or null if there was no mapping for the key - * @throws NullPointerException if the specified key or value is null - */ - public V replace(K key, V value) { - if (value == null) - throw new NullPointerException(); - int hash = hash(key.hashCode()); - return segmentFor(hash).replace(key, hash, value); - } - - /** - * Removes all of the mappings from this map. - */ - public void clear() { - for (int i = 0; i < segments.length; ++i) - segments[i].clear(); - } - - /** - * Returns a {@link Set} view of the keys contained in this map. - * The set is backed by the map, so changes to the map are - * reflected in the set, and vice-versa. The set supports element - * removal, which removes the corresponding mapping from this map, - * via the Iterator.remove, Set.remove, - * removeAll, retainAll, and clear - * operations. It does not support the add or - * addAll operations. - * - *

The view's iterator is a "weakly consistent" iterator - * that will never throw {@link ConcurrentModificationException}, - * and guarantees to traverse elements as they existed upon - * construction of the iterator, and may (but is not guaranteed to) - * reflect any modifications subsequent to construction. - */ - public Set keySet() { - Set ks = keySet; - return (ks != null) ? ks : (keySet = new KeySet()); - } - - /** - * Returns a {@link Collection} view of the values contained in this map. - * The collection is backed by the map, so changes to the map are - * reflected in the collection, and vice-versa. The collection - * supports element removal, which removes the corresponding - * mapping from this map, via the Iterator.remove, - * Collection.remove, removeAll, - * retainAll, and clear operations. It does not - * support the add or addAll operations. - * - *

The view's iterator is a "weakly consistent" iterator - * that will never throw {@link ConcurrentModificationException}, - * and guarantees to traverse elements as they existed upon - * construction of the iterator, and may (but is not guaranteed to) - * reflect any modifications subsequent to construction. - */ - public Collection values() { - Collection vs = values; - return (vs != null) ? vs : (values = new Values()); - } - - /** - * Returns a {@link Set} view of the mappings contained in this map. - * The set is backed by the map, so changes to the map are - * reflected in the set, and vice-versa. The set supports element - * removal, which removes the corresponding mapping from the map, - * via the Iterator.remove, Set.remove, - * removeAll, retainAll, and clear - * operations. It does not support the add or - * addAll operations. - * - *

The view's iterator is a "weakly consistent" iterator - * that will never throw {@link ConcurrentModificationException}, - * and guarantees to traverse elements as they existed upon - * construction of the iterator, and may (but is not guaranteed to) - * reflect any modifications subsequent to construction. - */ - public Set> entrySet() { - Set> es = entrySet; - return (es != null) ? es : (entrySet = new EntrySet()); - } - - /** - * Returns an enumeration of the keys in this table. - * - * @return an enumeration of the keys in this table - * @see #keySet() - */ - public Enumeration keys() { - return new KeyIterator(); - } - - /** - * Returns an enumeration of the values in this table. - * - * @return an enumeration of the values in this table - * @see #values() - */ - public Enumeration elements() { - return new ValueIterator(); - } - - /* ---------------- Iterator Support -------------- */ - - abstract class HashIterator { - int nextSegmentIndex; - int nextTableIndex; - HashEntry[] currentTable; - HashEntry nextEntry; - HashEntry lastReturned; - - HashIterator() { - nextSegmentIndex = segments.length - 1; - nextTableIndex = -1; - advance(); - } - - public boolean hasMoreElements() { return hasNext(); } - - final void advance() { - if (nextEntry != null && (nextEntry = nextEntry.next) != null) - return; - - while (nextTableIndex >= 0) { - if ( (nextEntry = currentTable[nextTableIndex--]) != null) - return; - } - - while (nextSegmentIndex >= 0) { - Segment seg = segments[nextSegmentIndex--]; - if (seg.count != 0) { - currentTable = seg.table; - for (int j = currentTable.length - 1; j >= 0; --j) { - if ( (nextEntry = currentTable[j]) != null) { - nextTableIndex = j - 1; - return; - } - } - } - } - } - - public boolean hasNext() { return nextEntry != null; } - - HashEntry nextEntry() { - if (nextEntry == null) - throw new NoSuchElementException(); - lastReturned = nextEntry; - advance(); - return lastReturned; - } - - public void remove() { - if (lastReturned == null) - throw new IllegalStateException(); - ConcurrentHashMap.this.remove(lastReturned.key); - lastReturned = null; - } - } - - final class KeyIterator - extends HashIterator - implements Iterator, Enumeration - { - public K next() { return super.nextEntry().key; } - public K nextElement() { return super.nextEntry().key; } - } - - final class ValueIterator - extends HashIterator - implements Iterator, Enumeration - { - public V next() { return super.nextEntry().value; } - public V nextElement() { return super.nextEntry().value; } - } - - /** - * Custom Entry class used by EntryIterator.next(), that relays - * setValue changes to the underlying map. - */ - final class WriteThroughEntry - extends SimpleEntry - { - WriteThroughEntry(K k, V v) { - super(k,v); - } - - /** - * Set our entry's value and write through to the map. The - * value to return is somewhat arbitrary here. Since a - * WriteThroughEntry does not necessarily track asynchronous - * changes, the most recent "previous" value could be - * different from what we return (or could even have been - * removed in which case the put will re-establish). We do not - * and cannot guarantee more. - */ - public V setValue(V value) { - if (value == null) throw new NullPointerException(); - V v = super.setValue(value); - ConcurrentHashMap.this.put(getKey(), value); - return v; - } - } - - final class EntryIterator - extends HashIterator - implements Iterator> - { - public Map.Entry next() { - HashEntry e = super.nextEntry(); - return new WriteThroughEntry(e.key, e.value); - } - } - - final class KeySet extends AbstractSet { - public Iterator iterator() { - return new KeyIterator(); - } - public int size() { - return ConcurrentHashMap.this.size(); - } - public boolean isEmpty() { - return ConcurrentHashMap.this.isEmpty(); - } - public boolean contains(Object o) { - return ConcurrentHashMap.this.containsKey(o); - } - public boolean remove(Object o) { - return ConcurrentHashMap.this.remove(o) != null; - } - public void clear() { - ConcurrentHashMap.this.clear(); - } - } - - final class Values extends AbstractCollection { - public Iterator iterator() { - return new ValueIterator(); - } - public int size() { - return ConcurrentHashMap.this.size(); - } - public boolean isEmpty() { - return ConcurrentHashMap.this.isEmpty(); - } - public boolean contains(Object o) { - return ConcurrentHashMap.this.containsValue(o); - } - public void clear() { - ConcurrentHashMap.this.clear(); - } - } - - final class EntrySet extends AbstractSet> { - public Iterator> iterator() { - return new EntryIterator(); - } - public boolean contains(Object o) { - if (!(o instanceof Map.Entry)) - return false; - Map.Entry e = (Map.Entry)o; - V v = ConcurrentHashMap.this.get(e.getKey()); - return v != null && v.equals(e.getValue()); - } - public boolean remove(Object o) { - if (!(o instanceof Map.Entry)) - return false; - Map.Entry e = (Map.Entry)o; - return ConcurrentHashMap.this.remove(e.getKey(), e.getValue()); - } - public int size() { - return ConcurrentHashMap.this.size(); - } - public boolean isEmpty() { - return ConcurrentHashMap.this.isEmpty(); - } - public void clear() { - ConcurrentHashMap.this.clear(); - } - } - - /** - * This duplicates java.util.AbstractMap.SimpleEntry until this class - * is made accessible. - */ - static class SimpleEntry implements Entry { - K key; - V value; - - public SimpleEntry(K key, V value) { - this.key = key; - this.value = value; - } - - public SimpleEntry(Entry e) { - this.key = e.getKey(); - this.value = e.getValue(); - } - - public K getKey() { - return key; - } - - public V getValue() { - return value; - } - - public V setValue(V value) { - V oldValue = this.value; - this.value = value; - return oldValue; - } - - public boolean equals(Object o) { - if (!(o instanceof Map.Entry)) - return false; - Map.Entry e = (Map.Entry)o; - return eq(key, e.getKey()) && eq(value, e.getValue()); - } - - public int hashCode() { - return ((key == null) ? 0 : key.hashCode()) ^ - ((value == null) ? 0 : value.hashCode()); - } - - public String toString() { - return key + "=" + value; - } - - static boolean eq(Object o1, Object o2) { - return (o1 == null ? o2 == null : o1.equals(o2)); - } - } - - /* ---------------- Serialization Support -------------- */ - - /** - * Save the state of the ConcurrentHashMap instance to a - * stream (i.e., serialize it). - * @param s the stream - * @serialData - * the key (Object) and value (Object) - * for each key-value mapping, followed by a null pair. - * The key-value mappings are emitted in no particular order. - */ - private void writeObject(java.io.ObjectOutputStream s) throws IOException { - s.defaultWriteObject(); - - for (int k = 0; k < segments.length; ++k) { - Segment seg = segments[k]; - seg.lock(); - try { - HashEntry[] tab = seg.table; - for (int i = 0; i < tab.length; ++i) { - for (HashEntry e = tab[i]; e != null; e = e.next) { - s.writeObject(e.key); - s.writeObject(e.value); - } - } - } finally { - seg.unlock(); - } - } - s.writeObject(null); - s.writeObject(null); - } - - /** - * Reconstitute the ConcurrentHashMap instance from a - * stream (i.e., deserialize it). - * @param s the stream - */ - private void readObject(java.io.ObjectInputStream s) - throws IOException, ClassNotFoundException { - s.defaultReadObject(); - - // Initialize each segment to be minimally sized, and let grow. - for (int i = 0; i < segments.length; ++i) { - segments[i].setTable(new HashEntry[1]); - } - - // Read the keys and values, and put the mappings in the table - for (;;) { - K key = (K) s.readObject(); - V value = (V) s.readObject(); - if (key == null) - break; - put(key, value); - } - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/ConcurrentLinkedQueue.java b/libcore/concurrent/src/main/java/java/util/concurrent/ConcurrentLinkedQueue.java deleted file mode 100644 index 2253823e9..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/ConcurrentLinkedQueue.java +++ /dev/null @@ -1,661 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; -import java.util.*; -import java.util.concurrent.atomic.*; - - -// BEGIN android-note -// removed link to collections framework docs -// END android-note - -/** - * An unbounded thread-safe {@linkplain Queue queue} based on linked nodes. - * This queue orders elements FIFO (first-in-first-out). - * The head of the queue is that element that has been on the - * queue the longest time. - * The tail of the queue is that element that has been on the - * queue the shortest time. New elements - * are inserted at the tail of the queue, and the queue retrieval - * operations obtain elements at the head of the queue. - * A {@code ConcurrentLinkedQueue} is an appropriate choice when - * many threads will share access to a common collection. - * This queue does not permit {@code null} elements. - * - *

This implementation employs an efficient "wait-free" - * algorithm based on one described in Simple, - * Fast, and Practical Non-Blocking and Blocking Concurrent Queue - * Algorithms by Maged M. Michael and Michael L. Scott. - * - *

Beware that, unlike in most collections, the {@code size} method - * is NOT a constant-time operation. Because of the - * asynchronous nature of these queues, determining the current number - * of elements requires a traversal of the elements. - * - *

This class and its iterator implement all of the - * optional methods of the {@link Collection} and {@link - * Iterator} interfaces. - * - *

Memory consistency effects: As with other concurrent - * collections, actions in a thread prior to placing an object into a - * {@code ConcurrentLinkedQueue} - * happen-before - * actions subsequent to the access or removal of that element from - * the {@code ConcurrentLinkedQueue} in another thread. - * - * @since 1.5 - * @author Doug Lea - * @param the type of elements held in this collection - * - */ -public class ConcurrentLinkedQueue extends AbstractQueue - implements Queue, java.io.Serializable { - private static final long serialVersionUID = 196745693267521676L; - - /* - * This is a modification of the Michael & Scott algorithm, - * adapted for a garbage-collected environment, with support for - * interior node deletion (to support remove(Object)). For - * explanation, read the paper. - * - * Note that like most non-blocking algorithms in this package, - * this implementation relies on the fact that in garbage - * collected systems, there is no possibility of ABA problems due - * to recycled nodes, so there is no need to use "counted - * pointers" or related techniques seen in versions used in - * non-GC'ed settings. - * - * The fundamental invariants are: - * - There is exactly one (last) Node with a null next reference, - * which is CASed when enqueueing. This last Node can be - * reached in O(1) time from tail, but tail is merely an - * optimization - it can always be reached in O(N) time from - * head as well. - * - The elements contained in the queue are the non-null items in - * Nodes that are reachable from head. CASing the item - * reference of a Node to null atomically removes it from the - * queue. Reachability of all elements from head must remain - * true even in the case of concurrent modifications that cause - * head to advance. A dequeued Node may remain in use - * indefinitely due to creation of an Iterator or simply a - * poll() that has lost its time slice. - * - * The above might appear to imply that all Nodes are GC-reachable - * from a predecessor dequeued Node. That would cause two problems: - * - allow a rogue Iterator to cause unbounded memory retention - * - cause cross-generational linking of old Nodes to new Nodes if - * a Node was tenured while live, which generational GCs have a - * hard time dealing with, causing repeated major collections. - * However, only non-deleted Nodes need to be reachable from - * dequeued Nodes, and reachability does not necessarily have to - * be of the kind understood by the GC. We use the trick of - * linking a Node that has just been dequeued to itself. Such a - * self-link implicitly means to advance to head. - * - * Both head and tail are permitted to lag. In fact, failing to - * update them every time one could is a significant optimization - * (fewer CASes). This is controlled by local "hops" variables - * that only trigger helping-CASes after experiencing multiple - * lags. - * - * Since head and tail are updated concurrently and independently, - * it is possible for tail to lag behind head (why not)? - * - * CASing a Node's item reference to null atomically removes the - * element from the queue. Iterators skip over Nodes with null - * items. Prior implementations of this class had a race between - * poll() and remove(Object) where the same element would appear - * to be successfully removed by two concurrent operations. The - * method remove(Object) also lazily unlinks deleted Nodes, but - * this is merely an optimization. - * - * When constructing a Node (before enqueuing it) we avoid paying - * for a volatile write to item by using lazySet instead of a - * normal write. This allows the cost of enqueue to be - * "one-and-a-half" CASes. - * - * Both head and tail may or may not point to a Node with a - * non-null item. If the queue is empty, all items must of course - * be null. Upon creation, both head and tail refer to a dummy - * Node with null item. Both head and tail are only updated using - * CAS, so they never regress, although again this is merely an - * optimization. - */ - private static class Node { - private volatile E item; - private volatile Node next; - - private static final - AtomicReferenceFieldUpdater - nextUpdater = - AtomicReferenceFieldUpdater.newUpdater - (Node.class, Node.class, "next"); - private static final - AtomicReferenceFieldUpdater - itemUpdater = - AtomicReferenceFieldUpdater.newUpdater - (Node.class, Object.class, "item"); - - - Node(E item) { setItem(item); } - - E getItem() { - return item; - } - - boolean casItem(E cmp, E val) { - return itemUpdater.compareAndSet(this, cmp, val); - } - - void setItem(E val) { - itemUpdater.set(this, val); - } - - Node getNext() { - return next; - } - - boolean casNext(Node cmp, Node val) { - return nextUpdater.compareAndSet(this, cmp, val); - } - - void setNext(Node val) { - nextUpdater.set(this, val); - } - - } - - private static final - AtomicReferenceFieldUpdater - tailUpdater = - AtomicReferenceFieldUpdater.newUpdater - (ConcurrentLinkedQueue.class, Node.class, "tail"); - private static final - AtomicReferenceFieldUpdater - headUpdater = - AtomicReferenceFieldUpdater.newUpdater - (ConcurrentLinkedQueue.class, Node.class, "head"); - - private boolean casTail(Node cmp, Node val) { - return tailUpdater.compareAndSet(this, cmp, val); - } - - private boolean casHead(Node cmp, Node val) { - return headUpdater.compareAndSet(this, cmp, val); - } - - - - /** - * Pointer to first node, initialized to a dummy node. - */ - private transient volatile Node head = new Node(null); - - /** Pointer to last node on list */ - private transient volatile Node tail = head; - - - /** - * Creates a {@code ConcurrentLinkedQueue} that is initially empty. - */ - public ConcurrentLinkedQueue() {} - - /** - * Creates a {@code ConcurrentLinkedQueue} - * initially containing the elements of the given collection, - * added in traversal order of the collection's iterator. - * @param c the collection of elements to initially contain - * @throws NullPointerException if the specified collection or any - * of its elements are null - */ - public ConcurrentLinkedQueue(Collection c) { - for (Iterator it = c.iterator(); it.hasNext();) - add(it.next()); - } - - // Have to override just to update the javadoc - - /** - * Inserts the specified element at the tail of this queue. - * - * @return {@code true} (as specified by {@link Collection#add}) - * @throws NullPointerException if the specified element is null - */ - public boolean add(E e) { - return offer(e); - } - - /** - * We don't bother to update head or tail pointers if less than - * HOPS links from "true" location. We assume that volatile - * writes are significantly more expensive than volatile reads. - */ - private static final int HOPS = 1; - - /** - * Try to CAS head to p. If successful, repoint old head to itself - * as sentinel for succ(), below. - */ - final void updateHead(Node h, Node p) { - if (h != p && casHead(h, p)) - h.setNext(h); - } - - /** - * Returns the successor of p, or the head node if p.next has been - * linked to self, which will only be true if traversing with a - * stale pointer that is now off the list. - */ - final Node succ(Node p) { - Node next = p.getNext(); - return (p == next) ? head : next; - } - - /** - * Inserts the specified element at the tail of this queue. - * - * @return {@code true} (as specified by {@link Queue#offer}) - * @throws NullPointerException if the specified element is null - */ - public boolean offer(E e) { - if (e == null) throw new NullPointerException(); - Node n = new Node(e); - retry: - for (;;) { - Node t = tail; - Node p = t; - for (int hops = 0; ; hops++) { - Node next = succ(p); - if (next != null) { - if (hops > HOPS && t != tail) - continue retry; - p = next; - } else if (p.casNext(null, n)) { - if (hops >= HOPS) - casTail(t, n); // Failure is OK. - return true; - } else { - p = succ(p); - } - } - } - } - - public E poll() { - Node h = head; - Node p = h; - for (int hops = 0; ; hops++) { - E item = p.getItem(); - - if (item != null && p.casItem(item, null)) { - if (hops >= HOPS) { - Node q = p.getNext(); - updateHead(h, (q != null) ? q : p); - } - return item; - } - Node next = succ(p); - if (next == null) { - updateHead(h, p); - break; - } - p = next; - } - return null; - } - - public E peek() { - Node h = head; - Node p = h; - E item; - for (;;) { - item = p.getItem(); - if (item != null) - break; - Node next = succ(p); - if (next == null) { - break; - } - p = next; - } - updateHead(h, p); - return item; - } - - /** - * Returns the first actual (non-header) node on list. This is yet - * another variant of poll/peek; here returning out the first - * node, not element (so we cannot collapse with peek() without - * introducing race.) - */ - Node first() { - Node h = head; - Node p = h; - Node result; - for (;;) { - E item = p.getItem(); - if (item != null) { - result = p; - break; - } - Node next = succ(p); - if (next == null) { - result = null; - break; - } - p = next; - } - updateHead(h, p); - return result; - } - - /** - * Returns {@code true} if this queue contains no elements. - * - * @return {@code true} if this queue contains no elements - */ - public boolean isEmpty() { - return first() == null; - } - - /** - * Returns the number of elements in this queue. If this queue - * contains more than {@code Integer.MAX_VALUE} elements, returns - * {@code Integer.MAX_VALUE}. - * - *

Beware that, unlike in most collections, this method is - * NOT a constant-time operation. Because of the - * asynchronous nature of these queues, determining the current - * number of elements requires an O(n) traversal. - * - * @return the number of elements in this queue - */ - public int size() { - int count = 0; - for (Node p = first(); p != null; p = succ(p)) { - if (p.getItem() != null) { - // Collections.size() spec says to max out - if (++count == Integer.MAX_VALUE) - break; - } - } - return count; - } - - /** - * Returns {@code true} if this queue contains the specified element. - * More formally, returns {@code true} if and only if this queue contains - * at least one element {@code e} such that {@code o.equals(e)}. - * - * @param o object to be checked for containment in this queue - * @return {@code true} if this queue contains the specified element - */ - public boolean contains(Object o) { - if (o == null) return false; - for (Node p = first(); p != null; p = succ(p)) { - E item = p.getItem(); - if (item != null && - o.equals(item)) - return true; - } - return false; - } - - /** - * Removes a single instance of the specified element from this queue, - * if it is present. More formally, removes an element {@code e} such - * that {@code o.equals(e)}, if this queue contains one or more such - * elements. - * Returns {@code true} if this queue contained the specified element - * (or equivalently, if this queue changed as a result of the call). - * - * @param o element to be removed from this queue, if present - * @return {@code true} if this queue changed as a result of the call - */ - public boolean remove(Object o) { - if (o == null) return false; - Node pred = null; - for (Node p = first(); p != null; p = succ(p)) { - E item = p.getItem(); - if (item != null && o.equals(item) && p.casItem(item, null)) { - Node next = succ(p); - if (pred != null && next != null) - pred.casNext(p, next); - return true; - } - pred = p; - } - return false; - } - - /** - * Returns an array containing all of the elements in this queue, in - * proper sequence. - * - *

The returned array will be "safe" in that no references to it are - * maintained by this queue. (In other words, this method must allocate - * a new array). The caller is thus free to modify the returned array. - * - *

This method acts as bridge between array-based and collection-based - * APIs. - * - * @return an array containing all of the elements in this queue - */ - public Object[] toArray() { - // Use ArrayList to deal with resizing. - ArrayList al = new ArrayList(); - for (Node p = first(); p != null; p = succ(p)) { - E item = p.getItem(); - if (item != null) - al.add(item); - } - return al.toArray(); - } - - /** - * Returns an array containing all of the elements in this queue, in - * proper sequence; the runtime type of the returned array is that of - * the specified array. If the queue fits in the specified array, it - * is returned therein. Otherwise, a new array is allocated with the - * runtime type of the specified array and the size of this queue. - * - *

If this queue fits in the specified array with room to spare - * (i.e., the array has more elements than this queue), the element in - * the array immediately following the end of the queue is set to - * {@code null}. - * - *

Like the {@link #toArray()} method, this method acts as bridge between - * array-based and collection-based APIs. Further, this method allows - * precise control over the runtime type of the output array, and may, - * under certain circumstances, be used to save allocation costs. - * - *

Suppose {@code x} is a queue known to contain only strings. - * The following code can be used to dump the queue into a newly - * allocated array of {@code String}: - * - *

-     *     String[] y = x.toArray(new String[0]);
- * - * Note that {@code toArray(new Object[0])} is identical in function to - * {@code toArray()}. - * - * @param a the array into which the elements of the queue are to - * be stored, if it is big enough; otherwise, a new array of the - * same runtime type is allocated for this purpose - * @return an array containing all of the elements in this queue - * @throws ArrayStoreException if the runtime type of the specified array - * is not a supertype of the runtime type of every element in - * this queue - * @throws NullPointerException if the specified array is null - */ - @SuppressWarnings("unchecked") - public T[] toArray(T[] a) { - // try to use sent-in array - int k = 0; - Node p; - for (p = first(); p != null && k < a.length; p = succ(p)) { - E item = p.getItem(); - if (item != null) - a[k++] = (T)item; - } - if (p == null) { - if (k < a.length) - a[k] = null; - return a; - } - - // If won't fit, use ArrayList version - ArrayList al = new ArrayList(); - for (Node q = first(); q != null; q = succ(q)) { - E item = q.getItem(); - if (item != null) - al.add(item); - } - return al.toArray(a); - } - - /** - * Returns an iterator over the elements in this queue in proper sequence. - * The returned iterator is a "weakly consistent" iterator that - * will never throw {@link ConcurrentModificationException}, - * and guarantees to traverse elements as they existed upon - * construction of the iterator, and may (but is not guaranteed to) - * reflect any modifications subsequent to construction. - * - * @return an iterator over the elements in this queue in proper sequence - */ - public Iterator iterator() { - return new Itr(); - } - - private class Itr implements Iterator { - /** - * Next node to return item for. - */ - private Node nextNode; - - /** - * nextItem holds on to item fields because once we claim - * that an element exists in hasNext(), we must return it in - * the following next() call even if it was in the process of - * being removed when hasNext() was called. - */ - private E nextItem; - - /** - * Node of the last returned item, to support remove. - */ - private Node lastRet; - - Itr() { - advance(); - } - - /** - * Moves to next valid node and returns item to return for - * next(), or null if no such. - */ - private E advance() { - lastRet = nextNode; - E x = nextItem; - - Node pred, p; - if (nextNode == null) { - p = first(); - pred = null; - } else { - pred = nextNode; - p = succ(nextNode); - } - - for (;;) { - if (p == null) { - nextNode = null; - nextItem = null; - return x; - } - E item = p.getItem(); - if (item != null) { - nextNode = p; - nextItem = item; - return x; - } else { - // skip over nulls - Node next = succ(p); - if (pred != null && next != null) - pred.casNext(p, next); - p = next; - } - } - } - - public boolean hasNext() { - return nextNode != null; - } - - public E next() { - if (nextNode == null) throw new NoSuchElementException(); - return advance(); - } - - public void remove() { - Node l = lastRet; - if (l == null) throw new IllegalStateException(); - // rely on a future traversal to relink. - l.setItem(null); - lastRet = null; - } - } - - /** - * Save the state to a stream (that is, serialize it). - * - * @serialData All of the elements (each an {@code E}) in - * the proper order, followed by a null - * @param s the stream - */ - private void writeObject(java.io.ObjectOutputStream s) - throws java.io.IOException { - - // Write out any hidden stuff - s.defaultWriteObject(); - - // Write out all elements in the proper order. - for (Node p = first(); p != null; p = succ(p)) { - Object item = p.getItem(); - if (item != null) - s.writeObject(item); - } - - // Use trailing null as sentinel - s.writeObject(null); - } - - /** - * Reconstitute the Queue instance from a stream (that is, - * deserialize it). - * @param s the stream - */ - private void readObject(java.io.ObjectInputStream s) - throws java.io.IOException, ClassNotFoundException { - // Read in capacity, and any hidden stuff - s.defaultReadObject(); - head = new Node(null); - tail = head; - // Read in all elements and place in queue - for (;;) { - @SuppressWarnings("unchecked") - E item = (E)s.readObject(); - if (item == null) - break; - else - offer(item); - } - } - -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/ConcurrentMap.java b/libcore/concurrent/src/main/java/java/util/concurrent/ConcurrentMap.java deleted file mode 100644 index 2daebc549..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/ConcurrentMap.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; -import java.util.Map; - -// BEGIN android-note -// removed link to collections framework docs -// END android-note - -/** - * A {@link java.util.Map} providing additional atomic - * putIfAbsent, remove, and replace methods. - * - *

Memory consistency effects: As with other concurrent - * collections, actions in a thread prior to placing an object into a - * {@code ConcurrentMap} as a key or value - * happen-before - * actions subsequent to the access or removal of that object from - * the {@code ConcurrentMap} in another thread. - * - * @since 1.5 - * @author Doug Lea - * @param the type of keys maintained by this map - * @param the type of mapped values - */ -public interface ConcurrentMap extends Map { - /** - * If the specified key is not already associated - * with a value, associate it with the given value. - * This is equivalent to - *

-     *   if (!map.containsKey(key))
-     *       return map.put(key, value);
-     *   else
-     *       return map.get(key);
- * except that the action is performed atomically. - * - * @param key key with which the specified value is to be associated - * @param value value to be associated with the specified key - * @return the previous value associated with the specified key, or - * null if there was no mapping for the key. - * (A null return can also indicate that the map - * previously associated null with the key, - * if the implementation supports null values.) - * @throws UnsupportedOperationException if the put operation - * is not supported by this map - * @throws ClassCastException if the class of the specified key or value - * prevents it from being stored in this map - * @throws NullPointerException if the specified key or value is null, - * and this map does not permit null keys or values - * @throws IllegalArgumentException if some property of the specified key - * or value prevents it from being stored in this map - * - */ - V putIfAbsent(K key, V value); - - /** - * Removes the entry for a key only if currently mapped to a given value. - * This is equivalent to - *
-     *   if (map.containsKey(key) && map.get(key).equals(value)) {
-     *       map.remove(key);
-     *       return true;
-     *   } else return false;
- * except that the action is performed atomically. - * - * @param key key with which the specified value is associated - * @param value value expected to be associated with the specified key - * @return true if the value was removed - * @throws UnsupportedOperationException if the remove operation - * is not supported by this map - * @throws ClassCastException if the key or value is of an inappropriate - * type for this map (optional) - * @throws NullPointerException if the specified key or value is null, - * and this map does not permit null keys or values (optional) - */ - boolean remove(Object key, Object value); - - /** - * Replaces the entry for a key only if currently mapped to a given value. - * This is equivalent to - *
-     *   if (map.containsKey(key) && map.get(key).equals(oldValue)) {
-     *       map.put(key, newValue);
-     *       return true;
-     *   } else return false;
- * except that the action is performed atomically. - * - * @param key key with which the specified value is associated - * @param oldValue value expected to be associated with the specified key - * @param newValue value to be associated with the specified key - * @return true if the value was replaced - * @throws UnsupportedOperationException if the put operation - * is not supported by this map - * @throws ClassCastException if the class of a specified key or value - * prevents it from being stored in this map - * @throws NullPointerException if a specified key or value is null, - * and this map does not permit null keys or values - * @throws IllegalArgumentException if some property of a specified key - * or value prevents it from being stored in this map - */ - boolean replace(K key, V oldValue, V newValue); - - /** - * Replaces the entry for a key only if currently mapped to some value. - * This is equivalent to - *
-     *   if (map.containsKey(key)) {
-     *       return map.put(key, value);
-     *   } else return null;
- * except that the action is performed atomically. - * - * @param key key with which the specified value is associated - * @param value value to be associated with the specified key - * @return the previous value associated with the specified key, or - * null if there was no mapping for the key. - * (A null return can also indicate that the map - * previously associated null with the key, - * if the implementation supports null values.) - * @throws UnsupportedOperationException if the put operation - * is not supported by this map - * @throws ClassCastException if the class of the specified key or value - * prevents it from being stored in this map - * @throws NullPointerException if the specified key or value is null, - * and this map does not permit null keys or values - * @throws IllegalArgumentException if some property of the specified key - * or value prevents it from being stored in this map - */ - V replace(K key, V value); -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/CopyOnWriteArrayList.java b/libcore/concurrent/src/main/java/java/util/concurrent/CopyOnWriteArrayList.java deleted file mode 100644 index f0c8ac6de..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/CopyOnWriteArrayList.java +++ /dev/null @@ -1,1317 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group. Adapted and released, under explicit permission, - * from JDK ArrayList.java which carries the following copyright: - * - * Copyright 1997 by Sun Microsystems, Inc., - * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. - * All rights reserved. - * - * This software is the confidential and proprietary information - * of Sun Microsystems, Inc. ("Confidential Information"). You - * shall not disclose such Confidential Information and shall use - * it only in accordance with the terms of the license agreement - * you entered into with Sun. - */ - -package java.util.concurrent; -import java.util.*; -import java.util.concurrent.locks.*; -import java.lang.reflect.Array; - -import sun.misc.Unsafe; - -// BEGIN android-note -// removed link to collections framework docs -// END android-note - -/** - * A thread-safe variant of {@link java.util.ArrayList} in which all mutative - * operations (add, set, and so on) are implemented by - * making a fresh copy of the underlying array. - * - *

This is ordinarily too costly, but may be more efficient - * than alternatives when traversal operations vastly outnumber - * mutations, and is useful when you cannot or don't want to - * synchronize traversals, yet need to preclude interference among - * concurrent threads. The "snapshot" style iterator method uses a - * reference to the state of the array at the point that the iterator - * was created. This array never changes during the lifetime of the - * iterator, so interference is impossible and the iterator is - * guaranteed not to throw ConcurrentModificationException. - * The iterator will not reflect additions, removals, or changes to - * the list since the iterator was created. Element-changing - * operations on iterators themselves (remove, set, and - * add) are not supported. These methods throw - * UnsupportedOperationException. - * - *

All elements are permitted, including null. - * - *

Memory consistency effects: As with other concurrent - * collections, actions in a thread prior to placing an object into a - * {@code CopyOnWriteArrayList} - * happen-before - * actions subsequent to the access or removal of that element from - * the {@code CopyOnWriteArrayList} in another thread. - * - * @since 1.5 - * @author Doug Lea - * @param the type of elements held in this collection - */ -public class CopyOnWriteArrayList - implements List, RandomAccess, Cloneable, java.io.Serializable { - private static final long serialVersionUID = 8673264195747942595L; - - /** The lock protecting all mutators */ - transient final ReentrantLock lock = new ReentrantLock(); - - /** The array, accessed only via getArray/setArray. */ - private volatile transient Object[] array; - - /** - * Gets the array. Non-private so as to also be accessible - * from CopyOnWriteArraySet class. - */ - final Object[] getArray() { - return array; - } - - /** - * Sets the array. - */ - final void setArray(Object[] a) { - array = a; - } - - /** - * Creates an empty list. - */ - public CopyOnWriteArrayList() { - setArray(new Object[0]); - } - - /** - * Creates a list containing the elements of the specified - * collection, in the order they are returned by the collection's - * iterator. - * - * @param c the collection of initially held elements - * @throws NullPointerException if the specified collection is null - */ - public CopyOnWriteArrayList(Collection c) { - Object[] elements = c.toArray(); - // c.toArray might (incorrectly) not return Object[] (see 6260652) - if (elements.getClass() != Object[].class) - elements = Java6Arrays.copyOf(elements, elements.length, Object[].class); - setArray(elements); - } - - /** - * Creates a list holding a copy of the given array. - * - * @param toCopyIn the array (a copy of this array is used as the - * internal array) - * @throws NullPointerException if the specified array is null - */ - public CopyOnWriteArrayList(E[] toCopyIn) { - setArray(Java6Arrays.copyOf(toCopyIn, toCopyIn.length, Object[].class)); - } - - /** - * Returns the number of elements in this list. - * - * @return the number of elements in this list - */ - public int size() { - return getArray().length; - } - - /** - * Returns true if this list contains no elements. - * - * @return true if this list contains no elements - */ - public boolean isEmpty() { - return size() == 0; - } - - /** - * Test for equality, coping with nulls. - */ - private static boolean eq(Object o1, Object o2) { - return (o1 == null ? o2 == null : o1.equals(o2)); - } - - /** - * static version of indexOf, to allow repeated calls without - * needing to re-acquire array each time. - * @param o element to search for - * @param elements the array - * @param index first index to search - * @param fence one past last index to search - * @return index of element, or -1 if absent - */ - private static int indexOf(Object o, Object[] elements, - int index, int fence) { - if (o == null) { - for (int i = index; i < fence; i++) - if (elements[i] == null) - return i; - } else { - for (int i = index; i < fence; i++) - if (o.equals(elements[i])) - return i; - } - return -1; - } - - /** - * static version of lastIndexOf. - * @param o element to search for - * @param elements the array - * @param index first index to search - * @return index of element, or -1 if absent - */ - private static int lastIndexOf(Object o, Object[] elements, int index) { - if (o == null) { - for (int i = index; i >= 0; i--) - if (elements[i] == null) - return i; - } else { - for (int i = index; i >= 0; i--) - if (o.equals(elements[i])) - return i; - } - return -1; - } - - /** - * Returns true if this list contains the specified element. - * More formally, returns true if and only if this list contains - * at least one element e such that - * (o==null ? e==null : o.equals(e)). - * - * @param o element whose presence in this list is to be tested - * @return true if this list contains the specified element - */ - public boolean contains(Object o) { - Object[] elements = getArray(); - return indexOf(o, elements, 0, elements.length) >= 0; - } - - /** - * {@inheritDoc} - */ - public int indexOf(Object o) { - Object[] elements = getArray(); - return indexOf(o, elements, 0, elements.length); - } - - /** - * Returns the index of the first occurrence of the specified element in - * this list, searching forwards from index, or returns -1 if - * the element is not found. - * More formally, returns the lowest index i such that - * (i >= index && (e==null ? get(i)==null : e.equals(get(i)))), - * or -1 if there is no such index. - * - * @param e element to search for - * @param index index to start searching from - * @return the index of the first occurrence of the element in - * this list at position index or later in the list; - * -1 if the element is not found. - * @throws IndexOutOfBoundsException if the specified index is negative - */ - public int indexOf(E e, int index) { - Object[] elements = getArray(); - return indexOf(e, elements, index, elements.length); - } - - /** - * {@inheritDoc} - */ - public int lastIndexOf(Object o) { - Object[] elements = getArray(); - return lastIndexOf(o, elements, elements.length - 1); - } - - /** - * Returns the index of the last occurrence of the specified element in - * this list, searching backwards from index, or returns -1 if - * the element is not found. - * More formally, returns the highest index i such that - * (i <= index && (e==null ? get(i)==null : e.equals(get(i)))), - * or -1 if there is no such index. - * - * @param e element to search for - * @param index index to start searching backwards from - * @return the index of the last occurrence of the element at position - * less than or equal to index in this list; - * -1 if the element is not found. - * @throws IndexOutOfBoundsException if the specified index is greater - * than or equal to the current size of this list - */ - public int lastIndexOf(E e, int index) { - Object[] elements = getArray(); - return lastIndexOf(e, elements, index); - } - - /** - * Returns a shallow copy of this list. (The elements themselves - * are not copied.) - * - * @return a clone of this list - */ - public Object clone() { - try { - CopyOnWriteArrayList c = (CopyOnWriteArrayList)(super.clone()); - c.resetLock(); - return c; - } catch (CloneNotSupportedException e) { - // this shouldn't happen, since we are Cloneable - throw new InternalError(); - } - } - - /** - * Returns an array containing all of the elements in this list - * in proper sequence (from first to last element). - * - *

The returned array will be "safe" in that no references to it are - * maintained by this list. (In other words, this method must allocate - * a new array). The caller is thus free to modify the returned array. - * - *

This method acts as bridge between array-based and collection-based - * APIs. - * - * @return an array containing all the elements in this list - */ - public Object[] toArray() { - Object[] elements = getArray(); - return Java6Arrays.copyOf(elements, elements.length); - } - - /** - * Returns an array containing all of the elements in this list in - * proper sequence (from first to last element); the runtime type of - * the returned array is that of the specified array. If the list fits - * in the specified array, it is returned therein. Otherwise, a new - * array is allocated with the runtime type of the specified array and - * the size of this list. - * - *

If this list fits in the specified array with room to spare - * (i.e., the array has more elements than this list), the element in - * the array immediately following the end of the list is set to - * null. (This is useful in determining the length of this - * list only if the caller knows that this list does not contain - * any null elements.) - * - *

Like the {@link #toArray()} method, this method acts as bridge between - * array-based and collection-based APIs. Further, this method allows - * precise control over the runtime type of the output array, and may, - * under certain circumstances, be used to save allocation costs. - * - *

Suppose x is a list known to contain only strings. - * The following code can be used to dump the list into a newly - * allocated array of String: - * - *

-     *     String[] y = x.toArray(new String[0]);
- * - * Note that toArray(new Object[0]) is identical in function to - * toArray(). - * - * @param a the array into which the elements of the list are to - * be stored, if it is big enough; otherwise, a new array of the - * same runtime type is allocated for this purpose. - * @return an array containing all the elements in this list - * @throws ArrayStoreException if the runtime type of the specified array - * is not a supertype of the runtime type of every element in - * this list - * @throws NullPointerException if the specified array is null - */ - @SuppressWarnings("unchecked") - public T[] toArray(T a[]) { - Object[] elements = getArray(); - int len = elements.length; - if (a.length < len) - return (T[]) Java6Arrays.copyOf(elements, len, a.getClass()); - else { - System.arraycopy(elements, 0, a, 0, len); - if (a.length > len) - a[len] = null; - return a; - } - } - - // Positional Access Operations - - @SuppressWarnings("unchecked") - private E get(Object[] a, int index) { - return (E) a[index]; - } - - /** - * {@inheritDoc} - * - * @throws IndexOutOfBoundsException {@inheritDoc} - */ - public E get(int index) { - return get(getArray(), index); - } - - /** - * Replaces the element at the specified position in this list with the - * specified element. - * - * @throws IndexOutOfBoundsException {@inheritDoc} - */ - public E set(int index, E element) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - Object[] elements = getArray(); - E oldValue = get(elements, index); - - if (oldValue != element) { - int len = elements.length; - Object[] newElements = Java6Arrays.copyOf(elements, len); - newElements[index] = element; - setArray(newElements); - } else { - // Not quite a no-op; ensures volatile write semantics - setArray(elements); - } - return oldValue; - } finally { - lock.unlock(); - } - } - - /** - * Appends the specified element to the end of this list. - * - * @param e element to be appended to this list - * @return true (as specified by {@link Collection#add}) - */ - public boolean add(E e) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - Object[] elements = getArray(); - int len = elements.length; - Object[] newElements = Java6Arrays.copyOf(elements, len + 1); - newElements[len] = e; - setArray(newElements); - return true; - } finally { - lock.unlock(); - } - } - - /** - * Inserts the specified element at the specified position in this - * list. Shifts the element currently at that position (if any) and - * any subsequent elements to the right (adds one to their indices). - * - * @throws IndexOutOfBoundsException {@inheritDoc} - */ - public void add(int index, E element) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - Object[] elements = getArray(); - int len = elements.length; - if (index > len || index < 0) - throw new IndexOutOfBoundsException("Index: "+index+ - ", Size: "+len); - Object[] newElements; - int numMoved = len - index; - if (numMoved == 0) - newElements = Java6Arrays.copyOf(elements, len + 1); - else { - newElements = new Object[len + 1]; - System.arraycopy(elements, 0, newElements, 0, index); - System.arraycopy(elements, index, newElements, index + 1, - numMoved); - } - newElements[index] = element; - setArray(newElements); - } finally { - lock.unlock(); - } - } - - /** - * Removes the element at the specified position in this list. - * Shifts any subsequent elements to the left (subtracts one from their - * indices). Returns the element that was removed from the list. - * - * @throws IndexOutOfBoundsException {@inheritDoc} - */ - public E remove(int index) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - Object[] elements = getArray(); - int len = elements.length; - E oldValue = get(elements, index); - int numMoved = len - index - 1; - if (numMoved == 0) - setArray(Java6Arrays.copyOf(elements, len - 1)); - else { - Object[] newElements = new Object[len - 1]; - System.arraycopy(elements, 0, newElements, 0, index); - System.arraycopy(elements, index + 1, newElements, index, - numMoved); - setArray(newElements); - } - return oldValue; - } finally { - lock.unlock(); - } - } - - /** - * Removes the first occurrence of the specified element from this list, - * if it is present. If this list does not contain the element, it is - * unchanged. More formally, removes the element with the lowest index - * i such that - * (o==null ? get(i)==null : o.equals(get(i))) - * (if such an element exists). Returns true if this list - * contained the specified element (or equivalently, if this list - * changed as a result of the call). - * - * @param o element to be removed from this list, if present - * @return true if this list contained the specified element - */ - public boolean remove(Object o) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - Object[] elements = getArray(); - int len = elements.length; - if (len != 0) { - // Copy while searching for element to remove - // This wins in the normal case of element being present - int newlen = len - 1; - Object[] newElements = new Object[newlen]; - - for (int i = 0; i < newlen; ++i) { - if (eq(o, elements[i])) { - // found one; copy remaining and exit - for (int k = i + 1; k < len; ++k) - newElements[k-1] = elements[k]; - setArray(newElements); - return true; - } else - newElements[i] = elements[i]; - } - - // special handling for last cell - if (eq(o, elements[newlen])) { - setArray(newElements); - return true; - } - } - return false; - } finally { - lock.unlock(); - } - } - - /** - * Removes from this list all of the elements whose index is between - * fromIndex, inclusive, and toIndex, exclusive. - * Shifts any succeeding elements to the left (reduces their index). - * This call shortens the list by (toIndex - fromIndex) elements. - * (If toIndex==fromIndex, this operation has no effect.) - * - * @param fromIndex index of first element to be removed - * @param toIndex index after last element to be removed - * @throws IndexOutOfBoundsException if fromIndex or toIndex out of range - * (@code{fromIndex < 0 || toIndex > size() || toIndex < fromIndex}) - */ - private void removeRange(int fromIndex, int toIndex) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - Object[] elements = getArray(); - int len = elements.length; - - if (fromIndex < 0 || toIndex > len || toIndex < fromIndex) - throw new IndexOutOfBoundsException(); - int newlen = len - (toIndex - fromIndex); - int numMoved = len - toIndex; - if (numMoved == 0) - setArray(Java6Arrays.copyOf(elements, newlen)); - else { - Object[] newElements = new Object[newlen]; - System.arraycopy(elements, 0, newElements, 0, fromIndex); - System.arraycopy(elements, toIndex, newElements, - fromIndex, numMoved); - setArray(newElements); - } - } finally { - lock.unlock(); - } - } - - /** - * Append the element if not present. - * - * @param e element to be added to this list, if absent - * @return true if the element was added - */ - public boolean addIfAbsent(E e) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - // Copy while checking if already present. - // This wins in the most common case where it is not present - Object[] elements = getArray(); - int len = elements.length; - Object[] newElements = new Object[len + 1]; - for (int i = 0; i < len; ++i) { - if (eq(e, elements[i])) - return false; // exit, throwing away copy - else - newElements[i] = elements[i]; - } - newElements[len] = e; - setArray(newElements); - return true; - } finally { - lock.unlock(); - } - } - - /** - * Returns true if this list contains all of the elements of the - * specified collection. - * - * @param c collection to be checked for containment in this list - * @return true if this list contains all of the elements of the - * specified collection - * @throws NullPointerException if the specified collection is null - * @see #contains(Object) - */ - public boolean containsAll(Collection c) { - Object[] elements = getArray(); - int len = elements.length; - for (Object e : c) { - if (indexOf(e, elements, 0, len) < 0) - return false; - } - return true; - } - - /** - * Removes from this list all of its elements that are contained in - * the specified collection. This is a particularly expensive operation - * in this class because of the need for an internal temporary array. - * - * @param c collection containing elements to be removed from this list - * @return true if this list changed as a result of the call - * @throws ClassCastException if the class of an element of this list - * is incompatible with the specified collection (optional) - * @throws NullPointerException if this list contains a null element and the - * specified collection does not permit null elements (optional), - * or if the specified collection is null - * @see #remove(Object) - */ - public boolean removeAll(Collection c) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - Object[] elements = getArray(); - int len = elements.length; - if (len != 0) { - // temp array holds those elements we know we want to keep - int newlen = 0; - Object[] temp = new Object[len]; - for (int i = 0; i < len; ++i) { - Object element = elements[i]; - if (!c.contains(element)) - temp[newlen++] = element; - } - if (newlen != len) { - setArray(Java6Arrays.copyOf(temp, newlen)); - return true; - } - } - return false; - } finally { - lock.unlock(); - } - } - - /** - * Retains only the elements in this list that are contained in the - * specified collection. In other words, removes from this list all of - * its elements that are not contained in the specified collection. - * - * @param c collection containing elements to be retained in this list - * @return true if this list changed as a result of the call - * @throws ClassCastException if the class of an element of this list - * is incompatible with the specified collection (optional) - * @throws NullPointerException if this list contains a null element and the - * specified collection does not permit null elements (optional), - * or if the specified collection is null - * @see #remove(Object) - */ - public boolean retainAll(Collection c) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - Object[] elements = getArray(); - int len = elements.length; - if (len != 0) { - // temp array holds those elements we know we want to keep - int newlen = 0; - Object[] temp = new Object[len]; - for (int i = 0; i < len; ++i) { - Object element = elements[i]; - if (c.contains(element)) - temp[newlen++] = element; - } - if (newlen != len) { - setArray(Java6Arrays.copyOf(temp, newlen)); - return true; - } - } - return false; - } finally { - lock.unlock(); - } - } - - /** - * Appends all of the elements in the specified collection that - * are not already contained in this list, to the end of - * this list, in the order that they are returned by the - * specified collection's iterator. - * - * @param c collection containing elements to be added to this list - * @return the number of elements added - * @throws NullPointerException if the specified collection is null - * @see #addIfAbsent(Object) - */ - public int addAllAbsent(Collection c) { - Object[] cs = c.toArray(); - if (cs.length == 0) - return 0; - Object[] uniq = new Object[cs.length]; - final ReentrantLock lock = this.lock; - lock.lock(); - try { - Object[] elements = getArray(); - int len = elements.length; - int added = 0; - for (int i = 0; i < cs.length; ++i) { // scan for duplicates - Object e = cs[i]; - if (indexOf(e, elements, 0, len) < 0 && - indexOf(e, uniq, 0, added) < 0) - uniq[added++] = e; - } - if (added > 0) { - Object[] newElements = Java6Arrays.copyOf(elements, len + added); - System.arraycopy(uniq, 0, newElements, len, added); - setArray(newElements); - } - return added; - } finally { - lock.unlock(); - } - } - - /** - * Removes all of the elements from this list. - * The list will be empty after this call returns. - */ - public void clear() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - setArray(new Object[0]); - } finally { - lock.unlock(); - } - } - - /** - * Appends all of the elements in the specified collection to the end - * of this list, in the order that they are returned by the specified - * collection's iterator. - * - * @param c collection containing elements to be added to this list - * @return true if this list changed as a result of the call - * @throws NullPointerException if the specified collection is null - * @see #add(Object) - */ - public boolean addAll(Collection c) { - Object[] cs = c.toArray(); - if (cs.length == 0) - return false; - final ReentrantLock lock = this.lock; - lock.lock(); - try { - Object[] elements = getArray(); - int len = elements.length; - Object[] newElements = Java6Arrays.copyOf(elements, len + cs.length); - System.arraycopy(cs, 0, newElements, len, cs.length); - setArray(newElements); - return true; - } finally { - lock.unlock(); - } - } - - /** - * Inserts all of the elements in the specified collection into this - * list, starting at the specified position. Shifts the element - * currently at that position (if any) and any subsequent elements to - * the right (increases their indices). The new elements will appear - * in this list in the order that they are returned by the - * specified collection's iterator. - * - * @param index index at which to insert the first element - * from the specified collection - * @param c collection containing elements to be added to this list - * @return true if this list changed as a result of the call - * @throws IndexOutOfBoundsException {@inheritDoc} - * @throws NullPointerException if the specified collection is null - * @see #add(int,Object) - */ - public boolean addAll(int index, Collection c) { - Object[] cs = c.toArray(); - final ReentrantLock lock = this.lock; - lock.lock(); - try { - Object[] elements = getArray(); - int len = elements.length; - if (index > len || index < 0) - throw new IndexOutOfBoundsException("Index: "+index+ - ", Size: "+len); - if (cs.length == 0) - return false; - int numMoved = len - index; - Object[] newElements; - if (numMoved == 0) - newElements = Java6Arrays.copyOf(elements, len + cs.length); - else { - newElements = new Object[len + cs.length]; - System.arraycopy(elements, 0, newElements, 0, index); - System.arraycopy(elements, index, - newElements, index + cs.length, - numMoved); - } - System.arraycopy(cs, 0, newElements, index, cs.length); - setArray(newElements); - return true; - } finally { - lock.unlock(); - } - } - - /** - * Save the state of the list to a stream (i.e., serialize it). - * - * @serialData The length of the array backing the list is emitted - * (int), followed by all of its elements (each an Object) - * in the proper order. - * @param s the stream - */ - private void writeObject(java.io.ObjectOutputStream s) - throws java.io.IOException{ - - // Write out element count, and any hidden stuff - s.defaultWriteObject(); - - Object[] elements = getArray(); - int len = elements.length; - // Write out array length - s.writeInt(len); - - // Write out all elements in the proper order. - for (int i = 0; i < len; i++) - s.writeObject(elements[i]); - } - - /** - * Reconstitute the list from a stream (i.e., deserialize it). - * @param s the stream - */ - private void readObject(java.io.ObjectInputStream s) - throws java.io.IOException, ClassNotFoundException { - - // Read in size, and any hidden stuff - s.defaultReadObject(); - - // bind to new lock - resetLock(); - - // Read in array length and allocate array - int len = s.readInt(); - Object[] elements = new Object[len]; - - // Read in all elements in the proper order. - for (int i = 0; i < len; i++) - elements[i] = s.readObject(); - setArray(elements); - } - - /** - * Returns a string representation of this list. The string - * representation consists of the string representations of the list's - * elements in the order they are returned by its iterator, enclosed in - * square brackets ("[]"). Adjacent elements are separated by - * the characters ", " (comma and space). Elements are - * converted to strings as by {@link String#valueOf(Object)}. - * - * @return a string representation of this list - */ - public String toString() { - return Arrays.toString(getArray()); - } - - /** - * Compares the specified object with this list for equality. - * Returns {@code true} if the specified object is the same object - * as this object, or if it is also a {@link List} and the sequence - * of elements returned by an {@linkplain List#iterator() iterator} - * over the specified list is the same as the sequence returned by - * an iterator over this list. The two sequences are considered to - * be the same if they have the same length and corresponding - * elements at the same position in the sequence are equal. - * Two elements {@code e1} and {@code e2} are considered - * equal if {@code (e1==null ? e2==null : e1.equals(e2))}. - * - * @param o the object to be compared for equality with this list - * @return {@code true} if the specified object is equal to this list - */ - public boolean equals(Object o) { - if (o == this) - return true; - if (!(o instanceof List)) - return false; - - List list = (List)(o); - Iterator it = list.iterator(); - Object[] elements = getArray(); - int len = elements.length; - for (int i = 0; i < len; ++i) - if (!it.hasNext() || !eq(elements[i], it.next())) - return false; - if (it.hasNext()) - return false; - return true; - } - - /** - * Returns the hash code value for this list. - * - *

This implementation uses the definition in {@link List#hashCode}. - * - * @return the hash code value for this list - */ - public int hashCode() { - int hashCode = 1; - Object[] elements = getArray(); - int len = elements.length; - for (int i = 0; i < len; ++i) { - Object obj = elements[i]; - hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode()); - } - return hashCode; - } - - /** - * Returns an iterator over the elements in this list in proper sequence. - * - *

The returned iterator provides a snapshot of the state of the list - * when the iterator was constructed. No synchronization is needed while - * traversing the iterator. The iterator does NOT support the - * remove method. - * - * @return an iterator over the elements in this list in proper sequence - */ - public Iterator iterator() { - return new COWIterator(getArray(), 0); - } - - /** - * {@inheritDoc} - * - *

The returned iterator provides a snapshot of the state of the list - * when the iterator was constructed. No synchronization is needed while - * traversing the iterator. The iterator does NOT support the - * remove, set or add methods. - */ - public ListIterator listIterator() { - return new COWIterator(getArray(), 0); - } - - /** - * {@inheritDoc} - * - *

The returned iterator provides a snapshot of the state of the list - * when the iterator was constructed. No synchronization is needed while - * traversing the iterator. The iterator does NOT support the - * remove, set or add methods. - * - * @throws IndexOutOfBoundsException {@inheritDoc} - */ - public ListIterator listIterator(final int index) { - Object[] elements = getArray(); - int len = elements.length; - if (index<0 || index>len) - throw new IndexOutOfBoundsException("Index: "+index); - - return new COWIterator(elements, index); - } - - private static class COWIterator implements ListIterator { - /** Snapshot of the array **/ - private final Object[] snapshot; - /** Index of element to be returned by subsequent call to next. */ - private int cursor; - - private COWIterator(Object[] elements, int initialCursor) { - cursor = initialCursor; - snapshot = elements; - } - - public boolean hasNext() { - return cursor < snapshot.length; - } - - public boolean hasPrevious() { - return cursor > 0; - } - - @SuppressWarnings("unchecked") - public E next() { - if (! hasNext()) - throw new NoSuchElementException(); - return (E) snapshot[cursor++]; - } - - @SuppressWarnings("unchecked") - public E previous() { - if (! hasPrevious()) - throw new NoSuchElementException(); - return (E) snapshot[--cursor]; - } - - public int nextIndex() { - return cursor; - } - - public int previousIndex() { - return cursor-1; - } - - /** - * Not supported. Always throws UnsupportedOperationException. - * @throws UnsupportedOperationException always; remove - * is not supported by this iterator. - */ - public void remove() { - throw new UnsupportedOperationException(); - } - - /** - * Not supported. Always throws UnsupportedOperationException. - * @throws UnsupportedOperationException always; set - * is not supported by this iterator. - */ - public void set(E e) { - throw new UnsupportedOperationException(); - } - - /** - * Not supported. Always throws UnsupportedOperationException. - * @throws UnsupportedOperationException always; add - * is not supported by this iterator. - */ - public void add(E e) { - throw new UnsupportedOperationException(); - } - } - - /** - * Returns a view of the portion of this list between - * fromIndex, inclusive, and toIndex, exclusive. - * The returned list is backed by this list, so changes in the - * returned list are reflected in this list. - * - *

The semantics of the list returned by this method become - * undefined if the backing list (i.e., this list) is modified in - * any way other than via the returned list. - * - * @param fromIndex low endpoint (inclusive) of the subList - * @param toIndex high endpoint (exclusive) of the subList - * @return a view of the specified range within this list - * @throws IndexOutOfBoundsException {@inheritDoc} - */ - public List subList(int fromIndex, int toIndex) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - Object[] elements = getArray(); - int len = elements.length; - if (fromIndex < 0 || toIndex > len || fromIndex > toIndex) - throw new IndexOutOfBoundsException(); - return new COWSubList(this, fromIndex, toIndex); - } finally { - lock.unlock(); - } - } - - /** - * Sublist for CopyOnWriteArrayList. - * This class extends AbstractList merely for convenience, to - * avoid having to define addAll, etc. This doesn't hurt, but - * is wasteful. This class does not need or use modCount - * mechanics in AbstractList, but does need to check for - * concurrent modification using similar mechanics. On each - * operation, the array that we expect the backing list to use - * is checked and updated. Since we do this for all of the - * base operations invoked by those defined in AbstractList, - * all is well. While inefficient, this is not worth - * improving. The kinds of list operations inherited from - * AbstractList are already so slow on COW sublists that - * adding a bit more space/time doesn't seem even noticeable. - */ - private static class COWSubList - extends AbstractList - implements RandomAccess - { - private final CopyOnWriteArrayList l; - private final int offset; - private int size; - private Object[] expectedArray; - - // only call this holding l's lock - COWSubList(CopyOnWriteArrayList list, - int fromIndex, int toIndex) { - l = list; - expectedArray = l.getArray(); - offset = fromIndex; - size = toIndex - fromIndex; - } - - // only call this holding l's lock - private void checkForComodification() { - if (l.getArray() != expectedArray) - throw new ConcurrentModificationException(); - } - - // only call this holding l's lock - private void rangeCheck(int index) { - if (index<0 || index>=size) - throw new IndexOutOfBoundsException("Index: "+index+ - ",Size: "+size); - } - - public E set(int index, E element) { - final ReentrantLock lock = l.lock; - lock.lock(); - try { - rangeCheck(index); - checkForComodification(); - E x = l.set(index+offset, element); - expectedArray = l.getArray(); - return x; - } finally { - lock.unlock(); - } - } - - public E get(int index) { - final ReentrantLock lock = l.lock; - lock.lock(); - try { - rangeCheck(index); - checkForComodification(); - return l.get(index+offset); - } finally { - lock.unlock(); - } - } - - public int size() { - final ReentrantLock lock = l.lock; - lock.lock(); - try { - checkForComodification(); - return size; - } finally { - lock.unlock(); - } - } - - public void add(int index, E element) { - final ReentrantLock lock = l.lock; - lock.lock(); - try { - checkForComodification(); - if (index<0 || index>size) - throw new IndexOutOfBoundsException(); - l.add(index+offset, element); - expectedArray = l.getArray(); - size++; - } finally { - lock.unlock(); - } - } - - public void clear() { - final ReentrantLock lock = l.lock; - lock.lock(); - try { - checkForComodification(); - l.removeRange(offset, offset+size); - expectedArray = l.getArray(); - size = 0; - } finally { - lock.unlock(); - } - } - - public E remove(int index) { - final ReentrantLock lock = l.lock; - lock.lock(); - try { - rangeCheck(index); - checkForComodification(); - E result = l.remove(index+offset); - expectedArray = l.getArray(); - size--; - return result; - } finally { - lock.unlock(); - } - } - - public boolean remove(Object o) { - int index = indexOf(o); - if (index == -1) - return false; - remove(index); - return true; - } - - public Iterator iterator() { - final ReentrantLock lock = l.lock; - lock.lock(); - try { - checkForComodification(); - return new COWSubListIterator(l, 0, offset, size); - } finally { - lock.unlock(); - } - } - - public ListIterator listIterator(final int index) { - final ReentrantLock lock = l.lock; - lock.lock(); - try { - checkForComodification(); - if (index<0 || index>size) - throw new IndexOutOfBoundsException("Index: "+index+ - ", Size: "+size); - return new COWSubListIterator(l, index, offset, size); - } finally { - lock.unlock(); - } - } - - public List subList(int fromIndex, int toIndex) { - final ReentrantLock lock = l.lock; - lock.lock(); - try { - checkForComodification(); - if (fromIndex<0 || toIndex>size) - throw new IndexOutOfBoundsException(); - return new COWSubList(l, fromIndex + offset, - toIndex + offset); - } finally { - lock.unlock(); - } - } - - } - - - private static class COWSubListIterator implements ListIterator { - private final ListIterator i; - private final int index; - private final int offset; - private final int size; - - COWSubListIterator(List l, int index, int offset, - int size) { - this.index = index; - this.offset = offset; - this.size = size; - i = l.listIterator(index+offset); - } - - public boolean hasNext() { - return nextIndex() < size; - } - - public E next() { - if (hasNext()) - return i.next(); - else - throw new NoSuchElementException(); - } - - public boolean hasPrevious() { - return previousIndex() >= 0; - } - - public E previous() { - if (hasPrevious()) - return i.previous(); - else - throw new NoSuchElementException(); - } - - public int nextIndex() { - return i.nextIndex() - offset; - } - - public int previousIndex() { - return i.previousIndex() - offset; - } - - public void remove() { - throw new UnsupportedOperationException(); - } - - public void set(E e) { - throw new UnsupportedOperationException(); - } - - public void add(E e) { - throw new UnsupportedOperationException(); - } - } - - // Support for resetting lock while deserializing - private static final Unsafe unsafe = Unsafe.getUnsafe(); - private static final long lockOffset; - static { - try { - lockOffset = unsafe.objectFieldOffset - (CopyOnWriteArrayList.class.getDeclaredField("lock")); - } catch (Exception ex) { throw new Error(ex); } - } - private void resetLock() { - unsafe.putObjectVolatile(this, lockOffset, new ReentrantLock()); - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/CopyOnWriteArraySet.java b/libcore/concurrent/src/main/java/java/util/concurrent/CopyOnWriteArraySet.java deleted file mode 100644 index 65a05de45..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/CopyOnWriteArraySet.java +++ /dev/null @@ -1,364 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; -import java.util.*; - -// BEGIN android-note -// removed link to collections framework docs -// END android-note - -/** - * A {@link java.util.Set} that uses an internal {@link CopyOnWriteArrayList} - * for all of its operations. Thus, it shares the same basic properties: - *

    - *
  • It is best suited for applications in which set sizes generally - * stay small, read-only operations - * vastly outnumber mutative operations, and you need - * to prevent interference among threads during traversal. - *
  • It is thread-safe. - *
  • Mutative operations (add, set, remove, etc.) - * are expensive since they usually entail copying the entire underlying - * array. - *
  • Iterators do not support the mutative remove operation. - *
  • Traversal via iterators is fast and cannot encounter - * interference from other threads. Iterators rely on - * unchanging snapshots of the array at the time the iterators were - * constructed. - *
- * - *

Sample Usage. The following code sketch uses a - * copy-on-write set to maintain a set of Handler objects that - * perform some action upon state updates. - * - *

- * class Handler { void handle(); ... }
- *
- * class X {
- *    private final CopyOnWriteArraySet<Handler> handlers
- *       = new CopyOnWriteArraySet<Handler>();
- *    public void addHandler(Handler h) { handlers.add(h); }
- *
- *    private long internalState;
- *    private synchronized void changeState() { internalState = ...; }
- *
- *    public void update() {
- *       changeState();
- *       for (Handler handler : handlers)
- *          handler.handle();
- *    }
- * }
- * 
- * - * @see CopyOnWriteArrayList - * @since 1.5 - * @author Doug Lea - * @param the type of elements held in this collection - */ -public class CopyOnWriteArraySet extends AbstractSet - implements java.io.Serializable { - private static final long serialVersionUID = 5457747651344034263L; - - private final CopyOnWriteArrayList al; - - /** - * Creates an empty set. - */ - public CopyOnWriteArraySet() { - al = new CopyOnWriteArrayList(); - } - - /** - * Creates a set containing all of the elements of the specified - * collection. - * - * @param c the collection of elements to initially contain - * @throws NullPointerException if the specified collection is null - */ - public CopyOnWriteArraySet(Collection c) { - al = new CopyOnWriteArrayList(); - al.addAllAbsent(c); - } - - /** - * Returns the number of elements in this set. - * - * @return the number of elements in this set - */ - public int size() { - return al.size(); - } - - /** - * Returns true if this set contains no elements. - * - * @return true if this set contains no elements - */ - public boolean isEmpty() { - return al.isEmpty(); - } - - /** - * Returns true if this set contains the specified element. - * More formally, returns true if and only if this set - * contains an element e such that - * (o==null ? e==null : o.equals(e)). - * - * @param o element whose presence in this set is to be tested - * @return true if this set contains the specified element - */ - public boolean contains(Object o) { - return al.contains(o); - } - - /** - * Returns an array containing all of the elements in this set. - * If this set makes any guarantees as to what order its elements - * are returned by its iterator, this method must return the - * elements in the same order. - * - *

The returned array will be "safe" in that no references to it - * are maintained by this set. (In other words, this method must - * allocate a new array even if this set is backed by an array). - * The caller is thus free to modify the returned array. - * - *

This method acts as bridge between array-based and collection-based - * APIs. - * - * @return an array containing all the elements in this set - */ - public Object[] toArray() { - return al.toArray(); - } - - /** - * Returns an array containing all of the elements in this set; the - * runtime type of the returned array is that of the specified array. - * If the set fits in the specified array, it is returned therein. - * Otherwise, a new array is allocated with the runtime type of the - * specified array and the size of this set. - * - *

If this set fits in the specified array with room to spare - * (i.e., the array has more elements than this set), the element in - * the array immediately following the end of the set is set to - * null. (This is useful in determining the length of this - * set only if the caller knows that this set does not contain - * any null elements.) - * - *

If this set makes any guarantees as to what order its elements - * are returned by its iterator, this method must return the elements - * in the same order. - * - *

Like the {@link #toArray()} method, this method acts as bridge between - * array-based and collection-based APIs. Further, this method allows - * precise control over the runtime type of the output array, and may, - * under certain circumstances, be used to save allocation costs. - * - *

Suppose x is a set known to contain only strings. - * The following code can be used to dump the set into a newly allocated - * array of String: - * - *

-     *     String[] y = x.toArray(new String[0]);
- * - * Note that toArray(new Object[0]) is identical in function to - * toArray(). - * - * @param a the array into which the elements of this set are to be - * stored, if it is big enough; otherwise, a new array of the same - * runtime type is allocated for this purpose. - * @return an array containing all the elements in this set - * @throws ArrayStoreException if the runtime type of the specified array - * is not a supertype of the runtime type of every element in this - * set - * @throws NullPointerException if the specified array is null - */ - public T[] toArray(T[] a) { - return al.toArray(a); - } - - /** - * Removes all of the elements from this set. - * The set will be empty after this call returns. - */ - public void clear() { - al.clear(); - } - - /** - * Removes the specified element from this set if it is present. - * More formally, removes an element e such that - * (o==null ? e==null : o.equals(e)), - * if this set contains such an element. Returns true if - * this set contained the element (or equivalently, if this set - * changed as a result of the call). (This set will not contain the - * element once the call returns.) - * - * @param o object to be removed from this set, if present - * @return true if this set contained the specified element - */ - public boolean remove(Object o) { - return al.remove(o); - } - - /** - * Adds the specified element to this set if it is not already present. - * More formally, adds the specified element e to this set if - * the set contains no element e2 such that - * (e==null ? e2==null : e.equals(e2)). - * If this set already contains the element, the call leaves the set - * unchanged and returns false. - * - * @param e element to be added to this set - * @return true if this set did not already contain the specified - * element - */ - public boolean add(E e) { - return al.addIfAbsent(e); - } - - /** - * Returns true if this set contains all of the elements of the - * specified collection. If the specified collection is also a set, this - * method returns true if it is a subset of this set. - * - * @param c collection to be checked for containment in this set - * @return true if this set contains all of the elements of the - * specified collection - * @throws NullPointerException if the specified collection is null - * @see #contains(Object) - */ - public boolean containsAll(Collection c) { - return al.containsAll(c); - } - - /** - * Adds all of the elements in the specified collection to this set if - * they're not already present. If the specified collection is also a - * set, the addAll operation effectively modifies this set so - * that its value is the union of the two sets. The behavior of - * this operation is undefined if the specified collection is modified - * while the operation is in progress. - * - * @param c collection containing elements to be added to this set - * @return true if this set changed as a result of the call - * @throws NullPointerException if the specified collection is null - * @see #add(Object) - */ - public boolean addAll(Collection c) { - return al.addAllAbsent(c) > 0; - } - - /** - * Removes from this set all of its elements that are contained in the - * specified collection. If the specified collection is also a set, - * this operation effectively modifies this set so that its value is the - * asymmetric set difference of the two sets. - * - * @param c collection containing elements to be removed from this set - * @return true if this set changed as a result of the call - * @throws ClassCastException if the class of an element of this set - * is incompatible with the specified collection (optional) - * @throws NullPointerException if this set contains a null element and the - * specified collection does not permit null elements (optional), - * or if the specified collection is null - * @see #remove(Object) - */ - public boolean removeAll(Collection c) { - return al.removeAll(c); - } - - /** - * Retains only the elements in this set that are contained in the - * specified collection. In other words, removes from this set all of - * its elements that are not contained in the specified collection. If - * the specified collection is also a set, this operation effectively - * modifies this set so that its value is the intersection of the - * two sets. - * - * @param c collection containing elements to be retained in this set - * @return true if this set changed as a result of the call - * @throws ClassCastException if the class of an element of this set - * is incompatible with the specified collection (optional) - * @throws NullPointerException if this set contains a null element and the - * specified collection does not permit null elements (optional), - * or if the specified collection is null - * @see #remove(Object) - */ - public boolean retainAll(Collection c) { - return al.retainAll(c); - } - - /** - * Returns an iterator over the elements contained in this set - * in the order in which these elements were added. - * - *

The returned iterator provides a snapshot of the state of the set - * when the iterator was constructed. No synchronization is needed while - * traversing the iterator. The iterator does NOT support the - * remove method. - * - * @return an iterator over the elements in this set - */ - public Iterator iterator() { - return al.iterator(); - } - - /** - * Compares the specified object with this set for equality. - * Returns {@code true} if the specified object is the same object - * as this object, or if it is also a {@link Set} and the elements - * returned by an {@linkplain List#iterator() iterator} over the - * specified set are the same as the elements returned by an - * iterator over this set. More formally, the two iterators are - * considered to return the same elements if they return the same - * number of elements and for every element {@code e1} returned by - * the iterator over the specified set, there is an element - * {@code e2} returned by the iterator over this set such that - * {@code (e1==null ? e2==null : e1.equals(e2))}. - * - * @param o object to be compared for equality with this set - * @return {@code true} if the specified object is equal to this set - */ - public boolean equals(Object o) { - if (o == this) - return true; - if (!(o instanceof Set)) - return false; - Set set = (Set)(o); - Iterator it = set.iterator(); - - // Uses O(n^2) algorithm that is only appropriate - // for small sets, which CopyOnWriteArraySets should be. - - // Use a single snapshot of underlying array - Object[] elements = al.getArray(); - int len = elements.length; - // Mark matched elements to avoid re-checking - boolean[] matched = new boolean[len]; - int k = 0; - outer: while (it.hasNext()) { - if (++k > len) - return false; - Object x = it.next(); - for (int i = 0; i < len; ++i) { - if (!matched[i] && eq(x, elements[i])) { - matched[i] = true; - continue outer; - } - } - return false; - } - return k == len; - } - - /** - * Test for equality, coping with nulls. - */ - private static boolean eq(Object o1, Object o2) { - return (o1 == null ? o2 == null : o1.equals(o2)); - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/CountDownLatch.java b/libcore/concurrent/src/main/java/java/util/concurrent/CountDownLatch.java deleted file mode 100644 index 2b945dd51..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/CountDownLatch.java +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; -import java.util.concurrent.locks.*; -import java.util.concurrent.atomic.*; - -/** - * A synchronization aid that allows one or more threads to wait until - * a set of operations being performed in other threads completes. - * - *

A {@code CountDownLatch} is initialized with a given count. - * The {@link #await await} methods block until the current count reaches - * zero due to invocations of the {@link #countDown} method, after which - * all waiting threads are released and any subsequent invocations of - * {@link #await await} return immediately. This is a one-shot phenomenon - * -- the count cannot be reset. If you need a version that resets the - * count, consider using a {@link CyclicBarrier}. - * - *

A {@code CountDownLatch} is a versatile synchronization tool - * and can be used for a number of purposes. A - * {@code CountDownLatch} initialized with a count of one serves as a - * simple on/off latch, or gate: all threads invoking {@link #await await} - * wait at the gate until it is opened by a thread invoking {@link - * #countDown}. A {@code CountDownLatch} initialized to N - * can be used to make one thread wait until N threads have - * completed some action, or some action has been completed N times. - * - *

A useful property of a {@code CountDownLatch} is that it - * doesn't require that threads calling {@code countDown} wait for - * the count to reach zero before proceeding, it simply prevents any - * thread from proceeding past an {@link #await await} until all - * threads could pass. - * - *

Sample usage: Here is a pair of classes in which a group - * of worker threads use two countdown latches: - *

    - *
  • The first is a start signal that prevents any worker from proceeding - * until the driver is ready for them to proceed; - *
  • The second is a completion signal that allows the driver to wait - * until all workers have completed. - *
- * - *
- * class Driver { // ...
- *   void main() throws InterruptedException {
- *     CountDownLatch startSignal = new CountDownLatch(1);
- *     CountDownLatch doneSignal = new CountDownLatch(N);
- *
- *     for (int i = 0; i < N; ++i) // create and start threads
- *       new Thread(new Worker(startSignal, doneSignal)).start();
- *
- *     doSomethingElse();            // don't let run yet
- *     startSignal.countDown();      // let all threads proceed
- *     doSomethingElse();
- *     doneSignal.await();           // wait for all to finish
- *   }
- * }
- *
- * class Worker implements Runnable {
- *   private final CountDownLatch startSignal;
- *   private final CountDownLatch doneSignal;
- *   Worker(CountDownLatch startSignal, CountDownLatch doneSignal) {
- *      this.startSignal = startSignal;
- *      this.doneSignal = doneSignal;
- *   }
- *   public void run() {
- *      try {
- *        startSignal.await();
- *        doWork();
- *        doneSignal.countDown();
- *      } catch (InterruptedException ex) {} // return;
- *   }
- *
- *   void doWork() { ... }
- * }
- *
- * 
- * - *

Another typical usage would be to divide a problem into N parts, - * describe each part with a Runnable that executes that portion and - * counts down on the latch, and queue all the Runnables to an - * Executor. When all sub-parts are complete, the coordinating thread - * will be able to pass through await. (When threads must repeatedly - * count down in this way, instead use a {@link CyclicBarrier}.) - * - *

- * class Driver2 { // ...
- *   void main() throws InterruptedException {
- *     CountDownLatch doneSignal = new CountDownLatch(N);
- *     Executor e = ...
- *
- *     for (int i = 0; i < N; ++i) // create and start threads
- *       e.execute(new WorkerRunnable(doneSignal, i));
- *
- *     doneSignal.await();           // wait for all to finish
- *   }
- * }
- *
- * class WorkerRunnable implements Runnable {
- *   private final CountDownLatch doneSignal;
- *   private final int i;
- *   WorkerRunnable(CountDownLatch doneSignal, int i) {
- *      this.doneSignal = doneSignal;
- *      this.i = i;
- *   }
- *   public void run() {
- *      try {
- *        doWork(i);
- *        doneSignal.countDown();
- *      } catch (InterruptedException ex) {} // return;
- *   }
- *
- *   void doWork() { ... }
- * }
- *
- * 
- * - *

Memory consistency effects: Until the count reaches - * zero, actions in a thread prior to calling - * {@code countDown()} - * happen-before - * actions following a successful return from a corresponding - * {@code await()} in another thread. - * - * @since 1.5 - * @author Doug Lea - */ -public class CountDownLatch { - /** - * Synchronization control For CountDownLatch. - * Uses AQS state to represent count. - */ - private static final class Sync extends AbstractQueuedSynchronizer { - private static final long serialVersionUID = 4982264981922014374L; - - Sync(int count) { - setState(count); - } - - int getCount() { - return getState(); - } - - protected int tryAcquireShared(int acquires) { - return getState() == 0? 1 : -1; - } - - protected boolean tryReleaseShared(int releases) { - // Decrement count; signal when transition to zero - for (;;) { - int c = getState(); - if (c == 0) - return false; - int nextc = c-1; - if (compareAndSetState(c, nextc)) - return nextc == 0; - } - } - } - - private final Sync sync; - - /** - * Constructs a {@code CountDownLatch} initialized with the given count. - * - * @param count the number of times {@link #countDown} must be invoked - * before threads can pass through {@link #await} - * @throws IllegalArgumentException if {@code count} is negative - */ - public CountDownLatch(int count) { - if (count < 0) throw new IllegalArgumentException("count < 0"); - this.sync = new Sync(count); - } - - /** - * Causes the current thread to wait until the latch has counted down to - * zero, unless the thread is {@linkplain Thread#interrupt interrupted}. - * - *

If the current count is zero then this method returns immediately. - * - *

If the current count is greater than zero then the current - * thread becomes disabled for thread scheduling purposes and lies - * dormant until one of two things happen: - *

    - *
  • The count reaches zero due to invocations of the - * {@link #countDown} method; or - *
  • Some other thread {@linkplain Thread#interrupt interrupts} - * the current thread. - *
- * - *

If the current thread: - *

    - *
  • has its interrupted status set on entry to this method; or - *
  • is {@linkplain Thread#interrupt interrupted} while waiting, - *
- * then {@link InterruptedException} is thrown and the current thread's - * interrupted status is cleared. - * - * @throws InterruptedException if the current thread is interrupted - * while waiting - */ - public void await() throws InterruptedException { - sync.acquireSharedInterruptibly(1); - } - - /** - * Causes the current thread to wait until the latch has counted down to - * zero, unless the thread is {@linkplain Thread#interrupt interrupted}, - * or the specified waiting time elapses. - * - *

If the current count is zero then this method returns immediately - * with the value {@code true}. - * - *

If the current count is greater than zero then the current - * thread becomes disabled for thread scheduling purposes and lies - * dormant until one of three things happen: - *

    - *
  • The count reaches zero due to invocations of the - * {@link #countDown} method; or - *
  • Some other thread {@linkplain Thread#interrupt interrupts} - * the current thread; or - *
  • The specified waiting time elapses. - *
- * - *

If the count reaches zero then the method returns with the - * value {@code true}. - * - *

If the current thread: - *

    - *
  • has its interrupted status set on entry to this method; or - *
  • is {@linkplain Thread#interrupt interrupted} while waiting, - *
- * then {@link InterruptedException} is thrown and the current thread's - * interrupted status is cleared. - * - *

If the specified waiting time elapses then the value {@code false} - * is returned. If the time is less than or equal to zero, the method - * will not wait at all. - * - * @param timeout the maximum time to wait - * @param unit the time unit of the {@code timeout} argument - * @return {@code true} if the count reached zero and {@code false} - * if the waiting time elapsed before the count reached zero - * @throws InterruptedException if the current thread is interrupted - * while waiting - */ - public boolean await(long timeout, TimeUnit unit) - throws InterruptedException { - return sync.tryAcquireSharedNanos(1, unit.toNanos(timeout)); - } - - /** - * Decrements the count of the latch, releasing all waiting threads if - * the count reaches zero. - * - *

If the current count is greater than zero then it is decremented. - * If the new count is zero then all waiting threads are re-enabled for - * thread scheduling purposes. - * - *

If the current count equals zero then nothing happens. - */ - public void countDown() { - sync.releaseShared(1); - } - - /** - * Returns the current count. - * - *

This method is typically used for debugging and testing purposes. - * - * @return the current count - */ - public long getCount() { - return sync.getCount(); - } - - /** - * Returns a string identifying this latch, as well as its state. - * The state, in brackets, includes the String {@code "Count ="} - * followed by the current count. - * - * @return a string identifying this latch, as well as its state - */ - public String toString() { - return super.toString() + "[Count = " + sync.getCount() + "]"; - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/CyclicBarrier.java b/libcore/concurrent/src/main/java/java/util/concurrent/CyclicBarrier.java deleted file mode 100644 index d5738c5ae..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/CyclicBarrier.java +++ /dev/null @@ -1,454 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; -import java.util.concurrent.locks.*; - -/** - * A synchronization aid that allows a set of threads to all wait for - * each other to reach a common barrier point. CyclicBarriers are - * useful in programs involving a fixed sized party of threads that - * must occasionally wait for each other. The barrier is called - * cyclic because it can be re-used after the waiting threads - * are released. - * - *

A CyclicBarrier supports an optional {@link Runnable} command - * that is run once per barrier point, after the last thread in the party - * arrives, but before any threads are released. - * This barrier action is useful - * for updating shared-state before any of the parties continue. - * - *

Sample usage: Here is an example of - * using a barrier in a parallel decomposition design: - *

- * class Solver {
- *   final int N;
- *   final float[][] data;
- *   final CyclicBarrier barrier;
- *
- *   class Worker implements Runnable {
- *     int myRow;
- *     Worker(int row) { myRow = row; }
- *     public void run() {
- *       while (!done()) {
- *         processRow(myRow);
- *
- *         try {
- *           barrier.await();
- *         } catch (InterruptedException ex) {
- *           return;
- *         } catch (BrokenBarrierException ex) {
- *           return;
- *         }
- *       }
- *     }
- *   }
- *
- *   public Solver(float[][] matrix) {
- *     data = matrix;
- *     N = matrix.length;
- *     barrier = new CyclicBarrier(N,
- *                                 new Runnable() {
- *                                   public void run() {
- *                                     mergeRows(...);
- *                                   }
- *                                 });
- *     for (int i = 0; i < N; ++i)
- *       new Thread(new Worker(i)).start();
- *
- *     waitUntilDone();
- *   }
- * }
- * 
- * Here, each worker thread processes a row of the matrix then waits at the - * barrier until all rows have been processed. When all rows are processed - * the supplied {@link Runnable} barrier action is executed and merges the - * rows. If the merger - * determines that a solution has been found then done() will return - * true and each worker will terminate. - * - *

If the barrier action does not rely on the parties being suspended when - * it is executed, then any of the threads in the party could execute that - * action when it is released. To facilitate this, each invocation of - * {@link #await} returns the arrival index of that thread at the barrier. - * You can then choose which thread should execute the barrier action, for - * example: - *

  if (barrier.await() == 0) {
- *     // log the completion of this iteration
- *   }
- * - *

The CyclicBarrier uses an all-or-none breakage model - * for failed synchronization attempts: If a thread leaves a barrier - * point prematurely because of interruption, failure, or timeout, all - * other threads waiting at that barrier point will also leave - * abnormally via {@link BrokenBarrierException} (or - * {@link InterruptedException} if they too were interrupted at about - * the same time). - * - *

Memory consistency effects: Actions in a thread prior to calling - * {@code await()} - * happen-before - * actions that are part of the barrier action, which in turn - * happen-before actions following a successful return from the - * corresponding {@code await()} in other threads. - * - * @since 1.5 - * @see CountDownLatch - * - * @author Doug Lea - */ -public class CyclicBarrier { - /** - * Each use of the barrier is represented as a generation instance. - * The generation changes whenever the barrier is tripped, or - * is reset. There can be many generations associated with threads - * using the barrier - due to the non-deterministic way the lock - * may be allocated to waiting threads - but only one of these - * can be active at a time (the one to which count applies) - * and all the rest are either broken or tripped. - * There need not be an active generation if there has been a break - * but no subsequent reset. - */ - private static class Generation { - boolean broken = false; - } - - /** The lock for guarding barrier entry */ - private final ReentrantLock lock = new ReentrantLock(); - /** Condition to wait on until tripped */ - private final Condition trip = lock.newCondition(); - /** The number of parties */ - private final int parties; - /* The command to run when tripped */ - private final Runnable barrierCommand; - /** The current generation */ - private Generation generation = new Generation(); - - /** - * Number of parties still waiting. Counts down from parties to 0 - * on each generation. It is reset to parties on each new - * generation or when broken. - */ - private int count; - - /** - * Updates state on barrier trip and wakes up everyone. - * Called only while holding lock. - */ - private void nextGeneration() { - // signal completion of last generation - trip.signalAll(); - // set up next generation - count = parties; - generation = new Generation(); - } - - /** - * Sets current barrier generation as broken and wakes up everyone. - * Called only while holding lock. - */ - private void breakBarrier() { - generation.broken = true; - count = parties; - trip.signalAll(); - } - - /** - * Main barrier code, covering the various policies. - */ - private int dowait(boolean timed, long nanos) - throws InterruptedException, BrokenBarrierException, - TimeoutException { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - final Generation g = generation; - - if (g.broken) - throw new BrokenBarrierException(); - - if (Thread.interrupted()) { - breakBarrier(); - throw new InterruptedException(); - } - - int index = --count; - if (index == 0) { // tripped - boolean ranAction = false; - try { - final Runnable command = barrierCommand; - if (command != null) - command.run(); - ranAction = true; - nextGeneration(); - return 0; - } finally { - if (!ranAction) - breakBarrier(); - } - } - - // loop until tripped, broken, interrupted, or timed out - for (;;) { - try { - if (!timed) - trip.await(); - else if (nanos > 0L) - nanos = trip.awaitNanos(nanos); - } catch (InterruptedException ie) { - if (g == generation && ! g.broken) { - breakBarrier(); - throw ie; - } else { - // We're about to finish waiting even if we had not - // been interrupted, so this interrupt is deemed to - // "belong" to subsequent execution. - Thread.currentThread().interrupt(); - } - } - - if (g.broken) - throw new BrokenBarrierException(); - - if (g != generation) - return index; - - if (timed && nanos <= 0L) { - breakBarrier(); - throw new TimeoutException(); - } - } - } finally { - lock.unlock(); - } - } - - /** - * Creates a new CyclicBarrier that will trip when the - * given number of parties (threads) are waiting upon it, and which - * will execute the given barrier action when the barrier is tripped, - * performed by the last thread entering the barrier. - * - * @param parties the number of threads that must invoke {@link #await} - * before the barrier is tripped - * @param barrierAction the command to execute when the barrier is - * tripped, or {@code null} if there is no action - * @throws IllegalArgumentException if {@code parties} is less than 1 - */ - public CyclicBarrier(int parties, Runnable barrierAction) { - if (parties <= 0) throw new IllegalArgumentException(); - this.parties = parties; - this.count = parties; - this.barrierCommand = barrierAction; - } - - /** - * Creates a new CyclicBarrier that will trip when the - * given number of parties (threads) are waiting upon it, and - * does not perform a predefined action when the barrier is tripped. - * - * @param parties the number of threads that must invoke {@link #await} - * before the barrier is tripped - * @throws IllegalArgumentException if {@code parties} is less than 1 - */ - public CyclicBarrier(int parties) { - this(parties, null); - } - - /** - * Returns the number of parties required to trip this barrier. - * - * @return the number of parties required to trip this barrier - */ - public int getParties() { - return parties; - } - - /** - * Waits until all {@linkplain #getParties parties} have invoked - * await on this barrier. - * - *

If the current thread is not the last to arrive then it is - * disabled for thread scheduling purposes and lies dormant until - * one of the following things happens: - *

    - *
  • The last thread arrives; or - *
  • Some other thread {@linkplain Thread#interrupt interrupts} - * the current thread; or - *
  • Some other thread {@linkplain Thread#interrupt interrupts} - * one of the other waiting threads; or - *
  • Some other thread times out while waiting for barrier; or - *
  • Some other thread invokes {@link #reset} on this barrier. - *
- * - *

If the current thread: - *

    - *
  • has its interrupted status set on entry to this method; or - *
  • is {@linkplain Thread#interrupt interrupted} while waiting - *
- * then {@link InterruptedException} is thrown and the current thread's - * interrupted status is cleared. - * - *

If the barrier is {@link #reset} while any thread is waiting, - * or if the barrier {@linkplain #isBroken is broken} when - * await is invoked, or while any thread is waiting, then - * {@link BrokenBarrierException} is thrown. - * - *

If any thread is {@linkplain Thread#interrupt interrupted} while waiting, - * then all other waiting threads will throw - * {@link BrokenBarrierException} and the barrier is placed in the broken - * state. - * - *

If the current thread is the last thread to arrive, and a - * non-null barrier action was supplied in the constructor, then the - * current thread runs the action before allowing the other threads to - * continue. - * If an exception occurs during the barrier action then that exception - * will be propagated in the current thread and the barrier is placed in - * the broken state. - * - * @return the arrival index of the current thread, where index - * {@link #getParties()} - 1 indicates the first - * to arrive and zero indicates the last to arrive - * @throws InterruptedException if the current thread was interrupted - * while waiting - * @throws BrokenBarrierException if another thread was - * interrupted or timed out while the current thread was - * waiting, or the barrier was reset, or the barrier was - * broken when {@code await} was called, or the barrier - * action (if present) failed due an exception. - */ - public int await() throws InterruptedException, BrokenBarrierException { - try { - return dowait(false, 0L); - } catch (TimeoutException toe) { - throw new Error(toe); // cannot happen; - } - } - - /** - * Waits until all {@linkplain #getParties parties} have invoked - * await on this barrier, or the specified waiting time elapses. - * - *

If the current thread is not the last to arrive then it is - * disabled for thread scheduling purposes and lies dormant until - * one of the following things happens: - *

    - *
  • The last thread arrives; or - *
  • The specified timeout elapses; or - *
  • Some other thread {@linkplain Thread#interrupt interrupts} - * the current thread; or - *
  • Some other thread {@linkplain Thread#interrupt interrupts} - * one of the other waiting threads; or - *
  • Some other thread times out while waiting for barrier; or - *
  • Some other thread invokes {@link #reset} on this barrier. - *
- * - *

If the current thread: - *

    - *
  • has its interrupted status set on entry to this method; or - *
  • is {@linkplain Thread#interrupt interrupted} while waiting - *
- * then {@link InterruptedException} is thrown and the current thread's - * interrupted status is cleared. - * - *

If the specified waiting time elapses then {@link TimeoutException} - * is thrown. If the time is less than or equal to zero, the - * method will not wait at all. - * - *

If the barrier is {@link #reset} while any thread is waiting, - * or if the barrier {@linkplain #isBroken is broken} when - * await is invoked, or while any thread is waiting, then - * {@link BrokenBarrierException} is thrown. - * - *

If any thread is {@linkplain Thread#interrupt interrupted} while - * waiting, then all other waiting threads will throw {@link - * BrokenBarrierException} and the barrier is placed in the broken - * state. - * - *

If the current thread is the last thread to arrive, and a - * non-null barrier action was supplied in the constructor, then the - * current thread runs the action before allowing the other threads to - * continue. - * If an exception occurs during the barrier action then that exception - * will be propagated in the current thread and the barrier is placed in - * the broken state. - * - * @param timeout the time to wait for the barrier - * @param unit the time unit of the timeout parameter - * @return the arrival index of the current thread, where index - * {@link #getParties()} - 1 indicates the first - * to arrive and zero indicates the last to arrive - * @throws InterruptedException if the current thread was interrupted - * while waiting - * @throws TimeoutException if the specified timeout elapses - * @throws BrokenBarrierException if another thread was - * interrupted or timed out while the current thread was - * waiting, or the barrier was reset, or the barrier was broken - * when {@code await} was called, or the barrier action (if - * present) failed due an exception - */ - public int await(long timeout, TimeUnit unit) - throws InterruptedException, - BrokenBarrierException, - TimeoutException { - return dowait(true, unit.toNanos(timeout)); - } - - /** - * Queries if this barrier is in a broken state. - * - * @return {@code true} if one or more parties broke out of this - * barrier due to interruption or timeout since - * construction or the last reset, or a barrier action - * failed due to an exception; {@code false} otherwise. - */ - public boolean isBroken() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return generation.broken; - } finally { - lock.unlock(); - } - } - - /** - * Resets the barrier to its initial state. If any parties are - * currently waiting at the barrier, they will return with a - * {@link BrokenBarrierException}. Note that resets after - * a breakage has occurred for other reasons can be complicated to - * carry out; threads need to re-synchronize in some other way, - * and choose one to perform the reset. It may be preferable to - * instead create a new barrier for subsequent use. - */ - public void reset() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - breakBarrier(); // break the current generation - nextGeneration(); // start a new generation - } finally { - lock.unlock(); - } - } - - /** - * Returns the number of parties currently waiting at the barrier. - * This method is primarily useful for debugging and assertions. - * - * @return the number of parties currently blocked in {@link #await} - */ - public int getNumberWaiting() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return parties - count; - } finally { - lock.unlock(); - } - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/DelayQueue.java b/libcore/concurrent/src/main/java/java/util/concurrent/DelayQueue.java deleted file mode 100644 index 52ac4a087..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/DelayQueue.java +++ /dev/null @@ -1,515 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - - -package java.util.concurrent; -import java.util.concurrent.locks.*; -import java.util.*; - -// BEGIN android-note -// removed link to collections framework docs -// END android-note - -/** - * An unbounded {@linkplain BlockingQueue blocking queue} of - * Delayed elements, in which an element can only be taken - * when its delay has expired. The head of the queue is that - * Delayed element whose delay expired furthest in the - * past. If no delay has expired there is no head and poll - * will return null. Expiration occurs when an element's - * getDelay(TimeUnit.NANOSECONDS) method returns a value less - * than or equal to zero. Even though unexpired elements cannot be - * removed using take or poll, they are otherwise - * treated as normal elements. For example, the size method - * returns the count of both expired and unexpired elements. - * This queue does not permit null elements. - * - *

This class and its iterator implement all of the - * optional methods of the {@link Collection} and {@link - * Iterator} interfaces. - * - * @since 1.5 - * @author Doug Lea - * @param the type of elements held in this collection - */ - -public class DelayQueue extends AbstractQueue - implements BlockingQueue { - - private transient final ReentrantLock lock = new ReentrantLock(); - private final PriorityQueue q = new PriorityQueue(); - - /** - * Thread designated to wait for the element at the head of - * the queue. This variant of the Leader-Follower pattern - * (http://www.cs.wustl.edu/~schmidt/POSA/POSA2/) serves to - * minimize unnecessary timed waiting. When a thread becomes - * the leader, it waits only for the next delay to elapse, but - * other threads await indefinitely. The leader thread must - * signal some other thread before returning from take() or - * poll(...), unless some other thread becomes leader in the - * interim. Whenever the head of the queue is replaced with - * an element with an earlier expiration time, the leader - * field is invalidated by being reset to null, and some - * waiting thread, but not necessarily the current leader, is - * signalled. So waiting threads must be prepared to acquire - * and lose leadership while waiting. - */ - private Thread leader = null; - - /** - * Condition signalled when a newer element becomes available - * at the head of the queue or a new thread may need to - * become leader. - */ - private final Condition available = lock.newCondition(); - - /** - * Creates a new DelayQueue that is initially empty. - */ - public DelayQueue() {} - - /** - * Creates a DelayQueue initially containing the elements of the - * given collection of {@link Delayed} instances. - * - * @param c the collection of elements to initially contain - * @throws NullPointerException if the specified collection or any - * of its elements are null - */ - public DelayQueue(Collection c) { - this.addAll(c); - } - - /** - * Inserts the specified element into this delay queue. - * - * @param e the element to add - * @return true (as specified by {@link Collection#add}) - * @throws NullPointerException if the specified element is null - */ - public boolean add(E e) { - return offer(e); - } - - /** - * Inserts the specified element into this delay queue. - * - * @param e the element to add - * @return true - * @throws NullPointerException if the specified element is null - */ - public boolean offer(E e) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - q.offer(e); - if (q.peek() == e) { - leader = null; - available.signal(); - } - return true; - } finally { - lock.unlock(); - } - } - - /** - * Inserts the specified element into this delay queue. As the queue is - * unbounded this method will never block. - * - * @param e the element to add - * @throws NullPointerException {@inheritDoc} - */ - public void put(E e) { - offer(e); - } - - /** - * Inserts the specified element into this delay queue. As the queue is - * unbounded this method will never block. - * - * @param e the element to add - * @param timeout This parameter is ignored as the method never blocks - * @param unit This parameter is ignored as the method never blocks - * @return true - * @throws NullPointerException {@inheritDoc} - */ - public boolean offer(E e, long timeout, TimeUnit unit) { - return offer(e); - } - - /** - * Retrieves and removes the head of this queue, or returns null - * if this queue has no elements with an expired delay. - * - * @return the head of this queue, or null if this - * queue has no elements with an expired delay - */ - public E poll() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - E first = q.peek(); - if (first == null || first.getDelay(TimeUnit.NANOSECONDS) > 0) - return null; - else - return q.poll(); - } finally { - lock.unlock(); - } - } - - /** - * Retrieves and removes the head of this queue, waiting if necessary - * until an element with an expired delay is available on this queue. - * - * @return the head of this queue - * @throws InterruptedException {@inheritDoc} - */ - public E take() throws InterruptedException { - final ReentrantLock lock = this.lock; - lock.lockInterruptibly(); - try { - for (;;) { - E first = q.peek(); - if (first == null) - available.await(); - else { - long delay = first.getDelay(TimeUnit.NANOSECONDS); - if (delay <= 0) - return q.poll(); - else if (leader != null) - available.await(); - else { - Thread thisThread = Thread.currentThread(); - leader = thisThread; - try { - available.awaitNanos(delay); - } finally { - if (leader == thisThread) - leader = null; - } - } - } - } - } finally { - if (leader == null && q.peek() != null) - available.signal(); - lock.unlock(); - } - } - - /** - * Retrieves and removes the head of this queue, waiting if necessary - * until an element with an expired delay is available on this queue, - * or the specified wait time expires. - * - * @return the head of this queue, or null if the - * specified waiting time elapses before an element with - * an expired delay becomes available - * @throws InterruptedException {@inheritDoc} - */ - public E poll(long timeout, TimeUnit unit) throws InterruptedException { - long nanos = unit.toNanos(timeout); - final ReentrantLock lock = this.lock; - lock.lockInterruptibly(); - try { - for (;;) { - E first = q.peek(); - if (first == null) { - if (nanos <= 0) - return null; - else - nanos = available.awaitNanos(nanos); - } else { - long delay = first.getDelay(TimeUnit.NANOSECONDS); - if (delay <= 0) - return q.poll(); - if (nanos <= 0) - return null; - if (nanos < delay || leader != null) - nanos = available.awaitNanos(nanos); - else { - Thread thisThread = Thread.currentThread(); - leader = thisThread; - try { - long timeLeft = available.awaitNanos(delay); - nanos -= delay - timeLeft; - } finally { - if (leader == thisThread) - leader = null; - } - } - } - } - } finally { - if (leader == null && q.peek() != null) - available.signal(); - lock.unlock(); - } - } - - /** - * Retrieves, but does not remove, the head of this queue, or - * returns null if this queue is empty. Unlike - * poll, if no expired elements are available in the queue, - * this method returns the element that will expire next, - * if one exists. - * - * @return the head of this queue, or null if this - * queue is empty. - */ - public E peek() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return q.peek(); - } finally { - lock.unlock(); - } - } - - public int size() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return q.size(); - } finally { - lock.unlock(); - } - } - - /** - * @throws UnsupportedOperationException {@inheritDoc} - * @throws ClassCastException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - * @throws IllegalArgumentException {@inheritDoc} - */ - public int drainTo(Collection c) { - if (c == null) - throw new NullPointerException(); - if (c == this) - throw new IllegalArgumentException(); - final ReentrantLock lock = this.lock; - lock.lock(); - try { - int n = 0; - for (;;) { - E first = q.peek(); - if (first == null || first.getDelay(TimeUnit.NANOSECONDS) > 0) - break; - c.add(q.poll()); - ++n; - } - return n; - } finally { - lock.unlock(); - } - } - - /** - * @throws UnsupportedOperationException {@inheritDoc} - * @throws ClassCastException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - * @throws IllegalArgumentException {@inheritDoc} - */ - public int drainTo(Collection c, int maxElements) { - if (c == null) - throw new NullPointerException(); - if (c == this) - throw new IllegalArgumentException(); - if (maxElements <= 0) - return 0; - final ReentrantLock lock = this.lock; - lock.lock(); - try { - int n = 0; - while (n < maxElements) { - E first = q.peek(); - if (first == null || first.getDelay(TimeUnit.NANOSECONDS) > 0) - break; - c.add(q.poll()); - ++n; - } - return n; - } finally { - lock.unlock(); - } - } - - /** - * Atomically removes all of the elements from this delay queue. - * The queue will be empty after this call returns. - * Elements with an unexpired delay are not waited for; they are - * simply discarded from the queue. - */ - public void clear() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - q.clear(); - } finally { - lock.unlock(); - } - } - - /** - * Always returns Integer.MAX_VALUE because - * a DelayQueue is not capacity constrained. - * - * @return Integer.MAX_VALUE - */ - public int remainingCapacity() { - return Integer.MAX_VALUE; - } - - /** - * Returns an array containing all of the elements in this queue. - * The returned array elements are in no particular order. - * - *

The returned array will be "safe" in that no references to it are - * maintained by this queue. (In other words, this method must allocate - * a new array). The caller is thus free to modify the returned array. - * - *

This method acts as bridge between array-based and collection-based - * APIs. - * - * @return an array containing all of the elements in this queue - */ - public Object[] toArray() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return q.toArray(); - } finally { - lock.unlock(); - } - } - - /** - * Returns an array containing all of the elements in this queue; the - * runtime type of the returned array is that of the specified array. - * The returned array elements are in no particular order. - * If the queue fits in the specified array, it is returned therein. - * Otherwise, a new array is allocated with the runtime type of the - * specified array and the size of this queue. - * - *

If this queue fits in the specified array with room to spare - * (i.e., the array has more elements than this queue), the element in - * the array immediately following the end of the queue is set to - * null. - * - *

Like the {@link #toArray()} method, this method acts as bridge between - * array-based and collection-based APIs. Further, this method allows - * precise control over the runtime type of the output array, and may, - * under certain circumstances, be used to save allocation costs. - * - *

The following code can be used to dump a delay queue into a newly - * allocated array of Delayed: - * - *

-     *     Delayed[] a = q.toArray(new Delayed[0]);
- * - * Note that toArray(new Object[0]) is identical in function to - * toArray(). - * - * @param a the array into which the elements of the queue are to - * be stored, if it is big enough; otherwise, a new array of the - * same runtime type is allocated for this purpose - * @return an array containing all of the elements in this queue - * @throws ArrayStoreException if the runtime type of the specified array - * is not a supertype of the runtime type of every element in - * this queue - * @throws NullPointerException if the specified array is null - */ - public T[] toArray(T[] a) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return q.toArray(a); - } finally { - lock.unlock(); - } - } - - /** - * Removes a single instance of the specified element from this - * queue, if it is present, whether or not it has expired. - */ - public boolean remove(Object o) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return q.remove(o); - } finally { - lock.unlock(); - } - } - - /** - * Returns an iterator over all the elements (both expired and - * unexpired) in this queue. The iterator does not return the - * elements in any particular order. The returned - * Iterator is a "weakly consistent" iterator that will - * never throw {@link ConcurrentModificationException}, and - * guarantees to traverse elements as they existed upon - * construction of the iterator, and may (but is not guaranteed - * to) reflect any modifications subsequent to construction. - * - * @return an iterator over the elements in this queue - */ - public Iterator iterator() { - return new Itr(toArray()); - } - - /** - * Snapshot iterator that works off copy of underlying q array. - */ - private class Itr implements Iterator { - final Object[] array; // Array of all elements - int cursor; // index of next element to return; - int lastRet; // index of last element, or -1 if no such - - Itr(Object[] array) { - lastRet = -1; - this.array = array; - } - - public boolean hasNext() { - return cursor < array.length; - } - - @SuppressWarnings("unchecked") - public E next() { - if (cursor >= array.length) - throw new NoSuchElementException(); - lastRet = cursor; - return (E)array[cursor++]; - } - - public void remove() { - if (lastRet < 0) - throw new IllegalStateException(); - Object x = array[lastRet]; - lastRet = -1; - // Traverse underlying queue to find == element, - // not just a .equals element. - lock.lock(); - try { - for (Iterator it = q.iterator(); it.hasNext(); ) { - if (it.next() == x) { - it.remove(); - return; - } - } - } finally { - lock.unlock(); - } - } - } - -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/Delayed.java b/libcore/concurrent/src/main/java/java/util/concurrent/Delayed.java deleted file mode 100644 index af413003f..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/Delayed.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -/* - * Modified in Apache Harmony to comply with Java 5 signature - * specification. - */ - -package java.util.concurrent; - -import java.util.*; - -// BEGIN android-note -// Added generic type Delayed to Comparable to be closer to the RI. -// END android-note - -/** - * A mix-in style interface for marking objects that should be - * acted upon after a given delay. - * - *

An implementation of this interface must define a - * compareTo method that provides an ordering consistent with - * its getDelay method. - * - * @since 1.5 - * @author Doug Lea - */ -public interface Delayed extends Comparable { - - /** - * Returns the remaining delay associated with this object, in the - * given time unit. - * - * @param unit the time unit - * @return the remaining delay; zero or negative values indicate - * that the delay has already elapsed - */ - long getDelay(TimeUnit unit); -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/Exchanger.java b/libcore/concurrent/src/main/java/java/util/concurrent/Exchanger.java deleted file mode 100644 index f67659c8c..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/Exchanger.java +++ /dev/null @@ -1,656 +0,0 @@ -/* - * Written by Doug Lea, Bill Scherer, and Michael Scott with - * assistance from members of JCP JSR-166 Expert Group and released to - * the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; -import java.util.concurrent.atomic.*; -import java.util.concurrent.locks.LockSupport; - -/** - * A synchronization point at which threads can pair and swap elements - * within pairs. Each thread presents some object on entry to the - * {@link #exchange exchange} method, matches with a partner thread, - * and receives its partner's object on return. An Exchanger may be - * viewed as a bidirectional form of a {@link SynchronousQueue}. - * Exchangers may be useful in applications such as genetic algorithms - * and pipeline designs. - * - *

Sample Usage: - * Here are the highlights of a class that uses an {@code Exchanger} - * to swap buffers between threads so that the thread filling the - * buffer gets a freshly emptied one when it needs it, handing off the - * filled one to the thread emptying the buffer. - *

{@code
- * class FillAndEmpty {
- *   Exchanger exchanger = new Exchanger();
- *   DataBuffer initialEmptyBuffer = ... a made-up type
- *   DataBuffer initialFullBuffer = ...
- *
- *   class FillingLoop implements Runnable {
- *     public void run() {
- *       DataBuffer currentBuffer = initialEmptyBuffer;
- *       try {
- *         while (currentBuffer != null) {
- *           addToBuffer(currentBuffer);
- *           if (currentBuffer.isFull())
- *             currentBuffer = exchanger.exchange(currentBuffer);
- *         }
- *       } catch (InterruptedException ex) { ... handle ... }
- *     }
- *   }
- *
- *   class EmptyingLoop implements Runnable {
- *     public void run() {
- *       DataBuffer currentBuffer = initialFullBuffer;
- *       try {
- *         while (currentBuffer != null) {
- *           takeFromBuffer(currentBuffer);
- *           if (currentBuffer.isEmpty())
- *             currentBuffer = exchanger.exchange(currentBuffer);
- *         }
- *       } catch (InterruptedException ex) { ... handle ...}
- *     }
- *   }
- *
- *   void start() {
- *     new Thread(new FillingLoop()).start();
- *     new Thread(new EmptyingLoop()).start();
- *   }
- * }
- * }
- * - *

Memory consistency effects: For each pair of threads that - * successfully exchange objects via an {@code Exchanger}, actions - * prior to the {@code exchange()} in each thread - * happen-before - * those subsequent to a return from the corresponding {@code exchange()} - * in the other thread. - * - * @since 1.5 - * @author Doug Lea and Bill Scherer and Michael Scott - * @param The type of objects that may be exchanged - */ -public class Exchanger { - /* - * Algorithm Description: - * - * The basic idea is to maintain a "slot", which is a reference to - * a Node containing both an Item to offer and a "hole" waiting to - * get filled in. If an incoming "occupying" thread sees that the - * slot is null, it CAS'es (compareAndSets) a Node there and waits - * for another to invoke exchange. That second "fulfilling" thread - * sees that the slot is non-null, and so CASes it back to null, - * also exchanging items by CASing the hole, plus waking up the - * occupying thread if it is blocked. In each case CAS'es may - * fail because a slot at first appears non-null but is null upon - * CAS, or vice-versa. So threads may need to retry these - * actions. - * - * This simple approach works great when there are only a few - * threads using an Exchanger, but performance rapidly - * deteriorates due to CAS contention on the single slot when - * there are lots of threads using an exchanger. So instead we use - * an "arena"; basically a kind of hash table with a dynamically - * varying number of slots, any one of which can be used by - * threads performing an exchange. Incoming threads pick slots - * based on a hash of their Thread ids. If an incoming thread - * fails to CAS in its chosen slot, it picks an alternative slot - * instead. And similarly from there. If a thread successfully - * CASes into a slot but no other thread arrives, it tries - * another, heading toward the zero slot, which always exists even - * if the table shrinks. The particular mechanics controlling this - * are as follows: - * - * Waiting: Slot zero is special in that it is the only slot that - * exists when there is no contention. A thread occupying slot - * zero will block if no thread fulfills it after a short spin. - * In other cases, occupying threads eventually give up and try - * another slot. Waiting threads spin for a while (a period that - * should be a little less than a typical context-switch time) - * before either blocking (if slot zero) or giving up (if other - * slots) and restarting. There is no reason for threads to block - * unless there are unlikely to be any other threads present. - * Occupants are mainly avoiding memory contention so sit there - * quietly polling for a shorter period than it would take to - * block and then unblock them. Non-slot-zero waits that elapse - * because of lack of other threads waste around one extra - * context-switch time per try, which is still on average much - * faster than alternative approaches. - * - * Sizing: Usually, using only a few slots suffices to reduce - * contention. Especially with small numbers of threads, using - * too many slots can lead to just as poor performance as using - * too few of them, and there's not much room for error. The - * variable "max" maintains the number of slots actually in - * use. It is increased when a thread sees too many CAS - * failures. (This is analogous to resizing a regular hash table - * based on a target load factor, except here, growth steps are - * just one-by-one rather than proportional.) Growth requires - * contention failures in each of three tried slots. Requiring - * multiple failures for expansion copes with the fact that some - * failed CASes are not due to contention but instead to simple - * races between two threads or thread pre-emptions occurring - * between reading and CASing. Also, very transient peak - * contention can be much higher than the average sustainable - * levels. The max limit is decreased on average 50% of the times - * that a non-slot-zero wait elapses without being fulfilled. - * Threads experiencing elapsed waits move closer to zero, so - * eventually find existing (or future) threads even if the table - * has been shrunk due to inactivity. The chosen mechanics and - * thresholds for growing and shrinking are intrinsically - * entangled with indexing and hashing inside the exchange code, - * and can't be nicely abstracted out. - * - * Hashing: Each thread picks its initial slot to use in accord - * with a simple hashcode. The sequence is the same on each - * encounter by any given thread, but effectively random across - * threads. Using arenas encounters the classic cost vs quality - * tradeoffs of all hash tables. Here, we use a one-step FNV-1a - * hash code based on the current thread's Thread.getId(), along - * with a cheap approximation to a mod operation to select an - * index. The downside of optimizing index selection in this way - * is that the code is hardwired to use a maximum table size of - * 32. But this value more than suffices for known platforms and - * applications. - * - * Probing: On sensed contention of a selected slot, we probe - * sequentially through the table, analogously to linear probing - * after collision in a hash table. (We move circularly, in - * reverse order, to mesh best with table growth and shrinkage - * rules.) Except that to minimize the effects of false-alarms - * and cache thrashing, we try the first selected slot twice - * before moving. - * - * Padding: Even with contention management, slots are heavily - * contended, so use cache-padding to avoid poor memory - * performance. Because of this, slots are lazily constructed - * only when used, to avoid wasting this space unnecessarily. - * While isolation of locations is not much of an issue at first - * in an application, as time goes on and garbage-collectors - * perform compaction, slots are very likely to be moved adjacent - * to each other, which can cause much thrashing of cache lines on - * MPs unless padding is employed. - * - * This is an improvement of the algorithm described in the paper - * "A Scalable Elimination-based Exchange Channel" by William - * Scherer, Doug Lea, and Michael Scott in Proceedings of SCOOL05 - * workshop. Available at: http://hdl.handle.net/1802/2104 - */ - - /** The number of CPUs, for sizing and spin control */ - private static final int NCPU = Runtime.getRuntime().availableProcessors(); - - /** - * The capacity of the arena. Set to a value that provides more - * than enough space to handle contention. On small machines - * most slots won't be used, but it is still not wasted because - * the extra space provides some machine-level address padding - * to minimize interference with heavily CAS'ed Slot locations. - * And on very large machines, performance eventually becomes - * bounded by memory bandwidth, not numbers of threads/CPUs. - * This constant cannot be changed without also modifying - * indexing and hashing algorithms. - */ - private static final int CAPACITY = 32; - - /** - * The value of "max" that will hold all threads without - * contention. When this value is less than CAPACITY, some - * otherwise wasted expansion can be avoided. - */ - private static final int FULL = - Math.max(0, Math.min(CAPACITY, NCPU / 2) - 1); - - /** - * The number of times to spin (doing nothing except polling a - * memory location) before blocking or giving up while waiting to - * be fulfilled. Should be zero on uniprocessors. On - * multiprocessors, this value should be large enough so that two - * threads exchanging items as fast as possible block only when - * one of them is stalled (due to GC or preemption), but not much - * longer, to avoid wasting CPU resources. Seen differently, this - * value is a little over half the number of cycles of an average - * context switch time on most systems. The value here is - * approximately the average of those across a range of tested - * systems. - */ - private static final int SPINS = (NCPU == 1) ? 0 : 2000; - - /** - * The number of times to spin before blocking in timed waits. - * Timed waits spin more slowly because checking the time takes - * time. The best value relies mainly on the relative rate of - * System.nanoTime vs memory accesses. The value is empirically - * derived to work well across a variety of systems. - */ - private static final int TIMED_SPINS = SPINS / 20; - - /** - * Sentinel item representing cancellation of a wait due to - * interruption, timeout, or elapsed spin-waits. This value is - * placed in holes on cancellation, and used as a return value - * from waiting methods to indicate failure to set or get hole. - */ - private static final Object CANCEL = new Object(); - - /** - * Value representing null arguments/returns from public - * methods. This disambiguates from internal requirement that - * holes start out as null to mean they are not yet set. - */ - private static final Object NULL_ITEM = new Object(); - - /** - * Nodes hold partially exchanged data. This class - * opportunistically subclasses AtomicReference to represent the - * hole. So get() returns hole, and compareAndSet CAS'es value - * into hole. This class cannot be parameterized as "V" because - * of the use of non-V CANCEL sentinels. - */ - private static final class Node extends AtomicReference { - /** The element offered by the Thread creating this node. */ - public final Object item; - - /** The Thread waiting to be signalled; null until waiting. */ - public volatile Thread waiter; - - /** - * Creates node with given item and empty hole. - * @param item the item - */ - public Node(Object item) { - this.item = item; - } - } - - /** - * A Slot is an AtomicReference with heuristic padding to lessen - * cache effects of this heavily CAS'ed location. While the - * padding adds noticeable space, all slots are created only on - * demand, and there will be more than one of them only when it - * would improve throughput more than enough to outweigh using - * extra space. - */ - private static final class Slot extends AtomicReference { - // Improve likelihood of isolation on <= 64 byte cache lines - long q0, q1, q2, q3, q4, q5, q6, q7, q8, q9, qa, qb, qc, qd, qe; - } - - /** - * Slot array. Elements are lazily initialized when needed. - * Declared volatile to enable double-checked lazy construction. - */ - private volatile Slot[] arena = new Slot[CAPACITY]; - - /** - * The maximum slot index being used. The value sometimes - * increases when a thread experiences too many CAS contentions, - * and sometimes decreases when a spin-wait elapses. Changes - * are performed only via compareAndSet, to avoid stale values - * when a thread happens to stall right before setting. - */ - private final AtomicInteger max = new AtomicInteger(); - - /** - * Main exchange function, handling the different policy variants. - * Uses Object, not "V" as argument and return value to simplify - * handling of sentinel values. Callers from public methods decode - * and cast accordingly. - * - * @param item the (non-null) item to exchange - * @param timed true if the wait is timed - * @param nanos if timed, the maximum wait time - * @return the other thread's item, or CANCEL if interrupted or timed out - */ - private Object doExchange(Object item, boolean timed, long nanos) { - Node me = new Node(item); // Create in case occupying - int index = hashIndex(); // Index of current slot - int fails = 0; // Number of CAS failures - - for (;;) { - Object y; // Contents of current slot - Slot slot = arena[index]; - if (slot == null) // Lazily initialize slots - createSlot(index); // Continue loop to reread - else if ((y = slot.get()) != null && // Try to fulfill - slot.compareAndSet(y, null)) { - Node you = (Node)y; // Transfer item - if (you.compareAndSet(null, item)) { - LockSupport.unpark(you.waiter); - return you.item; - } // Else cancelled; continue - } - else if (y == null && // Try to occupy - slot.compareAndSet(null, me)) { - if (index == 0) // Blocking wait for slot 0 - return timed? awaitNanos(me, slot, nanos): await(me, slot); - Object v = spinWait(me, slot); // Spin wait for non-0 - if (v != CANCEL) - return v; - me = new Node(item); // Throw away cancelled node - int m = max.get(); - if (m > (index >>>= 1)) // Decrease index - max.compareAndSet(m, m - 1); // Maybe shrink table - } - else if (++fails > 1) { // Allow 2 fails on 1st slot - int m = max.get(); - if (fails > 3 && m < FULL && max.compareAndSet(m, m + 1)) - index = m + 1; // Grow on 3rd failed slot - else if (--index < 0) - index = m; // Circularly traverse - } - } - } - - /** - * Returns a hash index for the current thread. Uses a one-step - * FNV-1a hash code (http://www.isthe.com/chongo/tech/comp/fnv/) - * based on the current thread's Thread.getId(). These hash codes - * have more uniform distribution properties with respect to small - * moduli (here 1-31) than do other simple hashing functions. - * - *

To return an index between 0 and max, we use a cheap - * approximation to a mod operation, that also corrects for bias - * due to non-power-of-2 remaindering (see {@link - * java.util.Random#nextInt}). Bits of the hashcode are masked - * with "nbits", the ceiling power of two of table size (looked up - * in a table packed into three ints). If too large, this is - * retried after rotating the hash by nbits bits, while forcing new - * top bit to 0, which guarantees eventual termination (although - * with a non-random-bias). This requires an average of less than - * 2 tries for all table sizes, and has a maximum 2% difference - * from perfectly uniform slot probabilities when applied to all - * possible hash codes for sizes less than 32. - * - * @return a per-thread-random index, 0 <= index < max - */ - private final int hashIndex() { - long id = Thread.currentThread().getId(); - int hash = (((int)(id ^ (id >>> 32))) ^ 0x811c9dc5) * 0x01000193; - - int m = max.get(); - int nbits = (((0xfffffc00 >> m) & 4) | // Compute ceil(log2(m+1)) - ((0x000001f8 >>> m) & 2) | // The constants hold - ((0xffff00f2 >>> m) & 1)); // a lookup table - int index; - while ((index = hash & ((1 << nbits) - 1)) > m) // May retry on - hash = (hash >>> nbits) | (hash << (33 - nbits)); // non-power-2 m - return index; - } - - /** - * Creates a new slot at given index. Called only when the slot - * appears to be null. Relies on double-check using builtin - * locks, since they rarely contend. This in turn relies on the - * arena array being declared volatile. - * - * @param index the index to add slot at - */ - private void createSlot(int index) { - // Create slot outside of lock to narrow sync region - Slot newSlot = new Slot(); - Slot[] a = arena; - synchronized (a) { - if (a[index] == null) - a[index] = newSlot; - } - } - - /** - * Tries to cancel a wait for the given node waiting in the given - * slot, if so, helping clear the node from its slot to avoid - * garbage retention. - * - * @param node the waiting node - * @param slot the slot it is waiting in - * @return true if successfully cancelled - */ - private static boolean tryCancel(Node node, Slot slot) { - if (!node.compareAndSet(null, CANCEL)) - return false; - if (slot.get() == node) // pre-check to minimize contention - slot.compareAndSet(node, null); - return true; - } - - // Three forms of waiting. Each just different enough not to merge - // code with others. - - /** - * Spin-waits for hole for a non-0 slot. Fails if spin elapses - * before hole filled. Does not check interrupt, relying on check - * in public exchange method to abort if interrupted on entry. - * - * @param node the waiting node - * @return on success, the hole; on failure, CANCEL - */ - private static Object spinWait(Node node, Slot slot) { - int spins = SPINS; - for (;;) { - Object v = node.get(); - if (v != null) - return v; - else if (spins > 0) - --spins; - else - tryCancel(node, slot); - } - } - - /** - * Waits for (by spinning and/or blocking) and gets the hole - * filled in by another thread. Fails if interrupted before - * hole filled. - * - * When a node/thread is about to block, it sets its waiter field - * and then rechecks state at least one more time before actually - * parking, thus covering race vs fulfiller noticing that waiter - * is non-null so should be woken. - * - * Thread interruption status is checked only surrounding calls to - * park. The caller is assumed to have checked interrupt status - * on entry. - * - * @param node the waiting node - * @return on success, the hole; on failure, CANCEL - */ - private static Object await(Node node, Slot slot) { - Thread w = Thread.currentThread(); - int spins = SPINS; - for (;;) { - Object v = node.get(); - if (v != null) - return v; - else if (spins > 0) // Spin-wait phase - --spins; - else if (node.waiter == null) // Set up to block next - node.waiter = w; - else if (w.isInterrupted()) // Abort on interrupt - tryCancel(node, slot); - else // Block - LockSupport.park(); - } - } - - /** - * Waits for (at index 0) and gets the hole filled in by another - * thread. Fails if timed out or interrupted before hole filled. - * Same basic logic as untimed version, but a bit messier. - * - * @param node the waiting node - * @param nanos the wait time - * @return on success, the hole; on failure, CANCEL - */ - private Object awaitNanos(Node node, Slot slot, long nanos) { - int spins = TIMED_SPINS; - long lastTime = 0; - Thread w = null; - for (;;) { - Object v = node.get(); - if (v != null) - return v; - long now = System.nanoTime(); - if (w == null) - w = Thread.currentThread(); - else - nanos -= now - lastTime; - lastTime = now; - if (nanos > 0) { - if (spins > 0) - --spins; - else if (node.waiter == null) - node.waiter = w; - else if (w.isInterrupted()) - tryCancel(node, slot); - else - LockSupport.parkNanos(nanos); - } - else if (tryCancel(node, slot) && !w.isInterrupted()) - return scanOnTimeout(node); - } - } - - /** - * Sweeps through arena checking for any waiting threads. Called - * only upon return from timeout while waiting in slot 0. When a - * thread gives up on a timed wait, it is possible that a - * previously-entered thread is still waiting in some other - * slot. So we scan to check for any. This is almost always - * overkill, but decreases the likelihood of timeouts when there - * are other threads present to far less than that in lock-based - * exchangers in which earlier-arriving threads may still be - * waiting on entry locks. - * - * @param node the waiting node - * @return another thread's item, or CANCEL - */ - private Object scanOnTimeout(Node node) { - Object y; - for (int j = arena.length - 1; j >= 0; --j) { - Slot slot = arena[j]; - if (slot != null) { - while ((y = slot.get()) != null) { - if (slot.compareAndSet(y, null)) { - Node you = (Node)y; - if (you.compareAndSet(null, node.item)) { - LockSupport.unpark(you.waiter); - return you.item; - } - } - } - } - } - return CANCEL; - } - - /** - * Creates a new Exchanger. - */ - public Exchanger() { - } - - /** - * Waits for another thread to arrive at this exchange point (unless - * the current thread is {@linkplain Thread#interrupt interrupted}), - * and then transfers the given object to it, receiving its object - * in return. - * - *

If another thread is already waiting at the exchange point then - * it is resumed for thread scheduling purposes and receives the object - * passed in by the current thread. The current thread returns immediately, - * receiving the object passed to the exchange by that other thread. - * - *

If no other thread is already waiting at the exchange then the - * current thread is disabled for thread scheduling purposes and lies - * dormant until one of two things happens: - *

    - *
  • Some other thread enters the exchange; or - *
  • Some other thread {@linkplain Thread#interrupt interrupts} the current - * thread. - *
- *

If the current thread: - *

    - *
  • has its interrupted status set on entry to this method; or - *
  • is {@linkplain Thread#interrupt interrupted} while waiting - * for the exchange, - *
- * then {@link InterruptedException} is thrown and the current thread's - * interrupted status is cleared. - * - * @param x the object to exchange - * @return the object provided by the other thread - * @throws InterruptedException if the current thread was - * interrupted while waiting - */ - public V exchange(V x) throws InterruptedException { - if (!Thread.interrupted()) { - Object v = doExchange(x == null? NULL_ITEM : x, false, 0); - if (v == NULL_ITEM) - return null; - if (v != CANCEL) - return (V)v; - Thread.interrupted(); // Clear interrupt status on IE throw - } - throw new InterruptedException(); - } - - /** - * Waits for another thread to arrive at this exchange point (unless - * the current thread is {@linkplain Thread#interrupt interrupted} or - * the specified waiting time elapses), and then transfers the given - * object to it, receiving its object in return. - * - *

If another thread is already waiting at the exchange point then - * it is resumed for thread scheduling purposes and receives the object - * passed in by the current thread. The current thread returns immediately, - * receiving the object passed to the exchange by that other thread. - * - *

If no other thread is already waiting at the exchange then the - * current thread is disabled for thread scheduling purposes and lies - * dormant until one of three things happens: - *

    - *
  • Some other thread enters the exchange; or - *
  • Some other thread {@linkplain Thread#interrupt interrupts} - * the current thread; or - *
  • The specified waiting time elapses. - *
- *

If the current thread: - *

    - *
  • has its interrupted status set on entry to this method; or - *
  • is {@linkplain Thread#interrupt interrupted} while waiting - * for the exchange, - *
- * then {@link InterruptedException} is thrown and the current thread's - * interrupted status is cleared. - * - *

If the specified waiting time elapses then {@link - * TimeoutException} is thrown. If the time is less than or equal - * to zero, the method will not wait at all. - * - * @param x the object to exchange - * @param timeout the maximum time to wait - * @param unit the time unit of the timeout argument - * @return the object provided by the other thread - * @throws InterruptedException if the current thread was - * interrupted while waiting - * @throws TimeoutException if the specified waiting time elapses - * before another thread enters the exchange - */ - public V exchange(V x, long timeout, TimeUnit unit) - throws InterruptedException, TimeoutException { - if (!Thread.interrupted()) { - Object v = doExchange(x == null? NULL_ITEM : x, - true, unit.toNanos(timeout)); - if (v == NULL_ITEM) - return null; - if (v != CANCEL) - return (V)v; - if (!Thread.interrupted()) - throw new TimeoutException(); - } - throw new InterruptedException(); - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/ExecutionException.java b/libcore/concurrent/src/main/java/java/util/concurrent/ExecutionException.java deleted file mode 100644 index bc561e58e..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/ExecutionException.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; - -/** - * Exception thrown when attempting to retrieve the result of a task - * that aborted by throwing an exception. This exception can be - * inspected using the {@link #getCause()} method. - * - * @see Future - * @since 1.5 - * @author Doug Lea - */ -public class ExecutionException extends Exception { - private static final long serialVersionUID = 7830266012832686185L; - - /** - * Constructs an ExecutionException with no detail message. - * The cause is not initialized, and may subsequently be - * initialized by a call to {@link #initCause(Throwable) initCause}. - */ - protected ExecutionException() { } - - /** - * Constructs an ExecutionException with the specified detail - * message. The cause is not initialized, and may subsequently be - * initialized by a call to {@link #initCause(Throwable) initCause}. - * - * @param message the detail message - */ - protected ExecutionException(String message) { - super(message); - } - - /** - * Constructs an ExecutionException with the specified detail - * message and cause. - * - * @param message the detail message - * @param cause the cause (which is saved for later retrieval by the - * {@link #getCause()} method) - */ - public ExecutionException(String message, Throwable cause) { - super(message, cause); - } - - /** - * Constructs an ExecutionException with the specified cause. - * The detail message is set to: - *

-     *  (cause == null ? null : cause.toString())
- * (which typically contains the class and detail message of - * cause). - * - * @param cause the cause (which is saved for later retrieval by the - * {@link #getCause()} method) - */ - public ExecutionException(Throwable cause) { - super(cause); - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/Executor.java b/libcore/concurrent/src/main/java/java/util/concurrent/Executor.java deleted file mode 100644 index a61e92152..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/Executor.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; - -/** - * An object that executes submitted {@link Runnable} tasks. This - * interface provides a way of decoupling task submission from the - * mechanics of how each task will be run, including details of thread - * use, scheduling, etc. An Executor is normally used - * instead of explicitly creating threads. For example, rather than - * invoking new Thread(new(RunnableTask())).start() for each - * of a set of tasks, you might use: - * - *
- * Executor executor = anExecutor;
- * executor.execute(new RunnableTask1());
- * executor.execute(new RunnableTask2());
- * ...
- * 
- * - * However, the Executor interface does not strictly - * require that execution be asynchronous. In the simplest case, an - * executor can run the submitted task immediately in the caller's - * thread: - * - *
- * class DirectExecutor implements Executor {
- *     public void execute(Runnable r) {
- *         r.run();
- *     }
- * }
- * - * More typically, tasks are executed in some thread other - * than the caller's thread. The executor below spawns a new thread - * for each task. - * - *
- * class ThreadPerTaskExecutor implements Executor {
- *     public void execute(Runnable r) {
- *         new Thread(r).start();
- *     }
- * }
- * - * Many Executor implementations impose some sort of - * limitation on how and when tasks are scheduled. The executor below - * serializes the submission of tasks to a second executor, - * illustrating a composite executor. - * - *
- * class SerialExecutor implements Executor {
- *     final Queue<Runnable> tasks = new ArrayDeque<Runnable>();
- *     final Executor executor;
- *     Runnable active;
- *
- *     SerialExecutor(Executor executor) {
- *         this.executor = executor;
- *     }
- *
- *     public synchronized void execute(final Runnable r) {
- *         tasks.offer(new Runnable() {
- *             public void run() {
- *                 try {
- *                     r.run();
- *                 } finally {
- *                     scheduleNext();
- *                 }
- *             }
- *         });
- *         if (active == null) {
- *             scheduleNext();
- *         }
- *     }
- *
- *     protected synchronized void scheduleNext() {
- *         if ((active = tasks.poll()) != null) {
- *             executor.execute(active);
- *         }
- *     }
- * }
- * - * The Executor implementations provided in this package - * implement {@link ExecutorService}, which is a more extensive - * interface. The {@link ThreadPoolExecutor} class provides an - * extensible thread pool implementation. The {@link Executors} class - * provides convenient factory methods for these Executors. - * - *

Memory consistency effects: Actions in a thread prior to - * submitting a {@code Runnable} object to an {@code Executor} - * happen-before - * its execution begins, perhaps in another thread. - * - * @since 1.5 - * @author Doug Lea - */ -public interface Executor { - - /** - * Executes the given command at some time in the future. The command - * may execute in a new thread, in a pooled thread, or in the calling - * thread, at the discretion of the Executor implementation. - * - * @param command the runnable task - * @throws RejectedExecutionException if this task cannot be - * accepted for execution. - * @throws NullPointerException if command is null - */ - void execute(Runnable command); -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/ExecutorCompletionService.java b/libcore/concurrent/src/main/java/java/util/concurrent/ExecutorCompletionService.java deleted file mode 100644 index 02606f960..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/ExecutorCompletionService.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; - -/** - * A {@link CompletionService} that uses a supplied {@link Executor} - * to execute tasks. This class arranges that submitted tasks are, - * upon completion, placed on a queue accessible using {@code take}. - * The class is lightweight enough to be suitable for transient use - * when processing groups of tasks. - * - *

- * - * Usage Examples. - * - * Suppose you have a set of solvers for a certain problem, each - * returning a value of some type {@code Result}, and would like to - * run them concurrently, processing the results of each of them that - * return a non-null value, in some method {@code use(Result r)}. You - * could write this as: - * - *

 {@code
- * void solve(Executor e,
- *            Collection> solvers)
- *     throws InterruptedException, ExecutionException {
- *     CompletionService ecs
- *         = new ExecutorCompletionService(e);
- *     for (Callable s : solvers)
- *         ecs.submit(s);
- *     int n = solvers.size();
- *     for (int i = 0; i < n; ++i) {
- *         Result r = ecs.take().get();
- *         if (r != null)
- *             use(r);
- *     }
- * }}
- * - * Suppose instead that you would like to use the first non-null result - * of the set of tasks, ignoring any that encounter exceptions, - * and cancelling all other tasks when the first one is ready: - * - *
 {@code
- * void solve(Executor e,
- *            Collection> solvers)
- *     throws InterruptedException {
- *     CompletionService ecs
- *         = new ExecutorCompletionService(e);
- *     int n = solvers.size();
- *     List> futures
- *         = new ArrayList>(n);
- *     Result result = null;
- *     try {
- *         for (Callable s : solvers)
- *             futures.add(ecs.submit(s));
- *         for (int i = 0; i < n; ++i) {
- *             try {
- *                 Result r = ecs.take().get();
- *                 if (r != null) {
- *                     result = r;
- *                     break;
- *                 }
- *             } catch (ExecutionException ignore) {}
- *         }
- *     }
- *     finally {
- *         for (Future f : futures)
- *             f.cancel(true);
- *     }
- *
- *     if (result != null)
- *         use(result);
- * }}
- */ -public class ExecutorCompletionService implements CompletionService { - private final Executor executor; - private final AbstractExecutorService aes; - private final BlockingQueue> completionQueue; - - /** - * FutureTask extension to enqueue upon completion - */ - private class QueueingFuture extends FutureTask { - QueueingFuture(FutureTask task) { - super(task, null); - this.task = task; - } - protected void done() { completionQueue.add(task); } - private final Future task; - } - - private FutureTask newTaskFor(Callable task) { - return new FutureTask(task); - } - - private FutureTask newTaskFor(Runnable task, V result) { - return new FutureTask(task, result); - } - - /** - * Creates an ExecutorCompletionService using the supplied - * executor for base task execution and a - * {@link LinkedBlockingQueue} as a completion queue. - * - * @param executor the executor to use - * @throws NullPointerException if executor is {@code null} - */ - public ExecutorCompletionService(Executor executor) { - if (executor == null) - throw new NullPointerException(); - this.executor = executor; - this.aes = (executor instanceof AbstractExecutorService) ? - (AbstractExecutorService) executor : null; - this.completionQueue = new LinkedBlockingQueue>(); - } - - /** - * Creates an ExecutorCompletionService using the supplied - * executor for base task execution and the supplied queue as its - * completion queue. - * - * @param executor the executor to use - * @param completionQueue the queue to use as the completion queue - * normally one dedicated for use by this service. This - * queue is treated as unbounded -- failed attempted - * {@code Queue.add} operations for completed taskes cause - * them not to be retrievable. - * @throws NullPointerException if executor or completionQueue are {@code null} - */ - public ExecutorCompletionService(Executor executor, - BlockingQueue> completionQueue) { - if (executor == null || completionQueue == null) - throw new NullPointerException(); - this.executor = executor; - this.aes = (executor instanceof AbstractExecutorService) ? - (AbstractExecutorService) executor : null; - this.completionQueue = completionQueue; - } - - public Future submit(Callable task) { - if (task == null) throw new NullPointerException(); - FutureTask f = newTaskFor(task); - executor.execute(new QueueingFuture(f)); - return f; - } - - public Future submit(Runnable task, V result) { - if (task == null) throw new NullPointerException(); - FutureTask f = newTaskFor(task, result); - executor.execute(new QueueingFuture(f)); - return f; - } - - public Future take() throws InterruptedException { - return completionQueue.take(); - } - - public Future poll() { - return completionQueue.poll(); - } - - public Future poll(long timeout, TimeUnit unit) throws InterruptedException { - return completionQueue.poll(timeout, unit); - } - -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/ExecutorService.java b/libcore/concurrent/src/main/java/java/util/concurrent/ExecutorService.java deleted file mode 100644 index 757f7cbad..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/ExecutorService.java +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; -import java.util.List; -import java.util.Collection; -import java.security.PrivilegedAction; -import java.security.PrivilegedExceptionAction; - -/** - * An {@link Executor} that provides methods to manage termination and - * methods that can produce a {@link Future} for tracking progress of - * one or more asynchronous tasks. - * - *

An ExecutorService can be shut down, which will cause - * it to reject new tasks. Two different methods are provided for - * shutting down an ExecutorService. The {@link #shutdown} - * method will allow previously submitted tasks to execute before - * terminating, while the {@link #shutdownNow} method prevents waiting - * tasks from starting and attempts to stop currently executing tasks. - * Upon termination, an executor has no tasks actively executing, no - * tasks awaiting execution, and no new tasks can be submitted. An - * unused ExecutorService should be shut down to allow - * reclamation of its resources. - * - *

Method submit extends base method {@link - * Executor#execute} by creating and returning a {@link Future} that - * can be used to cancel execution and/or wait for completion. - * Methods invokeAny and invokeAll perform the most - * commonly useful forms of bulk execution, executing a collection of - * tasks and then waiting for at least one, or all, to - * complete. (Class {@link ExecutorCompletionService} can be used to - * write customized variants of these methods.) - * - *

The {@link Executors} class provides factory methods for the - * executor services provided in this package. - * - *

Usage Examples

- * - * Here is a sketch of a network service in which threads in a thread - * pool service incoming requests. It uses the preconfigured {@link - * Executors#newFixedThreadPool} factory method: - * - *
- * class NetworkService implements Runnable {
- *   private final ServerSocket serverSocket;
- *   private final ExecutorService pool;
- *
- *   public NetworkService(int port, int poolSize)
- *       throws IOException {
- *     serverSocket = new ServerSocket(port);
- *     pool = Executors.newFixedThreadPool(poolSize);
- *   }
- *
- *   public void run() { // run the service
- *     try {
- *       for (;;) {
- *         pool.execute(new Handler(serverSocket.accept()));
- *       }
- *     } catch (IOException ex) {
- *       pool.shutdown();
- *     }
- *   }
- * }
- *
- * class Handler implements Runnable {
- *   private final Socket socket;
- *   Handler(Socket socket) { this.socket = socket; }
- *   public void run() {
- *     // read and service request on socket
- *   }
- * }
- * 
- * - * The following method shuts down an ExecutorService in two phases, - * first by calling shutdown to reject incoming tasks, and then - * calling shutdownNow, if necessary, to cancel any lingering tasks: - * - *
- * void shutdownAndAwaitTermination(ExecutorService pool) {
- *   pool.shutdown(); // Disable new tasks from being submitted
- *   try {
- *     // Wait a while for existing tasks to terminate
- *     if (!pool.awaitTermination(60, TimeUnit.SECONDS)) {
- *       pool.shutdownNow(); // Cancel currently executing tasks
- *       // Wait a while for tasks to respond to being cancelled
- *       if (!pool.awaitTermination(60, TimeUnit.SECONDS))
- *           System.err.println("Pool did not terminate");
- *     }
- *   } catch (InterruptedException ie) {
- *     // (Re-)Cancel if current thread also interrupted
- *     pool.shutdownNow();
- *     // Preserve interrupt status
- *     Thread.currentThread().interrupt();
- *   }
- * }
- * 
- * - *

Memory consistency effects: Actions in a thread prior to the - * submission of a {@code Runnable} or {@code Callable} task to an - * {@code ExecutorService} - * happen-before - * any actions taken by that task, which in turn happen-before the - * result is retrieved via {@code Future.get()}. - * - * @since 1.5 - * @author Doug Lea - */ -public interface ExecutorService extends Executor { - - /** - * Initiates an orderly shutdown in which previously submitted - * tasks are executed, but no new tasks will be accepted. - * Invocation has no additional effect if already shut down. - * - *

This method does not wait for previously submitted tasks to - * complete execution. Use {@link #awaitTermination awaitTermination} - * to do that. - * - * @throws SecurityException if a security manager exists and - * shutting down this ExecutorService may manipulate - * threads that the caller is not permitted to modify - * because it does not hold {@link - * java.lang.RuntimePermission}("modifyThread"), - * or the security manager's checkAccess method - * denies access. - */ - void shutdown(); - - /** - * Attempts to stop all actively executing tasks, halts the - * processing of waiting tasks, and returns a list of the tasks - * that were awaiting execution. - * - *

This method does not wait for actively executing tasks to - * terminate. Use {@link #awaitTermination awaitTermination} to - * do that. - * - *

There are no guarantees beyond best-effort attempts to stop - * processing actively executing tasks. For example, typical - * implementations will cancel via {@link Thread#interrupt}, so any - * task that fails to respond to interrupts may never terminate. - * - * @return list of tasks that never commenced execution - * @throws SecurityException if a security manager exists and - * shutting down this ExecutorService may manipulate - * threads that the caller is not permitted to modify - * because it does not hold {@link - * java.lang.RuntimePermission}("modifyThread"), - * or the security manager's checkAccess method - * denies access. - */ - List shutdownNow(); - - /** - * Returns true if this executor has been shut down. - * - * @return true if this executor has been shut down - */ - boolean isShutdown(); - - /** - * Returns true if all tasks have completed following shut down. - * Note that isTerminated is never true unless - * either shutdown or shutdownNow was called first. - * - * @return true if all tasks have completed following shut down - */ - boolean isTerminated(); - - /** - * Blocks until all tasks have completed execution after a shutdown - * request, or the timeout occurs, or the current thread is - * interrupted, whichever happens first. - * - * @param timeout the maximum time to wait - * @param unit the time unit of the timeout argument - * @return true if this executor terminated and - * false if the timeout elapsed before termination - * @throws InterruptedException if interrupted while waiting - */ - boolean awaitTermination(long timeout, TimeUnit unit) - throws InterruptedException; - - - /** - * Submits a value-returning task for execution and returns a - * Future representing the pending results of the task. The - * Future's get method will return the task's result upon - * successful completion. - * - *

- * If you would like to immediately block waiting - * for a task, you can use constructions of the form - * result = exec.submit(aCallable).get(); - * - *

Note: The {@link Executors} class includes a set of methods - * that can convert some other common closure-like objects, - * for example, {@link java.security.PrivilegedAction} to - * {@link Callable} form so they can be submitted. - * - * @param task the task to submit - * @return a Future representing pending completion of the task - * @throws RejectedExecutionException if the task cannot be - * scheduled for execution - * @throws NullPointerException if the task is null - */ - Future submit(Callable task); - - /** - * Submits a Runnable task for execution and returns a Future - * representing that task. The Future's get method will - * return the given result upon successful completion. - * - * @param task the task to submit - * @param result the result to return - * @return a Future representing pending completion of the task - * @throws RejectedExecutionException if the task cannot be - * scheduled for execution - * @throws NullPointerException if the task is null - */ - Future submit(Runnable task, T result); - - /** - * Submits a Runnable task for execution and returns a Future - * representing that task. The Future's get method will - * return null upon successful completion. - * - * @param task the task to submit - * @return a Future representing pending completion of the task - * @throws RejectedExecutionException if the task cannot be - * scheduled for execution - * @throws NullPointerException if the task is null - */ - Future submit(Runnable task); - - /** - * Executes the given tasks, returning a list of Futures holding - * their status and results when all complete. - * {@link Future#isDone} is true for each - * element of the returned list. - * Note that a completed task could have - * terminated either normally or by throwing an exception. - * The results of this method are undefined if the given - * collection is modified while this operation is in progress. - * - * @param tasks the collection of tasks - * @return A list of Futures representing the tasks, in the same - * sequential order as produced by the iterator for the - * given task list, each of which has completed. - * @throws InterruptedException if interrupted while waiting, in - * which case unfinished tasks are cancelled. - * @throws NullPointerException if tasks or any of its elements are null - * @throws RejectedExecutionException if any task cannot be - * scheduled for execution - */ - - List> invokeAll(Collection> tasks) - throws InterruptedException; - - /** - * Executes the given tasks, returning a list of Futures holding - * their status and results - * when all complete or the timeout expires, whichever happens first. - * {@link Future#isDone} is true for each - * element of the returned list. - * Upon return, tasks that have not completed are cancelled. - * Note that a completed task could have - * terminated either normally or by throwing an exception. - * The results of this method are undefined if the given - * collection is modified while this operation is in progress. - * - * @param tasks the collection of tasks - * @param timeout the maximum time to wait - * @param unit the time unit of the timeout argument - * @return a list of Futures representing the tasks, in the same - * sequential order as produced by the iterator for the - * given task list. If the operation did not time out, - * each task will have completed. If it did time out, some - * of these tasks will not have completed. - * @throws InterruptedException if interrupted while waiting, in - * which case unfinished tasks are cancelled - * @throws NullPointerException if tasks, any of its elements, or - * unit are null - * @throws RejectedExecutionException if any task cannot be scheduled - * for execution - */ - List> invokeAll(Collection> tasks, - long timeout, TimeUnit unit) - throws InterruptedException; - - /** - * Executes the given tasks, returning the result - * of one that has completed successfully (i.e., without throwing - * an exception), if any do. Upon normal or exceptional return, - * tasks that have not completed are cancelled. - * The results of this method are undefined if the given - * collection is modified while this operation is in progress. - * - * @param tasks the collection of tasks - * @return the result returned by one of the tasks - * @throws InterruptedException if interrupted while waiting - * @throws NullPointerException if tasks or any of its elements - * are null - * @throws IllegalArgumentException if tasks is empty - * @throws ExecutionException if no task successfully completes - * @throws RejectedExecutionException if tasks cannot be scheduled - * for execution - */ - T invokeAny(Collection> tasks) - throws InterruptedException, ExecutionException; - - /** - * Executes the given tasks, returning the result - * of one that has completed successfully (i.e., without throwing - * an exception), if any do before the given timeout elapses. - * Upon normal or exceptional return, tasks that have not - * completed are cancelled. - * The results of this method are undefined if the given - * collection is modified while this operation is in progress. - * - * @param tasks the collection of tasks - * @param timeout the maximum time to wait - * @param unit the time unit of the timeout argument - * @return the result returned by one of the tasks. - * @throws InterruptedException if interrupted while waiting - * @throws NullPointerException if tasks, any of its elements, or - * unit are null - * @throws TimeoutException if the given timeout elapses before - * any task successfully completes - * @throws ExecutionException if no task successfully completes - * @throws RejectedExecutionException if tasks cannot be scheduled - * for execution - */ - T invokeAny(Collection> tasks, - long timeout, TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException; -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/Executors.java b/libcore/concurrent/src/main/java/java/util/concurrent/Executors.java deleted file mode 100644 index a57abe5ec..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/Executors.java +++ /dev/null @@ -1,676 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; -import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.PrivilegedExceptionAction; -import java.security.PrivilegedActionException; -import java.security.AccessControlException; - -/** - * Factory and utility methods for {@link Executor}, {@link - * ExecutorService}, {@link ScheduledExecutorService}, {@link - * ThreadFactory}, and {@link Callable} classes defined in this - * package. This class supports the following kinds of methods: - * - *

    - *
  • Methods that create and return an {@link ExecutorService} - * set up with commonly useful configuration settings. - *
  • Methods that create and return a {@link ScheduledExecutorService} - * set up with commonly useful configuration settings. - *
  • Methods that create and return a "wrapped" ExecutorService, that - * disables reconfiguration by making implementation-specific methods - * inaccessible. - *
  • Methods that create and return a {@link ThreadFactory} - * that sets newly created threads to a known state. - *
  • Methods that create and return a {@link Callable} - * out of other closure-like forms, so they can be used - * in execution methods requiring Callable. - *
- * - * @since 1.5 - * @author Doug Lea - */ -public class Executors { - - /** - * Creates a thread pool that reuses a fixed number of threads - * operating off a shared unbounded queue. At any point, at most - * nThreads threads will be active processing tasks. - * If additional tasks are submitted when all threads are active, - * they will wait in the queue until a thread is available. - * If any thread terminates due to a failure during execution - * prior to shutdown, a new one will take its place if needed to - * execute subsequent tasks. The threads in the pool will exist - * until it is explicitly {@link ExecutorService#shutdown shutdown}. - * - * @param nThreads the number of threads in the pool - * @return the newly created thread pool - * @throws IllegalArgumentException if nThreads <= 0 - */ - public static ExecutorService newFixedThreadPool(int nThreads) { - return new ThreadPoolExecutor(nThreads, nThreads, - 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue()); - } - - /** - * Creates a thread pool that reuses a fixed number of threads - * operating off a shared unbounded queue, using the provided - * ThreadFactory to create new threads when needed. At any point, - * at most nThreads threads will be active processing - * tasks. If additional tasks are submitted when all threads are - * active, they will wait in the queue until a thread is - * available. If any thread terminates due to a failure during - * execution prior to shutdown, a new one will take its place if - * needed to execute subsequent tasks. The threads in the pool will - * exist until it is explicitly {@link ExecutorService#shutdown - * shutdown}. - * - * @param nThreads the number of threads in the pool - * @param threadFactory the factory to use when creating new threads - * @return the newly created thread pool - * @throws NullPointerException if threadFactory is null - * @throws IllegalArgumentException if nThreads <= 0 - */ - public static ExecutorService newFixedThreadPool(int nThreads, ThreadFactory threadFactory) { - return new ThreadPoolExecutor(nThreads, nThreads, - 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue(), - threadFactory); - } - - /** - * Creates an Executor that uses a single worker thread operating - * off an unbounded queue. (Note however that if this single - * thread terminates due to a failure during execution prior to - * shutdown, a new one will take its place if needed to execute - * subsequent tasks.) Tasks are guaranteed to execute - * sequentially, and no more than one task will be active at any - * given time. Unlike the otherwise equivalent - * newFixedThreadPool(1) the returned executor is - * guaranteed not to be reconfigurable to use additional threads. - * - * @return the newly created single-threaded Executor - */ - public static ExecutorService newSingleThreadExecutor() { - return new FinalizableDelegatedExecutorService - (new ThreadPoolExecutor(1, 1, - 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue())); - } - - /** - * Creates an Executor that uses a single worker thread operating - * off an unbounded queue, and uses the provided ThreadFactory to - * create a new thread when needed. Unlike the otherwise - * equivalent newFixedThreadPool(1, threadFactory) the - * returned executor is guaranteed not to be reconfigurable to use - * additional threads. - * - * @param threadFactory the factory to use when creating new - * threads - * - * @return the newly created single-threaded Executor - * @throws NullPointerException if threadFactory is null - */ - public static ExecutorService newSingleThreadExecutor(ThreadFactory threadFactory) { - return new FinalizableDelegatedExecutorService - (new ThreadPoolExecutor(1, 1, - 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue(), - threadFactory)); - } - - /** - * Creates a thread pool that creates new threads as needed, but - * will reuse previously constructed threads when they are - * available. These pools will typically improve the performance - * of programs that execute many short-lived asynchronous tasks. - * Calls to execute will reuse previously constructed - * threads if available. If no existing thread is available, a new - * thread will be created and added to the pool. Threads that have - * not been used for sixty seconds are terminated and removed from - * the cache. Thus, a pool that remains idle for long enough will - * not consume any resources. Note that pools with similar - * properties but different details (for example, timeout parameters) - * may be created using {@link ThreadPoolExecutor} constructors. - * - * @return the newly created thread pool - */ - public static ExecutorService newCachedThreadPool() { - return new ThreadPoolExecutor(0, Integer.MAX_VALUE, - 60L, TimeUnit.SECONDS, - new SynchronousQueue()); - } - - /** - * Creates a thread pool that creates new threads as needed, but - * will reuse previously constructed threads when they are - * available, and uses the provided - * ThreadFactory to create new threads when needed. - * @param threadFactory the factory to use when creating new threads - * @return the newly created thread pool - * @throws NullPointerException if threadFactory is null - */ - public static ExecutorService newCachedThreadPool(ThreadFactory threadFactory) { - return new ThreadPoolExecutor(0, Integer.MAX_VALUE, - 60L, TimeUnit.SECONDS, - new SynchronousQueue(), - threadFactory); - } - - /** - * Creates a single-threaded executor that can schedule commands - * to run after a given delay, or to execute periodically. - * (Note however that if this single - * thread terminates due to a failure during execution prior to - * shutdown, a new one will take its place if needed to execute - * subsequent tasks.) Tasks are guaranteed to execute - * sequentially, and no more than one task will be active at any - * given time. Unlike the otherwise equivalent - * newScheduledThreadPool(1) the returned executor is - * guaranteed not to be reconfigurable to use additional threads. - * @return the newly created scheduled executor - */ - public static ScheduledExecutorService newSingleThreadScheduledExecutor() { - return new DelegatedScheduledExecutorService - (new ScheduledThreadPoolExecutor(1)); - } - - /** - * Creates a single-threaded executor that can schedule commands - * to run after a given delay, or to execute periodically. (Note - * however that if this single thread terminates due to a failure - * during execution prior to shutdown, a new one will take its - * place if needed to execute subsequent tasks.) Tasks are - * guaranteed to execute sequentially, and no more than one task - * will be active at any given time. Unlike the otherwise - * equivalent newScheduledThreadPool(1, threadFactory) - * the returned executor is guaranteed not to be reconfigurable to - * use additional threads. - * @param threadFactory the factory to use when creating new - * threads - * @return a newly created scheduled executor - * @throws NullPointerException if threadFactory is null - */ - public static ScheduledExecutorService newSingleThreadScheduledExecutor(ThreadFactory threadFactory) { - return new DelegatedScheduledExecutorService - (new ScheduledThreadPoolExecutor(1, threadFactory)); - } - - /** - * Creates a thread pool that can schedule commands to run after a - * given delay, or to execute periodically. - * @param corePoolSize the number of threads to keep in the pool, - * even if they are idle. - * @return a newly created scheduled thread pool - * @throws IllegalArgumentException if corePoolSize < 0 - */ - public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize) { - return new ScheduledThreadPoolExecutor(corePoolSize); - } - - /** - * Creates a thread pool that can schedule commands to run after a - * given delay, or to execute periodically. - * @param corePoolSize the number of threads to keep in the pool, - * even if they are idle. - * @param threadFactory the factory to use when the executor - * creates a new thread. - * @return a newly created scheduled thread pool - * @throws IllegalArgumentException if corePoolSize < 0 - * @throws NullPointerException if threadFactory is null - */ - public static ScheduledExecutorService newScheduledThreadPool( - int corePoolSize, ThreadFactory threadFactory) { - return new ScheduledThreadPoolExecutor(corePoolSize, threadFactory); - } - - - /** - * Returns an object that delegates all defined {@link - * ExecutorService} methods to the given executor, but not any - * other methods that might otherwise be accessible using - * casts. This provides a way to safely "freeze" configuration and - * disallow tuning of a given concrete implementation. - * @param executor the underlying implementation - * @return an ExecutorService instance - * @throws NullPointerException if executor null - */ - public static ExecutorService unconfigurableExecutorService(ExecutorService executor) { - if (executor == null) - throw new NullPointerException(); - return new DelegatedExecutorService(executor); - } - - /** - * Returns an object that delegates all defined {@link - * ScheduledExecutorService} methods to the given executor, but - * not any other methods that might otherwise be accessible using - * casts. This provides a way to safely "freeze" configuration and - * disallow tuning of a given concrete implementation. - * @param executor the underlying implementation - * @return a ScheduledExecutorService instance - * @throws NullPointerException if executor null - */ - public static ScheduledExecutorService unconfigurableScheduledExecutorService(ScheduledExecutorService executor) { - if (executor == null) - throw new NullPointerException(); - return new DelegatedScheduledExecutorService(executor); - } - - /** - * Returns a default thread factory used to create new threads. - * This factory creates all new threads used by an Executor in the - * same {@link ThreadGroup}. If there is a {@link - * java.lang.SecurityManager}, it uses the group of {@link - * System#getSecurityManager}, else the group of the thread - * invoking this defaultThreadFactory method. Each new - * thread is created as a non-daemon thread with priority set to - * the smaller of Thread.NORM_PRIORITY and the maximum - * priority permitted in the thread group. New threads have names - * accessible via {@link Thread#getName} of - * pool-N-thread-M, where N is the sequence - * number of this factory, and M is the sequence number - * of the thread created by this factory. - * @return a thread factory - */ - public static ThreadFactory defaultThreadFactory() { - return new DefaultThreadFactory(); - } - - /** - * Returns a thread factory used to create new threads that - * have the same permissions as the current thread. - * This factory creates threads with the same settings as {@link - * Executors#defaultThreadFactory}, additionally setting the - * AccessControlContext and contextClassLoader of new threads to - * be the same as the thread invoking this - * privilegedThreadFactory method. A new - * privilegedThreadFactory can be created within an - * {@link AccessController#doPrivileged} action setting the - * current thread's access control context to create threads with - * the selected permission settings holding within that action. - * - *

Note that while tasks running within such threads will have - * the same access control and class loader settings as the - * current thread, they need not have the same {@link - * java.lang.ThreadLocal} or {@link - * java.lang.InheritableThreadLocal} values. If necessary, - * particular values of thread locals can be set or reset before - * any task runs in {@link ThreadPoolExecutor} subclasses using - * {@link ThreadPoolExecutor#beforeExecute}. Also, if it is - * necessary to initialize worker threads to have the same - * InheritableThreadLocal settings as some other designated - * thread, you can create a custom ThreadFactory in which that - * thread waits for and services requests to create others that - * will inherit its values. - * - * @return a thread factory - * @throws AccessControlException if the current access control - * context does not have permission to both get and set context - * class loader. - */ - public static ThreadFactory privilegedThreadFactory() { - return new PrivilegedThreadFactory(); - } - - /** - * Returns a {@link Callable} object that, when - * called, runs the given task and returns the given result. This - * can be useful when applying methods requiring a - * Callable to an otherwise resultless action. - * @param task the task to run - * @param result the result to return - * @return a callable object - * @throws NullPointerException if task null - */ - public static Callable callable(Runnable task, T result) { - if (task == null) - throw new NullPointerException(); - return new RunnableAdapter(task, result); - } - - /** - * Returns a {@link Callable} object that, when - * called, runs the given task and returns null. - * @param task the task to run - * @return a callable object - * @throws NullPointerException if task null - */ - public static Callable callable(Runnable task) { - if (task == null) - throw new NullPointerException(); - return new RunnableAdapter(task, null); - } - - /** - * Returns a {@link Callable} object that, when - * called, runs the given privileged action and returns its result. - * @param action the privileged action to run - * @return a callable object - * @throws NullPointerException if action null - */ - public static Callable callable(final PrivilegedAction action) { - if (action == null) - throw new NullPointerException(); - return new Callable() { - public Object call() { return action.run(); }}; - } - - /** - * Returns a {@link Callable} object that, when - * called, runs the given privileged exception action and returns - * its result. - * @param action the privileged exception action to run - * @return a callable object - * @throws NullPointerException if action null - */ - public static Callable callable(final PrivilegedExceptionAction action) { - if (action == null) - throw new NullPointerException(); - return new Callable() { - public Object call() throws Exception { return action.run(); }}; - } - - /** - * Returns a {@link Callable} object that will, when - * called, execute the given callable under the current - * access control context. This method should normally be - * invoked within an {@link AccessController#doPrivileged} action - * to create callables that will, if possible, execute under the - * selected permission settings holding within that action; or if - * not possible, throw an associated {@link - * AccessControlException}. - * @param callable the underlying task - * @return a callable object - * @throws NullPointerException if callable null - * - */ - public static Callable privilegedCallable(Callable callable) { - if (callable == null) - throw new NullPointerException(); - return new PrivilegedCallable(callable); - } - - /** - * Returns a {@link Callable} object that will, when - * called, execute the given callable under the current - * access control context, with the current context class loader - * as the context class loader. This method should normally be - * invoked within an {@link AccessController#doPrivileged} action - * to create callables that will, if possible, execute under the - * selected permission settings holding within that action; or if - * not possible, throw an associated {@link - * AccessControlException}. - * @param callable the underlying task - * - * @return a callable object - * @throws NullPointerException if callable null - * @throws AccessControlException if the current access control - * context does not have permission to both set and get context - * class loader. - */ - public static Callable privilegedCallableUsingCurrentClassLoader(Callable callable) { - if (callable == null) - throw new NullPointerException(); - return new PrivilegedCallableUsingCurrentClassLoader(callable); - } - - // Non-public classes supporting the public methods - - /** - * A callable that runs given task and returns given result - */ - static final class RunnableAdapter implements Callable { - final Runnable task; - final T result; - RunnableAdapter(Runnable task, T result) { - this.task = task; - this.result = result; - } - public T call() { - task.run(); - return result; - } - } - - /** - * A callable that runs under established access control settings - */ - static final class PrivilegedCallable implements Callable { - private final Callable task; - private final AccessControlContext acc; - - PrivilegedCallable(Callable task) { - this.task = task; - this.acc = AccessController.getContext(); - } - - public T call() throws Exception { - try { - return AccessController.doPrivileged( - new PrivilegedExceptionAction() { - public T run() throws Exception { - return task.call(); - } - }, acc); - } catch (PrivilegedActionException e) { - throw e.getException(); - } - } - } - - /** - * A callable that runs under established access control settings and - * current ClassLoader - */ - static final class PrivilegedCallableUsingCurrentClassLoader implements Callable { - private final Callable task; - private final AccessControlContext acc; - private final ClassLoader ccl; - - PrivilegedCallableUsingCurrentClassLoader(Callable task) { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - // Calls to getContextClassLoader from this class - // never trigger a security check, but we check - // whether our callers have this permission anyways. - sm.checkPermission(new RuntimePermission("getContextClassLoader")); - - // Whether setContextClassLoader turns out to be necessary - // or not, we fail fast if permission is not available. - sm.checkPermission(new RuntimePermission("setContextClassLoader")); - } - this.task = task; - this.acc = AccessController.getContext(); - this.ccl = Thread.currentThread().getContextClassLoader(); - } - - public T call() throws Exception { - try { - return AccessController.doPrivileged( - new PrivilegedExceptionAction() { - public T run() throws Exception { - ClassLoader savedcl = null; - Thread t = Thread.currentThread(); - try { - ClassLoader cl = t.getContextClassLoader(); - if (ccl != cl) { - t.setContextClassLoader(ccl); - savedcl = cl; - } - return task.call(); - } finally { - if (savedcl != null) - t.setContextClassLoader(savedcl); - } - } - }, acc); - } catch (PrivilegedActionException e) { - throw e.getException(); - } - } - } - - /** - * The default thread factory - */ - static class DefaultThreadFactory implements ThreadFactory { - private static final AtomicInteger poolNumber = new AtomicInteger(1); - private final ThreadGroup group; - private final AtomicInteger threadNumber = new AtomicInteger(1); - private final String namePrefix; - - DefaultThreadFactory() { - SecurityManager s = System.getSecurityManager(); - group = (s != null)? s.getThreadGroup() : - Thread.currentThread().getThreadGroup(); - namePrefix = "pool-" + - poolNumber.getAndIncrement() + - "-thread-"; - } - - public Thread newThread(Runnable r) { - Thread t = new Thread(group, r, - namePrefix + threadNumber.getAndIncrement(), - 0); - if (t.isDaemon()) - t.setDaemon(false); - if (t.getPriority() != Thread.NORM_PRIORITY) - t.setPriority(Thread.NORM_PRIORITY); - return t; - } - } - - /** - * Thread factory capturing access control context and class loader - */ - static class PrivilegedThreadFactory extends DefaultThreadFactory { - private final AccessControlContext acc; - private final ClassLoader ccl; - - PrivilegedThreadFactory() { - super(); - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - // Calls to getContextClassLoader from this class - // never trigger a security check, but we check - // whether our callers have this permission anyways. - sm.checkPermission(new RuntimePermission("getContextClassLoader")); - - // Fail fast - sm.checkPermission(new RuntimePermission("setContextClassLoader")); - } - this.acc = AccessController.getContext(); - this.ccl = Thread.currentThread().getContextClassLoader(); - } - - public Thread newThread(final Runnable r) { - return super.newThread(new Runnable() { - public void run() { - AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - Thread.currentThread().setContextClassLoader(ccl); - r.run(); - return null; - } - }, acc); - } - }); - } - } - - /** - * A wrapper class that exposes only the ExecutorService methods - * of an ExecutorService implementation. - */ - static class DelegatedExecutorService extends AbstractExecutorService { - private final ExecutorService e; - DelegatedExecutorService(ExecutorService executor) { e = executor; } - public void execute(Runnable command) { e.execute(command); } - public void shutdown() { e.shutdown(); } - public List shutdownNow() { return e.shutdownNow(); } - public boolean isShutdown() { return e.isShutdown(); } - public boolean isTerminated() { return e.isTerminated(); } - public boolean awaitTermination(long timeout, TimeUnit unit) - throws InterruptedException { - return e.awaitTermination(timeout, unit); - } - public Future submit(Runnable task) { - return e.submit(task); - } - public Future submit(Callable task) { - return e.submit(task); - } - public Future submit(Runnable task, T result) { - return e.submit(task, result); - } - public List> invokeAll(Collection> tasks) - throws InterruptedException { - return e.invokeAll(tasks); - } - public List> invokeAll(Collection> tasks, - long timeout, TimeUnit unit) - throws InterruptedException { - return e.invokeAll(tasks, timeout, unit); - } - public T invokeAny(Collection> tasks) - throws InterruptedException, ExecutionException { - return e.invokeAny(tasks); - } - public T invokeAny(Collection> tasks, - long timeout, TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException { - return e.invokeAny(tasks, timeout, unit); - } - } - - static class FinalizableDelegatedExecutorService - extends DelegatedExecutorService { - FinalizableDelegatedExecutorService(ExecutorService executor) { - super(executor); - } - protected void finalize() { - super.shutdown(); - } - } - - /** - * A wrapper class that exposes only the ScheduledExecutorService - * methods of a ScheduledExecutorService implementation. - */ - static class DelegatedScheduledExecutorService - extends DelegatedExecutorService - implements ScheduledExecutorService { - private final ScheduledExecutorService e; - DelegatedScheduledExecutorService(ScheduledExecutorService executor) { - super(executor); - e = executor; - } - public ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) { - return e.schedule(command, delay, unit); - } - public ScheduledFuture schedule(Callable callable, long delay, TimeUnit unit) { - return e.schedule(callable, delay, unit); - } - public ScheduledFuture scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { - return e.scheduleAtFixedRate(command, initialDelay, period, unit); - } - public ScheduledFuture scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) { - return e.scheduleWithFixedDelay(command, initialDelay, delay, unit); - } - } - - - /** Cannot instantiate. */ - private Executors() {} -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/Future.java b/libcore/concurrent/src/main/java/java/util/concurrent/Future.java deleted file mode 100644 index 0459ee453..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/Future.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; - -/** - * A Future represents the result of an asynchronous - * computation. Methods are provided to check if the computation is - * complete, to wait for its completion, and to retrieve the result of - * the computation. The result can only be retrieved using method - * get when the computation has completed, blocking if - * necessary until it is ready. Cancellation is performed by the - * cancel method. Additional methods are provided to - * determine if the task completed normally or was cancelled. Once a - * computation has completed, the computation cannot be cancelled. - * If you would like to use a Future for the sake - * of cancellability but not provide a usable result, you can - * declare types of the form Future<?> and - * return null as a result of the underlying task. - * - *

- * Sample Usage (Note that the following classes are all - * made-up.)

- *

- * interface ArchiveSearcher { String search(String target); }
- * class App {
- *   ExecutorService executor = ...
- *   ArchiveSearcher searcher = ...
- *   void showSearch(final String target)
- *       throws InterruptedException {
- *     Future<String> future
- *       = executor.submit(new Callable<String>() {
- *         public String call() {
- *             return searcher.search(target);
- *         }});
- *     displayOtherThings(); // do other things while searching
- *     try {
- *       displayText(future.get()); // use future
- *     } catch (ExecutionException ex) { cleanup(); return; }
- *   }
- * }
- * 
- * - * The {@link FutureTask} class is an implementation of Future that - * implements Runnable, and so may be executed by an Executor. - * For example, the above construction with submit could be replaced by: - *
- *     FutureTask<String> future =
- *       new FutureTask<String>(new Callable<String>() {
- *         public String call() {
- *           return searcher.search(target);
- *       }});
- *     executor.execute(future);
- * 
- * - *

Memory consistency effects: Actions taken by the asynchronous computation - * happen-before - * actions following the corresponding {@code Future.get()} in another thread. - * - * @see FutureTask - * @see Executor - * @since 1.5 - * @author Doug Lea - * @param The result type returned by this Future's get method - */ -public interface Future { - - /** - * Attempts to cancel execution of this task. This attempt will - * fail if the task has already completed, has already been cancelled, - * or could not be cancelled for some other reason. If successful, - * and this task has not started when cancel is called, - * this task should never run. If the task has already started, - * then the mayInterruptIfRunning parameter determines - * whether the thread executing this task should be interrupted in - * an attempt to stop the task. - * - *

After this method returns, subsequent calls to {@link #isDone} will - * always return true. Subsequent calls to {@link #isCancelled} - * will always return true if this method returned true. - * - * @param mayInterruptIfRunning true if the thread executing this - * task should be interrupted; otherwise, in-progress tasks are allowed - * to complete - * @return false if the task could not be cancelled, - * typically because it has already completed normally; - * true otherwise - */ - boolean cancel(boolean mayInterruptIfRunning); - - /** - * Returns true if this task was cancelled before it completed - * normally. - * - * @return true if this task was cancelled before it completed - */ - boolean isCancelled(); - - /** - * Returns true if this task completed. - * - * Completion may be due to normal termination, an exception, or - * cancellation -- in all of these cases, this method will return - * true. - * - * @return true if this task completed - */ - boolean isDone(); - - /** - * Waits if necessary for the computation to complete, and then - * retrieves its result. - * - * @return the computed result - * @throws CancellationException if the computation was cancelled - * @throws ExecutionException if the computation threw an - * exception - * @throws InterruptedException if the current thread was interrupted - * while waiting - */ - V get() throws InterruptedException, ExecutionException; - - /** - * Waits if necessary for at most the given time for the computation - * to complete, and then retrieves its result, if available. - * - * @param timeout the maximum time to wait - * @param unit the time unit of the timeout argument - * @return the computed result - * @throws CancellationException if the computation was cancelled - * @throws ExecutionException if the computation threw an - * exception - * @throws InterruptedException if the current thread was interrupted - * while waiting - * @throws TimeoutException if the wait timed out - */ - V get(long timeout, TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException; -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/FutureTask.java b/libcore/concurrent/src/main/java/java/util/concurrent/FutureTask.java deleted file mode 100644 index 8aa9dd14f..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/FutureTask.java +++ /dev/null @@ -1,331 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; -import java.util.concurrent.locks.*; - -/** - * A cancellable asynchronous computation. This class provides a base - * implementation of {@link Future}, with methods to start and cancel - * a computation, query to see if the computation is complete, and - * retrieve the result of the computation. The result can only be - * retrieved when the computation has completed; the get - * method will block if the computation has not yet completed. Once - * the computation has completed, the computation cannot be restarted - * or cancelled. - * - *

A FutureTask can be used to wrap a {@link Callable} or - * {@link java.lang.Runnable} object. Because FutureTask - * implements Runnable, a FutureTask can be - * submitted to an {@link Executor} for execution. - * - *

In addition to serving as a standalone class, this class provides - * protected functionality that may be useful when creating - * customized task classes. - * - * @since 1.5 - * @author Doug Lea - * @param The result type returned by this FutureTask's get method - */ -public class FutureTask implements Future, Runnable { - /** Synchronization control for FutureTask */ - private final Sync sync; - - /** - * Creates a FutureTask that will, upon running, execute the - * given Callable. - * - * @param callable the callable task - * @throws NullPointerException if callable is null - */ - public FutureTask(Callable callable) { - if (callable == null) - throw new NullPointerException(); - sync = new Sync(callable); - } - - /** - * Creates a FutureTask that will, upon running, execute the - * given Runnable, and arrange that get will return the - * given result on successful completion. - * - * @param runnable the runnable task - * @param result the result to return on successful completion. If - * you don't need a particular result, consider using - * constructions of the form: - * Future<?> f = new FutureTask<Object>(runnable, null) - * @throws NullPointerException if runnable is null - */ - public FutureTask(Runnable runnable, V result) { - sync = new Sync(Executors.callable(runnable, result)); - } - - public boolean isCancelled() { - return sync.innerIsCancelled(); - } - - public boolean isDone() { - return sync.innerIsDone(); - } - - public boolean cancel(boolean mayInterruptIfRunning) { - return sync.innerCancel(mayInterruptIfRunning); - } - - /** - * @throws CancellationException {@inheritDoc} - */ - public V get() throws InterruptedException, ExecutionException { - return sync.innerGet(); - } - - /** - * @throws CancellationException {@inheritDoc} - */ - public V get(long timeout, TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException { - return sync.innerGet(unit.toNanos(timeout)); - } - - /** - * Protected method invoked when this task transitions to state - * isDone (whether normally or via cancellation). The - * default implementation does nothing. Subclasses may override - * this method to invoke completion callbacks or perform - * bookkeeping. Note that you can query status inside the - * implementation of this method to determine whether this task - * has been cancelled. - */ - protected void done() { } - - /** - * Sets the result of this Future to the given value unless - * this future has already been set or has been cancelled. - * This method is invoked internally by the run method - * upon successful completion of the computation. - * @param v the value - */ - protected void set(V v) { - sync.innerSet(v); - } - - /** - * Causes this future to report an ExecutionException - * with the given throwable as its cause, unless this Future has - * already been set or has been cancelled. - * This method is invoked internally by the run method - * upon failure of the computation. - * @param t the cause of failure - */ - protected void setException(Throwable t) { - sync.innerSetException(t); - } - - // The following (duplicated) doc comment can be removed once - // - // 6270645: Javadoc comments should be inherited from most derived - // superinterface or superclass - // is fixed. - /** - * Sets this Future to the result of its computation - * unless it has been cancelled. - */ - public void run() { - sync.innerRun(); - } - - /** - * Executes the computation without setting its result, and then - * resets this Future to initial state, failing to do so if the - * computation encounters an exception or is cancelled. This is - * designed for use with tasks that intrinsically execute more - * than once. - * @return true if successfully run and reset - */ - protected boolean runAndReset() { - return sync.innerRunAndReset(); - } - - /** - * Synchronization control for FutureTask. Note that this must be - * a non-static inner class in order to invoke the protected - * done method. For clarity, all inner class support - * methods are same as outer, prefixed with "inner". - * - * Uses AQS sync state to represent run status - */ - private final class Sync extends AbstractQueuedSynchronizer { - private static final long serialVersionUID = -7828117401763700385L; - - /** State value representing that task is ready to run */ - private static final int READY = 0; - /** State value representing that task is running */ - private static final int RUNNING = 1; - /** State value representing that task ran */ - private static final int RAN = 2; - /** State value representing that task was cancelled */ - private static final int CANCELLED = 4; - - /** The underlying callable */ - private final Callable callable; - /** The result to return from get() */ - private V result; - /** The exception to throw from get() */ - private Throwable exception; - - /** - * The thread running task. When nulled after set/cancel, this - * indicates that the results are accessible. Must be - * volatile, to ensure visibility upon completion. - */ - private volatile Thread runner; - - Sync(Callable callable) { - this.callable = callable; - } - - private boolean ranOrCancelled(int state) { - return (state & (RAN | CANCELLED)) != 0; - } - - /** - * Implements AQS base acquire to succeed if ran or cancelled - */ - protected int tryAcquireShared(int ignore) { - return innerIsDone() ? 1 : -1; - } - - /** - * Implements AQS base release to always signal after setting - * final done status by nulling runner thread. - */ - protected boolean tryReleaseShared(int ignore) { - runner = null; - return true; - } - - boolean innerIsCancelled() { - return getState() == CANCELLED; - } - - boolean innerIsDone() { - return ranOrCancelled(getState()) && runner == null; - } - - V innerGet() throws InterruptedException, ExecutionException { - acquireSharedInterruptibly(0); - if (getState() == CANCELLED) - throw new CancellationException(); - if (exception != null) - throw new ExecutionException(exception); - return result; - } - - V innerGet(long nanosTimeout) throws InterruptedException, ExecutionException, TimeoutException { - if (!tryAcquireSharedNanos(0, nanosTimeout)) - throw new TimeoutException(); - if (getState() == CANCELLED) - throw new CancellationException(); - if (exception != null) - throw new ExecutionException(exception); - return result; - } - - void innerSet(V v) { - for (;;) { - int s = getState(); - if (s == RAN) - return; - if (s == CANCELLED) { - // aggressively release to set runner to null, - // in case we are racing with a cancel request - // that will try to interrupt runner - releaseShared(0); - return; - } - if (compareAndSetState(s, RAN)) { - result = v; - releaseShared(0); - done(); - return; - } - } - } - - void innerSetException(Throwable t) { - for (;;) { - int s = getState(); - if (s == RAN) - return; - if (s == CANCELLED) { - // aggressively release to set runner to null, - // in case we are racing with a cancel request - // that will try to interrupt runner - releaseShared(0); - return; - } - if (compareAndSetState(s, RAN)) { - exception = t; - releaseShared(0); - done(); - return; - } - } - } - - boolean innerCancel(boolean mayInterruptIfRunning) { - for (;;) { - int s = getState(); - if (ranOrCancelled(s)) - return false; - if (compareAndSetState(s, CANCELLED)) - break; - } - if (mayInterruptIfRunning) { - Thread r = runner; - if (r != null) - r.interrupt(); - } - releaseShared(0); - done(); - return true; - } - - void innerRun() { - if (!compareAndSetState(READY, RUNNING)) - return; - - runner = Thread.currentThread(); - if (getState() == RUNNING) { // recheck after setting thread - V result; - try { - result = callable.call(); - } catch (Throwable ex) { - setException(ex); - return; - } - set(result); - } else { - releaseShared(0); // cancel - } - } - - boolean innerRunAndReset() { - if (!compareAndSetState(READY, RUNNING)) - return false; - try { - runner = Thread.currentThread(); - if (getState() == RUNNING) - callable.call(); // don't set result - runner = null; - return compareAndSetState(RUNNING, READY); - } catch (Throwable ex) { - setException(ex); - return false; - } - } - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/Java6Arrays.java b/libcore/concurrent/src/main/java/java/util/concurrent/Java6Arrays.java deleted file mode 100644 index 6b728bef1..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/Java6Arrays.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.concurrent; - -import java.lang.reflect.Array; - -/** - * Arrays.copyOf and Arrays.copyOfRange backported from Java 6. - */ -class Java6Arrays { - - static T[] copyOf(T[] original, int newLength) { - if (null == original) { - throw new NullPointerException(); - } - if (0 <= newLength) { - return copyOfRange(original, 0, newLength); - } - throw new NegativeArraySizeException(); - } - - static T[] copyOf(U[] original, int newLength, - Class newType) { - if (0 <= newLength) { - return copyOfRange(original, 0, newLength, newType); - } - throw new NegativeArraySizeException(); - } - - @SuppressWarnings("unchecked") - static T[] copyOfRange(T[] original, int start, int end) { - if (original.length >= start && 0 <= start) { - if (start <= end) { - int length = end - start; - int copyLength = Math.min(length, original.length - start); - T[] copy = (T[]) Array.newInstance(original.getClass().getComponentType(), length); - System.arraycopy(original, start, copy, 0, copyLength); - return copy; - } - throw new IllegalArgumentException(); - } - throw new ArrayIndexOutOfBoundsException(); - } - - @SuppressWarnings("unchecked") - static T[] copyOfRange(U[] original, int start, int end, - Class newType) { - if (start <= end) { - if (original.length >= start && 0 <= start) { - int length = end - start; - int copyLength = Math.min(length, original.length - start); - T[] copy = (T[]) Array.newInstance(newType.getComponentType(), - length); - System.arraycopy(original, start, copy, 0, copyLength); - return copy; - } - throw new ArrayIndexOutOfBoundsException(); - } - throw new IllegalArgumentException(); - } - -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/LinkedBlockingQueue.java b/libcore/concurrent/src/main/java/java/util/concurrent/LinkedBlockingQueue.java deleted file mode 100644 index e06f7bd52..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/LinkedBlockingQueue.java +++ /dev/null @@ -1,809 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; -import java.util.concurrent.atomic.*; -import java.util.concurrent.locks.*; -import java.util.*; - -// BEGIN android-note -// removed link to collections framework docs -// END android-note - -/** - * An optionally-bounded {@linkplain BlockingQueue blocking queue} based on - * linked nodes. - * This queue orders elements FIFO (first-in-first-out). - * The head of the queue is that element that has been on the - * queue the longest time. - * The tail of the queue is that element that has been on the - * queue the shortest time. New elements - * are inserted at the tail of the queue, and the queue retrieval - * operations obtain elements at the head of the queue. - * Linked queues typically have higher throughput than array-based queues but - * less predictable performance in most concurrent applications. - * - *

The optional capacity bound constructor argument serves as a - * way to prevent excessive queue expansion. The capacity, if unspecified, - * is equal to {@link Integer#MAX_VALUE}. Linked nodes are - * dynamically created upon each insertion unless this would bring the - * queue above capacity. - * - *

This class and its iterator implement all of the - * optional methods of the {@link Collection} and {@link - * Iterator} interfaces. - * - * @since 1.5 - * @author Doug Lea - * @param the type of elements held in this collection - * - */ -public class LinkedBlockingQueue extends AbstractQueue - implements BlockingQueue, java.io.Serializable { - private static final long serialVersionUID = -6903933977591709194L; - - /* - * A variant of the "two lock queue" algorithm. The putLock gates - * entry to put (and offer), and has an associated condition for - * waiting puts. Similarly for the takeLock. The "count" field - * that they both rely on is maintained as an atomic to avoid - * needing to get both locks in most cases. Also, to minimize need - * for puts to get takeLock and vice-versa, cascading notifies are - * used. When a put notices that it has enabled at least one take, - * it signals taker. That taker in turn signals others if more - * items have been entered since the signal. And symmetrically for - * takes signalling puts. Operations such as remove(Object) and - * iterators acquire both locks. - */ - - /** - * Linked list node class - */ - static class Node { - /** The item, volatile to ensure barrier separating write and read */ - volatile E item; - Node next; - Node(E x) { item = x; } - } - - /** The capacity bound, or Integer.MAX_VALUE if none */ - private final int capacity; - - /** Current number of elements */ - private final AtomicInteger count = new AtomicInteger(0); - - /** Head of linked list */ - private transient Node head; - - /** Tail of linked list */ - private transient Node last; - - /** Lock held by take, poll, etc */ - private final ReentrantLock takeLock = new ReentrantLock(); - - /** Wait queue for waiting takes */ - private final Condition notEmpty = takeLock.newCondition(); - - /** Lock held by put, offer, etc */ - private final ReentrantLock putLock = new ReentrantLock(); - - /** Wait queue for waiting puts */ - private final Condition notFull = putLock.newCondition(); - - /** - * Signals a waiting take. Called only from put/offer (which do not - * otherwise ordinarily lock takeLock.) - */ - private void signalNotEmpty() { - final ReentrantLock takeLock = this.takeLock; - takeLock.lock(); - try { - notEmpty.signal(); - } finally { - takeLock.unlock(); - } - } - - /** - * Signals a waiting put. Called only from take/poll. - */ - private void signalNotFull() { - final ReentrantLock putLock = this.putLock; - putLock.lock(); - try { - notFull.signal(); - } finally { - putLock.unlock(); - } - } - - /** - * Creates a node and links it at end of queue. - * @param x the item - */ - private void insert(E x) { - last = last.next = new Node(x); - } - - /** - * Removes a node from head of queue, - * @return the node - */ - private E extract() { - Node h = head; - Node first = h.next; - h.next = null; // help GC - head = first; - E x = first.item; - first.item = null; - return x; - } - - /** - * Lock to prevent both puts and takes. - */ - private void fullyLock() { - putLock.lock(); - takeLock.lock(); - } - - /** - * Unlock to allow both puts and takes. - */ - private void fullyUnlock() { - takeLock.unlock(); - putLock.unlock(); - } - - - /** - * Creates a LinkedBlockingQueue with a capacity of - * {@link Integer#MAX_VALUE}. - */ - public LinkedBlockingQueue() { - this(Integer.MAX_VALUE); - } - - /** - * Creates a LinkedBlockingQueue with the given (fixed) capacity. - * - * @param capacity the capacity of this queue - * @throws IllegalArgumentException if capacity is not greater - * than zero - */ - public LinkedBlockingQueue(int capacity) { - if (capacity <= 0) throw new IllegalArgumentException(); - this.capacity = capacity; - last = head = new Node(null); - } - - /** - * Creates a LinkedBlockingQueue with a capacity of - * {@link Integer#MAX_VALUE}, initially containing the elements of the - * given collection, - * added in traversal order of the collection's iterator. - * - * @param c the collection of elements to initially contain - * @throws NullPointerException if the specified collection or any - * of its elements are null - */ - public LinkedBlockingQueue(Collection c) { - this(Integer.MAX_VALUE); - for (E e : c) - add(e); - } - - - // this doc comment is overridden to remove the reference to collections - // greater in size than Integer.MAX_VALUE - /** - * Returns the number of elements in this queue. - * - * @return the number of elements in this queue - */ - public int size() { - return count.get(); - } - - // this doc comment is a modified copy of the inherited doc comment, - // without the reference to unlimited queues. - /** - * Returns the number of additional elements that this queue can ideally - * (in the absence of memory or resource constraints) accept without - * blocking. This is always equal to the initial capacity of this queue - * less the current size of this queue. - * - *

Note that you cannot always tell if an attempt to insert - * an element will succeed by inspecting remainingCapacity - * because it may be the case that another thread is about to - * insert or remove an element. - */ - public int remainingCapacity() { - return capacity - count.get(); - } - - /** - * Inserts the specified element at the tail of this queue, waiting if - * necessary for space to become available. - * - * @throws InterruptedException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - */ - public void put(E e) throws InterruptedException { - if (e == null) throw new NullPointerException(); - // Note: convention in all put/take/etc is to preset - // local var holding count negative to indicate failure unless set. - int c = -1; - final ReentrantLock putLock = this.putLock; - final AtomicInteger count = this.count; - putLock.lockInterruptibly(); - try { - /* - * Note that count is used in wait guard even though it is - * not protected by lock. This works because count can - * only decrease at this point (all other puts are shut - * out by lock), and we (or some other waiting put) are - * signalled if it ever changes from - * capacity. Similarly for all other uses of count in - * other wait guards. - */ - try { - while (count.get() == capacity) - notFull.await(); - } catch (InterruptedException ie) { - notFull.signal(); // propagate to a non-interrupted thread - throw ie; - } - insert(e); - c = count.getAndIncrement(); - if (c + 1 < capacity) - notFull.signal(); - } finally { - putLock.unlock(); - } - if (c == 0) - signalNotEmpty(); - } - - /** - * Inserts the specified element at the tail of this queue, waiting if - * necessary up to the specified wait time for space to become available. - * - * @return true if successful, or false if - * the specified waiting time elapses before space is available. - * @throws InterruptedException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - */ - public boolean offer(E e, long timeout, TimeUnit unit) - throws InterruptedException { - - if (e == null) throw new NullPointerException(); - long nanos = unit.toNanos(timeout); - int c = -1; - final ReentrantLock putLock = this.putLock; - final AtomicInteger count = this.count; - putLock.lockInterruptibly(); - try { - for (;;) { - if (count.get() < capacity) { - insert(e); - c = count.getAndIncrement(); - if (c + 1 < capacity) - notFull.signal(); - break; - } - if (nanos <= 0) - return false; - try { - nanos = notFull.awaitNanos(nanos); - } catch (InterruptedException ie) { - notFull.signal(); // propagate to a non-interrupted thread - throw ie; - } - } - } finally { - putLock.unlock(); - } - if (c == 0) - signalNotEmpty(); - return true; - } - - /** - * Inserts the specified element at the tail of this queue if it is - * possible to do so immediately without exceeding the queue's capacity, - * returning true upon success and false if this queue - * is full. - * When using a capacity-restricted queue, this method is generally - * preferable to method {@link BlockingQueue#add add}, which can fail to - * insert an element only by throwing an exception. - * - * @throws NullPointerException if the specified element is null - */ - public boolean offer(E e) { - if (e == null) throw new NullPointerException(); - final AtomicInteger count = this.count; - if (count.get() == capacity) - return false; - int c = -1; - final ReentrantLock putLock = this.putLock; - putLock.lock(); - try { - if (count.get() < capacity) { - insert(e); - c = count.getAndIncrement(); - if (c + 1 < capacity) - notFull.signal(); - } - } finally { - putLock.unlock(); - } - if (c == 0) - signalNotEmpty(); - return c >= 0; - } - - - public E take() throws InterruptedException { - E x; - int c = -1; - final AtomicInteger count = this.count; - final ReentrantLock takeLock = this.takeLock; - takeLock.lockInterruptibly(); - try { - try { - while (count.get() == 0) - notEmpty.await(); - } catch (InterruptedException ie) { - notEmpty.signal(); // propagate to a non-interrupted thread - throw ie; - } - - x = extract(); - c = count.getAndDecrement(); - if (c > 1) - notEmpty.signal(); - } finally { - takeLock.unlock(); - } - if (c == capacity) - signalNotFull(); - return x; - } - - public E poll(long timeout, TimeUnit unit) throws InterruptedException { - E x = null; - int c = -1; - long nanos = unit.toNanos(timeout); - final AtomicInteger count = this.count; - final ReentrantLock takeLock = this.takeLock; - takeLock.lockInterruptibly(); - try { - for (;;) { - if (count.get() > 0) { - x = extract(); - c = count.getAndDecrement(); - if (c > 1) - notEmpty.signal(); - break; - } - if (nanos <= 0) - return null; - try { - nanos = notEmpty.awaitNanos(nanos); - } catch (InterruptedException ie) { - notEmpty.signal(); // propagate to a non-interrupted thread - throw ie; - } - } - } finally { - takeLock.unlock(); - } - if (c == capacity) - signalNotFull(); - return x; - } - - public E poll() { - final AtomicInteger count = this.count; - if (count.get() == 0) - return null; - E x = null; - int c = -1; - final ReentrantLock takeLock = this.takeLock; - takeLock.lock(); - try { - if (count.get() > 0) { - x = extract(); - c = count.getAndDecrement(); - if (c > 1) - notEmpty.signal(); - } - } finally { - takeLock.unlock(); - } - if (c == capacity) - signalNotFull(); - return x; - } - - - public E peek() { - if (count.get() == 0) - return null; - final ReentrantLock takeLock = this.takeLock; - takeLock.lock(); - try { - Node first = head.next; - if (first == null) - return null; - else - return first.item; - } finally { - takeLock.unlock(); - } - } - - /** - * Removes a single instance of the specified element from this queue, - * if it is present. More formally, removes an element e such - * that o.equals(e), if this queue contains one or more such - * elements. - * Returns true if this queue contained the specified element - * (or equivalently, if this queue changed as a result of the call). - * - * @param o element to be removed from this queue, if present - * @return true if this queue changed as a result of the call - */ - public boolean remove(Object o) { - if (o == null) return false; - boolean removed = false; - fullyLock(); - try { - Node trail = head; - Node p = head.next; - while (p != null) { - if (o.equals(p.item)) { - removed = true; - break; - } - trail = p; - p = p.next; - } - if (removed) { - p.item = null; - trail.next = p.next; - if (last == p) - last = trail; - if (count.getAndDecrement() == capacity) - notFull.signalAll(); - } - } finally { - fullyUnlock(); - } - return removed; - } - - /** - * Returns an array containing all of the elements in this queue, in - * proper sequence. - * - *

The returned array will be "safe" in that no references to it are - * maintained by this queue. (In other words, this method must allocate - * a new array). The caller is thus free to modify the returned array. - * - *

This method acts as bridge between array-based and collection-based - * APIs. - * - * @return an array containing all of the elements in this queue - */ - public Object[] toArray() { - fullyLock(); - try { - int size = count.get(); - Object[] a = new Object[size]; - int k = 0; - for (Node p = head.next; p != null; p = p.next) - a[k++] = p.item; - return a; - } finally { - fullyUnlock(); - } - } - - /** - * Returns an array containing all of the elements in this queue, in - * proper sequence; the runtime type of the returned array is that of - * the specified array. If the queue fits in the specified array, it - * is returned therein. Otherwise, a new array is allocated with the - * runtime type of the specified array and the size of this queue. - * - *

If this queue fits in the specified array with room to spare - * (i.e., the array has more elements than this queue), the element in - * the array immediately following the end of the queue is set to - * null. - * - *

Like the {@link #toArray()} method, this method acts as bridge between - * array-based and collection-based APIs. Further, this method allows - * precise control over the runtime type of the output array, and may, - * under certain circumstances, be used to save allocation costs. - * - *

Suppose x is a queue known to contain only strings. - * The following code can be used to dump the queue into a newly - * allocated array of String: - * - *

-     *     String[] y = x.toArray(new String[0]);
- * - * Note that toArray(new Object[0]) is identical in function to - * toArray(). - * - * @param a the array into which the elements of the queue are to - * be stored, if it is big enough; otherwise, a new array of the - * same runtime type is allocated for this purpose - * @return an array containing all of the elements in this queue - * @throws ArrayStoreException if the runtime type of the specified array - * is not a supertype of the runtime type of every element in - * this queue - * @throws NullPointerException if the specified array is null - */ - public T[] toArray(T[] a) { - fullyLock(); - try { - int size = count.get(); - if (a.length < size) - a = (T[])java.lang.reflect.Array.newInstance - (a.getClass().getComponentType(), size); - - int k = 0; - for (Node p = head.next; p != null; p = p.next) - a[k++] = (T)p.item; - if (a.length > k) - a[k] = null; - return a; - } finally { - fullyUnlock(); - } - } - - public String toString() { - fullyLock(); - try { - return super.toString(); - } finally { - fullyUnlock(); - } - } - - /** - * Atomically removes all of the elements from this queue. - * The queue will be empty after this call returns. - */ - public void clear() { - fullyLock(); - try { - head.next = null; - assert head.item == null; - last = head; - if (count.getAndSet(0) == capacity) - notFull.signalAll(); - } finally { - fullyUnlock(); - } - } - - /** - * @throws UnsupportedOperationException {@inheritDoc} - * @throws ClassCastException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - * @throws IllegalArgumentException {@inheritDoc} - */ - public int drainTo(Collection c) { - if (c == null) - throw new NullPointerException(); - if (c == this) - throw new IllegalArgumentException(); - Node first; - fullyLock(); - try { - first = head.next; - head.next = null; - assert head.item == null; - last = head; - if (count.getAndSet(0) == capacity) - notFull.signalAll(); - } finally { - fullyUnlock(); - } - // Transfer the elements outside of locks - int n = 0; - for (Node p = first; p != null; p = p.next) { - c.add(p.item); - p.item = null; - ++n; - } - return n; - } - - /** - * @throws UnsupportedOperationException {@inheritDoc} - * @throws ClassCastException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - * @throws IllegalArgumentException {@inheritDoc} - */ - public int drainTo(Collection c, int maxElements) { - if (c == null) - throw new NullPointerException(); - if (c == this) - throw new IllegalArgumentException(); - fullyLock(); - try { - int n = 0; - Node p = head.next; - while (p != null && n < maxElements) { - c.add(p.item); - p.item = null; - p = p.next; - ++n; - } - if (n != 0) { - head.next = p; - assert head.item == null; - if (p == null) - last = head; - if (count.getAndAdd(-n) == capacity) - notFull.signalAll(); - } - return n; - } finally { - fullyUnlock(); - } - } - - /** - * Returns an iterator over the elements in this queue in proper sequence. - * The returned Iterator is a "weakly consistent" iterator that - * will never throw {@link ConcurrentModificationException}, - * and guarantees to traverse elements as they existed upon - * construction of the iterator, and may (but is not guaranteed to) - * reflect any modifications subsequent to construction. - * - * @return an iterator over the elements in this queue in proper sequence - */ - public Iterator iterator() { - return new Itr(); - } - - private class Itr implements Iterator { - /* - * Basic weak-consistent iterator. At all times hold the next - * item to hand out so that if hasNext() reports true, we will - * still have it to return even if lost race with a take etc. - */ - private Node current; - private Node lastRet; - private E currentElement; - - Itr() { - final ReentrantLock putLock = LinkedBlockingQueue.this.putLock; - final ReentrantLock takeLock = LinkedBlockingQueue.this.takeLock; - putLock.lock(); - takeLock.lock(); - try { - current = head.next; - if (current != null) - currentElement = current.item; - } finally { - takeLock.unlock(); - putLock.unlock(); - } - } - - public boolean hasNext() { - return current != null; - } - - public E next() { - final ReentrantLock putLock = LinkedBlockingQueue.this.putLock; - final ReentrantLock takeLock = LinkedBlockingQueue.this.takeLock; - putLock.lock(); - takeLock.lock(); - try { - if (current == null) - throw new NoSuchElementException(); - E x = currentElement; - lastRet = current; - current = current.next; - if (current != null) - currentElement = current.item; - return x; - } finally { - takeLock.unlock(); - putLock.unlock(); - } - } - - public void remove() { - if (lastRet == null) - throw new IllegalStateException(); - final ReentrantLock putLock = LinkedBlockingQueue.this.putLock; - final ReentrantLock takeLock = LinkedBlockingQueue.this.takeLock; - putLock.lock(); - takeLock.lock(); - try { - Node node = lastRet; - lastRet = null; - Node trail = head; - Node p = head.next; - while (p != null && p != node) { - trail = p; - p = p.next; - } - if (p == node) { - p.item = null; - trail.next = p.next; - if (last == p) - last = trail; - int c = count.getAndDecrement(); - if (c == capacity) - notFull.signalAll(); - } - } finally { - takeLock.unlock(); - putLock.unlock(); - } - } - } - - /** - * Save the state to a stream (that is, serialize it). - * - * @serialData The capacity is emitted (int), followed by all of - * its elements (each an Object) in the proper order, - * followed by a null - * @param s the stream - */ - private void writeObject(java.io.ObjectOutputStream s) - throws java.io.IOException { - - fullyLock(); - try { - // Write out any hidden stuff, plus capacity - s.defaultWriteObject(); - - // Write out all elements in the proper order. - for (Node p = head.next; p != null; p = p.next) - s.writeObject(p.item); - - // Use trailing null as sentinel - s.writeObject(null); - } finally { - fullyUnlock(); - } - } - - /** - * Reconstitute this queue instance from a stream (that is, - * deserialize it). - * @param s the stream - */ - private void readObject(java.io.ObjectInputStream s) - throws java.io.IOException, ClassNotFoundException { - // Read in capacity, and any hidden stuff - s.defaultReadObject(); - - count.set(0); - last = head = new Node(null); - - // Read in all elements and place in queue - for (;;) { - E item = (E)s.readObject(); - if (item == null) - break; - add(item); - } - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/PriorityBlockingQueue.java b/libcore/concurrent/src/main/java/java/util/concurrent/PriorityBlockingQueue.java deleted file mode 100644 index 7a33dc7f2..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/PriorityBlockingQueue.java +++ /dev/null @@ -1,564 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; - -import java.util.concurrent.locks.*; -import java.util.*; - -// BEGIN android-note -// removed link to collections framework docs -// END android-note - -/** - * An unbounded {@linkplain BlockingQueue blocking queue} that uses - * the same ordering rules as class {@link PriorityQueue} and supplies - * blocking retrieval operations. While this queue is logically - * unbounded, attempted additions may fail due to resource exhaustion - * (causing OutOfMemoryError). This class does not permit - * null elements. A priority queue relying on {@linkplain - * Comparable natural ordering} also does not permit insertion of - * non-comparable objects (doing so results in - * ClassCastException). - * - *

This class and its iterator implement all of the - * optional methods of the {@link Collection} and {@link - * Iterator} interfaces. The Iterator provided in method {@link - * #iterator()} is not guaranteed to traverse the elements of - * the PriorityBlockingQueue in any particular order. If you need - * ordered traversal, consider using - * Arrays.sort(pq.toArray()). Also, method drainTo - * can be used to remove some or all elements in priority - * order and place them in another collection. - * - *

Operations on this class make no guarantees about the ordering - * of elements with equal priority. If you need to enforce an - * ordering, you can define custom classes or comparators that use a - * secondary key to break ties in primary priority values. For - * example, here is a class that applies first-in-first-out - * tie-breaking to comparable elements. To use it, you would insert a - * new FIFOEntry(anEntry) instead of a plain entry object. - * - *

- * class FIFOEntry<E extends Comparable<? super E>>
- *     implements Comparable<FIFOEntry<E>> {
- *   final static AtomicLong seq = new AtomicLong();
- *   final long seqNum;
- *   final E entry;
- *   public FIFOEntry(E entry) {
- *     seqNum = seq.getAndIncrement();
- *     this.entry = entry;
- *   }
- *   public E getEntry() { return entry; }
- *   public int compareTo(FIFOEntry<E> other) {
- *     int res = entry.compareTo(other.entry);
- *     if (res == 0 && other.entry != this.entry)
- *       res = (seqNum < other.seqNum ? -1 : 1);
- *     return res;
- *   }
- * }
- * - * @since 1.5 - * @author Doug Lea - * @param the type of elements held in this collection - */ -public class PriorityBlockingQueue extends AbstractQueue - implements BlockingQueue, java.io.Serializable { - private static final long serialVersionUID = 5595510919245408276L; - - private final PriorityQueue q; - private final ReentrantLock lock = new ReentrantLock(true); - private final Condition notEmpty = lock.newCondition(); - - /** - * Creates a PriorityBlockingQueue with the default - * initial capacity (11) that orders its elements according to - * their {@linkplain Comparable natural ordering}. - */ - public PriorityBlockingQueue() { - q = new PriorityQueue(); - } - - /** - * Creates a PriorityBlockingQueue with the specified - * initial capacity that orders its elements according to their - * {@linkplain Comparable natural ordering}. - * - * @param initialCapacity the initial capacity for this priority queue - * @throws IllegalArgumentException if initialCapacity is less - * than 1 - */ - public PriorityBlockingQueue(int initialCapacity) { - q = new PriorityQueue(initialCapacity, null); - } - - /** - * Creates a PriorityBlockingQueue with the specified initial - * capacity that orders its elements according to the specified - * comparator. - * - * @param initialCapacity the initial capacity for this priority queue - * @param comparator the comparator that will be used to order this - * priority queue. If {@code null}, the {@linkplain Comparable - * natural ordering} of the elements will be used. - * @throws IllegalArgumentException if initialCapacity is less - * than 1 - */ - public PriorityBlockingQueue(int initialCapacity, - Comparator comparator) { - q = new PriorityQueue(initialCapacity, comparator); - } - - /** - * Creates a PriorityBlockingQueue containing the elements - * in the specified collection. If the specified collection is a - * {@link SortedSet} or a {@link PriorityQueue}, this - * priority queue will be ordered according to the same ordering. - * Otherwise, this priority queue will be ordered according to the - * {@linkplain Comparable natural ordering} of its elements. - * - * @param c the collection whose elements are to be placed - * into this priority queue - * @throws ClassCastException if elements of the specified collection - * cannot be compared to one another according to the priority - * queue's ordering - * @throws NullPointerException if the specified collection or any - * of its elements are null - */ - public PriorityBlockingQueue(Collection c) { - q = new PriorityQueue(c); - } - - /** - * Inserts the specified element into this priority queue. - * - * @param e the element to add - * @return true (as specified by {@link Collection#add}) - * @throws ClassCastException if the specified element cannot be compared - * with elements currently in the priority queue according to the - * priority queue's ordering - * @throws NullPointerException if the specified element is null - */ - public boolean add(E e) { - return offer(e); - } - - // BEGIN android-changed - /** - * Inserts the specified element into this priority queue. - * - * @param e the element to add - * @return true (as specified by {@link Queue#offer}) - * @throws ClassCastException if the specified element cannot be compared - * with elements currently in the priority queue according to the - * priority queue's ordering - * @throws NullPointerException if the specified element is null - */ - public boolean offer(E e) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - boolean ok = q.offer(e); - assert ok; - notEmpty.signal(); - return true; - } finally { - lock.unlock(); - } - } - - /** - * Inserts the specified element into this priority queue. As the queue is - * unbounded this method will never block. - * - * @param e the element to add - * @throws ClassCastException if the specified element cannot be compared - * with elements currently in the priority queue according to the - * priority queue's ordering - * @throws NullPointerException if the specified element is null - */ - public void put(E e) { - offer(e); // never need to block - } - - /** - * Inserts the specified element into this priority queue. As the queue is - * unbounded this method will never block. - * - * @param e the element to add - * @param timeout This parameter is ignored as the method never blocks - * @param unit This parameter is ignored as the method never blocks - * @return true - * @throws ClassCastException if the specified element cannot be compared - * with elements currently in the priority queue according to the - * priority queue's ordering - * @throws NullPointerException if the specified element is null - */ - public boolean offer(E e, long timeout, TimeUnit unit) { - return offer(e); // never need to block - } - - public E poll() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return q.poll(); - } finally { - lock.unlock(); - } - } - - public E take() throws InterruptedException { - final ReentrantLock lock = this.lock; - lock.lockInterruptibly(); - try { - try { - while (q.size() == 0) - notEmpty.await(); - } catch (InterruptedException ie) { - notEmpty.signal(); // propagate to non-interrupted thread - throw ie; - } - E x = q.poll(); - assert x != null; - return x; - } finally { - lock.unlock(); - } - } - - public E poll(long timeout, TimeUnit unit) throws InterruptedException { - long nanos = unit.toNanos(timeout); - final ReentrantLock lock = this.lock; - lock.lockInterruptibly(); - try { - for (;;) { - E x = q.poll(); - if (x != null) - return x; - if (nanos <= 0) - return null; - try { - nanos = notEmpty.awaitNanos(nanos); - } catch (InterruptedException ie) { - notEmpty.signal(); // propagate to non-interrupted thread - throw ie; - } - } - } finally { - lock.unlock(); - } - } - - public E peek() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return q.peek(); - } finally { - lock.unlock(); - } - } - - /** - * Returns the comparator used to order the elements in this queue, - * or null if this queue uses the {@linkplain Comparable - * natural ordering} of its elements. - * - * @return the comparator used to order the elements in this queue, - * or null if this queue uses the natural - * ordering of its elements - */ - public Comparator comparator() { - return q.comparator(); - } - - public int size() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return q.size(); - } finally { - lock.unlock(); - } - } - - /** - * Always returns Integer.MAX_VALUE because - * a PriorityBlockingQueue is not capacity constrained. - * @return Integer.MAX_VALUE - */ - public int remainingCapacity() { - return Integer.MAX_VALUE; - } - - /** - * Removes a single instance of the specified element from this queue, - * if it is present. More formally, removes an element {@code e} such - * that {@code o.equals(e)}, if this queue contains one or more such - * elements. Returns {@code true} if and only if this queue contained - * the specified element (or equivalently, if this queue changed as a - * result of the call). - * - * @param o element to be removed from this queue, if present - * @return true if this queue changed as a result of the call - */ - public boolean remove(Object o) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return q.remove(o); - } finally { - lock.unlock(); - } - } - - /** - * Returns {@code true} if this queue contains the specified element. - * More formally, returns {@code true} if and only if this queue contains - * at least one element {@code e} such that {@code o.equals(e)}. - * - * @param o object to be checked for containment in this queue - * @return true if this queue contains the specified element - */ - public boolean contains(Object o) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return q.contains(o); - } finally { - lock.unlock(); - } - } - - /** - * Returns an array containing all of the elements in this queue. - * The returned array elements are in no particular order. - * - *

The returned array will be "safe" in that no references to it are - * maintained by this queue. (In other words, this method must allocate - * a new array). The caller is thus free to modify the returned array. - * - *

This method acts as bridge between array-based and collection-based - * APIs. - * - * @return an array containing all of the elements in this queue - */ - public Object[] toArray() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return q.toArray(); - } finally { - lock.unlock(); - } - } - - - public String toString() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return q.toString(); - } finally { - lock.unlock(); - } - } - - /** - * @throws UnsupportedOperationException {@inheritDoc} - * @throws ClassCastException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - * @throws IllegalArgumentException {@inheritDoc} - */ - public int drainTo(Collection c) { - if (c == null) - throw new NullPointerException(); - if (c == this) - throw new IllegalArgumentException(); - final ReentrantLock lock = this.lock; - lock.lock(); - try { - int n = 0; - E e; - while ( (e = q.poll()) != null) { - c.add(e); - ++n; - } - return n; - } finally { - lock.unlock(); - } - } - - /** - * @throws UnsupportedOperationException {@inheritDoc} - * @throws ClassCastException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - * @throws IllegalArgumentException {@inheritDoc} - */ - public int drainTo(Collection c, int maxElements) { - if (c == null) - throw new NullPointerException(); - if (c == this) - throw new IllegalArgumentException(); - if (maxElements <= 0) - return 0; - final ReentrantLock lock = this.lock; - lock.lock(); - try { - int n = 0; - E e; - while (n < maxElements && (e = q.poll()) != null) { - c.add(e); - ++n; - } - return n; - } finally { - lock.unlock(); - } - } - - /** - * Atomically removes all of the elements from this queue. - * The queue will be empty after this call returns. - */ - public void clear() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - q.clear(); - } finally { - lock.unlock(); - } - } - - /** - * Returns an array containing all of the elements in this queue; the - * runtime type of the returned array is that of the specified array. - * The returned array elements are in no particular order. - * If the queue fits in the specified array, it is returned therein. - * Otherwise, a new array is allocated with the runtime type of the - * specified array and the size of this queue. - * - *

If this queue fits in the specified array with room to spare - * (i.e., the array has more elements than this queue), the element in - * the array immediately following the end of the queue is set to - * null. - * - *

Like the {@link #toArray()} method, this method acts as bridge between - * array-based and collection-based APIs. Further, this method allows - * precise control over the runtime type of the output array, and may, - * under certain circumstances, be used to save allocation costs. - * - *

Suppose x is a queue known to contain only strings. - * The following code can be used to dump the queue into a newly - * allocated array of String: - * - *

-     *     String[] y = x.toArray(new String[0]);
- * - * Note that toArray(new Object[0]) is identical in function to - * toArray(). - * - * @param a the array into which the elements of the queue are to - * be stored, if it is big enough; otherwise, a new array of the - * same runtime type is allocated for this purpose - * @return an array containing all of the elements in this queue - * @throws ArrayStoreException if the runtime type of the specified array - * is not a supertype of the runtime type of every element in - * this queue - * @throws NullPointerException if the specified array is null - */ - public T[] toArray(T[] a) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return q.toArray(a); - } finally { - lock.unlock(); - } - } - - /** - * Returns an iterator over the elements in this queue. The - * iterator does not return the elements in any particular order. - * The returned Iterator is a "weakly consistent" - * iterator that will never throw {@link - * ConcurrentModificationException}, and guarantees to traverse - * elements as they existed upon construction of the iterator, and - * may (but is not guaranteed to) reflect any modifications - * subsequent to construction. - * - * @return an iterator over the elements in this queue - */ - public Iterator iterator() { - return new Itr(toArray()); - } - - /** - * Snapshot iterator that works off copy of underlying q array. - */ - private class Itr implements Iterator { - final Object[] array; // Array of all elements - int cursor; // index of next element to return; - int lastRet; // index of last element, or -1 if no such - - Itr(Object[] array) { - lastRet = -1; - this.array = array; - } - - public boolean hasNext() { - return cursor < array.length; - } - - public E next() { - if (cursor >= array.length) - throw new NoSuchElementException(); - lastRet = cursor; - return (E)array[cursor++]; - } - - public void remove() { - if (lastRet < 0) - throw new IllegalStateException(); - Object x = array[lastRet]; - lastRet = -1; - // Traverse underlying queue to find == element, - // not just a .equals element. - lock.lock(); - try { - for (Iterator it = q.iterator(); it.hasNext(); ) { - if (it.next() == x) { - it.remove(); - return; - } - } - } finally { - lock.unlock(); - } - } - } - - /** - * Saves the state to a stream (that is, serializes it). This - * merely wraps default serialization within lock. The - * serialization strategy for items is left to underlying - * Queue. Note that locking is not needed on deserialization, so - * readObject is not defined, just relying on default. - */ - private void writeObject(java.io.ObjectOutputStream s) - throws java.io.IOException { - lock.lock(); - try { - s.defaultWriteObject(); - } finally { - lock.unlock(); - } - } - -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/RejectedExecutionException.java b/libcore/concurrent/src/main/java/java/util/concurrent/RejectedExecutionException.java deleted file mode 100644 index 30b043d66..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/RejectedExecutionException.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; - -/** - * Exception thrown by an {@link Executor} when a task cannot be - * accepted for execution. - * - * @since 1.5 - * @author Doug Lea - */ -public class RejectedExecutionException extends RuntimeException { - private static final long serialVersionUID = -375805702767069545L; - - /** - * Constructs a RejectedExecutionException with no detail message. - * The cause is not initialized, and may subsequently be - * initialized by a call to {@link #initCause(Throwable) initCause}. - */ - public RejectedExecutionException() { } - - /** - * Constructs a RejectedExecutionException with the - * specified detail message. The cause is not initialized, and may - * subsequently be initialized by a call to {@link - * #initCause(Throwable) initCause}. - * - * @param message the detail message - */ - public RejectedExecutionException(String message) { - super(message); - } - - /** - * Constructs a RejectedExecutionException with the - * specified detail message and cause. - * - * @param message the detail message - * @param cause the cause (which is saved for later retrieval by the - * {@link #getCause()} method) - */ - public RejectedExecutionException(String message, Throwable cause) { - super(message, cause); - } - - /** - * Constructs a RejectedExecutionException with the - * specified cause. The detail message is set to:
 (cause ==
-     * null ? null : cause.toString())
(which typically contains - * the class and detail message of cause). - * - * @param cause the cause (which is saved for later retrieval by the - * {@link #getCause()} method) - */ - public RejectedExecutionException(Throwable cause) { - super(cause); - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/RejectedExecutionHandler.java b/libcore/concurrent/src/main/java/java/util/concurrent/RejectedExecutionHandler.java deleted file mode 100644 index 417a27cdd..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/RejectedExecutionHandler.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; - -/** - * A handler for tasks that cannot be executed by a {@link ThreadPoolExecutor}. - * - * @since 1.5 - * @author Doug Lea - */ -public interface RejectedExecutionHandler { - - /** - * Method that may be invoked by a {@link ThreadPoolExecutor} when - * {@link ThreadPoolExecutor#execute execute} cannot accept a - * task. This may occur when no more threads or queue slots are - * available because their bounds would be exceeded, or upon - * shutdown of the Executor. - * - *

In the absence of other alternatives, the method may throw - * an unchecked {@link RejectedExecutionException}, which will be - * propagated to the caller of {@code execute}. - * - * @param r the runnable task requested to be executed - * @param executor the executor attempting to execute this task - * @throws RejectedExecutionException if there is no remedy - */ - void rejectedExecution(Runnable r, ThreadPoolExecutor executor); -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/ScheduledExecutorService.java b/libcore/concurrent/src/main/java/java/util/concurrent/ScheduledExecutorService.java deleted file mode 100644 index c170c4a52..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/ScheduledExecutorService.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; -import java.util.concurrent.atomic.*; -import java.util.*; - -/** - * An {@link ExecutorService} that can schedule commands to run after a given - * delay, or to execute periodically. - * - *

The schedule methods create tasks with various delays - * and return a task object that can be used to cancel or check - * execution. The scheduleAtFixedRate and - * scheduleWithFixedDelay methods create and execute tasks - * that run periodically until cancelled. - * - *

Commands submitted using the {@link Executor#execute} and - * {@link ExecutorService} submit methods are scheduled with - * a requested delay of zero. Zero and negative delays (but not - * periods) are also allowed in schedule methods, and are - * treated as requests for immediate execution. - * - *

All schedule methods accept relative delays and - * periods as arguments, not absolute times or dates. It is a simple - * matter to transform an absolute time represented as a {@link - * java.util.Date} to the required form. For example, to schedule at - * a certain future date, you can use: schedule(task, - * date.getTime() - System.currentTimeMillis(), - * TimeUnit.MILLISECONDS). Beware however that expiration of a - * relative delay need not coincide with the current Date at - * which the task is enabled due to network time synchronization - * protocols, clock drift, or other factors. - * - * The {@link Executors} class provides convenient factory methods for - * the ScheduledExecutorService implementations provided in this package. - * - *

Usage Example

- * - * Here is a class with a method that sets up a ScheduledExecutorService - * to beep every ten seconds for an hour: - * - *
- * import static java.util.concurrent.TimeUnit.*;
- * class BeeperControl {
- *    private final ScheduledExecutorService scheduler =
- *       Executors.newScheduledThreadPool(1);
- *
- *    public void beepForAnHour() {
- *        final Runnable beeper = new Runnable() {
- *                public void run() { System.out.println("beep"); }
- *            };
- *        final ScheduledFuture<?> beeperHandle =
- *            scheduler.scheduleAtFixedRate(beeper, 10, 10, SECONDS);
- *        scheduler.schedule(new Runnable() {
- *                public void run() { beeperHandle.cancel(true); }
- *            }, 60 * 60, SECONDS);
- *    }
- * }
- * 
- * - * @since 1.5 - * @author Doug Lea - */ -public interface ScheduledExecutorService extends ExecutorService { - - /** - * Creates and executes a one-shot action that becomes enabled - * after the given delay. - * - * @param command the task to execute - * @param delay the time from now to delay execution - * @param unit the time unit of the delay parameter - * @return a ScheduledFuture representing pending completion of - * the task and whose get() method will return - * null upon completion - * @throws RejectedExecutionException if the task cannot be - * scheduled for execution - * @throws NullPointerException if command is null - */ - public ScheduledFuture schedule(Runnable command, - long delay, TimeUnit unit); - - /** - * Creates and executes a ScheduledFuture that becomes enabled after the - * given delay. - * - * @param callable the function to execute - * @param delay the time from now to delay execution - * @param unit the time unit of the delay parameter - * @return a ScheduledFuture that can be used to extract result or cancel - * @throws RejectedExecutionException if the task cannot be - * scheduled for execution - * @throws NullPointerException if callable is null - */ - public ScheduledFuture schedule(Callable callable, - long delay, TimeUnit unit); - - /** - * Creates and executes a periodic action that becomes enabled first - * after the given initial delay, and subsequently with the given - * period; that is executions will commence after - * initialDelay then initialDelay+period, then - * initialDelay + 2 * period, and so on. - * If any execution of the task - * encounters an exception, subsequent executions are suppressed. - * Otherwise, the task will only terminate via cancellation or - * termination of the executor. If any execution of this task - * takes longer than its period, then subsequent executions - * may start late, but will not concurrently execute. - * - * @param command the task to execute - * @param initialDelay the time to delay first execution - * @param period the period between successive executions - * @param unit the time unit of the initialDelay and period parameters - * @return a ScheduledFuture representing pending completion of - * the task, and whose get() method will throw an - * exception upon cancellation - * @throws RejectedExecutionException if the task cannot be - * scheduled for execution - * @throws NullPointerException if command is null - * @throws IllegalArgumentException if period less than or equal to zero - */ - public ScheduledFuture scheduleAtFixedRate(Runnable command, - long initialDelay, - long period, - TimeUnit unit); - - /** - * Creates and executes a periodic action that becomes enabled first - * after the given initial delay, and subsequently with the - * given delay between the termination of one execution and the - * commencement of the next. If any execution of the task - * encounters an exception, subsequent executions are suppressed. - * Otherwise, the task will only terminate via cancellation or - * termination of the executor. - * - * @param command the task to execute - * @param initialDelay the time to delay first execution - * @param delay the delay between the termination of one - * execution and the commencement of the next - * @param unit the time unit of the initialDelay and delay parameters - * @return a ScheduledFuture representing pending completion of - * the task, and whose get() method will throw an - * exception upon cancellation - * @throws RejectedExecutionException if the task cannot be - * scheduled for execution - * @throws NullPointerException if command is null - * @throws IllegalArgumentException if delay less than or equal to zero - */ - public ScheduledFuture scheduleWithFixedDelay(Runnable command, - long initialDelay, - long delay, - TimeUnit unit); - -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/ScheduledFuture.java b/libcore/concurrent/src/main/java/java/util/concurrent/ScheduledFuture.java deleted file mode 100644 index 239d681f6..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/ScheduledFuture.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; - -/** - * A delayed result-bearing action that can be cancelled. - * Usually a scheduled future is the result of scheduling - * a task with a {@link ScheduledExecutorService}. - * - * @since 1.5 - * @author Doug Lea - * @param The result type returned by this Future - */ -public interface ScheduledFuture extends Delayed, Future { -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/ScheduledThreadPoolExecutor.java b/libcore/concurrent/src/main/java/java/util/concurrent/ScheduledThreadPoolExecutor.java deleted file mode 100644 index 83ffb99e3..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/ScheduledThreadPoolExecutor.java +++ /dev/null @@ -1,1134 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -/* - * Modified in Apache Harmony. - */ - -package java.util.concurrent; -import java.util.concurrent.atomic.*; -import java.util.concurrent.locks.*; -import java.util.*; - -/** - * A {@link ThreadPoolExecutor} that can additionally schedule - * commands to run after a given delay, or to execute - * periodically. This class is preferable to {@link java.util.Timer} - * when multiple worker threads are needed, or when the additional - * flexibility or capabilities of {@link ThreadPoolExecutor} (which - * this class extends) are required. - * - *

Delayed tasks execute no sooner than they are enabled, but - * without any real-time guarantees about when, after they are - * enabled, they will commence. Tasks scheduled for exactly the same - * execution time are enabled in first-in-first-out (FIFO) order of - * submission. - * - *

Successive executions of a task scheduled via - * scheduleAtFixedRate or - * scheduleWithFixedDelay do not overlap. While different - * executions may be performed by different threads, the effects of - * prior executions happen-before - * those of subsequent ones. - * - *

While this class inherits from {@link ThreadPoolExecutor}, a few - * of the inherited tuning methods are not useful for it. In - * particular, because it acts as a fixed-sized pool using {@code - * corePoolSize} threads and an unbounded queue, adjustments to {@code - * maximumPoolSize} have no useful effect. - * - * @since 1.5 - * @author Doug Lea - */ -public class ScheduledThreadPoolExecutor - extends ThreadPoolExecutor - implements ScheduledExecutorService { - - /* - * This class specializes ThreadPoolExecutor implementation by - * - * 1. Using a custom task type, ScheduledFutureTask for - * tasks, even those that don't require scheduling (i.e., - * those submitted using ExecutorService execute, not - * ScheduledExecutorService methods) which are treated as - * delayed tasks with a delay of zero. - * - * 2. Using a custom queue (DelayedWorkQueue), a variant of - * unbounded DelayQueue. The lack of capacity constraint and - * the fact that corePoolSize and maximumPoolSize are - * effectively identical simplifies some execution mechanics - * (see delayedExecute) compared to ThreadPoolExecutor. - * - * 3. Supporting optional run-after-shutdown parameters, which - * leads to overrides of shutdown methods to remove and cancel - * tasks that should NOT be run after shutdown, as well as - * different recheck logic when task (re)submission overlaps - * with a shutdown. - * - * 4. Task decoration methods to allow interception and - * instrumentation, which are needed because subclasses cannot - * otherwise override submit methods to get this effect. These - * don't have any impact on pool control logic though. - */ - - /** - * False if should cancel/suppress periodic tasks on shutdown. - */ - private volatile boolean continueExistingPeriodicTasksAfterShutdown; - - /** - * False if should cancel non-periodic tasks on shutdown. - */ - private volatile boolean executeExistingDelayedTasksAfterShutdown = true; - - /** - * True if ScheduledFutureTask.cancel should remove from queue - */ - private volatile boolean removeOnCancel = false; - - /** - * Sequence number to break scheduling ties, and in turn to - * guarantee FIFO order among tied entries. - */ - private static final AtomicLong sequencer = new AtomicLong(0); - - - /** - * Value of System.nanoTime upon static initialization. This is - * used as an offset by now() to avoid wraparound of time values - * that would make them appear negative. - */ - static final long initialNanoTime = System.nanoTime(); - - /** - * Returns current nanosecond time. - */ - static long now() { - return System.nanoTime() - initialNanoTime; - } - - private class ScheduledFutureTask - extends FutureTask implements ScheduledFuture { - - /** Sequence number to break ties FIFO */ - private final long sequenceNumber; - - /** The time the task is enabled to execute in nanoTime units */ - private long time; - - /** - * Period in nanoseconds for repeating tasks. A positive - * value indicates fixed-rate execution. A negative value - * indicates fixed-delay execution. A value of 0 indicates a - * non-repeating task. - */ - private final long period; - - /** The actual task to be re-enqueued by reExecutePeriodic */ - ScheduledFutureTask outerTask = this; - - /** - * Index into delay queue, to support faster cancellation. - */ - int heapIndex; - - /** - * Creates a one-shot action with given nanoTime-based trigger time. - */ - ScheduledFutureTask(Runnable r, V result, long ns) { - super(r, result); - this.time = ns; - this.period = 0; - this.sequenceNumber = sequencer.getAndIncrement(); - } - - /** - * Creates a periodic action with given nano time and period. - */ - ScheduledFutureTask(Runnable r, V result, long ns, long period) { - super(r, result); - this.time = ns; - this.period = period; - this.sequenceNumber = sequencer.getAndIncrement(); - } - - /** - * Creates a one-shot action with given nanoTime-based trigger. - */ - ScheduledFutureTask(Callable callable, long ns) { - super(callable); - this.time = ns; - this.period = 0; - this.sequenceNumber = sequencer.getAndIncrement(); - } - - public long getDelay(TimeUnit unit) { - long d = time - now(); - return d<=0? 0 : unit.convert(d, TimeUnit.NANOSECONDS); - } - - public int compareTo(Delayed other) { - if (other == this) // compare zero ONLY if same object - return 0; - if (other instanceof ScheduledFutureTask) { - ScheduledFutureTask x = (ScheduledFutureTask)other; - long diff = time - x.time; - if (diff < 0) - return -1; - else if (diff > 0) - return 1; - else if (sequenceNumber < x.sequenceNumber) - return -1; - else - return 1; - } - long d = (getDelay(TimeUnit.NANOSECONDS) - - other.getDelay(TimeUnit.NANOSECONDS)); - return (d == 0) ? 0 : ((d < 0) ? -1 : 1); - } - - /** - * Returns true if this is a periodic (not a one-shot) action. - * - * @return true if periodic - */ - public boolean isPeriodic() { - return period != 0; - } - - /** - * Sets the next time to run for a periodic task. - */ - private void setNextRunTime() { - long p = period; - if (p > 0) - time += p; - else - time = now() - p; - } - - public boolean cancel(boolean mayInterruptIfRunning) { - boolean cancelled = super.cancel(mayInterruptIfRunning); - if (cancelled && removeOnCancel && heapIndex >= 0) - remove(this); - return cancelled; - } - - /** - * Overrides FutureTask version so as to reset/requeue if periodic. - */ - public void run() { - boolean periodic = isPeriodic(); - if (!canRunInCurrentRunState(periodic)) - cancel(false); - else if (!periodic) - ScheduledFutureTask.super.run(); - else if (ScheduledFutureTask.super.runAndReset()) { - setNextRunTime(); - reExecutePeriodic(outerTask); - } - } - } - - /** - * Returns true if can run a task given current run state - * and run-after-shutdown parameters. - * - * @param periodic true if this task periodic, false if delayed - */ - boolean canRunInCurrentRunState(boolean periodic) { - return isRunningOrShutdown(periodic ? - continueExistingPeriodicTasksAfterShutdown : - executeExistingDelayedTasksAfterShutdown); - } - - /** - * Main execution method for delayed or periodic tasks. If pool - * is shut down, rejects the task. Otherwise adds task to queue - * and starts a thread, if necessary, to run it. (We cannot - * prestart the thread to run the task because the task (probably) - * shouldn't be run yet,) If the pool is shut down while the task - * is being added, cancel and remove it if required by state and - * run-after-shutdown parameters. - * - * @param task the task - */ - private void delayedExecute(ScheduledFutureTask task) { - if (isShutdown()) - reject(task); - else { - super.getQueue().add(task); - if (isShutdown() && - !canRunInCurrentRunState(task.isPeriodic()) && - remove(task)) - task.cancel(false); - else - prestartCoreThread(); - } - } - - /** - * Requeues a periodic task unless current run state precludes it. - * Same idea as delayedExecute except drops task rather than rejecting. - * - * @param task the task - */ - void reExecutePeriodic(ScheduledFutureTask task) { - if (canRunInCurrentRunState(true)) { - super.getQueue().add(task); - if (!canRunInCurrentRunState(true) && remove(task)) - task.cancel(false); - else - prestartCoreThread(); - } - } - - /** - * Cancels and clears the queue of all tasks that should not be run - * due to shutdown policy. Invoked within super.shutdown. - */ - @Override void onShutdown() { - BlockingQueue q = super.getQueue(); - boolean keepDelayed = - getExecuteExistingDelayedTasksAfterShutdownPolicy(); - boolean keepPeriodic = - getContinueExistingPeriodicTasksAfterShutdownPolicy(); - if (!keepDelayed && !keepPeriodic) - q.clear(); - else { - // Traverse snapshot to avoid iterator exceptions - for (Object e : q.toArray()) { - if (e instanceof ScheduledFutureTask) { - ScheduledFutureTask t = - (ScheduledFutureTask)e; - if ((t.isPeriodic() ? !keepPeriodic : !keepDelayed) || - t.isCancelled()) { // also remove if already cancelled - if (q.remove(t)) - t.cancel(false); - } - } - } - } - tryTerminate(); - } - - /** - * Creates a new {@code ScheduledThreadPoolExecutor} with the - * given core pool size. - * - * @param corePoolSize the number of threads to keep in the pool, even - * if they are idle - * @throws IllegalArgumentException if {@code corePoolSize < 0} - */ - public ScheduledThreadPoolExecutor(int corePoolSize) { - super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS, - new DelayedWorkQueue()); - } - - /** - * Creates a new {@code ScheduledThreadPoolExecutor} with the - * given initial parameters. - * - * @param corePoolSize the number of threads to keep in the pool, even - * if they are idle - * @param threadFactory the factory to use when the executor - * creates a new thread - * @throws IllegalArgumentException if {@code corePoolSize < 0} - * @throws NullPointerException if {@code threadFactory} is null - */ - public ScheduledThreadPoolExecutor(int corePoolSize, - ThreadFactory threadFactory) { - super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS, - new DelayedWorkQueue(), threadFactory); - } - - /** - * Creates a new ScheduledThreadPoolExecutor with the given - * initial parameters. - * - * @param corePoolSize the number of threads to keep in the pool, even - * if they are idle - * @param handler the handler to use when execution is blocked - * because the thread bounds and queue capacities are reached - * @throws IllegalArgumentException if {@code corePoolSize < 0} - * @throws NullPointerException if {@code handler} is null - */ - public ScheduledThreadPoolExecutor(int corePoolSize, - RejectedExecutionHandler handler) { - super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS, - new DelayedWorkQueue(), handler); - } - - /** - * Creates a new ScheduledThreadPoolExecutor with the given - * initial parameters. - * - * @param corePoolSize the number of threads to keep in the pool, even - * if they are idle - * @param threadFactory the factory to use when the executor - * creates a new thread - * @param handler the handler to use when execution is blocked - * because the thread bounds and queue capacities are reached - * @throws IllegalArgumentException if {@code corePoolSize < 0} - * @throws NullPointerException if {@code threadFactory} or - * {@code handler} is null - */ - public ScheduledThreadPoolExecutor(int corePoolSize, - ThreadFactory threadFactory, - RejectedExecutionHandler handler) { - super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS, - new DelayedWorkQueue(), threadFactory, handler); - } - - /** - * Returns the trigger time of a delayed action - */ - private static long nextTriggerTime(long delay, TimeUnit unit) { - long triggerTime; - long now = now(); - if (delay <= 0) - return now; // avoid negative trigger times - else if ((triggerTime = now + unit.toNanos(delay)) < 0) - return Long.MAX_VALUE; // avoid numerical overflow - else - return triggerTime; - } - - /** - * @throws RejectedExecutionException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - */ - public ScheduledFuture schedule(Runnable command, - long delay, - TimeUnit unit) { - if (command == null || unit == null) - throw new NullPointerException(); - long triggerTime = nextTriggerTime(delay, unit); - ScheduledFutureTask t - = new ScheduledFutureTask(command, null, triggerTime); - delayedExecute(t); - return t; - } - - /** - * @throws RejectedExecutionException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - */ - public ScheduledFuture schedule(Callable callable, - long delay, - TimeUnit unit) { - if (callable == null || unit == null) - throw new NullPointerException(); - long triggerTime = nextTriggerTime(delay, unit); - ScheduledFutureTask t - = new ScheduledFutureTask(callable, triggerTime); - delayedExecute(t); - return t; - } - - /** - * @throws RejectedExecutionException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - * @throws IllegalArgumentException {@inheritDoc} - */ - public ScheduledFuture scheduleAtFixedRate(Runnable command, - long initialDelay, - long period, - TimeUnit unit) { - if (command == null || unit == null) - throw new NullPointerException(); - if (period <= 0) - throw new IllegalArgumentException(); - if (initialDelay < 0) initialDelay = 0; - long triggerTime = nextTriggerTime(initialDelay, unit); - ScheduledFutureTask sft = - new ScheduledFutureTask(command, - null, - triggerTime, - unit.toNanos(period)); - sft.outerTask = sft; - delayedExecute(sft); - return sft; - } - - /** - * @throws RejectedExecutionException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - * @throws IllegalArgumentException {@inheritDoc} - */ - public ScheduledFuture scheduleWithFixedDelay(Runnable command, - long initialDelay, - long delay, - TimeUnit unit) { - if (command == null || unit == null) - throw new NullPointerException(); - if (delay <= 0) - throw new IllegalArgumentException(); - long triggerTime = nextTriggerTime(initialDelay, unit); - ScheduledFutureTask sft = - new ScheduledFutureTask(command, - null, - triggerTime, - unit.toNanos(-delay)); - sft.outerTask = sft; - delayedExecute(sft); - return sft; - } - - /** - * Executes {@code command} with zero required delay. - * This has effect equivalent to - * {@link #schedule(Runnable,long,TimeUnit) schedule(command, 0, anyUnit)}. - * Note that inspections of the queue and of the list returned by - * {@code shutdownNow} will access the zero-delayed - * {@link ScheduledFuture}, not the {@code command} itself. - * - *

A consequence of the use of {@code ScheduledFuture} objects is - * that {@link ThreadPoolExecutor#afterExecute afterExecute} is always - * called with a null second {@code Throwable} argument, even if the - * {@code command} terminated abruptly. Instead, the {@code Throwable} - * thrown by such a task can be obtained via {@link Future#get}. - * - * @throws RejectedExecutionException at discretion of - * {@code RejectedExecutionHandler}, if the task - * cannot be accepted for execution because the - * executor has been shut down - * @throws NullPointerException {@inheritDoc} - */ - public void execute(Runnable command) { - schedule(command, 0, TimeUnit.NANOSECONDS); - } - - // Override AbstractExecutorService methods - - /** - * @throws RejectedExecutionException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - */ - public Future submit(Runnable task) { - return schedule(task, 0, TimeUnit.NANOSECONDS); - } - - /** - * @throws RejectedExecutionException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - */ - public Future submit(Runnable task, T result) { - return schedule(Executors.callable(task, result), - 0, TimeUnit.NANOSECONDS); - } - - /** - * @throws RejectedExecutionException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - */ - public Future submit(Callable task) { - return schedule(task, 0, TimeUnit.NANOSECONDS); - } - - /** - * Sets the policy on whether to continue executing existing - * periodic tasks even when this executor has been {@code shutdown}. - * In this case, these tasks will only terminate upon - * {@code shutdownNow} or after setting the policy to - * {@code false} when already shutdown. - * This value is by default {@code false}. - * - * @param value if {@code true}, continue after shutdown, else don't. - * @see #getContinueExistingPeriodicTasksAfterShutdownPolicy - */ - public void setContinueExistingPeriodicTasksAfterShutdownPolicy(boolean value) { - continueExistingPeriodicTasksAfterShutdown = value; - if (!value && isShutdown()) - onShutdown(); - } - - /** - * Gets the policy on whether to continue executing existing - * periodic tasks even when this executor has been {@code shutdown}. - * In this case, these tasks will only terminate upon - * {@code shutdownNow} or after setting the policy to - * {@code false} when already shutdown. - * This value is by default {@code false}. - * - * @return {@code true} if will continue after shutdown - * @see #setContinueExistingPeriodicTasksAfterShutdownPolicy - */ - public boolean getContinueExistingPeriodicTasksAfterShutdownPolicy() { - return continueExistingPeriodicTasksAfterShutdown; - } - - /** - * Sets the policy on whether to execute existing delayed - * tasks even when this executor has been {@code shutdown}. - * In this case, these tasks will only terminate upon - * {@code shutdownNow}, or after setting the policy to - * {@code false} when already shutdown. - * This value is by default {@code true}. - * - * @param value if {@code true}, execute after shutdown, else don't. - * @see #getExecuteExistingDelayedTasksAfterShutdownPolicy - */ - public void setExecuteExistingDelayedTasksAfterShutdownPolicy(boolean value) { - executeExistingDelayedTasksAfterShutdown = value; - if (!value && isShutdown()) - onShutdown(); - } - - /** - * Gets the policy on whether to execute existing delayed - * tasks even when this executor has been {@code shutdown}. - * In this case, these tasks will only terminate upon - * {@code shutdownNow}, or after setting the policy to - * {@code false} when already shutdown. - * This value is by default {@code true}. - * - * @return {@code true} if will execute after shutdown - * @see #setExecuteExistingDelayedTasksAfterShutdownPolicy - */ - public boolean getExecuteExistingDelayedTasksAfterShutdownPolicy() { - return executeExistingDelayedTasksAfterShutdown; - } - - /** - * Initiates an orderly shutdown in which previously submitted - * tasks are executed, but no new tasks will be accepted. - * Invocation has no additional effect if already shut down. - * - *

This method does not wait for previously submitted tasks to - * complete execution. Use {@link #awaitTermination awaitTermination} - * to do that. - * - *

If the {@code ExecuteExistingDelayedTasksAfterShutdownPolicy} - * has been set {@code false}, existing delayed tasks whose delays - * have not yet elapsed are cancelled. And unless the {@code - * ContinueExistingPeriodicTasksAfterShutdownPolicy} has been set - * {@code true}, future executions of existing periodic tasks will - * be cancelled. - * - * @throws SecurityException {@inheritDoc} - */ - public void shutdown() { - super.shutdown(); - } - - /** - * Attempts to stop all actively executing tasks, halts the - * processing of waiting tasks, and returns a list of the tasks - * that were awaiting execution. - * - *

This method does not wait for actively executing tasks to - * terminate. Use {@link #awaitTermination awaitTermination} to - * do that. - * - *

There are no guarantees beyond best-effort attempts to stop - * processing actively executing tasks. This implementation - * cancels tasks via {@link Thread#interrupt}, so any task that - * fails to respond to interrupts may never terminate. - * - * @return list of tasks that never commenced execution. - * Each element of this list is a {@link ScheduledFuture}, - * including those tasks submitted using {@code execute}, - * which are for scheduling purposes used as the basis of a - * zero-delay {@code ScheduledFuture}. - * @throws SecurityException {@inheritDoc} - */ - public List shutdownNow() { - return super.shutdownNow(); - } - - /** - * Returns the task queue used by this executor. Each element of - * this queue is a {@link ScheduledFuture}, including those - * tasks submitted using {@code execute} which are for scheduling - * purposes used as the basis of a zero-delay - * {@code ScheduledFuture}. Iteration over this queue is - * not guaranteed to traverse tasks in the order in - * which they will execute. - * - * @return the task queue - */ - public BlockingQueue getQueue() { - return super.getQueue(); - } - - /** - * Specialized delay queue. To mesh with TPE declarations, this - * class must be declared as a BlockingQueue even though - * it can only hold RunnableScheduledFutures. - */ - static class DelayedWorkQueue extends AbstractQueue - implements BlockingQueue { - - /* - * A DelayedWorkQueue is based on a heap-based data structure - * like those in DelayQueue and PriorityQueue, except that - * every ScheduledFutureTask also records its index into the - * heap array. This eliminates the need to find a task upon - * cancellation, greatly speeding up removal (down from O(n) - * to O(log n)), and reducing garbage retention that would - * otherwise occur by waiting for the element to rise to top - * before clearing. But because the queue may also hold - * RunnableScheduledFutures that are not ScheduledFutureTasks, - * we are not guaranteed to have such indices available, in - * which case we fall back to linear search. (We expect that - * most tasks will not be decorated, and that the faster cases - * will be much more common.) - * - * All heap operations must record index changes -- mainly - * within siftUp and siftDown. Upon removal, a task's - * heapIndex is set to -1. Note that ScheduledFutureTasks can - * appear at most once in the queue (this need not be true for - * other kinds of tasks or work queues), so are uniquely - * identified by heapIndex. - */ - - private static final int INITIAL_CAPACITY = 16; - private ScheduledFutureTask[] queue = - new ScheduledFutureTask[INITIAL_CAPACITY]; - private final ReentrantLock lock = new ReentrantLock(); - private int size = 0; - - /** - * Thread designated to wait for the task at the head of the - * queue. This variant of the Leader-Follower pattern - * (http://www.cs.wustl.edu/~schmidt/POSA/POSA2/) serves to - * minimize unnecessary timed waiting. When a thread becomes - * the leader, it waits only for the next delay to elapse, but - * other threads await indefinitely. The leader thread must - * signal some other thread before returning from take() or - * poll(...), unless some other thread becomes leader in the - * interim. Whenever the head of the queue is replaced with a - * task with an earlier expiration time, the leader field is - * invalidated by being reset to null, and some waiting - * thread, but not necessarily the current leader, is - * signalled. So waiting threads must be prepared to acquire - * and lose leadership while waiting. - */ - private Thread leader = null; - - /** - * Condition signalled when a newer task becomes available at the - * head of the queue or a new thread may need to become leader. - */ - private final Condition available = lock.newCondition(); - - /** - * Set f's heapIndex if it is a ScheduledFutureTask. - */ - private void setIndex(ScheduledFutureTask f, int idx) { - if (f instanceof ScheduledFutureTask) - ((ScheduledFutureTask)f).heapIndex = idx; - } - - /** - * Sift element added at bottom up to its heap-ordered spot. - * Call only when holding lock. - */ - private void siftUp(int k, ScheduledFutureTask key) { - while (k > 0) { - int parent = (k - 1) >>> 1; - ScheduledFutureTask e = queue[parent]; - if (key.compareTo(e) >= 0) - break; - queue[k] = e; - setIndex(e, k); - k = parent; - } - queue[k] = key; - setIndex(key, k); - } - - /** - * Sift element added at top down to its heap-ordered spot. - * Call only when holding lock. - */ - private void siftDown(int k, ScheduledFutureTask key) { - int half = size >>> 1; - while (k < half) { - int child = (k << 1) + 1; - ScheduledFutureTask c = queue[child]; - int right = child + 1; - if (right < size && c.compareTo(queue[right]) > 0) - c = queue[child = right]; - if (key.compareTo(c) <= 0) - break; - queue[k] = c; - setIndex(c, k); - k = child; - } - queue[k] = key; - setIndex(key, k); - } - - /** - * Resize the heap array. Call only when holding lock. - */ - private void grow() { - int oldCapacity = queue.length; - int newCapacity = oldCapacity + (oldCapacity >> 1); // grow 50% - if (newCapacity < 0) // overflow - newCapacity = Integer.MAX_VALUE; - queue = Java6Arrays.copyOf(queue, newCapacity); - } - - /** - * Find index of given object, or -1 if absent - */ - private int indexOf(Object x) { - if (x != null) { - if (x instanceof ScheduledFutureTask) { - int i = ((ScheduledFutureTask) x).heapIndex; - // Sanity check; x could conceivably be a - // ScheduledFutureTask from some other pool. - if (i >= 0 && i < size && queue[i] == x) - return i; - } else { - for (int i = 0; i < size; i++) - if (x.equals(queue[i])) - return i; - } - } - return -1; - } - - public boolean contains(Object x) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return indexOf(x) != -1; - } finally { - lock.unlock(); - } - } - - public boolean remove(Object x) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - int i = indexOf(x); - if (i < 0) - return false; - - setIndex(queue[i], -1); - int s = --size; - ScheduledFutureTask replacement = queue[s]; - queue[s] = null; - if (s != i) { - siftDown(i, replacement); - if (queue[i] == replacement) - siftUp(i, replacement); - } - return true; - } finally { - lock.unlock(); - } - } - - public int size() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return size; - } finally { - lock.unlock(); - } - } - - public boolean isEmpty() { - return size() == 0; - } - - public int remainingCapacity() { - return Integer.MAX_VALUE; - } - - public ScheduledFutureTask peek() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return queue[0]; - } finally { - lock.unlock(); - } - } - - public boolean offer(Runnable x) { - if (x == null) - throw new NullPointerException(); - ScheduledFutureTask e = (ScheduledFutureTask)x; - final ReentrantLock lock = this.lock; - lock.lock(); - try { - int i = size; - if (i >= queue.length) - grow(); - size = i + 1; - if (i == 0) { - queue[0] = e; - setIndex(e, 0); - } else { - siftUp(i, e); - } - if (queue[0] == e) { - leader = null; - available.signal(); - } - } finally { - lock.unlock(); - } - return true; - } - - public void put(Runnable e) { - offer(e); - } - - public boolean add(Runnable e) { - return offer(e); - } - - public boolean offer(Runnable e, long timeout, TimeUnit unit) { - return offer(e); - } - - /** - * Performs common bookkeeping for poll and take: Replaces - * first element with last and sifts it down. Call only when - * holding lock. - * @param f the task to remove and return - */ - private ScheduledFutureTask finishPoll(ScheduledFutureTask f) { - int s = --size; - ScheduledFutureTask x = queue[s]; - queue[s] = null; - if (s != 0) - siftDown(0, x); - setIndex(f, -1); - return f; - } - - public ScheduledFutureTask poll() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - ScheduledFutureTask first = queue[0]; - if (first == null || first.getDelay(TimeUnit.NANOSECONDS) > 0) - return null; - else - return finishPoll(first); - } finally { - lock.unlock(); - } - } - - public ScheduledFutureTask take() throws InterruptedException { - final ReentrantLock lock = this.lock; - lock.lockInterruptibly(); - try { - for (;;) { - ScheduledFutureTask first = queue[0]; - if (first == null) - available.await(); - else { - long delay = first.getDelay(TimeUnit.NANOSECONDS); - if (delay <= 0) - return finishPoll(first); - else if (leader != null) - available.await(); - else { - Thread thisThread = Thread.currentThread(); - leader = thisThread; - try { - available.awaitNanos(delay); - } finally { - if (leader == thisThread) - leader = null; - } - } - } - } - } finally { - if (leader == null && queue[0] != null) - available.signal(); - lock.unlock(); - } - } - - public ScheduledFutureTask poll(long timeout, TimeUnit unit) - throws InterruptedException { - long nanos = unit.toNanos(timeout); - final ReentrantLock lock = this.lock; - lock.lockInterruptibly(); - try { - for (;;) { - ScheduledFutureTask first = queue[0]; - if (first == null) { - if (nanos <= 0) - return null; - else - nanos = available.awaitNanos(nanos); - } else { - long delay = first.getDelay(TimeUnit.NANOSECONDS); - if (delay <= 0) - return finishPoll(first); - if (nanos <= 0) - return null; - if (nanos < delay || leader != null) - nanos = available.awaitNanos(nanos); - else { - Thread thisThread = Thread.currentThread(); - leader = thisThread; - try { - long timeLeft = available.awaitNanos(delay); - nanos -= delay - timeLeft; - } finally { - if (leader == thisThread) - leader = null; - } - } - } - } - } finally { - if (leader == null && queue[0] != null) - available.signal(); - lock.unlock(); - } - } - - public void clear() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - for (int i = 0; i < size; i++) { - ScheduledFutureTask t = queue[i]; - if (t != null) { - queue[i] = null; - setIndex(t, -1); - } - } - size = 0; - } finally { - lock.unlock(); - } - } - - /** - * Return and remove first element only if it is expired. - * Used only by drainTo. Call only when holding lock. - */ - private ScheduledFutureTask pollExpired() { - ScheduledFutureTask first = queue[0]; - if (first == null || first.getDelay(TimeUnit.NANOSECONDS) > 0) - return null; - return finishPoll(first); - } - - public int drainTo(Collection c) { - if (c == null) - throw new NullPointerException(); - if (c == this) - throw new IllegalArgumentException(); - final ReentrantLock lock = this.lock; - lock.lock(); - try { - ScheduledFutureTask first; - int n = 0; - while ((first = pollExpired()) != null) { - c.add(first); - ++n; - } - return n; - } finally { - lock.unlock(); - } - } - - public int drainTo(Collection c, int maxElements) { - if (c == null) - throw new NullPointerException(); - if (c == this) - throw new IllegalArgumentException(); - if (maxElements <= 0) - return 0; - final ReentrantLock lock = this.lock; - lock.lock(); - try { - ScheduledFutureTask first; - int n = 0; - while (n < maxElements && (first = pollExpired()) != null) { - c.add(first); - ++n; - } - return n; - } finally { - lock.unlock(); - } - } - - public Object[] toArray() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return Java6Arrays.copyOf(queue, size, Object[].class); - } finally { - lock.unlock(); - } - } - - @SuppressWarnings("unchecked") - public T[] toArray(T[] a) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - if (a.length < size) - return (T[]) Java6Arrays.copyOf(queue, size, a.getClass()); - System.arraycopy(queue, 0, a, 0, size); - if (a.length > size) - a[size] = null; - return a; - } finally { - lock.unlock(); - } - } - - public Iterator iterator() { - return new Itr(Java6Arrays.copyOf(queue, size)); - } - - /** - * Snapshot iterator that works off copy of underlying q array. - */ - private class Itr implements Iterator { - final ScheduledFutureTask[] array; - int cursor = 0; // index of next element to return - int lastRet = -1; // index of last element, or -1 if no such - - Itr(ScheduledFutureTask[] array) { - this.array = array; - } - - public boolean hasNext() { - return cursor < array.length; - } - - public Runnable next() { - if (cursor >= array.length) - throw new NoSuchElementException(); - lastRet = cursor; - return array[cursor++]; - } - - public void remove() { - if (lastRet < 0) - throw new IllegalStateException(); - DelayedWorkQueue.this.remove(array[lastRet]); - lastRet = -1; - } - } - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/Semaphore.java b/libcore/concurrent/src/main/java/java/util/concurrent/Semaphore.java deleted file mode 100644 index 105236439..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/Semaphore.java +++ /dev/null @@ -1,681 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; -import java.util.*; -import java.util.concurrent.locks.*; -import java.util.concurrent.atomic.*; - -/** - * A counting semaphore. Conceptually, a semaphore maintains a set of - * permits. Each {@link #acquire} blocks if necessary until a permit is - * available, and then takes it. Each {@link #release} adds a permit, - * potentially releasing a blocking acquirer. - * However, no actual permit objects are used; the {@code Semaphore} just - * keeps a count of the number available and acts accordingly. - * - *

Semaphores are often used to restrict the number of threads than can - * access some (physical or logical) resource. For example, here is - * a class that uses a semaphore to control access to a pool of items: - *

- * class Pool {
- *   private static final int MAX_AVAILABLE = 100;
- *   private final Semaphore available = new Semaphore(MAX_AVAILABLE, true);
- *
- *   public Object getItem() throws InterruptedException {
- *     available.acquire();
- *     return getNextAvailableItem();
- *   }
- *
- *   public void putItem(Object x) {
- *     if (markAsUnused(x))
- *       available.release();
- *   }
- *
- *   // Not a particularly efficient data structure; just for demo
- *
- *   protected Object[] items = ... whatever kinds of items being managed
- *   protected boolean[] used = new boolean[MAX_AVAILABLE];
- *
- *   protected synchronized Object getNextAvailableItem() {
- *     for (int i = 0; i < MAX_AVAILABLE; ++i) {
- *       if (!used[i]) {
- *          used[i] = true;
- *          return items[i];
- *       }
- *     }
- *     return null; // not reached
- *   }
- *
- *   protected synchronized boolean markAsUnused(Object item) {
- *     for (int i = 0; i < MAX_AVAILABLE; ++i) {
- *       if (item == items[i]) {
- *          if (used[i]) {
- *            used[i] = false;
- *            return true;
- *          } else
- *            return false;
- *       }
- *     }
- *     return false;
- *   }
- *
- * }
- * 
- * - *

Before obtaining an item each thread must acquire a permit from - * the semaphore, guaranteeing that an item is available for use. When - * the thread has finished with the item it is returned back to the - * pool and a permit is returned to the semaphore, allowing another - * thread to acquire that item. Note that no synchronization lock is - * held when {@link #acquire} is called as that would prevent an item - * from being returned to the pool. The semaphore encapsulates the - * synchronization needed to restrict access to the pool, separately - * from any synchronization needed to maintain the consistency of the - * pool itself. - * - *

A semaphore initialized to one, and which is used such that it - * only has at most one permit available, can serve as a mutual - * exclusion lock. This is more commonly known as a binary - * semaphore, because it only has two states: one permit - * available, or zero permits available. When used in this way, the - * binary semaphore has the property (unlike many {@link Lock} - * implementations), that the "lock" can be released by a - * thread other than the owner (as semaphores have no notion of - * ownership). This can be useful in some specialized contexts, such - * as deadlock recovery. - * - *

The constructor for this class optionally accepts a - * fairness parameter. When set false, this class makes no - * guarantees about the order in which threads acquire permits. In - * particular, barging is permitted, that is, a thread - * invoking {@link #acquire} can be allocated a permit ahead of a - * thread that has been waiting - logically the new thread places itself at - * the head of the queue of waiting threads. When fairness is set true, the - * semaphore guarantees that threads invoking any of the {@link - * #acquire() acquire} methods are selected to obtain permits in the order in - * which their invocation of those methods was processed - * (first-in-first-out; FIFO). Note that FIFO ordering necessarily - * applies to specific internal points of execution within these - * methods. So, it is possible for one thread to invoke - * {@code acquire} before another, but reach the ordering point after - * the other, and similarly upon return from the method. - * Also note that the untimed {@link #tryAcquire() tryAcquire} methods do not - * honor the fairness setting, but will take any permits that are - * available. - * - *

Generally, semaphores used to control resource access should be - * initialized as fair, to ensure that no thread is starved out from - * accessing a resource. When using semaphores for other kinds of - * synchronization control, the throughput advantages of non-fair - * ordering often outweigh fairness considerations. - * - *

This class also provides convenience methods to {@link - * #acquire(int) acquire} and {@link #release(int) release} multiple - * permits at a time. Beware of the increased risk of indefinite - * postponement when these methods are used without fairness set true. - * - *

Memory consistency effects: Actions in a thread prior to calling - * a "release" method such as {@code release()} - * happen-before - * actions following a successful "acquire" method such as {@code acquire()} - * in another thread. - * - * @since 1.5 - * @author Doug Lea - * - */ - -public class Semaphore implements java.io.Serializable { - private static final long serialVersionUID = -3222578661600680210L; - /** All mechanics via AbstractQueuedSynchronizer subclass */ - private final Sync sync; - - /** - * Synchronization implementation for semaphore. Uses AQS state - * to represent permits. Subclassed into fair and nonfair - * versions. - */ - abstract static class Sync extends AbstractQueuedSynchronizer { - private static final long serialVersionUID = 1192457210091910933L; - - Sync(int permits) { - setState(permits); - } - - final int getPermits() { - return getState(); - } - - final int nonfairTryAcquireShared(int acquires) { - for (;;) { - int available = getState(); - int remaining = available - acquires; - if (remaining < 0 || - compareAndSetState(available, remaining)) - return remaining; - } - } - - protected final boolean tryReleaseShared(int releases) { - for (;;) { - int p = getState(); - if (compareAndSetState(p, p + releases)) - return true; - } - } - - final void reducePermits(int reductions) { - for (;;) { - int current = getState(); - int next = current - reductions; - if (compareAndSetState(current, next)) - return; - } - } - - final int drainPermits() { - for (;;) { - int current = getState(); - if (current == 0 || compareAndSetState(current, 0)) - return current; - } - } - } - - /** - * NonFair version - */ - final static class NonfairSync extends Sync { - private static final long serialVersionUID = -2694183684443567898L; - - NonfairSync(int permits) { - super(permits); - } - - protected int tryAcquireShared(int acquires) { - return nonfairTryAcquireShared(acquires); - } - } - - /** - * Fair version - */ - final static class FairSync extends Sync { - private static final long serialVersionUID = 2014338818796000944L; - - FairSync(int permits) { - super(permits); - } - - protected int tryAcquireShared(int acquires) { - Thread current = Thread.currentThread(); - for (;;) { - Thread first = getFirstQueuedThread(); - if (first != null && first != current) - return -1; - int available = getState(); - int remaining = available - acquires; - if (remaining < 0 || - compareAndSetState(available, remaining)) - return remaining; - } - } - } - - /** - * Creates a {@code Semaphore} with the given number of - * permits and nonfair fairness setting. - * - * @param permits the initial number of permits available. - * This value may be negative, in which case releases - * must occur before any acquires will be granted. - */ - public Semaphore(int permits) { - sync = new NonfairSync(permits); - } - - /** - * Creates a {@code Semaphore} with the given number of - * permits and the given fairness setting. - * - * @param permits the initial number of permits available. - * This value may be negative, in which case releases - * must occur before any acquires will be granted. - * @param fair {@code true} if this semaphore will guarantee - * first-in first-out granting of permits under contention, - * else {@code false} - */ - public Semaphore(int permits, boolean fair) { - sync = (fair)? new FairSync(permits) : new NonfairSync(permits); - } - - /** - * Acquires a permit from this semaphore, blocking until one is - * available, or the thread is {@linkplain Thread#interrupt interrupted}. - * - *

Acquires a permit, if one is available and returns immediately, - * reducing the number of available permits by one. - * - *

If no permit is available then the current thread becomes - * disabled for thread scheduling purposes and lies dormant until - * one of two things happens: - *

    - *
  • Some other thread invokes the {@link #release} method for this - * semaphore and the current thread is next to be assigned a permit; or - *
  • Some other thread {@linkplain Thread#interrupt interrupts} - * the current thread. - *
- * - *

If the current thread: - *

    - *
  • has its interrupted status set on entry to this method; or - *
  • is {@linkplain Thread#interrupt interrupted} while waiting - * for a permit, - *
- * then {@link InterruptedException} is thrown and the current thread's - * interrupted status is cleared. - * - * @throws InterruptedException if the current thread is interrupted - */ - public void acquire() throws InterruptedException { - sync.acquireSharedInterruptibly(1); - } - - /** - * Acquires a permit from this semaphore, blocking until one is - * available. - * - *

Acquires a permit, if one is available and returns immediately, - * reducing the number of available permits by one. - * - *

If no permit is available then the current thread becomes - * disabled for thread scheduling purposes and lies dormant until - * some other thread invokes the {@link #release} method for this - * semaphore and the current thread is next to be assigned a permit. - * - *

If the current thread is {@linkplain Thread#interrupt interrupted} - * while waiting for a permit then it will continue to wait, but the - * time at which the thread is assigned a permit may change compared to - * the time it would have received the permit had no interruption - * occurred. When the thread does return from this method its interrupt - * status will be set. - */ - public void acquireUninterruptibly() { - sync.acquireShared(1); - } - - /** - * Acquires a permit from this semaphore, only if one is available at the - * time of invocation. - * - *

Acquires a permit, if one is available and returns immediately, - * with the value {@code true}, - * reducing the number of available permits by one. - * - *

If no permit is available then this method will return - * immediately with the value {@code false}. - * - *

Even when this semaphore has been set to use a - * fair ordering policy, a call to {@code tryAcquire()} will - * immediately acquire a permit if one is available, whether or not - * other threads are currently waiting. - * This "barging" behavior can be useful in certain - * circumstances, even though it breaks fairness. If you want to honor - * the fairness setting, then use - * {@link #tryAcquire(long, TimeUnit) tryAcquire(0, TimeUnit.SECONDS) } - * which is almost equivalent (it also detects interruption). - * - * @return {@code true} if a permit was acquired and {@code false} - * otherwise - */ - public boolean tryAcquire() { - return sync.nonfairTryAcquireShared(1) >= 0; - } - - /** - * Acquires a permit from this semaphore, if one becomes available - * within the given waiting time and the current thread has not - * been {@linkplain Thread#interrupt interrupted}. - * - *

Acquires a permit, if one is available and returns immediately, - * with the value {@code true}, - * reducing the number of available permits by one. - * - *

If no permit is available then the current thread becomes - * disabled for thread scheduling purposes and lies dormant until - * one of three things happens: - *

    - *
  • Some other thread invokes the {@link #release} method for this - * semaphore and the current thread is next to be assigned a permit; or - *
  • Some other thread {@linkplain Thread#interrupt interrupts} - * the current thread; or - *
  • The specified waiting time elapses. - *
- * - *

If a permit is acquired then the value {@code true} is returned. - * - *

If the current thread: - *

    - *
  • has its interrupted status set on entry to this method; or - *
  • is {@linkplain Thread#interrupt interrupted} while waiting - * to acquire a permit, - *
- * then {@link InterruptedException} is thrown and the current thread's - * interrupted status is cleared. - * - *

If the specified waiting time elapses then the value {@code false} - * is returned. If the time is less than or equal to zero, the method - * will not wait at all. - * - * @param timeout the maximum time to wait for a permit - * @param unit the time unit of the {@code timeout} argument - * @return {@code true} if a permit was acquired and {@code false} - * if the waiting time elapsed before a permit was acquired - * @throws InterruptedException if the current thread is interrupted - */ - public boolean tryAcquire(long timeout, TimeUnit unit) - throws InterruptedException { - return sync.tryAcquireSharedNanos(1, unit.toNanos(timeout)); - } - - /** - * Releases a permit, returning it to the semaphore. - * - *

Releases a permit, increasing the number of available permits by - * one. If any threads are trying to acquire a permit, then one is - * selected and given the permit that was just released. That thread - * is (re)enabled for thread scheduling purposes. - * - *

There is no requirement that a thread that releases a permit must - * have acquired that permit by calling {@link #acquire}. - * Correct usage of a semaphore is established by programming convention - * in the application. - */ - public void release() { - sync.releaseShared(1); - } - - /** - * Acquires the given number of permits from this semaphore, - * blocking until all are available, - * or the thread is {@linkplain Thread#interrupt interrupted}. - * - *

Acquires the given number of permits, if they are available, - * and returns immediately, reducing the number of available permits - * by the given amount. - * - *

If insufficient permits are available then the current thread becomes - * disabled for thread scheduling purposes and lies dormant until - * one of two things happens: - *

    - *
  • Some other thread invokes one of the {@link #release() release} - * methods for this semaphore, the current thread is next to be assigned - * permits and the number of available permits satisfies this request; or - *
  • Some other thread {@linkplain Thread#interrupt interrupts} - * the current thread. - *
- * - *

If the current thread: - *

    - *
  • has its interrupted status set on entry to this method; or - *
  • is {@linkplain Thread#interrupt interrupted} while waiting - * for a permit, - *
- * then {@link InterruptedException} is thrown and the current thread's - * interrupted status is cleared. - * Any permits that were to be assigned to this thread are instead - * assigned to other threads trying to acquire permits, as if - * permits had been made available by a call to {@link #release()}. - * - * @param permits the number of permits to acquire - * @throws InterruptedException if the current thread is interrupted - * @throws IllegalArgumentException if {@code permits} is negative - */ - public void acquire(int permits) throws InterruptedException { - if (permits < 0) throw new IllegalArgumentException(); - sync.acquireSharedInterruptibly(permits); - } - - /** - * Acquires the given number of permits from this semaphore, - * blocking until all are available. - * - *

Acquires the given number of permits, if they are available, - * and returns immediately, reducing the number of available permits - * by the given amount. - * - *

If insufficient permits are available then the current thread becomes - * disabled for thread scheduling purposes and lies dormant until - * some other thread invokes one of the {@link #release() release} - * methods for this semaphore, the current thread is next to be assigned - * permits and the number of available permits satisfies this request. - * - *

If the current thread is {@linkplain Thread#interrupt interrupted} - * while waiting for permits then it will continue to wait and its - * position in the queue is not affected. When the thread does return - * from this method its interrupt status will be set. - * - * @param permits the number of permits to acquire - * @throws IllegalArgumentException if {@code permits} is negative - * - */ - public void acquireUninterruptibly(int permits) { - if (permits < 0) throw new IllegalArgumentException(); - sync.acquireShared(permits); - } - - /** - * Acquires the given number of permits from this semaphore, only - * if all are available at the time of invocation. - * - *

Acquires the given number of permits, if they are available, and - * returns immediately, with the value {@code true}, - * reducing the number of available permits by the given amount. - * - *

If insufficient permits are available then this method will return - * immediately with the value {@code false} and the number of available - * permits is unchanged. - * - *

Even when this semaphore has been set to use a fair ordering - * policy, a call to {@code tryAcquire} will - * immediately acquire a permit if one is available, whether or - * not other threads are currently waiting. This - * "barging" behavior can be useful in certain - * circumstances, even though it breaks fairness. If you want to - * honor the fairness setting, then use {@link #tryAcquire(int, - * long, TimeUnit) tryAcquire(permits, 0, TimeUnit.SECONDS) } - * which is almost equivalent (it also detects interruption). - * - * @param permits the number of permits to acquire - * @return {@code true} if the permits were acquired and - * {@code false} otherwise - * @throws IllegalArgumentException if {@code permits} is negative - */ - public boolean tryAcquire(int permits) { - if (permits < 0) throw new IllegalArgumentException(); - return sync.nonfairTryAcquireShared(permits) >= 0; - } - - /** - * Acquires the given number of permits from this semaphore, if all - * become available within the given waiting time and the current - * thread has not been {@linkplain Thread#interrupt interrupted}. - * - *

Acquires the given number of permits, if they are available and - * returns immediately, with the value {@code true}, - * reducing the number of available permits by the given amount. - * - *

If insufficient permits are available then - * the current thread becomes disabled for thread scheduling - * purposes and lies dormant until one of three things happens: - *

    - *
  • Some other thread invokes one of the {@link #release() release} - * methods for this semaphore, the current thread is next to be assigned - * permits and the number of available permits satisfies this request; or - *
  • Some other thread {@linkplain Thread#interrupt interrupts} - * the current thread; or - *
  • The specified waiting time elapses. - *
- * - *

If the permits are acquired then the value {@code true} is returned. - * - *

If the current thread: - *

    - *
  • has its interrupted status set on entry to this method; or - *
  • is {@linkplain Thread#interrupt interrupted} while waiting - * to acquire the permits, - *
- * then {@link InterruptedException} is thrown and the current thread's - * interrupted status is cleared. - * Any permits that were to be assigned to this thread, are instead - * assigned to other threads trying to acquire permits, as if - * the permits had been made available by a call to {@link #release()}. - * - *

If the specified waiting time elapses then the value {@code false} - * is returned. If the time is less than or equal to zero, the method - * will not wait at all. Any permits that were to be assigned to this - * thread, are instead assigned to other threads trying to acquire - * permits, as if the permits had been made available by a call to - * {@link #release()}. - * - * @param permits the number of permits to acquire - * @param timeout the maximum time to wait for the permits - * @param unit the time unit of the {@code timeout} argument - * @return {@code true} if all permits were acquired and {@code false} - * if the waiting time elapsed before all permits were acquired - * @throws InterruptedException if the current thread is interrupted - * @throws IllegalArgumentException if {@code permits} is negative - */ - public boolean tryAcquire(int permits, long timeout, TimeUnit unit) - throws InterruptedException { - if (permits < 0) throw new IllegalArgumentException(); - return sync.tryAcquireSharedNanos(permits, unit.toNanos(timeout)); - } - - /** - * Releases the given number of permits, returning them to the semaphore. - * - *

Releases the given number of permits, increasing the number of - * available permits by that amount. - * If any threads are trying to acquire permits, then one - * is selected and given the permits that were just released. - * If the number of available permits satisfies that thread's request - * then that thread is (re)enabled for thread scheduling purposes; - * otherwise the thread will wait until sufficient permits are available. - * If there are still permits available - * after this thread's request has been satisfied, then those permits - * are assigned in turn to other threads trying to acquire permits. - * - *

There is no requirement that a thread that releases a permit must - * have acquired that permit by calling {@link Semaphore#acquire acquire}. - * Correct usage of a semaphore is established by programming convention - * in the application. - * - * @param permits the number of permits to release - * @throws IllegalArgumentException if {@code permits} is negative - */ - public void release(int permits) { - if (permits < 0) throw new IllegalArgumentException(); - sync.releaseShared(permits); - } - - /** - * Returns the current number of permits available in this semaphore. - * - *

This method is typically used for debugging and testing purposes. - * - * @return the number of permits available in this semaphore - */ - public int availablePermits() { - return sync.getPermits(); - } - - /** - * Acquires and returns all permits that are immediately available. - * - * @return the number of permits acquired - */ - public int drainPermits() { - return sync.drainPermits(); - } - - /** - * Shrinks the number of available permits by the indicated - * reduction. This method can be useful in subclasses that use - * semaphores to track resources that become unavailable. This - * method differs from {@code acquire} in that it does not block - * waiting for permits to become available. - * - * @param reduction the number of permits to remove - * @throws IllegalArgumentException if {@code reduction} is negative - */ - protected void reducePermits(int reduction) { - if (reduction < 0) throw new IllegalArgumentException(); - sync.reducePermits(reduction); - } - - /** - * Returns {@code true} if this semaphore has fairness set true. - * - * @return {@code true} if this semaphore has fairness set true - */ - public boolean isFair() { - return sync instanceof FairSync; - } - - /** - * Queries whether any threads are waiting to acquire. Note that - * because cancellations may occur at any time, a {@code true} - * return does not guarantee that any other thread will ever - * acquire. This method is designed primarily for use in - * monitoring of the system state. - * - * @return {@code true} if there may be other threads waiting to - * acquire the lock - */ - public final boolean hasQueuedThreads() { - return sync.hasQueuedThreads(); - } - - /** - * Returns an estimate of the number of threads waiting to acquire. - * The value is only an estimate because the number of threads may - * change dynamically while this method traverses internal data - * structures. This method is designed for use in monitoring of the - * system state, not for synchronization control. - * - * @return the estimated number of threads waiting for this lock - */ - public final int getQueueLength() { - return sync.getQueueLength(); - } - - /** - * Returns a collection containing threads that may be waiting to acquire. - * Because the actual set of threads may change dynamically while - * constructing this result, the returned collection is only a best-effort - * estimate. The elements of the returned collection are in no particular - * order. This method is designed to facilitate construction of - * subclasses that provide more extensive monitoring facilities. - * - * @return the collection of threads - */ - protected Collection getQueuedThreads() { - return sync.getQueuedThreads(); - } - - /** - * Returns a string identifying this semaphore, as well as its state. - * The state, in brackets, includes the String {@code "Permits ="} - * followed by the number of permits. - * - * @return a string identifying this semaphore, as well as its state - */ - public String toString() { - return super.toString() + "[Permits = " + sync.getPermits() + "]"; - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/SynchronousQueue.java b/libcore/concurrent/src/main/java/java/util/concurrent/SynchronousQueue.java deleted file mode 100644 index 0d297ff47..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/SynchronousQueue.java +++ /dev/null @@ -1,1128 +0,0 @@ -/* - * Written by Doug Lea, Bill Scherer, and Michael Scott with - * assistance from members of JCP JSR-166 Expert Group and released to - * the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; -import java.util.concurrent.locks.*; -import java.util.concurrent.atomic.*; -import java.util.*; - -// BEGIN android-note -// removed link to collections framework docs -// END android-note - -/** - * A {@linkplain BlockingQueue blocking queue} in which each insert - * operation must wait for a corresponding remove operation by another - * thread, and vice versa. A synchronous queue does not have any - * internal capacity, not even a capacity of one. You cannot - * peek at a synchronous queue because an element is only - * present when you try to remove it; you cannot insert an element - * (using any method) unless another thread is trying to remove it; - * you cannot iterate as there is nothing to iterate. The - * head of the queue is the element that the first queued - * inserting thread is trying to add to the queue; if there is no such - * queued thread then no element is available for removal and - * poll() will return null. For purposes of other - * Collection methods (for example contains), a - * SynchronousQueue acts as an empty collection. This queue - * does not permit null elements. - * - *

Synchronous queues are similar to rendezvous channels used in - * CSP and Ada. They are well suited for handoff designs, in which an - * object running in one thread must sync up with an object running - * in another thread in order to hand it some information, event, or - * task. - * - *

This class supports an optional fairness policy for ordering - * waiting producer and consumer threads. By default, this ordering - * is not guaranteed. However, a queue constructed with fairness set - * to true grants threads access in FIFO order. - * - *

This class and its iterator implement all of the - * optional methods of the {@link Collection} and {@link - * Iterator} interfaces. - * - * @since 1.5 - * @author Doug Lea and Bill Scherer and Michael Scott - * @param the type of elements held in this collection - */ -public class SynchronousQueue extends AbstractQueue - implements BlockingQueue, java.io.Serializable { - private static final long serialVersionUID = -3223113410248163686L; - - /* - * This class implements extensions of the dual stack and dual - * queue algorithms described in "Nonblocking Concurrent Objects - * with Condition Synchronization", by W. N. Scherer III and - * M. L. Scott. 18th Annual Conf. on Distributed Computing, - * Oct. 2004 (see also - * http://www.cs.rochester.edu/u/scott/synchronization/pseudocode/duals.html). - * The (Lifo) stack is used for non-fair mode, and the (Fifo) - * queue for fair mode. The performance of the two is generally - * similar. Fifo usually supports higher throughput under - * contention but Lifo maintains higher thread locality in common - * applications. - * - * A dual queue (and similarly stack) is one that at any given - * time either holds "data" -- items provided by put operations, - * or "requests" -- slots representing take operations, or is - * empty. A call to "fulfill" (i.e., a call requesting an item - * from a queue holding data or vice versa) dequeues a - * complementary node. The most interesting feature of these - * queues is that any operation can figure out which mode the - * queue is in, and act accordingly without needing locks. - * - * Both the queue and stack extend abstract class Transferer - * defining the single method transfer that does a put or a - * take. These are unified into a single method because in dual - * data structures, the put and take operations are symmetrical, - * so nearly all code can be combined. The resulting transfer - * methods are on the long side, but are easier to follow than - * they would be if broken up into nearly-duplicated parts. - * - * The queue and stack data structures share many conceptual - * similarities but very few concrete details. For simplicity, - * they are kept distinct so that they can later evolve - * separately. - * - * The algorithms here differ from the versions in the above paper - * in extending them for use in synchronous queues, as well as - * dealing with cancellation. The main differences include: - * - * 1. The original algorithms used bit-marked pointers, but - * the ones here use mode bits in nodes, leading to a number - * of further adaptations. - * 2. SynchronousQueues must block threads waiting to become - * fulfilled. - * 3. Support for cancellation via timeout and interrupts, - * including cleaning out cancelled nodes/threads - * from lists to avoid garbage retention and memory depletion. - * - * Blocking is mainly accomplished using LockSupport park/unpark, - * except that nodes that appear to be the next ones to become - * fulfilled first spin a bit (on multiprocessors only). On very - * busy synchronous queues, spinning can dramatically improve - * throughput. And on less busy ones, the amount of spinning is - * small enough not to be noticeable. - * - * Cleaning is done in different ways in queues vs stacks. For - * queues, we can almost always remove a node immediately in O(1) - * time (modulo retries for consistency checks) when it is - * cancelled. But if it may be pinned as the current tail, it must - * wait until some subsequent cancellation. For stacks, we need a - * potentially O(n) traversal to be sure that we can remove the - * node, but this can run concurrently with other threads - * accessing the stack. - * - * While garbage collection takes care of most node reclamation - * issues that otherwise complicate nonblocking algorithms, care - * is taken to "forget" references to data, other nodes, and - * threads that might be held on to long-term by blocked - * threads. In cases where setting to null would otherwise - * conflict with main algorithms, this is done by changing a - * node's link to now point to the node itself. This doesn't arise - * much for Stack nodes (because blocked threads do not hang on to - * old head pointers), but references in Queue nodes must be - * aggressively forgotten to avoid reachability of everything any - * node has ever referred to since arrival. - */ - - /** - * Shared internal API for dual stacks and queues. - */ - static abstract class Transferer { - /** - * Performs a put or take. - * - * @param e if non-null, the item to be handed to a consumer; - * if null, requests that transfer return an item - * offered by producer. - * @param timed if this operation should timeout - * @param nanos the timeout, in nanoseconds - * @return if non-null, the item provided or received; if null, - * the operation failed due to timeout or interrupt -- - * the caller can distinguish which of these occurred - * by checking Thread.interrupted. - */ - abstract Object transfer(Object e, boolean timed, long nanos); - } - - /** The number of CPUs, for spin control */ - static final int NCPUS = Runtime.getRuntime().availableProcessors(); - - /** - * The number of times to spin before blocking in timed waits. - * The value is empirically derived -- it works well across a - * variety of processors and OSes. Empirically, the best value - * seems not to vary with number of CPUs (beyond 2) so is just - * a constant. - */ - static final int maxTimedSpins = (NCPUS < 2)? 0 : 32; - - /** - * The number of times to spin before blocking in untimed waits. - * This is greater than timed value because untimed waits spin - * faster since they don't need to check times on each spin. - */ - static final int maxUntimedSpins = maxTimedSpins * 16; - - /** - * The number of nanoseconds for which it is faster to spin - * rather than to use timed park. A rough estimate suffices. - */ - static final long spinForTimeoutThreshold = 1000L; - - /** Dual stack */ - static final class TransferStack extends Transferer { - /* - * This extends Scherer-Scott dual stack algorithm, differing, - * among other ways, by using "covering" nodes rather than - * bit-marked pointers: Fulfilling operations push on marker - * nodes (with FULFILLING bit set in mode) to reserve a spot - * to match a waiting node. - */ - - /* Modes for SNodes, ORed together in node fields */ - /** Node represents an unfulfilled consumer */ - static final int REQUEST = 0; - /** Node represents an unfulfilled producer */ - static final int DATA = 1; - /** Node is fulfilling another unfulfilled DATA or REQUEST */ - static final int FULFILLING = 2; - - /** Return true if m has fulfilling bit set */ - static boolean isFulfilling(int m) { return (m & FULFILLING) != 0; } - - /** Node class for TransferStacks. */ - static final class SNode { - volatile SNode next; // next node in stack - volatile SNode match; // the node matched to this - volatile Thread waiter; // to control park/unpark - Object item; // data; or null for REQUESTs - int mode; - // Note: item and mode fields don't need to be volatile - // since they are always written before, and read after, - // other volatile/atomic operations. - - SNode(Object item) { - this.item = item; - } - - static final AtomicReferenceFieldUpdater - nextUpdater = AtomicReferenceFieldUpdater.newUpdater - (SNode.class, SNode.class, "next"); - - boolean casNext(SNode cmp, SNode val) { - return (cmp == next && - nextUpdater.compareAndSet(this, cmp, val)); - } - - static final AtomicReferenceFieldUpdater - matchUpdater = AtomicReferenceFieldUpdater.newUpdater - (SNode.class, SNode.class, "match"); - - /** - * Tries to match node s to this node, if so, waking up thread. - * Fulfillers call tryMatch to identify their waiters. - * Waiters block until they have been matched. - * - * @param s the node to match - * @return true if successfully matched to s - */ - boolean tryMatch(SNode s) { - if (match == null && - matchUpdater.compareAndSet(this, null, s)) { - Thread w = waiter; - if (w != null) { // waiters need at most one unpark - waiter = null; - LockSupport.unpark(w); - } - return true; - } - return match == s; - } - - /** - * Tries to cancel a wait by matching node to itself. - */ - void tryCancel() { - matchUpdater.compareAndSet(this, null, this); - } - - boolean isCancelled() { - return match == this; - } - } - - /** The head (top) of the stack */ - volatile SNode head; - - static final AtomicReferenceFieldUpdater - headUpdater = AtomicReferenceFieldUpdater.newUpdater - (TransferStack.class, SNode.class, "head"); - - boolean casHead(SNode h, SNode nh) { - return h == head && headUpdater.compareAndSet(this, h, nh); - } - - /** - * Creates or resets fields of a node. Called only from transfer - * where the node to push on stack is lazily created and - * reused when possible to help reduce intervals between reads - * and CASes of head and to avoid surges of garbage when CASes - * to push nodes fail due to contention. - */ - static SNode snode(SNode s, Object e, SNode next, int mode) { - if (s == null) s = new SNode(e); - s.mode = mode; - s.next = next; - return s; - } - - /** - * Puts or takes an item. - */ - Object transfer(Object e, boolean timed, long nanos) { - /* - * Basic algorithm is to loop trying one of three actions: - * - * 1. If apparently empty or already containing nodes of same - * mode, try to push node on stack and wait for a match, - * returning it, or null if cancelled. - * - * 2. If apparently containing node of complementary mode, - * try to push a fulfilling node on to stack, match - * with corresponding waiting node, pop both from - * stack, and return matched item. The matching or - * unlinking might not actually be necessary because of - * other threads performing action 3: - * - * 3. If top of stack already holds another fulfilling node, - * help it out by doing its match and/or pop - * operations, and then continue. The code for helping - * is essentially the same as for fulfilling, except - * that it doesn't return the item. - */ - - SNode s = null; // constructed/reused as needed - int mode = (e == null)? REQUEST : DATA; - - for (;;) { - SNode h = head; - if (h == null || h.mode == mode) { // empty or same-mode - if (timed && nanos <= 0) { // can't wait - if (h != null && h.isCancelled()) - casHead(h, h.next); // pop cancelled node - else - return null; - } else if (casHead(h, s = snode(s, e, h, mode))) { - SNode m = awaitFulfill(s, timed, nanos); - if (m == s) { // wait was cancelled - clean(s); - return null; - } - if ((h = head) != null && h.next == s) - casHead(h, s.next); // help s's fulfiller - return mode == REQUEST? m.item : s.item; - } - } else if (!isFulfilling(h.mode)) { // try to fulfill - if (h.isCancelled()) // already cancelled - casHead(h, h.next); // pop and retry - else if (casHead(h, s=snode(s, e, h, FULFILLING|mode))) { - for (;;) { // loop until matched or waiters disappear - SNode m = s.next; // m is s's match - if (m == null) { // all waiters are gone - casHead(s, null); // pop fulfill node - s = null; // use new node next time - break; // restart main loop - } - SNode mn = m.next; - if (m.tryMatch(s)) { - casHead(s, mn); // pop both s and m - return (mode == REQUEST)? m.item : s.item; - } else // lost match - s.casNext(m, mn); // help unlink - } - } - } else { // help a fulfiller - SNode m = h.next; // m is h's match - if (m == null) // waiter is gone - casHead(h, null); // pop fulfilling node - else { - SNode mn = m.next; - if (m.tryMatch(h)) // help match - casHead(h, mn); // pop both h and m - else // lost match - h.casNext(m, mn); // help unlink - } - } - } - } - - /** - * Spins/blocks until node s is matched by a fulfill operation. - * - * @param s the waiting node - * @param timed true if timed wait - * @param nanos timeout value - * @return matched node, or s if cancelled - */ - SNode awaitFulfill(SNode s, boolean timed, long nanos) { - /* - * When a node/thread is about to block, it sets its waiter - * field and then rechecks state at least one more time - * before actually parking, thus covering race vs - * fulfiller noticing that waiter is non-null so should be - * woken. - * - * When invoked by nodes that appear at the point of call - * to be at the head of the stack, calls to park are - * preceded by spins to avoid blocking when producers and - * consumers are arriving very close in time. This can - * happen enough to bother only on multiprocessors. - * - * The order of checks for returning out of main loop - * reflects fact that interrupts have precedence over - * normal returns, which have precedence over - * timeouts. (So, on timeout, one last check for match is - * done before giving up.) Except that calls from untimed - * SynchronousQueue.{poll/offer} don't check interrupts - * and don't wait at all, so are trapped in transfer - * method rather than calling awaitFulfill. - */ - long lastTime = (timed)? System.nanoTime() : 0; - Thread w = Thread.currentThread(); - SNode h = head; - int spins = (shouldSpin(s)? - (timed? maxTimedSpins : maxUntimedSpins) : 0); - for (;;) { - if (w.isInterrupted()) - s.tryCancel(); - SNode m = s.match; - if (m != null) - return m; - if (timed) { - long now = System.nanoTime(); - nanos -= now - lastTime; - lastTime = now; - if (nanos <= 0) { - s.tryCancel(); - continue; - } - } - if (spins > 0) - spins = shouldSpin(s)? (spins-1) : 0; - else if (s.waiter == null) - s.waiter = w; // establish waiter so can park next iter - else if (!timed) - LockSupport.park(); - else if (nanos > spinForTimeoutThreshold) - LockSupport.parkNanos(nanos); - } - } - - /** - * Returns true if node s is at head or there is an active - * fulfiller. - */ - boolean shouldSpin(SNode s) { - SNode h = head; - return (h == s || h == null || isFulfilling(h.mode)); - } - - /** - * Unlinks s from the stack. - */ - void clean(SNode s) { - s.item = null; // forget item - s.waiter = null; // forget thread - - /* - * At worst we may need to traverse entire stack to unlink - * s. If there are multiple concurrent calls to clean, we - * might not see s if another thread has already removed - * it. But we can stop when we see any node known to - * follow s. We use s.next unless it too is cancelled, in - * which case we try the node one past. We don't check any - * further because we don't want to doubly traverse just to - * find sentinel. - */ - - SNode past = s.next; - if (past != null && past.isCancelled()) - past = past.next; - - // Absorb cancelled nodes at head - SNode p; - while ((p = head) != null && p != past && p.isCancelled()) - casHead(p, p.next); - - // Unsplice embedded nodes - while (p != null && p != past) { - SNode n = p.next; - if (n != null && n.isCancelled()) - p.casNext(n, n.next); - else - p = n; - } - } - } - - /** Dual Queue */ - static final class TransferQueue extends Transferer { - /* - * This extends Scherer-Scott dual queue algorithm, differing, - * among other ways, by using modes within nodes rather than - * marked pointers. The algorithm is a little simpler than - * that for stacks because fulfillers do not need explicit - * nodes, and matching is done by CAS'ing QNode.item field - * from non-null to null (for put) or vice versa (for take). - */ - - /** Node class for TransferQueue. */ - static final class QNode { - volatile QNode next; // next node in queue - volatile Object item; // CAS'ed to or from null - volatile Thread waiter; // to control park/unpark - final boolean isData; - - QNode(Object item, boolean isData) { - this.item = item; - this.isData = isData; - } - - static final AtomicReferenceFieldUpdater - nextUpdater = AtomicReferenceFieldUpdater.newUpdater - (QNode.class, QNode.class, "next"); - - boolean casNext(QNode cmp, QNode val) { - return (next == cmp && - nextUpdater.compareAndSet(this, cmp, val)); - } - - static final AtomicReferenceFieldUpdater - itemUpdater = AtomicReferenceFieldUpdater.newUpdater - (QNode.class, Object.class, "item"); - - boolean casItem(Object cmp, Object val) { - return (item == cmp && - itemUpdater.compareAndSet(this, cmp, val)); - } - - /** - * Tries to cancel by CAS'ing ref to this as item. - */ - void tryCancel(Object cmp) { - itemUpdater.compareAndSet(this, cmp, this); - } - - boolean isCancelled() { - return item == this; - } - - /** - * Returns true if this node is known to be off the queue - * because its next pointer has been forgotten due to - * an advanceHead operation. - */ - boolean isOffList() { - return next == this; - } - } - - /** Head of queue */ - transient volatile QNode head; - /** Tail of queue */ - transient volatile QNode tail; - /** - * Reference to a cancelled node that might not yet have been - * unlinked from queue because it was the last inserted node - * when it cancelled. - */ - transient volatile QNode cleanMe; - - TransferQueue() { - QNode h = new QNode(null, false); // initialize to dummy node. - head = h; - tail = h; - } - - static final AtomicReferenceFieldUpdater - headUpdater = AtomicReferenceFieldUpdater.newUpdater - (TransferQueue.class, QNode.class, "head"); - - /** - * Tries to cas nh as new head; if successful, unlink - * old head's next node to avoid garbage retention. - */ - void advanceHead(QNode h, QNode nh) { - if (h == head && headUpdater.compareAndSet(this, h, nh)) - h.next = h; // forget old next - } - - static final AtomicReferenceFieldUpdater - tailUpdater = AtomicReferenceFieldUpdater.newUpdater - (TransferQueue.class, QNode.class, "tail"); - - /** - * Tries to cas nt as new tail. - */ - void advanceTail(QNode t, QNode nt) { - if (tail == t) - tailUpdater.compareAndSet(this, t, nt); - } - - static final AtomicReferenceFieldUpdater - cleanMeUpdater = AtomicReferenceFieldUpdater.newUpdater - (TransferQueue.class, QNode.class, "cleanMe"); - - /** - * Tries to CAS cleanMe slot. - */ - boolean casCleanMe(QNode cmp, QNode val) { - return (cleanMe == cmp && - cleanMeUpdater.compareAndSet(this, cmp, val)); - } - - /** - * Puts or takes an item. - */ - Object transfer(Object e, boolean timed, long nanos) { - /* Basic algorithm is to loop trying to take either of - * two actions: - * - * 1. If queue apparently empty or holding same-mode nodes, - * try to add node to queue of waiters, wait to be - * fulfilled (or cancelled) and return matching item. - * - * 2. If queue apparently contains waiting items, and this - * call is of complementary mode, try to fulfill by CAS'ing - * item field of waiting node and dequeuing it, and then - * returning matching item. - * - * In each case, along the way, check for and try to help - * advance head and tail on behalf of other stalled/slow - * threads. - * - * The loop starts off with a null check guarding against - * seeing uninitialized head or tail values. This never - * happens in current SynchronousQueue, but could if - * callers held non-volatile/final ref to the - * transferer. The check is here anyway because it places - * null checks at top of loop, which is usually faster - * than having them implicitly interspersed. - */ - - QNode s = null; // constructed/reused as needed - boolean isData = (e != null); - - for (;;) { - QNode t = tail; - QNode h = head; - if (t == null || h == null) // saw uninitialized value - continue; // spin - - if (h == t || t.isData == isData) { // empty or same-mode - QNode tn = t.next; - if (t != tail) // inconsistent read - continue; - if (tn != null) { // lagging tail - advanceTail(t, tn); - continue; - } - if (timed && nanos <= 0) // can't wait - return null; - if (s == null) - s = new QNode(e, isData); - if (!t.casNext(null, s)) // failed to link in - continue; - - advanceTail(t, s); // swing tail and wait - Object x = awaitFulfill(s, e, timed, nanos); - if (x == s) { // wait was cancelled - clean(t, s); - return null; - } - - if (!s.isOffList()) { // not already unlinked - advanceHead(t, s); // unlink if head - if (x != null) // and forget fields - s.item = s; - s.waiter = null; - } - return (x != null)? x : e; - - } else { // complementary-mode - QNode m = h.next; // node to fulfill - if (t != tail || m == null || h != head) - continue; // inconsistent read - - Object x = m.item; - if (isData == (x != null) || // m already fulfilled - x == m || // m cancelled - !m.casItem(x, e)) { // lost CAS - advanceHead(h, m); // dequeue and retry - continue; - } - - advanceHead(h, m); // successfully fulfilled - LockSupport.unpark(m.waiter); - return (x != null)? x : e; - } - } - } - - /** - * Spins/blocks until node s is fulfilled. - * - * @param s the waiting node - * @param e the comparison value for checking match - * @param timed true if timed wait - * @param nanos timeout value - * @return matched item, or s if cancelled - */ - Object awaitFulfill(QNode s, Object e, boolean timed, long nanos) { - /* Same idea as TransferStack.awaitFulfill */ - long lastTime = (timed)? System.nanoTime() : 0; - Thread w = Thread.currentThread(); - int spins = ((head.next == s) ? - (timed? maxTimedSpins : maxUntimedSpins) : 0); - for (;;) { - if (w.isInterrupted()) - s.tryCancel(e); - Object x = s.item; - if (x != e) - return x; - if (timed) { - long now = System.nanoTime(); - nanos -= now - lastTime; - lastTime = now; - if (nanos <= 0) { - s.tryCancel(e); - continue; - } - } - if (spins > 0) - --spins; - else if (s.waiter == null) - s.waiter = w; - else if (!timed) - LockSupport.park(); - else if (nanos > spinForTimeoutThreshold) - LockSupport.parkNanos(nanos); - } - } - - /** - * Gets rid of cancelled node s with original predecessor pred. - */ - void clean(QNode pred, QNode s) { - s.waiter = null; // forget thread - /* - * At any given time, exactly one node on list cannot be - * deleted -- the last inserted node. To accommodate this, - * if we cannot delete s, we save its predecessor as - * "cleanMe", deleting the previously saved version - * first. At least one of node s or the node previously - * saved can always be deleted, so this always terminates. - */ - while (pred.next == s) { // Return early if already unlinked - QNode h = head; - QNode hn = h.next; // Absorb cancelled first node as head - if (hn != null && hn.isCancelled()) { - advanceHead(h, hn); - continue; - } - QNode t = tail; // Ensure consistent read for tail - if (t == h) - return; - QNode tn = t.next; - if (t != tail) - continue; - if (tn != null) { - advanceTail(t, tn); - continue; - } - if (s != t) { // If not tail, try to unsplice - QNode sn = s.next; - if (sn == s || pred.casNext(s, sn)) - return; - } - QNode dp = cleanMe; - if (dp != null) { // Try unlinking previous cancelled node - QNode d = dp.next; - QNode dn; - if (d == null || // d is gone or - d == dp || // d is off list or - !d.isCancelled() || // d not cancelled or - (d != t && // d not tail and - (dn = d.next) != null && // has successor - dn != d && // that is on list - dp.casNext(d, dn))) // d unspliced - casCleanMe(dp, null); - if (dp == pred) - return; // s is already saved node - } else if (casCleanMe(null, pred)) - return; // Postpone cleaning s - } - } - } - - /** - * The transferer. Set only in constructor, but cannot be declared - * as final without further complicating serialization. Since - * this is accessed only at most once per public method, there - * isn't a noticeable performance penalty for using volatile - * instead of final here. - */ - private transient volatile Transferer transferer; - - /** - * Creates a SynchronousQueue with nonfair access policy. - */ - public SynchronousQueue() { - this(false); - } - - /** - * Creates a SynchronousQueue with the specified fairness policy. - * - * @param fair if true, waiting threads contend in FIFO order for - * access; otherwise the order is unspecified. - */ - public SynchronousQueue(boolean fair) { - transferer = (fair)? new TransferQueue() : new TransferStack(); - } - - /** - * Adds the specified element to this queue, waiting if necessary for - * another thread to receive it. - * - * @throws InterruptedException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - */ - public void put(E o) throws InterruptedException { - if (o == null) throw new NullPointerException(); - if (transferer.transfer(o, false, 0) == null) { - Thread.interrupted(); - throw new InterruptedException(); - } - } - - /** - * Inserts the specified element into this queue, waiting if necessary - * up to the specified wait time for another thread to receive it. - * - * @return true if successful, or false if the - * specified waiting time elapses before a consumer appears. - * @throws InterruptedException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - */ - public boolean offer(E o, long timeout, TimeUnit unit) - throws InterruptedException { - if (o == null) throw new NullPointerException(); - if (transferer.transfer(o, true, unit.toNanos(timeout)) != null) - return true; - if (!Thread.interrupted()) - return false; - throw new InterruptedException(); - } - - /** - * Inserts the specified element into this queue, if another thread is - * waiting to receive it. - * - * @param e the element to add - * @return true if the element was added to this queue, else - * false - * @throws NullPointerException if the specified element is null - */ - public boolean offer(E e) { - if (e == null) throw new NullPointerException(); - return transferer.transfer(e, true, 0) != null; - } - - /** - * Retrieves and removes the head of this queue, waiting if necessary - * for another thread to insert it. - * - * @return the head of this queue - * @throws InterruptedException {@inheritDoc} - */ - public E take() throws InterruptedException { - Object e = transferer.transfer(null, false, 0); - if (e != null) - return (E)e; - Thread.interrupted(); - throw new InterruptedException(); - } - - /** - * Retrieves and removes the head of this queue, waiting - * if necessary up to the specified wait time, for another thread - * to insert it. - * - * @return the head of this queue, or null if the - * specified waiting time elapses before an element is present. - * @throws InterruptedException {@inheritDoc} - */ - public E poll(long timeout, TimeUnit unit) throws InterruptedException { - Object e = transferer.transfer(null, true, unit.toNanos(timeout)); - if (e != null || !Thread.interrupted()) - return (E)e; - throw new InterruptedException(); - } - - /** - * Retrieves and removes the head of this queue, if another thread - * is currently making an element available. - * - * @return the head of this queue, or null if no - * element is available. - */ - public E poll() { - return (E)transferer.transfer(null, true, 0); - } - - /** - * Always returns true. - * A SynchronousQueue has no internal capacity. - * - * @return true - */ - public boolean isEmpty() { - return true; - } - - /** - * Always returns zero. - * A SynchronousQueue has no internal capacity. - * - * @return zero. - */ - public int size() { - return 0; - } - - /** - * Always returns zero. - * A SynchronousQueue has no internal capacity. - * - * @return zero. - */ - public int remainingCapacity() { - return 0; - } - - /** - * Does nothing. - * A SynchronousQueue has no internal capacity. - */ - public void clear() { - } - - /** - * Always returns false. - * A SynchronousQueue has no internal capacity. - * - * @param o the element - * @return false - */ - public boolean contains(Object o) { - return false; - } - - /** - * Always returns false. - * A SynchronousQueue has no internal capacity. - * - * @param o the element to remove - * @return false - */ - public boolean remove(Object o) { - return false; - } - - /** - * Returns false unless the given collection is empty. - * A SynchronousQueue has no internal capacity. - * - * @param c the collection - * @return false unless given collection is empty - */ - public boolean containsAll(Collection c) { - return c.isEmpty(); - } - - /** - * Always returns false. - * A SynchronousQueue has no internal capacity. - * - * @param c the collection - * @return false - */ - public boolean removeAll(Collection c) { - return false; - } - - /** - * Always returns false. - * A SynchronousQueue has no internal capacity. - * - * @param c the collection - * @return false - */ - public boolean retainAll(Collection c) { - return false; - } - - /** - * Always returns null. - * A SynchronousQueue does not return elements - * unless actively waited on. - * - * @return null - */ - public E peek() { - return null; - } - - - static class EmptyIterator implements Iterator { - public boolean hasNext() { - return false; - } - public E next() { - throw new NoSuchElementException(); - } - public void remove() { - throw new IllegalStateException(); - } - } - - /** - * Returns an empty iterator in which hasNext always returns - * false. - * - * @return an empty iterator - */ - public Iterator iterator() { - return new EmptyIterator(); - } - - /** - * Returns a zero-length array. - * @return a zero-length array - */ - public Object[] toArray() { - return new Object[0]; - } - - /** - * Sets the zeroeth element of the specified array to null - * (if the array has non-zero length) and returns it. - * - * @param a the array - * @return the specified array - * @throws NullPointerException if the specified array is null - */ - public T[] toArray(T[] a) { - if (a.length > 0) - a[0] = null; - return a; - } - - /** - * @throws UnsupportedOperationException {@inheritDoc} - * @throws ClassCastException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - * @throws IllegalArgumentException {@inheritDoc} - */ - public int drainTo(Collection c) { - if (c == null) - throw new NullPointerException(); - if (c == this) - throw new IllegalArgumentException(); - int n = 0; - E e; - while ( (e = poll()) != null) { - c.add(e); - ++n; - } - return n; - } - - /** - * @throws UnsupportedOperationException {@inheritDoc} - * @throws ClassCastException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - * @throws IllegalArgumentException {@inheritDoc} - */ - public int drainTo(Collection c, int maxElements) { - if (c == null) - throw new NullPointerException(); - if (c == this) - throw new IllegalArgumentException(); - int n = 0; - E e; - while (n < maxElements && (e = poll()) != null) { - c.add(e); - ++n; - } - return n; - } - - /* - * To cope with serialization strategy in the 1.5 version of - * SynchronousQueue, we declare some unused classes and fields - * that exist solely to enable serializability across versions. - * These fields are never used, so are initialized only if this - * object is ever serialized or deserialized. - */ - - static class WaitQueue implements java.io.Serializable { } - static class LifoWaitQueue extends WaitQueue { - private static final long serialVersionUID = -3633113410248163686L; - } - static class FifoWaitQueue extends WaitQueue { - private static final long serialVersionUID = -3623113410248163686L; - } - private ReentrantLock qlock; - private WaitQueue waitingProducers; - private WaitQueue waitingConsumers; - - /** - * Save the state to a stream (that is, serialize it). - * - * @param s the stream - */ - private void writeObject(java.io.ObjectOutputStream s) - throws java.io.IOException { - boolean fair = transferer instanceof TransferQueue; - if (fair) { - qlock = new ReentrantLock(true); - waitingProducers = new FifoWaitQueue(); - waitingConsumers = new FifoWaitQueue(); - } - else { - qlock = new ReentrantLock(); - waitingProducers = new LifoWaitQueue(); - waitingConsumers = new LifoWaitQueue(); - } - s.defaultWriteObject(); - } - - private void readObject(final java.io.ObjectInputStream s) - throws java.io.IOException, ClassNotFoundException { - s.defaultReadObject(); - if (waitingProducers instanceof FifoWaitQueue) - transferer = new TransferQueue(); - else - transferer = new TransferStack(); - } - -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/ThreadFactory.java b/libcore/concurrent/src/main/java/java/util/concurrent/ThreadFactory.java deleted file mode 100644 index 2f0fb1a96..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/ThreadFactory.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; - -/** - * An object that creates new threads on demand. Using thread factories - * removes hardwiring of calls to {@link Thread#Thread(Runnable) new Thread}, - * enabling applications to use special thread subclasses, priorities, etc. - * - *

- * The simplest implementation of this interface is just: - *

- * class SimpleThreadFactory implements ThreadFactory {
- *   public Thread newThread(Runnable r) {
- *     return new Thread(r);
- *   }
- * }
- * 
- * - * The {@link Executors#defaultThreadFactory} method provides a more - * useful simple implementation, that sets the created thread context - * to known values before returning it. - * @since 1.5 - * @author Doug Lea - */ -public interface ThreadFactory { - - /** - * Constructs a new {@code Thread}. Implementations may also initialize - * priority, name, daemon status, {@code ThreadGroup}, etc. - * - * @param r a runnable to be executed by new thread instance - * @return constructed thread, or {@code null} if the request to - * create a thread is rejected - */ - Thread newThread(Runnable r); -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/ThreadPoolExecutor.java b/libcore/concurrent/src/main/java/java/util/concurrent/ThreadPoolExecutor.java deleted file mode 100644 index d0c934d58..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/ThreadPoolExecutor.java +++ /dev/null @@ -1,1927 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; -import java.util.concurrent.locks.*; -import java.util.concurrent.atomic.*; -import java.util.*; - -/** - * An {@link ExecutorService} that executes each submitted task using - * one of possibly several pooled threads, normally configured - * using {@link Executors} factory methods. - * - *

Thread pools address two different problems: they usually - * provide improved performance when executing large numbers of - * asynchronous tasks, due to reduced per-task invocation overhead, - * and they provide a means of bounding and managing the resources, - * including threads, consumed when executing a collection of tasks. - * Each {@code ThreadPoolExecutor} also maintains some basic - * statistics, such as the number of completed tasks. - * - *

To be useful across a wide range of contexts, this class - * provides many adjustable parameters and extensibility - * hooks. However, programmers are urged to use the more convenient - * {@link Executors} factory methods {@link - * Executors#newCachedThreadPool} (unbounded thread pool, with - * automatic thread reclamation), {@link Executors#newFixedThreadPool} - * (fixed size thread pool) and {@link - * Executors#newSingleThreadExecutor} (single background thread), that - * preconfigure settings for the most common usage - * scenarios. Otherwise, use the following guide when manually - * configuring and tuning this class: - * - *

- * - *
Core and maximum pool sizes
- * - *
A {@code ThreadPoolExecutor} will automatically adjust the - * pool size (see {@link #getPoolSize}) - * according to the bounds set by - * corePoolSize (see {@link #getCorePoolSize}) and - * maximumPoolSize (see {@link #getMaximumPoolSize}). - * - * When a new task is submitted in method {@link #execute}, and fewer - * than corePoolSize threads are running, a new thread is created to - * handle the request, even if other worker threads are idle. If - * there are more than corePoolSize but less than maximumPoolSize - * threads running, a new thread will be created only if the queue is - * full. By setting corePoolSize and maximumPoolSize the same, you - * create a fixed-size thread pool. By setting maximumPoolSize to an - * essentially unbounded value such as {@code Integer.MAX_VALUE}, you - * allow the pool to accommodate an arbitrary number of concurrent - * tasks. Most typically, core and maximum pool sizes are set only - * upon construction, but they may also be changed dynamically using - * {@link #setCorePoolSize} and {@link #setMaximumPoolSize}.
- * - *
On-demand construction
- * - *
By default, even core threads are initially created and - * started only when new tasks arrive, but this can be overridden - * dynamically using method {@link #prestartCoreThread} or {@link - * #prestartAllCoreThreads}. You probably want to prestart threads if - * you construct the pool with a non-empty queue.
- * - *
Creating new threads
- * - *
New threads are created using a {@link ThreadFactory}. If not - * otherwise specified, a {@link Executors#defaultThreadFactory} is - * used, that creates threads to all be in the same {@link - * ThreadGroup} and with the same {@code NORM_PRIORITY} priority and - * non-daemon status. By supplying a different ThreadFactory, you can - * alter the thread's name, thread group, priority, daemon status, - * etc. If a {@code ThreadFactory} fails to create a thread when asked - * by returning null from {@code newThread}, the executor will - * continue, but might not be able to execute any tasks. Threads - * should possess the "modifyThread" {@code RuntimePermission}. If - * worker threads or other threads using the pool do not possess this - * permission, service may be degraded: configuration changes may not - * take effect in a timely manner, and a shutdown pool may remain in a - * state in which termination is possible but not completed.
- * - *
Keep-alive times
- * - *
If the pool currently has more than corePoolSize threads, - * excess threads will be terminated if they have been idle for more - * than the keepAliveTime (see {@link #getKeepAliveTime}). This - * provides a means of reducing resource consumption when the pool is - * not being actively used. If the pool becomes more active later, new - * threads will be constructed. This parameter can also be changed - * dynamically using method {@link #setKeepAliveTime}. Using a value - * of {@code Long.MAX_VALUE} {@link TimeUnit#NANOSECONDS} effectively - * disables idle threads from ever terminating prior to shut down. The - * keep-alive policy applies only when there are more than - * corePoolSizeThreads.
- * - *
Queuing
- * - *
Any {@link BlockingQueue} may be used to transfer and hold - * submitted tasks. The use of this queue interacts with pool sizing: - * - *
    - * - *
  • If fewer than corePoolSize threads are running, the Executor - * always prefers adding a new thread - * rather than queuing.
  • - * - *
  • If corePoolSize or more threads are running, the Executor - * always prefers queuing a request rather than adding a new - * thread.
  • - * - *
  • If a request cannot be queued, a new thread is created unless - * this would exceed maximumPoolSize, in which case, the task will be - * rejected.
  • - * - *
- * - * There are three general strategies for queuing: - *
    - * - *
  1. Direct handoffs. A good default choice for a work - * queue is a {@link SynchronousQueue} that hands off tasks to threads - * without otherwise holding them. Here, an attempt to queue a task - * will fail if no threads are immediately available to run it, so a - * new thread will be constructed. This policy avoids lockups when - * handling sets of requests that might have internal dependencies. - * Direct handoffs generally require unbounded maximumPoolSizes to - * avoid rejection of new submitted tasks. This in turn admits the - * possibility of unbounded thread growth when commands continue to - * arrive on average faster than they can be processed.
  2. - * - *
  3. Unbounded queues. Using an unbounded queue (for - * example a {@link LinkedBlockingQueue} without a predefined - * capacity) will cause new tasks to wait in the queue when all - * corePoolSize threads are busy. Thus, no more than corePoolSize - * threads will ever be created. (And the value of the maximumPoolSize - * therefore doesn't have any effect.) This may be appropriate when - * each task is completely independent of others, so tasks cannot - * affect each others execution; for example, in a web page server. - * While this style of queuing can be useful in smoothing out - * transient bursts of requests, it admits the possibility of - * unbounded work queue growth when commands continue to arrive on - * average faster than they can be processed.
  4. - * - *
  5. Bounded queues. A bounded queue (for example, an - * {@link ArrayBlockingQueue}) helps prevent resource exhaustion when - * used with finite maximumPoolSizes, but can be more difficult to - * tune and control. Queue sizes and maximum pool sizes may be traded - * off for each other: Using large queues and small pools minimizes - * CPU usage, OS resources, and context-switching overhead, but can - * lead to artificially low throughput. If tasks frequently block (for - * example if they are I/O bound), a system may be able to schedule - * time for more threads than you otherwise allow. Use of small queues - * generally requires larger pool sizes, which keeps CPUs busier but - * may encounter unacceptable scheduling overhead, which also - * decreases throughput.
  6. - * - *
- * - *
- * - *
Rejected tasks
- * - *
New tasks submitted in method {@link #execute} will be - * rejected when the Executor has been shut down, and also - * when the Executor uses finite bounds for both maximum threads and - * work queue capacity, and is saturated. In either case, the {@code - * execute} method invokes the {@link - * RejectedExecutionHandler#rejectedExecution} method of its {@link - * RejectedExecutionHandler}. Four predefined handler policies are - * provided: - * - *
    - * - *
  1. In the default {@link ThreadPoolExecutor.AbortPolicy}, the - * handler throws a runtime {@link RejectedExecutionException} upon - * rejection.
  2. - * - *
  3. In {@link ThreadPoolExecutor.CallerRunsPolicy}, the thread - * that invokes {@code execute} itself runs the task. This provides a - * simple feedback control mechanism that will slow down the rate that - * new tasks are submitted.
  4. - * - *
  5. In {@link ThreadPoolExecutor.DiscardPolicy}, a task that - * cannot be executed is simply dropped.
  6. - * - *
  7. In {@link ThreadPoolExecutor.DiscardOldestPolicy}, if the - * executor is not shut down, the task at the head of the work queue - * is dropped, and then execution is retried (which can fail again, - * causing this to be repeated.)
  8. - * - *
- * - * It is possible to define and use other kinds of {@link - * RejectedExecutionHandler} classes. Doing so requires some care - * especially when policies are designed to work only under particular - * capacity or queuing policies.
- * - *
Hook methods
- * - *
This class provides {@code protected} overridable {@link - * #beforeExecute} and {@link #afterExecute} methods that are called - * before and after execution of each task. These can be used to - * manipulate the execution environment; for example, reinitializing - * ThreadLocals, gathering statistics, or adding log - * entries. Additionally, method {@link #terminated} can be overridden - * to perform any special processing that needs to be done once the - * Executor has fully terminated. - * - *

If hook or callback methods throw exceptions, internal worker - * threads may in turn fail and abruptly terminate.

- * - *
Queue maintenance
- * - *
Method {@link #getQueue} allows access to the work queue for - * purposes of monitoring and debugging. Use of this method for any - * other purpose is strongly discouraged. Two supplied methods, - * {@link #remove} and {@link #purge} are available to assist in - * storage reclamation when large numbers of queued tasks become - * cancelled.
- * - *
Finalization
- * - *
A pool that is no longer referenced in a program AND - * has no remaining threads will be {@code shutdown} automatically. If - * you would like to ensure that unreferenced pools are reclaimed even - * if users forget to call {@link #shutdown}, then you must arrange - * that unused threads eventually die, by setting appropriate - * keep-alive times using a lower bound of zero core threads.
- * - *
- * - *

Extension example. Most extensions of this class - * override one or more of the protected hook methods. For example, - * here is a subclass that adds a simple pause/resume feature: - * - *

 {@code
- * class PausableThreadPoolExecutor extends ThreadPoolExecutor {
- *   private boolean isPaused;
- *   private ReentrantLock pauseLock = new ReentrantLock();
- *   private Condition unpaused = pauseLock.newCondition();
- *
- *   public PausableThreadPoolExecutor(...) { super(...); }
- *
- *   protected void beforeExecute(Thread t, Runnable r) {
- *     super.beforeExecute(t, r);
- *     pauseLock.lock();
- *     try {
- *       while (isPaused) unpaused.await();
- *     } catch (InterruptedException ie) {
- *       t.interrupt();
- *     } finally {
- *       pauseLock.unlock();
- *     }
- *   }
- *
- *   public void pause() {
- *     pauseLock.lock();
- *     try {
- *       isPaused = true;
- *     } finally {
- *       pauseLock.unlock();
- *     }
- *   }
- *
- *   public void resume() {
- *     pauseLock.lock();
- *     try {
- *       isPaused = false;
- *       unpaused.signalAll();
- *     } finally {
- *       pauseLock.unlock();
- *     }
- *   }
- * }}
- * - * @since 1.5 - * @author Doug Lea - */ -public class ThreadPoolExecutor extends AbstractExecutorService { - /** - * The main pool control state, ctl, is an atomic integer packing - * two conceptual fields - * workerCount, indicating the effective number of threads - * runState, indicating whether running, shutting down etc - * - * In order to pack them into one int, we limit workerCount to - * (2^29)-1 (about 500 million) threads rather than (2^31)-1 (2 - * billion) otherwise representable. If this is ever an issue in - * the future, the variable can be changed to be an AtomicLong, - * and the shift/mask constants below adjusted. But until the need - * arises, this code is a bit faster and simpler using an int. - * - * The workerCount is the number of workers that have been - * permitted to start and not permitted to stop. The value may be - * transiently different from the actual number of live threads, - * for example when a ThreadFactory fails to create a thread when - * asked, and when exiting threads are still performing - * bookkeeping before terminating. The user-visible pool size is - * reported as the current size of the workers set. - * - * The runState provides the main lifecyle control, taking on values: - * - * RUNNING: Accept new tasks and process queued tasks - * SHUTDOWN: Don't accept new tasks, but process queued tasks - * STOP: Don't accept new tasks, don't process queued tasks, - * and interrupt in-progress tasks - * TIDYING: All tasks have terminated, workerCount is zero, - * the thread transitioning to state TIDYING - * will run the terminated() hook method - * TERMINATED: terminated() has completed - * - * The numerical order among these values matters, to allow - * ordered comparisons. The runState monotonically increases over - * time, but need not hit each state. The transitions are: - * - * RUNNING -> SHUTDOWN - * On invocation of shutdown(), perhaps implicitly in finalize() - * (RUNNING or SHUTDOWN) -> STOP - * On invocation of shutdownNow() - * SHUTDOWN -> TIDYING - * When both queue and pool are empty - * STOP -> TIDYING - * When pool is empty - * TIDYING -> TERMINATED - * When the terminated() hook method has completed - * - * Threads waiting in awaitTermination() will return when the - * state reaches TERMINATED. - * - * Detecting the transition from SHUTDOWN to TIDYING is less - * straightforward than you'd like because the queue may become - * empty after non-empty and vice versa during SHUTDOWN state, but - * we can only terminate if, after seeing that it is empty, we see - * that workerCount is 0 (which sometimes entails a recheck -- see - * below). - */ - private final AtomicInteger ctl = new AtomicInteger(ctlOf(RUNNING, 0)); - private static final int COUNT_BITS = Integer.SIZE - 3; - private static final int CAPACITY = (1 << COUNT_BITS) - 1; - - // runState is stored in the high-order bits - private static final int RUNNING = -1 << COUNT_BITS; - private static final int SHUTDOWN = 0 << COUNT_BITS; - private static final int STOP = 1 << COUNT_BITS; - private static final int TIDYING = 2 << COUNT_BITS; - private static final int TERMINATED = 3 << COUNT_BITS; - - // Packing and unpacking ctl - private static int runStateOf(int c) { return c & ~CAPACITY; } - private static int workerCountOf(int c) { return c & CAPACITY; } - private static int ctlOf(int rs, int wc) { return rs | wc; } - - /* - * Bit field accessors that don't require unpacking ctl. - * These depend on the bit layout and on workerCount being never negative. - */ - - private static boolean runStateLessThan(int c, int s) { - return c < s; - } - - private static boolean runStateAtLeast(int c, int s) { - return c >= s; - } - - private static boolean isRunning(int c) { - return c < SHUTDOWN; - } - - /** - * Attempt to CAS-increment the workerCount field of ctl. - */ - private boolean compareAndIncrementWorkerCount(int expect) { - return ctl.compareAndSet(expect, expect + 1); - } - - /** - * Attempt to CAS-decrement the workerCount field of ctl. - */ - private boolean compareAndDecrementWorkerCount(int expect) { - return ctl.compareAndSet(expect, expect - 1); - } - - /** - * Decrements the workerCount field of ctl. This is called only on - * abrupt termination of a thread (see processWorkerExit). Other - * decrements are performed within getTask. - */ - private void decrementWorkerCount() { - do {} while (! compareAndDecrementWorkerCount(ctl.get())); - } - - /** - * The queue used for holding tasks and handing off to worker - * threads. We do not require that workQueue.poll() returning - * null necessarily means that workQueue.isEmpty(), so rely - * solely on isEmpty to see if the queue is empty (which we must - * do for example when deciding whether to transition from - * SHUTDOWN to TIDYING). This accommodates special-purpose - * queues such as DelayQueues for which poll() is allowed to - * return null even if it may later return non-null when delays - * expire. - */ - private final BlockingQueue workQueue; - - /** - * Lock held on access to workers set and related bookkeeping. - * While we could use a concurrent set of some sort, it turns out - * to be generally preferable to use a lock. Among the reasons is - * that this serializes interruptIdleWorkers, which avoids - * unnecessary interrupt storms, especially during shutdown. - * Otherwise exiting threads would concurrently interrupt those - * that have not yet interrupted. It also simplifies some of the - * associated statistics bookkeeping of largestPoolSize etc. We - * also hold mainLock on shutdown and shutdownNow, for the sake of - * ensuring workers set is stable while separately checking - * permission to interrupt and actually interrupting. - */ - private final ReentrantLock mainLock = new ReentrantLock(); - - /** - * Set containing all worker threads in pool. Accessed only when - * holding mainLock. - */ - private final HashSet workers = new HashSet(); - - /** - * Wait condition to support awaitTermination - */ - private final Condition termination = mainLock.newCondition(); - - /** - * Tracks largest attained pool size. Accessed only under - * mainLock. - */ - private int largestPoolSize; - - /** - * Counter for completed tasks. Updated only on termination of - * worker threads. Accessed only under mainLock. - */ - private long completedTaskCount; - - /* - * All user control parameters are declared as volatiles so that - * ongoing actions are based on freshest values, but without need - * for locking, since no internal invariants depend on them - * changing synchronously with respect to other actions. - */ - - /** - * Factory for new threads. All threads are created using this - * factory (via method addWorker). All callers must be prepared - * for addWorker to fail, which may reflect a system or user's - * policy limiting the number of threads. Even though it is not - * treated as an error, failure to create threads may result in - * new tasks being rejected or existing ones remaining stuck in - * the queue. On the other hand, no special precautions exist to - * handle OutOfMemoryErrors that might be thrown while trying to - * create threads, since there is generally no recourse from - * within this class. - */ - private volatile ThreadFactory threadFactory; - - /** - * Handler called when saturated or shutdown in execute. - */ - private volatile RejectedExecutionHandler handler; - - /** - * Timeout in nanoseconds for idle threads waiting for work. - * Threads use this timeout when there are more than corePoolSize - * present. Otherwise they wait forever for new work. - */ - private volatile long keepAliveTime; - - /** - * Core pool size is the minimum number of workers to keep alive - * (and not allow to time out etc). - */ - private volatile int corePoolSize; - - /** - * Maximum pool size. Note that the actual maximum is internally - * bounded by CAPACITY. - */ - private volatile int maximumPoolSize; - - /** - * The default rejected execution handler - */ - private static final RejectedExecutionHandler defaultHandler = - new AbortPolicy(); - - /** - * Permission required for callers of shutdown and shutdownNow. - * We additionally require (see checkShutdownAccess) that callers - * have permission to actually interrupt threads in the worker set - * (as governed by Thread.interrupt, which relies on - * ThreadGroup.checkAccess, which in turn relies on - * SecurityManager.checkAccess). Shutdowns are attempted only if - * these checks pass. - * - * All actual invocations of Thread.interrupt (see - * interruptIdleWorkers and interruptWorkers) ignore - * SecurityExceptions, meaning that the attempted interrupts - * silently fail. In the case of shutdown, they should not fail - * unless the SecurityManager has inconsistent policies, sometimes - * allowing access to a thread and sometimes not. In such cases, - * failure to actually interrupt threads may disable or delay full - * termination. Other uses of interruptIdleWorkers are advisory, - * and failure to actually interrupt will merely delay response to - * configuration changes so is not handled exceptionally. - */ - private static final RuntimePermission shutdownPerm = - new RuntimePermission("modifyThread"); - - /** - * Class Worker mainly maintains interrupt control state for - * threads running tasks, along with other minor bookkeeping. - * This class opportunistically extends AbstractQueuedSynchronizer - * to simplify acquiring and releasing a lock surrounding each - * task execution. This protects against interrupts that are - * intended to wake up a worker thread waiting for a task from - * instead interrupting a task being run. We implement a simple - * non-reentrant mutual exclusion lock rather than use ReentrantLock - * because we do not want worker tasks to be able to reacquire the - * lock when they invoke pool control methods like setCorePoolSize. - */ - private final class Worker - extends AbstractQueuedSynchronizer - implements Runnable - { - /** - * This class will never be serialized, but we provide a - * serialVersionUID to suppress a javac warning. - */ - private static final long serialVersionUID = 6138294804551838833L; - - /** Thread this worker is running in. Null if factory fails. */ - final Thread thread; - /** Initial task to run. Possibly null. */ - Runnable firstTask; - /** Per-thread task counter */ - volatile long completedTasks; - - /** - * Creates with given first task and thread from ThreadFactory. - * @param firstTask the first task (null if none) - */ - Worker(Runnable firstTask) { - this.firstTask = firstTask; - this.thread = getThreadFactory().newThread(this); - } - - /** Delegates main run loop to outer runWorker */ - public void run() { - runWorker(this); - } - - // Lock methods - // - // The value 0 represents the unlocked state. - // The value 1 represents the locked state. - - protected boolean isHeldExclusively() { - return getState() == 1; - } - - protected boolean tryAcquire(int unused) { - if (compareAndSetState(0, 1)) { - setExclusiveOwnerThread(Thread.currentThread()); - return true; - } - return false; - } - - protected boolean tryRelease(int unused) { - setExclusiveOwnerThread(null); - setState(0); - return true; - } - - public void lock() { acquire(1); } - public boolean tryLock() { return tryAcquire(1); } - public void unlock() { release(1); } - public boolean isLocked() { return isHeldExclusively(); } - } - - /* - * Methods for setting control state - */ - - /** - * Transitions runState to given target, or leaves it alone if - * already at least the given target. - * - * @param targetState the desired state, either SHUTDOWN or STOP - * (but not TIDYING or TERMINATED -- use tryTerminate for that) - */ - private void advanceRunState(int targetState) { - for (;;) { - int c = ctl.get(); - if (runStateAtLeast(c, targetState) || - ctl.compareAndSet(c, ctlOf(targetState, workerCountOf(c)))) - break; - } - } - - /** - * Transitions to TERMINATED state if either (SHUTDOWN and pool - * and queue empty) or (STOP and pool empty). If otherwise - * eligible to terminate but workerCount is nonzero, interrupts an - * idle worker to ensure that shutdown signals propagate. This - * method must be called following any action that might make - * termination possible -- reducing worker count or removing tasks - * from the queue during shutdown. The method is non-private to - * allow access from ScheduledThreadPoolExecutor. - */ - final void tryTerminate() { - for (;;) { - int c = ctl.get(); - if (isRunning(c) || - runStateAtLeast(c, TIDYING) || - (runStateOf(c) == SHUTDOWN && ! workQueue.isEmpty())) - return; - if (workerCountOf(c) != 0) { // Eligible to terminate - interruptIdleWorkers(ONLY_ONE); - return; - } - - final ReentrantLock mainLock = this.mainLock; - mainLock.lock(); - try { - if (ctl.compareAndSet(c, ctlOf(TIDYING, 0))) { - try { - terminated(); - } finally { - ctl.set(ctlOf(TERMINATED, 0)); - termination.signalAll(); - } - return; - } - } finally { - mainLock.unlock(); - } - // else retry on failed CAS - } - } - - /* - * Methods for controlling interrupts to worker threads. - */ - - /** - * If there is a security manager, makes sure caller has - * permission to shut down threads in general (see shutdownPerm). - * If this passes, additionally makes sure the caller is allowed - * to interrupt each worker thread. This might not be true even if - * first check passed, if the SecurityManager treats some threads - * specially. - */ - private void checkShutdownAccess() { - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPermission(shutdownPerm); - final ReentrantLock mainLock = this.mainLock; - mainLock.lock(); - try { - for (Worker w : workers) - security.checkAccess(w.thread); - } finally { - mainLock.unlock(); - } - } - } - - /** - * Interrupts all threads, even if active. Ignores SecurityExceptions - * (in which case some threads may remain uninterrupted). - */ - private void interruptWorkers() { - final ReentrantLock mainLock = this.mainLock; - mainLock.lock(); - try { - for (Worker w : workers) { - try { - w.thread.interrupt(); - } catch (SecurityException ignore) { - } - } - } finally { - mainLock.unlock(); - } - } - - /** - * Interrupts threads that might be waiting for tasks (as - * indicated by not being locked) so they can check for - * termination or configuration changes. Ignores - * SecurityExceptions (in which case some threads may remain - * uninterrupted). - * - * @param onlyOne If true, interrupt at most one worker. This is - * called only from tryTerminate when termination is otherwise - * enabled but there are still other workers. In this case, at - * most one waiting worker is interrupted to propagate shutdown - * signals in case all threads are currently waiting. - * Interrupting any arbitrary thread ensures that newly arriving - * workers since shutdown began will also eventually exit. - * To guarantee eventual termination, it suffices to always - * interrupt only one idle worker, but shutdown() interrupts all - * idle workers so that redundant workers exit promptly, not - * waiting for a straggler task to finish. - */ - private void interruptIdleWorkers(boolean onlyOne) { - final ReentrantLock mainLock = this.mainLock; - mainLock.lock(); - try { - for (Worker w : workers) { - Thread t = w.thread; - if (!t.isInterrupted() && w.tryLock()) { - try { - t.interrupt(); - } catch (SecurityException ignore) { - } finally { - w.unlock(); - } - } - if (onlyOne) - break; - } - } finally { - mainLock.unlock(); - } - } - - /** - * Common form of interruptIdleWorkers, to avoid having to - * remember what the boolean argument means. - */ - private void interruptIdleWorkers() { - interruptIdleWorkers(false); - } - - private static final boolean ONLY_ONE = true; - - /** - * Ensures that unless the pool is stopping, the current thread - * does not have its interrupt set. This requires a double-check - * of state in case the interrupt was cleared concurrently with a - * shutdownNow -- if so, the interrupt is re-enabled. - */ - private void clearInterruptsForTaskRun() { - if (runStateLessThan(ctl.get(), STOP) && - Thread.interrupted() && - runStateAtLeast(ctl.get(), STOP)) - Thread.currentThread().interrupt(); - } - - /* - * Misc utilities, most of which are also exported to - * ScheduledThreadPoolExecutor - */ - - /** - * Invokes the rejected execution handler for the given command. - * Package-protected for use by ScheduledThreadPoolExecutor. - */ - final void reject(Runnable command) { - handler.rejectedExecution(command, this); - } - - /** - * Performs any further cleanup following run state transition on - * invocation of shutdown. A no-op here, but used by - * ScheduledThreadPoolExecutor to cancel delayed tasks. - */ - void onShutdown() { - } - - /** - * State check needed by ScheduledThreadPoolExecutor to - * enable running tasks during shutdown. - * - * @param shutdownOK true if should return true if SHUTDOWN - */ - final boolean isRunningOrShutdown(boolean shutdownOK) { - int rs = runStateOf(ctl.get()); - return rs == RUNNING || (rs == SHUTDOWN && shutdownOK); - } - - /** - * Drains the task queue into a new list, normally using - * drainTo. But if the queue is a DelayQueue or any other kind of - * queue for which poll or drainTo may fail to remove some - * elements, it deletes them one by one. - */ - private List drainQueue() { - BlockingQueue q = workQueue; - List taskList = new ArrayList(); - q.drainTo(taskList); - if (!q.isEmpty()) { - for (Runnable r : q.toArray(new Runnable[0])) { - if (q.remove(r)) - taskList.add(r); - } - } - return taskList; - } - - /* - * Methods for creating, running and cleaning up after workers - */ - - /** - * Checks if a new worker can be added with respect to current - * pool state and the given bound (either core or maximum). If so, - * the worker count is adjusted accordingly, and, if possible, a - * new worker is created and started running firstTask as its - * first task. This method returns false if the pool is stopped or - * eligible to shut down. It also returns false if the thread - * factory fails to create a thread when asked, which requires a - * backout of workerCount, and a recheck for termination, in case - * the existence of this worker was holding up termination. - * - * @param firstTask the task the new thread should run first (or - * null if none). Workers are created with an initial first task - * (in method execute()) to bypass queuing when there are fewer - * than corePoolSize threads (in which case we always start one), - * or when the queue is full (in which case we must bypass queue). - * Initially idle threads are usually created via - * prestartCoreThread or to replace other dying workers. - * - * @param core if true use corePoolSize as bound, else - * maximumPoolSize. (A boolean indicator is used here rather than a - * value to ensure reads of fresh values after checking other pool - * state). - * @return true if successful - */ - private boolean addWorker(Runnable firstTask, boolean core) { - retry: - for (;;) { - int c = ctl.get(); - int rs = runStateOf(c); - - // Check if queue empty only if necessary. - if (rs >= SHUTDOWN && - ! (rs == SHUTDOWN && - firstTask == null && - ! workQueue.isEmpty())) - return false; - - for (;;) { - int wc = workerCountOf(c); - if (wc >= CAPACITY || - wc >= (core ? corePoolSize : maximumPoolSize)) - return false; - if (compareAndIncrementWorkerCount(c)) - break retry; - c = ctl.get(); // Re-read ctl - if (runStateOf(c) != rs) - continue retry; - // else CAS failed due to workerCount change; retry inner loop - } - } - - Worker w = new Worker(firstTask); - Thread t = w.thread; - - final ReentrantLock mainLock = this.mainLock; - mainLock.lock(); - try { - // Recheck while holding lock. - // Back out on ThreadFactory failure or if - // shut down before lock acquired. - int c = ctl.get(); - int rs = runStateOf(c); - - if (t == null || - (rs >= SHUTDOWN && - ! (rs == SHUTDOWN && - firstTask == null))) { - decrementWorkerCount(); - tryTerminate(); - return false; - } - - workers.add(w); - - int s = workers.size(); - if (s > largestPoolSize) - largestPoolSize = s; - } finally { - mainLock.unlock(); - } - - t.start(); - // It is possible (but unlikely) for a thread to have been - // added to workers, but not yet started, during transition to - // STOP, which could result in a rare missed interrupt, - // because Thread.interrupt is not guaranteed to have any effect - // on a non-yet-started Thread (see Thread#interrupt). - if (runStateOf(ctl.get()) == STOP && ! t.isInterrupted()) - t.interrupt(); - - return true; - } - - /** - * Performs cleanup and bookkeeping for a dying worker. Called - * only from worker threads. Unless completedAbruptly is set, - * assumes that workerCount has already been adjusted to account - * for exit. This method removes thread from worker set, and - * possibly terminates the pool or replaces the worker if either - * it exited due to user task exception or if fewer than - * corePoolSize workers are running or queue is non-empty but - * there are no workers. - * - * @param w the worker - * @param completedAbruptly if the worker died due to user exception - */ - private void processWorkerExit(Worker w, boolean completedAbruptly) { - if (completedAbruptly) // If abrupt, then workerCount wasn't adjusted - decrementWorkerCount(); - - final ReentrantLock mainLock = this.mainLock; - mainLock.lock(); - try { - completedTaskCount += w.completedTasks; - workers.remove(w); - } finally { - mainLock.unlock(); - } - - tryTerminate(); - - int c = ctl.get(); - if (runStateLessThan(c, STOP)) { - if (!completedAbruptly) { - int min = corePoolSize; - if (min == 0 && ! workQueue.isEmpty()) - min = 1; - if (workerCountOf(c) >= min) - return; // replacement not needed - } - addWorker(null, false); - } - } - - /** - * Performs blocking or timed wait for a task, depending on - * current configuration settings, or returns null if this worker - * must exit because of any of: - * 1. There are more than maximumPoolSize workers (due to - * a call to setMaximumPoolSize). - * 2. The pool is stopped. - * 3. The pool is shutdown and the queue is empty. - * 4. This worker timed out waiting for a task, and timed-out - * workers are subject to termination (that is, - * {@code workerCount > corePoolSize}) - * both before and after the timed wait. - * - * @return task, or null if the worker must exit, in which case - * workerCount is decremented - */ - private Runnable getTask() { - boolean timedOut = false; // Did the last poll() time out? - - retry: - for (;;) { - int c = ctl.get(); - int rs = runStateOf(c); - - // Check if queue empty only if necessary. - if (rs >= SHUTDOWN && (rs >= STOP || workQueue.isEmpty())) { - decrementWorkerCount(); - return null; - } - - boolean timed; // Are workers subject to culling? - - for (;;) { - int wc = workerCountOf(c); - timed = wc > corePoolSize; - - if (wc <= maximumPoolSize && ! (timedOut && timed)) - break; - if (compareAndDecrementWorkerCount(c)) - return null; - c = ctl.get(); // Re-read ctl - if (runStateOf(c) != rs) - continue retry; - // else CAS failed due to workerCount change; retry inner loop - } - - try { - Runnable r = timed ? - workQueue.poll(keepAliveTime, TimeUnit.NANOSECONDS) : - workQueue.take(); - if (r != null) - return r; - timedOut = true; - } catch (InterruptedException retry) { - timedOut = false; - } - } - } - - /** - * Main worker run loop. Repeatedly gets tasks from queue and - * executes them, while coping with a number of issues: - * - * 1. We may start out with an initial task, in which case we - * don't need to get the first one. Otherwise, as long as pool is - * running, we get tasks from getTask. If it returns null then the - * worker exits due to changed pool state or configuration - * parameters. Other exits result from exception throws in - * external code, in which case completedAbruptly holds, which - * usually leads processWorkerExit to replace this thread. - * - * 2. Before running any task, the lock is acquired to prevent - * other pool interrupts while the task is executing, and - * clearInterruptsForTaskRun called to ensure that unless pool is - * stopping, this thread does not have its interrupt set. - * - * 3. Each task run is preceded by a call to beforeExecute, which - * might throw an exception, in which case we cause thread to die - * (breaking loop with completedAbruptly true) without processing - * the task. - * - * 4. Assuming beforeExecute completes normally, we run the task, - * gathering any of its thrown exceptions to send to - * afterExecute. We separately handle RuntimeException, Error - * (both of which the specs guarantee that we trap) and arbitrary - * Throwables. Because we cannot rethrow Throwables within - * Runnable.run, we wrap them within Errors on the way out (to the - * thread's UncaughtExceptionHandler). Any thrown exception also - * conservatively causes thread to die. - * - * 5. After task.run completes, we call afterExecute, which may - * also throw an exception, which will also cause thread to - * die. According to JLS Sec 14.20, this exception is the one that - * will be in effect even if task.run throws. - * - * The net effect of the exception mechanics is that afterExecute - * and the thread's UncaughtExceptionHandler have as accurate - * information as we can provide about any problems encountered by - * user code. - * - * @param w the worker - */ - final void runWorker(Worker w) { - Runnable task = w.firstTask; - w.firstTask = null; - boolean completedAbruptly = true; - try { - while (task != null || (task = getTask()) != null) { - w.lock(); - clearInterruptsForTaskRun(); - try { - beforeExecute(w.thread, task); - Throwable thrown = null; - try { - task.run(); - } catch (RuntimeException x) { - thrown = x; throw x; - } catch (Error x) { - thrown = x; throw x; - } catch (Throwable x) { - thrown = x; throw new Error(x); - } finally { - afterExecute(task, thrown); - } - } finally { - task = null; - w.completedTasks++; - w.unlock(); - } - } - completedAbruptly = false; - } finally { - processWorkerExit(w, completedAbruptly); - } - } - - // Public constructors and methods - - /** - * Creates a new {@code ThreadPoolExecutor} with the given initial - * parameters and default thread factory and rejected execution handler. - * It may be more convenient to use one of the {@link Executors} factory - * methods instead of this general purpose constructor. - * - * @param corePoolSize the number of threads to keep in the pool, even - * if they are idle - * @param maximumPoolSize the maximum number of threads to allow in the - * pool - * @param keepAliveTime when the number of threads is greater than - * the core, this is the maximum time that excess idle threads - * will wait for new tasks before terminating. - * @param unit the time unit for the {@code keepAliveTime} argument - * @param workQueue the queue to use for holding tasks before they are - * executed. This queue will hold only the {@code Runnable} - * tasks submitted by the {@code execute} method. - * @throws IllegalArgumentException if one of the following holds:
- * {@code corePoolSize < 0}
- * {@code keepAliveTime < 0}
- * {@code maximumPoolSize <= 0}
- * {@code maximumPoolSize < corePoolSize} - * @throws NullPointerException if {@code workQueue} is null - */ - public ThreadPoolExecutor(int corePoolSize, - int maximumPoolSize, - long keepAliveTime, - TimeUnit unit, - BlockingQueue workQueue) { - this(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, - Executors.defaultThreadFactory(), defaultHandler); - } - - /** - * Creates a new {@code ThreadPoolExecutor} with the given initial - * parameters and default rejected execution handler. - * - * @param corePoolSize the number of threads to keep in the pool, even - * if they are idle - * @param maximumPoolSize the maximum number of threads to allow in the - * pool - * @param keepAliveTime when the number of threads is greater than - * the core, this is the maximum time that excess idle threads - * will wait for new tasks before terminating. - * @param unit the time unit for the {@code keepAliveTime} argument - * @param workQueue the queue to use for holding tasks before they are - * executed. This queue will hold only the {@code Runnable} - * tasks submitted by the {@code execute} method. - * @param threadFactory the factory to use when the executor - * creates a new thread - * @throws IllegalArgumentException if one of the following holds:
- * {@code corePoolSize < 0}
- * {@code keepAliveTime < 0}
- * {@code maximumPoolSize <= 0}
- * {@code maximumPoolSize < corePoolSize} - * @throws NullPointerException if {@code workQueue} - * or {@code threadFactory} is null - */ - public ThreadPoolExecutor(int corePoolSize, - int maximumPoolSize, - long keepAliveTime, - TimeUnit unit, - BlockingQueue workQueue, - ThreadFactory threadFactory) { - this(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, - threadFactory, defaultHandler); - } - - /** - * Creates a new {@code ThreadPoolExecutor} with the given initial - * parameters and default thread factory. - * - * @param corePoolSize the number of threads to keep in the pool, even - * if they are idle - * @param maximumPoolSize the maximum number of threads to allow in the - * pool - * @param keepAliveTime when the number of threads is greater than - * the core, this is the maximum time that excess idle threads - * will wait for new tasks before terminating. - * @param unit the time unit for the {@code keepAliveTime} argument - * @param workQueue the queue to use for holding tasks before they are - * executed. This queue will hold only the {@code Runnable} - * tasks submitted by the {@code execute} method. - * @param handler the handler to use when execution is blocked - * because the thread bounds and queue capacities are reached - * @throws IllegalArgumentException if one of the following holds:
- * {@code corePoolSize < 0}
- * {@code keepAliveTime < 0}
- * {@code maximumPoolSize <= 0}
- * {@code maximumPoolSize < corePoolSize} - * @throws NullPointerException if {@code workQueue} - * or {@code handler} is null - */ - public ThreadPoolExecutor(int corePoolSize, - int maximumPoolSize, - long keepAliveTime, - TimeUnit unit, - BlockingQueue workQueue, - RejectedExecutionHandler handler) { - this(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, - Executors.defaultThreadFactory(), handler); - } - - /** - * Creates a new {@code ThreadPoolExecutor} with the given initial - * parameters. - * - * @param corePoolSize the number of threads to keep in the pool, even - * if they are idle - * @param maximumPoolSize the maximum number of threads to allow in the - * pool - * @param keepAliveTime when the number of threads is greater than - * the core, this is the maximum time that excess idle threads - * will wait for new tasks before terminating. - * @param unit the time unit for the {@code keepAliveTime} argument - * @param workQueue the queue to use for holding tasks before they are - * executed. This queue will hold only the {@code Runnable} - * tasks submitted by the {@code execute} method. - * @param threadFactory the factory to use when the executor - * creates a new thread - * @param handler the handler to use when execution is blocked - * because the thread bounds and queue capacities are reached - * @throws IllegalArgumentException if one of the following holds:
- * {@code corePoolSize < 0}
- * {@code keepAliveTime < 0}
- * {@code maximumPoolSize <= 0}
- * {@code maximumPoolSize < corePoolSize} - * @throws NullPointerException if {@code workQueue} - * or {@code threadFactory} or {@code handler} is null - */ - public ThreadPoolExecutor(int corePoolSize, - int maximumPoolSize, - long keepAliveTime, - TimeUnit unit, - BlockingQueue workQueue, - ThreadFactory threadFactory, - RejectedExecutionHandler handler) { - if (corePoolSize < 0 || - maximumPoolSize <= 0 || - maximumPoolSize < corePoolSize || - keepAliveTime < 0) - throw new IllegalArgumentException(); - if (workQueue == null || threadFactory == null || handler == null) - throw new NullPointerException(); - this.corePoolSize = corePoolSize; - this.maximumPoolSize = maximumPoolSize; - this.workQueue = workQueue; - this.keepAliveTime = unit.toNanos(keepAliveTime); - this.threadFactory = threadFactory; - this.handler = handler; - } - - /** - * Executes the given task sometime in the future. The task - * may execute in a new thread or in an existing pooled thread. - * - * If the task cannot be submitted for execution, either because this - * executor has been shutdown or because its capacity has been reached, - * the task is handled by the current {@code RejectedExecutionHandler}. - * - * @param command the task to execute - * @throws RejectedExecutionException at discretion of - * {@code RejectedExecutionHandler}, if the task - * cannot be accepted for execution - * @throws NullPointerException if {@code command} is null - */ - public void execute(Runnable command) { - if (command == null) - throw new NullPointerException(); - /* - * Proceed in 3 steps: - * - * 1. If fewer than corePoolSize threads are running, try to - * start a new thread with the given command as its first - * task. The call to addWorker atomically checks runState and - * workerCount, and so prevents false alarms that would add - * threads when it shouldn't, by returning false. - * - * 2. If a task can be successfully queued, then we still need - * to double-check whether we should have added a thread - * (because existing ones died since last checking) or that - * the pool shut down since entry into this method. So we - * recheck state and if necessary roll back the enqueuing if - * stopped, or start a new thread if there are none. - * - * 3. If we cannot queue task, then we try to add a new - * thread. If it fails, we know we are shut down or saturated - * and so reject the task. - */ - int c = ctl.get(); - if (workerCountOf(c) < corePoolSize) { - if (addWorker(command, true)) - return; - c = ctl.get(); - } - if (isRunning(c) && workQueue.offer(command)) { - int recheck = ctl.get(); - if (! isRunning(recheck) && remove(command)) - reject(command); - else if (workerCountOf(recheck) == 0) - addWorker(null, false); - } - else if (!addWorker(command, false)) - reject(command); - } - - /** - * Initiates an orderly shutdown in which previously submitted - * tasks are executed, but no new tasks will be accepted. - * Invocation has no additional effect if already shut down. - * - *

This method does not wait for previously submitted tasks to - * complete execution. Use {@link #awaitTermination awaitTermination} - * to do that. - * - * @throws SecurityException {@inheritDoc} - */ - public void shutdown() { - final ReentrantLock mainLock = this.mainLock; - mainLock.lock(); - try { - checkShutdownAccess(); - advanceRunState(SHUTDOWN); - interruptIdleWorkers(); - onShutdown(); // hook for ScheduledThreadPoolExecutor - } finally { - mainLock.unlock(); - } - tryTerminate(); - } - - /** - * Attempts to stop all actively executing tasks, halts the - * processing of waiting tasks, and returns a list of the tasks - * that were awaiting execution. These tasks are drained (removed) - * from the task queue upon return from this method. - * - *

This method does not wait for actively executing tasks to - * terminate. Use {@link #awaitTermination awaitTermination} to - * do that. - * - *

There are no guarantees beyond best-effort attempts to stop - * processing actively executing tasks. This implementation - * cancels tasks via {@link Thread#interrupt}, so any task that - * fails to respond to interrupts may never terminate. - * - * @throws SecurityException {@inheritDoc} - */ - public List shutdownNow() { - List tasks; - final ReentrantLock mainLock = this.mainLock; - mainLock.lock(); - try { - checkShutdownAccess(); - advanceRunState(STOP); - interruptWorkers(); - tasks = drainQueue(); - } finally { - mainLock.unlock(); - } - tryTerminate(); - return tasks; - } - - public boolean isShutdown() { - return ! isRunning(ctl.get()); - } - - /** - * Returns true if this executor is in the process of terminating - * after {@link #shutdown} or {@link #shutdownNow} but has not - * completely terminated. This method may be useful for - * debugging. A return of {@code true} reported a sufficient - * period after shutdown may indicate that submitted tasks have - * ignored or suppressed interruption, causing this executor not - * to properly terminate. - * - * @return true if terminating but not yet terminated - */ - public boolean isTerminating() { - int c = ctl.get(); - return ! isRunning(c) && runStateLessThan(c, TERMINATED); - } - - public boolean isTerminated() { - return runStateAtLeast(ctl.get(), TERMINATED); - } - - public boolean awaitTermination(long timeout, TimeUnit unit) - throws InterruptedException { - long nanos = unit.toNanos(timeout); - final ReentrantLock mainLock = this.mainLock; - mainLock.lock(); - try { - for (;;) { - if (runStateAtLeast(ctl.get(), TERMINATED)) - return true; - if (nanos <= 0) - return false; - nanos = termination.awaitNanos(nanos); - } - } finally { - mainLock.unlock(); - } - } - - /** - * Invokes {@code shutdown} when this executor is no longer - * referenced and it has no threads. - */ - protected void finalize() { - shutdown(); - } - - /** - * Sets the thread factory used to create new threads. - * - * @param threadFactory the new thread factory - * @throws NullPointerException if threadFactory is null - * @see #getThreadFactory - */ - public void setThreadFactory(ThreadFactory threadFactory) { - if (threadFactory == null) - throw new NullPointerException(); - this.threadFactory = threadFactory; - } - - /** - * Returns the thread factory used to create new threads. - * - * @return the current thread factory - * @see #setThreadFactory - */ - public ThreadFactory getThreadFactory() { - return threadFactory; - } - - /** - * Sets a new handler for unexecutable tasks. - * - * @param handler the new handler - * @throws NullPointerException if handler is null - * @see #getRejectedExecutionHandler - */ - public void setRejectedExecutionHandler(RejectedExecutionHandler handler) { - if (handler == null) - throw new NullPointerException(); - this.handler = handler; - } - - /** - * Returns the current handler for unexecutable tasks. - * - * @return the current handler - * @see #setRejectedExecutionHandler - */ - public RejectedExecutionHandler getRejectedExecutionHandler() { - return handler; - } - - /** - * Sets the core number of threads. This overrides any value set - * in the constructor. If the new value is smaller than the - * current value, excess existing threads will be terminated when - * they next become idle. If larger, new threads will, if needed, - * be started to execute any queued tasks. - * - * @param corePoolSize the new core size - * @throws IllegalArgumentException if {@code corePoolSize < 0} - * @see #getCorePoolSize - */ - public void setCorePoolSize(int corePoolSize) { - if (corePoolSize < 0) - throw new IllegalArgumentException(); - int delta = corePoolSize - this.corePoolSize; - this.corePoolSize = corePoolSize; - if (workerCountOf(ctl.get()) > corePoolSize) - interruptIdleWorkers(); - else if (delta > 0) { - // We don't really know how many new threads are "needed". - // As a heuristic, prestart enough new workers (up to new - // core size) to handle the current number of tasks in - // queue, but stop if queue becomes empty while doing so. - int k = Math.min(delta, workQueue.size()); - while (k-- > 0 && addWorker(null, true)) { - if (workQueue.isEmpty()) - break; - } - } - } - - /** - * Returns the core number of threads. - * - * @return the core number of threads - * @see #setCorePoolSize - */ - public int getCorePoolSize() { - return corePoolSize; - } - - /** - * Starts a core thread, causing it to idly wait for work. This - * overrides the default policy of starting core threads only when - * new tasks are executed. This method will return {@code false} - * if all core threads have already been started. - * - * @return {@code true} if a thread was started - */ - public boolean prestartCoreThread() { - return workerCountOf(ctl.get()) < corePoolSize && - addWorker(null, true); - } - - /** - * Starts all core threads, causing them to idly wait for work. This - * overrides the default policy of starting core threads only when - * new tasks are executed. - * - * @return the number of threads started - */ - public int prestartAllCoreThreads() { - int n = 0; - while (addWorker(null, true)) - ++n; - return n; - } - - /** - * Sets the maximum allowed number of threads. This overrides any - * value set in the constructor. If the new value is smaller than - * the current value, excess existing threads will be - * terminated when they next become idle. - * - * @param maximumPoolSize the new maximum - * @throws IllegalArgumentException if the new maximum is - * less than or equal to zero, or - * less than the {@linkplain #getCorePoolSize core pool size} - * @see #getMaximumPoolSize - */ - public void setMaximumPoolSize(int maximumPoolSize) { - if (maximumPoolSize <= 0 || maximumPoolSize < corePoolSize) - throw new IllegalArgumentException(); - this.maximumPoolSize = maximumPoolSize; - if (workerCountOf(ctl.get()) > maximumPoolSize) - interruptIdleWorkers(); - } - - /** - * Returns the maximum allowed number of threads. - * - * @return the maximum allowed number of threads - * @see #setMaximumPoolSize - */ - public int getMaximumPoolSize() { - return maximumPoolSize; - } - - /** - * Sets the time limit for which threads may remain idle before - * being terminated. If there are more than the core number of - * threads currently in the pool, after waiting this amount of - * time without processing a task, excess threads will be - * terminated. This overrides any value set in the constructor. - * - * @param time the time to wait. A time value of zero will cause - * excess threads to terminate immediately after executing tasks. - * @param unit the time unit of the {@code time} argument - * @throws IllegalArgumentException if {@code time} less than zero or - * if {@code time} is zero and {@code allowsCoreThreadTimeOut} - * @see #getKeepAliveTime - */ - public void setKeepAliveTime(long time, TimeUnit unit) { - if (time < 0) - throw new IllegalArgumentException(); - long keepAliveTime = unit.toNanos(time); - long delta = keepAliveTime - this.keepAliveTime; - this.keepAliveTime = keepAliveTime; - if (delta < 0) - interruptIdleWorkers(); - } - - /** - * Returns the thread keep-alive time, which is the amount of time - * that threads in excess of the core pool size may remain - * idle before being terminated. - * - * @param unit the desired time unit of the result - * @return the time limit - * @see #setKeepAliveTime - */ - public long getKeepAliveTime(TimeUnit unit) { - return unit.convert(keepAliveTime, TimeUnit.NANOSECONDS); - } - - /* User-level queue utilities */ - - /** - * Returns the task queue used by this executor. Access to the - * task queue is intended primarily for debugging and monitoring. - * This queue may be in active use. Retrieving the task queue - * does not prevent queued tasks from executing. - * - * @return the task queue - */ - public BlockingQueue getQueue() { - return workQueue; - } - - /** - * Removes this task from the executor's internal queue if it is - * present, thus causing it not to be run if it has not already - * started. - * - *

This method may be useful as one part of a cancellation - * scheme. It may fail to remove tasks that have been converted - * into other forms before being placed on the internal queue. For - * example, a task entered using {@code submit} might be - * converted into a form that maintains {@code Future} status. - * However, in such cases, method {@link #purge} may be used to - * remove those Futures that have been cancelled. - * - * @param task the task to remove - * @return true if the task was removed - */ - public boolean remove(Runnable task) { - boolean removed = workQueue.remove(task); - tryTerminate(); // In case SHUTDOWN and now empty - return removed; - } - - /** - * Tries to remove from the work queue all {@link Future} - * tasks that have been cancelled. This method can be useful as a - * storage reclamation operation, that has no other impact on - * functionality. Cancelled tasks are never executed, but may - * accumulate in work queues until worker threads can actively - * remove them. Invoking this method instead tries to remove them now. - * However, this method may fail to remove tasks in - * the presence of interference by other threads. - */ - public void purge() { - final BlockingQueue q = workQueue; - try { - Iterator it = q.iterator(); - while (it.hasNext()) { - Runnable r = it.next(); - if (r instanceof Future && ((Future)r).isCancelled()) - it.remove(); - } - } catch (ConcurrentModificationException fallThrough) { - // Take slow path if we encounter interference during traversal. - // Make copy for traversal and call remove for cancelled entries. - // The slow path is more likely to be O(N*N). - for (Object r : q.toArray()) - if (r instanceof Future && ((Future)r).isCancelled()) - q.remove(r); - } - - tryTerminate(); // In case SHUTDOWN and now empty - } - - /* Statistics */ - - /** - * Returns the current number of threads in the pool. - * - * @return the number of threads - */ - public int getPoolSize() { - final ReentrantLock mainLock = this.mainLock; - mainLock.lock(); - try { - // Remove rare and surprising possibility of - // isTerminated() && getPoolSize() > 0 - return runStateAtLeast(ctl.get(), TIDYING) ? 0 - : workers.size(); - } finally { - mainLock.unlock(); - } - } - - /** - * Returns the approximate number of threads that are actively - * executing tasks. - * - * @return the number of threads - */ - public int getActiveCount() { - final ReentrantLock mainLock = this.mainLock; - mainLock.lock(); - try { - int n = 0; - for (Worker w : workers) - if (w.isLocked()) - ++n; - return n; - } finally { - mainLock.unlock(); - } - } - - /** - * Returns the largest number of threads that have ever - * simultaneously been in the pool. - * - * @return the number of threads - */ - public int getLargestPoolSize() { - final ReentrantLock mainLock = this.mainLock; - mainLock.lock(); - try { - return largestPoolSize; - } finally { - mainLock.unlock(); - } - } - - /** - * Returns the approximate total number of tasks that have ever been - * scheduled for execution. Because the states of tasks and - * threads may change dynamically during computation, the returned - * value is only an approximation. - * - * @return the number of tasks - */ - public long getTaskCount() { - final ReentrantLock mainLock = this.mainLock; - mainLock.lock(); - try { - long n = completedTaskCount; - for (Worker w : workers) { - n += w.completedTasks; - if (w.isLocked()) - ++n; - } - return n + workQueue.size(); - } finally { - mainLock.unlock(); - } - } - - /** - * Returns the approximate total number of tasks that have - * completed execution. Because the states of tasks and threads - * may change dynamically during computation, the returned value - * is only an approximation, but one that does not ever decrease - * across successive calls. - * - * @return the number of tasks - */ - public long getCompletedTaskCount() { - final ReentrantLock mainLock = this.mainLock; - mainLock.lock(); - try { - long n = completedTaskCount; - for (Worker w : workers) - n += w.completedTasks; - return n; - } finally { - mainLock.unlock(); - } - } - - /* Extension hooks */ - - /** - * Method invoked prior to executing the given Runnable in the - * given thread. This method is invoked by thread {@code t} that - * will execute task {@code r}, and may be used to re-initialize - * ThreadLocals, or to perform logging. - * - *

This implementation does nothing, but may be customized in - * subclasses. Note: To properly nest multiple overridings, subclasses - * should generally invoke {@code super.beforeExecute} at the end of - * this method. - * - * @param t the thread that will run task {@code r} - * @param r the task that will be executed - */ - protected void beforeExecute(Thread t, Runnable r) { } - - /** - * Method invoked upon completion of execution of the given Runnable. - * This method is invoked by the thread that executed the task. If - * non-null, the Throwable is the uncaught {@code RuntimeException} - * or {@code Error} that caused execution to terminate abruptly. - * - *

This implementation does nothing, but may be customized in - * subclasses. Note: To properly nest multiple overridings, subclasses - * should generally invoke {@code super.afterExecute} at the - * beginning of this method. - * - *

Note: When actions are enclosed in tasks (such as - * {@link FutureTask}) either explicitly or via methods such as - * {@code submit}, these task objects catch and maintain - * computational exceptions, and so they do not cause abrupt - * termination, and the internal exceptions are not - * passed to this method. If you would like to trap both kinds of - * failures in this method, you can further probe for such cases, - * as in this sample subclass that prints either the direct cause - * or the underlying exception if a task has been aborted: - * - *

 {@code
-     * class ExtendedExecutor extends ThreadPoolExecutor {
-     *   // ...
-     *   protected void afterExecute(Runnable r, Throwable t) {
-     *     super.afterExecute(r, t);
-     *     if (t == null && r instanceof Future) {
-     *       try {
-     *         Object result = ((Future) r).get();
-     *       } catch (CancellationException ce) {
-     *           t = ce;
-     *       } catch (ExecutionException ee) {
-     *           t = ee.getCause();
-     *       } catch (InterruptedException ie) {
-     *           Thread.currentThread().interrupt(); // ignore/reset
-     *       }
-     *     }
-     *     if (t != null)
-     *       System.out.println(t);
-     *   }
-     * }}
- * - * @param r the runnable that has completed - * @param t the exception that caused termination, or null if - * execution completed normally - */ - protected void afterExecute(Runnable r, Throwable t) { } - - /** - * Method invoked when the Executor has terminated. Default - * implementation does nothing. Note: To properly nest multiple - * overridings, subclasses should generally invoke - * {@code super.terminated} within this method. - */ - protected void terminated() { } - - /* Predefined RejectedExecutionHandlers */ - - /** - * A handler for rejected tasks that runs the rejected task - * directly in the calling thread of the {@code execute} method, - * unless the executor has been shut down, in which case the task - * is discarded. - */ - public static class CallerRunsPolicy implements RejectedExecutionHandler { - /** - * Creates a {@code CallerRunsPolicy}. - */ - public CallerRunsPolicy() { } - - /** - * Executes task r in the caller's thread, unless the executor - * has been shut down, in which case the task is discarded. - * - * @param r the runnable task requested to be executed - * @param e the executor attempting to execute this task - */ - public void rejectedExecution(Runnable r, ThreadPoolExecutor e) { - if (!e.isShutdown()) { - r.run(); - } - } - } - - /** - * A handler for rejected tasks that throws a - * {@code RejectedExecutionException}. - */ - public static class AbortPolicy implements RejectedExecutionHandler { - /** - * Creates an {@code AbortPolicy}. - */ - public AbortPolicy() { } - - /** - * Always throws RejectedExecutionException. - * - * @param r the runnable task requested to be executed - * @param e the executor attempting to execute this task - * @throws RejectedExecutionException always. - */ - public void rejectedExecution(Runnable r, ThreadPoolExecutor e) { - throw new RejectedExecutionException(); - } - } - - /** - * A handler for rejected tasks that silently discards the - * rejected task. - */ - public static class DiscardPolicy implements RejectedExecutionHandler { - /** - * Creates a {@code DiscardPolicy}. - */ - public DiscardPolicy() { } - - /** - * Does nothing, which has the effect of discarding task r. - * - * @param r the runnable task requested to be executed - * @param e the executor attempting to execute this task - */ - public void rejectedExecution(Runnable r, ThreadPoolExecutor e) { - } - } - - /** - * A handler for rejected tasks that discards the oldest unhandled - * request and then retries {@code execute}, unless the executor - * is shut down, in which case the task is discarded. - */ - public static class DiscardOldestPolicy implements RejectedExecutionHandler { - /** - * Creates a {@code DiscardOldestPolicy} for the given executor. - */ - public DiscardOldestPolicy() { } - - /** - * Obtains and ignores the next task that the executor - * would otherwise execute, if one is immediately available, - * and then retries execution of task r, unless the executor - * is shut down, in which case task r is instead discarded. - * - * @param r the runnable task requested to be executed - * @param e the executor attempting to execute this task - */ - public void rejectedExecution(Runnable r, ThreadPoolExecutor e) { - if (!e.isShutdown()) { - e.getQueue().poll(); - e.execute(r); - } - } - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/TimeUnit.java b/libcore/concurrent/src/main/java/java/util/concurrent/TimeUnit.java deleted file mode 100644 index 412d28a21..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/TimeUnit.java +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; - -/** - * A TimeUnit represents time durations at a given unit of - * granularity and provides utility methods to convert across units, - * and to perform timing and delay operations in these units. A - * TimeUnit does not maintain time information, but only - * helps organize and use time representations that may be maintained - * separately across various contexts. A nanosecond is defined as one - * thousandth of a microsecond, a microsecond as one thousandth of a - * millisecond, a millisecond as one thousandth of a second, a minute - * as sixty seconds, an hour as sixty minutes, and a day as twenty four - * hours. - * - *

A TimeUnit is mainly used to inform time-based methods - * how a given timing parameter should be interpreted. For example, - * the following code will timeout in 50 milliseconds if the {@link - * java.util.concurrent.locks.Lock lock} is not available: - * - *

  Lock lock = ...;
- *  if ( lock.tryLock(50L, TimeUnit.MILLISECONDS) ) ...
- * 
- * while this code will timeout in 50 seconds: - *
- *  Lock lock = ...;
- *  if ( lock.tryLock(50L, TimeUnit.SECONDS) ) ...
- * 
- * - * Note however, that there is no guarantee that a particular timeout - * implementation will be able to notice the passage of time at the - * same granularity as the given TimeUnit. - * - * @since 1.5 - * @author Doug Lea - */ -public enum TimeUnit { - /** TimeUnit which represents one nanosecond. */ - NANOSECONDS { - public long toNanos(long d) { return d; } - public long toMicros(long d) { return d/(C1/C0); } - public long toMillis(long d) { return d/(C2/C0); } - public long toSeconds(long d) { return d/(C3/C0); } - public long toMinutes(long d) { return d/(C4/C0); } - public long toHours(long d) { return d/(C5/C0); } - public long toDays(long d) { return d/(C6/C0); } - public long convert(long d, TimeUnit u) { return u.toNanos(d); } - int excessNanos(long d, long m) { return (int)(d - (m*C2)); } - }, - /** TimeUnit which represents one microsecond. */ - MICROSECONDS { - public long toNanos(long d) { return x(d, C1/C0, MAX/(C1/C0)); } - public long toMicros(long d) { return d; } - public long toMillis(long d) { return d/(C2/C1); } - public long toSeconds(long d) { return d/(C3/C1); } - public long toMinutes(long d) { return d/(C4/C1); } - public long toHours(long d) { return d/(C5/C1); } - public long toDays(long d) { return d/(C6/C1); } - public long convert(long d, TimeUnit u) { return u.toMicros(d); } - int excessNanos(long d, long m) { return (int)((d*C1) - (m*C2)); } - }, - /** TimeUnit which represents one millisecond. */ - MILLISECONDS { - public long toNanos(long d) { return x(d, C2/C0, MAX/(C2/C0)); } - public long toMicros(long d) { return x(d, C2/C1, MAX/(C2/C1)); } - public long toMillis(long d) { return d; } - public long toSeconds(long d) { return d/(C3/C2); } - public long toMinutes(long d) { return d/(C4/C2); } - public long toHours(long d) { return d/(C5/C2); } - public long toDays(long d) { return d/(C6/C2); } - public long convert(long d, TimeUnit u) { return u.toMillis(d); } - int excessNanos(long d, long m) { return 0; } - }, - /** TimeUnit which represents one second. */ - SECONDS { - public long toNanos(long d) { return x(d, C3/C0, MAX/(C3/C0)); } - public long toMicros(long d) { return x(d, C3/C1, MAX/(C3/C1)); } - public long toMillis(long d) { return x(d, C3/C2, MAX/(C3/C2)); } - public long toSeconds(long d) { return d; } - public long toMinutes(long d) { return d/(C4/C3); } - public long toHours(long d) { return d/(C5/C3); } - public long toDays(long d) { return d/(C6/C3); } - public long convert(long d, TimeUnit u) { return u.toSeconds(d); } - int excessNanos(long d, long m) { return 0; } - }; - - // Handy constants for conversion methods - static final long C0 = 1L; - static final long C1 = C0 * 1000L; - static final long C2 = C1 * 1000L; - static final long C3 = C2 * 1000L; - static final long C4 = C3 * 60L; - static final long C5 = C4 * 60L; - static final long C6 = C5 * 24L; - - static final long MAX = Long.MAX_VALUE; - - /** - * Scale d by m, checking for overflow. - * This has a short name to make above code more readable. - */ - static long x(long d, long m, long over) { - if (d > over) return Long.MAX_VALUE; - if (d < -over) return Long.MIN_VALUE; - return d * m; - } - - // To maintain full signature compatibility with 1.5, and to improve the - // clarity of the generated javadoc (see 6287639: Abstract methods in - // enum classes should not be listed as abstract), method convert - // etc. are not declared abstract but otherwise act as abstract methods. - - /** - * Convert the given time duration in the given unit to this - * unit. Conversions from finer to coarser granularities - * truncate, so lose precision. For example converting - * 999 milliseconds to seconds results in - * 0. Conversions from coarser to finer granularities - * with arguments that would numerically overflow saturate to - * Long.MIN_VALUE if negative or Long.MAX_VALUE - * if positive. - * - *

For example, to convert 10 minutes to milliseconds, use: - * TimeUnit.MILLISECONDS.convert(10L, TimeUnit.MINUTES) - * - * @param sourceDuration the time duration in the given sourceUnit - * @param sourceUnit the unit of the sourceDuration argument - * @return the converted duration in this unit, - * or Long.MIN_VALUE if conversion would negatively - * overflow, or Long.MAX_VALUE if it would positively overflow. - */ - public long convert(long sourceDuration, TimeUnit sourceUnit) { - throw new AbstractMethodError(); - } - - /** - * Equivalent to NANOSECONDS.convert(duration, this). - * @param duration the duration - * @return the converted duration, - * or Long.MIN_VALUE if conversion would negatively - * overflow, or Long.MAX_VALUE if it would positively overflow. - * @see #convert - */ - public long toNanos(long duration) { - throw new AbstractMethodError(); - } - - /** - * Equivalent to MICROSECONDS.convert(duration, this). - * @param duration the duration - * @return the converted duration, - * or Long.MIN_VALUE if conversion would negatively - * overflow, or Long.MAX_VALUE if it would positively overflow. - * @see #convert - */ - public long toMicros(long duration) { - throw new AbstractMethodError(); - } - - /** - * Equivalent to MILLISECONDS.convert(duration, this). - * @param duration the duration - * @return the converted duration, - * or Long.MIN_VALUE if conversion would negatively - * overflow, or Long.MAX_VALUE if it would positively overflow. - * @see #convert - */ - public long toMillis(long duration) { - throw new AbstractMethodError(); - } - - /** - * Equivalent to SECONDS.convert(duration, this). - * @param duration the duration - * @return the converted duration, - * or Long.MIN_VALUE if conversion would negatively - * overflow, or Long.MAX_VALUE if it would positively overflow. - * @see #convert - */ - public long toSeconds(long duration) { - throw new AbstractMethodError(); - } - - /** - * Equivalent to MINUTES.convert(duration, this). - * @param duration the duration - * @return the converted duration, - * or Long.MIN_VALUE if conversion would negatively - * overflow, or Long.MAX_VALUE if it would positively overflow. - * @see #convert - */ - long toMinutes(long duration) { - throw new AbstractMethodError(); - } - - /** - * Equivalent to HOURS.convert(duration, this). - * @param duration the duration - * @return the converted duration, - * or Long.MIN_VALUE if conversion would negatively - * overflow, or Long.MAX_VALUE if it would positively overflow. - * @see #convert - */ - long toHours(long duration) { - throw new AbstractMethodError(); - } - - /** - * Equivalent to DAYS.convert(duration, this). - * @param duration the duration - * @return the converted duration - * @see #convert - */ - long toDays(long duration) { - throw new AbstractMethodError(); - } - - /** - * Utility to compute the excess-nanosecond argument to wait, - * sleep, join. - * @param d the duration - * @param m the number of milliseconds - * @return the number of nanoseconds - */ - abstract int excessNanos(long d, long m); - - /** - * Performs a timed Object.wait using this time unit. - * This is a convenience method that converts timeout arguments - * into the form required by the Object.wait method. - * - *

For example, you could implement a blocking poll - * method (see {@link BlockingQueue#poll BlockingQueue.poll}) - * using: - * - *

  public synchronized Object poll(long timeout, TimeUnit unit) throws InterruptedException {
-     *    while (empty) {
-     *      unit.timedWait(this, timeout);
-     *      ...
-     *    }
-     *  }
- * - * @param obj the object to wait on - * @param timeout the maximum time to wait. If less than - * or equal to zero, do not wait at all. - * @throws InterruptedException if interrupted while waiting. - * @see Object#wait(long, int) - */ - public void timedWait(Object obj, long timeout) - throws InterruptedException { - if (timeout > 0) { - long ms = toMillis(timeout); - int ns = excessNanos(timeout, ms); - obj.wait(ms, ns); - } - } - - /** - * Performs a timed Thread.join using this time unit. - * This is a convenience method that converts time arguments into the - * form required by the Thread.join method. - * @param thread the thread to wait for - * @param timeout the maximum time to wait. If less than - * or equal to zero, do not wait at all. - * @throws InterruptedException if interrupted while waiting. - * @see Thread#join(long, int) - */ - public void timedJoin(Thread thread, long timeout) - throws InterruptedException { - if (timeout > 0) { - long ms = toMillis(timeout); - int ns = excessNanos(timeout, ms); - thread.join(ms, ns); - } - } - - /** - * Performs a Thread.sleep using this unit. - * This is a convenience method that converts time arguments into the - * form required by the Thread.sleep method. - * @param timeout the minimum time to sleep. If less than - * or equal to zero, do not sleep at all. - * @throws InterruptedException if interrupted while sleeping. - * @see Thread#sleep - */ - public void sleep(long timeout) throws InterruptedException { - if (timeout > 0) { - long ms = toMillis(timeout); - int ns = excessNanos(timeout, ms); - Thread.sleep(ms, ns); - } - } - -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/TimeoutException.java b/libcore/concurrent/src/main/java/java/util/concurrent/TimeoutException.java deleted file mode 100644 index 8b84f28e5..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/TimeoutException.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent; - -/** - * Exception thrown when a blocking operation times out. Blocking - * operations for which a timeout is specified need a means to - * indicate that the timeout has occurred. For many such operations it - * is possible to return a value that indicates timeout; when that is - * not possible or desirable then TimeoutException should be - * declared and thrown. - * - * @since 1.5 - * @author Doug Lea - */ -public class TimeoutException extends Exception { - private static final long serialVersionUID = 1900926677490660714L; - - /** - * Constructs a TimeoutException with no specified detail - * message. - */ - public TimeoutException() {} - - /** - * Constructs a TimeoutException with the specified detail - * message. - * - * @param message the detail message - */ - public TimeoutException(String message) { - super(message); - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicBoolean.java b/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicBoolean.java deleted file mode 100644 index ba6055672..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicBoolean.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.atomic; -import sun.misc.Unsafe; - -/** - * A {@code boolean} value that may be updated atomically. See the - * {@link java.util.concurrent.atomic} package specification for - * description of the properties of atomic variables. An - * {@code AtomicBoolean} is used in applications such as atomically - * updated flags, and cannot be used as a replacement for a - * {@link java.lang.Boolean}. - * - * @since 1.5 - * @author Doug Lea - */ -public class AtomicBoolean implements java.io.Serializable { - private static final long serialVersionUID = 4654671469794556979L; - // setup to use Unsafe.compareAndSwapInt for updates - // BEGIN android-changed - private static final Unsafe unsafe = UnsafeAccess.THE_ONE; - // END android-changed - - private static final long valueOffset; - - static { - try { - valueOffset = unsafe.objectFieldOffset - (AtomicBoolean.class.getDeclaredField("value")); - } catch (Exception ex) { throw new Error(ex); } - } - - private volatile int value; - - /** - * Creates a new {@code AtomicBoolean} with the given initial value. - * - * @param initialValue the initial value - */ - public AtomicBoolean(boolean initialValue) { - value = initialValue ? 1 : 0; - } - - /** - * Creates a new {@code AtomicBoolean} with initial value {@code false}. - */ - public AtomicBoolean() { - } - - /** - * Returns the current value. - * - * @return the current value - */ - public final boolean get() { - return value != 0; - } - - /** - * Atomically sets the value to the given updated value - * if the current value {@code ==} the expected value. - * - * @param expect the expected value - * @param update the new value - * @return true if successful. False return indicates that - * the actual value was not equal to the expected value. - */ - public final boolean compareAndSet(boolean expect, boolean update) { - int e = expect ? 1 : 0; - int u = update ? 1 : 0; - return unsafe.compareAndSwapInt(this, valueOffset, e, u); - } - - /** - * Atomically sets the value to the given updated value - * if the current value {@code ==} the expected value. - * - *

May fail spuriously - * and does not provide ordering guarantees, so is only rarely an - * appropriate alternative to {@code compareAndSet}. - * - * @param expect the expected value - * @param update the new value - * @return true if successful. - */ - public boolean weakCompareAndSet(boolean expect, boolean update) { - int e = expect ? 1 : 0; - int u = update ? 1 : 0; - return unsafe.compareAndSwapInt(this, valueOffset, e, u); - } - - /** - * Unconditionally sets to the given value. - * - * @param newValue the new value - */ - public final void set(boolean newValue) { - value = newValue ? 1 : 0; - } - - /** - * Atomically sets to the given value and returns the previous value. - * - * @param newValue the new value - * @return the previous value - */ - public final boolean getAndSet(boolean newValue) { - for (;;) { - boolean current = get(); - if (compareAndSet(current, newValue)) - return current; - } - } - - /** - * Returns the String representation of the current value. - * @return the String representation of the current value. - */ - public String toString() { - return Boolean.toString(get()); - } - -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicInteger.java b/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicInteger.java deleted file mode 100644 index 1aa32f436..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicInteger.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.atomic; -import sun.misc.Unsafe; - -/** - * An {@code int} value that may be updated atomically. See the - * {@link java.util.concurrent.atomic} package specification for - * description of the properties of atomic variables. An - * {@code AtomicInteger} is used in applications such as atomically - * incremented counters, and cannot be used as a replacement for an - * {@link java.lang.Integer}. However, this class does extend - * {@code Number} to allow uniform access by tools and utilities that - * deal with numerically-based classes. - * - * @since 1.5 - * @author Doug Lea -*/ -public class AtomicInteger extends Number implements java.io.Serializable { - private static final long serialVersionUID = 6214790243416807050L; - - // setup to use Unsafe.compareAndSwapInt for updates - // BEGIN android-changed - private static final Unsafe unsafe = UnsafeAccess.THE_ONE; - // END android-changed - private static final long valueOffset; - - static { - try { - valueOffset = unsafe.objectFieldOffset - (AtomicInteger.class.getDeclaredField("value")); - } catch (Exception ex) { throw new Error(ex); } - } - - private volatile int value; - - /** - * Creates a new AtomicInteger with the given initial value. - * - * @param initialValue the initial value - */ - public AtomicInteger(int initialValue) { - value = initialValue; - } - - /** - * Creates a new AtomicInteger with initial value {@code 0}. - */ - public AtomicInteger() { - } - - /** - * Gets the current value. - * - * @return the current value - */ - public final int get() { - return value; - } - - /** - * Sets to the given value. - * - * @param newValue the new value - */ - public final void set(int newValue) { - value = newValue; - } - - /** - * Atomically sets to the given value and returns the old value. - * - * @param newValue the new value - * @return the previous value - */ - public final int getAndSet(int newValue) { - for (;;) { - int current = get(); - if (compareAndSet(current, newValue)) - return current; - } - } - - /** - * Atomically sets the value to the given updated value - * if the current value {@code ==} the expected value. - * - * @param expect the expected value - * @param update the new value - * @return true if successful. False return indicates that - * the actual value was not equal to the expected value. - */ - public final boolean compareAndSet(int expect, int update) { - return unsafe.compareAndSwapInt(this, valueOffset, expect, update); - } - - /** - * Atomically sets the value to the given updated value - * if the current value {@code ==} the expected value. - * - *

May fail spuriously - * and does not provide ordering guarantees, so is only rarely an - * appropriate alternative to {@code compareAndSet}. - * - * @param expect the expected value - * @param update the new value - * @return true if successful. - */ - public final boolean weakCompareAndSet(int expect, int update) { - return unsafe.compareAndSwapInt(this, valueOffset, expect, update); - } - - /** - * Atomically increments by one the current value. - * - * @return the previous value - */ - public final int getAndIncrement() { - for (;;) { - int current = get(); - int next = current + 1; - if (compareAndSet(current, next)) - return current; - } - } - - /** - * Atomically decrements by one the current value. - * - * @return the previous value - */ - public final int getAndDecrement() { - for (;;) { - int current = get(); - int next = current - 1; - if (compareAndSet(current, next)) - return current; - } - } - - /** - * Atomically adds the given value to the current value. - * - * @param delta the value to add - * @return the previous value - */ - public final int getAndAdd(int delta) { - for (;;) { - int current = get(); - int next = current + delta; - if (compareAndSet(current, next)) - return current; - } - } - - /** - * Atomically increments by one the current value. - * - * @return the updated value - */ - public final int incrementAndGet() { - for (;;) { - int current = get(); - int next = current + 1; - if (compareAndSet(current, next)) - return next; - } - } - - /** - * Atomically decrements by one the current value. - * - * @return the updated value - */ - public final int decrementAndGet() { - for (;;) { - int current = get(); - int next = current - 1; - if (compareAndSet(current, next)) - return next; - } - } - - /** - * Atomically adds the given value to the current value. - * - * @param delta the value to add - * @return the updated value - */ - public final int addAndGet(int delta) { - for (;;) { - int current = get(); - int next = current + delta; - if (compareAndSet(current, next)) - return next; - } - } - - /** - * Returns the String representation of the current value. - * @return the String representation of the current value. - */ - public String toString() { - return Integer.toString(get()); - } - - - public int intValue() { - return get(); - } - - public long longValue() { - return (long)get(); - } - - public float floatValue() { - return (float)get(); - } - - public double doubleValue() { - return (double)get(); - } - -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicIntegerArray.java b/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicIntegerArray.java deleted file mode 100644 index ee21b13ba..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicIntegerArray.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.atomic; -import sun.misc.Unsafe; -import java.util.*; - -/** - * An {@code int} array in which elements may be updated atomically. - * See the {@link java.util.concurrent.atomic} package - * specification for description of the properties of atomic - * variables. - * @since 1.5 - * @author Doug Lea - */ -public class AtomicIntegerArray implements java.io.Serializable { - private static final long serialVersionUID = 2862133569453604235L; - - // setup to use Unsafe.compareAndSwapInt for updates - // BEGIN android-changed - private static final Unsafe unsafe = UnsafeAccess.THE_ONE; - // END android-changed - private static final int base = unsafe.arrayBaseOffset(int[].class); - private static final int scale = unsafe.arrayIndexScale(int[].class); - private final int[] array; - - private long rawIndex(int i) { - if (i < 0 || i >= array.length) - throw new IndexOutOfBoundsException("index " + i); - return base + i * scale; - } - - /** - * Creates a new AtomicIntegerArray of given length. - * - * @param length the length of the array - */ - public AtomicIntegerArray(int length) { - array = new int[length]; - // must perform at least one volatile write to conform to JMM - if (length > 0) - unsafe.putIntVolatile(array, rawIndex(0), 0); - } - - /** - * Creates a new AtomicIntegerArray with the same length as, and - * all elements copied from, the given array. - * - * @param array the array to copy elements from - * @throws NullPointerException if array is null - */ - public AtomicIntegerArray(int[] array) { - if (array == null) - throw new NullPointerException(); - int length = array.length; - this.array = new int[length]; - if (length > 0) { - int last = length-1; - for (int i = 0; i < last; ++i) - this.array[i] = array[i]; - // Do the last write as volatile - unsafe.putIntVolatile(this.array, rawIndex(last), array[last]); - } - } - - /** - * Returns the length of the array. - * - * @return the length of the array - */ - public final int length() { - return array.length; - } - - /** - * Gets the current value at position {@code i}. - * - * @param i the index - * @return the current value - */ - public final int get(int i) { - return unsafe.getIntVolatile(array, rawIndex(i)); - } - - /** - * Sets the element at position {@code i} to the given value. - * - * @param i the index - * @param newValue the new value - */ - public final void set(int i, int newValue) { - unsafe.putIntVolatile(array, rawIndex(i), newValue); - } - - /** - * Atomically sets the element at position {@code i} to the given - * value and returns the old value. - * - * @param i the index - * @param newValue the new value - * @return the previous value - */ - public final int getAndSet(int i, int newValue) { - while (true) { - int current = get(i); - if (compareAndSet(i, current, newValue)) - return current; - } - } - - /** - * Atomically sets the element at position {@code i} to the given - * updated value if the current value {@code ==} the expected value. - * - * @param i the index - * @param expect the expected value - * @param update the new value - * @return true if successful. False return indicates that - * the actual value was not equal to the expected value. - */ - public final boolean compareAndSet(int i, int expect, int update) { - return unsafe.compareAndSwapInt(array, rawIndex(i), - expect, update); - } - - /** - * Atomically sets the element at position {@code i} to the given - * updated value if the current value {@code ==} the expected value. - * - *

May fail spuriously - * and does not provide ordering guarantees, so is only rarely an - * appropriate alternative to {@code compareAndSet}. - * - * @param i the index - * @param expect the expected value - * @param update the new value - * @return true if successful. - */ - public final boolean weakCompareAndSet(int i, int expect, int update) { - return compareAndSet(i, expect, update); - } - - /** - * Atomically increments by one the element at index {@code i}. - * - * @param i the index - * @return the previous value - */ - public final int getAndIncrement(int i) { - while (true) { - int current = get(i); - int next = current + 1; - if (compareAndSet(i, current, next)) - return current; - } - } - - /** - * Atomically decrements by one the element at index {@code i}. - * - * @param i the index - * @return the previous value - */ - public final int getAndDecrement(int i) { - while (true) { - int current = get(i); - int next = current - 1; - if (compareAndSet(i, current, next)) - return current; - } - } - - /** - * Atomically adds the given value to the element at index {@code i}. - * - * @param i the index - * @param delta the value to add - * @return the previous value - */ - public final int getAndAdd(int i, int delta) { - while (true) { - int current = get(i); - int next = current + delta; - if (compareAndSet(i, current, next)) - return current; - } - } - - /** - * Atomically increments by one the element at index {@code i}. - * - * @param i the index - * @return the updated value - */ - public final int incrementAndGet(int i) { - while (true) { - int current = get(i); - int next = current + 1; - if (compareAndSet(i, current, next)) - return next; - } - } - - /** - * Atomically decrements by one the element at index {@code i}. - * - * @param i the index - * @return the updated value - */ - public final int decrementAndGet(int i) { - while (true) { - int current = get(i); - int next = current - 1; - if (compareAndSet(i, current, next)) - return next; - } - } - - /** - * Atomically adds the given value to the element at index {@code i}. - * - * @param i the index - * @param delta the value to add - * @return the updated value - */ - public final int addAndGet(int i, int delta) { - while (true) { - int current = get(i); - int next = current + delta; - if (compareAndSet(i, current, next)) - return next; - } - } - - /** - * Returns the String representation of the current values of array. - * @return the String representation of the current values of array. - */ - public String toString() { - if (array.length > 0) // force volatile read - get(0); - return Arrays.toString(array); - } - -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java b/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java deleted file mode 100644 index f8d2c8199..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.atomic; -import sun.misc.Unsafe; -import java.lang.reflect.*; - -import org.apache.harmony.kernel.vm.VM; -import dalvik.system.VMStack; - -/** - * A reflection-based utility that enables atomic updates to - * designated {@code volatile int} fields of designated classes. - * This class is designed for use in atomic data structures in which - * several fields of the same node are independently subject to atomic - * updates. - * - *

Note that the guarantees of the {@code compareAndSet} - * method in this class are weaker than in other atomic classes. - * Because this class cannot ensure that all uses of the field - * are appropriate for purposes of atomic access, it can - * guarantee atomicity only with respect to other invocations of - * {@code compareAndSet} and {@code set} on the same updater. - * - * @since 1.5 - * @author Doug Lea - * @param The type of the object holding the updatable field - */ -public abstract class AtomicIntegerFieldUpdater { - /** - * Creates and returns an updater for objects with the given field. - * The Class argument is needed to check that reflective types and - * generic types match. - * - * @param tclass the class of the objects holding the field - * @param fieldName the name of the field to be updated - * @return the updater - * @throws IllegalArgumentException if the field is not a - * volatile integer type - * @throws RuntimeException with a nested reflection-based - * exception if the class does not hold field or is the wrong type - */ - public static AtomicIntegerFieldUpdater newUpdater(Class tclass, String fieldName) { - return new AtomicIntegerFieldUpdaterImpl(tclass, fieldName); - } - - /** - * Protected do-nothing constructor for use by subclasses. - */ - protected AtomicIntegerFieldUpdater() { - } - - /** - * Atomically sets the field of the given object managed by this updater - * to the given updated value if the current value {@code ==} the - * expected value. This method is guaranteed to be atomic with respect to - * other calls to {@code compareAndSet} and {@code set}, but not - * necessarily with respect to other changes in the field. - * - * @param obj An object whose field to conditionally set - * @param expect the expected value - * @param update the new value - * @return true if successful - * @throws ClassCastException if {@code obj} is not an instance - * of the class possessing the field established in the constructor - */ - public abstract boolean compareAndSet(T obj, int expect, int update); - - /** - * Atomically sets the field of the given object managed by this updater - * to the given updated value if the current value {@code ==} the - * expected value. This method is guaranteed to be atomic with respect to - * other calls to {@code compareAndSet} and {@code set}, but not - * necessarily with respect to other changes in the field. - * - *

May fail spuriously - * and does not provide ordering guarantees, so is only rarely an - * appropriate alternative to {@code compareAndSet}. - * - * @param obj An object whose field to conditionally set - * @param expect the expected value - * @param update the new value - * @return true if successful - * @throws ClassCastException if {@code obj} is not an instance - * of the class possessing the field established in the constructor - */ - public abstract boolean weakCompareAndSet(T obj, int expect, int update); - - /** - * Sets the field of the given object managed by this updater to the - * given updated value. This operation is guaranteed to act as a volatile - * store with respect to subsequent invocations of {@code compareAndSet}. - * - * @param obj An object whose field to set - * @param newValue the new value - */ - public abstract void set(T obj, int newValue); - - /** - * Gets the current value held in the field of the given object managed - * by this updater. - * - * @param obj An object whose field to get - * @return the current value - */ - public abstract int get(T obj); - - /** - * Atomically sets the field of the given object managed by this updater - * to the given value and returns the old value. - * - * @param obj An object whose field to get and set - * @param newValue the new value - * @return the previous value - */ - public int getAndSet(T obj, int newValue) { - for (;;) { - int current = get(obj); - if (compareAndSet(obj, current, newValue)) - return current; - } - } - - /** - * Atomically increments by one the current value of the field of the - * given object managed by this updater. - * - * @param obj An object whose field to get and set - * @return the previous value - */ - public int getAndIncrement(T obj) { - for (;;) { - int current = get(obj); - int next = current + 1; - if (compareAndSet(obj, current, next)) - return current; - } - } - - /** - * Atomically decrements by one the current value of the field of the - * given object managed by this updater. - * - * @param obj An object whose field to get and set - * @return the previous value - */ - public int getAndDecrement(T obj) { - for (;;) { - int current = get(obj); - int next = current - 1; - if (compareAndSet(obj, current, next)) - return current; - } - } - - /** - * Atomically adds the given value to the current value of the field of - * the given object managed by this updater. - * - * @param obj An object whose field to get and set - * @param delta the value to add - * @return the previous value - */ - public int getAndAdd(T obj, int delta) { - for (;;) { - int current = get(obj); - int next = current + delta; - if (compareAndSet(obj, current, next)) - return current; - } - } - - /** - * Atomically increments by one the current value of the field of the - * given object managed by this updater. - * - * @param obj An object whose field to get and set - * @return the updated value - */ - public int incrementAndGet(T obj) { - for (;;) { - int current = get(obj); - int next = current + 1; - if (compareAndSet(obj, current, next)) - return next; - } - } - - /** - * Atomically decrements by one the current value of the field of the - * given object managed by this updater. - * - * @param obj An object whose field to get and set - * @return the updated value - */ - public int decrementAndGet(T obj) { - for (;;) { - int current = get(obj); - int next = current - 1; - if (compareAndSet(obj, current, next)) - return next; - } - } - - /** - * Atomically adds the given value to the current value of the field of - * the given object managed by this updater. - * - * @param obj An object whose field to get and set - * @param delta the value to add - * @return the updated value - */ - public int addAndGet(T obj, int delta) { - for (;;) { - int current = get(obj); - int next = current + delta; - if (compareAndSet(obj, current, next)) - return next; - } - } - - /** - * Standard hotspot implementation using intrinsics - */ - private static class AtomicIntegerFieldUpdaterImpl extends AtomicIntegerFieldUpdater { - // BEGIN android-changed - private static final Unsafe unsafe = UnsafeAccess.THE_ONE; - // END android-changed - private final long offset; - private final Class tclass; - private final Class cclass; - - AtomicIntegerFieldUpdaterImpl(Class tclass, String fieldName) { - Field field = null; - Class caller = null; - int modifiers = 0; - try { - field = tclass.getDeclaredField(fieldName); - // BEGIN android-changed - caller = VMStack.getStackClass2(); - // END android-changed - modifiers = field.getModifiers(); - - SecurityManager smgr = System.getSecurityManager(); - if (smgr != null) { - int type = Modifier.isPublic(modifiers) - ? Member.PUBLIC : Member.DECLARED; - smgr.checkMemberAccess(tclass, type); - smgr.checkPackageAccess(tclass.getPackage().getName()); - } - } catch (Exception ex) { - throw new RuntimeException(ex); - } - - Class fieldt = field.getType(); - if (fieldt != int.class) - throw new IllegalArgumentException("Must be integer type"); - - if (!Modifier.isVolatile(modifiers)) - throw new IllegalArgumentException("Must be volatile type"); - - this.cclass = (Modifier.isProtected(modifiers) && - caller != tclass) ? caller : null; - this.tclass = tclass; - offset = unsafe.objectFieldOffset(field); - } - - private void fullCheck(T obj) { - if (!tclass.isInstance(obj)) - throw new ClassCastException(); - if (cclass != null) - ensureProtectedAccess(obj); - } - - public boolean compareAndSet(T obj, int expect, int update) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - return unsafe.compareAndSwapInt(obj, offset, expect, update); - } - - public boolean weakCompareAndSet(T obj, int expect, int update) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - return unsafe.compareAndSwapInt(obj, offset, expect, update); - } - - public void set(T obj, int newValue) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - unsafe.putIntVolatile(obj, offset, newValue); - } - - public final int get(T obj) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - return unsafe.getIntVolatile(obj, offset); - } - - private void ensureProtectedAccess(T obj) { - if (cclass.isInstance(obj)) { - return; - } - throw new RuntimeException( - new IllegalAccessException("Class " + - cclass.getName() + - " can not access a protected member of class " + - tclass.getName() + - " using an instance of " + - obj.getClass().getName() - ) - ); - } - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLong.java b/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLong.java deleted file mode 100644 index 9b5600228..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLong.java +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.atomic; -import sun.misc.Unsafe; - -/** - * A {@code long} value that may be updated atomically. See the - * {@link java.util.concurrent.atomic} package specification for - * description of the properties of atomic variables. An - * {@code AtomicLong} is used in applications such as atomically - * incremented sequence numbers, and cannot be used as a replacement - * for a {@link java.lang.Long}. However, this class does extend - * {@code Number} to allow uniform access by tools and utilities that - * deal with numerically-based classes. - * - * @since 1.5 - * @author Doug Lea - */ -public class AtomicLong extends Number implements java.io.Serializable { - private static final long serialVersionUID = 1927816293512124184L; - - // setup to use Unsafe.compareAndSwapLong for updates - // BEGIN android-changed - private static final Unsafe unsafe = UnsafeAccess.THE_ONE; - // END android-changed - private static final long valueOffset; - - /** - * Records whether the underlying JVM supports lockless - * compareAndSwap for longs. While the Unsafe.compareAndSwapLong - * method works in either case, some constructions should be - * handled at Java level to avoid locking user-visible locks. - * - * Initialised in the static block. - */ - static final boolean VM_SUPPORTS_LONG_CAS; - - /** - * Returns whether underlying JVM supports lockless CompareAndSet - * for longs. Called only once and cached in VM_SUPPORTS_LONG_CAS. - */ - private static native boolean VMSupportsCS8(); - - static { - try { - valueOffset = unsafe.objectFieldOffset - (AtomicLong.class.getDeclaredField("value")); - } catch (Exception ex) { throw new Error(ex); } - - boolean longCASSupport; - try { - longCASSupport = VMSupportsCS8(); - } catch (UnsatisfiedLinkError e) { - // assume there's support if the native isn't provided by the VM - longCASSupport = true; - } - VM_SUPPORTS_LONG_CAS = longCASSupport; - } - - private volatile long value; - - /** - * Creates a new AtomicLong with the given initial value. - * - * @param initialValue the initial value - */ - public AtomicLong(long initialValue) { - value = initialValue; - } - - /** - * Creates a new AtomicLong with initial value {@code 0}. - */ - public AtomicLong() { - } - - /** - * Gets the current value. - * - * @return the current value - */ - public final long get() { - return value; - } - - /** - * Sets to the given value. - * - * @param newValue the new value - */ - public final void set(long newValue) { - value = newValue; - } - - /** - * Atomically sets to the given value and returns the old value. - * - * @param newValue the new value - * @return the previous value - */ - public final long getAndSet(long newValue) { - while (true) { - long current = get(); - if (compareAndSet(current, newValue)) - return current; - } - } - - /** - * Atomically sets the value to the given updated value - * if the current value {@code ==} the expected value. - * - * @param expect the expected value - * @param update the new value - * @return true if successful. False return indicates that - * the actual value was not equal to the expected value. - */ - public final boolean compareAndSet(long expect, long update) { - return unsafe.compareAndSwapLong(this, valueOffset, expect, update); - } - - /** - * Atomically sets the value to the given updated value - * if the current value {@code ==} the expected value. - * - *

May fail spuriously - * and does not provide ordering guarantees, so is only rarely an - * appropriate alternative to {@code compareAndSet}. - * - * @param expect the expected value - * @param update the new value - * @return true if successful. - */ - public final boolean weakCompareAndSet(long expect, long update) { - return unsafe.compareAndSwapLong(this, valueOffset, expect, update); - } - - /** - * Atomically increments by one the current value. - * - * @return the previous value - */ - public final long getAndIncrement() { - while (true) { - long current = get(); - long next = current + 1; - if (compareAndSet(current, next)) - return current; - } - } - - /** - * Atomically decrements by one the current value. - * - * @return the previous value - */ - public final long getAndDecrement() { - while (true) { - long current = get(); - long next = current - 1; - if (compareAndSet(current, next)) - return current; - } - } - - /** - * Atomically adds the given value to the current value. - * - * @param delta the value to add - * @return the previous value - */ - public final long getAndAdd(long delta) { - while (true) { - long current = get(); - long next = current + delta; - if (compareAndSet(current, next)) - return current; - } - } - - /** - * Atomically increments by one the current value. - * - * @return the updated value - */ - public final long incrementAndGet() { - for (;;) { - long current = get(); - long next = current + 1; - if (compareAndSet(current, next)) - return next; - } - } - - /** - * Atomically decrements by one the current value. - * - * @return the updated value - */ - public final long decrementAndGet() { - for (;;) { - long current = get(); - long next = current - 1; - if (compareAndSet(current, next)) - return next; - } - } - - /** - * Atomically adds the given value to the current value. - * - * @param delta the value to add - * @return the updated value - */ - public final long addAndGet(long delta) { - for (;;) { - long current = get(); - long next = current + delta; - if (compareAndSet(current, next)) - return next; - } - } - - /** - * Returns the String representation of the current value. - * @return the String representation of the current value. - */ - public String toString() { - return Long.toString(get()); - } - - - public int intValue() { - return (int)get(); - } - - public long longValue() { - return get(); - } - - public float floatValue() { - return (float)get(); - } - - public double doubleValue() { - return (double)get(); - } - -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLongArray.java b/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLongArray.java deleted file mode 100644 index d96f4c27a..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLongArray.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.atomic; -import sun.misc.Unsafe; -import java.util.*; - -/** - * A {@code long} array in which elements may be updated atomically. - * See the {@link java.util.concurrent.atomic} package specification - * for description of the properties of atomic variables. - * @since 1.5 - * @author Doug Lea - */ -public class AtomicLongArray implements java.io.Serializable { - private static final long serialVersionUID = -2308431214976778248L; - - // setup to use Unsafe.compareAndSwapInt for updates - // BEGIN android-changed - private static final Unsafe unsafe = UnsafeAccess.THE_ONE; - // END android-changed - private static final int base = unsafe.arrayBaseOffset(long[].class); - private static final int scale = unsafe.arrayIndexScale(long[].class); - private final long[] array; - - private long rawIndex(int i) { - if (i < 0 || i >= array.length) - throw new IndexOutOfBoundsException("index " + i); - return base + i * scale; - } - - /** - * Creates a new AtomicLongArray of given length. - * - * @param length the length of the array - */ - public AtomicLongArray(int length) { - array = new long[length]; - // must perform at least one volatile write to conform to JMM - if (length > 0) - unsafe.putLongVolatile(array, rawIndex(0), 0); - } - - /** - * Creates a new AtomicLongArray with the same length as, and - * all elements copied from, the given array. - * - * @param array the array to copy elements from - * @throws NullPointerException if array is null - */ - public AtomicLongArray(long[] array) { - if (array == null) - throw new NullPointerException(); - int length = array.length; - this.array = new long[length]; - if (length > 0) { - int last = length-1; - for (int i = 0; i < last; ++i) - this.array[i] = array[i]; - // Do the last write as volatile - unsafe.putLongVolatile(this.array, rawIndex(last), array[last]); - } - } - - /** - * Returns the length of the array. - * - * @return the length of the array - */ - public final int length() { - return array.length; - } - - /** - * Gets the current value at position {@code i}. - * - * @param i the index - * @return the current value - */ - public final long get(int i) { - return unsafe.getLongVolatile(array, rawIndex(i)); - } - - /** - * Sets the element at position {@code i} to the given value. - * - * @param i the index - * @param newValue the new value - */ - public final void set(int i, long newValue) { - unsafe.putLongVolatile(array, rawIndex(i), newValue); - } - - /** - * Atomically sets the element at position {@code i} to the given value - * and returns the old value. - * - * @param i the index - * @param newValue the new value - * @return the previous value - */ - public final long getAndSet(int i, long newValue) { - while (true) { - long current = get(i); - if (compareAndSet(i, current, newValue)) - return current; - } - } - - /** - * Atomically sets the value to the given updated value - * if the current value {@code ==} the expected value. - * - * @param i the index - * @param expect the expected value - * @param update the new value - * @return true if successful. False return indicates that - * the actual value was not equal to the expected value. - */ - public final boolean compareAndSet(int i, long expect, long update) { - return unsafe.compareAndSwapLong(array, rawIndex(i), - expect, update); - } - - /** - * Atomically sets the value to the given updated value - * if the current value {@code ==} the expected value. - * - *

May fail spuriously - * and does not provide ordering guarantees, so is only rarely an - * appropriate alternative to {@code compareAndSet}. - * - * @param i the index - * @param expect the expected value - * @param update the new value - * @return true if successful. - */ - public final boolean weakCompareAndSet(int i, long expect, long update) { - return compareAndSet(i, expect, update); - } - - /** - * Atomically increments by one the element at index {@code i}. - * - * @param i the index - * @return the previous value - */ - public final long getAndIncrement(int i) { - while (true) { - long current = get(i); - long next = current + 1; - if (compareAndSet(i, current, next)) - return current; - } - } - - /** - * Atomically decrements by one the element at index {@code i}. - * - * @param i the index - * @return the previous value - */ - public final long getAndDecrement(int i) { - while (true) { - long current = get(i); - long next = current - 1; - if (compareAndSet(i, current, next)) - return current; - } - } - - /** - * Atomically adds the given value to the element at index {@code i}. - * - * @param i the index - * @param delta the value to add - * @return the previous value - */ - public final long getAndAdd(int i, long delta) { - while (true) { - long current = get(i); - long next = current + delta; - if (compareAndSet(i, current, next)) - return current; - } - } - - /** - * Atomically increments by one the element at index {@code i}. - * - * @param i the index - * @return the updated value - */ - public final long incrementAndGet(int i) { - while (true) { - long current = get(i); - long next = current + 1; - if (compareAndSet(i, current, next)) - return next; - } - } - - /** - * Atomically decrements by one the element at index {@code i}. - * - * @param i the index - * @return the updated value - */ - public final long decrementAndGet(int i) { - while (true) { - long current = get(i); - long next = current - 1; - if (compareAndSet(i, current, next)) - return next; - } - } - - /** - * Atomically adds the given value to the element at index {@code i}. - * - * @param i the index - * @param delta the value to add - * @return the updated value - */ - public long addAndGet(int i, long delta) { - while (true) { - long current = get(i); - long next = current + delta; - if (compareAndSet(i, current, next)) - return next; - } - } - - /** - * Returns the String representation of the current values of array. - * @return the String representation of the current values of array. - */ - public String toString() { - if (array.length > 0) // force volatile read - get(0); - return Arrays.toString(array); - } - -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLongFieldUpdater.java b/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLongFieldUpdater.java deleted file mode 100644 index d97c2e47b..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicLongFieldUpdater.java +++ /dev/null @@ -1,411 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.atomic; -import sun.misc.Unsafe; -import java.lang.reflect.*; - -import org.apache.harmony.kernel.vm.VM; -import dalvik.system.VMStack; - -/** - * A reflection-based utility that enables atomic updates to - * designated {@code volatile long} fields of designated classes. - * This class is designed for use in atomic data structures in which - * several fields of the same node are independently subject to atomic - * updates. - * - *

Note that the guarantees of the {@code compareAndSet} - * method in this class are weaker than in other atomic classes. - * Because this class cannot ensure that all uses of the field - * are appropriate for purposes of atomic access, it can - * guarantee atomicity only with respect to other invocations of - * {@code compareAndSet} and {@code set} on the same updater. - * - * @since 1.5 - * @author Doug Lea - * @param The type of the object holding the updatable field - */ -public abstract class AtomicLongFieldUpdater { - /** - * Creates and returns an updater for objects with the given field. - * The Class argument is needed to check that reflective types and - * generic types match. - * - * @param tclass the class of the objects holding the field - * @param fieldName the name of the field to be updated. - * @return the updater - * @throws IllegalArgumentException if the field is not a - * volatile long type. - * @throws RuntimeException with a nested reflection-based - * exception if the class does not hold field or is the wrong type. - */ - public static AtomicLongFieldUpdater newUpdater(Class tclass, String fieldName) { - if (AtomicLong.VM_SUPPORTS_LONG_CAS) - return new CASUpdater(tclass, fieldName); - else - return new LockedUpdater(tclass, fieldName); - } - - /** - * Protected do-nothing constructor for use by subclasses. - */ - protected AtomicLongFieldUpdater() { - } - - /** - * Atomically sets the field of the given object managed by this updater - * to the given updated value if the current value {@code ==} the - * expected value. This method is guaranteed to be atomic with respect to - * other calls to {@code compareAndSet} and {@code set}, but not - * necessarily with respect to other changes in the field. - * - * @param obj An object whose field to conditionally set - * @param expect the expected value - * @param update the new value - * @return true if successful. - * @throws ClassCastException if {@code obj} is not an instance - * of the class possessing the field established in the constructor. - */ - public abstract boolean compareAndSet(T obj, long expect, long update); - - /** - * Atomically sets the field of the given object managed by this updater - * to the given updated value if the current value {@code ==} the - * expected value. This method is guaranteed to be atomic with respect to - * other calls to {@code compareAndSet} and {@code set}, but not - * necessarily with respect to other changes in the field. - * - *

May fail spuriously - * and does not provide ordering guarantees, so is only rarely an - * appropriate alternative to {@code compareAndSet}. - * - * @param obj An object whose field to conditionally set - * @param expect the expected value - * @param update the new value - * @return true if successful. - * @throws ClassCastException if {@code obj} is not an instance - * of the class possessing the field established in the constructor. - */ - public abstract boolean weakCompareAndSet(T obj, long expect, long update); - - /** - * Sets the field of the given object managed by this updater to the - * given updated value. This operation is guaranteed to act as a volatile - * store with respect to subsequent invocations of {@code compareAndSet}. - * - * @param obj An object whose field to set - * @param newValue the new value - */ - public abstract void set(T obj, long newValue); - - /** - * Gets the current value held in the field of the given object managed - * by this updater. - * - * @param obj An object whose field to get - * @return the current value - */ - public abstract long get(T obj); - - /** - * Atomically sets the field of the given object managed by this updater - * to the given value and returns the old value. - * - * @param obj An object whose field to get and set - * @param newValue the new value - * @return the previous value - */ - public long getAndSet(T obj, long newValue) { - for (;;) { - long current = get(obj); - if (compareAndSet(obj, current, newValue)) - return current; - } - } - - /** - * Atomically increments by one the current value of the field of the - * given object managed by this updater. - * - * @param obj An object whose field to get and set - * @return the previous value - */ - public long getAndIncrement(T obj) { - for (;;) { - long current = get(obj); - long next = current + 1; - if (compareAndSet(obj, current, next)) - return current; - } - } - - /** - * Atomically decrements by one the current value of the field of the - * given object managed by this updater. - * - * @param obj An object whose field to get and set - * @return the previous value - */ - public long getAndDecrement(T obj) { - for (;;) { - long current = get(obj); - long next = current - 1; - if (compareAndSet(obj, current, next)) - return current; - } - } - - /** - * Atomically adds the given value to the current value of the field of - * the given object managed by this updater. - * - * @param obj An object whose field to get and set - * @param delta the value to add - * @return the previous value - */ - public long getAndAdd(T obj, long delta) { - for (;;) { - long current = get(obj); - long next = current + delta; - if (compareAndSet(obj, current, next)) - return current; - } - } - - /** - * Atomically increments by one the current value of the field of the - * given object managed by this updater. - * - * @param obj An object whose field to get and set - * @return the updated value - */ - public long incrementAndGet(T obj) { - for (;;) { - long current = get(obj); - long next = current + 1; - if (compareAndSet(obj, current, next)) - return next; - } - } - - /** - * Atomically decrements by one the current value of the field of the - * given object managed by this updater. - * - * @param obj An object whose field to get and set - * @return the updated value - */ - public long decrementAndGet(T obj) { - for (;;) { - long current = get(obj); - long next = current - 1; - if (compareAndSet(obj, current, next)) - return next; - } - } - - /** - * Atomically adds the given value to the current value of the field of - * the given object managed by this updater. - * - * @param obj An object whose field to get and set - * @param delta the value to add - * @return the updated value - */ - public long addAndGet(T obj, long delta) { - for (;;) { - long current = get(obj); - long next = current + delta; - if (compareAndSet(obj, current, next)) - return next; - } - } - - private static class CASUpdater extends AtomicLongFieldUpdater { - // BEGIN android-changed - private static final Unsafe unsafe = UnsafeAccess.THE_ONE; - // END android-changed - private final long offset; - private final Class tclass; - private final Class cclass; - - CASUpdater(Class tclass, String fieldName) { - Field field = null; - Class caller = null; - int modifiers = 0; - try { - field = tclass.getDeclaredField(fieldName); - // BEGIN android-changed - caller = VMStack.getStackClass2(); - // END android-changed - modifiers = field.getModifiers(); - SecurityManager smgr = System.getSecurityManager(); - if (smgr != null) { - int type = Modifier.isPublic(modifiers) - ? Member.PUBLIC : Member.DECLARED; - smgr.checkMemberAccess(tclass, type); - smgr.checkPackageAccess(tclass.getPackage().getName()); - } - } catch (Exception ex) { - throw new RuntimeException(ex); - } - - Class fieldt = field.getType(); - if (fieldt != long.class) - throw new IllegalArgumentException("Must be long type"); - - if (!Modifier.isVolatile(modifiers)) - throw new IllegalArgumentException("Must be volatile type"); - - this.cclass = (Modifier.isProtected(modifiers) && - caller != tclass) ? caller : null; - this.tclass = tclass; - offset = unsafe.objectFieldOffset(field); - } - - private void fullCheck(T obj) { - if (!tclass.isInstance(obj)) - throw new ClassCastException(); - if (cclass != null) - ensureProtectedAccess(obj); - } - - public boolean compareAndSet(T obj, long expect, long update) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - return unsafe.compareAndSwapLong(obj, offset, expect, update); - } - - public boolean weakCompareAndSet(T obj, long expect, long update) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - return unsafe.compareAndSwapLong(obj, offset, expect, update); - } - - public void set(T obj, long newValue) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - unsafe.putLongVolatile(obj, offset, newValue); - } - - public long get(T obj) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - return unsafe.getLongVolatile(obj, offset); - } - - private void ensureProtectedAccess(T obj) { - if (cclass.isInstance(obj)) { - return; - } - throw new RuntimeException ( - new IllegalAccessException("Class " + - cclass.getName() + - " can not access a protected member of class " + - tclass.getName() + - " using an instance of " + - obj.getClass().getName() - ) - ); - } - } - - - private static class LockedUpdater extends AtomicLongFieldUpdater { - // BEGIN android-changed - private static final Unsafe unsafe = UnsafeAccess.THE_ONE; - // END android-changed - private final long offset; - private final Class tclass; - private final Class cclass; - - LockedUpdater(Class tclass, String fieldName) { - Field field = null; - Class caller = null; - int modifiers = 0; - try { - field = tclass.getDeclaredField(fieldName); - // BEGIN android-changed - caller = VMStack.getStackClass2(); - // END android-changed - modifiers = field.getModifiers(); - SecurityManager smgr = System.getSecurityManager(); - if (smgr != null) { - int type = Modifier.isPublic(modifiers) - ? Member.PUBLIC : Member.DECLARED; - smgr.checkMemberAccess(tclass, type); - smgr.checkPackageAccess(tclass.getPackage().getName()); - } - } catch (Exception ex) { - throw new RuntimeException(ex); - } - - Class fieldt = field.getType(); - if (fieldt != long.class) - throw new IllegalArgumentException("Must be long type"); - - if (!Modifier.isVolatile(modifiers)) - throw new IllegalArgumentException("Must be volatile type"); - - this.cclass = (Modifier.isProtected(modifiers) && - caller != tclass) ? caller : null; - this.tclass = tclass; - offset = unsafe.objectFieldOffset(field); - } - - private void fullCheck(T obj) { - if (!tclass.isInstance(obj)) - throw new ClassCastException(); - if (cclass != null) - ensureProtectedAccess(obj); - } - - public boolean compareAndSet(T obj, long expect, long update) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - synchronized(this) { - long v = unsafe.getLong(obj, offset); - if (v != expect) - return false; - unsafe.putLong(obj, offset, update); - return true; - } - } - - public boolean weakCompareAndSet(T obj, long expect, long update) { - return compareAndSet(obj, expect, update); - } - - public void set(T obj, long newValue) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - synchronized(this) { - unsafe.putLong(obj, offset, newValue); - } - } - - public void lazySet(T obj, long newValue) { - set(obj, newValue); - } - - public long get(T obj) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - synchronized(this) { - return unsafe.getLong(obj, offset); - } - } - - private void ensureProtectedAccess(T obj) { - if (cclass.isInstance(obj)) { - return; - } - throw new RuntimeException ( - new IllegalAccessException("Class " + - cclass.getName() + - " can not access a protected member of class " + - tclass.getName() + - " using an instance of " + - obj.getClass().getName() - ) - ); - } - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicMarkableReference.java b/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicMarkableReference.java deleted file mode 100644 index 4877dc49c..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicMarkableReference.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.atomic; - -/** - * An {@code AtomicMarkableReference} maintains an object reference - * along with a mark bit, that can be updated atomically. - *

- *

Implementation note. This implementation maintains markable - * references by creating internal objects representing "boxed" - * [reference, boolean] pairs. - * - * @since 1.5 - * @author Doug Lea - * @param The type of object referred to by this reference - */ -public class AtomicMarkableReference { - - private static class ReferenceBooleanPair { - private final T reference; - private final boolean bit; - ReferenceBooleanPair(T r, boolean i) { - reference = r; bit = i; - } - } - - private final AtomicReference> atomicRef; - - /** - * Creates a new {@code AtomicMarkableReference} with the given - * initial values. - * - * @param initialRef the initial reference - * @param initialMark the initial mark - */ - public AtomicMarkableReference(V initialRef, boolean initialMark) { - atomicRef = new AtomicReference> (new ReferenceBooleanPair(initialRef, initialMark)); - } - - /** - * Returns the current value of the reference. - * - * @return the current value of the reference - */ - public V getReference() { - return atomicRef.get().reference; - } - - /** - * Returns the current value of the mark. - * - * @return the current value of the mark - */ - public boolean isMarked() { - return atomicRef.get().bit; - } - - /** - * Returns the current values of both the reference and the mark. - * Typical usage is {@code boolean[1] holder; ref = v.get(holder); }. - * - * @param markHolder an array of size of at least one. On return, - * {@code markholder[0]} will hold the value of the mark. - * @return the current value of the reference - */ - public V get(boolean[] markHolder) { - ReferenceBooleanPair p = atomicRef.get(); - markHolder[0] = p.bit; - return p.reference; - } - - /** - * Atomically sets the value of both the reference and mark - * to the given update values if the - * current reference is {@code ==} to the expected reference - * and the current mark is equal to the expected mark. - * - *

May fail spuriously - * and does not provide ordering guarantees, so is only rarely an - * appropriate alternative to {@code compareAndSet}. - * - * @param expectedReference the expected value of the reference - * @param newReference the new value for the reference - * @param expectedMark the expected value of the mark - * @param newMark the new value for the mark - * @return true if successful - */ - public boolean weakCompareAndSet(V expectedReference, - V newReference, - boolean expectedMark, - boolean newMark) { - ReferenceBooleanPair current = atomicRef.get(); - return expectedReference == current.reference && - expectedMark == current.bit && - ((newReference == current.reference && newMark == current.bit) || - atomicRef.weakCompareAndSet(current, - new ReferenceBooleanPair(newReference, - newMark))); - } - - /** - * Atomically sets the value of both the reference and mark - * to the given update values if the - * current reference is {@code ==} to the expected reference - * and the current mark is equal to the expected mark. - * - * @param expectedReference the expected value of the reference - * @param newReference the new value for the reference - * @param expectedMark the expected value of the mark - * @param newMark the new value for the mark - * @return true if successful - */ - public boolean compareAndSet(V expectedReference, - V newReference, - boolean expectedMark, - boolean newMark) { - ReferenceBooleanPair current = atomicRef.get(); - return expectedReference == current.reference && - expectedMark == current.bit && - ((newReference == current.reference && newMark == current.bit) || - atomicRef.compareAndSet(current, - new ReferenceBooleanPair(newReference, - newMark))); - } - - /** - * Unconditionally sets the value of both the reference and mark. - * - * @param newReference the new value for the reference - * @param newMark the new value for the mark - */ - public void set(V newReference, boolean newMark) { - ReferenceBooleanPair current = atomicRef.get(); - if (newReference != current.reference || newMark != current.bit) - atomicRef.set(new ReferenceBooleanPair(newReference, newMark)); - } - - /** - * Atomically sets the value of the mark to the given update value - * if the current reference is {@code ==} to the expected - * reference. Any given invocation of this operation may fail - * (return {@code false}) spuriously, but repeated invocation - * when the current value holds the expected value and no other - * thread is also attempting to set the value will eventually - * succeed. - * - * @param expectedReference the expected value of the reference - * @param newMark the new value for the mark - * @return true if successful - */ - public boolean attemptMark(V expectedReference, boolean newMark) { - ReferenceBooleanPair current = atomicRef.get(); - return expectedReference == current.reference && - (newMark == current.bit || - atomicRef.compareAndSet - (current, new ReferenceBooleanPair(expectedReference, - newMark))); - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReference.java b/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReference.java deleted file mode 100644 index 1de9b1ccd..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReference.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.atomic; -import sun.misc.Unsafe; - -/** - * An object reference that may be updated atomically. See the {@link - * java.util.concurrent.atomic} package specification for description - * of the properties of atomic variables. - * @since 1.5 - * @author Doug Lea - * @param The type of object referred to by this reference - */ -public class AtomicReference implements java.io.Serializable { - private static final long serialVersionUID = -1848883965231344442L; - - // BEGIN android-changed - private static final Unsafe unsafe = UnsafeAccess.THE_ONE; - // END android-changed - private static final long valueOffset; - - static { - try { - valueOffset = unsafe.objectFieldOffset - (AtomicReference.class.getDeclaredField("value")); - } catch (Exception ex) { throw new Error(ex); } - } - - private volatile V value; - - /** - * Creates a new AtomicReference with the given initial value. - * - * @param initialValue the initial value - */ - public AtomicReference(V initialValue) { - value = initialValue; - } - - /** - * Creates a new AtomicReference with null initial value. - */ - public AtomicReference() { - } - - /** - * Gets the current value. - * - * @return the current value - */ - public final V get() { - return value; - } - - /** - * Sets to the given value. - * - * @param newValue the new value - */ - public final void set(V newValue) { - value = newValue; - } - - /** - * Atomically sets the value to the given updated value - * if the current value {@code ==} the expected value. - * @param expect the expected value - * @param update the new value - * @return true if successful. False return indicates that - * the actual value was not equal to the expected value. - */ - public final boolean compareAndSet(V expect, V update) { - return unsafe.compareAndSwapObject(this, valueOffset, expect, update); - } - - /** - * Atomically sets the value to the given updated value - * if the current value {@code ==} the expected value. - * - *

May fail spuriously - * and does not provide ordering guarantees, so is only rarely an - * appropriate alternative to {@code compareAndSet}. - * - * @param expect the expected value - * @param update the new value - * @return true if successful. - */ - public final boolean weakCompareAndSet(V expect, V update) { - return unsafe.compareAndSwapObject(this, valueOffset, expect, update); - } - - /** - * Atomically sets to the given value and returns the old value. - * - * @param newValue the new value - * @return the previous value - */ - public final V getAndSet(V newValue) { - while (true) { - V x = get(); - if (compareAndSet(x, newValue)) - return x; - } - } - - /** - * Returns the String representation of the current value. - * @return the String representation of the current value. - */ - public String toString() { - return String.valueOf(get()); - } - -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReferenceArray.java b/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReferenceArray.java deleted file mode 100644 index 9a484e614..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReferenceArray.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.atomic; -import sun.misc.Unsafe; -import java.util.*; - -/** - * An array of object references in which elements may be updated - * atomically. See the {@link java.util.concurrent.atomic} package - * specification for description of the properties of atomic - * variables. - * @since 1.5 - * @author Doug Lea - * @param The base class of elements held in this array - */ -public class AtomicReferenceArray implements java.io.Serializable { - private static final long serialVersionUID = -6209656149925076980L; - - // BEGIN android-changed - private static final Unsafe unsafe = UnsafeAccess.THE_ONE; - // END android-changed - private static final int base = unsafe.arrayBaseOffset(Object[].class); - private static final int scale = unsafe.arrayIndexScale(Object[].class); - private final Object[] array; - - private long rawIndex(int i) { - if (i < 0 || i >= array.length) - throw new IndexOutOfBoundsException("index " + i); - return base + i * scale; - } - - /** - * Creates a new AtomicReferenceArray of given length. - * @param length the length of the array - */ - public AtomicReferenceArray(int length) { - array = new Object[length]; - // must perform at least one volatile write to conform to JMM - if (length > 0) - unsafe.putObjectVolatile(array, rawIndex(0), null); - } - - /** - * Creates a new AtomicReferenceArray with the same length as, and - * all elements copied from, the given array. - * - * @param array the array to copy elements from - * @throws NullPointerException if array is null - */ - public AtomicReferenceArray(E[] array) { - if (array == null) - throw new NullPointerException(); - int length = array.length; - this.array = new Object[length]; - if (length > 0) { - int last = length-1; - for (int i = 0; i < last; ++i) - this.array[i] = array[i]; - // Do the last write as volatile - E e = array[last]; - unsafe.putObjectVolatile(this.array, rawIndex(last), e); - } - } - - /** - * Returns the length of the array. - * - * @return the length of the array - */ - public final int length() { - return array.length; - } - - /** - * Gets the current value at position {@code i}. - * - * @param i the index - * @return the current value - */ - public final E get(int i) { - return (E) unsafe.getObjectVolatile(array, rawIndex(i)); - } - - /** - * Sets the element at position {@code i} to the given value. - * - * @param i the index - * @param newValue the new value - */ - public final void set(int i, E newValue) { - unsafe.putObjectVolatile(array, rawIndex(i), newValue); - } - - /** - * Atomically sets the element at position {@code i} to the given - * value and returns the old value. - * - * @param i the index - * @param newValue the new value - * @return the previous value - */ - public final E getAndSet(int i, E newValue) { - while (true) { - E current = get(i); - if (compareAndSet(i, current, newValue)) - return current; - } - } - - /** - * Atomically sets the element at position {@code i} to the given - * updated value if the current value {@code ==} the expected value. - * @param i the index - * @param expect the expected value - * @param update the new value - * @return true if successful. False return indicates that - * the actual value was not equal to the expected value. - */ - public final boolean compareAndSet(int i, E expect, E update) { - return unsafe.compareAndSwapObject(array, rawIndex(i), - expect, update); - } - - /** - * Atomically sets the element at position {@code i} to the given - * updated value if the current value {@code ==} the expected value. - * - *

May fail spuriously - * and does not provide ordering guarantees, so is only rarely an - * appropriate alternative to {@code compareAndSet}. - * - * @param i the index - * @param expect the expected value - * @param update the new value - * @return true if successful. - */ - public final boolean weakCompareAndSet(int i, E expect, E update) { - return compareAndSet(i, expect, update); - } - - /** - * Returns the String representation of the current values of array. - * @return the String representation of the current values of array. - */ - public String toString() { - if (array.length > 0) // force volatile read - get(0); - return Arrays.toString(array); - } - -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java b/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java deleted file mode 100644 index fae134f96..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.atomic; -import sun.misc.Unsafe; -import java.lang.reflect.*; - -import org.apache.harmony.kernel.vm.VM; -import dalvik.system.VMStack; - -/** - * A reflection-based utility that enables atomic updates to - * designated {@code volatile} reference fields of designated - * classes. This class is designed for use in atomic data structures - * in which several reference fields of the same node are - * independently subject to atomic updates. For example, a tree node - * might be declared as - * - *

- * class Node {
- *   private volatile Node left, right;
- *
- *   private static final AtomicReferenceFieldUpdater<Node, Node> leftUpdater =
- *     AtomicReferenceFieldUpdater.newUpdater(Node.class, Node.class, "left");
- *   private static AtomicReferenceFieldUpdater<Node, Node> rightUpdater =
- *     AtomicReferenceFieldUpdater.newUpdater(Node.class, Node.class, "right");
- *
- *   Node getLeft() { return left;  }
- *   boolean compareAndSetLeft(Node expect, Node update) {
- *     return leftUpdater.compareAndSet(this, expect, update);
- *   }
- *   // ... and so on
- * }
- * 
- * - *

Note that the guarantees of the {@code compareAndSet} - * method in this class are weaker than in other atomic classes. - * Because this class cannot ensure that all uses of the field - * are appropriate for purposes of atomic access, it can - * guarantee atomicity only with respect to other invocations of - * {@code compareAndSet} and {@code set} on the same updater. - * - * @since 1.5 - * @author Doug Lea - * @param The type of the object holding the updatable field - * @param The type of the field - */ -public abstract class AtomicReferenceFieldUpdater { - - /** - * Creates and returns an updater for objects with the given field. - * The Class arguments are needed to check that reflective types and - * generic types match. - * - * @param tclass the class of the objects holding the field. - * @param vclass the class of the field - * @param fieldName the name of the field to be updated. - * @return the updater - * @throws IllegalArgumentException if the field is not a volatile reference type. - * @throws RuntimeException with a nested reflection-based - * exception if the class does not hold field or is the wrong type. - */ - public static AtomicReferenceFieldUpdater newUpdater(Class tclass, Class vclass, String fieldName) { - return new AtomicReferenceFieldUpdaterImpl(tclass, - vclass, - fieldName); - } - - /** - * Protected do-nothing constructor for use by subclasses. - */ - protected AtomicReferenceFieldUpdater() { - } - - /** - * Atomically sets the field of the given object managed by this updater - * to the given updated value if the current value {@code ==} the - * expected value. This method is guaranteed to be atomic with respect to - * other calls to {@code compareAndSet} and {@code set}, but not - * necessarily with respect to other changes in the field. - * - * @param obj An object whose field to conditionally set - * @param expect the expected value - * @param update the new value - * @return true if successful. - */ - public abstract boolean compareAndSet(T obj, V expect, V update); - - /** - * Atomically sets the field of the given object managed by this updater - * to the given updated value if the current value {@code ==} the - * expected value. This method is guaranteed to be atomic with respect to - * other calls to {@code compareAndSet} and {@code set}, but not - * necessarily with respect to other changes in the field. - * - *

May fail spuriously - * and does not provide ordering guarantees, so is only rarely an - * appropriate alternative to {@code compareAndSet}. - * - * @param obj An object whose field to conditionally set - * @param expect the expected value - * @param update the new value - * @return true if successful. - */ - public abstract boolean weakCompareAndSet(T obj, V expect, V update); - - /** - * Sets the field of the given object managed by this updater to the - * given updated value. This operation is guaranteed to act as a volatile - * store with respect to subsequent invocations of {@code compareAndSet}. - * - * @param obj An object whose field to set - * @param newValue the new value - */ - public abstract void set(T obj, V newValue); - - /** - * Gets the current value held in the field of the given object managed - * by this updater. - * - * @param obj An object whose field to get - * @return the current value - */ - public abstract V get(T obj); - - /** - * Atomically sets the field of the given object managed by this updater - * to the given value and returns the old value. - * - * @param obj An object whose field to get and set - * @param newValue the new value - * @return the previous value - */ - public V getAndSet(T obj, V newValue) { - for (;;) { - V current = get(obj); - if (compareAndSet(obj, current, newValue)) - return current; - } - } - - private static final class AtomicReferenceFieldUpdaterImpl - extends AtomicReferenceFieldUpdater { - // BEGIN android-changed - private static final Unsafe unsafe = UnsafeAccess.THE_ONE; - // END android-changed - private final long offset; - private final Class tclass; - private final Class vclass; - private final Class cclass; - - /* - * Internal type checks within all update methods contain - * internal inlined optimizations checking for the common - * cases where the class is final (in which case a simple - * getClass comparison suffices) or is of type Object (in - * which case no check is needed because all objects are - * instances of Object). The Object case is handled simply by - * setting vclass to null in constructor. The targetCheck and - * updateCheck methods are invoked when these faster - * screenings fail. - */ - - AtomicReferenceFieldUpdaterImpl(Class tclass, - Class vclass, - String fieldName) { - Field field = null; - Class fieldClass = null; - Class caller = null; - int modifiers = 0; - try { - field = tclass.getDeclaredField(fieldName); - // BEGIN android-changed - caller = VMStack.getStackClass2(); - // END android-changed - modifiers = field.getModifiers(); - SecurityManager smgr = System.getSecurityManager(); - if (smgr != null) { - int type = Modifier.isPublic(modifiers) - ? Member.PUBLIC : Member.DECLARED; - smgr.checkMemberAccess(tclass, type); - smgr.checkPackageAccess(tclass.getPackage().getName()); - } - fieldClass = field.getType(); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - - if (vclass != fieldClass) - throw new ClassCastException(); - - if (!Modifier.isVolatile(modifiers)) - throw new IllegalArgumentException("Must be volatile type"); - - this.cclass = (Modifier.isProtected(modifiers) && - caller != tclass) ? caller : null; - this.tclass = tclass; - if (vclass == Object.class) - this.vclass = null; - else - this.vclass = vclass; - offset = unsafe.objectFieldOffset(field); - } - - void targetCheck(T obj) { - if (!tclass.isInstance(obj)) - throw new ClassCastException(); - if (cclass != null) - ensureProtectedAccess(obj); - } - - void updateCheck(T obj, V update) { - if (!tclass.isInstance(obj) || - (update != null && vclass != null && !vclass.isInstance(update))) - throw new ClassCastException(); - if (cclass != null) - ensureProtectedAccess(obj); - } - - public boolean compareAndSet(T obj, V expect, V update) { - if (obj == null || obj.getClass() != tclass || cclass != null || - (update != null && vclass != null && - vclass != update.getClass())) - updateCheck(obj, update); - return unsafe.compareAndSwapObject(obj, offset, expect, update); - } - - public boolean weakCompareAndSet(T obj, V expect, V update) { - // same implementation as strong form for now - if (obj == null || obj.getClass() != tclass || cclass != null || - (update != null && vclass != null && - vclass != update.getClass())) - updateCheck(obj, update); - return unsafe.compareAndSwapObject(obj, offset, expect, update); - } - - public void set(T obj, V newValue) { - if (obj == null || obj.getClass() != tclass || cclass != null || - (newValue != null && vclass != null && - vclass != newValue.getClass())) - updateCheck(obj, newValue); - unsafe.putObjectVolatile(obj, offset, newValue); - } - - public V get(T obj) { - if (obj == null || obj.getClass() != tclass || cclass != null) - targetCheck(obj); - return (V)unsafe.getObjectVolatile(obj, offset); - } - - private void ensureProtectedAccess(T obj) { - if (cclass.isInstance(obj)) { - return; - } - throw new RuntimeException ( - new IllegalAccessException("Class " + - cclass.getName() + - " can not access a protected member of class " + - tclass.getName() + - " using an instance of " + - obj.getClass().getName() - ) - ); - } - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicStampedReference.java b/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicStampedReference.java deleted file mode 100644 index a1d535f8b..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/AtomicStampedReference.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.atomic; - -/** - * An {@code AtomicStampedReference} maintains an object reference - * along with an integer "stamp", that can be updated atomically. - * - *

Implementation note. This implementation maintains stamped - * references by creating internal objects representing "boxed" - * [reference, integer] pairs. - * - * @since 1.5 - * @author Doug Lea - * @param The type of object referred to by this reference - */ -public class AtomicStampedReference { - - private static class ReferenceIntegerPair { - private final T reference; - private final int integer; - ReferenceIntegerPair(T r, int i) { - reference = r; integer = i; - } - } - - private final AtomicReference> atomicRef; - - /** - * Creates a new {@code AtomicStampedReference} with the given - * initial values. - * - * @param initialRef the initial reference - * @param initialStamp the initial stamp - */ - public AtomicStampedReference(V initialRef, int initialStamp) { - atomicRef = new AtomicReference> - (new ReferenceIntegerPair(initialRef, initialStamp)); - } - - /** - * Returns the current value of the reference. - * - * @return the current value of the reference - */ - public V getReference() { - return atomicRef.get().reference; - } - - /** - * Returns the current value of the stamp. - * - * @return the current value of the stamp - */ - public int getStamp() { - return atomicRef.get().integer; - } - - /** - * Returns the current values of both the reference and the stamp. - * Typical usage is {@code int[1] holder; ref = v.get(holder); }. - * - * @param stampHolder an array of size of at least one. On return, - * {@code stampholder[0]} will hold the value of the stamp. - * @return the current value of the reference - */ - public V get(int[] stampHolder) { - ReferenceIntegerPair p = atomicRef.get(); - stampHolder[0] = p.integer; - return p.reference; - } - - /** - * Atomically sets the value of both the reference and stamp - * to the given update values if the - * current reference is {@code ==} to the expected reference - * and the current stamp is equal to the expected stamp. - * - *

May fail spuriously - * and does not provide ordering guarantees, so is only rarely an - * appropriate alternative to {@code compareAndSet}. - * - * @param expectedReference the expected value of the reference - * @param newReference the new value for the reference - * @param expectedStamp the expected value of the stamp - * @param newStamp the new value for the stamp - * @return true if successful - */ - public boolean weakCompareAndSet(V expectedReference, - V newReference, - int expectedStamp, - int newStamp) { - ReferenceIntegerPair current = atomicRef.get(); - return expectedReference == current.reference && - expectedStamp == current.integer && - ((newReference == current.reference && - newStamp == current.integer) || - atomicRef.weakCompareAndSet(current, - new ReferenceIntegerPair(newReference, - newStamp))); - } - - /** - * Atomically sets the value of both the reference and stamp - * to the given update values if the - * current reference is {@code ==} to the expected reference - * and the current stamp is equal to the expected stamp. - * - * @param expectedReference the expected value of the reference - * @param newReference the new value for the reference - * @param expectedStamp the expected value of the stamp - * @param newStamp the new value for the stamp - * @return true if successful - */ - public boolean compareAndSet(V expectedReference, - V newReference, - int expectedStamp, - int newStamp) { - ReferenceIntegerPair current = atomicRef.get(); - return expectedReference == current.reference && - expectedStamp == current.integer && - ((newReference == current.reference && - newStamp == current.integer) || - atomicRef.compareAndSet(current, - new ReferenceIntegerPair(newReference, - newStamp))); - } - - - /** - * Unconditionally sets the value of both the reference and stamp. - * - * @param newReference the new value for the reference - * @param newStamp the new value for the stamp - */ - public void set(V newReference, int newStamp) { - ReferenceIntegerPair current = atomicRef.get(); - if (newReference != current.reference || newStamp != current.integer) - atomicRef.set(new ReferenceIntegerPair(newReference, newStamp)); - } - - /** - * Atomically sets the value of the stamp to the given update value - * if the current reference is {@code ==} to the expected - * reference. Any given invocation of this operation may fail - * (return {@code false}) spuriously, but repeated invocation - * when the current value holds the expected value and no other - * thread is also attempting to set the value will eventually - * succeed. - * - * @param expectedReference the expected value of the reference - * @param newStamp the new value for the stamp - * @return true if successful - */ - public boolean attemptStamp(V expectedReference, int newStamp) { - ReferenceIntegerPair current = atomicRef.get(); - return expectedReference == current.reference && - (newStamp == current.integer || - atomicRef.compareAndSet(current, - new ReferenceIntegerPair(expectedReference, - newStamp))); - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/UnsafeAccess.java b/libcore/concurrent/src/main/java/java/util/concurrent/atomic/UnsafeAccess.java deleted file mode 100644 index 96fff1704..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/UnsafeAccess.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.concurrent.atomic; - -import sun.misc.Unsafe; - -/** - * Easy access to {@link Unsafe} for the rest of this package. - */ -/*package*/ final class UnsafeAccess { - /** non-null; unique instance of {@link Unsafe} */ - /*package*/ static final Unsafe THE_ONE = Unsafe.getUnsafe(); - - /** - * This class is uninstantiable. - */ - private UnsafeAccess() { - // This space intentionally left blank. - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/package-info.java b/libcore/concurrent/src/main/java/java/util/concurrent/atomic/package-info.java deleted file mode 100644 index 2252e5ce7..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/atomic/package-info.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -/** - * A small toolkit of classes that support lock-free thread-safe - * programming on single variables. In essence, the classes in this - * package extend the notion of {@code volatile} values, fields, and - * array elements to those that also provide an atomic conditional update - * operation of the form: - * - *

- *   boolean compareAndSet(expectedValue, updateValue);
- * 
- * - *

This method (which varies in argument types across different - * classes) atomically sets a variable to the {@code updateValue} if it - * currently holds the {@code expectedValue}, reporting {@code true} on - * success. The classes in this package also contain methods to get and - * unconditionally set values, as well as a weaker conditional atomic - * update operation {@code weakCompareAndSet} described below. - * - *

The specifications of these methods enable implementations to - * employ efficient machine-level atomic instructions that are available - * on contemporary processors. However on some platforms, support may - * entail some form of internal locking. Thus the methods are not - * strictly guaranteed to be non-blocking -- - * a thread may block transiently before performing the operation. - * - *

Instances of classes - * {@link java.util.concurrent.atomic.AtomicBoolean}, - * {@link java.util.concurrent.atomic.AtomicInteger}, - * {@link java.util.concurrent.atomic.AtomicLong}, and - * {@link java.util.concurrent.atomic.AtomicReference} - * each provide access and updates to a single variable of the - * corresponding type. Each class also provides appropriate utility - * methods for that type. For example, classes {@code AtomicLong} and - * {@code AtomicInteger} provide atomic increment methods. One - * application is to generate sequence numbers, as in: - * - *

- * class Sequencer {
- *   private final AtomicLong sequenceNumber
- *     = new AtomicLong(0);
- *   public long next() {
- *     return sequenceNumber.getAndIncrement();
- *   }
- * }
- * 
- * - *

The memory effects for accesses and updates of atomics generally - * follow the rules for volatiles, as stated in - * The Java Language - * Specification, Third Edition (17.4 Memory Model): - * - *

    - * - *
  • {@code get} has the memory effects of reading a - * {@code volatile} variable. - * - *
  • {@code set} has the memory effects of writing (assigning) a - * {@code volatile} variable. - * - *
  • {@code weakCompareAndSet} atomically reads and conditionally - * writes a variable but does not - * create any happens-before orderings, so provides no guarantees - * with respect to previous or subsequent reads and writes of any - * variables other than the target of the {@code weakCompareAndSet}. - * - *
  • {@code compareAndSet} - * and all other read-and-update operations such as {@code getAndIncrement} - * have the memory effects of both reading and - * writing {@code volatile} variables. - *
- * - *

In addition to classes representing single values, this package - * contains Updater classes that can be used to obtain - * {@code compareAndSet} operations on any selected {@code volatile} - * field of any selected class. - * - * {@link java.util.concurrent.atomic.AtomicReferenceFieldUpdater}, - * {@link java.util.concurrent.atomic.AtomicIntegerFieldUpdater}, and - * {@link java.util.concurrent.atomic.AtomicLongFieldUpdater} are - * reflection-based utilities that provide access to the associated - * field types. These are mainly of use in atomic data structures in - * which several {@code volatile} fields of the same node (for - * example, the links of a tree node) are independently subject to - * atomic updates. These classes enable greater flexibility in how - * and when to use atomic updates, at the expense of more awkward - * reflection-based setup, less convenient usage, and weaker - * guarantees. - * - *

The - * {@link java.util.concurrent.atomic.AtomicIntegerArray}, - * {@link java.util.concurrent.atomic.AtomicLongArray}, and - * {@link java.util.concurrent.atomic.AtomicReferenceArray} classes - * further extend atomic operation support to arrays of these types. - * These classes are also notable in providing {@code volatile} access - * semantics for their array elements, which is not supported for - * ordinary arrays. - * - * - *

The atomic classes also support method {@code weakCompareAndSet}, - * which has limited applicability. On some platforms, the weak version - * may be more efficient than {@code compareAndSet} in the normal case, - * but differs in that any given invocation of the - * {@code weakCompareAndSet} method may return {@code false} - * spuriously (that is, for no apparent reason). A - * {@code false} return means only that the operation may be retried if - * desired, relying on the guarantee that repeated invocation when the - * variable holds {@code expectedValue} and no other thread is also - * attempting to set the variable will eventually succeed. (Such - * spurious failures may for example be due to memory contention effects - * that are unrelated to whether the expected and current values are - * equal.) Additionally {@code weakCompareAndSet} does not provide - * ordering guarantees that are usually needed for synchronization - * control. However, the method may be useful for updating counters and - * statistics when such updates are unrelated to the other - * happens-before orderings of a program. When a thread sees an update - * to an atomic variable caused by a {@code weakCompareAndSet}, it does - * not necessarily see updates to any other variables that - * occurred before the {@code weakCompareAndSet}. This may be - * acceptable when, for example, updating performance statistics, but - * rarely otherwise. - * - *

The {@link java.util.concurrent.atomic.AtomicMarkableReference} - * class associates a single boolean with a reference. For example, this - * bit might be used inside a data structure to mean that the object - * being referenced has logically been deleted. - * - * The {@link java.util.concurrent.atomic.AtomicStampedReference} - * class associates an integer value with a reference. This may be - * used for example, to represent version numbers corresponding to - * series of updates. - * - *

Atomic classes are designed primarily as building blocks for - * implementing non-blocking data structures and related infrastructure - * classes. The {@code compareAndSet} method is not a general - * replacement for locking. It applies only when critical updates for an - * object are confined to a single variable. - * - *

Atomic classes are not general purpose replacements for - * {@code java.lang.Integer} and related classes. They do not - * define methods such as {@code hashCode} and - * {@code compareTo}. (Because atomic variables are expected to be - * mutated, they are poor choices for hash table keys.) Additionally, - * classes are provided only for those types that are commonly useful in - * intended applications. For example, there is no atomic class for - * representing {@code byte}. In those infrequent cases where you would - * like to do so, you can use an {@code AtomicInteger} to hold - * {@code byte} values, and cast appropriately. - * - * You can also hold floats using - * {@link java.lang.Float#floatToIntBits} and - * {@link java.lang.Float#intBitsToFloat} conversions, and doubles using - * {@link java.lang.Double#doubleToLongBits} and - * {@link java.lang.Double#longBitsToDouble} conversions. - * - * @since 1.5 - */ -package java.util.concurrent.atomic; diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/locks/AbstractOwnableSynchronizer.java b/libcore/concurrent/src/main/java/java/util/concurrent/locks/AbstractOwnableSynchronizer.java deleted file mode 100644 index bf2fe1618..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/locks/AbstractOwnableSynchronizer.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.locks; - -/** - * A synchronizer that may be exclusively owned by a thread. This - * class provides a basis for creating locks and related synchronizers - * that may entail a notion of ownership. The - * AbstractOwnableSynchronizer class itself does not manage or - * use this information. However, subclasses and tools may use - * appropriately maintained values to help control and monitor access - * and provide diagnostics. - * - * @author Doug Lea - */ -abstract class AbstractOwnableSynchronizer - implements java.io.Serializable { - - /** Use serial ID even though all fields transient. */ - private static final long serialVersionUID = 3737899427754241961L; - - /** - * Empty constructor for use by subclasses. - */ - protected AbstractOwnableSynchronizer() { } - - /** - * The current owner of exclusive mode synchronization. - */ - private transient Thread exclusiveOwnerThread; - - /** - * Sets the thread that currently owns exclusive access. A - * null argument indicates that no thread owns access. - * This method does not otherwise impose any synchronization or - * volatile field accesses. - */ - protected final void setExclusiveOwnerThread(Thread t) { - exclusiveOwnerThread = t; - } - - /** - * Returns the thread last set by - * setExclusiveOwnerThread, or null if never - * set. This method does not otherwise impose any synchronization - * or volatile field accesses. - * @return the owner thread - */ - protected final Thread getExclusiveOwnerThread() { - return exclusiveOwnerThread; - } -} \ No newline at end of file diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/locks/AbstractQueuedSynchronizer.java b/libcore/concurrent/src/main/java/java/util/concurrent/locks/AbstractQueuedSynchronizer.java deleted file mode 100644 index 8b9821ed4..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/locks/AbstractQueuedSynchronizer.java +++ /dev/null @@ -1,2305 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.locks; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; -import sun.misc.Unsafe; - -/** - * Provides a framework for implementing blocking locks and related - * synchronizers (semaphores, events, etc) that rely on - * first-in-first-out (FIFO) wait queues. This class is designed to - * be a useful basis for most kinds of synchronizers that rely on a - * single atomic int value to represent state. Subclasses - * must define the protected methods that change this state, and which - * define what that state means in terms of this object being acquired - * or released. Given these, the other methods in this class carry - * out all queuing and blocking mechanics. Subclasses can maintain - * other state fields, but only the atomically updated int - * value manipulated using methods {@link #getState}, {@link - * #setState} and {@link #compareAndSetState} is tracked with respect - * to synchronization. - * - *

Subclasses should be defined as non-public internal helper - * classes that are used to implement the synchronization properties - * of their enclosing class. Class - * AbstractQueuedSynchronizer does not implement any - * synchronization interface. Instead it defines methods such as - * {@link #acquireInterruptibly} that can be invoked as - * appropriate by concrete locks and related synchronizers to - * implement their public methods. - * - *

This class supports either or both a default exclusive - * mode and a shared mode. When acquired in exclusive mode, - * attempted acquires by other threads cannot succeed. Shared mode - * acquires by multiple threads may (but need not) succeed. This class - * does not "understand" these differences except in the - * mechanical sense that when a shared mode acquire succeeds, the next - * waiting thread (if one exists) must also determine whether it can - * acquire as well. Threads waiting in the different modes share the - * same FIFO queue. Usually, implementation subclasses support only - * one of these modes, but both can come into play for example in a - * {@link ReadWriteLock}. Subclasses that support only exclusive or - * only shared modes need not define the methods supporting the unused mode. - * - *

This class defines a nested {@link ConditionObject} class that - * can be used as a {@link Condition} implementation by subclasses - * supporting exclusive mode for which method {@link - * #isHeldExclusively} reports whether synchronization is exclusively - * held with respect to the current thread, method {@link #release} - * invoked with the current {@link #getState} value fully releases - * this object, and {@link #acquire}, given this saved state value, - * eventually restores this object to its previous acquired state. No - * AbstractQueuedSynchronizer method otherwise creates such a - * condition, so if this constraint cannot be met, do not use it. The - * behavior of {@link ConditionObject} depends of course on the - * semantics of its synchronizer implementation. - * - *

This class provides inspection, instrumentation, and monitoring - * methods for the internal queue, as well as similar methods for - * condition objects. These can be exported as desired into classes - * using an AbstractQueuedSynchronizer for their - * synchronization mechanics. - * - *

Serialization of this class stores only the underlying atomic - * integer maintaining state, so deserialized objects have empty - * thread queues. Typical subclasses requiring serializability will - * define a readObject method that restores this to a known - * initial state upon deserialization. - * - *

Usage

- * - *

To use this class as the basis of a synchronizer, redefine the - * following methods, as applicable, by inspecting and/or modifying - * the synchronization state using {@link #getState}, {@link - * #setState} and/or {@link #compareAndSetState}: - * - *

    - *
  • {@link #tryAcquire} - *
  • {@link #tryRelease} - *
  • {@link #tryAcquireShared} - *
  • {@link #tryReleaseShared} - *
  • {@link #isHeldExclusively} - *
- * - * Each of these methods by default throws {@link - * UnsupportedOperationException}. Implementations of these methods - * must be internally thread-safe, and should in general be short and - * not block. Defining these methods is the only supported - * means of using this class. All other methods are declared - * final because they cannot be independently varied. - * - *

Even though this class is based on an internal FIFO queue, it - * does not automatically enforce FIFO acquisition policies. The core - * of exclusive synchronization takes the form: - * - *

- * Acquire:
- *     while (!tryAcquire(arg)) {
- *        enqueue thread if it is not already queued;
- *        possibly block current thread;
- *     }
- *
- * Release:
- *     if (tryRelease(arg))
- *        unblock the first queued thread;
- * 
- * - * (Shared mode is similar but may involve cascading signals.) - * - *

Because checks in acquire are invoked before - * enqueuing, a newly acquiring thread may barge ahead of - * others that are blocked and queued. However, you can, if desired, - * define tryAcquire and/or tryAcquireShared to - * disable barging by internally invoking one or more of the inspection - * methods, thereby providing a fair FIFO acquisition order. - * In particular, most fair synchronizers can define tryAcquire - * to return false if predecessors are queued. Other variations - * are possible. - * - *

Throughput and scalability are generally highest for the - * default barging (also known as greedy, - * renouncement, and convoy-avoidance) strategy. - * While this is not guaranteed to be fair or starvation-free, earlier - * queued threads are allowed to recontend before later queued - * threads, and each recontention has an unbiased chance to succeed - * against incoming threads. Also, while acquires do not - * "spin" in the usual sense, they may perform multiple - * invocations of tryAcquire interspersed with other - * computations before blocking. This gives most of the benefits of - * spins when exclusive synchronization is only briefly held, without - * most of the liabilities when it isn't. If so desired, you can - * augment this by preceding calls to acquire methods with - * "fast-path" checks, possibly prechecking {@link #hasContended} - * and/or {@link #hasQueuedThreads} to only do so if the synchronizer - * is likely not to be contended. - * - *

This class provides an efficient and scalable basis for - * synchronization in part by specializing its range of use to - * synchronizers that can rely on int state, acquire, and - * release parameters, and an internal FIFO wait queue. When this does - * not suffice, you can build synchronizers from a lower level using - * {@link java.util.concurrent.atomic atomic} classes, your own custom - * {@link java.util.Queue} classes, and {@link LockSupport} blocking - * support. - * - *

Usage Examples

- * - *

Here is a non-reentrant mutual exclusion lock class that uses - * the value zero to represent the unlocked state, and one to - * represent the locked state. It also supports conditions and exposes - * one of the instrumentation methods: - * - *

- * class Mutex implements Lock, java.io.Serializable {
- *
- *   // Our internal helper class
- *   private static class Sync extends AbstractQueuedSynchronizer {
- *     // Report whether in locked state
- *     protected boolean isHeldExclusively() {
- *       return getState() == 1;
- *     }
- *
- *     // Acquire the lock if state is zero
- *     public boolean tryAcquire(int acquires) {
- *       assert acquires == 1; // Otherwise unused
- *       return compareAndSetState(0, 1);
- *     }
- *
- *     // Release the lock by setting state to zero
- *     protected boolean tryRelease(int releases) {
- *       assert releases == 1; // Otherwise unused
- *       if (getState() == 0) throw new IllegalMonitorStateException();
- *       setState(0);
- *       return true;
- *     }
- *
- *     // Provide a Condition
- *     Condition newCondition() { return new ConditionObject(); }
- *
- *     // Deserialize properly
- *     private void readObject(ObjectInputStream s)
- *         throws IOException, ClassNotFoundException {
- *       s.defaultReadObject();
- *       setState(0); // reset to unlocked state
- *     }
- *   }
- *
- *   // The sync object does all the hard work. We just forward to it.
- *   private final Sync sync = new Sync();
- *
- *   public void lock()                { sync.acquire(1); }
- *   public boolean tryLock()          { return sync.tryAcquire(1); }
- *   public void unlock()              { sync.release(1); }
- *   public Condition newCondition()   { return sync.newCondition(); }
- *   public boolean isLocked()         { return sync.isHeldExclusively(); }
- *   public boolean hasQueuedThreads() { return sync.hasQueuedThreads(); }
- *   public void lockInterruptibly() throws InterruptedException {
- *     sync.acquireInterruptibly(1);
- *   }
- *   public boolean tryLock(long timeout, TimeUnit unit)
- *       throws InterruptedException {
- *     return sync.tryAcquireNanos(1, unit.toNanos(timeout));
- *   }
- * }
- * 
- * - *

Here is a latch class that is like a {@link CountDownLatch} - * except that it only requires a single signal to - * fire. Because a latch is non-exclusive, it uses the shared - * acquire and release methods. - * - *

- * class BooleanLatch {
- *
- *   private static class Sync extends AbstractQueuedSynchronizer {
- *     boolean isSignalled() { return getState() != 0; }
- *
- *     protected int tryAcquireShared(int ignore) {
- *       return isSignalled()? 1 : -1;
- *     }
- *
- *     protected boolean tryReleaseShared(int ignore) {
- *       setState(1);
- *       return true;
- *     }
- *   }
- *
- *   private final Sync sync = new Sync();
- *   public boolean isSignalled() { return sync.isSignalled(); }
- *   public void signal()         { sync.releaseShared(1); }
- *   public void await() throws InterruptedException {
- *     sync.acquireSharedInterruptibly(1);
- *   }
- * }
- * 
- * - * @since 1.5 - * @author Doug Lea - */ -public abstract class AbstractQueuedSynchronizer - extends AbstractOwnableSynchronizer - implements java.io.Serializable { - - private static final long serialVersionUID = 7373984972572414691L; - - /** - * Creates a new AbstractQueuedSynchronizer instance - * with initial synchronization state of zero. - */ - protected AbstractQueuedSynchronizer() { } - - /** - * Wait queue node class. - * - *

The wait queue is a variant of a "CLH" (Craig, Landin, and - * Hagersten) lock queue. CLH locks are normally used for - * spinlocks. We instead use them for blocking synchronizers, but - * use the same basic tactic of holding some of the control - * information about a thread in the predecessor of its node. A - * "status" field in each node keeps track of whether a thread - * should block. A node is signalled when its predecessor - * releases. Each node of the queue otherwise serves as a - * specific-notification-style monitor holding a single waiting - * thread. The status field does NOT control whether threads are - * granted locks etc though. A thread may try to acquire if it is - * first in the queue. But being first does not guarantee success; - * it only gives the right to contend. So the currently released - * contender thread may need to rewait. - * - *

To enqueue into a CLH lock, you atomically splice it in as new - * tail. To dequeue, you just set the head field. - *

-     *      +------+  prev +-----+       +-----+
-     * head |      | <---- |     | <---- |     |  tail
-     *      +------+       +-----+       +-----+
-     * 
- * - *

Insertion into a CLH queue requires only a single atomic - * operation on "tail", so there is a simple atomic point of - * demarcation from unqueued to queued. Similarly, dequeing - * involves only updating the "head". However, it takes a bit - * more work for nodes to determine who their successors are, - * in part to deal with possible cancellation due to timeouts - * and interrupts. - * - *

The "prev" links (not used in original CLH locks), are mainly - * needed to handle cancellation. If a node is cancelled, its - * successor is (normally) relinked to a non-cancelled - * predecessor. For explanation of similar mechanics in the case - * of spin locks, see the papers by Scott and Scherer at - * http://www.cs.rochester.edu/u/scott/synchronization/ - * - *

We also use "next" links to implement blocking mechanics. - * The thread id for each node is kept in its own node, so a - * predecessor signals the next node to wake up by traversing - * next link to determine which thread it is. Determination of - * successor must avoid races with newly queued nodes to set - * the "next" fields of their predecessors. This is solved - * when necessary by checking backwards from the atomically - * updated "tail" when a node's successor appears to be null. - * (Or, said differently, the next-links are an optimization - * so that we don't usually need a backward scan.) - * - *

Cancellation introduces some conservatism to the basic - * algorithms. Since we must poll for cancellation of other - * nodes, we can miss noticing whether a cancelled node is - * ahead or behind us. This is dealt with by always unparking - * successors upon cancellation, allowing them to stabilize on - * a new predecessor, unless we can identify an uncancelled - * predecessor who will carry this responsibility. - * - *

CLH queues need a dummy header node to get started. But - * we don't create them on construction, because it would be wasted - * effort if there is never contention. Instead, the node - * is constructed and head and tail pointers are set upon first - * contention. - * - *

Threads waiting on Conditions use the same nodes, but - * use an additional link. Conditions only need to link nodes - * in simple (non-concurrent) linked queues because they are - * only accessed when exclusively held. Upon await, a node is - * inserted into a condition queue. Upon signal, the node is - * transferred to the main queue. A special value of status - * field is used to mark which queue a node is on. - * - *

Thanks go to Dave Dice, Mark Moir, Victor Luchangco, Bill - * Scherer and Michael Scott, along with members of JSR-166 - * expert group, for helpful ideas, discussions, and critiques - * on the design of this class. - */ - static final class Node { - /** Marker to indicate a node is waiting in shared mode */ - static final Node SHARED = new Node(); - /** Marker to indicate a node is waiting in exclusive mode */ - static final Node EXCLUSIVE = null; - - /** waitStatus value to indicate thread has cancelled */ - static final int CANCELLED = 1; - /** waitStatus value to indicate successor's thread needs unparking */ - static final int SIGNAL = -1; - /** waitStatus value to indicate thread is waiting on condition */ - static final int CONDITION = -2; - /** - * waitStatus value to indicate the next acquireShared should - * unconditionally propagate - */ - static final int PROPAGATE = -3; - - /** - * Status field, taking on only the values: - * SIGNAL: The successor of this node is (or will soon be) - * blocked (via park), so the current node must - * unpark its successor when it releases or - * cancels. To avoid races, acquire methods must - * first indicate they need a signal, - * then retry the atomic acquire, and then, - * on failure, block. - * CANCELLED: This node is cancelled due to timeout or interrupt. - * Nodes never leave this state. In particular, - * a thread with cancelled node never again blocks. - * CONDITION: This node is currently on a condition queue. - * It will not be used as a sync queue node - * until transferred, at which time the status - * will be set to 0. (Use of this value here has - * nothing to do with the other uses of the - * field, but simplifies mechanics.) - * PROPAGATE: A releaseShared should be propagated to other - * nodes. This is set (for head node only) in - * doReleaseShared to ensure propagation - * continues, even if other operations have - * since intervened. - * 0: None of the above - * - * The values are arranged numerically to simplify use. - * Non-negative values mean that a node doesn't need to - * signal. So, most code doesn't need to check for particular - * values, just for sign. - * - * The field is initialized to 0 for normal sync nodes, and - * CONDITION for condition nodes. It is modified using CAS - * (or when possible, unconditional volatile writes). - */ - volatile int waitStatus; - - /** - * Link to predecessor node that current node/thread relies on - * for checking waitStatus. Assigned during enqueing, and nulled - * out (for sake of GC) only upon dequeuing. Also, upon - * cancellation of a predecessor, we short-circuit while - * finding a non-cancelled one, which will always exist - * because the head node is never cancelled: A node becomes - * head only as a result of successful acquire. A - * cancelled thread never succeeds in acquiring, and a thread only - * cancels itself, not any other node. - */ - volatile Node prev; - - /** - * Link to the successor node that the current node/thread - * unparks upon release. Assigned during enqueuing, adjusted - * when bypassing cancelled predecessors, and nulled out (for - * sake of GC) when dequeued. The enq operation does not - * assign next field of a predecessor until after attachment, - * so seeing a null next field does not necessarily mean that - * node is at end of queue. However, if a next field appears - * to be null, we can scan prev's from the tail to - * double-check. The next field of cancelled nodes is set to - * point to the node itself instead of null, to make life - * easier for isOnSyncQueue. - */ - volatile Node next; - - /** - * The thread that enqueued this node. Initialized on - * construction and nulled out after use. - */ - volatile Thread thread; - - /** - * Link to next node waiting on condition, or the special - * value SHARED. Because condition queues are accessed only - * when holding in exclusive mode, we just need a simple - * linked queue to hold nodes while they are waiting on - * conditions. They are then transferred to the queue to - * re-acquire. And because conditions can only be exclusive, - * we save a field by using special value to indicate shared - * mode. - */ - Node nextWaiter; - - /** - * Returns true if node is waiting in shared mode - */ - final boolean isShared() { - return nextWaiter == SHARED; - } - - /** - * Returns previous node, or throws NullPointerException if null. - * Use when predecessor cannot be null. The null check could - * be elided, but is present to help the VM. - * - * @return the predecessor of this node - */ - final Node predecessor() throws NullPointerException { - Node p = prev; - if (p == null) - throw new NullPointerException(); - else - return p; - } - - Node() { // Used to establish initial head or SHARED marker - } - - Node(Thread thread, Node mode) { // Used by addWaiter - this.nextWaiter = mode; - this.thread = thread; - } - - Node(Thread thread, int waitStatus) { // Used by Condition - this.waitStatus = waitStatus; - this.thread = thread; - } - } - - /** - * Head of the wait queue, lazily initialized. Except for - * initialization, it is modified only via method setHead. Note: - * If head exists, its waitStatus is guaranteed not to be - * CANCELLED. - */ - private transient volatile Node head; - - /** - * Tail of the wait queue, lazily initialized. Modified only via - * method enq to add new wait node. - */ - private transient volatile Node tail; - - /** - * The synchronization state. - */ - private volatile int state; - - /** - * Returns the current value of synchronization state. - * This operation has memory semantics of a volatile read. - * @return current state value - */ - protected final int getState() { - return state; - } - - /** - * Sets the value of synchronization state. - * This operation has memory semantics of a volatile write. - * @param newState the new state value - */ - protected final void setState(int newState) { - state = newState; - } - - /** - * Atomically sets synchronization state to the given updated - * value if the current state value equals the expected value. - * This operation has memory semantics of a volatile read - * and write. - * - * @param expect the expected value - * @param update the new value - * @return true if successful. False return indicates that the actual - * value was not equal to the expected value. - */ - protected final boolean compareAndSetState(int expect, int update) { - // See below for intrinsics setup to support this - return unsafe.compareAndSwapInt(this, stateOffset, expect, update); - } - - // Queuing utilities - - /** - * The number of nanoseconds for which it is faster to spin - * rather than to use timed park. A rough estimate suffices - * to improve responsiveness with very short timeouts. - */ - static final long spinForTimeoutThreshold = 1000L; - - /** - * Inserts node into queue, initializing if necessary. See picture above. - * @param node the node to insert - * @return node's predecessor - */ - private Node enq(final Node node) { - for (;;) { - Node t = tail; - if (t == null) { // Must initialize - if (compareAndSetHead(new Node())) - tail = head; - } else { - node.prev = t; - if (compareAndSetTail(t, node)) { - t.next = node; - return t; - } - } - } - } - - /** - * Creates and enqueues node for current thread and given mode. - * - * @param mode Node.EXCLUSIVE for exclusive, Node.SHARED for shared - * @return the new node - */ - private Node addWaiter(Node mode) { - Node node = new Node(Thread.currentThread(), mode); - // Try the fast path of enq; backup to full enq on failure - Node pred = tail; - if (pred != null) { - node.prev = pred; - if (compareAndSetTail(pred, node)) { - pred.next = node; - return node; - } - } - enq(node); - return node; - } - - /** - * Sets head of queue to be node, thus dequeuing. Called only by - * acquire methods. Also nulls out unused fields for sake of GC - * and to suppress unnecessary signals and traversals. - * - * @param node the node - */ - private void setHead(Node node) { - head = node; - node.thread = null; - node.prev = null; - } - - /** - * Wakes up node's successor, if one exists. - * - * @param node the node - */ - private void unparkSuccessor(Node node) { - /* - * If status is negative (i.e., possibly needing signal) try - * to clear in anticipation of signalling. It is OK if this - * fails or if status is changed by waiting thread. - */ - int ws = node.waitStatus; - if (ws < 0) - compareAndSetWaitStatus(node, ws, 0); - - /* - * Thread to unpark is held in successor, which is normally - * just the next node. But if cancelled or apparently null, - * traverse backwards from tail to find the actual - * non-cancelled successor. - */ - Node s = node.next; - if (s == null || s.waitStatus > 0) { - s = null; - for (Node t = tail; t != null && t != node; t = t.prev) - if (t.waitStatus <= 0) - s = t; - } - if (s != null) - LockSupport.unpark(s.thread); - } - - /** - * Release action for shared mode -- signal successor and ensure - * propagation. (Note: For exclusive mode, release just amounts - * to calling unparkSuccessor of head if it needs signal.) - */ - private void doReleaseShared() { - /* - * Ensure that a release propagates, even if there are other - * in-progress acquires/releases. This proceeds in the usual - * way of trying to unparkSuccessor of head if it needs - * signal. But if it does not, status is set to PROPAGATE to - * ensure that upon release, propagation continues. - * Additionally, we must loop in case a new node is added - * while we are doing this. Also, unlike other uses of - * unparkSuccessor, we need to know if CAS to reset status - * fails, if so rechecking. - */ - for (;;) { - Node h = head; - if (h != null && h != tail) { - int ws = h.waitStatus; - if (ws == Node.SIGNAL) { - if (!compareAndSetWaitStatus(h, Node.SIGNAL, 0)) - continue; // loop to recheck cases - unparkSuccessor(h); - } - else if (ws == 0 && - !compareAndSetWaitStatus(h, 0, Node.PROPAGATE)) - continue; // loop on failed CAS - } - if (h == head) // loop if head changed - break; - } - } - - /** - * Sets head of queue, and checks if successor may be waiting - * in shared mode, if so propagating if either propagate > 0 or - * PROPAGATE status was set. - * - * @param node the node - * @param propagate the return value from a tryAcquireShared - */ - private void setHeadAndPropagate(Node node, int propagate) { - Node h = head; // Record old head for check below - setHead(node); - /* - * Try to signal next queued node if: - * Propagation was indicated by caller, - * or was recorded (as h.waitStatus) by a previous operation - * (note: this uses sign-check of waitStatus because - * PROPAGATE status may transition to SIGNAL.) - * and - * The next node is waiting in shared mode, - * or we don't know, because it appears null - * - * The conservatism in both of these checks may cause - * unnecessary wake-ups, but only when there are multiple - * racing acquires/releases, so most need signals now or soon - * anyway. - */ - if (propagate > 0 || h == null || h.waitStatus < 0) { - Node s = node.next; - if (s == null || s.isShared()) - doReleaseShared(); - } - } - - // Utilities for various versions of acquire - - /** - * Cancels an ongoing attempt to acquire. - * - * @param node the node - */ - private void cancelAcquire(Node node) { - // Ignore if node doesn't exist - if (node == null) - return; - - node.thread = null; - - // Skip cancelled predecessors - Node pred = node.prev; - while (pred.waitStatus > 0) - node.prev = pred = pred.prev; - - // predNext is the apparent node to unsplice. CASes below will - // fail if not, in which case, we lost race vs another cancel - // or signal, so no further action is necessary. - Node predNext = pred.next; - - // Can use unconditional write instead of CAS here. - // After this atomic step, other Nodes can skip past us. - // Before, we are free of interference from other threads. - node.waitStatus = Node.CANCELLED; - - // If we are the tail, remove ourselves. - if (node == tail && compareAndSetTail(node, pred)) { - compareAndSetNext(pred, predNext, null); - } else { - // If successor needs signal, try to set pred's next-link - // so it will get one. Otherwise wake it up to propagate. - int ws; - if (pred != head && - ((ws = pred.waitStatus) == Node.SIGNAL || - (ws <= 0 && compareAndSetWaitStatus(pred, ws, Node.SIGNAL))) && - pred.thread != null) { - Node next = node.next; - if (next != null && next.waitStatus <= 0) - compareAndSetNext(pred, predNext, next); - } else { - unparkSuccessor(node); - } - - node.next = node; // help GC - } - } - - /** - * Checks and updates status for a node that failed to acquire. - * Returns true if thread should block. This is the main signal - * control in all acquire loops. Requires that pred == node.prev - * - * @param pred node's predecessor holding status - * @param node the node - * @return {@code true} if thread should block - */ - private static boolean shouldParkAfterFailedAcquire(Node pred, Node node) { - int ws = pred.waitStatus; - if (ws == Node.SIGNAL) - /* - * This node has already set status asking a release - * to signal it, so it can safely park. - */ - return true; - if (ws > 0) { - /* - * Predecessor was cancelled. Skip over predecessors and - * indicate retry. - */ - do { - node.prev = pred = pred.prev; - } while (pred.waitStatus > 0); - pred.next = node; - } else { - /* - * waitStatus must be 0 or PROPAGATE. Indicate that we - * need a signal, but don't park yet. Caller will need to - * retry to make sure it cannot acquire before parking. - */ - compareAndSetWaitStatus(pred, ws, Node.SIGNAL); - } - return false; - } - - /** - * Convenience method to interrupt current thread. - */ - private static void selfInterrupt() { - Thread.currentThread().interrupt(); - } - - /** - * Convenience method to park and then check if interrupted - * - * @return {@code true} if interrupted - */ - private final boolean parkAndCheckInterrupt() { - LockSupport.park(); - return Thread.interrupted(); - } - - /* - * Various flavors of acquire, varying in exclusive/shared and - * control modes. Each is mostly the same, but annoyingly - * different. Only a little bit of factoring is possible due to - * interactions of exception mechanics (including ensuring that we - * cancel if tryAcquire throws exception) and other control, at - * least not without hurting performance too much. - */ - - /** - * Acquires in exclusive uninterruptible mode for thread already in - * queue. Used by condition wait methods as well as acquire. - * - * @param node the node - * @param arg the acquire argument - * @return {@code true} if interrupted while waiting - */ - final boolean acquireQueued(final Node node, int arg) { - boolean failed = true; - try { - boolean interrupted = false; - for (;;) { - final Node p = node.predecessor(); - if (p == head && tryAcquire(arg)) { - setHead(node); - p.next = null; // help GC - failed = false; - return interrupted; - } - if (shouldParkAfterFailedAcquire(p, node) && - parkAndCheckInterrupt()) - interrupted = true; - } - } finally { - if (failed) - cancelAcquire(node); - } - } - - /** - * Acquires in exclusive interruptible mode. - * @param arg the acquire argument - */ - private void doAcquireInterruptibly(int arg) - throws InterruptedException { - final Node node = addWaiter(Node.EXCLUSIVE); - boolean failed = true; - try { - for (;;) { - final Node p = node.predecessor(); - if (p == head && tryAcquire(arg)) { - setHead(node); - p.next = null; // help GC - failed = false; - return; - } - if (shouldParkAfterFailedAcquire(p, node) && - parkAndCheckInterrupt()) - throw new InterruptedException(); - } - } finally { - if (failed) - cancelAcquire(node); - } - } - - /** - * Acquires in exclusive timed mode. - * - * @param arg the acquire argument - * @param nanosTimeout max wait time - * @return {@code true} if acquired - */ - private boolean doAcquireNanos(int arg, long nanosTimeout) - throws InterruptedException { - long lastTime = System.nanoTime(); - final Node node = addWaiter(Node.EXCLUSIVE); - boolean failed = true; - try { - for (;;) { - final Node p = node.predecessor(); - if (p == head && tryAcquire(arg)) { - setHead(node); - p.next = null; // help GC - failed = false; - return true; - } - if (nanosTimeout <= 0) - return false; - if (shouldParkAfterFailedAcquire(p, node) && - nanosTimeout > spinForTimeoutThreshold) - LockSupport.parkNanos(nanosTimeout); - long now = System.nanoTime(); - nanosTimeout -= now - lastTime; - lastTime = now; - if (Thread.interrupted()) - throw new InterruptedException(); - } - } finally { - if (failed) - cancelAcquire(node); - } - } - - /** - * Acquires in shared uninterruptible mode. - * @param arg the acquire argument - */ - private void doAcquireShared(int arg) { - final Node node = addWaiter(Node.SHARED); - boolean failed = true; - try { - boolean interrupted = false; - for (;;) { - final Node p = node.predecessor(); - if (p == head) { - int r = tryAcquireShared(arg); - if (r >= 0) { - setHeadAndPropagate(node, r); - p.next = null; // help GC - if (interrupted) - selfInterrupt(); - failed = false; - return; - } - } - if (shouldParkAfterFailedAcquire(p, node) && - parkAndCheckInterrupt()) - interrupted = true; - } - } finally { - if (failed) - cancelAcquire(node); - } - } - - /** - * Acquires in shared interruptible mode. - * @param arg the acquire argument - */ - private void doAcquireSharedInterruptibly(int arg) - throws InterruptedException { - final Node node = addWaiter(Node.SHARED); - boolean failed = true; - try { - for (;;) { - final Node p = node.predecessor(); - if (p == head) { - int r = tryAcquireShared(arg); - if (r >= 0) { - setHeadAndPropagate(node, r); - p.next = null; // help GC - failed = false; - return; - } - } - if (shouldParkAfterFailedAcquire(p, node) && - parkAndCheckInterrupt()) - throw new InterruptedException(); - } - } finally { - if (failed) - cancelAcquire(node); - } - } - - /** - * Acquires in shared timed mode. - * - * @param arg the acquire argument - * @param nanosTimeout max wait time - * @return {@code true} if acquired - */ - private boolean doAcquireSharedNanos(int arg, long nanosTimeout) - throws InterruptedException { - - long lastTime = System.nanoTime(); - final Node node = addWaiter(Node.SHARED); - boolean failed = true; - try { - for (;;) { - final Node p = node.predecessor(); - if (p == head) { - int r = tryAcquireShared(arg); - if (r >= 0) { - setHeadAndPropagate(node, r); - p.next = null; // help GC - failed = false; - return true; - } - } - if (nanosTimeout <= 0) - return false; - if (shouldParkAfterFailedAcquire(p, node) && - nanosTimeout > spinForTimeoutThreshold) - LockSupport.parkNanos(nanosTimeout); - long now = System.nanoTime(); - nanosTimeout -= now - lastTime; - lastTime = now; - if (Thread.interrupted()) - throw new InterruptedException(); - } - } finally { - if (failed) - cancelAcquire(node); - } - } - - // Main exported methods - - /** - * Attempts to acquire in exclusive mode. This method should query - * if the state of the object permits it to be acquired in the - * exclusive mode, and if so to acquire it. - * - *

This method is always invoked by the thread performing - * acquire. If this method reports failure, the acquire method - * may queue the thread, if it is not already queued, until it is - * signalled by a release from some other thread. This can be used - * to implement method {@link Lock#tryLock()}. - * - *

The default - * implementation throws {@link UnsupportedOperationException}. - * - * @param arg the acquire argument. This value is always the one - * passed to an acquire method, or is the value saved on entry - * to a condition wait. The value is otherwise uninterpreted - * and can represent anything you like. - * @return {@code true} if successful. Upon success, this object has - * been acquired. - * @throws IllegalMonitorStateException if acquiring would place this - * synchronizer in an illegal state. This exception must be - * thrown in a consistent fashion for synchronization to work - * correctly. - * @throws UnsupportedOperationException if exclusive mode is not supported - */ - protected boolean tryAcquire(int arg) { - throw new UnsupportedOperationException(); - } - - /** - * Attempts to set the state to reflect a release in exclusive - * mode. - * - *

This method is always invoked by the thread performing release. - * - *

The default implementation throws - * {@link UnsupportedOperationException}. - * - * @param arg the release argument. This value is always the one - * passed to a release method, or the current state value upon - * entry to a condition wait. The value is otherwise - * uninterpreted and can represent anything you like. - * @return {@code true} if this object is now in a fully released - * state, so that any waiting threads may attempt to acquire; - * and {@code false} otherwise. - * @throws IllegalMonitorStateException if releasing would place this - * synchronizer in an illegal state. This exception must be - * thrown in a consistent fashion for synchronization to work - * correctly. - * @throws UnsupportedOperationException if exclusive mode is not supported - */ - protected boolean tryRelease(int arg) { - throw new UnsupportedOperationException(); - } - - /** - * Attempts to acquire in shared mode. This method should query if - * the state of the object permits it to be acquired in the shared - * mode, and if so to acquire it. - * - *

This method is always invoked by the thread performing - * acquire. If this method reports failure, the acquire method - * may queue the thread, if it is not already queued, until it is - * signalled by a release from some other thread. - * - *

The default implementation throws {@link - * UnsupportedOperationException}. - * - * @param arg the acquire argument. This value is always the one - * passed to an acquire method, or is the value saved on entry - * to a condition wait. The value is otherwise uninterpreted - * and can represent anything you like. - * @return a negative value on failure; zero if acquisition in shared - * mode succeeded but no subsequent shared-mode acquire can - * succeed; and a positive value if acquisition in shared - * mode succeeded and subsequent shared-mode acquires might - * also succeed, in which case a subsequent waiting thread - * must check availability. (Support for three different - * return values enables this method to be used in contexts - * where acquires only sometimes act exclusively.) Upon - * success, this object has been acquired. - * @throws IllegalMonitorStateException if acquiring would place this - * synchronizer in an illegal state. This exception must be - * thrown in a consistent fashion for synchronization to work - * correctly. - * @throws UnsupportedOperationException if shared mode is not supported - */ - protected int tryAcquireShared(int arg) { - throw new UnsupportedOperationException(); - } - - /** - * Attempts to set the state to reflect a release in shared mode. - * - *

This method is always invoked by the thread performing release. - * - *

The default implementation throws - * {@link UnsupportedOperationException}. - * - * @param arg the release argument. This value is always the one - * passed to a release method, or the current state value upon - * entry to a condition wait. The value is otherwise - * uninterpreted and can represent anything you like. - * @return {@code true} if this release of shared mode may permit a - * waiting acquire (shared or exclusive) to succeed; and - * {@code false} otherwise - * @throws IllegalMonitorStateException if releasing would place this - * synchronizer in an illegal state. This exception must be - * thrown in a consistent fashion for synchronization to work - * correctly. - * @throws UnsupportedOperationException if shared mode is not supported - */ - protected boolean tryReleaseShared(int arg) { - throw new UnsupportedOperationException(); - } - - /** - * Returns {@code true} if synchronization is held exclusively with - * respect to the current (calling) thread. This method is invoked - * upon each call to a non-waiting {@link ConditionObject} method. - * (Waiting methods instead invoke {@link #release}.) - * - *

The default implementation throws {@link - * UnsupportedOperationException}. This method is invoked - * internally only within {@link ConditionObject} methods, so need - * not be defined if conditions are not used. - * - * @return {@code true} if synchronization is held exclusively; - * {@code false} otherwise - * @throws UnsupportedOperationException if conditions are not supported - */ - protected boolean isHeldExclusively() { - throw new UnsupportedOperationException(); - } - - /** - * Acquires in exclusive mode, ignoring interrupts. Implemented - * by invoking at least once {@link #tryAcquire}, - * returning on success. Otherwise the thread is queued, possibly - * repeatedly blocking and unblocking, invoking {@link - * #tryAcquire} until success. This method can be used - * to implement method {@link Lock#lock}. - * - * @param arg the acquire argument. This value is conveyed to - * {@link #tryAcquire} but is otherwise uninterpreted and - * can represent anything you like. - */ - public final void acquire(int arg) { - if (!tryAcquire(arg) && - acquireQueued(addWaiter(Node.EXCLUSIVE), arg)) - selfInterrupt(); - } - - /** - * Acquires in exclusive mode, aborting if interrupted. - * Implemented by first checking interrupt status, then invoking - * at least once {@link #tryAcquire}, returning on - * success. Otherwise the thread is queued, possibly repeatedly - * blocking and unblocking, invoking {@link #tryAcquire} - * until success or the thread is interrupted. This method can be - * used to implement method {@link Lock#lockInterruptibly}. - * - * @param arg the acquire argument. This value is conveyed to - * {@link #tryAcquire} but is otherwise uninterpreted and - * can represent anything you like. - * @throws InterruptedException if the current thread is interrupted - */ - public final void acquireInterruptibly(int arg) throws InterruptedException { - if (Thread.interrupted()) - throw new InterruptedException(); - if (!tryAcquire(arg)) - doAcquireInterruptibly(arg); - } - - /** - * Attempts to acquire in exclusive mode, aborting if interrupted, - * and failing if the given timeout elapses. Implemented by first - * checking interrupt status, then invoking at least once {@link - * #tryAcquire}, returning on success. Otherwise, the thread is - * queued, possibly repeatedly blocking and unblocking, invoking - * {@link #tryAcquire} until success or the thread is interrupted - * or the timeout elapses. This method can be used to implement - * method {@link Lock#tryLock(long, TimeUnit)}. - * - * @param arg the acquire argument. This value is conveyed to - * {@link #tryAcquire} but is otherwise uninterpreted and - * can represent anything you like. - * @param nanosTimeout the maximum number of nanoseconds to wait - * @return {@code true} if acquired; {@code false} if timed out - * @throws InterruptedException if the current thread is interrupted - */ - public final boolean tryAcquireNanos(int arg, long nanosTimeout) throws InterruptedException { - if (Thread.interrupted()) - throw new InterruptedException(); - return tryAcquire(arg) || - doAcquireNanos(arg, nanosTimeout); - } - - /** - * Releases in exclusive mode. Implemented by unblocking one or - * more threads if {@link #tryRelease} returns true. - * This method can be used to implement method {@link Lock#unlock}. - * - * @param arg the release argument. This value is conveyed to - * {@link #tryRelease} but is otherwise uninterpreted and - * can represent anything you like. - * @return the value returned from {@link #tryRelease} - */ - public final boolean release(int arg) { - if (tryRelease(arg)) { - Node h = head; - if (h != null && h.waitStatus != 0) - unparkSuccessor(h); - return true; - } - return false; - } - - /** - * Acquires in shared mode, ignoring interrupts. Implemented by - * first invoking at least once {@link #tryAcquireShared}, - * returning on success. Otherwise the thread is queued, possibly - * repeatedly blocking and unblocking, invoking {@link - * #tryAcquireShared} until success. - * - * @param arg the acquire argument. This value is conveyed to - * {@link #tryAcquireShared} but is otherwise uninterpreted - * and can represent anything you like. - */ - public final void acquireShared(int arg) { - if (tryAcquireShared(arg) < 0) - doAcquireShared(arg); - } - - /** - * Acquires in shared mode, aborting if interrupted. Implemented - * by first checking interrupt status, then invoking at least once - * {@link #tryAcquireShared}, returning on success. Otherwise the - * thread is queued, possibly repeatedly blocking and unblocking, - * invoking {@link #tryAcquireShared} until success or the thread - * is interrupted. - * @param arg the acquire argument - * This value is conveyed to {@link #tryAcquireShared} but is - * otherwise uninterpreted and can represent anything - * you like. - * @throws InterruptedException if the current thread is interrupted - */ - public final void acquireSharedInterruptibly(int arg) throws InterruptedException { - if (Thread.interrupted()) - throw new InterruptedException(); - if (tryAcquireShared(arg) < 0) - doAcquireSharedInterruptibly(arg); - } - - /** - * Attempts to acquire in shared mode, aborting if interrupted, and - * failing if the given timeout elapses. Implemented by first - * checking interrupt status, then invoking at least once {@link - * #tryAcquireShared}, returning on success. Otherwise, the - * thread is queued, possibly repeatedly blocking and unblocking, - * invoking {@link #tryAcquireShared} until success or the thread - * is interrupted or the timeout elapses. - * - * @param arg the acquire argument. This value is conveyed to - * {@link #tryAcquireShared} but is otherwise uninterpreted - * and can represent anything you like. - * @param nanosTimeout the maximum number of nanoseconds to wait - * @return {@code true} if acquired; {@code false} if timed out - * @throws InterruptedException if the current thread is interrupted - */ - public final boolean tryAcquireSharedNanos(int arg, long nanosTimeout) throws InterruptedException { - if (Thread.interrupted()) - throw new InterruptedException(); - return tryAcquireShared(arg) >= 0 || - doAcquireSharedNanos(arg, nanosTimeout); - } - - /** - * Releases in shared mode. Implemented by unblocking one or more - * threads if {@link #tryReleaseShared} returns true. - * - * @param arg the release argument. This value is conveyed to - * {@link #tryReleaseShared} but is otherwise uninterpreted - * and can represent anything you like. - * @return the value returned from {@link #tryReleaseShared} - */ - public final boolean releaseShared(int arg) { - if (tryReleaseShared(arg)) { - doReleaseShared(); - return true; - } - return false; - } - - // Queue inspection methods - - /** - * Queries whether any threads are waiting to acquire. Note that - * because cancellations due to interrupts and timeouts may occur - * at any time, a {@code true} return does not guarantee that any - * other thread will ever acquire. - * - *

In this implementation, this operation returns in - * constant time. - * - * @return {@code true} if there may be other threads waiting to acquire - */ - public final boolean hasQueuedThreads() { - return head != tail; - } - - /** - * Queries whether any threads have ever contended to acquire this - * synchronizer; that is if an acquire method has ever blocked. - * - *

In this implementation, this operation returns in - * constant time. - * - * @return {@code true} if there has ever been contention - */ - public final boolean hasContended() { - return head != null; - } - - /** - * Returns the first (longest-waiting) thread in the queue, or - * {@code null} if no threads are currently queued. - * - *

In this implementation, this operation normally returns in - * constant time, but may iterate upon contention if other threads are - * concurrently modifying the queue. - * - * @return the first (longest-waiting) thread in the queue, or - * {@code null} if no threads are currently queued - */ - public final Thread getFirstQueuedThread() { - // handle only fast path, else relay - return (head == tail) ? null : fullGetFirstQueuedThread(); - } - - /** - * Version of getFirstQueuedThread called when fastpath fails - */ - private Thread fullGetFirstQueuedThread() { - /* - * The first node is normally head.next. Try to get its - * thread field, ensuring consistent reads: If thread - * field is nulled out or s.prev is no longer head, then - * some other thread(s) concurrently performed setHead in - * between some of our reads. We try this twice before - * resorting to traversal. - */ - Node h, s; - Thread st; - if (((h = head) != null && (s = h.next) != null && - s.prev == head && (st = s.thread) != null) || - ((h = head) != null && (s = h.next) != null && - s.prev == head && (st = s.thread) != null)) - return st; - - /* - * Head's next field might not have been set yet, or may have - * been unset after setHead. So we must check to see if tail - * is actually first node. If not, we continue on, safely - * traversing from tail back to head to find first, - * guaranteeing termination. - */ - - Node t = tail; - Thread firstThread = null; - while (t != null && t != head) { - Thread tt = t.thread; - if (tt != null) - firstThread = tt; - t = t.prev; - } - return firstThread; - } - - /** - * Returns true if the given thread is currently queued. - * - *

This implementation traverses the queue to determine - * presence of the given thread. - * - * @param thread the thread - * @return {@code true} if the given thread is on the queue - * @throws NullPointerException if the thread is null - */ - public final boolean isQueued(Thread thread) { - if (thread == null) - throw new NullPointerException(); - for (Node p = tail; p != null; p = p.prev) - if (p.thread == thread) - return true; - return false; - } - - /** - * Returns {@code true} if the apparent first queued thread, if one - * exists, is waiting in exclusive mode. If this method returns - * {@code true}, and the current thread is attempting to acquire in - * shared mode (that is, this method is invoked from {@link - * #tryAcquireShared}) then it is guaranteed that the current thread - * is not the first queued thread. Used only as a heuristic in - * ReentrantReadWriteLock. - */ - final boolean apparentlyFirstQueuedIsExclusive() { - Node h, s; - return (h = head) != null && - (s = h.next) != null && - !s.isShared() && - s.thread != null; - } - - /** - * Queries whether any threads have been waiting to acquire longer - * than the current thread. - * - *

An invocation of this method is equivalent to (but may be - * more efficient than): - *

 {@code
-     * getFirstQueuedThread() != Thread.currentThread() &&
-     * hasQueuedThreads()}
- * - *

Note that because cancellations due to interrupts and - * timeouts may occur at any time, a {@code true} return does not - * guarantee that some other thread will acquire before the current - * thread. Likewise, it is possible for another thread to win a - * race to enqueue after this method has returned {@code false}, - * due to the queue being empty. - * - *

This method is designed to be used by a fair synchronizer to - * avoid barging. - * Such a synchronizer's {@link #tryAcquire} method should return - * {@code false}, and its {@link #tryAcquireShared} method should - * return a negative value, if this method returns {@code true} - * (unless this is a reentrant acquire). For example, the {@code - * tryAcquire} method for a fair, reentrant, exclusive mode - * synchronizer might look like this: - * - *

 {@code
-     * protected boolean tryAcquire(int arg) {
-     *   if (isHeldExclusively()) {
-     *     // A reentrant acquire; increment hold count
-     *     return true;
-     *   } else if (hasQueuedPredecessors()) {
-     *     return false;
-     *   } else {
-     *     // try to acquire normally
-     *   }
-     * }}
- * - * @return {@code true} if there is a queued thread preceding the - * current thread, and {@code false} if the current thread - * is at the head of the queue or the queue is empty - */ - final boolean hasQueuedPredecessors() { - // The correctness of this depends on head being initialized - // before tail and on head.next being accurate if the current - // thread is first in queue. - Node t = tail; // Read fields in reverse initialization order - Node h = head; - Node s; - return h != t && - ((s = h.next) == null || s.thread != Thread.currentThread()); - } - - - // Instrumentation and monitoring methods - - /** - * Returns an estimate of the number of threads waiting to - * acquire. The value is only an estimate because the number of - * threads may change dynamically while this method traverses - * internal data structures. This method is designed for use in - * monitoring system state, not for synchronization - * control. - * - * @return the estimated number of threads waiting to acquire - */ - public final int getQueueLength() { - int n = 0; - for (Node p = tail; p != null; p = p.prev) { - if (p.thread != null) - ++n; - } - return n; - } - - /** - * Returns a collection containing threads that may be waiting to - * acquire. Because the actual set of threads may change - * dynamically while constructing this result, the returned - * collection is only a best-effort estimate. The elements of the - * returned collection are in no particular order. This method is - * designed to facilitate construction of subclasses that provide - * more extensive monitoring facilities. - * - * @return the collection of threads - */ - public final Collection getQueuedThreads() { - ArrayList list = new ArrayList(); - for (Node p = tail; p != null; p = p.prev) { - Thread t = p.thread; - if (t != null) - list.add(t); - } - return list; - } - - /** - * Returns a collection containing threads that may be waiting to - * acquire in exclusive mode. This has the same properties - * as {@link #getQueuedThreads} except that it only returns - * those threads waiting due to an exclusive acquire. - * - * @return the collection of threads - */ - public final Collection getExclusiveQueuedThreads() { - ArrayList list = new ArrayList(); - for (Node p = tail; p != null; p = p.prev) { - if (!p.isShared()) { - Thread t = p.thread; - if (t != null) - list.add(t); - } - } - return list; - } - - /** - * Returns a collection containing threads that may be waiting to - * acquire in shared mode. This has the same properties - * as {@link #getQueuedThreads} except that it only returns - * those threads waiting due to a shared acquire. - * - * @return the collection of threads - */ - public final Collection getSharedQueuedThreads() { - ArrayList list = new ArrayList(); - for (Node p = tail; p != null; p = p.prev) { - if (p.isShared()) { - Thread t = p.thread; - if (t != null) - list.add(t); - } - } - return list; - } - - /** - * Returns a string identifying this synchronizer, as well as its state. - * The state, in brackets, includes the String {@code "State ="} - * followed by the current value of {@link #getState}, and either - * {@code "nonempty"} or {@code "empty"} depending on whether the - * queue is empty. - * - * @return a string identifying this synchronizer, as well as its state - */ - public String toString() { - int s = getState(); - String q = hasQueuedThreads() ? "non" : ""; - return super.toString() + - "[State = " + s + ", " + q + "empty queue]"; - } - - - // Internal support methods for Conditions - - /** - * Returns true if a node, always one that was initially placed on - * a condition queue, is now waiting to reacquire on sync queue. - * @param node the node - * @return true if is reacquiring - */ - final boolean isOnSyncQueue(Node node) { - if (node.waitStatus == Node.CONDITION || node.prev == null) - return false; - if (node.next != null) // If has successor, it must be on queue - return true; - /* - * node.prev can be non-null, but not yet on queue because - * the CAS to place it on queue can fail. So we have to - * traverse from tail to make sure it actually made it. It - * will always be near the tail in calls to this method, and - * unless the CAS failed (which is unlikely), it will be - * there, so we hardly ever traverse much. - */ - return findNodeFromTail(node); - } - - /** - * Returns true if node is on sync queue by searching backwards from tail. - * Called only when needed by isOnSyncQueue. - * @return true if present - */ - private boolean findNodeFromTail(Node node) { - Node t = tail; - for (;;) { - if (t == node) - return true; - if (t == null) - return false; - t = t.prev; - } - } - - /** - * Transfers a node from a condition queue onto sync queue. - * Returns true if successful. - * @param node the node - * @return true if successfully transferred (else the node was - * cancelled before signal). - */ - final boolean transferForSignal(Node node) { - /* - * If cannot change waitStatus, the node has been cancelled. - */ - if (!compareAndSetWaitStatus(node, Node.CONDITION, 0)) - return false; - - /* - * Splice onto queue and try to set waitStatus of predecessor to - * indicate that thread is (probably) waiting. If cancelled or - * attempt to set waitStatus fails, wake up to resync (in which - * case the waitStatus can be transiently and harmlessly wrong). - */ - Node p = enq(node); - int ws = p.waitStatus; - if (ws > 0 || !compareAndSetWaitStatus(p, ws, Node.SIGNAL)) - LockSupport.unpark(node.thread); - return true; - } - - /** - * Transfers node, if necessary, to sync queue after a cancelled - * wait. Returns true if thread was cancelled before being - * signalled. - * @param node its node - * @return true if cancelled before the node was signalled - */ - final boolean transferAfterCancelledWait(Node node) { - if (compareAndSetWaitStatus(node, Node.CONDITION, 0)) { - enq(node); - return true; - } - /* - * If we lost out to a signal(), then we can't proceed - * until it finishes its enq(). Cancelling during an - * incomplete transfer is both rare and transient, so just - * spin. - */ - while (!isOnSyncQueue(node)) - Thread.yield(); - return false; - } - - /** - * Invokes release with current state value; returns saved state. - * Cancels node and throws exception on failure. - * @param node the condition node for this wait - * @return previous sync state - */ - final int fullyRelease(Node node) { - boolean failed = true; - try { - int savedState = getState(); - if (release(savedState)) { - failed = false; - return savedState; - } else { - throw new IllegalMonitorStateException(); - } - } finally { - if (failed) - node.waitStatus = Node.CANCELLED; - } - } - - // Instrumentation methods for conditions - - /** - * Queries whether the given ConditionObject - * uses this synchronizer as its lock. - * - * @param condition the condition - * @return true if owned - * @throws NullPointerException if the condition is null - */ - public final boolean owns(ConditionObject condition) { - if (condition == null) - throw new NullPointerException(); - return condition.isOwnedBy(this); - } - - /** - * Queries whether any threads are waiting on the given condition - * associated with this synchronizer. Note that because timeouts - * and interrupts may occur at any time, a true return - * does not guarantee that a future signal will awaken - * any threads. This method is designed primarily for use in - * monitoring of the system state. - * - * @param condition the condition - * @return true if there are any waiting threads - * @throws IllegalMonitorStateException if exclusive synchronization - * is not held - * @throws IllegalArgumentException if the given condition is - * not associated with this synchronizer - * @throws NullPointerException if the condition is null - */ - public final boolean hasWaiters(ConditionObject condition) { - if (!owns(condition)) - throw new IllegalArgumentException("Not owner"); - return condition.hasWaiters(); - } - - /** - * Returns an estimate of the number of threads waiting on the - * given condition associated with this synchronizer. Note that - * because timeouts and interrupts may occur at any time, the - * estimate serves only as an upper bound on the actual number of - * waiters. This method is designed for use in monitoring of the - * system state, not for synchronization control. - * - * @param condition the condition - * @return the estimated number of waiting threads - * @throws IllegalMonitorStateException if exclusive synchronization - * is not held - * @throws IllegalArgumentException if the given condition is - * not associated with this synchronizer - * @throws NullPointerException if the condition is null - */ - public final int getWaitQueueLength(ConditionObject condition) { - if (!owns(condition)) - throw new IllegalArgumentException("Not owner"); - return condition.getWaitQueueLength(); - } - - /** - * Returns a collection containing those threads that may be - * waiting on the given condition associated with this - * synchronizer. Because the actual set of threads may change - * dynamically while constructing this result, the returned - * collection is only a best-effort estimate. The elements of the - * returned collection are in no particular order. - * - * @param condition the condition - * @return the collection of threads - * @throws IllegalMonitorStateException if exclusive synchronization - * is not held - * @throws IllegalArgumentException if the given condition is - * not associated with this synchronizer - * @throws NullPointerException if the condition is null - */ - public final Collection getWaitingThreads(ConditionObject condition) { - if (!owns(condition)) - throw new IllegalArgumentException("Not owner"); - return condition.getWaitingThreads(); - } - - /** - * Condition implementation for a {@link - * AbstractQueuedSynchronizer} serving as the basis of a {@link - * Lock} implementation. - * - *

Method documentation for this class describes mechanics, - * not behavioral specifications from the point of view of Lock - * and Condition users. Exported versions of this class will in - * general need to be accompanied by documentation describing - * condition semantics that rely on those of the associated - * AbstractQueuedSynchronizer. - * - *

This class is Serializable, but all fields are transient, - * so deserialized conditions have no waiters. - */ - public class ConditionObject implements Condition, java.io.Serializable { - private static final long serialVersionUID = 1173984872572414699L; - /** First node of condition queue. */ - private transient Node firstWaiter; - /** Last node of condition queue. */ - private transient Node lastWaiter; - - /** - * Creates a new ConditionObject instance. - */ - public ConditionObject() { } - - // Internal methods - - /** - * Adds a new waiter to wait queue. - * @return its new wait node - */ - private Node addConditionWaiter() { - Node t = lastWaiter; - // If lastWaiter is cancelled, clean out. - if (t != null && t.waitStatus != Node.CONDITION) { - unlinkCancelledWaiters(); - t = lastWaiter; - } - Node node = new Node(Thread.currentThread(), Node.CONDITION); - if (t == null) - firstWaiter = node; - else - t.nextWaiter = node; - lastWaiter = node; - return node; - } - - /** - * Removes and transfers nodes until hit non-cancelled one or - * null. Split out from signal in part to encourage compilers - * to inline the case of no waiters. - * @param first (non-null) the first node on condition queue - */ - private void doSignal(Node first) { - do { - if ( (firstWaiter = first.nextWaiter) == null) - lastWaiter = null; - first.nextWaiter = null; - } while (!transferForSignal(first) && - (first = firstWaiter) != null); - } - - /** - * Removes and transfers all nodes. - * @param first (non-null) the first node on condition queue - */ - private void doSignalAll(Node first) { - lastWaiter = firstWaiter = null; - do { - Node next = first.nextWaiter; - first.nextWaiter = null; - transferForSignal(first); - first = next; - } while (first != null); - } - - /** - * Unlinks cancelled waiter nodes from condition queue. - * Called only while holding lock. This is called when - * cancellation occurred during condition wait, and upon - * insertion of a new waiter when lastWaiter is seen to have - * been cancelled. This method is needed to avoid garbage - * retention in the absence of signals. So even though it may - * require a full traversal, it comes into play only when - * timeouts or cancellations occur in the absence of - * signals. It traverses all nodes rather than stopping at a - * particular target to unlink all pointers to garbage nodes - * without requiring many re-traversals during cancellation - * storms. - */ - private void unlinkCancelledWaiters() { - Node t = firstWaiter; - Node trail = null; - while (t != null) { - Node next = t.nextWaiter; - if (t.waitStatus != Node.CONDITION) { - t.nextWaiter = null; - if (trail == null) - firstWaiter = next; - else - trail.nextWaiter = next; - if (next == null) - lastWaiter = trail; - } - else - trail = t; - t = next; - } - } - - // public methods - - /** - * Moves the longest-waiting thread, if one exists, from the - * wait queue for this condition to the wait queue for the - * owning lock. - * - * @throws IllegalMonitorStateException if {@link #isHeldExclusively} - * returns {@code false} - */ - public final void signal() { - if (!isHeldExclusively()) - throw new IllegalMonitorStateException(); - Node first = firstWaiter; - if (first != null) - doSignal(first); - } - - /** - * Moves all threads from the wait queue for this condition to - * the wait queue for the owning lock. - * - * @throws IllegalMonitorStateException if {@link #isHeldExclusively} - * returns {@code false} - */ - public final void signalAll() { - if (!isHeldExclusively()) - throw new IllegalMonitorStateException(); - Node first = firstWaiter; - if (first != null) - doSignalAll(first); - } - - /** - * Implements uninterruptible condition wait. - *

    - *
  1. Save lock state returned by {@link #getState}. - *
  2. Invoke {@link #release} with - * saved state as argument, throwing - * IllegalMonitorStateException if it fails. - *
  3. Block until signalled. - *
  4. Reacquire by invoking specialized version of - * {@link #acquire} with saved state as argument. - *
- */ - public final void awaitUninterruptibly() { - Node node = addConditionWaiter(); - int savedState = fullyRelease(node); - boolean interrupted = false; - while (!isOnSyncQueue(node)) { - LockSupport.park(); - if (Thread.interrupted()) - interrupted = true; - } - if (acquireQueued(node, savedState) || interrupted) - selfInterrupt(); - } - - /* - * For interruptible waits, we need to track whether to throw - * InterruptedException, if interrupted while blocked on - * condition, versus reinterrupt current thread, if - * interrupted while blocked waiting to re-acquire. - */ - - /** Mode meaning to reinterrupt on exit from wait */ - private static final int REINTERRUPT = 1; - /** Mode meaning to throw InterruptedException on exit from wait */ - private static final int THROW_IE = -1; - - /** - * Checks for interrupt, returning THROW_IE if interrupted - * before signalled, REINTERRUPT if after signalled, or - * 0 if not interrupted. - */ - private int checkInterruptWhileWaiting(Node node) { - return Thread.interrupted() ? - (transferAfterCancelledWait(node) ? THROW_IE : REINTERRUPT) : - 0; - } - - /** - * Throws InterruptedException, reinterrupts current thread, or - * does nothing, depending on mode. - */ - private void reportInterruptAfterWait(int interruptMode) - throws InterruptedException { - if (interruptMode == THROW_IE) - throw new InterruptedException(); - else if (interruptMode == REINTERRUPT) - selfInterrupt(); - } - - /** - * Implements interruptible condition wait. - *
    - *
  1. If current thread is interrupted, throw InterruptedException. - *
  2. Save lock state returned by {@link #getState}. - *
  3. Invoke {@link #release} with - * saved state as argument, throwing - * IllegalMonitorStateException if it fails. - *
  4. Block until signalled or interrupted. - *
  5. Reacquire by invoking specialized version of - * {@link #acquire} with saved state as argument. - *
  6. If interrupted while blocked in step 4, throw InterruptedException. - *
- * - * @throws InterruptedException if the current thread is interrupted (and - * interruption of thread suspension is supported). - */ - public final void await() throws InterruptedException { - if (Thread.interrupted()) - throw new InterruptedException(); - Node node = addConditionWaiter(); - int savedState = fullyRelease(node); - int interruptMode = 0; - while (!isOnSyncQueue(node)) { - LockSupport.park(); - if ((interruptMode = checkInterruptWhileWaiting(node)) != 0) - break; - } - if (acquireQueued(node, savedState) && interruptMode != THROW_IE) - interruptMode = REINTERRUPT; - if (node.nextWaiter != null) // clean up if cancelled - unlinkCancelledWaiters(); - if (interruptMode != 0) - reportInterruptAfterWait(interruptMode); - } - - /** - * Implements timed condition wait. - *
    - *
  1. If current thread is interrupted, throw InterruptedException. - *
  2. Save lock state returned by {@link #getState}. - *
  3. Invoke {@link #release} with - * saved state as argument, throwing - * IllegalMonitorStateException if it fails. - *
  4. Block until signalled, interrupted, or timed out. - *
  5. Reacquire by invoking specialized version of - * {@link #acquire} with saved state as argument. - *
  6. If interrupted while blocked in step 4, throw InterruptedException. - *
- * - * @param nanosTimeout the maximum time to wait, in nanoseconds - * @return A value less than or equal to zero if the wait has - * timed out; otherwise an estimate, that - * is strictly less than the nanosTimeout argument, - * of the time still remaining when this method returned. - * - * @throws InterruptedException if the current thread is interrupted (and - * interruption of thread suspension is supported). - */ - public final long awaitNanos(long nanosTimeout) throws InterruptedException { - if (Thread.interrupted()) - throw new InterruptedException(); - Node node = addConditionWaiter(); - int savedState = fullyRelease(node); - long lastTime = System.nanoTime(); - int interruptMode = 0; - while (!isOnSyncQueue(node)) { - if (nanosTimeout <= 0L) { - transferAfterCancelledWait(node); - break; - } - LockSupport.parkNanos(nanosTimeout); - if ((interruptMode = checkInterruptWhileWaiting(node)) != 0) - break; - - long now = System.nanoTime(); - nanosTimeout -= now - lastTime; - lastTime = now; - } - if (acquireQueued(node, savedState) && interruptMode != THROW_IE) - interruptMode = REINTERRUPT; - if (node.nextWaiter != null) - unlinkCancelledWaiters(); - if (interruptMode != 0) - reportInterruptAfterWait(interruptMode); - return nanosTimeout - (System.nanoTime() - lastTime); - } - - /** - * Implements absolute timed condition wait. - *
    - *
  1. If current thread is interrupted, throw InterruptedException. - *
  2. Save lock state returned by {@link #getState}. - *
  3. Invoke {@link #release} with - * saved state as argument, throwing - * IllegalMonitorStateException if it fails. - *
  4. Block until signalled, interrupted, or timed out. - *
  5. Reacquire by invoking specialized version of - * {@link #acquire} with saved state as argument. - *
  6. If interrupted while blocked in step 4, throw InterruptedException. - *
  7. If timed out while blocked in step 4, return false, else true. - *
- * - * @param deadline the absolute time to wait until - * @return false if the deadline has - * elapsed upon return, else true. - * - * @throws InterruptedException if the current thread is interrupted (and - * interruption of thread suspension is supported). - */ - public final boolean awaitUntil(Date deadline) throws InterruptedException { - if (deadline == null) - throw new NullPointerException(); - long abstime = deadline.getTime(); - if (Thread.interrupted()) - throw new InterruptedException(); - Node node = addConditionWaiter(); - int savedState = fullyRelease(node); - boolean timedout = false; - int interruptMode = 0; - while (!isOnSyncQueue(node)) { - if (System.currentTimeMillis() > abstime) { - timedout = transferAfterCancelledWait(node); - break; - } - LockSupport.parkUntil(abstime); - if ((interruptMode = checkInterruptWhileWaiting(node)) != 0) - break; - } - if (acquireQueued(node, savedState) && interruptMode != THROW_IE) - interruptMode = REINTERRUPT; - if (node.nextWaiter != null) - unlinkCancelledWaiters(); - if (interruptMode != 0) - reportInterruptAfterWait(interruptMode); - return !timedout; - } - - /** - * Implements timed condition wait. - *
    - *
  1. If current thread is interrupted, throw InterruptedException. - *
  2. Save lock state returned by {@link #getState}. - *
  3. Invoke {@link #release} with - * saved state as argument, throwing - * IllegalMonitorStateException if it fails. - *
  4. Block until signalled, interrupted, or timed out. - *
  5. Reacquire by invoking specialized version of - * {@link #acquire} with saved state as argument. - *
  6. If interrupted while blocked in step 4, throw InterruptedException. - *
  7. If timed out while blocked in step 4, return false, else true. - *
- * - * @param time the maximum time to wait - * @param unit the time unit of the time argument. - * @return false if the waiting time detectably elapsed - * before return from the method, else true. - * @throws InterruptedException if the current thread is interrupted (and - * interruption of thread suspension is supported). - */ - public final boolean await(long time, TimeUnit unit) throws InterruptedException { - if (unit == null) - throw new NullPointerException(); - long nanosTimeout = unit.toNanos(time); - if (Thread.interrupted()) - throw new InterruptedException(); - Node node = addConditionWaiter(); - int savedState = fullyRelease(node); - long lastTime = System.nanoTime(); - boolean timedout = false; - int interruptMode = 0; - while (!isOnSyncQueue(node)) { - if (nanosTimeout <= 0L) { - timedout = transferAfterCancelledWait(node); - break; - } - if (nanosTimeout >= spinForTimeoutThreshold) - LockSupport.parkNanos(nanosTimeout); - if ((interruptMode = checkInterruptWhileWaiting(node)) != 0) - break; - long now = System.nanoTime(); - nanosTimeout -= now - lastTime; - lastTime = now; - } - if (acquireQueued(node, savedState) && interruptMode != THROW_IE) - interruptMode = REINTERRUPT; - if (node.nextWaiter != null) - unlinkCancelledWaiters(); - if (interruptMode != 0) - reportInterruptAfterWait(interruptMode); - return !timedout; - } - - // support for instrumentation - - /** - * Returns true if this condition was created by the given - * synchronization object. - * - * @return {@code true} if owned - */ - final boolean isOwnedBy(AbstractQueuedSynchronizer sync) { - return sync == AbstractQueuedSynchronizer.this; - } - - /** - * Queries whether any threads are waiting on this condition. - * Implements {@link AbstractQueuedSynchronizer#hasWaiters}. - * - * @return {@code true} if there are any waiting threads - * @throws IllegalMonitorStateException if {@link #isHeldExclusively} - * returns {@code false} - */ - protected final boolean hasWaiters() { - if (!isHeldExclusively()) - throw new IllegalMonitorStateException(); - for (Node w = firstWaiter; w != null; w = w.nextWaiter) { - if (w.waitStatus == Node.CONDITION) - return true; - } - return false; - } - - /** - * Returns an estimate of the number of threads waiting on - * this condition. - * Implements {@link AbstractQueuedSynchronizer#getWaitQueueLength}. - * - * @return the estimated number of waiting threads - * @throws IllegalMonitorStateException if {@link #isHeldExclusively} - * returns {@code false} - */ - protected final int getWaitQueueLength() { - if (!isHeldExclusively()) - throw new IllegalMonitorStateException(); - int n = 0; - for (Node w = firstWaiter; w != null; w = w.nextWaiter) { - if (w.waitStatus == Node.CONDITION) - ++n; - } - return n; - } - - /** - * Returns a collection containing those threads that may be - * waiting on this Condition. - * Implements {@link AbstractQueuedSynchronizer#getWaitingThreads}. - * - * @return the collection of threads - * @throws IllegalMonitorStateException if {@link #isHeldExclusively} - * returns {@code false} - */ - protected final Collection getWaitingThreads() { - if (!isHeldExclusively()) - throw new IllegalMonitorStateException(); - ArrayList list = new ArrayList(); - for (Node w = firstWaiter; w != null; w = w.nextWaiter) { - if (w.waitStatus == Node.CONDITION) { - Thread t = w.thread; - if (t != null) - list.add(t); - } - } - return list; - } - } - - /** - * Setup to support compareAndSet. We need to natively implement - * this here: For the sake of permitting future enhancements, we - * cannot explicitly subclass AtomicInteger, which would be - * efficient and useful otherwise. So, as the lesser of evils, we - * natively implement using hotspot intrinsics API. And while we - * are at it, we do the same for other CASable fields (which could - * otherwise be done with atomic field updaters). - */ - // BEGIN android-changed - private static final Unsafe unsafe = UnsafeAccess.THE_ONE; - // END android-changed - private static final long stateOffset; - private static final long headOffset; - private static final long tailOffset; - private static final long waitStatusOffset; - private static final long nextOffset; - - static { - try { - stateOffset = unsafe.objectFieldOffset - (AbstractQueuedSynchronizer.class.getDeclaredField("state")); - headOffset = unsafe.objectFieldOffset - (AbstractQueuedSynchronizer.class.getDeclaredField("head")); - tailOffset = unsafe.objectFieldOffset - (AbstractQueuedSynchronizer.class.getDeclaredField("tail")); - waitStatusOffset = unsafe.objectFieldOffset - (Node.class.getDeclaredField("waitStatus")); - nextOffset = unsafe.objectFieldOffset - (Node.class.getDeclaredField("next")); - - } catch (Exception ex) { throw new Error(ex); } - } - - /** - * CAS head field. Used only by enq. - */ - private final boolean compareAndSetHead(Node update) { - return unsafe.compareAndSwapObject(this, headOffset, null, update); - } - - /** - * CAS tail field. Used only by enq. - */ - private final boolean compareAndSetTail(Node expect, Node update) { - return unsafe.compareAndSwapObject(this, tailOffset, expect, update); - } - - /** - * CAS waitStatus field of a node. - */ - private final static boolean compareAndSetWaitStatus(Node node, - int expect, - int update) { - return unsafe.compareAndSwapInt(node, waitStatusOffset, - expect, update); - } - - /** - * CAS next field of a node. - */ - private final static boolean compareAndSetNext(Node node, - Node expect, - Node update) { - return unsafe.compareAndSwapObject(node, nextOffset, expect, update); - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/locks/Condition.java b/libcore/concurrent/src/main/java/java/util/concurrent/locks/Condition.java deleted file mode 100644 index 03be58f73..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/locks/Condition.java +++ /dev/null @@ -1,435 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.locks; -import java.util.concurrent.*; -import java.util.Date; - -/** - * {@code Condition} factors out the {@code Object} monitor - * methods ({@link Object#wait() wait}, {@link Object#notify notify} - * and {@link Object#notifyAll notifyAll}) into distinct objects to - * give the effect of having multiple wait-sets per object, by - * combining them with the use of arbitrary {@link Lock} implementations. - * Where a {@code Lock} replaces the use of {@code synchronized} methods - * and statements, a {@code Condition} replaces the use of the Object - * monitor methods. - * - *

Conditions (also known as condition queues or - * condition variables) provide a means for one thread to - * suspend execution (to "wait") until notified by another - * thread that some state condition may now be true. Because access - * to this shared state information occurs in different threads, it - * must be protected, so a lock of some form is associated with the - * condition. The key property that waiting for a condition provides - * is that it atomically releases the associated lock and - * suspends the current thread, just like {@code Object.wait}. - * - *

A {@code Condition} instance is intrinsically bound to a lock. - * To obtain a {@code Condition} instance for a particular {@link Lock} - * instance use its {@link Lock#newCondition newCondition()} method. - * - *

As an example, suppose we have a bounded buffer which supports - * {@code put} and {@code take} methods. If a - * {@code take} is attempted on an empty buffer, then the thread will block - * until an item becomes available; if a {@code put} is attempted on a - * full buffer, then the thread will block until a space becomes available. - * We would like to keep waiting {@code put} threads and {@code take} - * threads in separate wait-sets so that we can use the optimization of - * only notifying a single thread at a time when items or spaces become - * available in the buffer. This can be achieved using two - * {@link Condition} instances. - *

- * class BoundedBuffer {
- *   final Lock lock = new ReentrantLock();
- *   final Condition notFull  = lock.newCondition(); 
- *   final Condition notEmpty = lock.newCondition(); 
- *
- *   final Object[] items = new Object[100];
- *   int putptr, takeptr, count;
- *
- *   public void put(Object x) throws InterruptedException {
- *     lock.lock();
- *     try {
- *       while (count == items.length)
- *         notFull.await();
- *       items[putptr] = x;
- *       if (++putptr == items.length) putptr = 0;
- *       ++count;
- *       notEmpty.signal();
- *     } finally {
- *       lock.unlock();
- *     }
- *   }
- *
- *   public Object take() throws InterruptedException {
- *     lock.lock();
- *     try {
- *       while (count == 0)
- *         notEmpty.await();
- *       Object x = items[takeptr];
- *       if (++takeptr == items.length) takeptr = 0;
- *       --count;
- *       notFull.signal();
- *       return x;
- *     } finally {
- *       lock.unlock();
- *     }
- *   }
- * }
- * 
- * - * (The {@link java.util.concurrent.ArrayBlockingQueue} class provides - * this functionality, so there is no reason to implement this - * sample usage class.) - * - *

A {@code Condition} implementation can provide behavior and semantics - * that is - * different from that of the {@code Object} monitor methods, such as - * guaranteed ordering for notifications, or not requiring a lock to be held - * when performing notifications. - * If an implementation provides such specialized semantics then the - * implementation must document those semantics. - * - *

Note that {@code Condition} instances are just normal objects and can - * themselves be used as the target in a {@code synchronized} statement, - * and can have their own monitor {@link Object#wait wait} and - * {@link Object#notify notification} methods invoked. - * Acquiring the monitor lock of a {@code Condition} instance, or using its - * monitor methods, has no specified relationship with acquiring the - * {@link Lock} associated with that {@code Condition} or the use of its - * {@linkplain #await waiting} and {@linkplain #signal signalling} methods. - * It is recommended that to avoid confusion you never use {@code Condition} - * instances in this way, except perhaps within their own implementation. - * - *

Except where noted, passing a {@code null} value for any parameter - * will result in a {@link NullPointerException} being thrown. - * - *

Implementation Considerations

- * - *

When waiting upon a {@code Condition}, a "spurious - * wakeup" is permitted to occur, in - * general, as a concession to the underlying platform semantics. - * This has little practical impact on most application programs as a - * {@code Condition} should always be waited upon in a loop, testing - * the state predicate that is being waited for. An implementation is - * free to remove the possibility of spurious wakeups but it is - * recommended that applications programmers always assume that they can - * occur and so always wait in a loop. - * - *

The three forms of condition waiting - * (interruptible, non-interruptible, and timed) may differ in their ease of - * implementation on some platforms and in their performance characteristics. - * In particular, it may be difficult to provide these features and maintain - * specific semantics such as ordering guarantees. - * Further, the ability to interrupt the actual suspension of the thread may - * not always be feasible to implement on all platforms. - * - *

Consequently, an implementation is not required to define exactly the - * same guarantees or semantics for all three forms of waiting, nor is it - * required to support interruption of the actual suspension of the thread. - * - *

An implementation is required to - * clearly document the semantics and guarantees provided by each of the - * waiting methods, and when an implementation does support interruption of - * thread suspension then it must obey the interruption semantics as defined - * in this interface. - * - *

As interruption generally implies cancellation, and checks for - * interruption are often infrequent, an implementation can favor responding - * to an interrupt over normal method return. This is true even if it can be - * shown that the interrupt occurred after another action that may have - * unblocked the thread. An implementation should document this behavior. - * - * @since 1.5 - * @author Doug Lea - */ -public interface Condition { - - /** - * Causes the current thread to wait until it is signalled or - * {@linkplain Thread#interrupt interrupted}. - * - *

The lock associated with this {@code Condition} is atomically - * released and the current thread becomes disabled for thread scheduling - * purposes and lies dormant until one of four things happens: - *

    - *
  • Some other thread invokes the {@link #signal} method for this - * {@code Condition} and the current thread happens to be chosen as the - * thread to be awakened; or - *
  • Some other thread invokes the {@link #signalAll} method for this - * {@code Condition}; or - *
  • Some other thread {@linkplain Thread#interrupt interrupts} the - * current thread, and interruption of thread suspension is supported; or - *
  • A "spurious wakeup" occurs. - *
- * - *

In all cases, before this method can return the current thread must - * re-acquire the lock associated with this condition. When the - * thread returns it is guaranteed to hold this lock. - * - *

If the current thread: - *

    - *
  • has its interrupted status set on entry to this method; or - *
  • is {@linkplain Thread#interrupt interrupted} while waiting - * and interruption of thread suspension is supported, - *
- * then {@link InterruptedException} is thrown and the current thread's - * interrupted status is cleared. It is not specified, in the first - * case, whether or not the test for interruption occurs before the lock - * is released. - * - *

Implementation Considerations - * - *

The current thread is assumed to hold the lock associated with this - * {@code Condition} when this method is called. - * It is up to the implementation to determine if this is - * the case and if not, how to respond. Typically, an exception will be - * thrown (such as {@link IllegalMonitorStateException}) and the - * implementation must document that fact. - * - *

An implementation can favor responding to an interrupt over normal - * method return in response to a signal. In that case the implementation - * must ensure that the signal is redirected to another waiting thread, if - * there is one. - * - * @throws InterruptedException if the current thread is interrupted - * (and interruption of thread suspension is supported) - */ - void await() throws InterruptedException; - - /** - * Causes the current thread to wait until it is signalled. - * - *

The lock associated with this condition is atomically - * released and the current thread becomes disabled for thread scheduling - * purposes and lies dormant until one of three things happens: - *

    - *
  • Some other thread invokes the {@link #signal} method for this - * {@code Condition} and the current thread happens to be chosen as the - * thread to be awakened; or - *
  • Some other thread invokes the {@link #signalAll} method for this - * {@code Condition}; or - *
  • A "spurious wakeup" occurs. - *
- * - *

In all cases, before this method can return the current thread must - * re-acquire the lock associated with this condition. When the - * thread returns it is guaranteed to hold this lock. - * - *

If the current thread's interrupted status is set when it enters - * this method, or it is {@linkplain Thread#interrupt interrupted} - * while waiting, it will continue to wait until signalled. When it finally - * returns from this method its interrupted status will still - * be set. - * - *

Implementation Considerations - * - *

The current thread is assumed to hold the lock associated with this - * {@code Condition} when this method is called. - * It is up to the implementation to determine if this is - * the case and if not, how to respond. Typically, an exception will be - * thrown (such as {@link IllegalMonitorStateException}) and the - * implementation must document that fact. - */ - void awaitUninterruptibly(); - - /** - * Causes the current thread to wait until it is signalled or interrupted, - * or the specified waiting time elapses. - * - *

The lock associated with this condition is atomically - * released and the current thread becomes disabled for thread scheduling - * purposes and lies dormant until one of five things happens: - *

    - *
  • Some other thread invokes the {@link #signal} method for this - * {@code Condition} and the current thread happens to be chosen as the - * thread to be awakened; or - *
  • Some other thread invokes the {@link #signalAll} method for this - * {@code Condition}; or - *
  • Some other thread {@linkplain Thread#interrupt interrupts} the - * current thread, and interruption of thread suspension is supported; or - *
  • The specified waiting time elapses; or - *
  • A "spurious wakeup" occurs. - *
- * - *

In all cases, before this method can return the current thread must - * re-acquire the lock associated with this condition. When the - * thread returns it is guaranteed to hold this lock. - * - *

If the current thread: - *

    - *
  • has its interrupted status set on entry to this method; or - *
  • is {@linkplain Thread#interrupt interrupted} while waiting - * and interruption of thread suspension is supported, - *
- * then {@link InterruptedException} is thrown and the current thread's - * interrupted status is cleared. It is not specified, in the first - * case, whether or not the test for interruption occurs before the lock - * is released. - * - *

The method returns an estimate of the number of nanoseconds - * remaining to wait given the supplied {@code nanosTimeout} - * value upon return, or a value less than or equal to zero if it - * timed out. This value can be used to determine whether and how - * long to re-wait in cases where the wait returns but an awaited - * condition still does not hold. Typical uses of this method take - * the following form: - * - *

-     * synchronized boolean aMethod(long timeout, TimeUnit unit) {
-     *   long nanosTimeout = unit.toNanos(timeout);
-     *   while (!conditionBeingWaitedFor) {
-     *     if (nanosTimeout > 0)
-     *         nanosTimeout = theCondition.awaitNanos(nanosTimeout);
-     *      else
-     *        return false;
-     *   }
-     *   // ...
-     * }
-     * 
- * - *

Design note: This method requires a nanosecond argument so - * as to avoid truncation errors in reporting remaining times. - * Such precision loss would make it difficult for programmers to - * ensure that total waiting times are not systematically shorter - * than specified when re-waits occur. - * - *

Implementation Considerations - * - *

The current thread is assumed to hold the lock associated with this - * {@code Condition} when this method is called. - * It is up to the implementation to determine if this is - * the case and if not, how to respond. Typically, an exception will be - * thrown (such as {@link IllegalMonitorStateException}) and the - * implementation must document that fact. - * - *

An implementation can favor responding to an interrupt over normal - * method return in response to a signal, or over indicating the elapse - * of the specified waiting time. In either case the implementation - * must ensure that the signal is redirected to another waiting thread, if - * there is one. - * - * @param nanosTimeout the maximum time to wait, in nanoseconds - * @return an estimate of the {@code nanosTimeout} value minus - * the time spent waiting upon return from this method. - * A positive value may be used as the argument to a - * subsequent call to this method to finish waiting out - * the desired time. A value less than or equal to zero - * indicates that no time remains. - * @throws InterruptedException if the current thread is interrupted - * (and interruption of thread suspension is supported) - */ - long awaitNanos(long nanosTimeout) throws InterruptedException; - - /** - * Causes the current thread to wait until it is signalled or interrupted, - * or the specified waiting time elapses. This method is behaviorally - * equivalent to:
- *

-     *   awaitNanos(unit.toNanos(time)) > 0
-     * 
- * @param time the maximum time to wait - * @param unit the time unit of the {@code time} argument - * @return {@code false} if the waiting time detectably elapsed - * before return from the method, else {@code true} - * @throws InterruptedException if the current thread is interrupted - * (and interruption of thread suspension is supported) - */ - boolean await(long time, TimeUnit unit) throws InterruptedException; - - /** - * Causes the current thread to wait until it is signalled or interrupted, - * or the specified deadline elapses. - * - *

The lock associated with this condition is atomically - * released and the current thread becomes disabled for thread scheduling - * purposes and lies dormant until one of five things happens: - *

    - *
  • Some other thread invokes the {@link #signal} method for this - * {@code Condition} and the current thread happens to be chosen as the - * thread to be awakened; or - *
  • Some other thread invokes the {@link #signalAll} method for this - * {@code Condition}; or - *
  • Some other thread {@linkplain Thread#interrupt interrupts} the - * current thread, and interruption of thread suspension is supported; or - *
  • The specified deadline elapses; or - *
  • A "spurious wakeup" occurs. - *
- * - *

In all cases, before this method can return the current thread must - * re-acquire the lock associated with this condition. When the - * thread returns it is guaranteed to hold this lock. - * - * - *

If the current thread: - *

    - *
  • has its interrupted status set on entry to this method; or - *
  • is {@linkplain Thread#interrupt interrupted} while waiting - * and interruption of thread suspension is supported, - *
- * then {@link InterruptedException} is thrown and the current thread's - * interrupted status is cleared. It is not specified, in the first - * case, whether or not the test for interruption occurs before the lock - * is released. - * - * - *

The return value indicates whether the deadline has elapsed, - * which can be used as follows: - *

-     * synchronized boolean aMethod(Date deadline) {
-     *   boolean stillWaiting = true;
-     *   while (!conditionBeingWaitedFor) {
-     *     if (stillWaiting)
-     *         stillWaiting = theCondition.awaitUntil(deadline);
-     *      else
-     *        return false;
-     *   }
-     *   // ...
-     * }
-     * 
- * - *

Implementation Considerations - * - *

The current thread is assumed to hold the lock associated with this - * {@code Condition} when this method is called. - * It is up to the implementation to determine if this is - * the case and if not, how to respond. Typically, an exception will be - * thrown (such as {@link IllegalMonitorStateException}) and the - * implementation must document that fact. - * - *

An implementation can favor responding to an interrupt over normal - * method return in response to a signal, or over indicating the passing - * of the specified deadline. In either case the implementation - * must ensure that the signal is redirected to another waiting thread, if - * there is one. - * - * @param deadline the absolute time to wait until - * @return {@code false} if the deadline has elapsed upon return, else - * {@code true} - * @throws InterruptedException if the current thread is interrupted - * (and interruption of thread suspension is supported) - */ - boolean awaitUntil(Date deadline) throws InterruptedException; - - /** - * Wakes up one waiting thread. - * - *

If any threads are waiting on this condition then one - * is selected for waking up. That thread must then re-acquire the - * lock before returning from {@code await}. - */ - void signal(); - - /** - * Wakes up all waiting threads. - * - *

If any threads are waiting on this condition then they are - * all woken up. Each thread must re-acquire the lock before it can - * return from {@code await}. - */ - void signalAll(); -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/locks/Lock.java b/libcore/concurrent/src/main/java/java/util/concurrent/locks/Lock.java deleted file mode 100644 index 4b9abd665..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/locks/Lock.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.locks; -import java.util.concurrent.TimeUnit; - -/** - * {@code Lock} implementations provide more extensive locking - * operations than can be obtained using {@code synchronized} methods - * and statements. They allow more flexible structuring, may have - * quite different properties, and may support multiple associated - * {@link Condition} objects. - * - *

A lock is a tool for controlling access to a shared resource by - * multiple threads. Commonly, a lock provides exclusive access to a - * shared resource: only one thread at a time can acquire the lock and - * all access to the shared resource requires that the lock be - * acquired first. However, some locks may allow concurrent access to - * a shared resource, such as the read lock of a {@link ReadWriteLock}. - * - *

The use of {@code synchronized} methods or statements provides - * access to the implicit monitor lock associated with every object, but - * forces all lock acquisition and release to occur in a block-structured way: - * when multiple locks are acquired they must be released in the opposite - * order, and all locks must be released in the same lexical scope in which - * they were acquired. - * - *

While the scoping mechanism for {@code synchronized} methods - * and statements makes it much easier to program with monitor locks, - * and helps avoid many common programming errors involving locks, - * there are occasions where you need to work with locks in a more - * flexible way. For example, some algorithms for traversing - * concurrently accessed data structures require the use of - * "hand-over-hand" or "chain locking": you - * acquire the lock of node A, then node B, then release A and acquire - * C, then release B and acquire D and so on. Implementations of the - * {@code Lock} interface enable the use of such techniques by - * allowing a lock to be acquired and released in different scopes, - * and allowing multiple locks to be acquired and released in any - * order. - * - *

With this increased flexibility comes additional - * responsibility. The absence of block-structured locking removes the - * automatic release of locks that occurs with {@code synchronized} - * methods and statements. In most cases, the following idiom - * should be used: - * - *

     Lock l = ...;
- *     l.lock();
- *     try {
- *         // access the resource protected by this lock
- *     } finally {
- *         l.unlock();
- *     }
- * 
- * - * When locking and unlocking occur in different scopes, care must be - * taken to ensure that all code that is executed while the lock is - * held is protected by try-finally or try-catch to ensure that the - * lock is released when necessary. - * - *

{@code Lock} implementations provide additional functionality - * over the use of {@code synchronized} methods and statements by - * providing a non-blocking attempt to acquire a lock ({@link - * #tryLock()}), an attempt to acquire the lock that can be - * interrupted ({@link #lockInterruptibly}, and an attempt to acquire - * the lock that can timeout ({@link #tryLock(long, TimeUnit)}). - * - *

A {@code Lock} class can also provide behavior and semantics - * that is quite different from that of the implicit monitor lock, - * such as guaranteed ordering, non-reentrant usage, or deadlock - * detection. If an implementation provides such specialized semantics - * then the implementation must document those semantics. - * - *

Note that {@code Lock} instances are just normal objects and can - * themselves be used as the target in a {@code synchronized} statement. - * Acquiring the - * monitor lock of a {@code Lock} instance has no specified relationship - * with invoking any of the {@link #lock} methods of that instance. - * It is recommended that to avoid confusion you never use {@code Lock} - * instances in this way, except within their own implementation. - * - *

Except where noted, passing a {@code null} value for any - * parameter will result in a {@link NullPointerException} being - * thrown. - * - *

Memory Synchronization

- * - *

All {@code Lock} implementations must enforce the same - * memory synchronization semantics as provided by the built-in monitor - * lock, as described in - * The Java Language Specification, Third Edition (17.4 Memory Model): - *

    - *
  • A successful {@code lock} operation has the same memory - * synchronization effects as a successful Lock action. - *
  • A successful {@code unlock} operation has the same - * memory synchronization effects as a successful Unlock action. - *
- * - * Unsuccessful locking and unlocking operations, and reentrant - * locking/unlocking operations, do not require any memory - * synchronization effects. - * - *

Implementation Considerations

- * - *

The three forms of lock acquisition (interruptible, - * non-interruptible, and timed) may differ in their performance - * characteristics, ordering guarantees, or other implementation - * qualities. Further, the ability to interrupt the ongoing - * acquisition of a lock may not be available in a given {@code Lock} - * class. Consequently, an implementation is not required to define - * exactly the same guarantees or semantics for all three forms of - * lock acquisition, nor is it required to support interruption of an - * ongoing lock acquisition. An implementation is required to clearly - * document the semantics and guarantees provided by each of the - * locking methods. It must also obey the interruption semantics as - * defined in this interface, to the extent that interruption of lock - * acquisition is supported: which is either totally, or only on - * method entry. - * - *

As interruption generally implies cancellation, and checks for - * interruption are often infrequent, an implementation can favor responding - * to an interrupt over normal method return. This is true even if it can be - * shown that the interrupt occurred after another action may have unblocked - * the thread. An implementation should document this behavior. - * - * @see ReentrantLock - * @see Condition - * @see ReadWriteLock - * - * @since 1.5 - * @author Doug Lea - */ -public interface Lock { - - /** - * Acquires the lock. - * - *

If the lock is not available then the current thread becomes - * disabled for thread scheduling purposes and lies dormant until the - * lock has been acquired. - * - *

Implementation Considerations - * - *

A {@code Lock} implementation may be able to detect erroneous use - * of the lock, such as an invocation that would cause deadlock, and - * may throw an (unchecked) exception in such circumstances. The - * circumstances and the exception type must be documented by that - * {@code Lock} implementation. - */ - void lock(); - - /** - * Acquires the lock unless the current thread is - * {@linkplain Thread#interrupt interrupted}. - * - *

Acquires the lock if it is available and returns immediately. - * - *

If the lock is not available then the current thread becomes - * disabled for thread scheduling purposes and lies dormant until - * one of two things happens: - * - *

    - *
  • The lock is acquired by the current thread; or - *
  • Some other thread {@linkplain Thread#interrupt interrupts} the - * current thread, and interruption of lock acquisition is supported. - *
- * - *

If the current thread: - *

    - *
  • has its interrupted status set on entry to this method; or - *
  • is {@linkplain Thread#interrupt interrupted} while acquiring the - * lock, and interruption of lock acquisition is supported, - *
- * then {@link InterruptedException} is thrown and the current thread's - * interrupted status is cleared. - * - *

Implementation Considerations - * - *

The ability to interrupt a lock acquisition in some - * implementations may not be possible, and if possible may be an - * expensive operation. The programmer should be aware that this - * may be the case. An implementation should document when this is - * the case. - * - *

An implementation can favor responding to an interrupt over - * normal method return. - * - *

A {@code Lock} implementation may be able to detect - * erroneous use of the lock, such as an invocation that would - * cause deadlock, and may throw an (unchecked) exception in such - * circumstances. The circumstances and the exception type must - * be documented by that {@code Lock} implementation. - * - * @throws InterruptedException if the current thread is - * interrupted while acquiring the lock (and interruption - * of lock acquisition is supported). - */ - void lockInterruptibly() throws InterruptedException; - - /** - * Acquires the lock only if it is free at the time of invocation. - * - *

Acquires the lock if it is available and returns immediately - * with the value {@code true}. - * If the lock is not available then this method will return - * immediately with the value {@code false}. - * - *

A typical usage idiom for this method would be: - *

-     *      Lock lock = ...;
-     *      if (lock.tryLock()) {
-     *          try {
-     *              // manipulate protected state
-     *          } finally {
-     *              lock.unlock();
-     *          }
-     *      } else {
-     *          // perform alternative actions
-     *      }
-     * 
- * This usage ensures that the lock is unlocked if it was acquired, and - * doesn't try to unlock if the lock was not acquired. - * - * @return {@code true} if the lock was acquired and - * {@code false} otherwise - */ - boolean tryLock(); - - /** - * Acquires the lock if it is free within the given waiting time and the - * current thread has not been {@linkplain Thread#interrupt interrupted}. - * - *

If the lock is available this method returns immediately - * with the value {@code true}. - * If the lock is not available then - * the current thread becomes disabled for thread scheduling - * purposes and lies dormant until one of three things happens: - *

    - *
  • The lock is acquired by the current thread; or - *
  • Some other thread {@linkplain Thread#interrupt interrupts} the - * current thread, and interruption of lock acquisition is supported; or - *
  • The specified waiting time elapses - *
- * - *

If the lock is acquired then the value {@code true} is returned. - * - *

If the current thread: - *

    - *
  • has its interrupted status set on entry to this method; or - *
  • is {@linkplain Thread#interrupt interrupted} while acquiring - * the lock, and interruption of lock acquisition is supported, - *
- * then {@link InterruptedException} is thrown and the current thread's - * interrupted status is cleared. - * - *

If the specified waiting time elapses then the value {@code false} - * is returned. - * If the time is - * less than or equal to zero, the method will not wait at all. - * - *

Implementation Considerations - * - *

The ability to interrupt a lock acquisition in some implementations - * may not be possible, and if possible may - * be an expensive operation. - * The programmer should be aware that this may be the case. An - * implementation should document when this is the case. - * - *

An implementation can favor responding to an interrupt over normal - * method return, or reporting a timeout. - * - *

A {@code Lock} implementation may be able to detect - * erroneous use of the lock, such as an invocation that would cause - * deadlock, and may throw an (unchecked) exception in such circumstances. - * The circumstances and the exception type must be documented by that - * {@code Lock} implementation. - * - * @param time the maximum time to wait for the lock - * @param unit the time unit of the {@code time} argument - * @return {@code true} if the lock was acquired and {@code false} - * if the waiting time elapsed before the lock was acquired - * - * @throws InterruptedException if the current thread is interrupted - * while acquiring the lock (and interruption of lock - * acquisition is supported) - */ - boolean tryLock(long time, TimeUnit unit) throws InterruptedException; - - /** - * Releases the lock. - * - *

Implementation Considerations - * - *

A {@code Lock} implementation will usually impose - * restrictions on which thread can release a lock (typically only the - * holder of the lock can release it) and may throw - * an (unchecked) exception if the restriction is violated. - * Any restrictions and the exception - * type must be documented by that {@code Lock} implementation. - */ - void unlock(); - - /** - * Returns a new {@link Condition} instance that is bound to this - * {@code Lock} instance. - * - *

Before waiting on the condition the lock must be held by the - * current thread. - * A call to {@link Condition#await()} will atomically release the lock - * before waiting and re-acquire the lock before the wait returns. - * - *

Implementation Considerations - * - *

The exact operation of the {@link Condition} instance depends on - * the {@code Lock} implementation and must be documented by that - * implementation. - * - * @return A new {@link Condition} instance for this {@code Lock} instance - * @throws UnsupportedOperationException if this {@code Lock} - * implementation does not support conditions - */ - Condition newCondition(); -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/locks/LockSupport.java b/libcore/concurrent/src/main/java/java/util/concurrent/locks/LockSupport.java deleted file mode 100644 index b55b874d7..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/locks/LockSupport.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.locks; -import java.util.concurrent.*; -import sun.misc.Unsafe; - - -/** - * Basic thread blocking primitives for creating locks and other - * synchronization classes. - * - *

This class associates, with each thread that uses it, a permit - * (in the sense of the {@link java.util.concurrent.Semaphore - * Semaphore} class). A call to {@code park} will return immediately - * if the permit is available, consuming it in the process; otherwise - * it may block. A call to {@code unpark} makes the permit - * available, if it was not already available. (Unlike with Semaphores - * though, permits do not accumulate. There is at most one.) - * - *

Methods {@code park} and {@code unpark} provide efficient - * means of blocking and unblocking threads that do not encounter the - * problems that cause the deprecated methods {@code Thread.suspend} - * and {@code Thread.resume} to be unusable for such purposes: Races - * between one thread invoking {@code park} and another thread trying - * to {@code unpark} it will preserve liveness, due to the - * permit. Additionally, {@code park} will return if the caller's - * thread was interrupted, and timeout versions are supported. The - * {@code park} method may also return at any other time, for "no - * reason", so in general must be invoked within a loop that rechecks - * conditions upon return. In this sense {@code park} serves as an - * optimization of a "busy wait" that does not waste as much time - * spinning, but must be paired with an {@code unpark} to be - * effective. - * - *

These methods are designed to be used as tools for creating - * higher-level synchronization utilities, and are not in themselves - * useful for most concurrency control applications. The {@code park} - * method is designed for use only in constructions of the form: - *

while (!canProceed()) { ... LockSupport.park(this); }
- * where neither {@code canProceed} nor any other actions prior to the - * call to {@code park} entail locking or blocking. Because only one - * permit is associated with each thread, any intermediary uses of - * {@code park} could interfere with its intended effects. - * - *

Sample Usage. Here is a sketch of a first-in-first-out - * non-reentrant lock class: - *

{@code
- * class FIFOMutex {
- *   private final AtomicBoolean locked = new AtomicBoolean(false);
- *   private final Queue waiters
- *     = new ConcurrentLinkedQueue();
- *
- *   public void lock() {
- *     boolean wasInterrupted = false;
- *     Thread current = Thread.currentThread();
- *     waiters.add(current);
- *
- *     // Block while not first in queue or cannot acquire lock
- *     while (waiters.peek() != current ||
- *            !locked.compareAndSet(false, true)) {
- *        LockSupport.park(this);
- *        if (Thread.interrupted()) // ignore interrupts while waiting
- *          wasInterrupted = true;
- *     }
- *
- *     waiters.remove();
- *     if (wasInterrupted)          // reassert interrupt status on exit
- *        current.interrupt();
- *   }
- *
- *   public void unlock() {
- *     locked.set(false);
- *     LockSupport.unpark(waiters.peek());
- *   }
- * }}
- */ -@SuppressWarnings("all") -public class LockSupport { - private LockSupport() {} // Cannot be instantiated. - - // BEGIN android-changed - private static final Unsafe unsafe = UnsafeAccess.THE_ONE; - // END android-changed - - /** - * Makes available the permit for the given thread, if it - * was not already available. If the thread was blocked on - * {@code park} then it will unblock. Otherwise, its next call - * to {@code park} is guaranteed not to block. This operation - * is not guaranteed to have any effect at all if the given - * thread has not been started. - * - * @param thread the thread to unpark, or {@code null}, in which case - * this operation has no effect - */ - public static void unpark(Thread thread) { - if (thread != null) - unsafe.unpark(thread); - } - - /** - * Disables the current thread for thread scheduling purposes unless the - * permit is available. - * - *

If the permit is available then it is consumed and the call - * returns immediately; otherwise the current thread becomes disabled - * for thread scheduling purposes and lies dormant until one of three - * things happens: - * - *

    - * - *
  • Some other thread invokes {@link #unpark unpark} with the - * current thread as the target; or - * - *
  • Some other thread {@linkplain Thread#interrupt interrupts} - * the current thread; or - * - *
  • The call spuriously (that is, for no reason) returns. - *
- * - *

This method does not report which of these caused the - * method to return. Callers should re-check the conditions which caused - * the thread to park in the first place. Callers may also determine, - * for example, the interrupt status of the thread upon return. - */ - public static void park() { - unsafe.park(false, 0L); - } - - /** - * Disables the current thread for thread scheduling purposes, for up to - * the specified waiting time, unless the permit is available. - * - *

If the permit is available then it is consumed and the call - * returns immediately; otherwise the current thread becomes disabled - * for thread scheduling purposes and lies dormant until one of four - * things happens: - * - *

    - *
  • Some other thread invokes {@link #unpark unpark} with the - * current thread as the target; or - * - *
  • Some other thread {@linkplain Thread#interrupt interrupts} - * the current thread; or - * - *
  • The specified waiting time elapses; or - * - *
  • The call spuriously (that is, for no reason) returns. - *
- * - *

This method does not report which of these caused the - * method to return. Callers should re-check the conditions which caused - * the thread to park in the first place. Callers may also determine, - * for example, the interrupt status of the thread, or the elapsed time - * upon return. - * - * @param nanos the maximum number of nanoseconds to wait - */ - public static void parkNanos(long nanos) { - if (nanos > 0) - unsafe.park(false, nanos); - } - - /** - * Disables the current thread for thread scheduling purposes, until - * the specified deadline, unless the permit is available. - * - *

If the permit is available then it is consumed and the call - * returns immediately; otherwise the current thread becomes disabled - * for thread scheduling purposes and lies dormant until one of four - * things happens: - * - *

    - *
  • Some other thread invokes {@link #unpark unpark} with the - * current thread as the target; or - * - *
  • Some other thread {@linkplain Thread#interrupt interrupts} - * the current thread; or - * - *
  • The specified deadline passes; or - * - *
  • The call spuriously (that is, for no reason) returns. - *
- * - *

This method does not report which of these caused the - * method to return. Callers should re-check the conditions which caused - * the thread to park in the first place. Callers may also determine, - * for example, the interrupt status of the thread, or the current time - * upon return. - * - * @param deadline the absolute time, in milliseconds from the Epoch, - * to wait until - */ - public static void parkUntil(long deadline) { - unsafe.park(true, deadline); - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/locks/ReadWriteLock.java b/libcore/concurrent/src/main/java/java/util/concurrent/locks/ReadWriteLock.java deleted file mode 100644 index 484f68d15..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/locks/ReadWriteLock.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.locks; - -/** - * A ReadWriteLock maintains a pair of associated {@link - * Lock locks}, one for read-only operations and one for writing. - * The {@link #readLock read lock} may be held simultaneously by - * multiple reader threads, so long as there are no writers. The - * {@link #writeLock write lock} is exclusive. - * - *

All ReadWriteLock implementations must guarantee that - * the memory synchronization effects of writeLock operations - * (as specified in the {@link Lock} interface) also hold with respect - * to the associated readLock. That is, a thread successfully - * acquiring the read lock will see all updates made upon previous - * release of the write lock. - * - *

A read-write lock allows for a greater level of concurrency in - * accessing shared data than that permitted by a mutual exclusion lock. - * It exploits the fact that while only a single thread at a time (a - * writer thread) can modify the shared data, in many cases any - * number of threads can concurrently read the data (hence reader - * threads). - * In theory, the increase in concurrency permitted by the use of a read-write - * lock will lead to performance improvements over the use of a mutual - * exclusion lock. In practice this increase in concurrency will only be fully - * realized on a multi-processor, and then only if the access patterns for - * the shared data are suitable. - * - *

Whether or not a read-write lock will improve performance over the use - * of a mutual exclusion lock depends on the frequency that the data is - * read compared to being modified, the duration of the read and write - * operations, and the contention for the data - that is, the number of - * threads that will try to read or write the data at the same time. - * For example, a collection that is initially populated with data and - * thereafter infrequently modified, while being frequently searched - * (such as a directory of some kind) is an ideal candidate for the use of - * a read-write lock. However, if updates become frequent then the data - * spends most of its time being exclusively locked and there is little, if any - * increase in concurrency. Further, if the read operations are too short - * the overhead of the read-write lock implementation (which is inherently - * more complex than a mutual exclusion lock) can dominate the execution - * cost, particularly as many read-write lock implementations still serialize - * all threads through a small section of code. Ultimately, only profiling - * and measurement will establish whether the use of a read-write lock is - * suitable for your application. - * - * - *

Although the basic operation of a read-write lock is straight-forward, - * there are many policy decisions that an implementation must make, which - * may affect the effectiveness of the read-write lock in a given application. - * Examples of these policies include: - *

    - *
  • Determining whether to grant the read lock or the write lock, when - * both readers and writers are waiting, at the time that a writer releases - * the write lock. Writer preference is common, as writes are expected to be - * short and infrequent. Reader preference is less common as it can lead to - * lengthy delays for a write if the readers are frequent and long-lived as - * expected. Fair, or "in-order" implementations are also possible. - * - *
  • Determining whether readers that request the read lock while a - * reader is active and a writer is waiting, are granted the read lock. - * Preference to the reader can delay the writer indefinitely, while - * preference to the writer can reduce the potential for concurrency. - * - *
  • Determining whether the locks are reentrant: can a thread with the - * write lock reacquire it? Can it acquire a read lock while holding the - * write lock? Is the read lock itself reentrant? - * - *
  • Can the write lock be downgraded to a read lock without allowing - * an intervening writer? Can a read lock be upgraded to a write lock, - * in preference to other waiting readers or writers? - * - *
- * You should consider all of these things when evaluating the suitability - * of a given implementation for your application. - * - * @see ReentrantReadWriteLock - * @see Lock - * @see ReentrantLock - * - * @since 1.5 - * @author Doug Lea - */ -public interface ReadWriteLock { - /** - * Returns the lock used for reading. - * - * @return the lock used for reading. - */ - Lock readLock(); - - /** - * Returns the lock used for writing. - * - * @return the lock used for writing. - */ - Lock writeLock(); -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/locks/ReentrantLock.java b/libcore/concurrent/src/main/java/java/util/concurrent/locks/ReentrantLock.java deleted file mode 100644 index bf2ac38cc..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/locks/ReentrantLock.java +++ /dev/null @@ -1,740 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.locks; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; - -/** - * A reentrant mutual exclusion {@link Lock} with the same basic - * behavior and semantics as the implicit monitor lock accessed using - * {@code synchronized} methods and statements, but with extended - * capabilities. - * - *

A {@code ReentrantLock} is owned by the thread last - * successfully locking, but not yet unlocking it. A thread invoking - * {@code lock} will return, successfully acquiring the lock, when - * the lock is not owned by another thread. The method will return - * immediately if the current thread already owns the lock. This can - * be checked using methods {@link #isHeldByCurrentThread}, and {@link - * #getHoldCount}. - * - *

The constructor for this class accepts an optional - * fairness parameter. When set {@code true}, under - * contention, locks favor granting access to the longest-waiting - * thread. Otherwise this lock does not guarantee any particular - * access order. Programs using fair locks accessed by many threads - * may display lower overall throughput (i.e., are slower; often much - * slower) than those using the default setting, but have smaller - * variances in times to obtain locks and guarantee lack of - * starvation. Note however, that fairness of locks does not guarantee - * fairness of thread scheduling. Thus, one of many threads using a - * fair lock may obtain it multiple times in succession while other - * active threads are not progressing and not currently holding the - * lock. - * Also note that the untimed {@link #tryLock() tryLock} method does not - * honor the fairness setting. It will succeed if the lock - * is available even if other threads are waiting. - * - *

It is recommended practice to always immediately - * follow a call to {@code lock} with a {@code try} block, most - * typically in a before/after construction such as: - * - *

- * class X {
- *   private final ReentrantLock lock = new ReentrantLock();
- *   // ...
- *
- *   public void m() {
- *     lock.lock();  // block until condition holds
- *     try {
- *       // ... method body
- *     } finally {
- *       lock.unlock()
- *     }
- *   }
- * }
- * 
- * - *

In addition to implementing the {@link Lock} interface, this - * class defines methods {@code isLocked} and - * {@code getLockQueueLength}, as well as some associated - * {@code protected} access methods that may be useful for - * instrumentation and monitoring. - * - *

Serialization of this class behaves in the same way as built-in - * locks: a deserialized lock is in the unlocked state, regardless of - * its state when serialized. - * - *

This lock supports a maximum of 2147483647 recursive locks by - * the same thread. Attempts to exceed this limit result in - * {@link Error} throws from locking methods. - * - * @since 1.5 - * @author Doug Lea - */ -public class ReentrantLock implements Lock, java.io.Serializable { - private static final long serialVersionUID = 7373984872572414699L; - /** Synchronizer providing all implementation mechanics */ - private final Sync sync; - - /** - * Base of synchronization control for this lock. Subclassed - * into fair and nonfair versions below. Uses AQS state to - * represent the number of holds on the lock. - */ - static abstract class Sync extends AbstractQueuedSynchronizer { - private static final long serialVersionUID = -5179523762034025860L; - - /** - * Performs {@link Lock#lock}. The main reason for subclassing - * is to allow fast path for nonfair version. - */ - abstract void lock(); - - /** - * Performs non-fair tryLock. tryAcquire is - * implemented in subclasses, but both need nonfair - * try for trylock method. - */ - final boolean nonfairTryAcquire(int acquires) { - final Thread current = Thread.currentThread(); - int c = getState(); - if (c == 0) { - if (compareAndSetState(0, acquires)) { - setExclusiveOwnerThread(current); - return true; - } - } - else if (current == getExclusiveOwnerThread()) { - int nextc = c + acquires; - if (nextc < 0) // overflow - throw new Error("Maximum lock count exceeded"); - setState(nextc); - return true; - } - return false; - } - - protected final boolean tryRelease(int releases) { - int c = getState() - releases; - if (Thread.currentThread() != getExclusiveOwnerThread()) - throw new IllegalMonitorStateException(); - boolean free = false; - if (c == 0) { - free = true; - setExclusiveOwnerThread(null); - } - setState(c); - return free; - } - - protected final boolean isHeldExclusively() { - // While we must in general read state before owner, - // we don't need to do so to check if current thread is owner - return getExclusiveOwnerThread() == Thread.currentThread(); - } - - final ConditionObject newCondition() { - return new ConditionObject(); - } - - // Methods relayed from outer class - - final Thread getOwner() { - return getState() == 0 ? null : getExclusiveOwnerThread(); - } - - final int getHoldCount() { - return isHeldExclusively() ? getState() : 0; - } - - final boolean isLocked() { - return getState() != 0; - } - - /** - * Reconstitutes this lock instance from a stream. - * @param s the stream - */ - private void readObject(java.io.ObjectInputStream s) - throws java.io.IOException, ClassNotFoundException { - s.defaultReadObject(); - setState(0); // reset to unlocked state - } - } - - /** - * Sync object for non-fair locks - */ - final static class NonfairSync extends Sync { - private static final long serialVersionUID = 7316153563782823691L; - - /** - * Performs lock. Try immediate barge, backing up to normal - * acquire on failure. - */ - final void lock() { - if (compareAndSetState(0, 1)) - setExclusiveOwnerThread(Thread.currentThread()); - else - acquire(1); - } - - protected final boolean tryAcquire(int acquires) { - return nonfairTryAcquire(acquires); - } - } - - /** - * Sync object for fair locks - */ - final static class FairSync extends Sync { - private static final long serialVersionUID = -3000897897090466540L; - - final void lock() { - acquire(1); - } - - /** - * Fair version of tryAcquire. Don't grant access unless - * recursive call or no waiters or is first. - */ - protected final boolean tryAcquire(int acquires) { - final Thread current = Thread.currentThread(); - int c = getState(); - if (c == 0) { - if (!hasQueuedPredecessors() && - compareAndSetState(0, acquires)) { - setExclusiveOwnerThread(current); - return true; - } - } - else if (current == getExclusiveOwnerThread()) { - int nextc = c + acquires; - if (nextc < 0) - throw new Error("Maximum lock count exceeded"); - setState(nextc); - return true; - } - return false; - } - } - - /** - * Creates an instance of {@code ReentrantLock}. - * This is equivalent to using {@code ReentrantLock(false)}. - */ - public ReentrantLock() { - sync = new NonfairSync(); - } - - /** - * Creates an instance of {@code ReentrantLock} with the - * given fairness policy. - * - * @param fair {@code true} if this lock should use a fair ordering policy - */ - public ReentrantLock(boolean fair) { - sync = (fair)? new FairSync() : new NonfairSync(); - } - - /** - * Acquires the lock. - * - *

Acquires the lock if it is not held by another thread and returns - * immediately, setting the lock hold count to one. - * - *

If the current thread already holds the lock then the hold - * count is incremented by one and the method returns immediately. - * - *

If the lock is held by another thread then the - * current thread becomes disabled for thread scheduling - * purposes and lies dormant until the lock has been acquired, - * at which time the lock hold count is set to one. - */ - public void lock() { - sync.lock(); - } - - /** - * Acquires the lock unless the current thread is - * {@linkplain Thread#interrupt interrupted}. - * - *

Acquires the lock if it is not held by another thread and returns - * immediately, setting the lock hold count to one. - * - *

If the current thread already holds this lock then the hold count - * is incremented by one and the method returns immediately. - * - *

If the lock is held by another thread then the - * current thread becomes disabled for thread scheduling - * purposes and lies dormant until one of two things happens: - * - *

    - * - *
  • The lock is acquired by the current thread; or - * - *
  • Some other thread {@linkplain Thread#interrupt interrupts} the - * current thread. - * - *
- * - *

If the lock is acquired by the current thread then the lock hold - * count is set to one. - * - *

If the current thread: - * - *

    - * - *
  • has its interrupted status set on entry to this method; or - * - *
  • is {@linkplain Thread#interrupt interrupted} while acquiring - * the lock, - * - *
- * - * then {@link InterruptedException} is thrown and the current thread's - * interrupted status is cleared. - * - *

In this implementation, as this method is an explicit - * interruption point, preference is given to responding to the - * interrupt over normal or reentrant acquisition of the lock. - * - * @throws InterruptedException if the current thread is interrupted - */ - public void lockInterruptibly() throws InterruptedException { - sync.acquireInterruptibly(1); - } - - /** - * Acquires the lock only if it is not held by another thread at the time - * of invocation. - * - *

Acquires the lock if it is not held by another thread and - * returns immediately with the value {@code true}, setting the - * lock hold count to one. Even when this lock has been set to use a - * fair ordering policy, a call to {@code tryLock()} will - * immediately acquire the lock if it is available, whether or not - * other threads are currently waiting for the lock. - * This "barging" behavior can be useful in certain - * circumstances, even though it breaks fairness. If you want to honor - * the fairness setting for this lock, then use - * {@link #tryLock(long, TimeUnit) tryLock(0, TimeUnit.SECONDS) } - * which is almost equivalent (it also detects interruption). - * - *

If the current thread already holds this lock then the hold - * count is incremented by one and the method returns {@code true}. - * - *

If the lock is held by another thread then this method will return - * immediately with the value {@code false}. - * - * @return {@code true} if the lock was free and was acquired by the - * current thread, or the lock was already held by the current - * thread; and {@code false} otherwise - */ - public boolean tryLock() { - return sync.nonfairTryAcquire(1); - } - - /** - * Acquires the lock if it is not held by another thread within the given - * waiting time and the current thread has not been - * {@linkplain Thread#interrupt interrupted}. - * - *

Acquires the lock if it is not held by another thread and returns - * immediately with the value {@code true}, setting the lock hold count - * to one. If this lock has been set to use a fair ordering policy then - * an available lock will not be acquired if any other threads - * are waiting for the lock. This is in contrast to the {@link #tryLock()} - * method. If you want a timed {@code tryLock} that does permit barging on - * a fair lock then combine the timed and un-timed forms together: - * - *

if (lock.tryLock() || lock.tryLock(timeout, unit) ) { ... }
-     * 
- * - *

If the current thread - * already holds this lock then the hold count is incremented by one and - * the method returns {@code true}. - * - *

If the lock is held by another thread then the - * current thread becomes disabled for thread scheduling - * purposes and lies dormant until one of three things happens: - * - *

    - * - *
  • The lock is acquired by the current thread; or - * - *
  • Some other thread {@linkplain Thread#interrupt interrupts} - * the current thread; or - * - *
  • The specified waiting time elapses - * - *
- * - *

If the lock is acquired then the value {@code true} is returned and - * the lock hold count is set to one. - * - *

If the current thread: - * - *

    - * - *
  • has its interrupted status set on entry to this method; or - * - *
  • is {@linkplain Thread#interrupt interrupted} while - * acquiring the lock, - * - *
- * then {@link InterruptedException} is thrown and the current thread's - * interrupted status is cleared. - * - *

If the specified waiting time elapses then the value {@code false} - * is returned. If the time is less than or equal to zero, the method - * will not wait at all. - * - *

In this implementation, as this method is an explicit - * interruption point, preference is given to responding to the - * interrupt over normal or reentrant acquisition of the lock, and - * over reporting the elapse of the waiting time. - * - * @param timeout the time to wait for the lock - * @param unit the time unit of the timeout argument - * @return {@code true} if the lock was free and was acquired by the - * current thread, or the lock was already held by the current - * thread; and {@code false} if the waiting time elapsed before - * the lock could be acquired - * @throws InterruptedException if the current thread is interrupted - * @throws NullPointerException if the time unit is null - * - */ - public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException { - return sync.tryAcquireNanos(1, unit.toNanos(timeout)); - } - - /** - * Attempts to release this lock. - * - *

If the current thread is the holder of this lock then the hold - * count is decremented. If the hold count is now zero then the lock - * is released. If the current thread is not the holder of this - * lock then {@link IllegalMonitorStateException} is thrown. - * - * @throws IllegalMonitorStateException if the current thread does not - * hold this lock - */ - public void unlock() { - sync.release(1); - } - - /** - * Returns a {@link Condition} instance for use with this - * {@link Lock} instance. - * - *

The returned {@link Condition} instance supports the same - * usages as do the {@link Object} monitor methods ({@link - * Object#wait() wait}, {@link Object#notify notify}, and {@link - * Object#notifyAll notifyAll}) when used with the built-in - * monitor lock. - * - *

    - * - *
  • If this lock is not held when any of the {@link Condition} - * {@linkplain Condition#await() waiting} or {@linkplain - * Condition#signal signalling} methods are called, then an {@link - * IllegalMonitorStateException} is thrown. - * - *
  • When the condition {@linkplain Condition#await() waiting} - * methods are called the lock is released and, before they - * return, the lock is reacquired and the lock hold count restored - * to what it was when the method was called. - * - *
  • If a thread is {@linkplain Thread#interrupt interrupted} - * while waiting then the wait will terminate, an {@link - * InterruptedException} will be thrown, and the thread's - * interrupted status will be cleared. - * - *
  • Waiting threads are signalled in FIFO order. - * - *
  • The ordering of lock reacquisition for threads returning - * from waiting methods is the same as for threads initially - * acquiring the lock, which is in the default case not specified, - * but for fair locks favors those threads that have been - * waiting the longest. - * - *
- * - * @return the Condition object - */ - public Condition newCondition() { - return sync.newCondition(); - } - - /** - * Queries the number of holds on this lock by the current thread. - * - *

A thread has a hold on a lock for each lock action that is not - * matched by an unlock action. - * - *

The hold count information is typically only used for testing and - * debugging purposes. For example, if a certain section of code should - * not be entered with the lock already held then we can assert that - * fact: - * - *

-     * class X {
-     *   ReentrantLock lock = new ReentrantLock();
-     *   // ...
-     *   public void m() {
-     *     assert lock.getHoldCount() == 0;
-     *     lock.lock();
-     *     try {
-     *       // ... method body
-     *     } finally {
-     *       lock.unlock();
-     *     }
-     *   }
-     * }
-     * 
- * - * @return the number of holds on this lock by the current thread, - * or zero if this lock is not held by the current thread - */ - public int getHoldCount() { - return sync.getHoldCount(); - } - - /** - * Queries if this lock is held by the current thread. - * - *

Analogous to the {@link Thread#holdsLock} method for built-in - * monitor locks, this method is typically used for debugging and - * testing. For example, a method that should only be called while - * a lock is held can assert that this is the case: - * - *

-     * class X {
-     *   ReentrantLock lock = new ReentrantLock();
-     *   // ...
-     *
-     *   public void m() {
-     *       assert lock.isHeldByCurrentThread();
-     *       // ... method body
-     *   }
-     * }
-     * 
- * - *

It can also be used to ensure that a reentrant lock is used - * in a non-reentrant manner, for example: - * - *

-     * class X {
-     *   ReentrantLock lock = new ReentrantLock();
-     *   // ...
-     *
-     *   public void m() {
-     *       assert !lock.isHeldByCurrentThread();
-     *       lock.lock();
-     *       try {
-     *           // ... method body
-     *       } finally {
-     *           lock.unlock();
-     *       }
-     *   }
-     * }
-     * 
- * - * @return {@code true} if current thread holds this lock and - * {@code false} otherwise - */ - public boolean isHeldByCurrentThread() { - return sync.isHeldExclusively(); - } - - /** - * Queries if this lock is held by any thread. This method is - * designed for use in monitoring of the system state, - * not for synchronization control. - * - * @return {@code true} if any thread holds this lock and - * {@code false} otherwise - */ - public boolean isLocked() { - return sync.isLocked(); - } - - /** - * Returns {@code true} if this lock has fairness set true. - * - * @return {@code true} if this lock has fairness set true - */ - public final boolean isFair() { - return sync instanceof FairSync; - } - - /** - * Returns the thread that currently owns this lock, or - * {@code null} if not owned. When this method is called by a - * thread that is not the owner, the return value reflects a - * best-effort approximation of current lock status. For example, - * the owner may be momentarily {@code null} even if there are - * threads trying to acquire the lock but have not yet done so. - * This method is designed to facilitate construction of - * subclasses that provide more extensive lock monitoring - * facilities. - * - * @return the owner, or {@code null} if not owned - */ - protected Thread getOwner() { - return sync.getOwner(); - } - - /** - * Queries whether any threads are waiting to acquire this lock. Note that - * because cancellations may occur at any time, a {@code true} - * return does not guarantee that any other thread will ever - * acquire this lock. This method is designed primarily for use in - * monitoring of the system state. - * - * @return {@code true} if there may be other threads waiting to - * acquire the lock - */ - public final boolean hasQueuedThreads() { - return sync.hasQueuedThreads(); - } - - - /** - * Queries whether the given thread is waiting to acquire this - * lock. Note that because cancellations may occur at any time, a - * {@code true} return does not guarantee that this thread - * will ever acquire this lock. This method is designed primarily for use - * in monitoring of the system state. - * - * @param thread the thread - * @return {@code true} if the given thread is queued waiting for this lock - * @throws NullPointerException if the thread is null - */ - public final boolean hasQueuedThread(Thread thread) { - return sync.isQueued(thread); - } - - - /** - * Returns an estimate of the number of threads waiting to - * acquire this lock. The value is only an estimate because the number of - * threads may change dynamically while this method traverses - * internal data structures. This method is designed for use in - * monitoring of the system state, not for synchronization - * control. - * - * @return the estimated number of threads waiting for this lock - */ - public final int getQueueLength() { - return sync.getQueueLength(); - } - - /** - * Returns a collection containing threads that may be waiting to - * acquire this lock. Because the actual set of threads may change - * dynamically while constructing this result, the returned - * collection is only a best-effort estimate. The elements of the - * returned collection are in no particular order. This method is - * designed to facilitate construction of subclasses that provide - * more extensive monitoring facilities. - * - * @return the collection of threads - */ - protected Collection getQueuedThreads() { - return sync.getQueuedThreads(); - } - - /** - * Queries whether any threads are waiting on the given condition - * associated with this lock. Note that because timeouts and - * interrupts may occur at any time, a {@code true} return does - * not guarantee that a future {@code signal} will awaken any - * threads. This method is designed primarily for use in - * monitoring of the system state. - * - * @param condition the condition - * @return {@code true} if there are any waiting threads - * @throws IllegalMonitorStateException if this lock is not held - * @throws IllegalArgumentException if the given condition is - * not associated with this lock - * @throws NullPointerException if the condition is null - */ - public boolean hasWaiters(Condition condition) { - if (condition == null) - throw new NullPointerException(); - if (!(condition instanceof AbstractQueuedSynchronizer.ConditionObject)) - throw new IllegalArgumentException("not owner"); - return sync.hasWaiters((AbstractQueuedSynchronizer.ConditionObject)condition); - } - - /** - * Returns an estimate of the number of threads waiting on the - * given condition associated with this lock. Note that because - * timeouts and interrupts may occur at any time, the estimate - * serves only as an upper bound on the actual number of waiters. - * This method is designed for use in monitoring of the system - * state, not for synchronization control. - * - * @param condition the condition - * @return the estimated number of waiting threads - * @throws IllegalMonitorStateException if this lock is not held - * @throws IllegalArgumentException if the given condition is - * not associated with this lock - * @throws NullPointerException if the condition is null - */ - public int getWaitQueueLength(Condition condition) { - if (condition == null) - throw new NullPointerException(); - if (!(condition instanceof AbstractQueuedSynchronizer.ConditionObject)) - throw new IllegalArgumentException("not owner"); - return sync.getWaitQueueLength((AbstractQueuedSynchronizer.ConditionObject)condition); - } - - /** - * Returns a collection containing those threads that may be - * waiting on the given condition associated with this lock. - * Because the actual set of threads may change dynamically while - * constructing this result, the returned collection is only a - * best-effort estimate. The elements of the returned collection - * are in no particular order. This method is designed to - * facilitate construction of subclasses that provide more - * extensive condition monitoring facilities. - * - * @param condition the condition - * @return the collection of threads - * @throws IllegalMonitorStateException if this lock is not held - * @throws IllegalArgumentException if the given condition is - * not associated with this lock - * @throws NullPointerException if the condition is null - */ - protected Collection getWaitingThreads(Condition condition) { - if (condition == null) - throw new NullPointerException(); - if (!(condition instanceof AbstractQueuedSynchronizer.ConditionObject)) - throw new IllegalArgumentException("not owner"); - return sync.getWaitingThreads((AbstractQueuedSynchronizer.ConditionObject)condition); - } - - /** - * Returns a string identifying this lock, as well as its lock state. - * The state, in brackets, includes either the String {@code "Unlocked"} - * or the String {@code "Locked by"} followed by the - * {@linkplain Thread#getName name} of the owning thread. - * - * @return a string identifying this lock, as well as its lock state - */ - public String toString() { - Thread o = sync.getOwner(); - return super.toString() + ((o == null) ? - "[Unlocked]" : - "[Locked by thread " + o.getName() + "]"); - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/locks/ReentrantReadWriteLock.java b/libcore/concurrent/src/main/java/java/util/concurrent/locks/ReentrantReadWriteLock.java deleted file mode 100644 index c9239448c..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/locks/ReentrantReadWriteLock.java +++ /dev/null @@ -1,1415 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package java.util.concurrent.locks; -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; -import java.util.*; - -/** - * An implementation of {@link ReadWriteLock} supporting similar - * semantics to {@link ReentrantLock}. - *

This class has the following properties: - * - *

    - *
  • Acquisition order - * - *

    This class does not impose a reader or writer preference - * ordering for lock access. However, it does support an optional - * fairness policy. - * - *

    - *
    Non-fair mode (default) - *
    When constructed as non-fair (the default), the order of entry - * to the read and write lock is unspecified, subject to reentrancy - * constraints. A nonfair lock that is continuously contended may - * indefinitely postpone one or more reader or writer threads, but - * will normally have higher throughput than a fair lock. - *

    - * - *

    Fair mode - *
    When constructed as fair, threads contend for entry using an - * approximately arrival-order policy. When the currently held lock - * is released either the longest-waiting single writer thread will - * be assigned the write lock, or if there is a group of reader threads - * waiting longer than all waiting writer threads, that group will be - * assigned the read lock. - * - *

    A thread that tries to acquire a fair read lock (non-reentrantly) - * will block if either the write lock is held, or there is a waiting - * writer thread. The thread will not acquire the read lock until - * after the oldest currently waiting writer thread has acquired and - * released the write lock. Of course, if a waiting writer abandons - * its wait, leaving one or more reader threads as the longest waiters - * in the queue with the write lock free, then those readers will be - * assigned the read lock. - * - *

    A thread that tries to acquire a fair write lock (non-reentrantly) - * will block unless both the read lock and write lock are free (which - * implies there are no waiting threads). (Note that the non-blocking - * {@link ReadLock#tryLock()} and {@link WriteLock#tryLock()} methods - * do not honor this fair setting and will acquire the lock if it is - * possible, regardless of waiting threads.) - *

    - *

    - * - *
  • Reentrancy - * - *

    This lock allows both readers and writers to reacquire read or - * write locks in the style of a {@link ReentrantLock}. Non-reentrant - * readers are not allowed until all write locks held by the writing - * thread have been released. - * - *

    Additionally, a writer can acquire the read lock, but not - * vice-versa. Among other applications, reentrancy can be useful - * when write locks are held during calls or callbacks to methods that - * perform reads under read locks. If a reader tries to acquire the - * write lock it will never succeed. - * - *

  • Lock downgrading - *

    Reentrancy also allows downgrading from the write lock to a read lock, - * by acquiring the write lock, then the read lock and then releasing the - * write lock. However, upgrading from a read lock to the write lock is - * not possible. - * - *

  • Interruption of lock acquisition - *

    The read lock and write lock both support interruption during lock - * acquisition. - * - *

  • {@link Condition} support - *

    The write lock provides a {@link Condition} implementation that - * behaves in the same way, with respect to the write lock, as the - * {@link Condition} implementation provided by - * {@link ReentrantLock#newCondition} does for {@link ReentrantLock}. - * This {@link Condition} can, of course, only be used with the write lock. - * - *

    The read lock does not support a {@link Condition} and - * {@code readLock().newCondition()} throws - * {@code UnsupportedOperationException}. - * - *

  • Instrumentation - *

    This class supports methods to determine whether locks - * are held or contended. These methods are designed for monitoring - * system state, not for synchronization control. - *

- * - *

Serialization of this class behaves in the same way as built-in - * locks: a deserialized lock is in the unlocked state, regardless of - * its state when serialized. - * - *

Sample usages. Here is a code sketch showing how to perform - * lock downgrading after updating a cache (exception handling is - * particularly tricky when handling multiple locks in a non-nested - * fashion): - * - *

 {@code
- * class CachedData {
- *   Object data;
- *   volatile boolean cacheValid;
- *   final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock();
- *
- *   void processCachedData() {
- *     rwl.readLock().lock();
- *     if (!cacheValid) {
- *        // Must release read lock before acquiring write lock
- *        rwl.readLock().unlock();
- *        rwl.writeLock().lock();
- *        try {
- *          // Recheck state because another thread might have
- *          // acquired write lock and changed state before we did.
- *          if (!cacheValid) {
- *            data = ...
- *            cacheValid = true;
- *          }
- *          // Downgrade by acquiring read lock before releasing write lock
- *          rwl.readLock().lock();
- *        } finally  {
- *          rwl.writeLock().unlock(); // Unlock write, still hold read
- *        }
- *     }
- *
- *     try {
- *       use(data);
- *     } finally {
- *       rwl.readLock().unlock();
- *     }
- *   }
- * }}
- * - * ReentrantReadWriteLocks can be used to improve concurrency in some - * uses of some kinds of Collections. This is typically worthwhile - * only when the collections are expected to be large, accessed by - * more reader threads than writer threads, and entail operations with - * overhead that outweighs synchronization overhead. For example, here - * is a class using a TreeMap that is expected to be large and - * concurrently accessed. - * - *
{@code
- * class RWDictionary {
- *    private final Map m = new TreeMap();
- *    private final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock();
- *    private final Lock r = rwl.readLock();
- *    private final Lock w = rwl.writeLock();
- *
- *    public Data get(String key) {
- *        r.lock();
- *        try { return m.get(key); }
- *        finally { r.unlock(); }
- *    }
- *    public String[] allKeys() {
- *        r.lock();
- *        try { return m.keySet().toArray(); }
- *        finally { r.unlock(); }
- *    }
- *    public Data put(String key, Data value) {
- *        w.lock();
- *        try { return m.put(key, value); }
- *        finally { w.unlock(); }
- *    }
- *    public void clear() {
- *        w.lock();
- *        try { m.clear(); }
- *        finally { w.unlock(); }
- *    }
- * }}
- * - *

Implementation Notes

- * - *

This lock supports a maximum of 65535 recursive write locks - * and 65535 read locks. Attempts to exceed these limits result in - * {@link Error} throws from locking methods. - * - * @since 1.5 - * @author Doug Lea - * - */ -public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializable { - private static final long serialVersionUID = -6992448646407690164L; - /** Inner class providing readlock */ - private final ReentrantReadWriteLock.ReadLock readerLock; - /** Inner class providing writelock */ - private final ReentrantReadWriteLock.WriteLock writerLock; - /** Performs all synchronization mechanics */ - final Sync sync; - - /** - * Creates a new {@code ReentrantReadWriteLock} with - * default (nonfair) ordering properties. - */ - public ReentrantReadWriteLock() { - this(false); - } - - /** - * Creates a new {@code ReentrantReadWriteLock} with - * the given fairness policy. - * - * @param fair {@code true} if this lock should use a fair ordering policy - */ - public ReentrantReadWriteLock(boolean fair) { - sync = fair ? new FairSync() : new NonfairSync(); - readerLock = new ReadLock(this); - writerLock = new WriteLock(this); - } - - public ReentrantReadWriteLock.WriteLock writeLock() { return writerLock; } - public ReentrantReadWriteLock.ReadLock readLock() { return readerLock; } - - /** - * Synchronization implementation for ReentrantReadWriteLock. - * Subclassed into fair and nonfair versions. - */ - static abstract class Sync extends AbstractQueuedSynchronizer { - private static final long serialVersionUID = 6317671515068378041L; - - /* - * Read vs write count extraction constants and functions. - * Lock state is logically divided into two unsigned shorts: - * The lower one representing the exclusive (writer) lock hold count, - * and the upper the shared (reader) hold count. - */ - - static final int SHARED_SHIFT = 16; - static final int SHARED_UNIT = (1 << SHARED_SHIFT); - static final int MAX_COUNT = (1 << SHARED_SHIFT) - 1; - static final int EXCLUSIVE_MASK = (1 << SHARED_SHIFT) - 1; - - /** Returns the number of shared holds represented in count */ - static int sharedCount(int c) { return c >>> SHARED_SHIFT; } - /** Returns the number of exclusive holds represented in count */ - static int exclusiveCount(int c) { return c & EXCLUSIVE_MASK; } - - /** - * A counter for per-thread read hold counts. - * Maintained as a ThreadLocal; cached in cachedHoldCounter - */ - static final class HoldCounter { - int count = 0; - // Use id, not reference, to avoid garbage retention - final long tid = Thread.currentThread().getId(); - } - - /** - * ThreadLocal subclass. Easiest to explicitly define for sake - * of deserialization mechanics. - */ - static final class ThreadLocalHoldCounter - extends ThreadLocal { - public HoldCounter initialValue() { - return new HoldCounter(); - } - } - - /** - * The number of reentrant read locks held by current thread. - * Initialized only in constructor and readObject. - * Removed whenever a thread's read hold count drops to 0. - */ - private transient ThreadLocalHoldCounter readHolds; - - /** - * The hold count of the last thread to successfully acquire - * readLock. This saves ThreadLocal lookup in the common case - * where the next thread to release is the last one to - * acquire. This is non-volatile since it is just used - * as a heuristic, and would be great for threads to cache. - * - *

Can outlive the Thread for which it is caching the read - * hold count, but avoids garbage retention by not retaining a - * reference to the Thread. - * - *

Accessed via a benign data race; relies on the memory - * model's final field and out-of-thin-air guarantees. - */ - private transient HoldCounter cachedHoldCounter; - - /** - * firstReader is the first thread to have acquired the read lock. - * firstReaderHoldCount is firstReader's hold count. - * - *

More precisely, firstReader is the unique thread that last - * changed the shared count from 0 to 1, and has not released the - * read lock since then; null if there is no such thread. - * - *

Cannot cause garbage retention unless the thread terminated - * without relinquishing its read locks, since tryReleaseShared - * sets it to null. - * - *

Accessed via a benign data race; relies on the memory - * model's out-of-thin-air guarantees for references. - * - *

This allows tracking of read holds for uncontended read - * locks to be very cheap. - */ - private transient Thread firstReader = null; - private transient int firstReaderHoldCount; - - Sync() { - readHolds = new ThreadLocalHoldCounter(); - setState(getState()); // ensures visibility of readHolds - } - - /* - * Acquires and releases use the same code for fair and - * nonfair locks, but differ in whether/how they allow barging - * when queues are non-empty. - */ - - /** - * Returns true if the current thread, when trying to acquire - * the read lock, and otherwise eligible to do so, should block - * because of policy for overtaking other waiting threads. - */ - abstract boolean readerShouldBlock(); - - /** - * Returns true if the current thread, when trying to acquire - * the write lock, and otherwise eligible to do so, should block - * because of policy for overtaking other waiting threads. - */ - abstract boolean writerShouldBlock(); - - /* - * Note that tryRelease and tryAcquire can be called by - * Conditions. So it is possible that their arguments contain - * both read and write holds that are all released during a - * condition wait and re-established in tryAcquire. - */ - - protected final boolean tryRelease(int releases) { - if (!isHeldExclusively()) - throw new IllegalMonitorStateException(); - int nextc = getState() - releases; - boolean free = exclusiveCount(nextc) == 0; - if (free) - setExclusiveOwnerThread(null); - setState(nextc); - return free; - } - - protected final boolean tryAcquire(int acquires) { - /* - * Walkthrough: - * 1. If read count nonzero or write count nonzero - * and owner is a different thread, fail. - * 2. If count would saturate, fail. (This can only - * happen if count is already nonzero.) - * 3. Otherwise, this thread is eligible for lock if - * it is either a reentrant acquire or - * queue policy allows it. If so, update state - * and set owner. - */ - Thread current = Thread.currentThread(); - int c = getState(); - int w = exclusiveCount(c); - if (c != 0) { - // (Note: if c != 0 and w == 0 then shared count != 0) - if (w == 0 || current != getExclusiveOwnerThread()) - return false; - if (w + exclusiveCount(acquires) > MAX_COUNT) - throw new Error("Maximum lock count exceeded"); - // Reentrant acquire - setState(c + acquires); - return true; - } - if (writerShouldBlock() || - !compareAndSetState(c, c + acquires)) - return false; - setExclusiveOwnerThread(current); - return true; - } - - protected final boolean tryReleaseShared(int unused) { - Thread current = Thread.currentThread(); - if (firstReader == current) { - // assert firstReaderHoldCount > 0; - if (firstReaderHoldCount == 1) - firstReader = null; - else - firstReaderHoldCount--; - } else { - HoldCounter rh = cachedHoldCounter; - if (rh == null || rh.tid != current.getId()) - rh = readHolds.get(); - int count = rh.count; - if (count <= 1) { - readHolds.remove(); - if (count <= 0) - throw unmatchedUnlockException(); - } - --rh.count; - } - for (;;) { - int c = getState(); - int nextc = c - SHARED_UNIT; - if (compareAndSetState(c, nextc)) - // Releasing the read lock has no effect on readers, - // but it may allow waiting writers to proceed if - // both read and write locks are now free. - return nextc == 0; - } - } - - private IllegalMonitorStateException unmatchedUnlockException() { - return new IllegalMonitorStateException( - "attempt to unlock read lock, not locked by current thread"); - } - - protected final int tryAcquireShared(int unused) { - /* - * Walkthrough: - * 1. If write lock held by another thread, fail. - * 2. Otherwise, this thread is eligible for - * lock wrt state, so ask if it should block - * because of queue policy. If not, try - * to grant by CASing state and updating count. - * Note that step does not check for reentrant - * acquires, which is postponed to full version - * to avoid having to check hold count in - * the more typical non-reentrant case. - * 3. If step 2 fails either because thread - * apparently not eligible or CAS fails or count - * saturated, chain to version with full retry loop. - */ - Thread current = Thread.currentThread(); - int c = getState(); - if (exclusiveCount(c) != 0 && - getExclusiveOwnerThread() != current) - return -1; - int r = sharedCount(c); - if (!readerShouldBlock() && - r < MAX_COUNT && - compareAndSetState(c, c + SHARED_UNIT)) { - if (r == 0) { - firstReader = current; - firstReaderHoldCount = 1; - } else if (firstReader == current) { - firstReaderHoldCount++; - } else { - HoldCounter rh = cachedHoldCounter; - if (rh == null || rh.tid != current.getId()) - cachedHoldCounter = rh = readHolds.get(); - else if (rh.count == 0) - readHolds.set(rh); - rh.count++; - } - return 1; - } - return fullTryAcquireShared(current); - } - - /** - * Full version of acquire for reads, that handles CAS misses - * and reentrant reads not dealt with in tryAcquireShared. - */ - final int fullTryAcquireShared(Thread current) { - /* - * This code is in part redundant with that in - * tryAcquireShared but is simpler overall by not - * complicating tryAcquireShared with interactions between - * retries and lazily reading hold counts. - */ - HoldCounter rh = null; - for (;;) { - int c = getState(); - if (exclusiveCount(c) != 0) { - if (getExclusiveOwnerThread() != current) - return -1; - // else we hold the exclusive lock; blocking here - // would cause deadlock. - } else if (readerShouldBlock()) { - // Make sure we're not acquiring read lock reentrantly - if (firstReader == current) { - // assert firstReaderHoldCount > 0; - } else { - if (rh == null) { - rh = cachedHoldCounter; - if (rh == null || rh.tid != current.getId()) { - rh = readHolds.get(); - if (rh.count == 0) - readHolds.remove(); - } - } - if (rh.count == 0) - return -1; - } - } - if (sharedCount(c) == MAX_COUNT) - throw new Error("Maximum lock count exceeded"); - if (compareAndSetState(c, c + SHARED_UNIT)) { - if (sharedCount(c) == 0) { - firstReader = current; - firstReaderHoldCount = 1; - } else if (firstReader == current) { - firstReaderHoldCount++; - } else { - if (rh == null) - rh = cachedHoldCounter; - if (rh == null || rh.tid != current.getId()) - rh = readHolds.get(); - else if (rh.count == 0) - readHolds.set(rh); - rh.count++; - cachedHoldCounter = rh; // cache for release - } - return 1; - } - } - } - - /** - * Performs tryLock for write, enabling barging in both modes. - * This is identical in effect to tryAcquire except for lack - * of calls to writerShouldBlock. - */ - final boolean tryWriteLock() { - Thread current = Thread.currentThread(); - int c = getState(); - if (c != 0) { - int w = exclusiveCount(c); - if (w == 0 || current != getExclusiveOwnerThread()) - return false; - if (w == MAX_COUNT) - throw new Error("Maximum lock count exceeded"); - } - if (!compareAndSetState(c, c + 1)) - return false; - setExclusiveOwnerThread(current); - return true; - } - - /** - * Performs tryLock for read, enabling barging in both modes. - * This is identical in effect to tryAcquireShared except for - * lack of calls to readerShouldBlock. - */ - final boolean tryReadLock() { - Thread current = Thread.currentThread(); - for (;;) { - int c = getState(); - if (exclusiveCount(c) != 0 && - getExclusiveOwnerThread() != current) - return false; - int r = sharedCount(c); - if (r == MAX_COUNT) - throw new Error("Maximum lock count exceeded"); - if (compareAndSetState(c, c + SHARED_UNIT)) { - if (r == 0) { - firstReader = current; - firstReaderHoldCount = 1; - } else if (firstReader == current) { - firstReaderHoldCount++; - } else { - HoldCounter rh = cachedHoldCounter; - if (rh == null || rh.tid != current.getId()) - cachedHoldCounter = rh = readHolds.get(); - else if (rh.count == 0) - readHolds.set(rh); - rh.count++; - } - return true; - } - } - } - - protected final boolean isHeldExclusively() { - // While we must in general read state before owner, - // we don't need to do so to check if current thread is owner - return getExclusiveOwnerThread() == Thread.currentThread(); - } - - // Methods relayed to outer class - - final ConditionObject newCondition() { - return new ConditionObject(); - } - - final Thread getOwner() { - // Must read state before owner to ensure memory consistency - return ((exclusiveCount(getState()) == 0)? - null : - getExclusiveOwnerThread()); - } - - final int getReadLockCount() { - return sharedCount(getState()); - } - - final boolean isWriteLocked() { - return exclusiveCount(getState()) != 0; - } - - final int getWriteHoldCount() { - return isHeldExclusively() ? exclusiveCount(getState()) : 0; - } - - final int getReadHoldCount() { - if (getReadLockCount() == 0) - return 0; - - Thread current = Thread.currentThread(); - if (firstReader == current) - return firstReaderHoldCount; - - HoldCounter rh = cachedHoldCounter; - if (rh != null && rh.tid == current.getId()) - return rh.count; - - int count = readHolds.get().count; - if (count == 0) readHolds.remove(); - return count; - } - - /** - * Reconstitute this lock instance from a stream - * @param s the stream - */ - private void readObject(java.io.ObjectInputStream s) - throws java.io.IOException, ClassNotFoundException { - s.defaultReadObject(); - readHolds = new ThreadLocalHoldCounter(); - setState(0); // reset to unlocked state - } - - final int getCount() { return getState(); } - } - - /** - * Nonfair version of Sync - */ - final static class NonfairSync extends Sync { - private static final long serialVersionUID = -8159625535654395037L; - final boolean writerShouldBlock() { - return false; // writers can always barge - } - final boolean readerShouldBlock() { - /* As a heuristic to avoid indefinite writer starvation, - * block if the thread that momentarily appears to be head - * of queue, if one exists, is a waiting writer. This is - * only a probabilistic effect since a new reader will not - * block if there is a waiting writer behind other enabled - * readers that have not yet drained from the queue. - */ - return apparentlyFirstQueuedIsExclusive(); - } - } - - /** - * Fair version of Sync - */ - final static class FairSync extends Sync { - private static final long serialVersionUID = -2274990926593161451L; - final boolean writerShouldBlock() { - return hasQueuedPredecessors(); - } - final boolean readerShouldBlock() { - return hasQueuedPredecessors(); - } - } - - /** - * The lock returned by method {@link ReentrantReadWriteLock#readLock}. - */ - public static class ReadLock implements Lock, java.io.Serializable { - private static final long serialVersionUID = -5992448646407690164L; - private final Sync sync; - - /** - * Constructor for use by subclasses - * - * @param lock the outer lock object - * @throws NullPointerException if the lock is null - */ - protected ReadLock(ReentrantReadWriteLock lock) { - sync = lock.sync; - } - - /** - * Acquires the read lock. - * - *

Acquires the read lock if the write lock is not held by - * another thread and returns immediately. - * - *

If the write lock is held by another thread then - * the current thread becomes disabled for thread scheduling - * purposes and lies dormant until the read lock has been acquired. - */ - public void lock() { - sync.acquireShared(1); - } - - /** - * Acquires the read lock unless the current thread is - * {@linkplain Thread#interrupt interrupted}. - * - *

Acquires the read lock if the write lock is not held - * by another thread and returns immediately. - * - *

If the write lock is held by another thread then the - * current thread becomes disabled for thread scheduling - * purposes and lies dormant until one of two things happens: - * - *

    - * - *
  • The read lock is acquired by the current thread; or - * - *
  • Some other thread {@linkplain Thread#interrupt interrupts} - * the current thread. - * - *
- * - *

If the current thread: - * - *

    - * - *
  • has its interrupted status set on entry to this method; or - * - *
  • is {@linkplain Thread#interrupt interrupted} while - * acquiring the read lock, - * - *
- * - * then {@link InterruptedException} is thrown and the current - * thread's interrupted status is cleared. - * - *

In this implementation, as this method is an explicit - * interruption point, preference is given to responding to - * the interrupt over normal or reentrant acquisition of the - * lock. - * - * @throws InterruptedException if the current thread is interrupted - */ - public void lockInterruptibly() throws InterruptedException { - sync.acquireSharedInterruptibly(1); - } - - /** - * Acquires the read lock only if the write lock is not held by - * another thread at the time of invocation. - * - *

Acquires the read lock if the write lock is not held by - * another thread and returns immediately with the value - * {@code true}. Even when this lock has been set to use a - * fair ordering policy, a call to {@code tryLock()} - * will immediately acquire the read lock if it is - * available, whether or not other threads are currently - * waiting for the read lock. This "barging" behavior - * can be useful in certain circumstances, even though it - * breaks fairness. If you want to honor the fairness setting - * for this lock, then use {@link #tryLock(long, TimeUnit) - * tryLock(0, TimeUnit.SECONDS) } which is almost equivalent - * (it also detects interruption). - * - *

If the write lock is held by another thread then - * this method will return immediately with the value - * {@code false}. - * - * @return {@code true} if the read lock was acquired - */ - public boolean tryLock() { - return sync.tryReadLock(); - } - - /** - * Acquires the read lock if the write lock is not held by - * another thread within the given waiting time and the - * current thread has not been {@linkplain Thread#interrupt - * interrupted}. - * - *

Acquires the read lock if the write lock is not held by - * another thread and returns immediately with the value - * {@code true}. If this lock has been set to use a fair - * ordering policy then an available lock will not be - * acquired if any other threads are waiting for the - * lock. This is in contrast to the {@link #tryLock()} - * method. If you want a timed {@code tryLock} that does - * permit barging on a fair lock then combine the timed and - * un-timed forms together: - * - *

if (lock.tryLock() || lock.tryLock(timeout, unit) ) { ... }
-         * 
- * - *

If the write lock is held by another thread then the - * current thread becomes disabled for thread scheduling - * purposes and lies dormant until one of three things happens: - * - *

    - * - *
  • The read lock is acquired by the current thread; or - * - *
  • Some other thread {@linkplain Thread#interrupt interrupts} - * the current thread; or - * - *
  • The specified waiting time elapses. - * - *
- * - *

If the read lock is acquired then the value {@code true} is - * returned. - * - *

If the current thread: - * - *

    - * - *
  • has its interrupted status set on entry to this method; or - * - *
  • is {@linkplain Thread#interrupt interrupted} while - * acquiring the read lock, - * - *
then {@link InterruptedException} is thrown and the - * current thread's interrupted status is cleared. - * - *

If the specified waiting time elapses then the value - * {@code false} is returned. If the time is less than or - * equal to zero, the method will not wait at all. - * - *

In this implementation, as this method is an explicit - * interruption point, preference is given to responding to - * the interrupt over normal or reentrant acquisition of the - * lock, and over reporting the elapse of the waiting time. - * - * @param timeout the time to wait for the read lock - * @param unit the time unit of the timeout argument - * @return {@code true} if the read lock was acquired - * @throws InterruptedException if the current thread is interrupted - * @throws NullPointerException if the time unit is null - * - */ - public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException { - return sync.tryAcquireSharedNanos(1, unit.toNanos(timeout)); - } - - /** - * Attempts to release this lock. - * - *

If the number of readers is now zero then the lock - * is made available for write lock attempts. - */ - public void unlock() { - sync.releaseShared(1); - } - - /** - * Throws {@code UnsupportedOperationException} because - * {@code ReadLocks} do not support conditions. - * - * @throws UnsupportedOperationException always - */ - public Condition newCondition() { - throw new UnsupportedOperationException(); - } - - /** - * Returns a string identifying this lock, as well as its lock state. - * The state, in brackets, includes the String {@code "Read locks ="} - * followed by the number of held read locks. - * - * @return a string identifying this lock, as well as its lock state - */ - public String toString() { - int r = sync.getReadLockCount(); - return super.toString() + - "[Read locks = " + r + "]"; - } - } - - /** - * The lock returned by method {@link ReentrantReadWriteLock#writeLock}. - */ - public static class WriteLock implements Lock, java.io.Serializable { - private static final long serialVersionUID = -4992448646407690164L; - private final Sync sync; - - /** - * Constructor for use by subclasses - * - * @param lock the outer lock object - * @throws NullPointerException if the lock is null - */ - protected WriteLock(ReentrantReadWriteLock lock) { - sync = lock.sync; - } - - /** - * Acquires the write lock. - * - *

Acquires the write lock if neither the read nor write lock - * are held by another thread - * and returns immediately, setting the write lock hold count to - * one. - * - *

If the current thread already holds the write lock then the - * hold count is incremented by one and the method returns - * immediately. - * - *

If the lock is held by another thread then the current - * thread becomes disabled for thread scheduling purposes and - * lies dormant until the write lock has been acquired, at which - * time the write lock hold count is set to one. - */ - public void lock() { - sync.acquire(1); - } - - /** - * Acquires the write lock unless the current thread is - * {@linkplain Thread#interrupt interrupted}. - * - *

Acquires the write lock if neither the read nor write lock - * are held by another thread - * and returns immediately, setting the write lock hold count to - * one. - * - *

If the current thread already holds this lock then the - * hold count is incremented by one and the method returns - * immediately. - * - *

If the lock is held by another thread then the current - * thread becomes disabled for thread scheduling purposes and - * lies dormant until one of two things happens: - * - *

    - * - *
  • The write lock is acquired by the current thread; or - * - *
  • Some other thread {@linkplain Thread#interrupt interrupts} - * the current thread. - * - *
- * - *

If the write lock is acquired by the current thread then the - * lock hold count is set to one. - * - *

If the current thread: - * - *

    - * - *
  • has its interrupted status set on entry to this method; - * or - * - *
  • is {@linkplain Thread#interrupt interrupted} while - * acquiring the write lock, - * - *
- * - * then {@link InterruptedException} is thrown and the current - * thread's interrupted status is cleared. - * - *

In this implementation, as this method is an explicit - * interruption point, preference is given to responding to - * the interrupt over normal or reentrant acquisition of the - * lock. - * - * @throws InterruptedException if the current thread is interrupted - */ - public void lockInterruptibly() throws InterruptedException { - sync.acquireInterruptibly(1); - } - - /** - * Acquires the write lock only if it is not held by another thread - * at the time of invocation. - * - *

Acquires the write lock if neither the read nor write lock - * are held by another thread - * and returns immediately with the value {@code true}, - * setting the write lock hold count to one. Even when this lock has - * been set to use a fair ordering policy, a call to - * {@code tryLock()} will immediately acquire the - * lock if it is available, whether or not other threads are - * currently waiting for the write lock. This "barging" - * behavior can be useful in certain circumstances, even - * though it breaks fairness. If you want to honor the - * fairness setting for this lock, then use {@link - * #tryLock(long, TimeUnit) tryLock(0, TimeUnit.SECONDS) } - * which is almost equivalent (it also detects interruption). - * - *

If the current thread already holds this lock then the - * hold count is incremented by one and the method returns - * {@code true}. - * - *

If the lock is held by another thread then this method - * will return immediately with the value {@code false}. - * - * @return {@code true} if the lock was free and was acquired - * by the current thread, or the write lock was already held - * by the current thread; and {@code false} otherwise. - */ - public boolean tryLock( ) { - return sync.tryWriteLock(); - } - - /** - * Acquires the write lock if it is not held by another thread - * within the given waiting time and the current thread has - * not been {@linkplain Thread#interrupt interrupted}. - * - *

Acquires the write lock if neither the read nor write lock - * are held by another thread - * and returns immediately with the value {@code true}, - * setting the write lock hold count to one. If this lock has been - * set to use a fair ordering policy then an available lock - * will not be acquired if any other threads are - * waiting for the write lock. This is in contrast to the {@link - * #tryLock()} method. If you want a timed {@code tryLock} - * that does permit barging on a fair lock then combine the - * timed and un-timed forms together: - * - *

if (lock.tryLock() || lock.tryLock(timeout, unit) ) { ... }
-         * 
- * - *

If the current thread already holds this lock then the - * hold count is incremented by one and the method returns - * {@code true}. - * - *

If the lock is held by another thread then the current - * thread becomes disabled for thread scheduling purposes and - * lies dormant until one of three things happens: - * - *

    - * - *
  • The write lock is acquired by the current thread; or - * - *
  • Some other thread {@linkplain Thread#interrupt interrupts} - * the current thread; or - * - *
  • The specified waiting time elapses - * - *
- * - *

If the write lock is acquired then the value {@code true} is - * returned and the write lock hold count is set to one. - * - *

If the current thread: - * - *

    - * - *
  • has its interrupted status set on entry to this method; - * or - * - *
  • is {@linkplain Thread#interrupt interrupted} while - * acquiring the write lock, - * - *
- * - * then {@link InterruptedException} is thrown and the current - * thread's interrupted status is cleared. - * - *

If the specified waiting time elapses then the value - * {@code false} is returned. If the time is less than or - * equal to zero, the method will not wait at all. - * - *

In this implementation, as this method is an explicit - * interruption point, preference is given to responding to - * the interrupt over normal or reentrant acquisition of the - * lock, and over reporting the elapse of the waiting time. - * - * @param timeout the time to wait for the write lock - * @param unit the time unit of the timeout argument - * - * @return {@code true} if the lock was free and was acquired - * by the current thread, or the write lock was already held by the - * current thread; and {@code false} if the waiting time - * elapsed before the lock could be acquired. - * - * @throws InterruptedException if the current thread is interrupted - * @throws NullPointerException if the time unit is null - * - */ - public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException { - return sync.tryAcquireNanos(1, unit.toNanos(timeout)); - } - - /** - * Attempts to release this lock. - * - *

If the current thread is the holder of this lock then - * the hold count is decremented. If the hold count is now - * zero then the lock is released. If the current thread is - * not the holder of this lock then {@link - * IllegalMonitorStateException} is thrown. - * - * @throws IllegalMonitorStateException if the current thread does not - * hold this lock. - */ - public void unlock() { - sync.release(1); - } - - /** - * Returns a {@link Condition} instance for use with this - * {@link Lock} instance. - *

The returned {@link Condition} instance supports the same - * usages as do the {@link Object} monitor methods ({@link - * Object#wait() wait}, {@link Object#notify notify}, and {@link - * Object#notifyAll notifyAll}) when used with the built-in - * monitor lock. - * - *

    - * - *
  • If this write lock is not held when any {@link - * Condition} method is called then an {@link - * IllegalMonitorStateException} is thrown. (Read locks are - * held independently of write locks, so are not checked or - * affected. However it is essentially always an error to - * invoke a condition waiting method when the current thread - * has also acquired read locks, since other threads that - * could unblock it will not be able to acquire the write - * lock.) - * - *
  • When the condition {@linkplain Condition#await() waiting} - * methods are called the write lock is released and, before - * they return, the write lock is reacquired and the lock hold - * count restored to what it was when the method was called. - * - *
  • If a thread is {@linkplain Thread#interrupt interrupted} while - * waiting then the wait will terminate, an {@link - * InterruptedException} will be thrown, and the thread's - * interrupted status will be cleared. - * - *
  • Waiting threads are signalled in FIFO order. - * - *
  • The ordering of lock reacquisition for threads returning - * from waiting methods is the same as for threads initially - * acquiring the lock, which is in the default case not specified, - * but for fair locks favors those threads that have been - * waiting the longest. - * - *
- * - * @return the Condition object - */ - public Condition newCondition() { - return sync.newCondition(); - } - - /** - * Returns a string identifying this lock, as well as its lock - * state. The state, in brackets includes either the String - * {@code "Unlocked"} or the String {@code "Locked by"} - * followed by the {@linkplain Thread#getName name} of the owning thread. - * - * @return a string identifying this lock, as well as its lock state - */ - public String toString() { - Thread o = sync.getOwner(); - return super.toString() + ((o == null) ? - "[Unlocked]" : - "[Locked by thread " + o.getName() + "]"); - } - - } - - // Instrumentation and status - - /** - * Returns {@code true} if this lock has fairness set true. - * - * @return {@code true} if this lock has fairness set true - */ - public final boolean isFair() { - return sync instanceof FairSync; - } - - /** - * Returns the thread that currently owns the write lock, or - * {@code null} if not owned. When this method is called by a - * thread that is not the owner, the return value reflects a - * best-effort approximation of current lock status. For example, - * the owner may be momentarily {@code null} even if there are - * threads trying to acquire the lock but have not yet done so. - * This method is designed to facilitate construction of - * subclasses that provide more extensive lock monitoring - * facilities. - * - * @return the owner, or {@code null} if not owned - */ - protected Thread getOwner() { - return sync.getOwner(); - } - - /** - * Queries the number of read locks held for this lock. This - * method is designed for use in monitoring system state, not for - * synchronization control. - * @return the number of read locks held. - */ - public int getReadLockCount() { - return sync.getReadLockCount(); - } - - /** - * Queries if the write lock is held by any thread. This method is - * designed for use in monitoring system state, not for - * synchronization control. - * - * @return {@code true} if any thread holds the write lock and - * {@code false} otherwise - */ - public boolean isWriteLocked() { - return sync.isWriteLocked(); - } - - /** - * Queries if the write lock is held by the current thread. - * - * @return {@code true} if the current thread holds the write lock and - * {@code false} otherwise - */ - public boolean isWriteLockedByCurrentThread() { - return sync.isHeldExclusively(); - } - - /** - * Queries the number of reentrant write holds on this lock by the - * current thread. A writer thread has a hold on a lock for - * each lock action that is not matched by an unlock action. - * - * @return the number of holds on the write lock by the current thread, - * or zero if the write lock is not held by the current thread - */ - public int getWriteHoldCount() { - return sync.getWriteHoldCount(); - } - - /** - * Returns a collection containing threads that may be waiting to - * acquire the write lock. Because the actual set of threads may - * change dynamically while constructing this result, the returned - * collection is only a best-effort estimate. The elements of the - * returned collection are in no particular order. This method is - * designed to facilitate construction of subclasses that provide - * more extensive lock monitoring facilities. - * - * @return the collection of threads - */ - protected Collection getQueuedWriterThreads() { - return sync.getExclusiveQueuedThreads(); - } - - /** - * Returns a collection containing threads that may be waiting to - * acquire the read lock. Because the actual set of threads may - * change dynamically while constructing this result, the returned - * collection is only a best-effort estimate. The elements of the - * returned collection are in no particular order. This method is - * designed to facilitate construction of subclasses that provide - * more extensive lock monitoring facilities. - * - * @return the collection of threads - */ - protected Collection getQueuedReaderThreads() { - return sync.getSharedQueuedThreads(); - } - - /** - * Queries whether any threads are waiting to acquire the read or - * write lock. Note that because cancellations may occur at any - * time, a {@code true} return does not guarantee that any other - * thread will ever acquire a lock. This method is designed - * primarily for use in monitoring of the system state. - * - * @return {@code true} if there may be other threads waiting to - * acquire the lock - */ - public final boolean hasQueuedThreads() { - return sync.hasQueuedThreads(); - } - - /** - * Queries whether the given thread is waiting to acquire either - * the read or write lock. Note that because cancellations may - * occur at any time, a {@code true} return does not guarantee - * that this thread will ever acquire a lock. This method is - * designed primarily for use in monitoring of the system state. - * - * @param thread the thread - * @return {@code true} if the given thread is queued waiting for this lock - * @throws NullPointerException if the thread is null - */ - public final boolean hasQueuedThread(Thread thread) { - return sync.isQueued(thread); - } - - /** - * Returns an estimate of the number of threads waiting to acquire - * either the read or write lock. The value is only an estimate - * because the number of threads may change dynamically while this - * method traverses internal data structures. This method is - * designed for use in monitoring of the system state, not for - * synchronization control. - * - * @return the estimated number of threads waiting for this lock - */ - public final int getQueueLength() { - return sync.getQueueLength(); - } - - /** - * Returns a collection containing threads that may be waiting to - * acquire either the read or write lock. Because the actual set - * of threads may change dynamically while constructing this - * result, the returned collection is only a best-effort estimate. - * The elements of the returned collection are in no particular - * order. This method is designed to facilitate construction of - * subclasses that provide more extensive monitoring facilities. - * - * @return the collection of threads - */ - protected Collection getQueuedThreads() { - return sync.getQueuedThreads(); - } - - /** - * Queries whether any threads are waiting on the given condition - * associated with the write lock. Note that because timeouts and - * interrupts may occur at any time, a {@code true} return does - * not guarantee that a future {@code signal} will awaken any - * threads. This method is designed primarily for use in - * monitoring of the system state. - * - * @param condition the condition - * @return {@code true} if there are any waiting threads - * @throws IllegalMonitorStateException if this lock is not held - * @throws IllegalArgumentException if the given condition is - * not associated with this lock - * @throws NullPointerException if the condition is null - */ - public boolean hasWaiters(Condition condition) { - if (condition == null) - throw new NullPointerException(); - if (!(condition instanceof AbstractQueuedSynchronizer.ConditionObject)) - throw new IllegalArgumentException("not owner"); - return sync.hasWaiters((AbstractQueuedSynchronizer.ConditionObject)condition); - } - - /** - * Returns an estimate of the number of threads waiting on the - * given condition associated with the write lock. Note that because - * timeouts and interrupts may occur at any time, the estimate - * serves only as an upper bound on the actual number of waiters. - * This method is designed for use in monitoring of the system - * state, not for synchronization control. - * - * @param condition the condition - * @return the estimated number of waiting threads - * @throws IllegalMonitorStateException if this lock is not held - * @throws IllegalArgumentException if the given condition is - * not associated with this lock - * @throws NullPointerException if the condition is null - */ - public int getWaitQueueLength(Condition condition) { - if (condition == null) - throw new NullPointerException(); - if (!(condition instanceof AbstractQueuedSynchronizer.ConditionObject)) - throw new IllegalArgumentException("not owner"); - return sync.getWaitQueueLength((AbstractQueuedSynchronizer.ConditionObject)condition); - } - - /** - * Returns a collection containing those threads that may be - * waiting on the given condition associated with the write lock. - * Because the actual set of threads may change dynamically while - * constructing this result, the returned collection is only a - * best-effort estimate. The elements of the returned collection - * are in no particular order. This method is designed to - * facilitate construction of subclasses that provide more - * extensive condition monitoring facilities. - * - * @param condition the condition - * @return the collection of threads - * @throws IllegalMonitorStateException if this lock is not held - * @throws IllegalArgumentException if the given condition is - * not associated with this lock - * @throws NullPointerException if the condition is null - */ - protected Collection getWaitingThreads(Condition condition) { - if (condition == null) - throw new NullPointerException(); - if (!(condition instanceof AbstractQueuedSynchronizer.ConditionObject)) - throw new IllegalArgumentException("not owner"); - return sync.getWaitingThreads((AbstractQueuedSynchronizer.ConditionObject)condition); - } - - /** - * Returns a string identifying this lock, as well as its lock state. - * The state, in brackets, includes the String {@code "Write locks ="} - * followed by the number of reentrantly held write locks, and the - * String {@code "Read locks ="} followed by the number of held - * read locks. - * - * @return a string identifying this lock, as well as its lock state - */ - public String toString() { - int c = sync.getCount(); - int w = Sync.exclusiveCount(c); - int r = Sync.sharedCount(c); - - return super.toString() + - "[Write locks = " + w + ", Read locks = " + r + "]"; - } - -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/locks/UnsafeAccess.java b/libcore/concurrent/src/main/java/java/util/concurrent/locks/UnsafeAccess.java deleted file mode 100644 index 07f64e4b1..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/locks/UnsafeAccess.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.concurrent.locks; - -import sun.misc.Unsafe; - -/** - * Easy access to {@link Unsafe} for the rest of this package. - */ -/*package*/ final class UnsafeAccess { - /** non-null; unique instance of {@link Unsafe} */ - /*package*/ static final Unsafe THE_ONE = Unsafe.getUnsafe(); - - /** - * This class is uninstantiable. - */ - private UnsafeAccess() { - // This space intentionally left blank. - } -} diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/locks/package-info.java b/libcore/concurrent/src/main/java/java/util/concurrent/locks/package-info.java deleted file mode 100644 index 801ee9be6..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/locks/package-info.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -/** - * Interfaces and classes providing a framework for locking and waiting - * for conditions that is distinct from built-in synchronization and - * monitors. The framework permits much greater flexibility in the use of - * locks and conditions, at the expense of more awkward syntax. - * - *

The {@link java.util.concurrent.locks.Lock} interface supports - * locking disciplines that differ in semantics (reentrant, fair, etc), - * and that can be used in non-block-structured contexts including - * hand-over-hand and lock reordering algorithms. The main implementation - * is {@link java.util.concurrent.locks.ReentrantLock}. - * - *

The {@link java.util.concurrent.locks.ReadWriteLock} interface - * similarly defines locks that may be shared among readers but are - * exclusive to writers. Only a single implementation, {@link - * java.util.concurrent.locks.ReentrantReadWriteLock}, is provided, since - * it covers most standard usage contexts. But programmers may create - * their own implementations to cover nonstandard requirements. - * - *

The {@link java.util.concurrent.locks.Condition} interface - * describes condition variables that may be associated with Locks. - * These are similar in usage to the implicit monitors accessed using - * {@code Object.wait}, but offer extended capabilities. - * In particular, multiple {@code Condition} objects may be associated - * with a single {@code Lock}. To avoid compatibility issues, the - * names of {@code Condition} methods are different from the - * corresponding {@code Object} versions. - * - *

The {@link java.util.concurrent.locks.AbstractQueuedSynchronizer} - * class serves as a useful superclass for defining locks and other - * synchronizers that rely on queuing blocked threads. The - * {@link java.util.concurrent.locks.LockSupport} class provides - * lower-level blocking and unblocking support that is useful for those - * developers implementing their own customized lock classes. - * - * @since 1.5 - */ -package java.util.concurrent.locks; diff --git a/libcore/concurrent/src/main/java/java/util/concurrent/package-info.java b/libcore/concurrent/src/main/java/java/util/concurrent/package-info.java deleted file mode 100644 index d49ef2526..000000000 --- a/libcore/concurrent/src/main/java/java/util/concurrent/package-info.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -/** - * Utility classes commonly useful in concurrent programming. This - * package includes a few small standardized extensible frameworks, as - * well as some classes that provide useful functionality and are - * otherwise tedious or difficult to implement. Here are brief - * descriptions of the main components. See also the - * {@link java.util.concurrent.locks} and - * {@link java.util.concurrent.atomic} packages. - * - *

Executors

- * - * Interfaces. - * - * {@link java.util.concurrent.Executor} is a simple standardized - * interface for defining custom thread-like subsystems, including - * thread pools, asynchronous IO, and lightweight task frameworks. - * Depending on which concrete Executor class is being used, tasks may - * execute in a newly created thread, an existing task-execution thread, - * or the thread calling {@link java.util.concurrent.Executor#execute - * execute}, and may execute sequentially or concurrently. - * - * {@link java.util.concurrent.ExecutorService} provides a more - * complete asynchronous task execution framework. An - * ExecutorService manages queuing and scheduling of tasks, - * and allows controlled shutdown. - * - * The {@link java.util.concurrent.ScheduledExecutorService} - * subinterface and associated interfaces add support for - * delayed and periodic task execution. ExecutorServices - * provide methods arranging asynchronous execution of any - * function expressed as {@link java.util.concurrent.Callable}, - * the result-bearing analog of {@link java.lang.Runnable}. - * - * A {@link java.util.concurrent.Future} returns the results of - * a function, allows determination of whether execution has - * completed, and provides a means to cancel execution. - * - *

- * - * Implementations. - * - * Classes {@link java.util.concurrent.ThreadPoolExecutor} and - * {@link java.util.concurrent.ScheduledThreadPoolExecutor} - * provide tunable, flexible thread pools. - * - * The {@link java.util.concurrent.Executors} class provides - * factory methods for the most common kinds and configurations - * of Executors, as well as a few utility methods for using - * them. Other utilities based on {@code Executors} include the - * concrete class {@link java.util.concurrent.FutureTask} - * providing a common extensible implementation of Futures, and - * {@link java.util.concurrent.ExecutorCompletionService}, that - * assists in coordinating the processing of groups of - * asynchronous tasks. - * - *

Queues

- * - * The {@link java.util.concurrent.ConcurrentLinkedQueue} class - * supplies an efficient scalable thread-safe non-blocking FIFO - * queue. - * - *

Five implementations in {@code java.util.concurrent} support - * the extended {@link java.util.concurrent.BlockingQueue} - * interface, that defines blocking versions of put and take: - * {@link java.util.concurrent.LinkedBlockingQueue}, - * {@link java.util.concurrent.ArrayBlockingQueue}, - * {@link java.util.concurrent.SynchronousQueue}, - * {@link java.util.concurrent.PriorityBlockingQueue}, and - * {@link java.util.concurrent.DelayQueue}. - * The different classes cover the most common usage contexts - * for producer-consumer, messaging, parallel tasking, and - * related concurrent designs. - * - *

Timing

- * - * The {@link java.util.concurrent.TimeUnit} class provides - * multiple granularities (including nanoseconds) for - * specifying and controlling time-out based operations. Most - * classes in the package contain operations based on time-outs - * in addition to indefinite waits. In all cases that - * time-outs are used, the time-out specifies the minimum time - * that the method should wait before indicating that it - * timed-out. Implementations make a "best effort" - * to detect time-outs as soon as possible after they occur. - * However, an indefinite amount of time may elapse between a - * time-out being detected and a thread actually executing - * again after that time-out. All methods that accept timeout - * parameters treat values less than or equal to zero to mean - * not to wait at all. To wait "forever", you can use a value - * of {@code Long.MAX_VALUE}. - * - *

Synchronizers

- * - * Four classes aid common special-purpose synchronization idioms. - * {@link java.util.concurrent.Semaphore} is a classic concurrency tool. - * {@link java.util.concurrent.CountDownLatch} is a very simple yet very - * common utility for blocking until a given number of signals, events, - * or conditions hold. A {@link java.util.concurrent.CyclicBarrier} is a - * resettable multiway synchronization point useful in some styles of - * parallel programming. An {@link java.util.concurrent.Exchanger} allows - * two threads to exchange objects at a rendezvous point, and is useful - * in several pipeline designs. - * - *

Concurrent Collections

- * - * Besides Queues, this package supplies Collection implementations - * designed for use in multithreaded contexts: - * {@link java.util.concurrent.ConcurrentHashMap}, - * {@link java.util.concurrent.CopyOnWriteArrayList}, and - * {@link java.util.concurrent.CopyOnWriteArraySet}. - * When many threads are expected to access a given collection, a - * {@code ConcurrentHashMap} is normally preferable to a synchronized - * {@code HashMap}. A {@code CopyOnWriteArrayList} is preferable to a - * synchronized {@code ArrayList} when the expected number of reads and - * traversals greatly outnumber the number of updates to a list. - - *

The "Concurrent" prefix used with some classes in this package - * is a shorthand indicating several differences from similar - * "synchronized" classes. For example {@code java.util.Hashtable} and - * {@code Collections.synchronizedMap(new HashMap())} are - * synchronized. But {@link - * java.util.concurrent.ConcurrentHashMap} is "concurrent". A - * concurrent collection is thread-safe, but not governed by a - * single exclusion lock. In the particular case of - * ConcurrentHashMap, it safely permits any number of - * concurrent reads as well as a tunable number of concurrent - * writes. "Synchronized" classes can be useful when you need - * to prevent all access to a collection via a single lock, at - * the expense of poorer scalability. In other cases in which - * multiple threads are expected to access a common collection, - * "concurrent" versions are normally preferable. And - * unsynchronized collections are preferable when either - * collections are unshared, or are accessible only when - * holding other locks. - * - *

Most concurrent Collection implementations (including most - * Queues) also differ from the usual java.util conventions in that - * their Iterators provide weakly consistent rather than - * fast-fail traversal. A weakly consistent iterator is thread-safe, - * but does not necessarily freeze the collection while iterating, so - * it may (or may not) reflect any updates since the iterator was - * created. - * - *

Memory Consistency Properties

- * - * - * Chapter 17 of the Java Language Specification defines the - * happens-before relation on memory operations such as reads and - * writes of shared variables. The results of a write by one thread are - * guaranteed to be visible to a read by another thread only if the write - * operation happens-before the read operation. The - * {@code synchronized} and {@code volatile} constructs, as well as the - * {@code Thread.start()} and {@code Thread.join()} methods, can form - * happens-before relationships. In particular: - * - *
    - *
  • Each action in a thread happens-before every action in that - * thread that comes later in the program's order. - * - *
  • An unlock ({@code synchronized} block or method exit) of a - * monitor happens-before every subsequent lock ({@code synchronized} - * block or method entry) of that same monitor. And because - * the happens-before relation is transitive, all actions - * of a thread prior to unlocking happen-before all actions - * subsequent to any thread locking that monitor. - * - *
  • A write to a {@code volatile} field happens-before every - * subsequent read of that same field. Writes and reads of - * {@code volatile} fields have similar memory consistency effects - * as entering and exiting monitors, but do not entail - * mutual exclusion locking. - * - *
  • A call to {@code start} on a thread happens-before any - * action in the started thread. - * - *
  • All actions in a thread happen-before any other thread - * successfully returns from a {@code join} on that thread. - * - *
- * - * - * The methods of all classes in {@code java.util.concurrent} and its - * subpackages extend these guarantees to higher-level - * synchronization. In particular: - * - *
    - * - *
  • Actions in a thread prior to placing an object into any concurrent - * collection happen-before actions subsequent to the access or - * removal of that element from the collection in another thread. - * - *
  • Actions in a thread prior to the submission of a {@code Runnable} - * to an {@code Executor} happen-before its execution begins. - * Similarly for {@code Callables} submitted to an {@code ExecutorService}. - * - *
  • Actions taken by the asynchronous computation represented by a - * {@code Future} happen-before actions subsequent to the - * retrieval of the result via {@code Future.get()} in another thread. - * - *
  • Actions prior to "releasing" synchronizer methods such as - * {@code Lock.unlock}, {@code Semaphore.release}, and - * {@code CountDownLatch.countDown} happen-before actions - * subsequent to a successful "acquiring" method such as - * {@code Lock.lock}, {@code Semaphore.acquire}, - * {@code Condition.await}, and {@code CountDownLatch.await} on the - * same synchronizer object in another thread. - * - *
  • For each pair of threads that successfully exchange objects via - * an {@code Exchanger}, actions prior to the {@code exchange()} - * in each thread happen-before those subsequent to the - * corresponding {@code exchange()} in another thread. - * - *
  • Actions prior to calling {@code CyclicBarrier.await} - * happen-before actions performed by the barrier action, and - * actions performed by the barrier action happen-before actions - * subsequent to a successful return from the corresponding {@code await} - * in other threads. - * - *
- * - * @since 1.5 - */ -package java.util.concurrent; diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AbstractExecutorServiceTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AbstractExecutorServiceTest.java deleted file mode 100644 index 99a007aa0..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AbstractExecutorServiceTest.java +++ /dev/null @@ -1,808 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.math.BigInteger; -import java.security.*; - -public class AbstractExecutorServiceTest extends JSR166TestCase{ - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(AbstractExecutorServiceTest.class); - } - - /** - * A no-frills implementation of AbstractExecutorService, designed - * to test the submit methods only. - */ - static class DirectExecutorService extends AbstractExecutorService { - public void execute(Runnable r) { r.run(); } - public void shutdown() { shutdown = true; } - public List shutdownNow() { shutdown = true; return Collections.EMPTY_LIST; } - public boolean isShutdown() { return shutdown; } - public boolean isTerminated() { return isShutdown(); } - public boolean awaitTermination(long timeout, TimeUnit unit) { return isShutdown(); } - private volatile boolean shutdown = false; - } - - /** - * execute(runnable) runs it to completion - */ - public void testExecuteRunnable() { - try { - ExecutorService e = new DirectExecutorService(); - TrackedShortRunnable task = new TrackedShortRunnable(); - assertFalse(task.done); - Future future = e.submit(task); - future.get(); - assertTrue(task.done); - } - catch (ExecutionException ex) { - unexpectedException(); - } - catch (InterruptedException ex) { - unexpectedException(); - } - } - - - /** - * Completed submit(callable) returns result - */ - public void testSubmitCallable() { - try { - ExecutorService e = new DirectExecutorService(); - Future future = e.submit(new StringTask()); - String result = future.get(); - assertSame(TEST_STRING, result); - } - catch (ExecutionException ex) { - unexpectedException(); - } - catch (InterruptedException ex) { - unexpectedException(); - } - } - - /** - * Completed submit(runnable) returns successfully - */ - public void testSubmitRunnable() { - try { - ExecutorService e = new DirectExecutorService(); - Future future = e.submit(new NoOpRunnable()); - future.get(); - assertTrue(future.isDone()); - } - catch (ExecutionException ex) { - unexpectedException(); - } - catch (InterruptedException ex) { - unexpectedException(); - } - } - - /** - * Completed submit(runnable, result) returns result - */ - public void testSubmitRunnable2() { - try { - ExecutorService e = new DirectExecutorService(); - Future future = e.submit(new NoOpRunnable(), TEST_STRING); - String result = future.get(); - assertSame(TEST_STRING, result); - } - catch (ExecutionException ex) { - unexpectedException(); - } - catch (InterruptedException ex) { - unexpectedException(); - } - } - - - /** - * A submitted privileged action to completion - */ - public void testSubmitPrivilegedAction() { - Policy savedPolicy = null; - try { - savedPolicy = Policy.getPolicy(); - AdjustablePolicy policy = new AdjustablePolicy(); - policy.addPermission(new RuntimePermission("getContextClassLoader")); - policy.addPermission(new RuntimePermission("setContextClassLoader")); - Policy.setPolicy(policy); - } catch(AccessControlException ok) { - return; - } - try { - ExecutorService e = new DirectExecutorService(); - Future future = e.submit(Executors.callable(new PrivilegedAction() { - public Object run() { - return TEST_STRING; - }})); - - Object result = future.get(); - assertSame(TEST_STRING, result); - } - catch (ExecutionException ex) { - unexpectedException(); - } - catch (InterruptedException ex) { - unexpectedException(); - } - finally { - try { - Policy.setPolicy(savedPolicy); - } catch(AccessControlException ok) { - return; - } - } - } - - /** - * A submitted a privileged exception action runs to completion - */ - public void testSubmitPrivilegedExceptionAction() { - Policy savedPolicy = null; - try { - savedPolicy = Policy.getPolicy(); - AdjustablePolicy policy = new AdjustablePolicy(); - policy.addPermission(new RuntimePermission("getContextClassLoader")); - policy.addPermission(new RuntimePermission("setContextClassLoader")); - Policy.setPolicy(policy); - } catch(AccessControlException ok) { - return; - } - - try { - ExecutorService e = new DirectExecutorService(); - Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() { - public Object run() { - return TEST_STRING; - }})); - - Object result = future.get(); - assertSame(TEST_STRING, result); - } - catch (ExecutionException ex) { - unexpectedException(); - } - catch (InterruptedException ex) { - unexpectedException(); - } - finally { - Policy.setPolicy(savedPolicy); - } - } - - /** - * A submitted failed privileged exception action reports exception - */ - public void testSubmitFailedPrivilegedExceptionAction() { - Policy savedPolicy = null; - try { - savedPolicy = Policy.getPolicy(); - AdjustablePolicy policy = new AdjustablePolicy(); - policy.addPermission(new RuntimePermission("getContextClassLoader")); - policy.addPermission(new RuntimePermission("setContextClassLoader")); - Policy.setPolicy(policy); - } catch(AccessControlException ok) { - return; - } - - - try { - ExecutorService e = new DirectExecutorService(); - Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() { - public Object run() throws Exception { - throw new IndexOutOfBoundsException(); - }})); - - Object result = future.get(); - shouldThrow(); - } - catch (ExecutionException success) { - } - catch (InterruptedException ex) { - unexpectedException(); - } - finally { - Policy.setPolicy(savedPolicy); - } - } - - /** - * execute(null runnable) throws NPE - */ - public void testExecuteNullRunnable() { - try { - ExecutorService e = new DirectExecutorService(); - TrackedShortRunnable task = null; - Future future = e.submit(task); - shouldThrow(); - } - catch (NullPointerException success) { - } - catch (Exception ex) { - unexpectedException(); - } - } - - - /** - * submit(null callable) throws NPE - */ - public void testSubmitNullCallable() { - try { - ExecutorService e = new DirectExecutorService(); - StringTask t = null; - Future future = e.submit(t); - shouldThrow(); - } - catch (NullPointerException success) { - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * submit(runnable) throws RejectedExecutionException if - * executor is saturated. - */ - public void testExecute1() { - ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, 60, TimeUnit.SECONDS, new ArrayBlockingQueue(1)); - try { - - for(int i = 0; i < 5; ++i){ - p.submit(new MediumRunnable()); - } - shouldThrow(); - } catch(RejectedExecutionException success){} - joinPool(p); - } - - /** - * submit(callable) throws RejectedExecutionException - * if executor is saturated. - */ - public void testExecute2() { - ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, 60, TimeUnit.SECONDS, new ArrayBlockingQueue(1)); - try { - for(int i = 0; i < 5; ++i) { - p.submit(new SmallCallable()); - } - shouldThrow(); - } catch(RejectedExecutionException e){} - joinPool(p); - } - - - /** - * Blocking on submit(callable) throws InterruptedException if - * caller interrupted. - */ - public void testInterruptedSubmit() { - final ThreadPoolExecutor p = new ThreadPoolExecutor(1,1,60, TimeUnit.SECONDS, new ArrayBlockingQueue(10)); - Thread t = new Thread(new Runnable() { - public void run() { - try { - p.submit(new Callable() { - public Object call() { - try { - Thread.sleep(MEDIUM_DELAY_MS); - shouldThrow(); - } catch(InterruptedException e){ - } - return null; - } - }).get(); - } catch(InterruptedException success){ - } catch(Exception e) { - unexpectedException(); - } - - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - } catch(Exception e){ - unexpectedException(); - } - joinPool(p); - } - - /** - * get of submitted callable throws Exception if callable - * interrupted - */ - public void testSubmitIE() { - final ThreadPoolExecutor p = new ThreadPoolExecutor(1,1,60, TimeUnit.SECONDS, new ArrayBlockingQueue(10)); - - final Callable c = new Callable() { - public Object call() { - try { - p.submit(new SmallCallable()).get(); - shouldThrow(); - } catch(InterruptedException e){} - catch(RejectedExecutionException e2){} - catch(ExecutionException e3){} - return Boolean.TRUE; - } - }; - - - - Thread t = new Thread(new Runnable() { - public void run() { - try { - c.call(); - } catch(Exception e){} - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch(InterruptedException e){ - unexpectedException(); - } - - joinPool(p); - } - - /** - * get of submit(callable) throws ExecutionException if callable - * throws exception - */ - public void testSubmitEE() { - ThreadPoolExecutor p = new ThreadPoolExecutor(1,1,60, TimeUnit.SECONDS, new ArrayBlockingQueue(10)); - - try { - Callable c = new Callable() { - public Object call() { - int i = 5/0; - return Boolean.TRUE; - } - }; - - for(int i =0; i < 5; i++){ - p.submit(c).get(); - } - - shouldThrow(); - } - catch(ExecutionException success){ - } catch(Exception e) { - unexpectedException(); - } - joinPool(p); - } - - /** - * invokeAny(null) throws NPE - */ - public void testInvokeAny1() { - ExecutorService e = new DirectExecutorService(); - try { - e.invokeAny(null); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAny(empty collection) throws IAE - */ - public void testInvokeAny2() { - ExecutorService e = new DirectExecutorService(); - try { - e.invokeAny(new ArrayList>()); - } catch (IllegalArgumentException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAny(c) throws NPE if c has null elements - */ - public void testInvokeAny3() { - ExecutorService e = new DirectExecutorService(); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(null); - e.invokeAny(l); - } catch (NullPointerException success) { - } catch(Exception ex) { - ex.printStackTrace(); - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAny(c) throws ExecutionException if no task in c completes - */ - public void testInvokeAny4() { - ExecutorService e = new DirectExecutorService(); - try { - ArrayList> l = new ArrayList>(); - l.add(new NPETask()); - e.invokeAny(l); - } catch(ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAny(c) returns result of some task in c if at least one completes - */ - public void testInvokeAny5() { - ExecutorService e = new DirectExecutorService(); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(new StringTask()); - String result = e.invokeAny(l); - assertSame(TEST_STRING, result); - } catch (ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAll(null) throws NPE - */ - public void testInvokeAll1() { - ExecutorService e = new DirectExecutorService(); - try { - e.invokeAll(null); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAll(empty collection) returns empty collection - */ - public void testInvokeAll2() { - ExecutorService e = new DirectExecutorService(); - try { - List> r = e.invokeAll(new ArrayList>()); - assertTrue(r.isEmpty()); - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAll(c) throws NPE if c has null elements - */ - public void testInvokeAll3() { - ExecutorService e = new DirectExecutorService(); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(null); - e.invokeAll(l); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * get of returned element of invokeAll(c) throws exception on failed task - */ - public void testInvokeAll4() { - ExecutorService e = new DirectExecutorService(); - try { - ArrayList> l = new ArrayList>(); - l.add(new NPETask()); - List> result = e.invokeAll(l); - assertEquals(1, result.size()); - for (Iterator> it = result.iterator(); it.hasNext();) - it.next().get(); - } catch(ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAll(c) returns results of all completed tasks in c - */ - public void testInvokeAll5() { - ExecutorService e = new DirectExecutorService(); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(new StringTask()); - List> result = e.invokeAll(l); - assertEquals(2, result.size()); - for (Iterator> it = result.iterator(); it.hasNext();) - assertSame(TEST_STRING, it.next().get()); - } catch (ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - - /** - * timed invokeAny(null) throws NPE - */ - public void testTimedInvokeAny1() { - ExecutorService e = new DirectExecutorService(); - try { - e.invokeAny(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAny(null time unit) throws NPE - */ - public void testTimedInvokeAnyNullTimeUnit() { - ExecutorService e = new DirectExecutorService(); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - e.invokeAny(l, MEDIUM_DELAY_MS, null); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAny(empty collection) throws IAE - */ - public void testTimedInvokeAny2() { - ExecutorService e = new DirectExecutorService(); - try { - e.invokeAny(new ArrayList>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - } catch (IllegalArgumentException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAny(c) throws NPE if c has null elements - */ - public void testTimedInvokeAny3() { - ExecutorService e = new DirectExecutorService(); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(null); - e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - } catch (NullPointerException success) { - } catch(Exception ex) { - ex.printStackTrace(); - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAny(c) throws ExecutionException if no task completes - */ - public void testTimedInvokeAny4() { - ExecutorService e = new DirectExecutorService(); - try { - ArrayList> l = new ArrayList>(); - l.add(new NPETask()); - e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - } catch(ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAny(c) returns result of some task in c - */ - public void testTimedInvokeAny5() { - ExecutorService e = new DirectExecutorService(); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(new StringTask()); - String result = e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - assertSame(TEST_STRING, result); - } catch (ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAll(null) throws NPE - */ - public void testTimedInvokeAll1() { - ExecutorService e = new DirectExecutorService(); - try { - e.invokeAll(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAll(null time unit) throws NPE - */ - public void testTimedInvokeAllNullTimeUnit() { - ExecutorService e = new DirectExecutorService(); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - e.invokeAll(l, MEDIUM_DELAY_MS, null); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAll(empty collection) returns empty collection - */ - public void testTimedInvokeAll2() { - ExecutorService e = new DirectExecutorService(); - try { - List> r = e.invokeAll(new ArrayList>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - assertTrue(r.isEmpty()); - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAll(c) throws NPE if c has null elements - */ - public void testTimedInvokeAll3() { - ExecutorService e = new DirectExecutorService(); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(null); - e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * get of returned element of invokeAll(c) throws exception on failed task - */ - public void testTimedInvokeAll4() { - ExecutorService e = new DirectExecutorService(); - try { - ArrayList> l = new ArrayList>(); - l.add(new NPETask()); - List> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - assertEquals(1, result.size()); - for (Iterator> it = result.iterator(); it.hasNext();) - it.next().get(); - } catch(ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAll(c) returns results of all completed tasks in c - */ - public void testTimedInvokeAll5() { - ExecutorService e = new DirectExecutorService(); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(new StringTask()); - List> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - assertEquals(2, result.size()); - for (Iterator> it = result.iterator(); it.hasNext();) - assertSame(TEST_STRING, it.next().get()); - } catch (ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAll cancels tasks not completed by timeout - */ - public void testTimedInvokeAll6() { - ExecutorService e = new DirectExecutorService(); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(Executors.callable(new MediumPossiblyInterruptedRunnable(), TEST_STRING)); - l.add(new StringTask()); - List> result = e.invokeAll(l, SMALL_DELAY_MS, TimeUnit.MILLISECONDS); - assertEquals(3, result.size()); - Iterator> it = result.iterator(); - Future f1 = it.next(); - Future f2 = it.next(); - Future f3 = it.next(); - assertTrue(f1.isDone()); - assertFalse(f1.isCancelled()); - assertTrue(f2.isDone()); - assertTrue(f3.isDone()); - assertTrue(f3.isCancelled()); - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AbstractQueueTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AbstractQueueTest.java deleted file mode 100644 index 02513905c..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AbstractQueueTest.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.locks.*; -import java.io.*; - -public class AbstractQueueTest extends JSR166TestCase { - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(AbstractQueueTest.class); - } - - static class Succeed extends AbstractQueue { - public boolean offer(Integer x) { - if (x == null) throw new NullPointerException(); - return true; - } - public Integer peek() { return one; } - public Integer poll() { return one; } - public int size() { return 0; } - public Iterator iterator() { return null; } // not needed - } - - static class Fail extends AbstractQueue { - public boolean offer(Integer x) { - if (x == null) throw new NullPointerException(); - return false; - } - public Integer peek() { return null; } - public Integer poll() { return null; } - public int size() { return 0; } - public Iterator iterator() { return null; } // not needed - } - - /** - * add returns true if offer succeeds - */ - public void testAddS() { - Succeed q = new Succeed(); - assertTrue(q.add(two)); - } - - /** - * add throws ISE true if offer fails - */ - public void testAddF() { - Fail q = new Fail(); - try { - q.add(one); - shouldThrow(); - } catch (IllegalStateException success) { - } - } - - /** - * add throws NPE if offer does - */ - public void testAddNPE() { - Succeed q = new Succeed(); - try { - q.add(null); - shouldThrow(); - } catch (NullPointerException success) { - } - } - - /** - * remove returns normally if poll succeeds - */ - public void testRemoveS() { - Succeed q = new Succeed(); - q.remove(); - } - - /** - * remove throws NSEE if poll returns null - */ - public void testRemoveF() { - Fail q = new Fail(); - try { - q.remove(); - shouldThrow(); - } catch (NoSuchElementException success) { - } - } - - - /** - * element returns normally if peek succeeds - */ - public void testElementS() { - Succeed q = new Succeed(); - q.element(); - } - - /** - * element throws NSEE if peek returns null - */ - public void testElementF() { - Fail q = new Fail(); - try { - q.element(); - shouldThrow(); - } catch (NoSuchElementException success) { - } - } - - /** - * addAll(null) throws NPE - */ - public void testAddAll1() { - try { - Succeed q = new Succeed(); - q.addAll(null); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * addAll(this) throws IAE - */ - public void testAddAllSelf() { - try { - Succeed q = new Succeed(); - q.addAll(q); - shouldThrow(); - } - catch (IllegalArgumentException success) {} - } - - - /** - * addAll of a collection with null elements throws NPE - */ - public void testAddAll2() { - try { - Succeed q = new Succeed(); - Integer[] ints = new Integer[SIZE]; - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - /** - * addAll of a collection with any null elements throws NPE after - * possibly adding some elements - */ - public void testAddAll3() { - try { - Succeed q = new Succeed(); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new Integer(i); - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - /** - * addAll throws ISE if an add fails - */ - public void testAddAll4() { - try { - Fail q = new Fail(); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } - catch (IllegalStateException success) {} - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AbstractQueuedSynchronizerTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AbstractQueuedSynchronizerTest.java deleted file mode 100644 index db89645eb..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AbstractQueuedSynchronizerTest.java +++ /dev/null @@ -1,1304 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.locks.*; -import java.io.*; - -public class AbstractQueuedSynchronizerTest extends JSR166TestCase { - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(AbstractQueuedSynchronizerTest.class); - } - - /** - * A simple mutex class, adapted from the - * AbstractQueuedSynchronizer javadoc. Exclusive acquire tests - * exercise this as a sample user extension. Other - * methods/features of AbstractQueuedSynchronizerTest are tested - * via other test classes, including those for ReentrantLock, - * ReentrantReadWriteLock, and Semaphore - */ - static class Mutex extends AbstractQueuedSynchronizer { - public boolean isHeldExclusively() { return getState() == 1; } - - public boolean tryAcquire(int acquires) { - assertTrue(acquires == 1); - return compareAndSetState(0, 1); - } - - public boolean tryRelease(int releases) { - if (getState() == 0) throw new IllegalMonitorStateException(); - setState(0); - return true; - } - - public AbstractQueuedSynchronizer.ConditionObject newCondition() { return new AbstractQueuedSynchronizer.ConditionObject(); } - - } - - - /** - * A simple latch class, to test shared mode. - */ - static class BooleanLatch extends AbstractQueuedSynchronizer { - public boolean isSignalled() { return getState() != 0; } - - public int tryAcquireShared(int ignore) { - return isSignalled()? 1 : -1; - } - - public boolean tryReleaseShared(int ignore) { - setState(1); - return true; - } - } - - /** - * A runnable calling acquireInterruptibly - */ - class InterruptibleSyncRunnable implements Runnable { - final Mutex sync; - InterruptibleSyncRunnable(Mutex l) { sync = l; } - public void run() { - try { - sync.acquireInterruptibly(1); - } catch(InterruptedException success){} - } - } - - - /** - * A runnable calling acquireInterruptibly that expects to be - * interrupted - */ - class InterruptedSyncRunnable implements Runnable { - final Mutex sync; - InterruptedSyncRunnable(Mutex l) { sync = l; } - public void run() { - try { - sync.acquireInterruptibly(1); - threadShouldThrow(); - } catch(InterruptedException success){} - } - } - - /** - * isHeldExclusively is false upon construction - */ - public void testIsHeldExclusively() { - Mutex rl = new Mutex(); - assertFalse(rl.isHeldExclusively()); - } - - /** - * acquiring released sync succeeds - */ - public void testAcquire() { - Mutex rl = new Mutex(); - rl.acquire(1); - assertTrue(rl.isHeldExclusively()); - rl.release(1); - assertFalse(rl.isHeldExclusively()); - } - - /** - * tryAcquire on an released sync succeeds - */ - public void testTryAcquire() { - Mutex rl = new Mutex(); - assertTrue(rl.tryAcquire(1)); - assertTrue(rl.isHeldExclusively()); - rl.release(1); - } - - /** - * hasQueuedThreads reports whether there are waiting threads - */ - public void testhasQueuedThreads() { - final Mutex sync = new Mutex(); - Thread t1 = new Thread(new InterruptedSyncRunnable(sync)); - Thread t2 = new Thread(new InterruptibleSyncRunnable(sync)); - try { - assertFalse(sync.hasQueuedThreads()); - sync.acquire(1); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.hasQueuedThreads()); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.hasQueuedThreads()); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.hasQueuedThreads()); - sync.release(1); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(sync.hasQueuedThreads()); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * isQueued(null) throws NPE - */ - public void testIsQueuedNPE() { - final Mutex sync = new Mutex(); - try { - sync.isQueued(null); - shouldThrow(); - } catch (NullPointerException success) { - } - } - - /** - * isQueued reports whether a thread is queued. - */ - public void testIsQueued() { - final Mutex sync = new Mutex(); - Thread t1 = new Thread(new InterruptedSyncRunnable(sync)); - Thread t2 = new Thread(new InterruptibleSyncRunnable(sync)); - try { - assertFalse(sync.isQueued(t1)); - assertFalse(sync.isQueued(t2)); - sync.acquire(1); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.isQueued(t1)); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.isQueued(t1)); - assertTrue(sync.isQueued(t2)); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(sync.isQueued(t1)); - assertTrue(sync.isQueued(t2)); - sync.release(1); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(sync.isQueued(t1)); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(sync.isQueued(t2)); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * getFirstQueuedThread returns first waiting thread or null if none - */ - public void testGetFirstQueuedThread() { - final Mutex sync = new Mutex(); - Thread t1 = new Thread(new InterruptedSyncRunnable(sync)); - Thread t2 = new Thread(new InterruptibleSyncRunnable(sync)); - try { - assertNull(sync.getFirstQueuedThread()); - sync.acquire(1); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(t1, sync.getFirstQueuedThread()); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(t1, sync.getFirstQueuedThread()); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(t2, sync.getFirstQueuedThread()); - sync.release(1); - Thread.sleep(SHORT_DELAY_MS); - assertNull(sync.getFirstQueuedThread()); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * hasContended reports false if no thread has ever blocked, else true - */ - public void testHasContended() { - final Mutex sync = new Mutex(); - Thread t1 = new Thread(new InterruptedSyncRunnable(sync)); - Thread t2 = new Thread(new InterruptibleSyncRunnable(sync)); - try { - assertFalse(sync.hasContended()); - sync.acquire(1); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.hasContended()); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.hasContended()); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.hasContended()); - sync.release(1); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.hasContended()); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * getQueuedThreads includes waiting threads - */ - public void testGetQueuedThreads() { - final Mutex sync = new Mutex(); - Thread t1 = new Thread(new InterruptedSyncRunnable(sync)); - Thread t2 = new Thread(new InterruptibleSyncRunnable(sync)); - try { - assertTrue(sync.getQueuedThreads().isEmpty()); - sync.acquire(1); - assertTrue(sync.getQueuedThreads().isEmpty()); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.getQueuedThreads().contains(t1)); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.getQueuedThreads().contains(t1)); - assertTrue(sync.getQueuedThreads().contains(t2)); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(sync.getQueuedThreads().contains(t1)); - assertTrue(sync.getQueuedThreads().contains(t2)); - sync.release(1); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.getQueuedThreads().isEmpty()); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * getExclusiveQueuedThreads includes waiting threads - */ - public void testGetExclusiveQueuedThreads() { - final Mutex sync = new Mutex(); - Thread t1 = new Thread(new InterruptedSyncRunnable(sync)); - Thread t2 = new Thread(new InterruptibleSyncRunnable(sync)); - try { - assertTrue(sync.getExclusiveQueuedThreads().isEmpty()); - sync.acquire(1); - assertTrue(sync.getExclusiveQueuedThreads().isEmpty()); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.getExclusiveQueuedThreads().contains(t1)); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.getExclusiveQueuedThreads().contains(t1)); - assertTrue(sync.getExclusiveQueuedThreads().contains(t2)); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(sync.getExclusiveQueuedThreads().contains(t1)); - assertTrue(sync.getExclusiveQueuedThreads().contains(t2)); - sync.release(1); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.getExclusiveQueuedThreads().isEmpty()); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * getSharedQueuedThreads does not include exclusively waiting threads - */ - public void testGetSharedQueuedThreads() { - final Mutex sync = new Mutex(); - Thread t1 = new Thread(new InterruptedSyncRunnable(sync)); - Thread t2 = new Thread(new InterruptibleSyncRunnable(sync)); - try { - assertTrue(sync.getSharedQueuedThreads().isEmpty()); - sync.acquire(1); - assertTrue(sync.getSharedQueuedThreads().isEmpty()); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.getSharedQueuedThreads().isEmpty()); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.getSharedQueuedThreads().isEmpty()); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.getSharedQueuedThreads().isEmpty()); - sync.release(1); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.getSharedQueuedThreads().isEmpty()); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * tryAcquireNanos is interruptible. - */ - public void testInterruptedException2() { - final Mutex sync = new Mutex(); - sync.acquire(1); - Thread t = new Thread(new Runnable() { - public void run() { - try { - sync.tryAcquireNanos(1, MEDIUM_DELAY_MS * 1000 * 1000); - threadShouldThrow(); - } catch(InterruptedException success){} - } - }); - try { - t.start(); - t.interrupt(); - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * TryAcquire on exclusively held sync fails - */ - public void testTryAcquireWhenSynced() { - final Mutex sync = new Mutex(); - sync.acquire(1); - Thread t = new Thread(new Runnable() { - public void run() { - threadAssertFalse(sync.tryAcquire(1)); - } - }); - try { - t.start(); - t.join(); - sync.release(1); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * tryAcquireNanos on an exclusively held sync times out - */ - public void testAcquireNanos_Timeout() { - final Mutex sync = new Mutex(); - sync.acquire(1); - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertFalse(sync.tryAcquireNanos(1, 1000 * 1000)); - } catch (Exception ex) { - threadUnexpectedException(); - } - } - }); - try { - t.start(); - t.join(); - sync.release(1); - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * getState is true when acquired and false when not - */ - public void testGetState() { - final Mutex sync = new Mutex(); - sync.acquire(1); - assertTrue(sync.isHeldExclusively()); - sync.release(1); - assertFalse(sync.isHeldExclusively()); - Thread t = new Thread(new Runnable() { - public void run() { - sync.acquire(1); - try { - Thread.sleep(SMALL_DELAY_MS); - } - catch(Exception e) { - threadUnexpectedException(); - } - sync.release(1); - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.isHeldExclusively()); - t.join(); - assertFalse(sync.isHeldExclusively()); - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * acquireInterruptibly is interruptible. - */ - public void testAcquireInterruptibly1() { - final Mutex sync = new Mutex(); - sync.acquire(1); - Thread t = new Thread(new InterruptedSyncRunnable(sync)); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - sync.release(1); - t.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * acquireInterruptibly succeeds when released, else is interruptible - */ - public void testAcquireInterruptibly2() { - final Mutex sync = new Mutex(); - try { - sync.acquireInterruptibly(1); - } catch(Exception e) { - unexpectedException(); - } - Thread t = new Thread(new InterruptedSyncRunnable(sync)); - try { - t.start(); - t.interrupt(); - assertTrue(sync.isHeldExclusively()); - t.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * owns is true for a condition created by sync else false - */ - public void testOwns() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition(); - final Mutex sync2 = new Mutex(); - assertTrue(sync.owns(c)); - assertFalse(sync2.owns(c)); - } - - /** - * Calling await without holding sync throws IllegalMonitorStateException - */ - public void testAwait_IllegalMonitor() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition(); - try { - c.await(); - shouldThrow(); - } - catch (IllegalMonitorStateException success) { - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * Calling signal without holding sync throws IllegalMonitorStateException - */ - public void testSignal_IllegalMonitor() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition(); - try { - c.signal(); - shouldThrow(); - } - catch (IllegalMonitorStateException success) { - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * awaitNanos without a signal times out - */ - public void testAwaitNanos_Timeout() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition(); - try { - sync.acquire(1); - long t = c.awaitNanos(100); - assertTrue(t <= 0); - sync.release(1); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * Timed await without a signal times out - */ - public void testAwait_Timeout() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition(); - try { - sync.acquire(1); - assertFalse(c.await(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - sync.release(1); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * awaitUntil without a signal times out - */ - public void testAwaitUntil_Timeout() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition(); - try { - sync.acquire(1); - java.util.Date d = new java.util.Date(); - assertFalse(c.awaitUntil(new java.util.Date(d.getTime() + 10))); - sync.release(1); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * await returns when signalled - */ - public void testAwait() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - sync.acquire(1); - c.await(); - sync.release(1); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - sync.acquire(1); - c.signal(); - sync.release(1); - t.join(SHORT_DELAY_MS); - assertFalse(t.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - - - /** - * hasWaiters throws NPE if null - */ - public void testHasWaitersNPE() { - final Mutex sync = new Mutex(); - try { - sync.hasWaiters(null); - shouldThrow(); - } catch (NullPointerException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - /** - * getWaitQueueLength throws NPE if null - */ - public void testGetWaitQueueLengthNPE() { - final Mutex sync = new Mutex(); - try { - sync.getWaitQueueLength(null); - shouldThrow(); - } catch (NullPointerException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - - /** - * getWaitingThreads throws NPE if null - */ - public void testGetWaitingThreadsNPE() { - final Mutex sync = new Mutex(); - try { - sync.getWaitingThreads(null); - shouldThrow(); - } catch (NullPointerException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - - /** - * hasWaiters throws IAE if not owned - */ - public void testHasWaitersIAE() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = (sync.newCondition()); - final Mutex sync2 = new Mutex(); - try { - sync2.hasWaiters(c); - shouldThrow(); - } catch (IllegalArgumentException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - /** - * hasWaiters throws IMSE if not synced - */ - public void testHasWaitersIMSE() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = (sync.newCondition()); - try { - sync.hasWaiters(c); - shouldThrow(); - } catch (IllegalMonitorStateException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - - /** - * getWaitQueueLength throws IAE if not owned - */ - public void testGetWaitQueueLengthIAE() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = (sync.newCondition()); - final Mutex sync2 = new Mutex(); - try { - sync2.getWaitQueueLength(c); - shouldThrow(); - } catch (IllegalArgumentException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - /** - * getWaitQueueLength throws IMSE if not synced - */ - public void testGetWaitQueueLengthIMSE() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = (sync.newCondition()); - try { - sync.getWaitQueueLength(c); - shouldThrow(); - } catch (IllegalMonitorStateException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - - /** - * getWaitingThreads throws IAE if not owned - */ - public void testGetWaitingThreadsIAE() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = (sync.newCondition()); - final Mutex sync2 = new Mutex(); - try { - sync2.getWaitingThreads(c); - shouldThrow(); - } catch (IllegalArgumentException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - /** - * getWaitingThreads throws IMSE if not synced - */ - public void testGetWaitingThreadsIMSE() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = (sync.newCondition()); - try { - sync.getWaitingThreads(c); - shouldThrow(); - } catch (IllegalMonitorStateException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - - - /** - * hasWaiters returns true when a thread is waiting, else false - */ - public void testHasWaiters() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - sync.acquire(1); - threadAssertFalse(sync.hasWaiters(c)); - threadAssertEquals(0, sync.getWaitQueueLength(c)); - c.await(); - sync.release(1); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - sync.acquire(1); - assertTrue(sync.hasWaiters(c)); - assertEquals(1, sync.getWaitQueueLength(c)); - c.signal(); - sync.release(1); - Thread.sleep(SHORT_DELAY_MS); - sync.acquire(1); - assertFalse(sync.hasWaiters(c)); - assertEquals(0, sync.getWaitQueueLength(c)); - sync.release(1); - t.join(SHORT_DELAY_MS); - assertFalse(t.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * getWaitQueueLength returns number of waiting threads - */ - public void testGetWaitQueueLength() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition(); - Thread t1 = new Thread(new Runnable() { - public void run() { - try { - sync.acquire(1); - threadAssertFalse(sync.hasWaiters(c)); - threadAssertEquals(0, sync.getWaitQueueLength(c)); - c.await(); - sync.release(1); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - Thread t2 = new Thread(new Runnable() { - public void run() { - try { - sync.acquire(1); - threadAssertTrue(sync.hasWaiters(c)); - threadAssertEquals(1, sync.getWaitQueueLength(c)); - c.await(); - sync.release(1); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - try { - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - sync.acquire(1); - assertTrue(sync.hasWaiters(c)); - assertEquals(2, sync.getWaitQueueLength(c)); - c.signalAll(); - sync.release(1); - Thread.sleep(SHORT_DELAY_MS); - sync.acquire(1); - assertFalse(sync.hasWaiters(c)); - assertEquals(0, sync.getWaitQueueLength(c)); - sync.release(1); - t1.join(SHORT_DELAY_MS); - t2.join(SHORT_DELAY_MS); - assertFalse(t1.isAlive()); - assertFalse(t2.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * getWaitingThreads returns only and all waiting threads - */ - public void testGetWaitingThreads() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition(); - Thread t1 = new Thread(new Runnable() { - public void run() { - try { - sync.acquire(1); - threadAssertTrue(sync.getWaitingThreads(c).isEmpty()); - c.await(); - sync.release(1); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - Thread t2 = new Thread(new Runnable() { - public void run() { - try { - sync.acquire(1); - threadAssertFalse(sync.getWaitingThreads(c).isEmpty()); - c.await(); - sync.release(1); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - try { - sync.acquire(1); - assertTrue(sync.getWaitingThreads(c).isEmpty()); - sync.release(1); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - sync.acquire(1); - assertTrue(sync.hasWaiters(c)); - assertTrue(sync.getWaitingThreads(c).contains(t1)); - assertTrue(sync.getWaitingThreads(c).contains(t2)); - c.signalAll(); - sync.release(1); - Thread.sleep(SHORT_DELAY_MS); - sync.acquire(1); - assertFalse(sync.hasWaiters(c)); - assertTrue(sync.getWaitingThreads(c).isEmpty()); - sync.release(1); - t1.join(SHORT_DELAY_MS); - t2.join(SHORT_DELAY_MS); - assertFalse(t1.isAlive()); - assertFalse(t2.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - - - /** - * awaitUninterruptibly doesn't abort on interrupt - */ - public void testAwaitUninterruptibly() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition(); - Thread t = new Thread(new Runnable() { - public void run() { - sync.acquire(1); - c.awaitUninterruptibly(); - sync.release(1); - } - }); - - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - sync.acquire(1); - c.signal(); - sync.release(1); - t.join(SHORT_DELAY_MS); - assertFalse(t.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * await is interruptible - */ - public void testAwait_Interrupt() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - sync.acquire(1); - c.await(); - sync.release(1); - threadShouldThrow(); - } - catch(InterruptedException success) { - } - } - }); - - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(SHORT_DELAY_MS); - assertFalse(t.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * awaitNanos is interruptible - */ - public void testAwaitNanos_Interrupt() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - sync.acquire(1); - c.awaitNanos(1000 * 1000 * 1000); // 1 sec - sync.release(1); - threadShouldThrow(); - } - catch(InterruptedException success) { - } - } - }); - - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(SHORT_DELAY_MS); - assertFalse(t.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * awaitUntil is interruptible - */ - public void testAwaitUntil_Interrupt() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - sync.acquire(1); - java.util.Date d = new java.util.Date(); - c.awaitUntil(new java.util.Date(d.getTime() + 10000)); - sync.release(1); - threadShouldThrow(); - } - catch(InterruptedException success) { - } - } - }); - - try { - t.start(); - // BEGIN android-changed - Thread.sleep(SMALL_DELAY_MS); // SHORT_DELAY_MS was flaky on Android - t.interrupt(); - t.join(SMALL_DELAY_MS); // SHORT_DELAY_MS was flaky on Android - // END android-changed - assertFalse(t.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * signalAll wakes up all threads - */ - public void testSignalAll() { - final Mutex sync = new Mutex(); - final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition(); - Thread t1 = new Thread(new Runnable() { - public void run() { - try { - sync.acquire(1); - c.await(); - sync.release(1); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - Thread t2 = new Thread(new Runnable() { - public void run() { - try { - sync.acquire(1); - c.await(); - sync.release(1); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - try { - t1.start(); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - sync.acquire(1); - c.signalAll(); - sync.release(1); - t1.join(SHORT_DELAY_MS); - t2.join(SHORT_DELAY_MS); - assertFalse(t1.isAlive()); - assertFalse(t2.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - - /** - * toString indicates current state - */ - public void testToString() { - Mutex sync = new Mutex(); - String us = sync.toString(); - assertTrue(us.indexOf("State = 0") >= 0); - sync.acquire(1); - String ls = sync.toString(); - assertTrue(ls.indexOf("State = 1") >= 0); - } - - /** - * A serialized AQS deserializes with current state - */ - public void testSerialization() { - Mutex l = new Mutex(); - l.acquire(1); - assertTrue(l.isHeldExclusively()); - - try { - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(l); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - Mutex r = (Mutex) in.readObject(); - assertTrue(r.isHeldExclusively()); - } catch(Exception e){ - e.printStackTrace(); - unexpectedException(); - } - } - - - /** - * tryReleaseShared setting state changes getState - */ - public void testGetStateWithReleaseShared() { - final BooleanLatch l = new BooleanLatch(); - assertFalse(l.isSignalled()); - l.releaseShared(0); - assertTrue(l.isSignalled()); - } - - /** - * releaseShared has no effect when already signalled - */ - public void testReleaseShared() { - final BooleanLatch l = new BooleanLatch(); - assertFalse(l.isSignalled()); - l.releaseShared(0); - assertTrue(l.isSignalled()); - l.releaseShared(0); - assertTrue(l.isSignalled()); - } - - /** - * acquireSharedInterruptibly returns after release, but not before - */ - public void testAcquireSharedInterruptibly() { - final BooleanLatch l = new BooleanLatch(); - - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertFalse(l.isSignalled()); - l.acquireSharedInterruptibly(0); - threadAssertTrue(l.isSignalled()); - } catch(InterruptedException e){ - threadUnexpectedException(); - } - } - }); - try { - t.start(); - assertFalse(l.isSignalled()); - Thread.sleep(SHORT_DELAY_MS); - l.releaseShared(0); - assertTrue(l.isSignalled()); - t.join(); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - - /** - * acquireSharedTimed returns after release - */ - public void testAsquireSharedTimed() { - final BooleanLatch l = new BooleanLatch(); - - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertFalse(l.isSignalled()); - threadAssertTrue(l.tryAcquireSharedNanos(0, MEDIUM_DELAY_MS* 1000 * 1000)); - threadAssertTrue(l.isSignalled()); - - } catch(InterruptedException e){ - threadUnexpectedException(); - } - } - }); - try { - t.start(); - assertFalse(l.isSignalled()); - Thread.sleep(SHORT_DELAY_MS); - l.releaseShared(0); - assertTrue(l.isSignalled()); - t.join(); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * acquireSharedInterruptibly throws IE if interrupted before released - */ - public void testAcquireSharedInterruptibly_InterruptedException() { - final BooleanLatch l = new BooleanLatch(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertFalse(l.isSignalled()); - l.acquireSharedInterruptibly(0); - threadShouldThrow(); - } catch(InterruptedException success){} - } - }); - t.start(); - try { - assertFalse(l.isSignalled()); - t.interrupt(); - t.join(); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * acquireSharedTimed throws IE if interrupted before released - */ - public void testAcquireSharedNanos_InterruptedException() { - final BooleanLatch l = new BooleanLatch(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertFalse(l.isSignalled()); - l.tryAcquireSharedNanos(0, SMALL_DELAY_MS* 1000 * 1000); - threadShouldThrow(); - } catch(InterruptedException success){} - } - }); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - assertFalse(l.isSignalled()); - t.interrupt(); - t.join(); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * acquireSharedTimed times out if not released before timeout - */ - public void testAcquireSharedNanos_Timeout() { - final BooleanLatch l = new BooleanLatch(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertFalse(l.isSignalled()); - threadAssertFalse(l.tryAcquireSharedNanos(0, SMALL_DELAY_MS* 1000 * 1000)); - } catch(InterruptedException ie){ - threadUnexpectedException(); - } - } - }); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - assertFalse(l.isSignalled()); - t.join(); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ArrayBlockingQueueTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ArrayBlockingQueueTest.java deleted file mode 100755 index b650ede1f..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ArrayBlockingQueueTest.java +++ /dev/null @@ -1,1060 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.io.*; - -public class ArrayBlockingQueueTest extends JSR166TestCase { - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(ArrayBlockingQueueTest.class); - } - - /** - * Create a queue of given size containing consecutive - * Integers 0 ... n. - */ - private ArrayBlockingQueue populatedQueue(int n) { - ArrayBlockingQueue q = new ArrayBlockingQueue(n); - assertTrue(q.isEmpty()); - for(int i = 0; i < n; i++) - assertTrue(q.offer(new Integer(i))); - assertFalse(q.isEmpty()); - assertEquals(0, q.remainingCapacity()); - assertEquals(n, q.size()); - return q; - } - - /** - * A new queue has the indicated capacity - */ - public void testConstructor1() { - assertEquals(SIZE, new ArrayBlockingQueue(SIZE).remainingCapacity()); - } - - /** - * Constructor throws IAE if capacity argument nonpositive - */ - public void testConstructor2() { - try { - ArrayBlockingQueue q = new ArrayBlockingQueue(0); - shouldThrow(); - } - catch (IllegalArgumentException success) {} - } - - /** - * Initializing from null Collection throws NPE - */ - public void testConstructor3() { - try { - ArrayBlockingQueue q = new ArrayBlockingQueue(1, true, null); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Initializing from Collection of null elements throws NPE - */ - public void testConstructor4() { - try { - Integer[] ints = new Integer[SIZE]; - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE, false, Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Initializing from Collection with some null elements throws NPE - */ - public void testConstructor5() { - try { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new Integer(i); - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE, false, Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Initializing from too large collection throws IAE - */ - public void testConstructor6() { - try { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - ArrayBlockingQueue q = new ArrayBlockingQueue(1, false, Arrays.asList(ints)); - shouldThrow(); - } - catch (IllegalArgumentException success) {} - } - - /** - * Queue contains all elements of collection used to initialize - */ - public void testConstructor7() { - try { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE, true, Arrays.asList(ints)); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); - } - finally {} - } - - /** - * Queue transitions from empty to full when elements added - */ - public void testEmptyFull() { - ArrayBlockingQueue q = new ArrayBlockingQueue(2); - assertTrue(q.isEmpty()); - assertEquals(2, q.remainingCapacity()); - q.add(one); - assertFalse(q.isEmpty()); - q.add(two); - assertFalse(q.isEmpty()); - assertEquals(0, q.remainingCapacity()); - assertFalse(q.offer(three)); - } - - /** - * remainingCapacity decreases on add, increases on remove - */ - public void testRemainingCapacity() { - ArrayBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.remainingCapacity()); - assertEquals(SIZE-i, q.size()); - q.remove(); - } - for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE-i, q.remainingCapacity()); - assertEquals(i, q.size()); - q.add(new Integer(i)); - } - } - - /** - * offer(null) throws NPE - */ - public void testOfferNull() { - try { - ArrayBlockingQueue q = new ArrayBlockingQueue(1); - q.offer(null); - shouldThrow(); - } catch (NullPointerException success) { } - } - - /** - * add(null) throws NPE - */ - public void testAddNull() { - try { - ArrayBlockingQueue q = new ArrayBlockingQueue(1); - q.add(null); - shouldThrow(); - } catch (NullPointerException success) { } - } - - /** - * Offer succeeds if not full; fails if full - */ - public void testOffer() { - ArrayBlockingQueue q = new ArrayBlockingQueue(1); - assertTrue(q.offer(zero)); - assertFalse(q.offer(one)); - } - - /** - * add succeeds if not full; throws ISE if full - */ - public void testAdd() { - try { - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertTrue(q.add(new Integer(i))); - } - assertEquals(0, q.remainingCapacity()); - q.add(new Integer(SIZE)); - } catch (IllegalStateException success){ - } - } - - /** - * addAll(null) throws NPE - */ - public void testAddAll1() { - try { - ArrayBlockingQueue q = new ArrayBlockingQueue(1); - q.addAll(null); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * addAll(this) throws IAE - */ - public void testAddAllSelf() { - try { - ArrayBlockingQueue q = populatedQueue(SIZE); - q.addAll(q); - shouldThrow(); - } - catch (IllegalArgumentException success) {} - } - - - /** - * addAll of a collection with null elements throws NPE - */ - public void testAddAll2() { - try { - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - /** - * addAll of a collection with any null elements throws NPE after - * possibly adding some elements - */ - public void testAddAll3() { - try { - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new Integer(i); - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - /** - * addAll throws ISE if not enough room - */ - public void testAddAll4() { - try { - ArrayBlockingQueue q = new ArrayBlockingQueue(1); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } - catch (IllegalStateException success) {} - } - /** - * Queue contains all elements, in traversal order, of successful addAll - */ - public void testAddAll5() { - try { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); - assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); - } - finally {} - } - - /** - * put(null) throws NPE - */ - public void testPutNull() { - try { - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); - q.put(null); - shouldThrow(); - } - catch (NullPointerException success){ - } - catch (InterruptedException ie) { - unexpectedException(); - } - } - - /** - * all elements successfully put are contained - */ - public void testPut() { - try { - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - Integer I = new Integer(i); - q.put(I); - assertTrue(q.contains(I)); - } - assertEquals(0, q.remainingCapacity()); - } - catch (InterruptedException ie) { - unexpectedException(); - } - } - - /** - * put blocks interruptibly if full - */ - public void testBlockingPut() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); - Thread t = new Thread(new Runnable() { - public void run() { - int added = 0; - try { - for (int i = 0; i < SIZE; ++i) { - q.put(new Integer(i)); - ++added; - } - q.put(new Integer(SIZE)); - threadShouldThrow(); - } catch (InterruptedException ie){ - threadAssertEquals(added, SIZE); - } - }}); - try { - t.start(); - Thread.sleep(MEDIUM_DELAY_MS); - t.interrupt(); - t.join(); - } - catch (InterruptedException ie) { - unexpectedException(); - } - } - - /** - * put blocks waiting for take when full - */ - public void testPutWithTake() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(2); - Thread t = new Thread(new Runnable() { - public void run() { - int added = 0; - try { - q.put(new Object()); - ++added; - q.put(new Object()); - ++added; - q.put(new Object()); - ++added; - q.put(new Object()); - ++added; - threadShouldThrow(); - } catch (InterruptedException e){ - threadAssertTrue(added >= 2); - } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - q.take(); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - /** - * timed offer times out if full and elements not taken - */ - public void testTimedOffer() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(2); - Thread t = new Thread(new Runnable() { - public void run() { - try { - q.put(new Object()); - q.put(new Object()); - threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS/2, TimeUnit.MILLISECONDS)); - q.offer(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch (InterruptedException success){} - } - }); - - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - /** - * take retrieves elements in FIFO order - */ - public void testTake() { - try { - ArrayBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.take()).intValue()); - } - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * take blocks interruptibly when empty - */ - public void testTakeFromEmpty() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(2); - Thread t = new Thread(new Runnable() { - public void run() { - try { - q.take(); - threadShouldThrow(); - } catch (InterruptedException success){ } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - /** - * Take removes existing elements until empty, then blocks interruptibly - */ - public void testBlockingTake() { - Thread t = new Thread(new Runnable() { - public void run() { - try { - ArrayBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - threadAssertEquals(i, ((Integer)q.take()).intValue()); - } - q.take(); - threadShouldThrow(); - } catch (InterruptedException success){ - } - }}); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } - catch (InterruptedException ie) { - unexpectedException(); - } - } - - - /** - * poll succeeds unless empty - */ - public void testPoll() { - ArrayBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.poll()).intValue()); - } - assertNull(q.poll()); - } - - /** - * timed pool with zero timeout succeeds when non-empty, else times out - */ - public void testTimedPoll0() { - try { - ArrayBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.poll(0, TimeUnit.MILLISECONDS)).intValue()); - } - assertNull(q.poll(0, TimeUnit.MILLISECONDS)); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * timed pool with nonzero timeout succeeds when non-empty, else times out - */ - public void testTimedPoll() { - try { - ArrayBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); - } - assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * Interrupted timed poll throws InterruptedException instead of - * returning timeout status - */ - public void testInterruptedTimedPoll() { - Thread t = new Thread(new Runnable() { - public void run() { - try { - ArrayBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - threadAssertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); - } - threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch (InterruptedException success){ - } - }}); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } - catch (InterruptedException ie) { - unexpectedException(); - } - } - - /** - * timed poll before a delayed offer fails; after offer succeeds; - * on interruption throws - */ - public void testTimedPollWithOffer() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(2); - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch (InterruptedException success) { } - } - }); - try { - t.start(); - Thread.sleep(SMALL_DELAY_MS); - assertTrue(q.offer(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - - /** - * peek returns next element, or null if empty - */ - public void testPeek() { - ArrayBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.peek()).intValue()); - q.poll(); - assertTrue(q.peek() == null || - i != ((Integer)q.peek()).intValue()); - } - assertNull(q.peek()); - } - - /** - * element returns next element, or throws NSEE if empty - */ - public void testElement() { - ArrayBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.element()).intValue()); - q.poll(); - } - try { - q.element(); - shouldThrow(); - } - catch (NoSuchElementException success) {} - } - - /** - * remove removes next element, or throws NSEE if empty - */ - public void testRemove() { - ArrayBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.remove()).intValue()); - } - try { - q.remove(); - shouldThrow(); - } catch (NoSuchElementException success){ - } - } - - /** - * remove(x) removes x and returns true if present - */ - public void testRemoveElement() { - ArrayBlockingQueue q = populatedQueue(SIZE); - for (int i = 1; i < SIZE; i+=2) { - assertTrue(q.remove(new Integer(i))); - } - for (int i = 0; i < SIZE; i+=2) { - assertTrue(q.remove(new Integer(i))); - assertFalse(q.remove(new Integer(i+1))); - } - assertTrue(q.isEmpty()); - } - - /** - * contains(x) reports true when elements added but not yet removed - */ - public void testContains() { - ArrayBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); - q.poll(); - assertFalse(q.contains(new Integer(i))); - } - } - - /** - * clear removes all elements - */ - public void testClear() { - ArrayBlockingQueue q = populatedQueue(SIZE); - q.clear(); - assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - assertEquals(SIZE, q.remainingCapacity()); - q.add(one); - assertFalse(q.isEmpty()); - assertTrue(q.contains(one)); - q.clear(); - assertTrue(q.isEmpty()); - } - - /** - * containsAll(c) is true when c contains a subset of elements - */ - public void testContainsAll() { - ArrayBlockingQueue q = populatedQueue(SIZE); - ArrayBlockingQueue p = new ArrayBlockingQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertTrue(q.containsAll(p)); - assertFalse(p.containsAll(q)); - p.add(new Integer(i)); - } - assertTrue(p.containsAll(q)); - } - - /** - * retainAll(c) retains only those elements of c and reports true if changed - */ - public void testRetainAll() { - ArrayBlockingQueue q = populatedQueue(SIZE); - ArrayBlockingQueue p = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - boolean changed = q.retainAll(p); - if (i == 0) - assertFalse(changed); - else - assertTrue(changed); - - assertTrue(q.containsAll(p)); - assertEquals(SIZE-i, q.size()); - p.remove(); - } - } - - /** - * removeAll(c) removes only those elements of c and reports true if changed - */ - public void testRemoveAll() { - for (int i = 1; i < SIZE; ++i) { - ArrayBlockingQueue q = populatedQueue(SIZE); - ArrayBlockingQueue p = populatedQueue(i); - assertTrue(q.removeAll(p)); - assertEquals(SIZE-i, q.size()); - for (int j = 0; j < i; ++j) { - Integer I = (Integer)(p.remove()); - assertFalse(q.contains(I)); - } - } - } - - /** - * toArray contains all elements - */ - public void testToArray() { - ArrayBlockingQueue q = populatedQueue(SIZE); - Object[] o = q.toArray(); - try { - for(int i = 0; i < o.length; i++) - assertEquals(o[i], q.take()); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * toArray(a) contains all elements - */ - public void testToArray2() { - ArrayBlockingQueue q = populatedQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - ints = (Integer[])q.toArray(ints); - try { - for(int i = 0; i < ints.length; i++) - assertEquals(ints[i], q.take()); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * toArray(null) throws NPE - */ - public void testToArray_BadArg() { - try { - ArrayBlockingQueue q = populatedQueue(SIZE); - Object o[] = q.toArray(null); - shouldThrow(); - } catch(NullPointerException success){} - } - - /** - * toArray with incompatible array type throws CCE - */ - public void testToArray1_BadArg() { - try { - ArrayBlockingQueue q = populatedQueue(SIZE); - Object o[] = q.toArray(new String[10] ); - shouldThrow(); - } catch(ArrayStoreException success){} - } - - - /** - * iterator iterates through all elements - */ - public void testIterator() { - ArrayBlockingQueue q = populatedQueue(SIZE); - Iterator it = q.iterator(); - try { - while(it.hasNext()){ - assertEquals(it.next(), q.take()); - } - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * iterator.remove removes current element - */ - public void testIteratorRemove () { - final ArrayBlockingQueue q = new ArrayBlockingQueue(3); - q.add(two); - q.add(one); - q.add(three); - - Iterator it = q.iterator(); - it.next(); - it.remove(); - - it = q.iterator(); - assertEquals(it.next(), one); - assertEquals(it.next(), three); - assertFalse(it.hasNext()); - } - - /** - * iterator ordering is FIFO - */ - public void testIteratorOrdering() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(3); - q.add(one); - q.add(two); - q.add(three); - - assertEquals("queue should be full", 0, q.remainingCapacity()); - - int k = 0; - for (Iterator it = q.iterator(); it.hasNext();) { - int i = ((Integer)(it.next())).intValue(); - assertEquals(++k, i); - } - assertEquals(3, k); - } - - /** - * Modifications do not cause iterators to fail - */ - public void testWeaklyConsistentIteration () { - final ArrayBlockingQueue q = new ArrayBlockingQueue(3); - q.add(one); - q.add(two); - q.add(three); - try { - for (Iterator it = q.iterator(); it.hasNext();) { - q.remove(); - it.next(); - } - } - catch (ConcurrentModificationException e) { - unexpectedException(); - } - assertEquals(0, q.size()); - } - - - /** - * toString contains toStrings of elements - */ - public void testToString() { - ArrayBlockingQueue q = populatedQueue(SIZE); - String s = q.toString(); - for (int i = 0; i < SIZE; ++i) { - assertTrue(s.indexOf(String.valueOf(i)) >= 0); - } - } - - - /** - * offer transfers elements across Executor tasks - */ - public void testOfferInExecutor() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(2); - q.add(one); - q.add(two); - ExecutorService executor = Executors.newFixedThreadPool(2); - executor.execute(new Runnable() { - public void run() { - threadAssertFalse(q.offer(three)); - try { - threadAssertTrue(q.offer(three, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS)); - threadAssertEquals(0, q.remainingCapacity()); - } - catch (InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - executor.execute(new Runnable() { - public void run() { - try { - Thread.sleep(SMALL_DELAY_MS); - threadAssertEquals(one, q.take()); - } - catch (InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - joinPool(executor); - - } - - /** - * poll retrieves elements across Executor threads - */ - public void testPollInExecutor() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(2); - ExecutorService executor = Executors.newFixedThreadPool(2); - executor.execute(new Runnable() { - public void run() { - threadAssertNull(q.poll()); - try { - threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS)); - threadAssertTrue(q.isEmpty()); - } - catch (InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - executor.execute(new Runnable() { - public void run() { - try { - Thread.sleep(SMALL_DELAY_MS); - q.put(one); - } - catch (InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - joinPool(executor); - } - - /** - * A deserialized serialized queue has same elements in same order - */ - public void testSerialization() { - ArrayBlockingQueue q = populatedQueue(SIZE); - - try { - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(q); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - ArrayBlockingQueue r = (ArrayBlockingQueue)in.readObject(); - assertEquals(q.size(), r.size()); - while (!q.isEmpty()) - assertEquals(q.remove(), r.remove()); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * drainTo(null) throws NPE - */ - public void testDrainToNull() { - ArrayBlockingQueue q = populatedQueue(SIZE); - try { - q.drainTo(null); - shouldThrow(); - } catch(NullPointerException success) { - } - } - - /** - * drainTo(this) throws IAE - */ - public void testDrainToSelf() { - ArrayBlockingQueue q = populatedQueue(SIZE); - try { - q.drainTo(q); - shouldThrow(); - } catch(IllegalArgumentException success) { - } - } - - /** - * drainTo(c) empties queue into another collection c - */ - public void testDrainTo() { - ArrayBlockingQueue q = populatedQueue(SIZE); - ArrayList l = new ArrayList(); - q.drainTo(l); - assertEquals(q.size(), 0); - assertEquals(l.size(), SIZE); - for (int i = 0; i < SIZE; ++i) - assertEquals(l.get(i), new Integer(i)); - q.add(zero); - q.add(one); - assertFalse(q.isEmpty()); - assertTrue(q.contains(zero)); - assertTrue(q.contains(one)); - l.clear(); - q.drainTo(l); - assertEquals(q.size(), 0); - assertEquals(l.size(), 2); - for (int i = 0; i < 2; ++i) - assertEquals(l.get(i), new Integer(i)); - } - - /** - * drainTo empties full queue, unblocking a waiting put. - */ - public void testDrainToWithActivePut() { - final ArrayBlockingQueue q = populatedQueue(SIZE); - Thread t = new Thread(new Runnable() { - public void run() { - try { - q.put(new Integer(SIZE+1)); - } catch (InterruptedException ie){ - threadUnexpectedException(); - } - } - }); - try { - t.start(); - ArrayList l = new ArrayList(); - q.drainTo(l); - assertTrue(l.size() >= SIZE); - for (int i = 0; i < SIZE; ++i) - assertEquals(l.get(i), new Integer(i)); - t.join(); - assertTrue(q.size() + l.size() >= SIZE); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * drainTo(null, n) throws NPE - */ - public void testDrainToNullN() { - ArrayBlockingQueue q = populatedQueue(SIZE); - try { - q.drainTo(null, 0); - shouldThrow(); - } catch(NullPointerException success) { - } - } - - /** - * drainTo(this, n) throws IAE - */ - public void testDrainToSelfN() { - ArrayBlockingQueue q = populatedQueue(SIZE); - try { - q.drainTo(q, 0); - shouldThrow(); - } catch(IllegalArgumentException success) { - } - } - - /** - * drainTo(c, n) empties first max {n, size} elements of queue into c - */ - public void testDrainToN() { - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE*2); - for (int i = 0; i < SIZE + 2; ++i) { - for(int j = 0; j < SIZE; j++) - assertTrue(q.offer(new Integer(j))); - ArrayList l = new ArrayList(); - q.drainTo(l, i); - int k = (i < SIZE)? i : SIZE; - assertEquals(l.size(), k); - assertEquals(q.size(), SIZE-k); - for (int j = 0; j < k; ++j) - assertEquals(l.get(j), new Integer(j)); - while (q.poll() != null) ; - } - } - - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicBooleanTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicBooleanTest.java deleted file mode 100755 index 230357afc..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicBooleanTest.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.concurrent.atomic.*; -import java.io.*; - -public class AtomicBooleanTest extends JSR166TestCase { - public static void main (String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(AtomicBooleanTest.class); - } - - /** - * constructor initializes to given value - */ - public void testConstructor() { - AtomicBoolean ai = new AtomicBoolean(true); - assertEquals(true,ai.get()); - } - - /** - * default constructed initializes to false - */ - public void testConstructor2() { - AtomicBoolean ai = new AtomicBoolean(); - assertEquals(false,ai.get()); - } - - /** - * get returns the last value set - */ - public void testGetSet() { - AtomicBoolean ai = new AtomicBoolean(true); - assertEquals(true,ai.get()); - ai.set(false); - assertEquals(false,ai.get()); - ai.set(true); - assertEquals(true,ai.get()); - - } - - /** - * compareAndSet succeeds in changing value if equal to expected else fails - */ - public void testCompareAndSet() { - AtomicBoolean ai = new AtomicBoolean(true); - assertTrue(ai.compareAndSet(true,false)); - assertEquals(false,ai.get()); - assertTrue(ai.compareAndSet(false,false)); - assertEquals(false,ai.get()); - assertFalse(ai.compareAndSet(true,false)); - assertFalse((ai.get())); - assertTrue(ai.compareAndSet(false,true)); - assertEquals(true,ai.get()); - } - - /** - * compareAndSet in one thread enables another waiting for value - * to succeed - */ - public void testCompareAndSetInMultipleThreads() { - final AtomicBoolean ai = new AtomicBoolean(true); - Thread t = new Thread(new Runnable() { - public void run() { - while(!ai.compareAndSet(false, true)) Thread.yield(); - }}); - try { - t.start(); - assertTrue(ai.compareAndSet(true, false)); - t.join(LONG_DELAY_MS); - assertFalse(t.isAlive()); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * repeated weakCompareAndSet succeeds in changing value when equal - * to expected - */ - public void testWeakCompareAndSet() { - AtomicBoolean ai = new AtomicBoolean(true); - while(!ai.weakCompareAndSet(true,false)); - assertEquals(false,ai.get()); - while(!ai.weakCompareAndSet(false,false)); - assertEquals(false,ai.get()); - while(!ai.weakCompareAndSet(false,true)); - assertEquals(true,ai.get()); - } - - /** - * getAndSet returns previous value and sets to given value - */ - public void testGetAndSet() { - AtomicBoolean ai = new AtomicBoolean(true); - assertEquals(true,ai.getAndSet(false)); - assertEquals(false,ai.getAndSet(false)); - assertEquals(false,ai.getAndSet(true)); - assertEquals(true,ai.get()); - } - - /** - * a deserialized serialized atomic holds same value - */ - public void testSerialization() { - AtomicBoolean l = new AtomicBoolean(); - - try { - l.set(true); - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(l); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - AtomicBoolean r = (AtomicBoolean) in.readObject(); - assertEquals(l.get(), r.get()); - } catch(Exception e){ - e.printStackTrace(); - unexpectedException(); - } - } - - /** - * toString returns current value. - */ - public void testToString() { - AtomicBoolean ai = new AtomicBoolean(); - assertEquals(ai.toString(), Boolean.toString(false)); - ai.set(true); - assertEquals(ai.toString(), Boolean.toString(true)); - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicIntegerArrayTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicIntegerArrayTest.java deleted file mode 100644 index cd13fcf72..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicIntegerArrayTest.java +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.concurrent.atomic.*; -import java.io.*; -import java.util.*; - -public class AtomicIntegerArrayTest extends JSR166TestCase { - - public static void main (String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(AtomicIntegerArrayTest.class); - } - - - /** - * constructor creates array of given size with all elements zero - */ - public void testConstructor() { - AtomicIntegerArray ai = new AtomicIntegerArray(SIZE); - for (int i = 0; i < SIZE; ++i) - assertEquals(0,ai.get(i)); - } - - /** - * constructor with null array throws NPE - */ - public void testConstructor2NPE() { - try { - int[] a = null; - AtomicIntegerArray ai = new AtomicIntegerArray(a); - } catch (NullPointerException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - /** - * constructor with array is of same size and has all elements - */ - public void testConstructor2() { - int[] a = { 17, 3, -42, 99, -7}; - AtomicIntegerArray ai = new AtomicIntegerArray(a); - assertEquals(a.length, ai.length()); - for (int i = 0; i < a.length; ++i) - assertEquals(a[i], ai.get(i)); - } - - /** - * get and set for out of bound indices throw IndexOutOfBoundsException - */ - public void testIndexing(){ - AtomicIntegerArray ai = new AtomicIntegerArray(SIZE); - try { - ai.get(SIZE); - } catch(IndexOutOfBoundsException success){ - } - try { - ai.get(-1); - } catch(IndexOutOfBoundsException success){ - } - try { - ai.set(SIZE, 0); - } catch(IndexOutOfBoundsException success){ - } - try { - ai.set(-1, 0); - } catch(IndexOutOfBoundsException success){ - } - } - - /** - * get returns the last value set at index - */ - public void testGetSet() { - AtomicIntegerArray ai = new AtomicIntegerArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - assertEquals(1,ai.get(i)); - ai.set(i, 2); - assertEquals(2,ai.get(i)); - ai.set(i, -3); - assertEquals(-3,ai.get(i)); - } - } - - /** - * compareAndSet succeeds in changing value if equal to expected else fails - */ - public void testCompareAndSet() { - AtomicIntegerArray ai = new AtomicIntegerArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - assertTrue(ai.compareAndSet(i, 1,2)); - assertTrue(ai.compareAndSet(i, 2,-4)); - assertEquals(-4,ai.get(i)); - assertFalse(ai.compareAndSet(i, -5,7)); - assertFalse((7 == ai.get(i))); - assertTrue(ai.compareAndSet(i, -4,7)); - assertEquals(7,ai.get(i)); - } - } - - /** - * compareAndSet in one thread enables another waiting for value - * to succeed - */ - public void testCompareAndSetInMultipleThreads() { - final AtomicIntegerArray a = new AtomicIntegerArray(1); - a.set(0, 1); - Thread t = new Thread(new Runnable() { - public void run() { - while(!a.compareAndSet(0, 2, 3)) Thread.yield(); - }}); - try { - t.start(); - assertTrue(a.compareAndSet(0, 1, 2)); - t.join(LONG_DELAY_MS); - assertFalse(t.isAlive()); - assertEquals(a.get(0), 3); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * repeated weakCompareAndSet succeeds in changing value when equal - * to expected - */ - public void testWeakCompareAndSet() { - AtomicIntegerArray ai = new AtomicIntegerArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - while(!ai.weakCompareAndSet(i, 1,2)); - while(!ai.weakCompareAndSet(i, 2,-4)); - assertEquals(-4,ai.get(i)); - while(!ai.weakCompareAndSet(i, -4,7)); - assertEquals(7,ai.get(i)); - } - } - - /** - * getAndSet returns previous value and sets to given value at given index - */ - public void testGetAndSet() { - AtomicIntegerArray ai = new AtomicIntegerArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - assertEquals(1,ai.getAndSet(i,0)); - assertEquals(0,ai.getAndSet(i,-10)); - assertEquals(-10,ai.getAndSet(i,1)); - } - } - - /** - * getAndAdd returns previous value and adds given value - */ - public void testGetAndAdd() { - AtomicIntegerArray ai = new AtomicIntegerArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - assertEquals(1,ai.getAndAdd(i,2)); - assertEquals(3,ai.get(i)); - assertEquals(3,ai.getAndAdd(i,-4)); - assertEquals(-1,ai.get(i)); - } - } - - /** - * getAndDecrement returns previous value and decrements - */ - public void testGetAndDecrement() { - AtomicIntegerArray ai = new AtomicIntegerArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - assertEquals(1,ai.getAndDecrement(i)); - assertEquals(0,ai.getAndDecrement(i)); - assertEquals(-1,ai.getAndDecrement(i)); - } - } - - /** - * getAndIncrement returns previous value and increments - */ - public void testGetAndIncrement() { - AtomicIntegerArray ai = new AtomicIntegerArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - assertEquals(1,ai.getAndIncrement(i)); - assertEquals(2,ai.get(i)); - ai.set(i,-2); - assertEquals(-2,ai.getAndIncrement(i)); - assertEquals(-1,ai.getAndIncrement(i)); - assertEquals(0,ai.getAndIncrement(i)); - assertEquals(1,ai.get(i)); - } - } - - /** - * addAndGet adds given value to current, and returns current value - */ - public void testAddAndGet() { - AtomicIntegerArray ai = new AtomicIntegerArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - assertEquals(3,ai.addAndGet(i,2)); - assertEquals(3,ai.get(i)); - assertEquals(-1,ai.addAndGet(i,-4)); - assertEquals(-1,ai.get(i)); - } - } - - /** - * decrementAndGet decrements and returns current value - */ - public void testDecrementAndGet() { - AtomicIntegerArray ai = new AtomicIntegerArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - assertEquals(0,ai.decrementAndGet(i)); - assertEquals(-1,ai.decrementAndGet(i)); - assertEquals(-2,ai.decrementAndGet(i)); - assertEquals(-2,ai.get(i)); - } - } - - /** - * incrementAndGet increments and returns current value - */ - public void testIncrementAndGet() { - AtomicIntegerArray ai = new AtomicIntegerArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - assertEquals(2,ai.incrementAndGet(i)); - assertEquals(2,ai.get(i)); - ai.set(i, -2); - assertEquals(-1,ai.incrementAndGet(i)); - assertEquals(0,ai.incrementAndGet(i)); - assertEquals(1,ai.incrementAndGet(i)); - assertEquals(1,ai.get(i)); - } - } - - static final int COUNTDOWN = 100000; - - class Counter implements Runnable { - final AtomicIntegerArray ai; - volatile int counts; - Counter(AtomicIntegerArray a) { ai = a; } - public void run() { - for (;;) { - boolean done = true; - for (int i = 0; i < ai.length(); ++i) { - int v = ai.get(i); - threadAssertTrue(v >= 0); - if (v != 0) { - done = false; - if (ai.compareAndSet(i, v, v-1)) - ++counts; - } - } - if (done) - break; - } - } - } - - /** - * Multiple threads using same array of counters successfully - * update a number of times equal to total count - */ - public void testCountingInMultipleThreads() { - try { - final AtomicIntegerArray ai = new AtomicIntegerArray(SIZE); - for (int i = 0; i < SIZE; ++i) - ai.set(i, COUNTDOWN); - Counter c1 = new Counter(ai); - Counter c2 = new Counter(ai); - Thread t1 = new Thread(c1); - Thread t2 = new Thread(c2); - t1.start(); - t2.start(); - t1.join(); - t2.join(); - assertEquals(c1.counts+c2.counts, SIZE * COUNTDOWN); - } - catch(InterruptedException ie) { - unexpectedException(); - } - } - - - /** - * a deserialized serialized array holds same values - */ - public void testSerialization() { - AtomicIntegerArray l = new AtomicIntegerArray(SIZE); - for (int i = 0; i < SIZE; ++i) - l.set(i, -i); - - try { - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(l); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - AtomicIntegerArray r = (AtomicIntegerArray) in.readObject(); - for (int i = 0; i < SIZE; ++i) { - assertEquals(l.get(i), r.get(i)); - } - } catch(Exception e){ - e.printStackTrace(); - unexpectedException(); - } - } - - - /** - * toString returns current value. - */ - public void testToString() { - int[] a = { 17, 3, -42, 99, -7}; - AtomicIntegerArray ai = new AtomicIntegerArray(a); - assertEquals(Arrays.toString(a), ai.toString()); - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicIntegerFieldUpdaterTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicIntegerFieldUpdaterTest.java deleted file mode 100755 index 4c3ecb486..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicIntegerFieldUpdaterTest.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import java.util.concurrent.atomic.*; -import junit.framework.*; -import java.util.*; - -public class AtomicIntegerFieldUpdaterTest extends JSR166TestCase { - volatile int x = 0; - int w; - long z; - public static void main(String[] args){ - junit.textui.TestRunner.run(suite()); - } - public static Test suite() { - return new TestSuite(AtomicIntegerFieldUpdaterTest.class); - } - - /** - * Construction with non-existent field throws RuntimeException - */ - public void testConstructor() { - try{ - AtomicIntegerFieldUpdater - a = AtomicIntegerFieldUpdater.newUpdater - (AtomicIntegerFieldUpdaterTest.class, "y"); - shouldThrow(); - } - catch (RuntimeException rt) {} - } - - /** - * construction with field not of given type throws RuntimeException - */ - public void testConstructor2() { - try{ - AtomicIntegerFieldUpdater - a = AtomicIntegerFieldUpdater.newUpdater - (AtomicIntegerFieldUpdaterTest.class, "z"); - shouldThrow(); - } - catch (RuntimeException rt) {} - } - - /** - * construction with non-volatile field throws RuntimeException - */ - public void testConstructor3() { - try{ - AtomicIntegerFieldUpdater - a = AtomicIntegerFieldUpdater.newUpdater - (AtomicIntegerFieldUpdaterTest.class, "w"); - shouldThrow(); - } - catch (RuntimeException rt) {} - } - - static class Base { - protected volatile int f = 0; - } - static class Sub1 extends Base { - AtomicIntegerFieldUpdater fUpdater - = AtomicIntegerFieldUpdater.newUpdater(Base.class, "f"); - } - static class Sub2 extends Base {} - - public void testProtectedFieldOnAnotherSubtype() { - Sub1 sub1 = new Sub1(); - Sub2 sub2 = new Sub2(); - - sub1.fUpdater.set(sub1, 1); - try { - sub1.fUpdater.set(sub2, 2); - shouldThrow(); - } - catch (RuntimeException rt) {} - } - - /** - * get returns the last value set or assigned - */ - public void testGetSet() { - AtomicIntegerFieldUpdater a; - try { - a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - assertEquals(1,a.get(this)); - a.set(this,2); - assertEquals(2,a.get(this)); - a.set(this,-3); - assertEquals(-3,a.get(this)); - - } - - /** - * compareAndSet succeeds in changing value if equal to expected else fails - */ - public void testCompareAndSet() { - AtomicIntegerFieldUpdater a; - try { - a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - assertTrue(a.compareAndSet(this,1,2)); - assertTrue(a.compareAndSet(this,2,-4)); - assertEquals(-4,a.get(this)); - assertFalse(a.compareAndSet(this,-5,7)); - assertFalse((7 == a.get(this))); - assertTrue(a.compareAndSet(this,-4,7)); - assertEquals(7,a.get(this)); - } - - - /** - * compareAndSet in one thread enables another waiting for value - * to succeed - */ - public void testCompareAndSetInMultipleThreads() { - x = 1; - final AtomicIntegerFieldUpdatera; - try { - a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - - Thread t = new Thread(new Runnable() { - public void run() { - while(!a.compareAndSet(AtomicIntegerFieldUpdaterTest.this, 2, 3)) Thread.yield(); - }}); - try { - t.start(); - assertTrue(a.compareAndSet(this, 1, 2)); - t.join(LONG_DELAY_MS); - assertFalse(t.isAlive()); - assertEquals(a.get(this), 3); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * repeated weakCompareAndSet succeeds in changing value when equal - * to expected - */ - public void testWeakCompareAndSet() { - AtomicIntegerFieldUpdater a; - try { - a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - while(!a.weakCompareAndSet(this,1,2)); - while(!a.weakCompareAndSet(this,2,-4)); - assertEquals(-4,a.get(this)); - while(!a.weakCompareAndSet(this,-4,7)); - assertEquals(7,a.get(this)); - } - - /** - * getAndSet returns previous value and sets to given value - */ - public void testGetAndSet() { - AtomicIntegerFieldUpdater a; - try { - a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - assertEquals(1,a.getAndSet(this, 0)); - assertEquals(0,a.getAndSet(this,-10)); - assertEquals(-10,a.getAndSet(this,1)); - } - - /** - * getAndAdd returns previous value and adds given value - */ - public void testGetAndAdd() { - AtomicIntegerFieldUpdater a; - try { - a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - assertEquals(1,a.getAndAdd(this,2)); - assertEquals(3,a.get(this)); - assertEquals(3,a.getAndAdd(this,-4)); - assertEquals(-1,a.get(this)); - } - - /** - * getAndDecrement returns previous value and decrements - */ - public void testGetAndDecrement() { - AtomicIntegerFieldUpdater a; - try { - a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - assertEquals(1,a.getAndDecrement(this)); - assertEquals(0,a.getAndDecrement(this)); - assertEquals(-1,a.getAndDecrement(this)); - } - - /** - * getAndIncrement returns previous value and increments - */ - public void testGetAndIncrement() { - AtomicIntegerFieldUpdater a; - try { - a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - assertEquals(1,a.getAndIncrement(this)); - assertEquals(2,a.get(this)); - a.set(this,-2); - assertEquals(-2,a.getAndIncrement(this)); - assertEquals(-1,a.getAndIncrement(this)); - assertEquals(0,a.getAndIncrement(this)); - assertEquals(1,a.get(this)); - } - - /** - * addAndGet adds given value to current, and returns current value - */ - public void testAddAndGet() { - AtomicIntegerFieldUpdater a; - try { - a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - assertEquals(3,a.addAndGet(this,2)); - assertEquals(3,a.get(this)); - assertEquals(-1,a.addAndGet(this,-4)); - assertEquals(-1,a.get(this)); - } - - /** - * decrementAndGet decrements and returns current value - */ - public void testDecrementAndGet() { - AtomicIntegerFieldUpdater a; - try { - a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - assertEquals(0,a.decrementAndGet(this)); - assertEquals(-1,a.decrementAndGet(this)); - assertEquals(-2,a.decrementAndGet(this)); - assertEquals(-2,a.get(this)); - } - - /** - * incrementAndGet increments and returns current value - */ - public void testIncrementAndGet() { - AtomicIntegerFieldUpdater a; - try { - a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - assertEquals(2,a.incrementAndGet(this)); - assertEquals(2,a.get(this)); - a.set(this,-2); - assertEquals(-1,a.incrementAndGet(this)); - assertEquals(0,a.incrementAndGet(this)); - assertEquals(1,a.incrementAndGet(this)); - assertEquals(1,a.get(this)); - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicIntegerTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicIntegerTest.java deleted file mode 100755 index d48478560..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicIntegerTest.java +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.concurrent.atomic.*; -import java.io.*; - -public class AtomicIntegerTest extends JSR166TestCase { - public static void main (String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(AtomicIntegerTest.class); - } - - /** - * constructor initializes to given value - */ - public void testConstructor(){ - AtomicInteger ai = new AtomicInteger(1); - assertEquals(1,ai.get()); - } - - /** - * default constructed initializes to zero - */ - public void testConstructor2(){ - AtomicInteger ai = new AtomicInteger(); - assertEquals(0,ai.get()); - } - - /** - * get returns the last value set - */ - public void testGetSet(){ - AtomicInteger ai = new AtomicInteger(1); - assertEquals(1,ai.get()); - ai.set(2); - assertEquals(2,ai.get()); - ai.set(-3); - assertEquals(-3,ai.get()); - - } - - /** - * compareAndSet succeeds in changing value if equal to expected else fails - */ - public void testCompareAndSet(){ - AtomicInteger ai = new AtomicInteger(1); - assertTrue(ai.compareAndSet(1,2)); - assertTrue(ai.compareAndSet(2,-4)); - assertEquals(-4,ai.get()); - assertFalse(ai.compareAndSet(-5,7)); - assertFalse((7 == ai.get())); - assertTrue(ai.compareAndSet(-4,7)); - assertEquals(7,ai.get()); - } - - /** - * compareAndSet in one thread enables another waiting for value - * to succeed - */ - public void testCompareAndSetInMultipleThreads() { - final AtomicInteger ai = new AtomicInteger(1); - Thread t = new Thread(new Runnable() { - public void run() { - while(!ai.compareAndSet(2, 3)) Thread.yield(); - }}); - try { - t.start(); - assertTrue(ai.compareAndSet(1, 2)); - t.join(LONG_DELAY_MS); - assertFalse(t.isAlive()); - assertEquals(ai.get(), 3); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * repeated weakCompareAndSet succeeds in changing value when equal - * to expected - */ - public void testWeakCompareAndSet(){ - AtomicInteger ai = new AtomicInteger(1); - while(!ai.weakCompareAndSet(1,2)); - while(!ai.weakCompareAndSet(2,-4)); - assertEquals(-4,ai.get()); - while(!ai.weakCompareAndSet(-4,7)); - assertEquals(7,ai.get()); - } - - /** - * getAndSet returns previous value and sets to given value - */ - public void testGetAndSet(){ - AtomicInteger ai = new AtomicInteger(1); - assertEquals(1,ai.getAndSet(0)); - assertEquals(0,ai.getAndSet(-10)); - assertEquals(-10,ai.getAndSet(1)); - } - - /** - * getAndAdd returns previous value and adds given value - */ - public void testGetAndAdd(){ - AtomicInteger ai = new AtomicInteger(1); - assertEquals(1,ai.getAndAdd(2)); - assertEquals(3,ai.get()); - assertEquals(3,ai.getAndAdd(-4)); - assertEquals(-1,ai.get()); - } - - /** - * getAndDecrement returns previous value and decrements - */ - public void testGetAndDecrement(){ - AtomicInteger ai = new AtomicInteger(1); - assertEquals(1,ai.getAndDecrement()); - assertEquals(0,ai.getAndDecrement()); - assertEquals(-1,ai.getAndDecrement()); - } - - /** - * getAndIncrement returns previous value and increments - */ - public void testGetAndIncrement(){ - AtomicInteger ai = new AtomicInteger(1); - assertEquals(1,ai.getAndIncrement()); - assertEquals(2,ai.get()); - ai.set(-2); - assertEquals(-2,ai.getAndIncrement()); - assertEquals(-1,ai.getAndIncrement()); - assertEquals(0,ai.getAndIncrement()); - assertEquals(1,ai.get()); - } - - /** - * addAndGet adds given value to current, and returns current value - */ - public void testAddAndGet(){ - AtomicInteger ai = new AtomicInteger(1); - assertEquals(3,ai.addAndGet(2)); - assertEquals(3,ai.get()); - assertEquals(-1,ai.addAndGet(-4)); - assertEquals(-1,ai.get()); - } - - /** - * decrementAndGet decrements and returns current value - */ - public void testDecrementAndGet(){ - AtomicInteger ai = new AtomicInteger(1); - assertEquals(0,ai.decrementAndGet()); - assertEquals(-1,ai.decrementAndGet()); - assertEquals(-2,ai.decrementAndGet()); - assertEquals(-2,ai.get()); - } - - /** - * incrementAndGet increments and returns current value - */ - public void testIncrementAndGet(){ - AtomicInteger ai = new AtomicInteger(1); - assertEquals(2,ai.incrementAndGet()); - assertEquals(2,ai.get()); - ai.set(-2); - assertEquals(-1,ai.incrementAndGet()); - assertEquals(0,ai.incrementAndGet()); - assertEquals(1,ai.incrementAndGet()); - assertEquals(1,ai.get()); - } - - /** - * a deserialized serialized atomic holds same value - */ - public void testSerialization() { - AtomicInteger l = new AtomicInteger(); - - try { - l.set(22); - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(l); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - AtomicInteger r = (AtomicInteger) in.readObject(); - assertEquals(l.get(), r.get()); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * toString returns current value. - */ - public void testToString() { - AtomicInteger ai = new AtomicInteger(); - for (int i = -12; i < 6; ++i) { - ai.set(i); - assertEquals(ai.toString(), Integer.toString(i)); - } - } - - /** - * intValue returns current value. - */ - public void testIntValue() { - AtomicInteger ai = new AtomicInteger(); - for (int i = -12; i < 6; ++i) { - ai.set(i); - assertEquals(i, ai.intValue()); - } - } - - - /** - * longValue returns current value. - */ - public void testLongValue() { - AtomicInteger ai = new AtomicInteger(); - for (int i = -12; i < 6; ++i) { - ai.set(i); - assertEquals((long)i, ai.longValue()); - } - } - - /** - * floatValue returns current value. - */ - public void testFloatValue() { - AtomicInteger ai = new AtomicInteger(); - for (int i = -12; i < 6; ++i) { - ai.set(i); - assertEquals((float)i, ai.floatValue()); - } - } - - /** - * doubleValue returns current value. - */ - public void testDoubleValue() { - AtomicInteger ai = new AtomicInteger(); - for (int i = -12; i < 6; ++i) { - ai.set(i); - assertEquals((double)i, ai.doubleValue()); - } - } - - - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicLongArrayTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicLongArrayTest.java deleted file mode 100644 index 99ce20491..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicLongArrayTest.java +++ /dev/null @@ -1,336 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.concurrent.atomic.*; -import java.io.*; -import java.util.*; - -public class AtomicLongArrayTest extends JSR166TestCase { - public static void main (String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(AtomicLongArrayTest.class); - } - - /** - * constructor creates array of given size with all elements zero - */ - public void testConstructor(){ - AtomicLongArray ai = new AtomicLongArray(SIZE); - for (int i = 0; i < SIZE; ++i) - assertEquals(0,ai.get(i)); - } - - /** - * constructor with null array throws NPE - */ - public void testConstructor2NPE() { - try { - long[] a = null; - AtomicLongArray ai = new AtomicLongArray(a); - } catch (NullPointerException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - /** - * constructor with array is of same size and has all elements - */ - public void testConstructor2() { - long[] a = { 17L, 3L, -42L, 99L, -7L}; - AtomicLongArray ai = new AtomicLongArray(a); - assertEquals(a.length, ai.length()); - for (int i = 0; i < a.length; ++i) - assertEquals(a[i], ai.get(i)); - } - - /** - * get and set for out of bound indices throw IndexOutOfBoundsException - */ - public void testIndexing(){ - AtomicLongArray ai = new AtomicLongArray(SIZE); - try { - ai.get(SIZE); - } catch(IndexOutOfBoundsException success){ - } - try { - ai.get(-1); - } catch(IndexOutOfBoundsException success){ - } - try { - ai.set(SIZE, 0); - } catch(IndexOutOfBoundsException success){ - } - try { - ai.set(-1, 0); - } catch(IndexOutOfBoundsException success){ - } - } - - /** - * get returns the last value set at index - */ - public void testGetSet(){ - AtomicLongArray ai = new AtomicLongArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - assertEquals(1,ai.get(i)); - ai.set(i, 2); - assertEquals(2,ai.get(i)); - ai.set(i, -3); - assertEquals(-3,ai.get(i)); - } - } - - /** - * compareAndSet succeeds in changing value if equal to expected else fails - */ - public void testCompareAndSet(){ - AtomicLongArray ai = new AtomicLongArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - assertTrue(ai.compareAndSet(i, 1,2)); - assertTrue(ai.compareAndSet(i, 2,-4)); - assertEquals(-4,ai.get(i)); - assertFalse(ai.compareAndSet(i, -5,7)); - assertFalse((7 == ai.get(i))); - assertTrue(ai.compareAndSet(i, -4,7)); - assertEquals(7,ai.get(i)); - } - } - - /** - * compareAndSet in one thread enables another waiting for value - * to succeed - */ - public void testCompareAndSetInMultipleThreads() { - final AtomicLongArray a = new AtomicLongArray(1); - a.set(0, 1); - Thread t = new Thread(new Runnable() { - public void run() { - while(!a.compareAndSet(0, 2, 3)) Thread.yield(); - }}); - try { - t.start(); - assertTrue(a.compareAndSet(0, 1, 2)); - t.join(LONG_DELAY_MS); - assertFalse(t.isAlive()); - assertEquals(a.get(0), 3); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * repeated weakCompareAndSet succeeds in changing value when equal - * to expected - */ - public void testWeakCompareAndSet(){ - AtomicLongArray ai = new AtomicLongArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - while(!ai.weakCompareAndSet(i, 1,2)); - while(!ai.weakCompareAndSet(i, 2,-4)); - assertEquals(-4,ai.get(i)); - while(!ai.weakCompareAndSet(i, -4,7)); - assertEquals(7,ai.get(i)); - } - } - - /** - * getAndSet returns previous value and sets to given value at given index - */ - public void testGetAndSet(){ - AtomicLongArray ai = new AtomicLongArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - assertEquals(1,ai.getAndSet(i,0)); - assertEquals(0,ai.getAndSet(i,-10)); - assertEquals(-10,ai.getAndSet(i,1)); - } - } - - /** - * getAndAdd returns previous value and adds given value - */ - public void testGetAndAdd(){ - AtomicLongArray ai = new AtomicLongArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - assertEquals(1,ai.getAndAdd(i,2)); - assertEquals(3,ai.get(i)); - assertEquals(3,ai.getAndAdd(i,-4)); - assertEquals(-1,ai.get(i)); - } - } - - /** - * getAndDecrement returns previous value and decrements - */ - public void testGetAndDecrement(){ - AtomicLongArray ai = new AtomicLongArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - assertEquals(1,ai.getAndDecrement(i)); - assertEquals(0,ai.getAndDecrement(i)); - assertEquals(-1,ai.getAndDecrement(i)); - } - } - - /** - * getAndIncrement returns previous value and increments - */ - public void testGetAndIncrement(){ - AtomicLongArray ai = new AtomicLongArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - assertEquals(1,ai.getAndIncrement(i)); - assertEquals(2,ai.get(i)); - ai.set(i,-2); - assertEquals(-2,ai.getAndIncrement(i)); - assertEquals(-1,ai.getAndIncrement(i)); - assertEquals(0,ai.getAndIncrement(i)); - assertEquals(1,ai.get(i)); - } - } - - /** - * addAndGet adds given value to current, and returns current value - */ - public void testAddAndGet() { - AtomicLongArray ai = new AtomicLongArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - assertEquals(3,ai.addAndGet(i,2)); - assertEquals(3,ai.get(i)); - assertEquals(-1,ai.addAndGet(i,-4)); - assertEquals(-1,ai.get(i)); - } - } - - /** - * decrementAndGet decrements and returns current value - */ - public void testDecrementAndGet(){ - AtomicLongArray ai = new AtomicLongArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - assertEquals(0,ai.decrementAndGet(i)); - assertEquals(-1,ai.decrementAndGet(i)); - assertEquals(-2,ai.decrementAndGet(i)); - assertEquals(-2,ai.get(i)); - } - } - - /** - * incrementAndGet increments and returns current value - */ - public void testIncrementAndGet() { - AtomicLongArray ai = new AtomicLongArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, 1); - assertEquals(2,ai.incrementAndGet(i)); - assertEquals(2,ai.get(i)); - ai.set(i, -2); - assertEquals(-1,ai.incrementAndGet(i)); - assertEquals(0,ai.incrementAndGet(i)); - assertEquals(1,ai.incrementAndGet(i)); - assertEquals(1,ai.get(i)); - } - } - - static final long COUNTDOWN = 100000; - - class Counter implements Runnable { - final AtomicLongArray ai; - volatile long counts; - Counter(AtomicLongArray a) { ai = a; } - public void run() { - for (;;) { - boolean done = true; - for (int i = 0; i < ai.length(); ++i) { - long v = ai.get(i); - threadAssertTrue(v >= 0); - if (v != 0) { - done = false; - if (ai.compareAndSet(i, v, v-1)) - ++counts; - } - } - if (done) - break; - } - } - } - - /** - * Multiple threads using same array of counters successfully - * update a number of times equal to total count - */ - public void testCountingInMultipleThreads() { - try { - final AtomicLongArray ai = new AtomicLongArray(SIZE); - for (int i = 0; i < SIZE; ++i) - ai.set(i, COUNTDOWN); - Counter c1 = new Counter(ai); - Counter c2 = new Counter(ai); - Thread t1 = new Thread(c1); - Thread t2 = new Thread(c2); - t1.start(); - t2.start(); - t1.join(); - t2.join(); - assertEquals(c1.counts+c2.counts, SIZE * COUNTDOWN); - } - catch(InterruptedException ie) { - unexpectedException(); - } - } - - /** - * a deserialized serialized array holds same values - */ - public void testSerialization() { - AtomicLongArray l = new AtomicLongArray(SIZE); - for (int i = 0; i < SIZE; ++i) - l.set(i, -i); - - try { - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(l); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - AtomicLongArray r = (AtomicLongArray) in.readObject(); - for (int i = 0; i < SIZE; ++i) { - assertEquals(l.get(i), r.get(i)); - } - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * toString returns current value. - */ - public void testToString() { - long[] a = { 17, 3, -42, 99, -7}; - AtomicLongArray ai = new AtomicLongArray(a); - assertEquals(Arrays.toString(a), ai.toString()); - } - - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicLongFieldUpdaterTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicLongFieldUpdaterTest.java deleted file mode 100755 index 93107954e..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicLongFieldUpdaterTest.java +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import java.util.concurrent.atomic.*; -import junit.framework.*; -import java.util.*; - -public class AtomicLongFieldUpdaterTest extends JSR166TestCase { - volatile long x = 0; - int z; - long w; - - public static void main(String[] args){ - junit.textui.TestRunner.run(suite()); - } - public static Test suite() { - return new TestSuite(AtomicLongFieldUpdaterTest.class); - } - - /** - * Construction with non-existent field throws RuntimeException - */ - public void testConstructor(){ - try{ - AtomicLongFieldUpdater - a = AtomicLongFieldUpdater.newUpdater - (AtomicLongFieldUpdaterTest.class, "y"); - shouldThrow(); - } - catch (RuntimeException rt) {} - } - - /** - * construction with field not of given type throws RuntimeException - */ - public void testConstructor2(){ - try{ - AtomicLongFieldUpdater - a = AtomicLongFieldUpdater.newUpdater - (AtomicLongFieldUpdaterTest.class, "z"); - shouldThrow(); - } - catch (RuntimeException rt) {} - } - - /** - * construction with non-volatile field throws RuntimeException - */ - public void testConstructor3(){ - try{ - AtomicLongFieldUpdater - a = AtomicLongFieldUpdater.newUpdater - (AtomicLongFieldUpdaterTest.class, "w"); - shouldThrow(); - } - - catch (RuntimeException rt) {} - } - - static class Base { - protected volatile long f = 0; - } - static class Sub1 extends Base { - AtomicLongFieldUpdater fUpdater - = AtomicLongFieldUpdater.newUpdater(Base.class, "f"); - } - static class Sub2 extends Base {} - - public void testProtectedFieldOnAnotherSubtype() { - Sub1 sub1 = new Sub1(); - Sub2 sub2 = new Sub2(); - - sub1.fUpdater.set(sub1, 1); - try { - sub1.fUpdater.set(sub2, 2); - shouldThrow(); - } - catch (RuntimeException rt) {} - } - - /** - * get returns the last value set or assigned - */ - public void testGetSet(){ - AtomicLongFieldUpdater a; - try { - a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - assertEquals(1,a.get(this)); - a.set(this,2); - assertEquals(2,a.get(this)); - a.set(this,-3); - assertEquals(-3,a.get(this)); - - } - /** - * compareAndSet succeeds in changing value if equal to expected else fails - */ - public void testCompareAndSet(){ - AtomicLongFieldUpdater a; - try { - a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - assertTrue(a.compareAndSet(this,1,2)); - assertTrue(a.compareAndSet(this,2,-4)); - assertEquals(-4,a.get(this)); - assertFalse(a.compareAndSet(this,-5,7)); - assertFalse((7 == a.get(this))); - assertTrue(a.compareAndSet(this,-4,7)); - assertEquals(7,a.get(this)); - } - - - /** - * compareAndSet in one thread enables another waiting for value - * to succeed - */ - public void testCompareAndSetInMultipleThreads() { - x = 1; - final AtomicLongFieldUpdatera; - try { - a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - - Thread t = new Thread(new Runnable() { - public void run() { - while(!a.compareAndSet(AtomicLongFieldUpdaterTest.this, 2, 3)) Thread.yield(); - }}); - try { - t.start(); - assertTrue(a.compareAndSet(this, 1, 2)); - t.join(LONG_DELAY_MS); - assertFalse(t.isAlive()); - assertEquals(a.get(this), 3); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * repeated weakCompareAndSet succeeds in changing value when equal - * to expected - */ - public void testWeakCompareAndSet(){ - AtomicLongFieldUpdater a; - try { - a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - while(!a.weakCompareAndSet(this,1,2)); - while(!a.weakCompareAndSet(this,2,-4)); - assertEquals(-4,a.get(this)); - while(!a.weakCompareAndSet(this,-4,7)); - assertEquals(7,a.get(this)); - } - - /** - * getAndSet returns previous value and sets to given value - */ - public void testGetAndSet(){ - AtomicLongFieldUpdater a; - try { - a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - assertEquals(1,a.getAndSet(this, 0)); - assertEquals(0,a.getAndSet(this,-10)); - assertEquals(-10,a.getAndSet(this,1)); - } - - /** - * getAndAdd returns previous value and adds given value - */ - public void testGetAndAdd(){ - AtomicLongFieldUpdater a; - try { - a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - assertEquals(1,a.getAndAdd(this,2)); - assertEquals(3,a.get(this)); - assertEquals(3,a.getAndAdd(this,-4)); - assertEquals(-1,a.get(this)); - } - - /** - * getAndDecrement returns previous value and decrements - */ - public void testGetAndDecrement(){ - AtomicLongFieldUpdater a; - try { - a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - assertEquals(1,a.getAndDecrement(this)); - assertEquals(0,a.getAndDecrement(this)); - assertEquals(-1,a.getAndDecrement(this)); - } - - /** - * getAndIncrement returns previous value and increments - */ - public void testGetAndIncrement(){ - AtomicLongFieldUpdater a; - try { - a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - assertEquals(1,a.getAndIncrement(this)); - assertEquals(2,a.get(this)); - a.set(this,-2); - assertEquals(-2,a.getAndIncrement(this)); - assertEquals(-1,a.getAndIncrement(this)); - assertEquals(0,a.getAndIncrement(this)); - assertEquals(1,a.get(this)); - } - - /** - * addAndGet adds given value to current, and returns current value - */ - public void testAddAndGet(){ - AtomicLongFieldUpdater a; - try { - a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - assertEquals(3,a.addAndGet(this,2)); - assertEquals(3,a.get(this)); - assertEquals(-1,a.addAndGet(this,-4)); - assertEquals(-1,a.get(this)); - } - - /** - * decrementAndGet decrements and returns current value - */ - public void testDecrementAndGet(){ - AtomicLongFieldUpdater a; - try { - a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - assertEquals(0,a.decrementAndGet(this)); - assertEquals(-1,a.decrementAndGet(this)); - assertEquals(-2,a.decrementAndGet(this)); - assertEquals(-2,a.get(this)); - } - - /** - * incrementAndGet increments and returns current value - */ - public void testIncrementAndGet(){ - AtomicLongFieldUpdater a; - try { - a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = 1; - assertEquals(2,a.incrementAndGet(this)); - assertEquals(2,a.get(this)); - a.set(this,-2); - assertEquals(-1,a.incrementAndGet(this)); - assertEquals(0,a.incrementAndGet(this)); - assertEquals(1,a.incrementAndGet(this)); - assertEquals(1,a.get(this)); - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicLongTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicLongTest.java deleted file mode 100755 index 143c84a51..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicLongTest.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.concurrent.atomic.*; -import java.io.*; - -public class AtomicLongTest extends JSR166TestCase { - public static void main (String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(AtomicLongTest.class); - } - - /** - * constructor initializes to given value - */ - public void testConstructor(){ - AtomicLong ai = new AtomicLong(1); - assertEquals(1,ai.get()); - } - - /** - * default constructed initializes to zero - */ - public void testConstructor2(){ - AtomicLong ai = new AtomicLong(); - assertEquals(0,ai.get()); - } - - /** - * get returns the last value set - */ - public void testGetSet(){ - AtomicLong ai = new AtomicLong(1); - assertEquals(1,ai.get()); - ai.set(2); - assertEquals(2,ai.get()); - ai.set(-3); - assertEquals(-3,ai.get()); - - } - - /** - * compareAndSet succeeds in changing value if equal to expected else fails - */ - public void testCompareAndSet(){ - AtomicLong ai = new AtomicLong(1); - assertTrue(ai.compareAndSet(1,2)); - assertTrue(ai.compareAndSet(2,-4)); - assertEquals(-4,ai.get()); - assertFalse(ai.compareAndSet(-5,7)); - assertFalse((7 == ai.get())); - assertTrue(ai.compareAndSet(-4,7)); - assertEquals(7,ai.get()); - } - - /** - * compareAndSet in one thread enables another waiting for value - * to succeed - */ - public void testCompareAndSetInMultipleThreads() { - final AtomicLong ai = new AtomicLong(1); - Thread t = new Thread(new Runnable() { - public void run() { - while(!ai.compareAndSet(2, 3)) Thread.yield(); - }}); - try { - t.start(); - assertTrue(ai.compareAndSet(1, 2)); - t.join(LONG_DELAY_MS); - assertFalse(t.isAlive()); - assertEquals(ai.get(), 3); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * repeated weakCompareAndSet succeeds in changing value when equal - * to expected - */ - public void testWeakCompareAndSet(){ - AtomicLong ai = new AtomicLong(1); - while(!ai.weakCompareAndSet(1,2)); - while(!ai.weakCompareAndSet(2,-4)); - assertEquals(-4,ai.get()); - while(!ai.weakCompareAndSet(-4,7)); - assertEquals(7,ai.get()); - } - - /** - * getAndSet returns previous value and sets to given value - */ - public void testGetAndSet(){ - AtomicLong ai = new AtomicLong(1); - assertEquals(1,ai.getAndSet(0)); - assertEquals(0,ai.getAndSet(-10)); - assertEquals(-10,ai.getAndSet(1)); - } - - /** - * getAndAdd returns previous value and adds given value - */ - public void testGetAndAdd(){ - AtomicLong ai = new AtomicLong(1); - assertEquals(1,ai.getAndAdd(2)); - assertEquals(3,ai.get()); - assertEquals(3,ai.getAndAdd(-4)); - assertEquals(-1,ai.get()); - } - - /** - * getAndDecrement returns previous value and decrements - */ - public void testGetAndDecrement(){ - AtomicLong ai = new AtomicLong(1); - assertEquals(1,ai.getAndDecrement()); - assertEquals(0,ai.getAndDecrement()); - assertEquals(-1,ai.getAndDecrement()); - } - - /** - * getAndIncrement returns previous value and increments - */ - public void testGetAndIncrement(){ - AtomicLong ai = new AtomicLong(1); - assertEquals(1,ai.getAndIncrement()); - assertEquals(2,ai.get()); - ai.set(-2); - assertEquals(-2,ai.getAndIncrement()); - assertEquals(-1,ai.getAndIncrement()); - assertEquals(0,ai.getAndIncrement()); - assertEquals(1,ai.get()); - } - - /** - * addAndGet adds given value to current, and returns current value - */ - public void testAddAndGet(){ - AtomicLong ai = new AtomicLong(1); - assertEquals(3,ai.addAndGet(2)); - assertEquals(3,ai.get()); - assertEquals(-1,ai.addAndGet(-4)); - assertEquals(-1,ai.get()); - } - - /** - * decrementAndGet decrements and returns current value - */ - public void testDecrementAndGet(){ - AtomicLong ai = new AtomicLong(1); - assertEquals(0,ai.decrementAndGet()); - assertEquals(-1,ai.decrementAndGet()); - assertEquals(-2,ai.decrementAndGet()); - assertEquals(-2,ai.get()); - } - - /** - * incrementAndGet increments and returns current value - */ - public void testIncrementAndGet(){ - AtomicLong ai = new AtomicLong(1); - assertEquals(2,ai.incrementAndGet()); - assertEquals(2,ai.get()); - ai.set(-2); - assertEquals(-1,ai.incrementAndGet()); - assertEquals(0,ai.incrementAndGet()); - assertEquals(1,ai.incrementAndGet()); - assertEquals(1,ai.get()); - } - - /** - * a deserialized serialized atomic holds same value - */ - public void testSerialization() { - AtomicLong l = new AtomicLong(); - - try { - l.set(-22); - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(l); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - AtomicLong r = (AtomicLong) in.readObject(); - assertEquals(l.get(), r.get()); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * toString returns current value. - */ - public void testToString() { - AtomicLong ai = new AtomicLong(); - for (long i = -12; i < 6; ++i) { - ai.set(i); - assertEquals(ai.toString(), Long.toString(i)); - } - } - - /** - * longValue returns current value. - */ - public void testLongValue() { - AtomicLong ai = new AtomicLong(); - for (int i = -12; i < 6; ++i) { - ai.set(i); - assertEquals((long)i, ai.longValue()); - } - } - - /** - * floatValue returns current value. - */ - public void testFloatValue() { - AtomicLong ai = new AtomicLong(); - for (int i = -12; i < 6; ++i) { - ai.set(i); - assertEquals((float)i, ai.floatValue()); - } - } - - /** - * doubleValue returns current value. - */ - public void testDoubleValue() { - AtomicLong ai = new AtomicLong(); - for (int i = -12; i < 6; ++i) { - ai.set(i); - assertEquals((double)i, ai.doubleValue()); - } - } - - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicMarkableReferenceTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicMarkableReferenceTest.java deleted file mode 100755 index 7b3dcb18d..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicMarkableReferenceTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.concurrent.atomic.*; - -public class AtomicMarkableReferenceTest extends JSR166TestCase{ - public static void main (String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(AtomicMarkableReferenceTest.class); - } - - /** - * constructor initializes to given reference and mark - */ - public void testConstructor(){ - AtomicMarkableReference ai = new AtomicMarkableReference(one, false); - assertEquals(one,ai.getReference()); - assertFalse(ai.isMarked()); - AtomicMarkableReference a2 = new AtomicMarkableReference(null, true); - assertNull(a2.getReference()); - assertTrue(a2.isMarked()); - - } - - /** - * get returns the last values of reference and mark set - */ - public void testGetSet(){ - boolean[] mark = new boolean[1]; - AtomicMarkableReference ai = new AtomicMarkableReference(one, false); - assertEquals(one,ai.getReference()); - assertFalse(ai.isMarked()); - assertEquals(one, ai.get(mark)); - assertFalse(mark[0]); - ai.set(two, false); - assertEquals(two,ai.getReference()); - assertFalse(ai.isMarked()); - assertEquals(two, ai.get(mark)); - assertFalse(mark[0]); - ai.set(one, true); - assertEquals(one,ai.getReference()); - assertTrue(ai.isMarked()); - assertEquals(one, ai.get(mark)); - assertTrue(mark[0]); - } - - /** - * attemptMark succeeds in single thread - */ - public void testAttemptMark(){ - boolean[] mark = new boolean[1]; - AtomicMarkableReference ai = new AtomicMarkableReference(one, false); - assertFalse(ai.isMarked()); - assertTrue(ai.attemptMark(one, true)); - assertTrue(ai.isMarked()); - assertEquals(one, ai.get(mark)); - assertTrue(mark[0]); - } - - /** - * compareAndSet succeeds in changing values if equal to expected reference - * and mark else fails - */ - public void testCompareAndSet(){ - boolean[] mark = new boolean[1]; - AtomicMarkableReference ai = new AtomicMarkableReference(one, false); - assertEquals(one, ai.get(mark)); - assertFalse(ai.isMarked()); - assertFalse(mark[0]); - - assertTrue(ai.compareAndSet(one, two, false, false)); - assertEquals(two, ai.get(mark)); - assertFalse(mark[0]); - - assertTrue(ai.compareAndSet(two, m3, false, true)); - assertEquals(m3, ai.get(mark)); - assertTrue(mark[0]); - - assertFalse(ai.compareAndSet(two, m3, true, true)); - assertEquals(m3, ai.get(mark)); - assertTrue(mark[0]); - } - - /** - * compareAndSet in one thread enables another waiting for reference value - * to succeed - */ - public void testCompareAndSetInMultipleThreads() { - final AtomicMarkableReference ai = new AtomicMarkableReference(one, false); - Thread t = new Thread(new Runnable() { - public void run() { - while(!ai.compareAndSet(two, three, false, false)) Thread.yield(); - }}); - try { - t.start(); - assertTrue(ai.compareAndSet(one, two, false, false)); - t.join(LONG_DELAY_MS); - assertFalse(t.isAlive()); - assertEquals(ai.getReference(), three); - assertFalse(ai.isMarked()); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * compareAndSet in one thread enables another waiting for mark value - * to succeed - */ - public void testCompareAndSetInMultipleThreads2() { - final AtomicMarkableReference ai = new AtomicMarkableReference(one, false); - Thread t = new Thread(new Runnable() { - public void run() { - while(!ai.compareAndSet(one, one, true, false)) Thread.yield(); - }}); - try { - t.start(); - assertTrue(ai.compareAndSet(one, one, false, true)); - t.join(LONG_DELAY_MS); - assertFalse(t.isAlive()); - assertEquals(ai.getReference(), one); - assertFalse(ai.isMarked()); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * repeated weakCompareAndSet succeeds in changing values when equal - * to expected - */ - public void testWeakCompareAndSet(){ - boolean[] mark = new boolean[1]; - AtomicMarkableReference ai = new AtomicMarkableReference(one, false); - assertEquals(one, ai.get(mark)); - assertFalse(ai.isMarked()); - assertFalse(mark[0]); - - while(!ai.weakCompareAndSet(one, two, false, false)); - assertEquals(two, ai.get(mark)); - assertFalse(mark[0]); - - while(!ai.weakCompareAndSet(two, m3, false, true)); - assertEquals(m3, ai.get(mark)); - assertTrue(mark[0]); - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicReferenceArrayTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicReferenceArrayTest.java deleted file mode 100644 index 9330d3996..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicReferenceArrayTest.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.concurrent.atomic.*; -import java.io.*; -import java.util.*; - -public class AtomicReferenceArrayTest extends JSR166TestCase -{ - public static void main (String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(AtomicReferenceArrayTest.class); - } - - /** - * constructor creates array of given size with all elements null - */ - public void testConstructor(){ - AtomicReferenceArray ai = new AtomicReferenceArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertNull(ai.get(i)); - } - } - - /** - * constructor with null array throws NPE - */ - public void testConstructor2NPE() { - try { - Integer[] a = null; - AtomicReferenceArray ai = new AtomicReferenceArray(a); - } catch (NullPointerException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - /** - * constructor with array is of same size and has all elements - */ - public void testConstructor2() { - Integer[] a = { two, one, three, four, seven}; - AtomicReferenceArray ai = new AtomicReferenceArray(a); - assertEquals(a.length, ai.length()); - for (int i = 0; i < a.length; ++i) - assertEquals(a[i], ai.get(i)); - } - - - /** - * get and set for out of bound indices throw IndexOutOfBoundsException - */ - public void testIndexing(){ - AtomicReferenceArray ai = new AtomicReferenceArray(SIZE); - try { - ai.get(SIZE); - } catch(IndexOutOfBoundsException success){ - } - try { - ai.get(-1); - } catch(IndexOutOfBoundsException success){ - } - try { - ai.set(SIZE, null); - } catch(IndexOutOfBoundsException success){ - } - try { - ai.set(-1, null); - } catch(IndexOutOfBoundsException success){ - } - } - - /** - * get returns the last value set at index - */ - public void testGetSet(){ - AtomicReferenceArray ai = new AtomicReferenceArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, one); - assertEquals(one,ai.get(i)); - ai.set(i, two); - assertEquals(two,ai.get(i)); - ai.set(i, m3); - assertEquals(m3,ai.get(i)); - } - } - - /** - * compareAndSet succeeds in changing value if equal to expected else fails - */ - public void testCompareAndSet(){ - AtomicReferenceArray ai = new AtomicReferenceArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, one); - assertTrue(ai.compareAndSet(i, one,two)); - assertTrue(ai.compareAndSet(i, two,m4)); - assertEquals(m4,ai.get(i)); - assertFalse(ai.compareAndSet(i, m5,seven)); - assertFalse((seven.equals(ai.get(i)))); - assertTrue(ai.compareAndSet(i, m4,seven)); - assertEquals(seven,ai.get(i)); - } - } - - /** - * compareAndSet in one thread enables another waiting for value - * to succeed - */ - public void testCompareAndSetInMultipleThreads() { - final AtomicReferenceArray a = new AtomicReferenceArray(1); - a.set(0, one); - Thread t = new Thread(new Runnable() { - public void run() { - while(!a.compareAndSet(0, two, three)) Thread.yield(); - }}); - try { - t.start(); - assertTrue(a.compareAndSet(0, one, two)); - t.join(LONG_DELAY_MS); - assertFalse(t.isAlive()); - assertEquals(a.get(0), three); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * repeated weakCompareAndSet succeeds in changing value when equal - * to expected - */ - public void testWeakCompareAndSet(){ - AtomicReferenceArray ai = new AtomicReferenceArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, one); - while(!ai.weakCompareAndSet(i, one,two)); - while(!ai.weakCompareAndSet(i, two,m4)); - assertEquals(m4,ai.get(i)); - while(!ai.weakCompareAndSet(i, m4,seven)); - assertEquals(seven,ai.get(i)); - } - } - - /** - * getAndSet returns previous value and sets to given value at given index - */ - public void testGetAndSet(){ - AtomicReferenceArray ai = new AtomicReferenceArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - ai.set(i, one); - assertEquals(one,ai.getAndSet(i,zero)); - assertEquals(0,ai.getAndSet(i,m10)); - assertEquals(m10,ai.getAndSet(i,one)); - } - } - - /** - * a deserialized serialized array holds same values - */ - public void testSerialization() { - AtomicReferenceArray l = new AtomicReferenceArray(SIZE); - for (int i = 0; i < SIZE; ++i) { - l.set(i, new Integer(-i)); - } - - try { - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(l); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - AtomicReferenceArray r = (AtomicReferenceArray) in.readObject(); - assertEquals(l.length(), r.length()); - for (int i = 0; i < SIZE; ++i) { - assertEquals(r.get(i), l.get(i)); - } - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * toString returns current value. - */ - public void testToString() { - Integer[] a = { two, one, three, four, seven}; - AtomicReferenceArray ai = new AtomicReferenceArray(a); - assertEquals(Arrays.toString(a), ai.toString()); - } -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicReferenceFieldUpdaterTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicReferenceFieldUpdaterTest.java deleted file mode 100755 index feddce759..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicReferenceFieldUpdaterTest.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import java.util.concurrent.atomic.*; -import junit.framework.*; -import java.util.*; - -public class AtomicReferenceFieldUpdaterTest extends JSR166TestCase{ - volatile Integer x = null; - Object z; - Integer w; - - public static void main(String[] args){ - junit.textui.TestRunner.run(suite()); - } - public static Test suite() { - return new TestSuite(AtomicReferenceFieldUpdaterTest.class); - } - - /** - * Construction with non-existent field throws RuntimeException - */ - public void testConstructor(){ - try{ - AtomicReferenceFieldUpdater - a = AtomicReferenceFieldUpdater.newUpdater - (AtomicReferenceFieldUpdaterTest.class, Integer.class, "y"); - shouldThrow(); - } - catch (RuntimeException rt) {} - } - - - /** - * construction with field not of given type throws RuntimeException - */ - public void testConstructor2(){ - try{ - AtomicReferenceFieldUpdater - a = AtomicReferenceFieldUpdater.newUpdater - (AtomicReferenceFieldUpdaterTest.class, Integer.class, "z"); - shouldThrow(); - } - catch (RuntimeException rt) {} - } - - /** - * Constructor with non-volatile field throws exception - */ - public void testConstructor3(){ - try{ - AtomicReferenceFieldUpdater - a = AtomicReferenceFieldUpdater.newUpdater - (AtomicReferenceFieldUpdaterTest.class, Integer.class, "w"); - shouldThrow(); - } - catch (RuntimeException rt) {} - } - - static class Base { - protected volatile Object f = null; - } - static class Sub1 extends Base { - AtomicReferenceFieldUpdater fUpdater - = AtomicReferenceFieldUpdater.newUpdater(Base.class, Object.class, "f"); - } - static class Sub2 extends Base {} - - public void testProtectedFieldOnAnotherSubtype() { - Sub1 sub1 = new Sub1(); - Sub2 sub2 = new Sub2(); - - sub1.fUpdater.set(sub1, "f"); - try { - sub1.fUpdater.set(sub2, "g"); - shouldThrow(); - } - catch (RuntimeException rt) {} - } - - /** - * get returns the last value set or assigned - */ - public void testGetSet(){ - AtomicReferenceFieldUpdatera; - try { - a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = one; - assertEquals(one,a.get(this)); - a.set(this,two); - assertEquals(two,a.get(this)); - a.set(this,m3); - assertEquals(m3,a.get(this)); - } - /** - * compareAndSet succeeds in changing value if equal to expected else fails - */ - public void testCompareAndSet(){ - AtomicReferenceFieldUpdatera; - try { - a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = one; - assertTrue(a.compareAndSet(this,one,two)); - assertTrue(a.compareAndSet(this,two,m4)); - assertEquals(m4,a.get(this)); - assertFalse(a.compareAndSet(this,m5,seven)); - assertFalse((seven == a.get(this))); - assertTrue(a.compareAndSet(this,m4,seven)); - assertEquals(seven,a.get(this)); - } - - /** - * compareAndSet in one thread enables another waiting for value - * to succeed - */ - public void testCompareAndSetInMultipleThreads() { - x = one; - final AtomicReferenceFieldUpdatera; - try { - a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x"); - } catch (RuntimeException ok) { - return; - } - - Thread t = new Thread(new Runnable() { - public void run() { - while(!a.compareAndSet(AtomicReferenceFieldUpdaterTest.this, two, three)) Thread.yield(); - }}); - try { - t.start(); - assertTrue(a.compareAndSet(this, one, two)); - t.join(LONG_DELAY_MS); - assertFalse(t.isAlive()); - assertEquals(a.get(this), three); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * repeated weakCompareAndSet succeeds in changing value when equal - * to expected - */ - public void testWeakCompareAndSet(){ - AtomicReferenceFieldUpdatera; - try { - a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = one; - while(!a.weakCompareAndSet(this,one,two)); - while(!a.weakCompareAndSet(this,two,m4)); - assertEquals(m4,a.get(this)); - while(!a.weakCompareAndSet(this,m4,seven)); - assertEquals(seven,a.get(this)); - } - - /** - * getAndSet returns previous value and sets to given value - */ - public void testGetAndSet(){ - AtomicReferenceFieldUpdatera; - try { - a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x"); - } catch (RuntimeException ok) { - return; - } - x = one; - assertEquals(one,a.getAndSet(this, zero)); - assertEquals(zero,a.getAndSet(this,m10)); - assertEquals(m10,a.getAndSet(this,1)); - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicReferenceTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicReferenceTest.java deleted file mode 100755 index 33da30d73..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicReferenceTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.concurrent.atomic.*; -import java.io.*; - -public class AtomicReferenceTest extends JSR166TestCase { - public static void main (String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(AtomicReferenceTest.class); - } - - /** - * constructor initializes to given value - */ - public void testConstructor(){ - AtomicReference ai = new AtomicReference(one); - assertEquals(one,ai.get()); - } - - /** - * default constructed initializes to null - */ - public void testConstructor2(){ - AtomicReference ai = new AtomicReference(); - assertNull(ai.get()); - } - - /** - * get returns the last value set - */ - public void testGetSet(){ - AtomicReference ai = new AtomicReference(one); - assertEquals(one,ai.get()); - ai.set(two); - assertEquals(two,ai.get()); - ai.set(m3); - assertEquals(m3,ai.get()); - - } - /** - * compareAndSet succeeds in changing value if equal to expected else fails - */ - public void testCompareAndSet(){ - AtomicReference ai = new AtomicReference(one); - assertTrue(ai.compareAndSet(one,two)); - assertTrue(ai.compareAndSet(two,m4)); - assertEquals(m4,ai.get()); - assertFalse(ai.compareAndSet(m5,seven)); - assertFalse((seven.equals(ai.get()))); - assertTrue(ai.compareAndSet(m4,seven)); - assertEquals(seven,ai.get()); - } - - /** - * compareAndSet in one thread enables another waiting for value - * to succeed - */ - public void testCompareAndSetInMultipleThreads() { - final AtomicReference ai = new AtomicReference(one); - Thread t = new Thread(new Runnable() { - public void run() { - while(!ai.compareAndSet(two, three)) Thread.yield(); - }}); - try { - t.start(); - assertTrue(ai.compareAndSet(one, two)); - t.join(LONG_DELAY_MS); - assertFalse(t.isAlive()); - assertEquals(ai.get(), three); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * repeated weakCompareAndSet succeeds in changing value when equal - * to expected - */ - public void testWeakCompareAndSet(){ - AtomicReference ai = new AtomicReference(one); - while(!ai.weakCompareAndSet(one,two)); - while(!ai.weakCompareAndSet(two,m4)); - assertEquals(m4,ai.get()); - while(!ai.weakCompareAndSet(m4,seven)); - assertEquals(seven,ai.get()); - } - - /** - * getAndSet returns previous value and sets to given value - */ - public void testGetAndSet(){ - AtomicReference ai = new AtomicReference(one); - assertEquals(one,ai.getAndSet(zero)); - assertEquals(zero,ai.getAndSet(m10)); - assertEquals(m10,ai.getAndSet(one)); - } - - /** - * a deserialized serialized atomic holds same value - */ - public void testSerialization() { - AtomicReference l = new AtomicReference(); - - try { - l.set(one); - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(l); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - AtomicReference r = (AtomicReference) in.readObject(); - assertEquals(l.get(), r.get()); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * toString returns current value. - */ - public void testToString() { - AtomicReference ai = new AtomicReference(one); - assertEquals(ai.toString(), one.toString()); - ai.set(two); - assertEquals(ai.toString(), two.toString()); - } - -} - diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicStampedReferenceTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicStampedReferenceTest.java deleted file mode 100755 index 3ffc0a7ff..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/AtomicStampedReferenceTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.concurrent.atomic.*; - -public class AtomicStampedReferenceTest extends JSR166TestCase{ - public static void main (String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(AtomicStampedReferenceTest.class); - } - - /** - * constructor initializes to given reference and stamp - */ - public void testConstructor(){ - AtomicStampedReference ai = new AtomicStampedReference(one, 0); - assertEquals(one,ai.getReference()); - assertEquals(0, ai.getStamp()); - AtomicStampedReference a2 = new AtomicStampedReference(null, 1); - assertNull(a2.getReference()); - assertEquals(1, a2.getStamp()); - - } - - /** - * get returns the last values of reference and stamp set - */ - public void testGetSet(){ - int[] mark = new int[1]; - AtomicStampedReference ai = new AtomicStampedReference(one, 0); - assertEquals(one,ai.getReference()); - assertEquals(0, ai.getStamp()); - assertEquals(one, ai.get(mark)); - assertEquals(0, mark[0]); - ai.set(two, 0); - assertEquals(two,ai.getReference()); - assertEquals(0, ai.getStamp()); - assertEquals(two, ai.get(mark)); - assertEquals(0, mark[0]); - ai.set(one, 1); - assertEquals(one,ai.getReference()); - assertEquals(1, ai.getStamp()); - assertEquals(one, ai.get(mark)); - assertEquals(1,mark[0]); - } - - /** - * attemptStamp succeeds in single thread - */ - public void testAttemptStamp(){ - int[] mark = new int[1]; - AtomicStampedReference ai = new AtomicStampedReference(one, 0); - assertEquals(0, ai.getStamp()); - assertTrue(ai.attemptStamp(one, 1)); - assertEquals(1, ai.getStamp()); - assertEquals(one, ai.get(mark)); - assertEquals(1, mark[0]); - } - - /** - * compareAndSet succeeds in changing values if equal to expected reference - * and stamp else fails - */ - public void testCompareAndSet(){ - int[] mark = new int[1]; - AtomicStampedReference ai = new AtomicStampedReference(one, 0); - assertEquals(one, ai.get(mark)); - assertEquals(0, ai.getStamp()); - assertEquals(0, mark[0]); - - assertTrue(ai.compareAndSet(one, two, 0, 0)); - assertEquals(two, ai.get(mark)); - assertEquals(0, mark[0]); - - assertTrue(ai.compareAndSet(two, m3, 0, 1)); - assertEquals(m3, ai.get(mark)); - assertEquals(1, mark[0]); - - assertFalse(ai.compareAndSet(two, m3, 1, 1)); - assertEquals(m3, ai.get(mark)); - assertEquals(1, mark[0]); - } - - /** - * compareAndSet in one thread enables another waiting for reference value - * to succeed - */ - public void testCompareAndSetInMultipleThreads() { - final AtomicStampedReference ai = new AtomicStampedReference(one, 0); - Thread t = new Thread(new Runnable() { - public void run() { - while(!ai.compareAndSet(two, three, 0, 0)) Thread.yield(); - }}); - try { - t.start(); - assertTrue(ai.compareAndSet(one, two, 0, 0)); - t.join(LONG_DELAY_MS); - assertFalse(t.isAlive()); - assertEquals(ai.getReference(), three); - assertEquals(ai.getStamp(), 0); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * compareAndSet in one thread enables another waiting for stamp value - * to succeed - */ - public void testCompareAndSetInMultipleThreads2() { - final AtomicStampedReference ai = new AtomicStampedReference(one, 0); - Thread t = new Thread(new Runnable() { - public void run() { - while(!ai.compareAndSet(one, one, 1, 2)) Thread.yield(); - }}); - try { - t.start(); - assertTrue(ai.compareAndSet(one, one, 0, 1)); - t.join(LONG_DELAY_MS); - assertFalse(t.isAlive()); - assertEquals(ai.getReference(), one); - assertEquals(ai.getStamp(), 2); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * repeated weakCompareAndSet succeeds in changing values when equal - * to expected - */ - public void testWeakCompareAndSet(){ - int[] mark = new int[1]; - AtomicStampedReference ai = new AtomicStampedReference(one, 0); - assertEquals(one, ai.get(mark)); - assertEquals(0, ai.getStamp ()); - assertEquals(0, mark[0]); - - while(!ai.weakCompareAndSet(one, two, 0, 0)); - assertEquals(two, ai.get(mark)); - assertEquals(0, mark[0]); - - while(!ai.weakCompareAndSet(two, m3, 0, 1)); - assertEquals(m3, ai.get(mark)); - assertEquals(1, mark[0]); - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ConcurrentHashMapTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ConcurrentHashMapTest.java deleted file mode 100755 index d7f2210fe..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ConcurrentHashMapTest.java +++ /dev/null @@ -1,609 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.Enumeration; -import java.io.*; - -public class ConcurrentHashMapTest extends JSR166TestCase{ - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(ConcurrentHashMapTest.class); - } - - /** - * Create a map from Integers 1-5 to Strings "A"-"E". - */ - private static ConcurrentHashMap map5() { - ConcurrentHashMap map = new ConcurrentHashMap(5); - assertTrue(map.isEmpty()); - map.put(one, "A"); - map.put(two, "B"); - map.put(three, "C"); - map.put(four, "D"); - map.put(five, "E"); - assertFalse(map.isEmpty()); - assertEquals(5, map.size()); - return map; - } - - /** - * clear removes all pairs - */ - public void testClear() { - ConcurrentHashMap map = map5(); - map.clear(); - assertEquals(map.size(), 0); - } - - /** - * Maps with same contents are equal - */ - public void testEquals() { - ConcurrentHashMap map1 = map5(); - ConcurrentHashMap map2 = map5(); - assertEquals(map1, map2); - assertEquals(map2, map1); - map1.clear(); - assertFalse(map1.equals(map2)); - assertFalse(map2.equals(map1)); - } - - /** - * contains returns true for contained value - */ - public void testContains() { - ConcurrentHashMap map = map5(); - assertTrue(map.contains("A")); - assertFalse(map.contains("Z")); - } - - /** - * containsKey returns true for contained key - */ - public void testContainsKey() { - ConcurrentHashMap map = map5(); - assertTrue(map.containsKey(one)); - assertFalse(map.containsKey(zero)); - } - - /** - * containsValue returns true for held values - */ - public void testContainsValue() { - ConcurrentHashMap map = map5(); - assertTrue(map.containsValue("A")); - assertFalse(map.containsValue("Z")); - } - - /** - * enumeration returns an enumeration containing the correct - * elements - */ - public void testEnumeration() { - ConcurrentHashMap map = map5(); - Enumeration e = map.elements(); - int count = 0; - while(e.hasMoreElements()){ - count++; - e.nextElement(); - } - assertEquals(5, count); - } - - /** - * get returns the correct element at the given key, - * or null if not present - */ - public void testGet() { - ConcurrentHashMap map = map5(); - assertEquals("A", (String)map.get(one)); - ConcurrentHashMap empty = new ConcurrentHashMap(); - assertNull(map.get("anything")); - } - - /** - * isEmpty is true of empty map and false for non-empty - */ - public void testIsEmpty() { - ConcurrentHashMap empty = new ConcurrentHashMap(); - ConcurrentHashMap map = map5(); - assertTrue(empty.isEmpty()); - assertFalse(map.isEmpty()); - } - - /** - * keys returns an enumeration containing all the keys from the map - */ - public void testKeys() { - ConcurrentHashMap map = map5(); - Enumeration e = map.keys(); - int count = 0; - while(e.hasMoreElements()){ - count++; - e.nextElement(); - } - assertEquals(5, count); - } - - /** - * keySet returns a Set containing all the keys - */ - public void testKeySet() { - ConcurrentHashMap map = map5(); - Set s = map.keySet(); - assertEquals(5, s.size()); - assertTrue(s.contains(one)); - assertTrue(s.contains(two)); - assertTrue(s.contains(three)); - assertTrue(s.contains(four)); - assertTrue(s.contains(five)); - } - - /** - * keySet.toArray returns contains all keys - */ - public void testKeySetToArray() { - ConcurrentHashMap map = map5(); - Set s = map.keySet(); - Object[] ar = s.toArray(); - assertTrue(s.containsAll(Arrays.asList(ar))); - assertEquals(5, ar.length); - ar[0] = m10; - assertFalse(s.containsAll(Arrays.asList(ar))); - } - - /** - * Values.toArray contains all values - */ - public void testValuesToArray() { - ConcurrentHashMap map = map5(); - Collection v = map.values(); - Object[] ar = v.toArray(); - ArrayList s = new ArrayList(Arrays.asList(ar)); - assertEquals(5, ar.length); - assertTrue(s.contains("A")); - assertTrue(s.contains("B")); - assertTrue(s.contains("C")); - assertTrue(s.contains("D")); - assertTrue(s.contains("E")); - } - - /** - * entrySet.toArray contains all entries - */ - public void testEntrySetToArray() { - ConcurrentHashMap map = map5(); - Set s = map.entrySet(); - Object[] ar = s.toArray(); - assertEquals(5, ar.length); - for (int i = 0; i < 5; ++i) { - assertTrue(map.containsKey(((Map.Entry)(ar[i])).getKey())); - assertTrue(map.containsValue(((Map.Entry)(ar[i])).getValue())); - } - } - - /** - * values collection contains all values - */ - public void testValues() { - ConcurrentHashMap map = map5(); - Collection s = map.values(); - assertEquals(5, s.size()); - assertTrue(s.contains("A")); - assertTrue(s.contains("B")); - assertTrue(s.contains("C")); - assertTrue(s.contains("D")); - assertTrue(s.contains("E")); - } - - /** - * entrySet contains all pairs - */ - public void testEntrySet() { - ConcurrentHashMap map = map5(); - Set s = map.entrySet(); - assertEquals(5, s.size()); - Iterator it = s.iterator(); - while (it.hasNext()) { - Map.Entry e = (Map.Entry) it.next(); - assertTrue( - (e.getKey().equals(one) && e.getValue().equals("A")) || - (e.getKey().equals(two) && e.getValue().equals("B")) || - (e.getKey().equals(three) && e.getValue().equals("C")) || - (e.getKey().equals(four) && e.getValue().equals("D")) || - (e.getKey().equals(five) && e.getValue().equals("E"))); - } - } - - /** - * putAll adds all key-value pairs from the given map - */ - public void testPutAll() { - ConcurrentHashMap empty = new ConcurrentHashMap(); - ConcurrentHashMap map = map5(); - empty.putAll(map); - assertEquals(5, empty.size()); - assertTrue(empty.containsKey(one)); - assertTrue(empty.containsKey(two)); - assertTrue(empty.containsKey(three)); - assertTrue(empty.containsKey(four)); - assertTrue(empty.containsKey(five)); - } - - /** - * putIfAbsent works when the given key is not present - */ - public void testPutIfAbsent() { - ConcurrentHashMap map = map5(); - map.putIfAbsent(six, "Z"); - assertTrue(map.containsKey(six)); - } - - /** - * putIfAbsent does not add the pair if the key is already present - */ - public void testPutIfAbsent2() { - ConcurrentHashMap map = map5(); - assertEquals("A", map.putIfAbsent(one, "Z")); - } - - /** - * replace fails when the given key is not present - */ - public void testReplace() { - ConcurrentHashMap map = map5(); - assertNull(map.replace(six, "Z")); - assertFalse(map.containsKey(six)); - } - - /** - * replace succeeds if the key is already present - */ - public void testReplace2() { - ConcurrentHashMap map = map5(); - assertNotNull(map.replace(one, "Z")); - assertEquals("Z", map.get(one)); - } - - - /** - * replace value fails when the given key not mapped to expected value - */ - public void testReplaceValue() { - ConcurrentHashMap map = map5(); - assertEquals("A", map.get(one)); - assertFalse(map.replace(one, "Z", "Z")); - assertEquals("A", map.get(one)); - } - - /** - * replace value succeeds when the given key mapped to expected value - */ - public void testReplaceValue2() { - ConcurrentHashMap map = map5(); - assertEquals("A", map.get(one)); - assertTrue(map.replace(one, "A", "Z")); - assertEquals("Z", map.get(one)); - } - - - /** - * remove removes the correct key-value pair from the map - */ - public void testRemove() { - ConcurrentHashMap map = map5(); - map.remove(five); - assertEquals(4, map.size()); - assertFalse(map.containsKey(five)); - } - - /** - * remove(key,value) removes only if pair present - */ - public void testRemove2() { - ConcurrentHashMap map = map5(); - map.remove(five, "E"); - assertEquals(4, map.size()); - assertFalse(map.containsKey(five)); - map.remove(four, "A"); - assertEquals(4, map.size()); - assertTrue(map.containsKey(four)); - - } - - /** - * size returns the correct values - */ - public void testSize() { - ConcurrentHashMap map = map5(); - ConcurrentHashMap empty = new ConcurrentHashMap(); - assertEquals(0, empty.size()); - assertEquals(5, map.size()); - } - - /** - * toString contains toString of elements - */ - public void testToString() { - ConcurrentHashMap map = map5(); - String s = map.toString(); - for (int i = 1; i <= 5; ++i) { - assertTrue(s.indexOf(String.valueOf(i)) >= 0); - } - } - - // Exception tests - - /** - * Cannot create with negative capacity - */ - public void testConstructor1() { - try { - new ConcurrentHashMap(-1,0,1); - shouldThrow(); - } catch(IllegalArgumentException e){} - } - - /** - * Cannot create with negative concurrency level - */ - public void testConstructor2() { - try { - new ConcurrentHashMap(1,0,-1); - shouldThrow(); - } catch(IllegalArgumentException e){} - } - - /** - * Cannot create with only negative capacity - */ - public void testConstructor3() { - try { - new ConcurrentHashMap(-1); - shouldThrow(); - } catch(IllegalArgumentException e){} - } - - /** - * get(null) throws NPE - */ - public void testGet_NullPointerException() { - try { - ConcurrentHashMap c = new ConcurrentHashMap(5); - c.get(null); - shouldThrow(); - } catch(NullPointerException e){} - } - - /** - * containsKey(null) throws NPE - */ - public void testContainsKey_NullPointerException() { - try { - ConcurrentHashMap c = new ConcurrentHashMap(5); - c.containsKey(null); - shouldThrow(); - } catch(NullPointerException e){} - } - - /** - * containsValue(null) throws NPE - */ - public void testContainsValue_NullPointerException() { - try { - ConcurrentHashMap c = new ConcurrentHashMap(5); - c.containsValue(null); - shouldThrow(); - } catch(NullPointerException e){} - } - - /** - * contains(null) throws NPE - */ - public void testContains_NullPointerException() { - try { - ConcurrentHashMap c = new ConcurrentHashMap(5); - c.contains(null); - shouldThrow(); - } catch(NullPointerException e){} - } - - /** - * put(null,x) throws NPE - */ - public void testPut1_NullPointerException() { - try { - ConcurrentHashMap c = new ConcurrentHashMap(5); - c.put(null, "whatever"); - shouldThrow(); - } catch(NullPointerException e){} - } - - /** - * put(x, null) throws NPE - */ - public void testPut2_NullPointerException() { - try { - ConcurrentHashMap c = new ConcurrentHashMap(5); - c.put("whatever", null); - shouldThrow(); - } catch(NullPointerException e){} - } - - /** - * putIfAbsent(null, x) throws NPE - */ - public void testPutIfAbsent1_NullPointerException() { - try { - ConcurrentHashMap c = new ConcurrentHashMap(5); - c.putIfAbsent(null, "whatever"); - shouldThrow(); - } catch(NullPointerException e){} - } - - /** - * replace(null, x) throws NPE - */ - public void testReplace_NullPointerException() { - try { - ConcurrentHashMap c = new ConcurrentHashMap(5); - c.replace(null, "whatever"); - shouldThrow(); - } catch(NullPointerException e){} - } - - /** - * replace(null, x, y) throws NPE - */ - public void testReplaceValue_NullPointerException() { - try { - ConcurrentHashMap c = new ConcurrentHashMap(5); - c.replace(null, one, "whatever"); - shouldThrow(); - } catch(NullPointerException e){} - } - - /** - * putIfAbsent(x, null) throws NPE - */ - public void testPutIfAbsent2_NullPointerException() { - try { - ConcurrentHashMap c = new ConcurrentHashMap(5); - c.putIfAbsent("whatever", null); - shouldThrow(); - } catch(NullPointerException e){} - } - - - /** - * replace(x, null) throws NPE - */ - public void testReplace2_NullPointerException() { - try { - ConcurrentHashMap c = new ConcurrentHashMap(5); - c.replace("whatever", null); - shouldThrow(); - } catch(NullPointerException e){} - } - - /** - * replace(x, null, y) throws NPE - */ - public void testReplaceValue2_NullPointerException() { - try { - ConcurrentHashMap c = new ConcurrentHashMap(5); - c.replace("whatever", null, "A"); - shouldThrow(); - } catch(NullPointerException e){} - } - - /** - * replace(x, y, null) throws NPE - */ - public void testReplaceValue3_NullPointerException() { - try { - ConcurrentHashMap c = new ConcurrentHashMap(5); - c.replace("whatever", one, null); - shouldThrow(); - } catch(NullPointerException e){} - } - - - /** - * remove(null) throws NPE - */ - public void testRemove1_NullPointerException() { - try { - ConcurrentHashMap c = new ConcurrentHashMap(5); - c.put("sadsdf", "asdads"); - c.remove(null); - shouldThrow(); - } catch(NullPointerException e){} - } - - /** - * remove(null, x) throws NPE - */ - public void testRemove2_NullPointerException() { - try { - ConcurrentHashMap c = new ConcurrentHashMap(5); - c.put("sadsdf", "asdads"); - c.remove(null, "whatever"); - shouldThrow(); - } catch(NullPointerException e){} - } - - /** - * remove(x, null) returns false - */ - public void testRemove3() { - try { - ConcurrentHashMap c = new ConcurrentHashMap(5); - c.put("sadsdf", "asdads"); - assertFalse(c.remove("sadsdf", null)); - } catch(NullPointerException e){ - fail(); - } - } - - /** - * A deserialized map equals original - */ - public void testSerialization() { - ConcurrentHashMap q = map5(); - - try { - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(q); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - ConcurrentHashMap r = (ConcurrentHashMap)in.readObject(); - assertEquals(q.size(), r.size()); - assertTrue(q.equals(r)); - assertTrue(r.equals(q)); - } catch(Exception e){ - e.printStackTrace(); - unexpectedException(); - } - } - - - /** - * SetValue of an EntrySet entry sets value in the map. - */ - public void testSetValueWriteThrough() { - // Adapted from a bug report by Eric Zoerner - ConcurrentHashMap map = new ConcurrentHashMap(2, 5.0f, 1); - assertTrue(map.isEmpty()); - for (int i = 0; i < 20; i++) - map.put(new Integer(i), new Integer(i)); - assertFalse(map.isEmpty()); - Map.Entry entry1 = (Map.Entry)map.entrySet().iterator().next(); - - // assert that entry1 is not 16 - assertTrue("entry is 16, test not valid", - !entry1.getKey().equals(new Integer(16))); - - // remove 16 (a different key) from map - // which just happens to cause entry1 to be cloned in map - map.remove(new Integer(16)); - entry1.setValue("XYZ"); - assertTrue(map.containsValue("XYZ")); // fails - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ConcurrentLinkedQueueTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ConcurrentLinkedQueueTest.java deleted file mode 100755 index 8d8e13b0e..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ConcurrentLinkedQueueTest.java +++ /dev/null @@ -1,537 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.io.*; - -public class ConcurrentLinkedQueueTest extends JSR166TestCase { - - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - - public static Test suite() { - return new TestSuite(ConcurrentLinkedQueueTest.class); - } - - /** - * Create a queue of given size containing consecutive - * Integers 0 ... n. - */ - private ConcurrentLinkedQueue populatedQueue(int n) { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); - assertTrue(q.isEmpty()); - for(int i = 0; i < n; ++i) - assertTrue(q.offer(new Integer(i))); - assertFalse(q.isEmpty()); - assertEquals(n, q.size()); - return q; - } - - /** - * new queue is empty - */ - public void testConstructor1() { - assertEquals(0, new ConcurrentLinkedQueue().size()); - } - - /** - * Initializing from null Collection throws NPE - */ - public void testConstructor3() { - try { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue((Collection)null); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Initializing from Collection of null elements throws NPE - */ - public void testConstructor4() { - try { - Integer[] ints = new Integer[SIZE]; - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Initializing from Collection with some null elements throws NPE - */ - public void testConstructor5() { - try { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new Integer(i); - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Queue contains all elements of collection used to initialize - */ - public void testConstructor6() { - try { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(Arrays.asList(ints)); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); - } - finally {} - } - - /** - * isEmpty is true before add, false after - */ - public void testEmpty() { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); - assertTrue(q.isEmpty()); - q.add(one); - assertFalse(q.isEmpty()); - q.add(two); - q.remove(); - q.remove(); - assertTrue(q.isEmpty()); - } - - /** - * size changes when elements added and removed - */ - public void testSize() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE-i, q.size()); - q.remove(); - } - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - q.add(new Integer(i)); - } - } - - /** - * offer(null) throws NPE - */ - public void testOfferNull() { - try { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); - q.offer(null); - shouldThrow(); - } catch (NullPointerException success) { } - } - - /** - * add(null) throws NPE - */ - public void testAddNull() { - try { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); - q.add(null); - shouldThrow(); - } catch (NullPointerException success) { } - } - - - /** - * Offer returns true - */ - public void testOffer() { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); - assertTrue(q.offer(zero)); - assertTrue(q.offer(one)); - } - - /** - * add returns true - */ - public void testAdd() { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - assertTrue(q.add(new Integer(i))); - } - } - - /** - * addAll(null) throws NPE - */ - public void testAddAll1() { - try { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); - q.addAll(null); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * addAll(this) throws IAE - */ - public void testAddAllSelf() { - try { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - q.addAll(q); - shouldThrow(); - } - catch (IllegalArgumentException success) {} - } - - /** - * addAll of a collection with null elements throws NPE - */ - public void testAddAll2() { - try { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); - Integer[] ints = new Integer[SIZE]; - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - /** - * addAll of a collection with any null elements throws NPE after - * possibly adding some elements - */ - public void testAddAll3() { - try { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new Integer(i); - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Queue contains all elements, in traversal order, of successful addAll - */ - public void testAddAll5() { - try { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); - assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); - } - finally {} - } - - /** - * poll succeeds unless empty - */ - public void testPoll() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.poll()).intValue()); - } - assertNull(q.poll()); - } - - /** - * peek returns next element, or null if empty - */ - public void testPeek() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.peek()).intValue()); - q.poll(); - assertTrue(q.peek() == null || - i != ((Integer)q.peek()).intValue()); - } - assertNull(q.peek()); - } - - /** - * element returns next element, or throws NSEE if empty - */ - public void testElement() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.element()).intValue()); - q.poll(); - } - try { - q.element(); - shouldThrow(); - } - catch (NoSuchElementException success) {} - } - - /** - * remove removes next element, or throws NSEE if empty - */ - public void testRemove() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.remove()).intValue()); - } - try { - q.remove(); - shouldThrow(); - } catch (NoSuchElementException success){ - } - } - - /** - * remove(x) removes x and returns true if present - */ - public void testRemoveElement() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - for (int i = 1; i < SIZE; i+=2) { - assertTrue(q.remove(new Integer(i))); - } - for (int i = 0; i < SIZE; i+=2) { - assertTrue(q.remove(new Integer(i))); - assertFalse(q.remove(new Integer(i+1))); - } - assertTrue(q.isEmpty()); - } - - /** - * contains(x) reports true when elements added but not yet removed - */ - public void testContains() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); - q.poll(); - assertFalse(q.contains(new Integer(i))); - } - } - - /** - * clear removes all elements - */ - public void testClear() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - q.clear(); - assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - q.add(one); - assertFalse(q.isEmpty()); - q.clear(); - assertTrue(q.isEmpty()); - } - - /** - * containsAll(c) is true when c contains a subset of elements - */ - public void testContainsAll() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - ConcurrentLinkedQueue p = new ConcurrentLinkedQueue(); - for (int i = 0; i < SIZE; ++i) { - assertTrue(q.containsAll(p)); - assertFalse(p.containsAll(q)); - p.add(new Integer(i)); - } - assertTrue(p.containsAll(q)); - } - - /** - * retainAll(c) retains only those elements of c and reports true if change - */ - public void testRetainAll() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - ConcurrentLinkedQueue p = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - boolean changed = q.retainAll(p); - if (i == 0) - assertFalse(changed); - else - assertTrue(changed); - - assertTrue(q.containsAll(p)); - assertEquals(SIZE-i, q.size()); - p.remove(); - } - } - - /** - * removeAll(c) removes only those elements of c and reports true if changed - */ - public void testRemoveAll() { - for (int i = 1; i < SIZE; ++i) { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - ConcurrentLinkedQueue p = populatedQueue(i); - assertTrue(q.removeAll(p)); - assertEquals(SIZE-i, q.size()); - for (int j = 0; j < i; ++j) { - Integer I = (Integer)(p.remove()); - assertFalse(q.contains(I)); - } - } - } - - /** - * toArray contains all elements - */ - public void testToArray() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - Object[] o = q.toArray(); - Arrays.sort(o); - for(int i = 0; i < o.length; i++) - assertEquals(o[i], q.poll()); - } - - /** - * toArray(a) contains all elements - */ - public void testToArray2() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - ints = (Integer[])q.toArray(ints); - Arrays.sort(ints); - for(int i = 0; i < ints.length; i++) - assertEquals(ints[i], q.poll()); - } - - /** - * toArray(null) throws NPE - */ - public void testToArray_BadArg() { - try { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - Object o[] = q.toArray(null); - shouldThrow(); - } catch(NullPointerException success){} - } - - /** - * toArray with incompatible array type throws CCE - */ - public void testToArray1_BadArg() { - try { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - Object o[] = q.toArray(new String[10] ); - shouldThrow(); - } catch(ArrayStoreException success){} - } - - /** - * iterator iterates through all elements - */ - public void testIterator() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - int i = 0; - Iterator it = q.iterator(); - while(it.hasNext()) { - assertTrue(q.contains(it.next())); - ++i; - } - assertEquals(i, SIZE); - } - - /** - * iterator ordering is FIFO - */ - public void testIteratorOrdering() { - final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); - q.add(one); - q.add(two); - q.add(three); - - int k = 0; - for (Iterator it = q.iterator(); it.hasNext();) { - int i = ((Integer)(it.next())).intValue(); - assertEquals(++k, i); - } - - assertEquals(3, k); - } - - /** - * Modifications do not cause iterators to fail - */ - public void testWeaklyConsistentIteration () { - final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); - q.add(one); - q.add(two); - q.add(three); - - try { - for (Iterator it = q.iterator(); it.hasNext();) { - q.remove(); - it.next(); - } - } - catch (ConcurrentModificationException e) { - shouldThrow(); - } - - assertEquals("queue should be empty again", 0, q.size()); - } - - /** - * iterator.remove removes current element - */ - public void testIteratorRemove () { - final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); - q.add(one); - q.add(two); - q.add(three); - Iterator it = q.iterator(); - it.next(); - it.remove(); - it = q.iterator(); - assertEquals(it.next(), two); - assertEquals(it.next(), three); - assertFalse(it.hasNext()); - } - - - /** - * toString contains toStrings of elements - */ - public void testToString() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - String s = q.toString(); - for (int i = 0; i < SIZE; ++i) { - assertTrue(s.indexOf(String.valueOf(i)) >= 0); - } - } - - /** - * A deserialized serialized queue has same elements in same order - */ - public void testSerialization() { - ConcurrentLinkedQueue q = populatedQueue(SIZE); - try { - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(q); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - ConcurrentLinkedQueue r = (ConcurrentLinkedQueue)in.readObject(); - assertEquals(q.size(), r.size()); - while (!q.isEmpty()) - assertEquals(q.remove(), r.remove()); - } catch(Exception e){ - unexpectedException(); - } - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/CopyOnWriteArrayListTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/CopyOnWriteArrayListTest.java deleted file mode 100755 index d20803989..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/CopyOnWriteArrayListTest.java +++ /dev/null @@ -1,623 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.io.*; - -public class CopyOnWriteArrayListTest extends JSR166TestCase{ - - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - - public static Test suite() { - return new TestSuite(CopyOnWriteArrayListTest.class); - } - - static CopyOnWriteArrayList populatedArray(int n){ - CopyOnWriteArrayList a = new CopyOnWriteArrayList(); - assertTrue(a.isEmpty()); - for (int i = 0; i < n; ++i) - a.add(new Integer(i)); - assertFalse(a.isEmpty()); - assertEquals(n, a.size()); - return a; - } - - - /** - * a new list is empty - */ - public void testConstructor() { - CopyOnWriteArrayList a = new CopyOnWriteArrayList(); - assertTrue(a.isEmpty()); - } - - /** - * new list contains all elements of initializing array - */ - public void testConstructor2() { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new Integer(i); - CopyOnWriteArrayList a = new CopyOnWriteArrayList(ints); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], a.get(i)); - } - - /** - * new list contains all elements of initializing collection - */ - public void testConstructor3() { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new Integer(i); - CopyOnWriteArrayList a = new CopyOnWriteArrayList(Arrays.asList(ints)); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], a.get(i)); - } - - - /** - * addAll adds each element from the given collection - */ - public void testAddAll() { - CopyOnWriteArrayList full = populatedArray(3); - Vector v = new Vector(); - v.add(three); - v.add(four); - v.add(five); - full.addAll(v); - assertEquals(6, full.size()); - } - - /** - * addAllAbsent adds each element from the given collection that did not - * already exist in the List - */ - public void testAddAllAbsent() { - CopyOnWriteArrayList full = populatedArray(3); - Vector v = new Vector(); - v.add(three); - v.add(four); - v.add(one); // will not add this element - full.addAllAbsent(v); - assertEquals(5, full.size()); - } - - /** - * addIfAbsent will not add the element if it already exists in the list - */ - public void testAddIfAbsent() { - CopyOnWriteArrayList full = populatedArray(SIZE); - full.addIfAbsent(one); - assertEquals(SIZE, full.size()); - } - - /** - * addIfAbsent adds the element when it does not exist in the list - */ - public void testAddIfAbsent2() { - CopyOnWriteArrayList full = populatedArray(SIZE); - full.addIfAbsent(three); - assertTrue(full.contains(three)); - } - - /** - * clear removes all elements from the list - */ - public void testClear() { - CopyOnWriteArrayList full = populatedArray(SIZE); - full.clear(); - assertEquals(0, full.size()); - } - - - /** - * Cloned list is equal - */ - public void testClone() { - CopyOnWriteArrayList l1 = populatedArray(SIZE); - CopyOnWriteArrayList l2 = (CopyOnWriteArrayList)(l1.clone()); - assertEquals(l1, l2); - l1.clear(); - assertFalse(l1.equals(l2)); - } - - /** - * contains is true for added elements - */ - public void testContains() { - CopyOnWriteArrayList full = populatedArray(3); - assertTrue(full.contains(one)); - assertFalse(full.contains(five)); - } - - /** - * adding at an index places it in the indicated index - */ - public void testAddIndex() { - CopyOnWriteArrayList full = populatedArray(3); - full.add(0, m1); - assertEquals(4, full.size()); - assertEquals(m1, full.get(0)); - assertEquals(zero, full.get(1)); - - full.add(2, m2); - assertEquals(5, full.size()); - assertEquals(m2, full.get(2)); - assertEquals(two, full.get(4)); - } - - /** - * lists with same elements are equal and have same hashCode - */ - public void testEquals() { - CopyOnWriteArrayList a = populatedArray(3); - CopyOnWriteArrayList b = populatedArray(3); - assertTrue(a.equals(b)); - assertTrue(b.equals(a)); - assertEquals(a.hashCode(), b.hashCode()); - a.add(m1); - assertFalse(a.equals(b)); - assertFalse(b.equals(a)); - b.add(m1); - assertTrue(a.equals(b)); - assertTrue(b.equals(a)); - assertEquals(a.hashCode(), b.hashCode()); - } - - - /** - * containsAll returns true for collection with subset of elements - */ - public void testContainsAll() { - CopyOnWriteArrayList full = populatedArray(3); - Vector v = new Vector(); - v.add(one); - v.add(two); - assertTrue(full.containsAll(v)); - v.add(six); - assertFalse(full.containsAll(v)); - } - - /** - * get returns the value at the given index - */ - public void testGet() { - CopyOnWriteArrayList full = populatedArray(3); - assertEquals(0, ((Integer)full.get(0)).intValue()); - } - - /** - * indexOf gives the index for the given object - */ - public void testIndexOf() { - CopyOnWriteArrayList full = populatedArray(3); - assertEquals(1, full.indexOf(one)); - assertEquals(-1, full.indexOf("puppies")); - } - - /** - * indexOf gives the index based on the given index - * at which to start searching - */ - public void testIndexOf2() { - CopyOnWriteArrayList full = populatedArray(3); - assertEquals(1, full.indexOf(one, 0)); - assertEquals(-1, full.indexOf(one, 2)); - } - - /** - * isEmpty returns true when empty, else false - */ - public void testIsEmpty() { - CopyOnWriteArrayList empty = new CopyOnWriteArrayList(); - CopyOnWriteArrayList full = populatedArray(SIZE); - assertTrue(empty.isEmpty()); - assertFalse(full.isEmpty()); - } - - /** - * iterator() returns an iterator containing the elements of the list - */ - public void testIterator() { - CopyOnWriteArrayList full = populatedArray(SIZE); - Iterator i = full.iterator(); - int j; - for(j = 0; i.hasNext(); j++) - assertEquals(j, ((Integer)i.next()).intValue()); - assertEquals(SIZE, j); - } - - /** - * iterator.remove throws UnsupportedOperationException - */ - public void testIteratorRemove () { - CopyOnWriteArrayList full = populatedArray(SIZE); - Iterator it = full.iterator(); - it.next(); - try { - it.remove(); - shouldThrow(); - } - catch (UnsupportedOperationException success) {} - } - - /** - * toString contains toString of elements - */ - public void testToString() { - CopyOnWriteArrayList full = populatedArray(3); - String s = full.toString(); - for (int i = 0; i < 3; ++i) { - assertTrue(s.indexOf(String.valueOf(i)) >= 0); - } - } - - /** - * lastIndexOf returns the index for the given object - */ - public void testLastIndexOf1() { - CopyOnWriteArrayList full = populatedArray(3); - full.add(one); - full.add(three); - assertEquals(3, full.lastIndexOf(one)); - assertEquals(-1, full.lastIndexOf(six)); - } - - /** - * lastIndexOf returns the index from the given starting point - */ - public void testlastIndexOf2() { - CopyOnWriteArrayList full = populatedArray(3); - full.add(one); - full.add(three); - assertEquals(3, full.lastIndexOf(one, 4)); - assertEquals(-1, full.lastIndexOf(three, 3)); - } - - /** - * listIterator traverses all elements - */ - public void testListIterator1() { - CopyOnWriteArrayList full = populatedArray(SIZE); - ListIterator i = full.listIterator(); - int j; - for(j = 0; i.hasNext(); j++) - assertEquals(j, ((Integer)i.next()).intValue()); - assertEquals(SIZE, j); - } - - /** - * listIterator only returns those elements after the given index - */ - public void testListIterator2() { - CopyOnWriteArrayList full = populatedArray(3); - ListIterator i = full.listIterator(1); - int j; - for(j = 0; i.hasNext(); j++) - assertEquals(j+1, ((Integer)i.next()).intValue()); - assertEquals(2, j); - } - - /** - * remove removes and returns the object at the given index - */ - public void testRemove() { - CopyOnWriteArrayList full = populatedArray(3); - assertEquals(two, full.remove(2)); - assertEquals(2, full.size()); - } - - /** - * removeAll removes all elements from the given collection - */ - public void testRemoveAll() { - CopyOnWriteArrayList full = populatedArray(3); - Vector v = new Vector(); - v.add(one); - v.add(two); - full.removeAll(v); - assertEquals(1, full.size()); - } - - /** - * set changes the element at the given index - */ - public void testSet() { - CopyOnWriteArrayList full = populatedArray(3); - assertEquals(two, full.set(2, four)); - assertEquals(4, ((Integer)full.get(2)).intValue()); - } - - /** - * size returns the number of elements - */ - public void testSize() { - CopyOnWriteArrayList empty = new CopyOnWriteArrayList(); - CopyOnWriteArrayList full = populatedArray(SIZE); - assertEquals(SIZE, full.size()); - assertEquals(0, empty.size()); - } - - /** - * toArray returns an Object array containing all elements from the list - */ - public void testToArray() { - CopyOnWriteArrayList full = populatedArray(3); - Object[] o = full.toArray(); - assertEquals(3, o.length); - assertEquals(0, ((Integer)o[0]).intValue()); - assertEquals(1, ((Integer)o[1]).intValue()); - assertEquals(2, ((Integer)o[2]).intValue()); - } - - /** - * toArray returns an Integer array containing all elements from - * the list - */ - public void testToArray2() { - CopyOnWriteArrayList full = populatedArray(3); - Integer[] i = new Integer[3]; - i = (Integer[])full.toArray(i); - assertEquals(3, i.length); - assertEquals(0, i[0].intValue()); - assertEquals(1, i[1].intValue()); - assertEquals(2, i[2].intValue()); - } - - - /** - * sublists contains elements at indexes offset from their base - */ - public void testSubList() { - CopyOnWriteArrayList a = populatedArray(10); - assertTrue(a.subList(1,1).isEmpty()); - for(int j = 0; j < 9; ++j) { - for(int i = j ; i < 10; ++i) { - List b = a.subList(j,i); - for(int k = j; k < i; ++k) { - assertEquals(new Integer(k), b.get(k-j)); - } - } - } - - List s = a.subList(2, 5); - assertEquals(s.size(), 3); - s.set(2, m1); - assertEquals(a.get(4), m1); - s.clear(); - assertEquals(a.size(), 7); - } - - // Exception tests - - /** - * toArray throws an ArrayStoreException when the given array - * can not store the objects inside the list - */ - public void testToArray_ArrayStoreException() { - try { - CopyOnWriteArrayList c = new CopyOnWriteArrayList(); - c.add("zfasdfsdf"); - c.add("asdadasd"); - c.toArray(new Long[5]); - shouldThrow(); - } catch(ArrayStoreException e){} - } - - /** - * get throws an IndexOutOfBoundsException on a negative index - */ - public void testGet1_IndexOutOfBoundsException() { - try { - CopyOnWriteArrayList c = new CopyOnWriteArrayList(); - c.get(-1); - shouldThrow(); - } catch(IndexOutOfBoundsException e){} - } - - /** - * get throws an IndexOutOfBoundsException on a too high index - */ - public void testGet2_IndexOutOfBoundsException() { - try { - CopyOnWriteArrayList c = new CopyOnWriteArrayList(); - c.add("asdasd"); - c.add("asdad"); - c.get(100); - shouldThrow(); - } catch(IndexOutOfBoundsException e){} - } - - /** - * set throws an IndexOutOfBoundsException on a negative index - */ - public void testSet1_IndexOutOfBoundsException() { - try { - CopyOnWriteArrayList c = new CopyOnWriteArrayList(); - c.set(-1,"qwerty"); - shouldThrow(); - } catch(IndexOutOfBoundsException e){} - } - - /** - * set throws an IndexOutOfBoundsException on a too high index - */ - public void testSet2() { - try { - CopyOnWriteArrayList c = new CopyOnWriteArrayList(); - c.add("asdasd"); - c.add("asdad"); - c.set(100, "qwerty"); - shouldThrow(); - } catch(IndexOutOfBoundsException e){} - } - - /** - * add throws an IndexOutOfBoundsException on a negative index - */ - public void testAdd1_IndexOutOfBoundsException() { - try { - CopyOnWriteArrayList c = new CopyOnWriteArrayList(); - c.add(-1,"qwerty"); - shouldThrow(); - } catch(IndexOutOfBoundsException e){} - } - - /** - * add throws an IndexOutOfBoundsException on a too high index - */ - public void testAdd2_IndexOutOfBoundsException() { - try { - CopyOnWriteArrayList c = new CopyOnWriteArrayList(); - c.add("asdasd"); - c.add("asdasdasd"); - c.add(100, "qwerty"); - shouldThrow(); - } catch(IndexOutOfBoundsException e){} - } - - /** - * remove throws an IndexOutOfBoundsException on a negative index - */ - public void testRemove1_IndexOutOfBounds() { - try { - CopyOnWriteArrayList c = new CopyOnWriteArrayList(); - c.remove(-1); - shouldThrow(); - } catch(IndexOutOfBoundsException e){} - } - - /** - * remove throws an IndexOutOfBoundsException on a too high index - */ - public void testRemove2_IndexOutOfBounds() { - try { - CopyOnWriteArrayList c = new CopyOnWriteArrayList(); - c.add("asdasd"); - c.add("adasdasd"); - c.remove(100); - shouldThrow(); - } catch(IndexOutOfBoundsException e){} - } - - /** - * addAll throws an IndexOutOfBoundsException on a negative index - */ - public void testAddAll1_IndexOutOfBoundsException() { - try { - CopyOnWriteArrayList c = new CopyOnWriteArrayList(); - c.addAll(-1,new LinkedList()); - shouldThrow(); - } catch(IndexOutOfBoundsException e){} - } - - /** - * addAll throws an IndexOutOfBoundsException on a too high index - */ - public void testAddAll2_IndexOutOfBoundsException() { - try { - CopyOnWriteArrayList c = new CopyOnWriteArrayList(); - c.add("asdasd"); - c.add("asdasdasd"); - c.addAll(100, new LinkedList()); - shouldThrow(); - } catch(IndexOutOfBoundsException e){} - } - - /** - * listIterator throws an IndexOutOfBoundsException on a negative index - */ - public void testListIterator1_IndexOutOfBoundsException() { - try { - CopyOnWriteArrayList c = new CopyOnWriteArrayList(); - c.listIterator(-1); - shouldThrow(); - } catch(IndexOutOfBoundsException e){} - } - - /** - * listIterator throws an IndexOutOfBoundsException on a too high index - */ - public void testListIterator2_IndexOutOfBoundsException() { - try { - CopyOnWriteArrayList c = new CopyOnWriteArrayList(); - c.add("adasd"); - c.add("asdasdas"); - c.listIterator(100); - shouldThrow(); - } catch(IndexOutOfBoundsException e){} - } - - /** - * subList throws an IndexOutOfBoundsException on a negative index - */ - public void testSubList1_IndexOutOfBoundsException() { - try { - CopyOnWriteArrayList c = new CopyOnWriteArrayList(); - c.subList(-1,100); - - shouldThrow(); - } catch(IndexOutOfBoundsException e){} - } - - /** - * subList throws an IndexOutOfBoundsException on a too high index - */ - public void testSubList2_IndexOutOfBoundsException() { - try { - CopyOnWriteArrayList c = new CopyOnWriteArrayList(); - c.add("asdasd"); - c.subList(1,100); - shouldThrow(); - } catch(IndexOutOfBoundsException e){} - } - - /** - * subList throws IndexOutOfBoundsException when the second index - * is lower then the first - */ - public void testSubList3_IndexOutOfBoundsException() { - try { - CopyOnWriteArrayList c = new CopyOnWriteArrayList(); - c.subList(3,1); - - shouldThrow(); - } catch(IndexOutOfBoundsException e){} - } - - /** - * a deserialized serialiszed list is equal - */ - public void testSerialization() { - CopyOnWriteArrayList q = populatedArray(SIZE); - - try { - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(q); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - CopyOnWriteArrayList r = (CopyOnWriteArrayList)in.readObject(); - assertEquals(q.size(), r.size()); - assertTrue(q.equals(r)); - assertTrue(r.equals(q)); - } catch(Exception e){ - unexpectedException(); - } - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/CopyOnWriteArraySetTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/CopyOnWriteArraySetTest.java deleted file mode 100755 index 809fc5990..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/CopyOnWriteArraySetTest.java +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.io.*; - -public class CopyOnWriteArraySetTest extends JSR166TestCase { - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(CopyOnWriteArraySetTest.class); - } - - static CopyOnWriteArraySet populatedSet(int n){ - CopyOnWriteArraySet a = new CopyOnWriteArraySet(); - assertTrue(a.isEmpty()); - for (int i = 0; i < n; ++i) - a.add(new Integer(i)); - assertFalse(a.isEmpty()); - assertEquals(n, a.size()); - return a; - } - - /** - * Default-constructed set is empty - */ - public void testConstructor() { - CopyOnWriteArraySet a = new CopyOnWriteArraySet(); - assertTrue(a.isEmpty()); - } - - /** - * Collection-constructed set holds all of its elements - */ - public void testConstructor3() { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new Integer(i); - CopyOnWriteArraySet a = new CopyOnWriteArraySet(Arrays.asList(ints)); - for (int i = 0; i < SIZE; ++i) - assertTrue(a.contains(ints[i])); - } - - - /** - * addAll adds each element from the given collection - */ - public void testAddAll() { - CopyOnWriteArraySet full = populatedSet(3); - Vector v = new Vector(); - v.add(three); - v.add(four); - v.add(five); - full.addAll(v); - assertEquals(6, full.size()); - } - - /** - * addAll adds each element from the given collection that did not - * already exist in the set - */ - public void testAddAll2() { - CopyOnWriteArraySet full = populatedSet(3); - Vector v = new Vector(); - v.add(three); - v.add(four); - v.add(one); // will not add this element - full.addAll(v); - assertEquals(5, full.size()); - } - - /** - * add will not add the element if it already exists in the set - */ - public void testAdd2() { - CopyOnWriteArraySet full = populatedSet(3); - full.add(one); - assertEquals(3, full.size()); - } - - /** - * add adds the element when it does not exist - * in the set - */ - public void testAdd3() { - CopyOnWriteArraySet full = populatedSet(3); - full.add(three); - assertTrue(full.contains(three)); - } - - /** - * clear removes all elements from the set - */ - public void testClear() { - CopyOnWriteArraySet full = populatedSet(3); - full.clear(); - assertEquals(0, full.size()); - } - - /** - * contains returns true for added elements - */ - public void testContains() { - CopyOnWriteArraySet full = populatedSet(3); - assertTrue(full.contains(one)); - assertFalse(full.contains(five)); - } - - /** - * Sets with equal elements are equal - */ - public void testEquals() { - CopyOnWriteArraySet a = populatedSet(3); - CopyOnWriteArraySet b = populatedSet(3); - assertTrue(a.equals(b)); - assertTrue(b.equals(a)); - assertEquals(a.hashCode(), b.hashCode()); - a.add(m1); - assertFalse(a.equals(b)); - assertFalse(b.equals(a)); - b.add(m1); - assertTrue(a.equals(b)); - assertTrue(b.equals(a)); - assertEquals(a.hashCode(), b.hashCode()); - } - - - /** - * containsAll returns true for collections with subset of elements - */ - public void testContainsAll() { - CopyOnWriteArraySet full = populatedSet(3); - Vector v = new Vector(); - v.add(one); - v.add(two); - assertTrue(full.containsAll(v)); - v.add(six); - assertFalse(full.containsAll(v)); - } - - /** - * isEmpty is true when empty, else false - */ - public void testIsEmpty() { - CopyOnWriteArraySet empty = new CopyOnWriteArraySet(); - CopyOnWriteArraySet full = populatedSet(3); - assertTrue(empty.isEmpty()); - assertFalse(full.isEmpty()); - } - - /** - * iterator() returns an iterator containing the elements of the set - */ - public void testIterator() { - CopyOnWriteArraySet full = populatedSet(3); - Iterator i = full.iterator(); - int j; - for(j = 0; i.hasNext(); j++) - assertEquals(j, ((Integer)i.next()).intValue()); - assertEquals(3, j); - } - - /** - * iterator remove is unsupported - */ - public void testIteratorRemove () { - CopyOnWriteArraySet full = populatedSet(3); - Iterator it = full.iterator(); - it.next(); - try { - it.remove(); - shouldThrow(); - } - catch (UnsupportedOperationException success) {} - } - - /** - * toString holds toString of elements - */ - public void testToString() { - CopyOnWriteArraySet full = populatedSet(3); - String s = full.toString(); - for (int i = 0; i < 3; ++i) { - assertTrue(s.indexOf(String.valueOf(i)) >= 0); - } - } - - - /** - * removeAll removes all elements from the given collection - */ - public void testRemoveAll() { - CopyOnWriteArraySet full = populatedSet(3); - Vector v = new Vector(); - v.add(one); - v.add(two); - full.removeAll(v); - assertEquals(1, full.size()); - } - - - /** - * remove removes an element - */ - public void testRemove() { - CopyOnWriteArraySet full = populatedSet(3); - full.remove(one); - assertFalse(full.contains(one)); - assertEquals(2, full.size()); - } - - /** - * size returns the number of elements - */ - public void testSize() { - CopyOnWriteArraySet empty = new CopyOnWriteArraySet(); - CopyOnWriteArraySet full = populatedSet(3); - assertEquals(3, full.size()); - assertEquals(0, empty.size()); - } - - /** - * toArray returns an Object array containing all elements from the set - */ - public void testToArray() { - CopyOnWriteArraySet full = populatedSet(3); - Object[] o = full.toArray(); - assertEquals(3, o.length); - assertEquals(0, ((Integer)o[0]).intValue()); - assertEquals(1, ((Integer)o[1]).intValue()); - assertEquals(2, ((Integer)o[2]).intValue()); - } - - /** - * toArray returns an Integer array containing all elements from - * the set - */ - public void testToArray2() { - CopyOnWriteArraySet full = populatedSet(3); - Integer[] i = new Integer[3]; - i = (Integer[])full.toArray(i); - assertEquals(3, i.length); - assertEquals(0, i[0].intValue()); - assertEquals(1, i[1].intValue()); - assertEquals(2, i[2].intValue()); - } - - - /** - * toArray throws an ArrayStoreException when the given array can - * not store the objects inside the set - */ - public void testToArray_ArrayStoreException() { - try { - CopyOnWriteArraySet c = new CopyOnWriteArraySet(); - c.add("zfasdfsdf"); - c.add("asdadasd"); - c.toArray(new Long[5]); - shouldThrow(); - } catch(ArrayStoreException e){} - } - - /** - * A deserialized serialized set is equal - */ - public void testSerialization() { - CopyOnWriteArraySet q = populatedSet(SIZE); - - try { - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(q); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - CopyOnWriteArraySet r = (CopyOnWriteArraySet)in.readObject(); - assertEquals(q.size(), r.size()); - assertTrue(q.equals(r)); - assertTrue(r.equals(q)); - } catch(Exception e){ - unexpectedException(); - } - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/CountDownLatchTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/CountDownLatchTest.java deleted file mode 100755 index 0d69889be..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/CountDownLatchTest.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; - -public class CountDownLatchTest extends JSR166TestCase { - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(CountDownLatchTest.class); - } - - /** - * negative constructor argument throws IAE - */ - public void testConstructor() { - try { - new CountDownLatch(-1); - shouldThrow(); - } catch(IllegalArgumentException success){} - } - - /** - * getCount returns initial count and decreases after countDown - */ - public void testGetCount() { - final CountDownLatch l = new CountDownLatch(2); - assertEquals(2, l.getCount()); - l.countDown(); - assertEquals(1, l.getCount()); - } - - /** - * countDown decrements count when positive and has no effect when zero - */ - public void testCountDown() { - final CountDownLatch l = new CountDownLatch(1); - assertEquals(1, l.getCount()); - l.countDown(); - assertEquals(0, l.getCount()); - l.countDown(); - assertEquals(0, l.getCount()); - } - - /** - * await returns after countDown to zero, but not before - */ - public void testAwait() { - final CountDownLatch l = new CountDownLatch(2); - - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertTrue(l.getCount() > 0); - l.await(); - threadAssertTrue(l.getCount() == 0); - } catch(InterruptedException e){ - threadUnexpectedException(); - } - } - }); - t.start(); - try { - assertEquals(l.getCount(), 2); - Thread.sleep(SHORT_DELAY_MS); - l.countDown(); - assertEquals(l.getCount(), 1); - l.countDown(); - assertEquals(l.getCount(), 0); - t.join(); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - - /** - * timed await returns after countDown to zero - */ - public void testTimedAwait() { - final CountDownLatch l = new CountDownLatch(2); - - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertTrue(l.getCount() > 0); - threadAssertTrue(l.await(SMALL_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch(InterruptedException e){ - threadUnexpectedException(); - } - } - }); - t.start(); - try { - assertEquals(l.getCount(), 2); - Thread.sleep(SHORT_DELAY_MS); - l.countDown(); - assertEquals(l.getCount(), 1); - l.countDown(); - assertEquals(l.getCount(), 0); - t.join(); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * await throws IE if interrupted before counted down - */ - public void testAwait_InterruptedException() { - final CountDownLatch l = new CountDownLatch(1); - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertTrue(l.getCount() > 0); - l.await(); - threadShouldThrow(); - } catch(InterruptedException success){} - } - }); - t.start(); - try { - assertEquals(l.getCount(), 1); - t.interrupt(); - t.join(); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * timed await throws IE if interrupted before counted down - */ - public void testTimedAwait_InterruptedException() { - final CountDownLatch l = new CountDownLatch(1); - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertTrue(l.getCount() > 0); - l.await(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch(InterruptedException success){} - } - }); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - assertEquals(l.getCount(), 1); - t.interrupt(); - t.join(); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * timed await times out if not counted down before timeout - */ - public void testAwaitTimeout() { - final CountDownLatch l = new CountDownLatch(1); - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertTrue(l.getCount() > 0); - threadAssertFalse(l.await(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - threadAssertTrue(l.getCount() > 0); - } catch(InterruptedException ie){ - threadUnexpectedException(); - } - } - }); - t.start(); - try { - assertEquals(l.getCount(), 1); - t.join(); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * toString indicates current count - */ - public void testToString() { - CountDownLatch s = new CountDownLatch(2); - String us = s.toString(); - assertTrue(us.indexOf("Count = 2") >= 0); - s.countDown(); - String s1 = s.toString(); - assertTrue(s1.indexOf("Count = 1") >= 0); - s.countDown(); - String s2 = s.toString(); - assertTrue(s2.indexOf("Count = 0") >= 0); - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/CyclicBarrierTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/CyclicBarrierTest.java deleted file mode 100755 index ecd6e45c6..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/CyclicBarrierTest.java +++ /dev/null @@ -1,626 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.locks.*; -import java.util.concurrent.atomic.*; - -public class CyclicBarrierTest extends JSR166TestCase{ - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(CyclicBarrierTest.class); - } - - private volatile int countAction; - private class MyAction implements Runnable { - public void run() { ++countAction; } - } - - /** - * Creating with negative parties throws IAE - */ - public void testConstructor1() { - try { - new CyclicBarrier(-1, (Runnable)null); - shouldThrow(); - } catch(IllegalArgumentException e){} - } - - /** - * Creating with negative parties and no action throws IAE - */ - public void testConstructor2() { - try { - new CyclicBarrier(-1); - shouldThrow(); - } catch(IllegalArgumentException e){} - } - - /** - * getParties returns the number of parties given in constructor - */ - public void testGetParties() { - CyclicBarrier b = new CyclicBarrier(2); - assertEquals(2, b.getParties()); - assertEquals(0, b.getNumberWaiting()); - } - - /** - * A 1-party barrier triggers after single await - */ - public void testSingleParty() { - try { - CyclicBarrier b = new CyclicBarrier(1); - assertEquals(1, b.getParties()); - assertEquals(0, b.getNumberWaiting()); - b.await(); - b.await(); - assertEquals(0, b.getNumberWaiting()); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * The supplied barrier action is run at barrier - */ - public void testBarrierAction() { - try { - countAction = 0; - CyclicBarrier b = new CyclicBarrier(1, new MyAction()); - assertEquals(1, b.getParties()); - assertEquals(0, b.getNumberWaiting()); - b.await(); - b.await(); - assertEquals(0, b.getNumberWaiting()); - assertEquals(countAction, 2); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * A 2-party/thread barrier triggers after both threads invoke await - */ - public void testTwoParties() { - final CyclicBarrier b = new CyclicBarrier(2); - Thread t = new Thread(new Runnable() { - public void run() { - try { - b.await(); - b.await(); - b.await(); - b.await(); - } catch(Exception e){ - threadUnexpectedException(); - }}}); - - try { - t.start(); - b.await(); - b.await(); - b.await(); - b.await(); - t.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * An interruption in one party causes others waiting in await to - * throw BrokenBarrierException - */ - public void testAwait1_Interrupted_BrokenBarrier() { - final CyclicBarrier c = new CyclicBarrier(3); - Thread t1 = new Thread(new Runnable() { - public void run() { - try { - c.await(); - threadShouldThrow(); - } catch(InterruptedException success){} - catch(Exception b){ - threadUnexpectedException(); - } - } - }); - Thread t2 = new Thread(new Runnable() { - public void run() { - try { - c.await(); - threadShouldThrow(); - } catch(BrokenBarrierException success){ - } catch(Exception i){ - threadUnexpectedException(); - } - } - }); - try { - t1.start(); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - t1.interrupt(); - t1.join(); - t2.join(); - } catch(InterruptedException e){ - unexpectedException(); - } - } - - /** - * An interruption in one party causes others waiting in timed await to - * throw BrokenBarrierException - */ - public void testAwait2_Interrupted_BrokenBarrier() { - final CyclicBarrier c = new CyclicBarrier(3); - Thread t1 = new Thread(new Runnable() { - public void run() { - try { - c.await(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch(InterruptedException success){ - } catch(Exception b){ - threadUnexpectedException(); - } - } - }); - Thread t2 = new Thread(new Runnable() { - public void run() { - try { - c.await(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch(BrokenBarrierException success){ - } catch(Exception i){ - threadUnexpectedException(); - } - } - }); - try { - t1.start(); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - t1.interrupt(); - t1.join(); - t2.join(); - } catch(InterruptedException e){ - unexpectedException(); - } - } - - /** - * A timeout in timed await throws TimeoutException - */ - public void testAwait3_TimeOutException() { - final CyclicBarrier c = new CyclicBarrier(2); - Thread t = new Thread(new Runnable() { - public void run() { - try { - c.await(SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch(TimeoutException success){ - } catch(Exception b){ - threadUnexpectedException(); - - } - } - }); - try { - t.start(); - t.join(); - } catch(InterruptedException e){ - unexpectedException(); - } - } - - /** - * A timeout in one party causes others waiting in timed await to - * throw BrokenBarrierException - */ - public void testAwait4_Timeout_BrokenBarrier() { - final CyclicBarrier c = new CyclicBarrier(3); - Thread t1 = new Thread(new Runnable() { - public void run() { - try { - c.await(SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch(TimeoutException success){ - } catch(Exception b){ - threadUnexpectedException(); - } - } - }); - Thread t2 = new Thread(new Runnable() { - public void run() { - try { - c.await(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch(BrokenBarrierException success){ - } catch(Exception i){ - threadUnexpectedException(); - } - } - }); - try { - t1.start(); - t2.start(); - t1.join(); - t2.join(); - } catch(InterruptedException e){ - unexpectedException(); - } - } - - /** - * A timeout in one party causes others waiting in await to - * throw BrokenBarrierException - */ - public void testAwait5_Timeout_BrokenBarrier() { - final CyclicBarrier c = new CyclicBarrier(3); - Thread t1 = new Thread(new Runnable() { - public void run() { - try { - c.await(SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch(TimeoutException success){ - } catch(Exception b){ - threadUnexpectedException(); - } - } - }); - Thread t2 = new Thread(new Runnable() { - public void run() { - try { - c.await(); - threadShouldThrow(); - } catch(BrokenBarrierException success){ - } catch(Exception i){ - threadUnexpectedException(); - } - } - }); - try { - t1.start(); - t2.start(); - t1.join(); - t2.join(); - } catch(InterruptedException e){ - unexpectedException(); - } - } - - /** - * A reset of an active barrier causes waiting threads to throw - * BrokenBarrierException - */ - public void testReset_BrokenBarrier() { - final CyclicBarrier c = new CyclicBarrier(3); - Thread t1 = new Thread(new Runnable() { - public void run() { - try { - c.await(); - threadShouldThrow(); - } catch(BrokenBarrierException success){} - catch(Exception b){ - threadUnexpectedException(); - } - } - }); - Thread t2 = new Thread(new Runnable() { - public void run() { - try { - c.await(); - threadShouldThrow(); - } catch(BrokenBarrierException success){ - } catch(Exception i){ - threadUnexpectedException(); - } - } - }); - try { - t1.start(); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - c.reset(); - t1.join(); - t2.join(); - } catch(InterruptedException e){ - unexpectedException(); - } - } - - /** - * A reset before threads enter barrier does not throw - * BrokenBarrierException - */ - public void testReset_NoBrokenBarrier() { - final CyclicBarrier c = new CyclicBarrier(3); - Thread t1 = new Thread(new Runnable() { - public void run() { - try { - c.await(); - } catch(Exception b){ - threadUnexpectedException(); - } - } - }); - Thread t2 = new Thread(new Runnable() { - public void run() { - try { - c.await(); - } catch(Exception i){ - threadUnexpectedException(); - } - } - }); - try { - c.reset(); - t1.start(); - t2.start(); - c.await(); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * All threads block while a barrier is broken. - */ - public void testReset_Leakage() { - try { - final CyclicBarrier c = new CyclicBarrier(2); - final AtomicBoolean done = new AtomicBoolean(); - Thread t = new Thread() { - public void run() { - while (!done.get()) { - try { - while (c.isBroken()) - c.reset(); - - c.await(); - threadFail("await should not return"); - } - catch (BrokenBarrierException e) { - } - catch (InterruptedException ie) { - } - } - } - }; - - t.start(); - for( int i = 0; i < 4; i++) { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - } - done.set(true); - t.interrupt(); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * Reset of a non-broken barrier does not break barrier - */ - public void testResetWithoutBreakage() { - try { - final CyclicBarrier start = new CyclicBarrier(3); - final CyclicBarrier barrier = new CyclicBarrier(3); - for (int i = 0; i < 3; i++) { - Thread t1 = new Thread(new Runnable() { - public void run() { - try { start.await(); } - catch (Exception ie) { - threadFail("start barrier"); - } - try { barrier.await(); } - catch (Throwable thrown) { - unexpectedException(); - }}}); - - Thread t2 = new Thread(new Runnable() { - public void run() { - try { start.await(); } - catch (Exception ie) { - threadFail("start barrier"); - } - try { barrier.await(); } - catch (Throwable thrown) { - unexpectedException(); - }}}); - - - t1.start(); - t2.start(); - try { start.await(); } - catch (Exception ie) { threadFail("start barrier"); } - barrier.await(); - t1.join(); - t2.join(); - assertFalse(barrier.isBroken()); - assertEquals(0, barrier.getNumberWaiting()); - if (i == 1) barrier.reset(); - assertFalse(barrier.isBroken()); - assertEquals(0, barrier.getNumberWaiting()); - } - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * Reset of a barrier after interruption reinitializes it. - */ - public void testResetAfterInterrupt() { - try { - final CyclicBarrier start = new CyclicBarrier(3); - final CyclicBarrier barrier = new CyclicBarrier(3); - for (int i = 0; i < 2; i++) { - Thread t1 = new Thread(new Runnable() { - public void run() { - try { start.await(); } - catch (Exception ie) { - threadFail("start barrier"); - } - try { barrier.await(); } - catch(InterruptedException ok) {} - catch (Throwable thrown) { - unexpectedException(); - }}}); - - Thread t2 = new Thread(new Runnable() { - public void run() { - try { start.await(); } - catch (Exception ie) { - threadFail("start barrier"); - } - try { barrier.await(); } - catch(BrokenBarrierException ok) {} - catch (Throwable thrown) { - unexpectedException(); - }}}); - - t1.start(); - t2.start(); - try { start.await(); } - catch (Exception ie) { threadFail("start barrier"); } - t1.interrupt(); - t1.join(); - t2.join(); - assertTrue(barrier.isBroken()); - assertEquals(0, barrier.getNumberWaiting()); - barrier.reset(); - assertFalse(barrier.isBroken()); - assertEquals(0, barrier.getNumberWaiting()); - } - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * Reset of a barrier after timeout reinitializes it. - */ - public void testResetAfterTimeout() { - try { - final CyclicBarrier start = new CyclicBarrier(3); - final CyclicBarrier barrier = new CyclicBarrier(3); - for (int i = 0; i < 2; i++) { - Thread t1 = new Thread(new Runnable() { - public void run() { - try { start.await(); } - catch (Exception ie) { - threadFail("start barrier"); - } - try { barrier.await(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); } - catch(TimeoutException ok) {} - catch (Throwable thrown) { - unexpectedException(); - }}}); - - Thread t2 = new Thread(new Runnable() { - public void run() { - try { start.await(); } - catch (Exception ie) { - threadFail("start barrier"); - } - try { barrier.await(); } - catch(BrokenBarrierException ok) {} - catch (Throwable thrown) { - unexpectedException(); - }}}); - - t1.start(); - t2.start(); - try { start.await(); } - catch (Exception ie) { threadFail("start barrier"); } - t1.join(); - t2.join(); - assertTrue(barrier.isBroken()); - assertEquals(0, barrier.getNumberWaiting()); - barrier.reset(); - assertFalse(barrier.isBroken()); - assertEquals(0, barrier.getNumberWaiting()); - } - } - catch (Exception ex) { - unexpectedException(); - } - } - - - /** - * Reset of a barrier after a failed command reinitializes it. - */ - public void testResetAfterCommandException() { - try { - final CyclicBarrier start = new CyclicBarrier(3); - final CyclicBarrier barrier = - new CyclicBarrier(3, new Runnable() { - public void run() { - throw new NullPointerException(); }}); - for (int i = 0; i < 2; i++) { - Thread t1 = new Thread(new Runnable() { - public void run() { - try { start.await(); } - catch (Exception ie) { - threadFail("start barrier"); - } - try { barrier.await(); } - catch(BrokenBarrierException ok) {} - catch (Throwable thrown) { - unexpectedException(); - }}}); - - Thread t2 = new Thread(new Runnable() { - public void run() { - try { start.await(); } - catch (Exception ie) { - threadFail("start barrier"); - } - try { barrier.await(); } - catch(BrokenBarrierException ok) {} - catch (Throwable thrown) { - unexpectedException(); - }}}); - - t1.start(); - t2.start(); - try { start.await(); } - catch (Exception ie) { threadFail("start barrier"); } - while (barrier.getNumberWaiting() < 2) { Thread.yield(); } - try { barrier.await(); } - catch (Exception ok) { } - t1.join(); - t2.join(); - assertTrue(barrier.isBroken()); - assertEquals(0, barrier.getNumberWaiting()); - barrier.reset(); - assertFalse(barrier.isBroken()); - assertEquals(0, barrier.getNumberWaiting()); - } - } - catch (Exception ex) { - unexpectedException(); - } - } -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/DelayQueueTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/DelayQueueTest.java deleted file mode 100755 index 978edb460..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/DelayQueueTest.java +++ /dev/null @@ -1,1035 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; - -public class DelayQueueTest extends JSR166TestCase { - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - - public static Test suite() { - return new TestSuite(DelayQueueTest.class); - } - - private static final int NOCAP = Integer.MAX_VALUE; - - /** - * A delayed implementation for testing. - * Most tests use Pseudodelays, where delays are all elapsed - * (so, no blocking solely for delays) but are still ordered - */ - static class PDelay implements Delayed { - int pseudodelay; - PDelay(int i) { pseudodelay = Integer.MIN_VALUE + i; } - public int compareTo(PDelay y) { - int i = pseudodelay; - int j = ((PDelay)y).pseudodelay; - if (i < j) return -1; - if (i > j) return 1; - return 0; - } - - public int compareTo(Delayed y) { - int i = pseudodelay; - int j = ((PDelay)y).pseudodelay; - if (i < j) return -1; - if (i > j) return 1; - return 0; - } - - public boolean equals(Object other) { - return ((PDelay)other).pseudodelay == pseudodelay; - } - public boolean equals(PDelay other) { - return ((PDelay)other).pseudodelay == pseudodelay; - } - - - public long getDelay(TimeUnit ignore) { - return pseudodelay; - } - public int intValue() { - return pseudodelay; - } - - public String toString() { - return String.valueOf(pseudodelay); - } - } - - - /** - * Delayed implementation that actually delays - */ - static class NanoDelay implements Delayed { - long trigger; - NanoDelay(long i) { - trigger = System.nanoTime() + i; - } - public int compareTo(NanoDelay y) { - long i = trigger; - long j = ((NanoDelay)y).trigger; - if (i < j) return -1; - if (i > j) return 1; - return 0; - } - - public int compareTo(Delayed y) { - long i = trigger; - long j = ((NanoDelay)y).trigger; - if (i < j) return -1; - if (i > j) return 1; - return 0; - } - - public boolean equals(Object other) { - return ((NanoDelay)other).trigger == trigger; - } - public boolean equals(NanoDelay other) { - return ((NanoDelay)other).trigger == trigger; - } - - public long getDelay(TimeUnit unit) { - long n = trigger - System.nanoTime(); - return unit.convert(n, TimeUnit.NANOSECONDS); - } - - public long getTriggerTime() { - return trigger; - } - - public String toString() { - return String.valueOf(trigger); - } - } - - - /** - * Create a queue of given size containing consecutive - * PDelays 0 ... n. - */ - private DelayQueue populatedQueue(int n) { - DelayQueue q = new DelayQueue(); - assertTrue(q.isEmpty()); - for(int i = n-1; i >= 0; i-=2) - assertTrue(q.offer(new PDelay(i))); - for(int i = (n & 1); i < n; i+=2) - assertTrue(q.offer(new PDelay(i))); - assertFalse(q.isEmpty()); - assertEquals(NOCAP, q.remainingCapacity()); - assertEquals(n, q.size()); - return q; - } - - /** - * A new queue has unbounded capacity - */ - public void testConstructor1() { - assertEquals(NOCAP, new DelayQueue().remainingCapacity()); - } - - /** - * Initializing from null Collection throws NPE - */ - public void testConstructor3() { - try { - DelayQueue q = new DelayQueue(null); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Initializing from Collection of null elements throws NPE - */ - public void testConstructor4() { - try { - PDelay[] ints = new PDelay[SIZE]; - DelayQueue q = new DelayQueue(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Initializing from Collection with some null elements throws NPE - */ - public void testConstructor5() { - try { - PDelay[] ints = new PDelay[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new PDelay(i); - DelayQueue q = new DelayQueue(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Queue contains all elements of collection used to initialize - */ - public void testConstructor6() { - try { - PDelay[] ints = new PDelay[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new PDelay(i); - DelayQueue q = new DelayQueue(Arrays.asList(ints)); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); - } - finally {} - } - - /** - * isEmpty is true before add, false after - */ - public void testEmpty() { - DelayQueue q = new DelayQueue(); - assertTrue(q.isEmpty()); - assertEquals(NOCAP, q.remainingCapacity()); - q.add(new PDelay(1)); - assertFalse(q.isEmpty()); - q.add(new PDelay(2)); - q.remove(); - q.remove(); - assertTrue(q.isEmpty()); - } - - /** - * remainingCapacity does not change when elementa added or removed, - * but size does - */ - public void testRemainingCapacity() { - DelayQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(NOCAP, q.remainingCapacity()); - assertEquals(SIZE-i, q.size()); - q.remove(); - } - for (int i = 0; i < SIZE; ++i) { - assertEquals(NOCAP, q.remainingCapacity()); - assertEquals(i, q.size()); - q.add(new PDelay(i)); - } - } - - /** - * offer(null) throws NPE - */ - public void testOfferNull() { - try { - DelayQueue q = new DelayQueue(); - q.offer(null); - shouldThrow(); - } catch (NullPointerException success) { } - } - - /** - * add(null) throws NPE - */ - public void testAddNull() { - try { - DelayQueue q = new DelayQueue(); - q.add(null); - shouldThrow(); - } catch (NullPointerException success) { } - } - - /** - * offer non-null succeeds - */ - public void testOffer() { - DelayQueue q = new DelayQueue(); - assertTrue(q.offer(new PDelay(0))); - assertTrue(q.offer(new PDelay(1))); - } - - /** - * add succeeds - */ - public void testAdd() { - DelayQueue q = new DelayQueue(); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - assertTrue(q.add(new PDelay(i))); - } - } - - /** - * addAll(null) throws NPE - */ - public void testAddAll1() { - try { - DelayQueue q = new DelayQueue(); - q.addAll(null); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - - /** - * addAll(this) throws IAE - */ - public void testAddAllSelf() { - try { - DelayQueue q = populatedQueue(SIZE); - q.addAll(q); - shouldThrow(); - } - catch (IllegalArgumentException success) {} - } - - /** - * addAll of a collection with null elements throws NPE - */ - public void testAddAll2() { - try { - DelayQueue q = new DelayQueue(); - PDelay[] ints = new PDelay[SIZE]; - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - /** - * addAll of a collection with any null elements throws NPE after - * possibly adding some elements - */ - public void testAddAll3() { - try { - DelayQueue q = new DelayQueue(); - PDelay[] ints = new PDelay[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new PDelay(i); - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Queue contains all elements of successful addAll - */ - public void testAddAll5() { - try { - PDelay[] empty = new PDelay[0]; - PDelay[] ints = new PDelay[SIZE]; - for (int i = SIZE-1; i >= 0; --i) - ints[i] = new PDelay(i); - DelayQueue q = new DelayQueue(); - assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); - } - finally {} - } - - /** - * put(null) throws NPE - */ - public void testPutNull() { - try { - DelayQueue q = new DelayQueue(); - q.put(null); - shouldThrow(); - } - catch (NullPointerException success){ - } - } - - /** - * all elements successfully put are contained - */ - public void testPut() { - try { - DelayQueue q = new DelayQueue(); - for (int i = 0; i < SIZE; ++i) { - PDelay I = new PDelay(i); - q.put(I); - assertTrue(q.contains(I)); - } - assertEquals(SIZE, q.size()); - } - finally { - } - } - - /** - * put doesn't block waiting for take - */ - public void testPutWithTake() { - final DelayQueue q = new DelayQueue(); - Thread t = new Thread(new Runnable() { - public void run() { - int added = 0; - try { - q.put(new PDelay(0)); - ++added; - q.put(new PDelay(0)); - ++added; - q.put(new PDelay(0)); - ++added; - q.put(new PDelay(0)); - ++added; - threadAssertTrue(added == 4); - } finally { - } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - q.take(); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - /** - * timed offer does not time out - */ - public void testTimedOffer() { - final DelayQueue q = new DelayQueue(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - q.put(new PDelay(0)); - q.put(new PDelay(0)); - threadAssertTrue(q.offer(new PDelay(0), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - threadAssertTrue(q.offer(new PDelay(0), LONG_DELAY_MS, TimeUnit.MILLISECONDS)); - } finally { } - } - }); - - try { - t.start(); - Thread.sleep(SMALL_DELAY_MS); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - /** - * take retrieves elements in priority order - */ - public void testTake() { - try { - DelayQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(new PDelay(i), ((PDelay)q.take())); - } - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * take blocks interruptibly when empty - */ - public void testTakeFromEmpty() { - final DelayQueue q = new DelayQueue(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - q.take(); - threadShouldThrow(); - } catch (InterruptedException success){ } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - /** - * Take removes existing elements until empty, then blocks interruptibly - */ - public void testBlockingTake() { - Thread t = new Thread(new Runnable() { - public void run() { - try { - DelayQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - threadAssertEquals(new PDelay(i), ((PDelay)q.take())); - } - q.take(); - threadShouldThrow(); - } catch (InterruptedException success){ - } - }}); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } - catch (InterruptedException ie) { - unexpectedException(); - } - } - - - /** - * poll succeeds unless empty - */ - public void testPoll() { - DelayQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(new PDelay(i), ((PDelay)q.poll())); - } - assertNull(q.poll()); - } - - /** - * timed pool with zero timeout succeeds when non-empty, else times out - */ - public void testTimedPoll0() { - try { - DelayQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(new PDelay(i), ((PDelay)q.poll(0, TimeUnit.MILLISECONDS))); - } - assertNull(q.poll(0, TimeUnit.MILLISECONDS)); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * timed pool with nonzero timeout succeeds when non-empty, else times out - */ - public void testTimedPoll() { - try { - DelayQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(new PDelay(i), ((PDelay)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS))); - } - assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * Interrupted timed poll throws InterruptedException instead of - * returning timeout status - */ - public void testInterruptedTimedPoll() { - Thread t = new Thread(new Runnable() { - public void run() { - try { - DelayQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - threadAssertEquals(new PDelay(i), ((PDelay)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS))); - } - threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch (InterruptedException success){ - } - }}); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } - catch (InterruptedException ie) { - unexpectedException(); - } - } - - /** - * timed poll before a delayed offer fails; after offer succeeds; - * on interruption throws - */ - public void testTimedPollWithOffer() { - final DelayQueue q = new DelayQueue(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadFail("Should block"); - } catch (InterruptedException success) { } - } - }); - try { - t.start(); - Thread.sleep(SMALL_DELAY_MS); - assertTrue(q.offer(new PDelay(0), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - - /** - * peek returns next element, or null if empty - */ - public void testPeek() { - DelayQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(new PDelay(i), ((PDelay)q.peek())); - q.poll(); - if (q.isEmpty()) - assertNull(q.peek()); - else - assertTrue(i != ((PDelay)q.peek()).intValue()); - } - assertNull(q.peek()); - } - - /** - * element returns next element, or throws NSEE if empty - */ - public void testElement() { - DelayQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(new PDelay(i), ((PDelay)q.element())); - q.poll(); - } - try { - q.element(); - shouldThrow(); - } - catch (NoSuchElementException success) {} - } - - /** - * remove removes next element, or throws NSEE if empty - */ - public void testRemove() { - DelayQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(new PDelay(i), ((PDelay)q.remove())); - } - try { - q.remove(); - shouldThrow(); - } catch (NoSuchElementException success){ - } - } - - /** - * remove(x) removes x and returns true if present - */ - public void testRemoveElement() { - DelayQueue q = populatedQueue(SIZE); - for (int i = 1; i < SIZE; i+=2) { - assertTrue(q.remove(new PDelay(i))); - } - for (int i = 0; i < SIZE; i+=2) { - assertTrue(q.remove(new PDelay(i))); - assertFalse(q.remove(new PDelay(i+1))); - } - assertTrue(q.isEmpty()); - } - - /** - * contains(x) reports true when elements added but not yet removed - */ - public void testContains() { - DelayQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new PDelay(i))); - q.poll(); - assertFalse(q.contains(new PDelay(i))); - } - } - - /** - * clear removes all elements - */ - public void testClear() { - DelayQueue q = populatedQueue(SIZE); - q.clear(); - assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - assertEquals(NOCAP, q.remainingCapacity()); - PDelay x = new PDelay(1); - q.add(x); - assertFalse(q.isEmpty()); - assertTrue(q.contains(x)); - q.clear(); - assertTrue(q.isEmpty()); - } - - /** - * containsAll(c) is true when c contains a subset of elements - */ - public void testContainsAll() { - DelayQueue q = populatedQueue(SIZE); - DelayQueue p = new DelayQueue(); - for (int i = 0; i < SIZE; ++i) { - assertTrue(q.containsAll(p)); - assertFalse(p.containsAll(q)); - p.add(new PDelay(i)); - } - assertTrue(p.containsAll(q)); - } - - /** - * retainAll(c) retains only those elements of c and reports true if changed - */ - public void testRetainAll() { - DelayQueue q = populatedQueue(SIZE); - DelayQueue p = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - boolean changed = q.retainAll(p); - if (i == 0) - assertFalse(changed); - else - assertTrue(changed); - - assertTrue(q.containsAll(p)); - assertEquals(SIZE-i, q.size()); - p.remove(); - } - } - - /** - * removeAll(c) removes only those elements of c and reports true if changed - */ - public void testRemoveAll() { - for (int i = 1; i < SIZE; ++i) { - DelayQueue q = populatedQueue(SIZE); - DelayQueue p = populatedQueue(i); - assertTrue(q.removeAll(p)); - assertEquals(SIZE-i, q.size()); - for (int j = 0; j < i; ++j) { - PDelay I = (PDelay)(p.remove()); - assertFalse(q.contains(I)); - } - } - } - - /** - * toArray contains all elements - */ - public void testToArray() { - DelayQueue q = populatedQueue(SIZE); - Object[] o = q.toArray(); - Arrays.sort(o); - try { - for(int i = 0; i < o.length; i++) - assertEquals(o[i], q.take()); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * toArray(a) contains all elements - */ - public void testToArray2() { - DelayQueue q = populatedQueue(SIZE); - PDelay[] ints = new PDelay[SIZE]; - ints = (PDelay[])q.toArray(ints); - Arrays.sort(ints); - try { - for(int i = 0; i < ints.length; i++) - assertEquals(ints[i], q.take()); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - - /** - * toArray(null) throws NPE - */ - public void testToArray_BadArg() { - try { - DelayQueue q = populatedQueue(SIZE); - Object o[] = q.toArray(null); - shouldThrow(); - } catch(NullPointerException success){} - } - - /** - * toArray with incompatible array type throws CCE - */ - public void testToArray1_BadArg() { - try { - DelayQueue q = populatedQueue(SIZE); - Object o[] = q.toArray(new String[10] ); - shouldThrow(); - } catch(ArrayStoreException success){} - } - - /** - * iterator iterates through all elements - */ - public void testIterator() { - DelayQueue q = populatedQueue(SIZE); - int i = 0; - Iterator it = q.iterator(); - while(it.hasNext()) { - assertTrue(q.contains(it.next())); - ++i; - } - assertEquals(i, SIZE); - } - - /** - * iterator.remove removes current element - */ - public void testIteratorRemove () { - final DelayQueue q = new DelayQueue(); - q.add(new PDelay(2)); - q.add(new PDelay(1)); - q.add(new PDelay(3)); - Iterator it = q.iterator(); - it.next(); - it.remove(); - it = q.iterator(); - assertEquals(it.next(), new PDelay(2)); - assertEquals(it.next(), new PDelay(3)); - assertFalse(it.hasNext()); - } - - - /** - * toString contains toStrings of elements - */ - public void testToString() { - DelayQueue q = populatedQueue(SIZE); - String s = q.toString(); - for (int i = 0; i < SIZE; ++i) { - assertTrue(s.indexOf(String.valueOf(Integer.MIN_VALUE+i)) >= 0); - } - } - - /** - * offer transfers elements across Executor tasks - */ - public void testPollInExecutor() { - final DelayQueue q = new DelayQueue(); - ExecutorService executor = Executors.newFixedThreadPool(2); - executor.execute(new Runnable() { - public void run() { - threadAssertNull(q.poll()); - try { - threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS)); - threadAssertTrue(q.isEmpty()); - } - catch (InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - executor.execute(new Runnable() { - public void run() { - try { - Thread.sleep(SHORT_DELAY_MS); - q.put(new PDelay(1)); - } - catch (InterruptedException e) { - threadUnexpectedException(); - } - } - }); - joinPool(executor); - - } - - - /** - * Delayed actions do not occur until their delay elapses - */ - public void testDelay() { - DelayQueue q = new DelayQueue(); - NanoDelay[] elements = new NanoDelay[SIZE]; - for (int i = 0; i < SIZE; ++i) { - elements[i] = new NanoDelay(1000000000L + 1000000L * (SIZE - i)); - } - for (int i = 0; i < SIZE; ++i) { - q.add(elements[i]); - } - - try { - long last = 0; - for (int i = 0; i < SIZE; ++i) { - NanoDelay e = (NanoDelay)(q.take()); - long tt = e.getTriggerTime(); - assertTrue(tt <= System.nanoTime()); - if (i != 0) - assertTrue(tt >= last); - last = tt; - } - } - catch(InterruptedException ie) { - unexpectedException(); - } - } - - /** - * peek of a non-empty queue returns non-null even if not expired - */ - public void testPeekDelayed() { - DelayQueue q = new DelayQueue(); - q.add(new NanoDelay(Long.MAX_VALUE)); - assert(q.peek() != null); - } - - - /** - * poll of a non-empty queue returns null if no expired elements. - */ - public void testPollDelayed() { - DelayQueue q = new DelayQueue(); - q.add(new NanoDelay(Long.MAX_VALUE)); - assertNull(q.poll()); - } - - /** - * timed poll of a non-empty queue returns null if no expired elements. - */ - public void testTimedPollDelayed() { - DelayQueue q = new DelayQueue(); - q.add(new NanoDelay(LONG_DELAY_MS * 1000000L)); - try { - assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch (Exception ex) { - unexpectedException(); - } - } - - /** - * drainTo(null) throws NPE - */ - public void testDrainToNull() { - DelayQueue q = populatedQueue(SIZE); - try { - q.drainTo(null); - shouldThrow(); - } catch(NullPointerException success) { - } - } - - /** - * drainTo(this) throws IAE - */ - public void testDrainToSelf() { - DelayQueue q = populatedQueue(SIZE); - try { - q.drainTo(q); - shouldThrow(); - } catch(IllegalArgumentException success) { - } - } - - /** - * drainTo(c) empties queue into another collection c - */ - public void testDrainTo() { - DelayQueue q = new DelayQueue(); - PDelay[] elems = new PDelay[SIZE]; - for (int i = 0; i < SIZE; ++i) { - elems[i] = new PDelay(i); - q.add(elems[i]); - } - ArrayList l = new ArrayList(); - q.drainTo(l); - assertEquals(q.size(), 0); - for (int i = 0; i < SIZE; ++i) - assertEquals(l.get(i), elems[i]); - q.add(elems[0]); - q.add(elems[1]); - assertFalse(q.isEmpty()); - assertTrue(q.contains(elems[0])); - assertTrue(q.contains(elems[1])); - l.clear(); - q.drainTo(l); - assertEquals(q.size(), 0); - assertEquals(l.size(), 2); - for (int i = 0; i < 2; ++i) - assertEquals(l.get(i), elems[i]); - } - - /** - * drainTo empties queue - */ - public void testDrainToWithActivePut() { - final DelayQueue q = populatedQueue(SIZE); - Thread t = new Thread(new Runnable() { - public void run() { - q.put(new PDelay(SIZE+1)); - } - }); - try { - t.start(); - ArrayList l = new ArrayList(); - q.drainTo(l); - assertTrue(l.size() >= SIZE); - t.join(); - assertTrue(q.size() + l.size() >= SIZE); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * drainTo(null, n) throws NPE - */ - public void testDrainToNullN() { - DelayQueue q = populatedQueue(SIZE); - try { - q.drainTo(null, 0); - shouldThrow(); - } catch(NullPointerException success) { - } - } - - /** - * drainTo(this, n) throws IAE - */ - public void testDrainToSelfN() { - DelayQueue q = populatedQueue(SIZE); - try { - q.drainTo(q, 0); - shouldThrow(); - } catch(IllegalArgumentException success) { - } - } - - /** - * drainTo(c, n) empties first max {n, size} elements of queue into c - */ - public void testDrainToN() { - for (int i = 0; i < SIZE + 2; ++i) { - DelayQueue q = populatedQueue(SIZE); - ArrayList l = new ArrayList(); - q.drainTo(l, i); - int k = (i < SIZE)? i : SIZE; - assertEquals(q.size(), SIZE-k); - assertEquals(l.size(), k); - } - } - - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ExchangerTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ExchangerTest.java deleted file mode 100755 index 9811e82d2..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ExchangerTest.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; - -public class ExchangerTest extends JSR166TestCase { - - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(ExchangerTest.class); - } - - /** - * exchange exchanges objects across two threads - */ - public void testExchange() { - final Exchanger e = new Exchanger(); - Thread t1 = new Thread(new Runnable(){ - public void run(){ - try { - Object v = e.exchange(one); - threadAssertEquals(v, two); - Object w = e.exchange(v); - threadAssertEquals(w, one); - } catch(InterruptedException e){ - threadUnexpectedException(); - } - } - }); - Thread t2 = new Thread(new Runnable(){ - public void run(){ - try { - Object v = e.exchange(two); - threadAssertEquals(v, one); - Object w = e.exchange(v); - threadAssertEquals(w, two); - } catch(InterruptedException e){ - threadUnexpectedException(); - } - } - }); - try { - t1.start(); - t2.start(); - t1.join(); - t2.join(); - } catch(InterruptedException ex) { - unexpectedException(); - } - } - - /** - * timed exchange exchanges objects across two threads - */ - public void testTimedExchange() { - final Exchanger e = new Exchanger(); - Thread t1 = new Thread(new Runnable(){ - public void run(){ - try { - Object v = e.exchange(one, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - threadAssertEquals(v, two); - Object w = e.exchange(v, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - threadAssertEquals(w, one); - } catch(InterruptedException e){ - threadUnexpectedException(); - } catch(TimeoutException toe) { - threadUnexpectedException(); - } - } - }); - Thread t2 = new Thread(new Runnable(){ - public void run(){ - try { - Object v = e.exchange(two, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - threadAssertEquals(v, one); - Object w = e.exchange(v, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - threadAssertEquals(w, two); - } catch(InterruptedException e){ - threadUnexpectedException(); - } catch(TimeoutException toe) { - threadUnexpectedException(); - } - } - }); - try { - t1.start(); - t2.start(); - t1.join(); - t2.join(); - } catch(InterruptedException ex) { - unexpectedException(); - } - } - - /** - * interrupt during wait for exchange throws IE - */ - public void testExchange_InterruptedException(){ - final Exchanger e = new Exchanger(); - Thread t = new Thread(new Runnable() { - public void run(){ - try { - e.exchange(one); - threadShouldThrow(); - } catch(InterruptedException success){ - } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch(InterruptedException ex) { - unexpectedException(); - } - } - - /** - * interrupt during wait for timed exchange throws IE - */ - public void testTimedExchange_InterruptedException(){ - final Exchanger e = new Exchanger(); - Thread t = new Thread(new Runnable() { - public void run(){ - try { - e.exchange(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch(InterruptedException success){ - } catch(Exception e2){ - threadFail("should throw IE"); - } - } - }); - try { - t.start(); - t.interrupt(); - t.join(); - } catch(InterruptedException ex){ - unexpectedException(); - } - } - - /** - * timeout during wait for timed exchange throws TOE - */ - public void testExchange_TimeOutException(){ - final Exchanger e = new Exchanger(); - Thread t = new Thread(new Runnable() { - public void run(){ - try { - e.exchange(null, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch(TimeoutException success){ - } catch(InterruptedException e2){ - threadFail("should throw TOE"); - } - } - }); - try { - t.start(); - t.join(); - } catch(InterruptedException ex){ - unexpectedException(); - } - } - - /** - * If one exchanging thread is interrupted, another succeeds. - */ - public void testReplacementAfterExchange() { - final Exchanger e = new Exchanger(); - Thread t1 = new Thread(new Runnable(){ - public void run(){ - try { - Object v = e.exchange(one); - threadAssertEquals(v, two); - Object w = e.exchange(v); - threadShouldThrow(); - } catch(InterruptedException success){ - } - } - }); - Thread t2 = new Thread(new Runnable(){ - public void run(){ - try { - Object v = e.exchange(two); - threadAssertEquals(v, one); - Thread.sleep(SMALL_DELAY_MS); - Object w = e.exchange(v); - threadAssertEquals(w, three); - } catch(InterruptedException e){ - threadUnexpectedException(); - } - } - }); - Thread t3 = new Thread(new Runnable(){ - public void run(){ - try { - Thread.sleep(SMALL_DELAY_MS); - Object w = e.exchange(three); - threadAssertEquals(w, one); - } catch(InterruptedException e){ - threadUnexpectedException(); - } - } - }); - - try { - t1.start(); - t2.start(); - t3.start(); - Thread.sleep(SHORT_DELAY_MS); - t1.interrupt(); - t1.join(); - t2.join(); - t3.join(); - } catch(InterruptedException ex) { - unexpectedException(); - } - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ExecutorCompletionServiceTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ExecutorCompletionServiceTest.java deleted file mode 100644 index b1988cc5b..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ExecutorCompletionServiceTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; -import java.math.BigInteger; -import java.security.*; - -public class ExecutorCompletionServiceTest extends JSR166TestCase{ - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(ExecutorCompletionServiceTest.class); - } - - - /** - * Creating a new ECS with null Executor throw NPE - */ - public void testConstructorNPE() { - try { - ExecutorCompletionService ecs = new ExecutorCompletionService(null); - shouldThrow(); - } catch (NullPointerException success) { - } - } - - /** - * Creating a new ECS with null queue throw NPE - */ - public void testConstructorNPE2() { - try { - ExecutorService e = Executors.newCachedThreadPool(); - ExecutorCompletionService ecs = new ExecutorCompletionService(e, null); - shouldThrow(); - } catch (NullPointerException success) { - } - } - - /** - * Submitting a null callable throws NPE - */ - public void testSubmitNPE() { - ExecutorService e = Executors.newCachedThreadPool(); - ExecutorCompletionService ecs = new ExecutorCompletionService(e); - try { - Callable c = null; - ecs.submit(c); - shouldThrow(); - } catch (NullPointerException success) { - } finally { - joinPool(e); - } - } - - /** - * Submitting a null runnable throws NPE - */ - public void testSubmitNPE2() { - ExecutorService e = Executors.newCachedThreadPool(); - ExecutorCompletionService ecs = new ExecutorCompletionService(e); - try { - Runnable r = null; - ecs.submit(r, Boolean.TRUE); - shouldThrow(); - } catch (NullPointerException success) { - } finally { - joinPool(e); - } - } - - /** - * A taken submitted task is completed - */ - public void testTake() { - ExecutorService e = Executors.newCachedThreadPool(); - ExecutorCompletionService ecs = new ExecutorCompletionService(e); - try { - Callable c = new StringTask(); - ecs.submit(c); - Future f = ecs.take(); - assertTrue(f.isDone()); - } catch (Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * Take returns the same future object returned by submit - */ - public void testTake2() { - ExecutorService e = Executors.newCachedThreadPool(); - ExecutorCompletionService ecs = new ExecutorCompletionService(e); - try { - Callable c = new StringTask(); - Future f1 = ecs.submit(c); - Future f2 = ecs.take(); - assertSame(f1, f2); - } catch (Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * If poll returns non-null, the returned task is completed - */ - public void testPoll1() { - ExecutorService e = Executors.newCachedThreadPool(); - ExecutorCompletionService ecs = new ExecutorCompletionService(e); - try { - assertNull(ecs.poll()); - Callable c = new StringTask(); - ecs.submit(c); - Thread.sleep(SHORT_DELAY_MS); - for (;;) { - Future f = ecs.poll(); - if (f != null) { - assertTrue(f.isDone()); - break; - } - } - } catch (Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * If timed poll returns non-null, the returned task is completed - */ - public void testPoll2() { - ExecutorService e = Executors.newCachedThreadPool(); - ExecutorCompletionService ecs = new ExecutorCompletionService(e); - try { - assertNull(ecs.poll()); - Callable c = new StringTask(); - ecs.submit(c); - Future f = ecs.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - if (f != null) - assertTrue(f.isDone()); - } catch (Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ExecutorsTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ExecutorsTest.java deleted file mode 100755 index e8fc7e504..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ExecutorsTest.java +++ /dev/null @@ -1,666 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.math.BigInteger; -import java.security.*; - -public class ExecutorsTest extends JSR166TestCase{ - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(ExecutorsTest.class); - } - - static class TimedCallable implements Callable { - private final ExecutorService exec; - private final Callable func; - private final long msecs; - - TimedCallable(ExecutorService exec, Callable func, long msecs) { - this.exec = exec; - this.func = func; - this.msecs = msecs; - } - - public T call() throws Exception { - Future ftask = exec.submit(func); - try { - return ftask.get(msecs, TimeUnit.MILLISECONDS); - } finally { - ftask.cancel(true); - } - } - } - - - private static class Fib implements Callable { - private final BigInteger n; - Fib(long n) { - if (n < 0) throw new IllegalArgumentException("need non-negative arg, but got " + n); - this.n = BigInteger.valueOf(n); - } - public BigInteger call() { - BigInteger f1 = BigInteger.ONE; - BigInteger f2 = f1; - for (BigInteger i = BigInteger.ZERO; i.compareTo(n) < 0; i = i.add(BigInteger.ONE)) { - BigInteger t = f1.add(f2); - f1 = f2; - f2 = t; - } - return f1; - } - }; - - /** - * A newCachedThreadPool can execute runnables - */ - public void testNewCachedThreadPool1() { - ExecutorService e = Executors.newCachedThreadPool(); - e.execute(new NoOpRunnable()); - e.execute(new NoOpRunnable()); - e.execute(new NoOpRunnable()); - joinPool(e); - } - - /** - * A newCachedThreadPool with given ThreadFactory can execute runnables - */ - public void testNewCachedThreadPool2() { - ExecutorService e = Executors.newCachedThreadPool(new SimpleThreadFactory()); - e.execute(new NoOpRunnable()); - e.execute(new NoOpRunnable()); - e.execute(new NoOpRunnable()); - joinPool(e); - } - - /** - * A newCachedThreadPool with null ThreadFactory throws NPE - */ - public void testNewCachedThreadPool3() { - try { - ExecutorService e = Executors.newCachedThreadPool(null); - shouldThrow(); - } - catch(NullPointerException success) { - } - } - - - /** - * A new SingleThreadExecutor can execute runnables - */ - public void testNewSingleThreadExecutor1() { - ExecutorService e = Executors.newSingleThreadExecutor(); - e.execute(new NoOpRunnable()); - e.execute(new NoOpRunnable()); - e.execute(new NoOpRunnable()); - joinPool(e); - } - - /** - * A new SingleThreadExecutor with given ThreadFactory can execute runnables - */ - public void testNewSingleThreadExecutor2() { - ExecutorService e = Executors.newSingleThreadExecutor(new SimpleThreadFactory()); - e.execute(new NoOpRunnable()); - e.execute(new NoOpRunnable()); - e.execute(new NoOpRunnable()); - joinPool(e); - } - - /** - * A new SingleThreadExecutor with null ThreadFactory throws NPE - */ - public void testNewSingleThreadExecutor3() { - try { - ExecutorService e = Executors.newSingleThreadExecutor(null); - shouldThrow(); - } - catch(NullPointerException success) { - } - } - - /** - * A new SingleThreadExecutor cannot be casted to concrete implementation - */ - public void testCastNewSingleThreadExecutor() { - ExecutorService e = Executors.newSingleThreadExecutor(); - try { - ThreadPoolExecutor tpe = (ThreadPoolExecutor)e; - } catch (ClassCastException success) { - } finally { - joinPool(e); - } - } - - - /** - * A new newFixedThreadPool can execute runnables - */ - public void testNewFixedThreadPool1() { - ExecutorService e = Executors.newFixedThreadPool(2); - e.execute(new NoOpRunnable()); - e.execute(new NoOpRunnable()); - e.execute(new NoOpRunnable()); - joinPool(e); - } - - /** - * A new newFixedThreadPool with given ThreadFactory can execute runnables - */ - public void testNewFixedThreadPool2() { - ExecutorService e = Executors.newFixedThreadPool(2, new SimpleThreadFactory()); - e.execute(new NoOpRunnable()); - e.execute(new NoOpRunnable()); - e.execute(new NoOpRunnable()); - joinPool(e); - } - - /** - * A new newFixedThreadPool with null ThreadFactory throws NPE - */ - public void testNewFixedThreadPool3() { - try { - ExecutorService e = Executors.newFixedThreadPool(2, null); - shouldThrow(); - } - catch(NullPointerException success) { - } - } - - /** - * A new newFixedThreadPool with 0 threads throws IAE - */ - public void testNewFixedThreadPool4() { - try { - ExecutorService e = Executors.newFixedThreadPool(0); - shouldThrow(); - } - catch(IllegalArgumentException success) { - } - } - - - /** - * An unconfigurable newFixedThreadPool can execute runnables - */ - public void testunconfigurableExecutorService() { - ExecutorService e = Executors.unconfigurableExecutorService(Executors.newFixedThreadPool(2)); - e.execute(new NoOpRunnable()); - e.execute(new NoOpRunnable()); - e.execute(new NoOpRunnable()); - joinPool(e); - } - - /** - * unconfigurableExecutorService(null) throws NPE - */ - public void testunconfigurableExecutorServiceNPE() { - try { - ExecutorService e = Executors.unconfigurableExecutorService(null); - } - catch (NullPointerException success) { - } - } - - /** - * unconfigurableScheduledExecutorService(null) throws NPE - */ - public void testunconfigurableScheduledExecutorServiceNPE() { - try { - ExecutorService e = Executors.unconfigurableScheduledExecutorService(null); - } - catch (NullPointerException success) { - } - } - - - /** - * a newSingleThreadScheduledExecutor successfully runs delayed task - */ - public void testNewSingleThreadScheduledExecutor() { - try { - TrackedCallable callable = new TrackedCallable(); - ScheduledExecutorService p1 = Executors.newSingleThreadScheduledExecutor(); - Future f = p1.schedule(callable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - assertFalse(callable.done); - Thread.sleep(MEDIUM_DELAY_MS); - assertTrue(callable.done); - assertEquals(Boolean.TRUE, f.get()); - joinPool(p1); - } catch(RejectedExecutionException e){} - catch(Exception e){ - e.printStackTrace(); - unexpectedException(); - } - } - - /** - * a newScheduledThreadPool successfully runs delayed task - */ - public void testnewScheduledThreadPool() { - try { - TrackedCallable callable = new TrackedCallable(); - ScheduledExecutorService p1 = Executors.newScheduledThreadPool(2); - Future f = p1.schedule(callable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - assertFalse(callable.done); - Thread.sleep(MEDIUM_DELAY_MS); - assertTrue(callable.done); - assertEquals(Boolean.TRUE, f.get()); - joinPool(p1); - } catch(RejectedExecutionException e){} - catch(Exception e){ - e.printStackTrace(); - unexpectedException(); - } - } - - /** - * an unconfigurable newScheduledThreadPool successfully runs delayed task - */ - public void testunconfigurableScheduledExecutorService() { - try { - TrackedCallable callable = new TrackedCallable(); - ScheduledExecutorService p1 = Executors.unconfigurableScheduledExecutorService(Executors.newScheduledThreadPool(2)); - Future f = p1.schedule(callable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - assertFalse(callable.done); - Thread.sleep(MEDIUM_DELAY_MS); - assertTrue(callable.done); - assertEquals(Boolean.TRUE, f.get()); - joinPool(p1); - } catch(RejectedExecutionException e){} - catch(Exception e){ - e.printStackTrace(); - unexpectedException(); - } - } - - /** - * timeouts from execute will time out if they compute too long. - */ - public void testTimedCallable() { - int N = 10000; - ExecutorService executor = Executors.newSingleThreadExecutor(); - List> tasks = new ArrayList>(N); - try { - long startTime = System.currentTimeMillis(); - - long i = 0; - while (tasks.size() < N) { - tasks.add(new TimedCallable(executor, new Fib(i), 1)); - i += 10; - } - - int iters = 0; - BigInteger sum = BigInteger.ZERO; - for (Iterator> it = tasks.iterator(); it.hasNext();) { - try { - ++iters; - sum = sum.add(it.next().call()); - } - catch (TimeoutException success) { - assertTrue(iters > 0); - return; - } - catch (Exception e) { - unexpectedException(); - } - } - // if by chance we didn't ever time out, total time must be small - long elapsed = System.currentTimeMillis() - startTime; - assertTrue(elapsed < N); - } - finally { - joinPool(executor); - } - } - - - /** - * ThreadPoolExecutor using defaultThreadFactory has - * specified group, priority, daemon status, and name - */ - public void testDefaultThreadFactory() { - final ThreadGroup egroup = Thread.currentThread().getThreadGroup(); - Runnable r = new Runnable() { - public void run() { - try { - Thread current = Thread.currentThread(); - threadAssertTrue(!current.isDaemon()); - threadAssertTrue(current.getPriority() <= Thread.NORM_PRIORITY); - ThreadGroup g = current.getThreadGroup(); - SecurityManager s = System.getSecurityManager(); - if (s != null) - threadAssertTrue(g == s.getThreadGroup()); - else - threadAssertTrue(g == egroup); - String name = current.getName(); - threadAssertTrue(name.endsWith("thread-1")); - } catch (SecurityException ok) { - // Also pass if not allowed to change setting - } - } - }; - ExecutorService e = Executors.newSingleThreadExecutor(Executors.defaultThreadFactory()); - - e.execute(r); - try { - e.shutdown(); - } catch(SecurityException ok) { - } - - try { - Thread.sleep(SHORT_DELAY_MS); - } catch (Exception eX) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * ThreadPoolExecutor using privilegedThreadFactory has - * specified group, priority, daemon status, name, - * access control context and context class loader - */ - public void testPrivilegedThreadFactory() { - Policy savedPolicy = null; - try { - savedPolicy = Policy.getPolicy(); - AdjustablePolicy policy = new AdjustablePolicy(); - policy.addPermission(new RuntimePermission("getContextClassLoader")); - policy.addPermission(new RuntimePermission("setContextClassLoader")); - Policy.setPolicy(policy); - } catch (AccessControlException ok) { - return; - } - final ThreadGroup egroup = Thread.currentThread().getThreadGroup(); - final ClassLoader thisccl = Thread.currentThread().getContextClassLoader(); - final AccessControlContext thisacc = AccessController.getContext(); - Runnable r = new Runnable() { - public void run() { - try { - Thread current = Thread.currentThread(); - threadAssertTrue(!current.isDaemon()); - threadAssertTrue(current.getPriority() <= Thread.NORM_PRIORITY); - ThreadGroup g = current.getThreadGroup(); - SecurityManager s = System.getSecurityManager(); - if (s != null) - threadAssertTrue(g == s.getThreadGroup()); - else - threadAssertTrue(g == egroup); - String name = current.getName(); - threadAssertTrue(name.endsWith("thread-1")); - threadAssertTrue(thisccl == current.getContextClassLoader()); - threadAssertTrue(thisacc.equals(AccessController.getContext())); - } catch(SecurityException ok) { - // Also pass if not allowed to change settings - } - } - }; - ExecutorService e = Executors.newSingleThreadExecutor(Executors.privilegedThreadFactory()); - - Policy.setPolicy(savedPolicy); - e.execute(r); - try { - e.shutdown(); - } catch(SecurityException ok) { - } - try { - Thread.sleep(SHORT_DELAY_MS); - } catch (Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - - } - - void checkCCL() { - AccessController.getContext().checkPermission(new RuntimePermission("getContextClassLoader")); - } - - class CheckCCL implements Callable { - public Object call() { - checkCCL(); - return null; - } - } - - - /** - * Without class loader permissions, creating - * privilegedCallableUsingCurrentClassLoader throws ACE - */ - public void testCreatePrivilegedCallableUsingCCLWithNoPrivs() { - Policy savedPolicy = null; - try { - savedPolicy = Policy.getPolicy(); - AdjustablePolicy policy = new AdjustablePolicy(); - Policy.setPolicy(policy); - } catch (AccessControlException ok) { - return; - } - - // Check if program still has too many permissions to run test - try { - checkCCL(); - // too many privileges to test; so return - Policy.setPolicy(savedPolicy); - return; - } catch(AccessControlException ok) { - } - - try { - Callable task = Executors.privilegedCallableUsingCurrentClassLoader(new NoOpCallable()); - shouldThrow(); - } catch(AccessControlException success) { - } catch(Exception ex) { - unexpectedException(); - } - finally { - Policy.setPolicy(savedPolicy); - } - } - - /** - * With class loader permissions, calling - * privilegedCallableUsingCurrentClassLoader does not throw ACE - */ - public void testprivilegedCallableUsingCCLWithPrivs() { - Policy savedPolicy = null; - try { - savedPolicy = Policy.getPolicy(); - AdjustablePolicy policy = new AdjustablePolicy(); - policy.addPermission(new RuntimePermission("getContextClassLoader")); - policy.addPermission(new RuntimePermission("setContextClassLoader")); - Policy.setPolicy(policy); - } catch (AccessControlException ok) { - return; - } - - try { - Callable task = Executors.privilegedCallableUsingCurrentClassLoader(new NoOpCallable()); - task.call(); - } catch(Exception ex) { - unexpectedException(); - } - finally { - Policy.setPolicy(savedPolicy); - } - } - - /** - * Without permissions, calling privilegedCallable throws ACE - */ - public void testprivilegedCallableWithNoPrivs() { - Callable task; - Policy savedPolicy = null; - AdjustablePolicy policy = null; - AccessControlContext noprivAcc = null; - try { - savedPolicy = Policy.getPolicy(); - policy = new AdjustablePolicy(); - Policy.setPolicy(policy); - noprivAcc = AccessController.getContext(); - task = Executors.privilegedCallable(new CheckCCL()); - Policy.setPolicy(savedPolicy); - } catch (AccessControlException ok) { - return; // program has too few permissions to set up test - } - - // Make sure that program doesn't have too many permissions - try { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - checkCCL(); - return null; - }}, noprivAcc); - // too many permssions; skip test - return; - } catch(AccessControlException ok) { - } - - try { - task.call(); - shouldThrow(); - } catch(AccessControlException success) { - } catch(Exception ex) { - unexpectedException(); - } - } - - /** - * With permissions, calling privilegedCallable succeeds - */ - public void testprivilegedCallableWithPrivs() { - Policy savedPolicy = null; - try { - savedPolicy = Policy.getPolicy(); - AdjustablePolicy policy = new AdjustablePolicy(); - policy.addPermission(new RuntimePermission("getContextClassLoader")); - policy.addPermission(new RuntimePermission("setContextClassLoader")); - Policy.setPolicy(policy); - } catch (AccessControlException ok) { - return; - } - - Callable task = Executors.privilegedCallable(new CheckCCL()); - try { - task.call(); - } catch(Exception ex) { - unexpectedException(); - } finally { - Policy.setPolicy(savedPolicy); - } - } - - /** - * callable(Runnable) returns null when called - */ - public void testCallable1() { - try { - Callable c = Executors.callable(new NoOpRunnable()); - assertNull(c.call()); - } catch(Exception ex) { - unexpectedException(); - } - - } - - /** - * callable(Runnable, result) returns result when called - */ - public void testCallable2() { - try { - Callable c = Executors.callable(new NoOpRunnable(), one); - assertEquals(one, c.call()); - } catch(Exception ex) { - unexpectedException(); - } - } - - /** - * callable(PrivilegedAction) returns its result when called - */ - public void testCallable3() { - try { - Callable c = Executors.callable(new PrivilegedAction() { - public Object run() { return one; }}); - assertEquals(one, c.call()); - } catch(Exception ex) { - unexpectedException(); - } - } - - /** - * callable(PrivilegedExceptionAction) returns its result when called - */ - public void testCallable4() { - try { - Callable c = Executors.callable(new PrivilegedExceptionAction() { - public Object run() { return one; }}); - assertEquals(one, c.call()); - } catch(Exception ex) { - unexpectedException(); - } - } - - - /** - * callable(null Runnable) throws NPE - */ - public void testCallableNPE1() { - try { - Runnable r = null; - Callable c = Executors.callable(r); - } catch (NullPointerException success) { - } - } - - /** - * callable(null, result) throws NPE - */ - public void testCallableNPE2() { - try { - Runnable r = null; - Callable c = Executors.callable(r, one); - } catch (NullPointerException success) { - } - } - - /** - * callable(null PrivilegedAction) throws NPE - */ - public void testCallableNPE3() { - try { - PrivilegedAction r = null; - Callable c = Executors.callable(r); - } catch (NullPointerException success) { - } - } - - /** - * callable(null PrivilegedExceptionAction) throws NPE - */ - public void testCallableNPE4() { - try { - PrivilegedExceptionAction r = null; - Callable c = Executors.callable(r); - } catch (NullPointerException success) { - } - } - - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/FutureTaskTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/FutureTaskTest.java deleted file mode 100755 index 2108986fd..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/FutureTaskTest.java +++ /dev/null @@ -1,476 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.concurrent.*; -import java.util.*; - -public class FutureTaskTest extends JSR166TestCase { - - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(FutureTaskTest.class); - } - - /** - * Subclass to expose protected methods - */ - static class PublicFutureTask extends FutureTask { - public PublicFutureTask(Callable r) { super(r); } - public boolean runAndReset() { return super.runAndReset(); } - public void set(Object x) { super.set(x); } - public void setException(Throwable t) { super.setException(t); } - } - - /** - * Creating a future with a null callable throws NPE - */ - public void testConstructor() { - try { - FutureTask task = new FutureTask(null); - shouldThrow(); - } - catch(NullPointerException success) { - } - } - - /** - * creating a future with null runnable fails - */ - public void testConstructor2() { - try { - FutureTask task = new FutureTask(null, Boolean.TRUE); - shouldThrow(); - } - catch(NullPointerException success) { - } - } - - /** - * isDone is true when a task completes - */ - public void testIsDone() { - FutureTask task = new FutureTask( new NoOpCallable()); - task.run(); - assertTrue(task.isDone()); - assertFalse(task.isCancelled()); - } - - /** - * runAndReset of a non-cancelled task succeeds - */ - public void testRunAndReset() { - PublicFutureTask task = new PublicFutureTask(new NoOpCallable()); - assertTrue(task.runAndReset()); - assertFalse(task.isDone()); - } - - /** - * runAndReset after cancellation fails - */ - public void testResetAfterCancel() { - PublicFutureTask task = new PublicFutureTask(new NoOpCallable()); - assertTrue(task.cancel(false)); - assertFalse(task.runAndReset()); - assertTrue(task.isDone()); - assertTrue(task.isCancelled()); - } - - - - /** - * setting value causes get to return it - */ - public void testSet() { - PublicFutureTask task = new PublicFutureTask(new NoOpCallable()); - task.set(one); - try { - assertEquals(task.get(), one); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * setException causes get to throw ExecutionException - */ - public void testSetException() { - Exception nse = new NoSuchElementException(); - PublicFutureTask task = new PublicFutureTask(new NoOpCallable()); - task.setException(nse); - try { - Object x = task.get(); - shouldThrow(); - } - catch(ExecutionException ee) { - Throwable cause = ee.getCause(); - assertEquals(cause, nse); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * Cancelling before running succeeds - */ - public void testCancelBeforeRun() { - FutureTask task = new FutureTask( new NoOpCallable()); - assertTrue(task.cancel(false)); - task.run(); - assertTrue(task.isDone()); - assertTrue(task.isCancelled()); - } - - /** - * Cancel(true) before run succeeds - */ - public void testCancelBeforeRun2() { - FutureTask task = new FutureTask( new NoOpCallable()); - assertTrue(task.cancel(true)); - task.run(); - assertTrue(task.isDone()); - assertTrue(task.isCancelled()); - } - - /** - * cancel of a completed task fails - */ - public void testCancelAfterRun() { - FutureTask task = new FutureTask( new NoOpCallable()); - task.run(); - assertFalse(task.cancel(false)); - assertTrue(task.isDone()); - assertFalse(task.isCancelled()); - } - - /** - * cancel(true) interrupts a running task - */ - public void testCancelInterrupt() { - FutureTask task = new FutureTask( new Callable() { - public Object call() { - try { - Thread.sleep(MEDIUM_DELAY_MS); - threadShouldThrow(); - } - catch (InterruptedException success) {} - return Boolean.TRUE; - } }); - Thread t = new Thread(task); - t.start(); - - try { - Thread.sleep(SHORT_DELAY_MS); - assertTrue(task.cancel(true)); - t.join(); - assertTrue(task.isDone()); - assertTrue(task.isCancelled()); - } catch(InterruptedException e){ - unexpectedException(); - } - } - - - /** - * cancel(false) does not interrupt a running task - */ - public void testCancelNoInterrupt() { - FutureTask task = new FutureTask( new Callable() { - public Object call() { - try { - Thread.sleep(MEDIUM_DELAY_MS); - } - catch (InterruptedException success) { - threadFail("should not interrupt"); - } - return Boolean.TRUE; - } }); - Thread t = new Thread(task); - t.start(); - - try { - Thread.sleep(SHORT_DELAY_MS); - assertTrue(task.cancel(false)); - t.join(); - assertTrue(task.isDone()); - assertTrue(task.isCancelled()); - } catch(InterruptedException e){ - unexpectedException(); - } - } - - /** - * set in one thread causes get in another thread to retrieve value - */ - public void testGet1() { - final FutureTask ft = new FutureTask(new Callable() { - public Object call() { - try { - Thread.sleep(MEDIUM_DELAY_MS); - } catch(InterruptedException e){ - threadUnexpectedException(); - } - return Boolean.TRUE; - } - }); - Thread t = new Thread(new Runnable() { - public void run() { - try { - ft.get(); - } catch(Exception e){ - threadUnexpectedException(); - } - } - }); - try { - assertFalse(ft.isDone()); - assertFalse(ft.isCancelled()); - t.start(); - Thread.sleep(SHORT_DELAY_MS); - ft.run(); - t.join(); - assertTrue(ft.isDone()); - assertFalse(ft.isCancelled()); - } catch(InterruptedException e){ - unexpectedException(); - - } - } - - /** - * set in one thread causes timed get in another thread to retrieve value - */ - public void testTimedGet1() { - final FutureTask ft = new FutureTask(new Callable() { - public Object call() { - try { - Thread.sleep(MEDIUM_DELAY_MS); - } catch(InterruptedException e){ - threadUnexpectedException(); - } - return Boolean.TRUE; - } - }); - Thread t = new Thread(new Runnable() { - public void run() { - try { - ft.get(SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - } catch(TimeoutException success) { - } catch(Exception e){ - threadUnexpectedException(); - } - } - }); - try { - assertFalse(ft.isDone()); - assertFalse(ft.isCancelled()); - t.start(); - ft.run(); - t.join(); - assertTrue(ft.isDone()); - assertFalse(ft.isCancelled()); - } catch(InterruptedException e){ - unexpectedException(); - - } - } - - /** - * Cancelling a task causes timed get in another thread to throw CancellationException - */ - public void testTimedGet_Cancellation() { - final FutureTask ft = new FutureTask(new Callable() { - public Object call() { - try { - Thread.sleep(SMALL_DELAY_MS); - threadShouldThrow(); - } catch(InterruptedException e) { - } - return Boolean.TRUE; - } - }); - try { - Thread t1 = new Thread(new Runnable() { - public void run() { - try { - ft.get(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch(CancellationException success) {} - catch(Exception e){ - threadUnexpectedException(); - } - } - }); - Thread t2 = new Thread(ft); - t1.start(); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - ft.cancel(true); - t1.join(); - t2.join(); - } catch(InterruptedException ie){ - unexpectedException(); - } - } - - /** - * Cancelling a task causes get in another thread to throw CancellationException - */ - public void testGet_Cancellation() { - final FutureTask ft = new FutureTask(new Callable() { - public Object call() { - try { - Thread.sleep(MEDIUM_DELAY_MS); - threadShouldThrow(); - } catch(InterruptedException e){ - } - return Boolean.TRUE; - } - }); - try { - Thread t1 = new Thread(new Runnable() { - public void run() { - try { - ft.get(); - threadShouldThrow(); - } catch(CancellationException success){ - } - catch(Exception e){ - threadUnexpectedException(); - } - } - }); - Thread t2 = new Thread(ft); - t1.start(); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - ft.cancel(true); - t1.join(); - t2.join(); - } catch(InterruptedException success){ - unexpectedException(); - } - } - - - /** - * A runtime exception in task causes get to throw ExecutionException - */ - public void testGet_ExecutionException() { - final FutureTask ft = new FutureTask(new Callable() { - public Object call() { - int i = 5/0; - return Boolean.TRUE; - } - }); - try { - ft.run(); - ft.get(); - shouldThrow(); - } catch(ExecutionException success){ - } - catch(Exception e){ - unexpectedException(); - } - } - - /** - * A runtime exception in task causes timed get to throw ExecutionException - */ - public void testTimedGet_ExecutionException2() { - final FutureTask ft = new FutureTask(new Callable() { - public Object call() { - int i = 5/0; - return Boolean.TRUE; - } - }); - try { - ft.run(); - ft.get(SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - shouldThrow(); - } catch(ExecutionException success) { - } catch(TimeoutException success) { } // unlikely but OK - catch(Exception e){ - unexpectedException(); - } - } - - - /** - * Interrupting a waiting get causes it to throw InterruptedException - */ - public void testGet_InterruptedException() { - final FutureTask ft = new FutureTask(new NoOpCallable()); - Thread t = new Thread(new Runnable() { - public void run() { - try { - ft.get(); - threadShouldThrow(); - } catch(InterruptedException success){ - } catch(Exception e){ - threadUnexpectedException(); - } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * Interrupting a waiting timed get causes it to throw InterruptedException - */ - public void testTimedGet_InterruptedException2() { - final FutureTask ft = new FutureTask(new NoOpCallable()); - Thread t = new Thread(new Runnable() { - public void run() { - try { - ft.get(LONG_DELAY_MS,TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch(InterruptedException success){} - catch(Exception e){ - threadUnexpectedException(); - } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * A timed out timed get throws TimeoutException - */ - public void testGet_TimeoutException() { - try { - FutureTask ft = new FutureTask(new NoOpCallable()); - ft.get(1,TimeUnit.MILLISECONDS); - shouldThrow(); - } catch(TimeoutException success){} - catch(Exception success){ - unexpectedException(); - } - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/JSR166TestCase.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/JSR166TestCase.java deleted file mode 100644 index c900616e3..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/JSR166TestCase.java +++ /dev/null @@ -1,579 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.io.*; -import java.security.*; - -/** - * Base class for JSR166 Junit TCK tests. Defines some constants, - * utility methods and classes, as well as a simple framework for - * helping to make sure that assertions failing in generated threads - * cause the associated test that generated them to itself fail (which - * JUnit does not otherwise arrange). The rules for creating such - * tests are: - * - *
    - * - *
  1. All assertions in code running in generated threads must use - * the forms {@link #threadFail}, {@link #threadAssertTrue}, {@link - * #threadAssertEquals}, or {@link #threadAssertNull}, (not - * fail, assertTrue, etc.) It is OK (but not - * particularly recommended) for other code to use these forms too. - * Only the most typically used JUnit assertion methods are defined - * this way, but enough to live with.
  2. - * - *
  3. If you override {@link #setUp} or {@link #tearDown}, make sure - * to invoke super.setUp and super.tearDown within - * them. These methods are used to clear and check for thread - * assertion failures.
  4. - * - *
  5. All delays and timeouts must use one of the constants - * SHORT_DELAY_MS, SMALL_DELAY_MS, MEDIUM_DELAY_MS, - * LONG_DELAY_MS. The idea here is that a SHORT is always - * discriminable from zero time, and always allows enough time for the - * small amounts of computation (creating a thread, calling a few - * methods, etc) needed to reach a timeout point. Similarly, a SMALL - * is always discriminable as larger than SHORT and smaller than - * MEDIUM. And so on. These constants are set to conservative values, - * but even so, if there is ever any doubt, they can all be increased - * in one spot to rerun tests on slower platforms.
  6. - * - *
  7. All threads generated must be joined inside each test case - * method (or fail to do so) before returning from the - * method. The joinPool method can be used to do this when - * using Executors.
  8. - * - *
- * - *

Other notes - *

    - * - *
  • Usually, there is one testcase method per JSR166 method - * covering "normal" operation, and then as many exception-testing - * methods as there are exceptions the method can throw. Sometimes - * there are multiple tests per JSR166 method when the different - * "normal" behaviors differ significantly. And sometimes testcases - * cover multiple methods when they cannot be tested in - * isolation.
  • - * - *
  • The documentation style for testcases is to provide as javadoc - * a simple sentence or two describing the property that the testcase - * method purports to test. The javadocs do not say anything about how - * the property is tested. To find out, read the code.
  • - * - *
  • These tests are "conformance tests", and do not attempt to - * test throughput, latency, scalability or other performance factors - * (see the separate "jtreg" tests for a set intended to check these - * for the most central aspects of functionality.) So, most tests use - * the smallest sensible numbers of threads, collection sizes, etc - * needed to check basic conformance.
  • - * - *
  • The test classes currently do not declare inclusion in - * any particular package to simplify things for people integrating - * them in TCK test suites.
  • - * - *
  • As a convenience, the main of this class (JSR166TestCase) - * runs all JSR166 unit tests.
  • - * - *
- */ -public class JSR166TestCase extends TestCase { - /** - * Runs all JSR166 unit tests using junit.textui.TestRunner - */ - public static void main (String[] args) { - int iters = 1; - if (args.length > 0) - iters = Integer.parseInt(args[0]); - Test s = suite(); - for (int i = 0; i < iters; ++i) { - junit.textui.TestRunner.run (s); - System.gc(); - System.runFinalization(); - } - System.exit(0); - } - - /** - * Collects all JSR166 unit tests as one suite - */ - public static Test suite ( ) { - TestSuite suite = tests.TestSuiteFactory.createTestSuite("JSR166 Unit Tests"); - // BEGIN android-changed - suite.addTest(AbstractExecutorServiceTest.suite()); - suite.addTest(AbstractQueueTest.suite()); - suite.addTest(AbstractQueuedSynchronizerTest.suite()); - suite.addTest(ArrayBlockingQueueTest.suite()); - suite.addTest(AtomicBooleanTest.suite()); - suite.addTest(AtomicIntegerArrayTest.suite()); - suite.addTest(AtomicIntegerFieldUpdaterTest.suite()); - suite.addTest(AtomicIntegerTest.suite()); - suite.addTest(AtomicLongArrayTest.suite()); - suite.addTest(AtomicLongFieldUpdaterTest.suite()); - suite.addTest(AtomicLongTest.suite()); - suite.addTest(AtomicMarkableReferenceTest.suite()); - suite.addTest(AtomicReferenceArrayTest.suite()); - suite.addTest(AtomicReferenceFieldUpdaterTest.suite()); - suite.addTest(AtomicReferenceTest.suite()); - suite.addTest(AtomicStampedReferenceTest.suite()); - suite.addTest(ConcurrentHashMapTest.suite()); - suite.addTest(ConcurrentLinkedQueueTest.suite()); - suite.addTest(CopyOnWriteArrayListTest.suite()); - suite.addTest(CopyOnWriteArraySetTest.suite()); - suite.addTest(CountDownLatchTest.suite()); - suite.addTest(CyclicBarrierTest.suite()); - suite.addTest(DelayQueueTest.suite()); - suite.addTest(ExchangerTest.suite()); - suite.addTest(ExecutorsTest.suite()); - suite.addTest(ExecutorCompletionServiceTest.suite()); - suite.addTest(FutureTaskTest.suite()); - suite.addTest(LinkedBlockingQueueTest.suite()); - suite.addTest(LinkedListTest.suite()); - suite.addTest(LockSupportTest.suite()); - suite.addTest(PriorityBlockingQueueTest.suite()); - suite.addTest(PriorityQueueTest.suite()); - suite.addTest(ReentrantLockTest.suite()); - suite.addTest(ReentrantReadWriteLockTest.suite()); - suite.addTest(ScheduledExecutorTest.suite()); - suite.addTest(SemaphoreTest.suite()); - suite.addTest(SynchronousQueueTest.suite()); - suite.addTest(SystemTest.suite()); - suite.addTest(ThreadLocalTest.suite()); - suite.addTest(ThreadPoolExecutorTest.suite()); - suite.addTest(ThreadTest.suite()); - suite.addTest(TimeUnitTest.suite()); - // END android-changed - return suite; - } - - - public static long SHORT_DELAY_MS; - public static long SMALL_DELAY_MS; - public static long MEDIUM_DELAY_MS; - public static long LONG_DELAY_MS; - - - /** - * Returns the shortest timed delay. This could - * be reimplemented to use for example a Property. - */ - protected long getShortDelay() { - return 50; - } - - - /** - * Sets delays as multiples of SHORT_DELAY. - */ - protected void setDelays() { - SHORT_DELAY_MS = getShortDelay(); - SMALL_DELAY_MS = SHORT_DELAY_MS * 5; - MEDIUM_DELAY_MS = SHORT_DELAY_MS * 10; - LONG_DELAY_MS = SHORT_DELAY_MS * 50; - } - - /** - * Flag set true if any threadAssert methods fail - */ - volatile boolean threadFailed; - - /** - * Initializes test to indicate that no thread assertions have failed - */ - public void setUp() { - setDelays(); - threadFailed = false; - } - - /** - * Triggers test case failure if any thread assertions have failed - */ - public void tearDown() { - assertFalse(threadFailed); - } - - /** - * Fail, also setting status to indicate current testcase should fail - */ - public void threadFail(String reason) { - threadFailed = true; - fail(reason); - } - - /** - * If expression not true, set status to indicate current testcase - * should fail - */ - public void threadAssertTrue(boolean b) { - if (!b) { - threadFailed = true; - assertTrue(b); - } - } - - /** - * If expression not false, set status to indicate current testcase - * should fail - */ - public void threadAssertFalse(boolean b) { - if (b) { - threadFailed = true; - assertFalse(b); - } - } - - /** - * If argument not null, set status to indicate current testcase - * should fail - */ - public void threadAssertNull(Object x) { - if (x != null) { - threadFailed = true; - assertNull(x); - } - } - - /** - * If arguments not equal, set status to indicate current testcase - * should fail - */ - public void threadAssertEquals(long x, long y) { - if (x != y) { - threadFailed = true; - assertEquals(x, y); - } - } - - /** - * If arguments not equal, set status to indicate current testcase - * should fail - */ - public void threadAssertEquals(Object x, Object y) { - if (x != y && (x == null || !x.equals(y))) { - threadFailed = true; - assertEquals(x, y); - } - } - - /** - * threadFail with message "should throw exception" - */ - public void threadShouldThrow() { - try { - threadFailed = true; - fail("should throw exception"); - } catch (AssertionFailedError e) { - e.printStackTrace(); - throw e; - } - } - - /** - * threadFail with message "Unexpected exception" - */ - public void threadUnexpectedException() { - threadFailed = true; - fail("Unexpected exception"); - } - - /** - * threadFail with message "Unexpected exception", with argument - */ - public void threadUnexpectedException(Throwable ex) { - threadFailed = true; - ex.printStackTrace(); - fail("Unexpected exception: " + ex); - } - - /** - * Wait out termination of a thread pool or fail doing so - */ - public void joinPool(ExecutorService exec) { - try { - exec.shutdown(); - assertTrue(exec.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch(SecurityException ok) { - // Allowed in case test doesn't have privs - } catch(InterruptedException ie) { - fail("Unexpected exception"); - } - } - - - /** - * fail with message "should throw exception" - */ - public void shouldThrow() { - fail("Should throw exception"); - } - - /** - * fail with message "Unexpected exception" - */ - public void unexpectedException() { - fail("Unexpected exception"); - } - - - /** - * The number of elements to place in collections, arrays, etc. - */ - static final int SIZE = 20; - - // Some convenient Integer constants - - static final Integer zero = new Integer(0); - static final Integer one = new Integer(1); - static final Integer two = new Integer(2); - static final Integer three = new Integer(3); - static final Integer four = new Integer(4); - static final Integer five = new Integer(5); - static final Integer six = new Integer(6); - static final Integer seven = new Integer(7); - static final Integer eight = new Integer(8); - static final Integer nine = new Integer(9); - static final Integer m1 = new Integer(-1); - static final Integer m2 = new Integer(-2); - static final Integer m3 = new Integer(-3); - static final Integer m4 = new Integer(-4); - static final Integer m5 = new Integer(-5); - static final Integer m6 = new Integer(-6); - static final Integer m10 = new Integer(-10); - - - /** - * A security policy where new permissions can be dynamically added - * or all cleared. - */ - static class AdjustablePolicy extends java.security.Policy { - Permissions perms = new Permissions(); - AdjustablePolicy() { } - void addPermission(Permission perm) { perms.add(perm); } - void clearPermissions() { perms = new Permissions(); } - public PermissionCollection getPermissions(CodeSource cs) { - return perms; - } - public PermissionCollection getPermissions(ProtectionDomain pd) { - return perms; - } - public boolean implies(ProtectionDomain pd, Permission p) { - return perms.implies(p); - } - public void refresh() {} - } - - - // Some convenient Runnable classes - - static class NoOpRunnable implements Runnable { - public void run() {} - } - - static class NoOpCallable implements Callable { - public Object call() { return Boolean.TRUE; } - } - - static final String TEST_STRING = "a test string"; - - static class StringTask implements Callable { - public String call() { return TEST_STRING; } - } - - static class NPETask implements Callable { - public String call() { throw new NullPointerException(); } - } - - static class CallableOne implements Callable { - public Integer call() { return one; } - } - - class ShortRunnable implements Runnable { - public void run() { - try { - Thread.sleep(SHORT_DELAY_MS); - } - catch(Exception e) { - threadUnexpectedException(e); - } - } - } - - class ShortInterruptedRunnable implements Runnable { - public void run() { - try { - Thread.sleep(SHORT_DELAY_MS); - threadShouldThrow(); - } - catch(InterruptedException success) { - } - } - } - - class SmallRunnable implements Runnable { - public void run() { - try { - Thread.sleep(SMALL_DELAY_MS); - } - catch(Exception e) { - threadUnexpectedException(e); - } - } - } - - class SmallPossiblyInterruptedRunnable implements Runnable { - public void run() { - try { - Thread.sleep(SMALL_DELAY_MS); - } - catch(Exception e) { - } - } - } - - class SmallCallable implements Callable { - public Object call() { - try { - Thread.sleep(SMALL_DELAY_MS); - } - catch(Exception e) { - threadUnexpectedException(e); - } - return Boolean.TRUE; - } - } - - class SmallInterruptedRunnable implements Runnable { - public void run() { - try { - Thread.sleep(SMALL_DELAY_MS); - threadShouldThrow(); - } - catch(InterruptedException success) { - } - } - } - - - class MediumRunnable implements Runnable { - public void run() { - try { - Thread.sleep(MEDIUM_DELAY_MS); - } - catch(Exception e) { - threadUnexpectedException(e); - } - } - } - - class MediumInterruptedRunnable implements Runnable { - public void run() { - try { - Thread.sleep(MEDIUM_DELAY_MS); - threadShouldThrow(); - } - catch(InterruptedException success) { - } - } - } - - class MediumPossiblyInterruptedRunnable implements Runnable { - public void run() { - try { - Thread.sleep(MEDIUM_DELAY_MS); - } - catch(InterruptedException success) { - } - } - } - - class LongPossiblyInterruptedRunnable implements Runnable { - public void run() { - try { - Thread.sleep(LONG_DELAY_MS); - } - catch(InterruptedException success) { - } - } - } - - /** - * For use as ThreadFactory in constructors - */ - static class SimpleThreadFactory implements ThreadFactory{ - public Thread newThread(Runnable r){ - return new Thread(r); - } - } - - static class TrackedShortRunnable implements Runnable { - volatile boolean done = false; - public void run() { - try { - Thread.sleep(SMALL_DELAY_MS); - done = true; - } catch(Exception e){ - } - } - } - - static class TrackedMediumRunnable implements Runnable { - volatile boolean done = false; - public void run() { - try { - Thread.sleep(MEDIUM_DELAY_MS); - done = true; - } catch(Exception e){ - } - } - } - - static class TrackedLongRunnable implements Runnable { - volatile boolean done = false; - public void run() { - try { - Thread.sleep(LONG_DELAY_MS); - done = true; - } catch(Exception e){ - } - } - } - - static class TrackedNoOpRunnable implements Runnable { - volatile boolean done = false; - public void run() { - done = true; - } - } - - static class TrackedCallable implements Callable { - volatile boolean done = false; - public Object call() { - try { - Thread.sleep(SMALL_DELAY_MS); - done = true; - } catch(Exception e){ - } - return Boolean.TRUE; - } - } - - - /** - * For use as RejectedExecutionHandler in constructors - */ - static class NoOpREHandler implements RejectedExecutionHandler{ - public void rejectedExecution(Runnable r, ThreadPoolExecutor executor){} - } - - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/LinkedBlockingQueueTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/LinkedBlockingQueueTest.java deleted file mode 100755 index 6648afb7e..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/LinkedBlockingQueueTest.java +++ /dev/null @@ -1,1063 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.io.*; - -public class LinkedBlockingQueueTest extends JSR166TestCase { - - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - - public static Test suite() { - return new TestSuite(LinkedBlockingQueueTest.class); - } - - - /** - * Create a queue of given size containing consecutive - * Integers 0 ... n. - */ - private LinkedBlockingQueue populatedQueue(int n) { - LinkedBlockingQueue q = new LinkedBlockingQueue(n); - assertTrue(q.isEmpty()); - for(int i = 0; i < n; i++) - assertTrue(q.offer(new Integer(i))); - assertFalse(q.isEmpty()); - assertEquals(0, q.remainingCapacity()); - assertEquals(n, q.size()); - return q; - } - - /** - * A new queue has the indicated capacity, or Integer.MAX_VALUE if - * none given - */ - public void testConstructor1() { - assertEquals(SIZE, new LinkedBlockingQueue(SIZE).remainingCapacity()); - assertEquals(Integer.MAX_VALUE, new LinkedBlockingQueue().remainingCapacity()); - } - - /** - * Constructor throws IAE if capacity argument nonpositive - */ - public void testConstructor2() { - try { - LinkedBlockingQueue q = new LinkedBlockingQueue(0); - shouldThrow(); - } - catch (IllegalArgumentException success) {} - } - - /** - * Initializing from null Collection throws NPE - */ - public void testConstructor3() { - try { - LinkedBlockingQueue q = new LinkedBlockingQueue(null); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Initializing from Collection of null elements throws NPE - */ - public void testConstructor4() { - try { - Integer[] ints = new Integer[SIZE]; - LinkedBlockingQueue q = new LinkedBlockingQueue(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Initializing from Collection with some null elements throws NPE - */ - public void testConstructor5() { - try { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new Integer(i); - LinkedBlockingQueue q = new LinkedBlockingQueue(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Queue contains all elements of collection used to initialize - */ - public void testConstructor6() { - try { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - LinkedBlockingQueue q = new LinkedBlockingQueue(Arrays.asList(ints)); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); - } - finally {} - } - - /** - * Queue transitions from empty to full when elements added - */ - public void testEmptyFull() { - LinkedBlockingQueue q = new LinkedBlockingQueue(2); - assertTrue(q.isEmpty()); - assertEquals("should have room for 2", 2, q.remainingCapacity()); - q.add(one); - assertFalse(q.isEmpty()); - q.add(two); - assertFalse(q.isEmpty()); - assertEquals(0, q.remainingCapacity()); - assertFalse(q.offer(three)); - } - - /** - * remainingCapacity decreases on add, increases on remove - */ - public void testRemainingCapacity() { - LinkedBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.remainingCapacity()); - assertEquals(SIZE-i, q.size()); - q.remove(); - } - for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE-i, q.remainingCapacity()); - assertEquals(i, q.size()); - q.add(new Integer(i)); - } - } - - /** - * offer(null) throws NPE - */ - public void testOfferNull() { - try { - LinkedBlockingQueue q = new LinkedBlockingQueue(1); - q.offer(null); - shouldThrow(); - } catch (NullPointerException success) { } - } - - /** - * add(null) throws NPE - */ - public void testAddNull() { - try { - LinkedBlockingQueue q = new LinkedBlockingQueue(1); - q.add(null); - shouldThrow(); - } catch (NullPointerException success) { } - } - - /** - * Offer succeeds if not full; fails if full - */ - public void testOffer() { - LinkedBlockingQueue q = new LinkedBlockingQueue(1); - assertTrue(q.offer(zero)); - assertFalse(q.offer(one)); - } - - /** - * add succeeds if not full; throws ISE if full - */ - public void testAdd() { - try { - LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertTrue(q.add(new Integer(i))); - } - assertEquals(0, q.remainingCapacity()); - q.add(new Integer(SIZE)); - } catch (IllegalStateException success){ - } - } - - /** - * addAll(null) throws NPE - */ - public void testAddAll1() { - try { - LinkedBlockingQueue q = new LinkedBlockingQueue(1); - q.addAll(null); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * addAll(this) throws IAE - */ - public void testAddAllSelf() { - try { - LinkedBlockingQueue q = populatedQueue(SIZE); - q.addAll(q); - shouldThrow(); - } - catch (IllegalArgumentException success) {} - } - - /** - * addAll of a collection with null elements throws NPE - */ - public void testAddAll2() { - try { - LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - /** - * addAll of a collection with any null elements throws NPE after - * possibly adding some elements - */ - public void testAddAll3() { - try { - LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new Integer(i); - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - /** - * addAll throws ISE if not enough room - */ - public void testAddAll4() { - try { - LinkedBlockingQueue q = new LinkedBlockingQueue(1); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } - catch (IllegalStateException success) {} - } - /** - * Queue contains all elements, in traversal order, of successful addAll - */ - public void testAddAll5() { - try { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE); - assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); - } - finally {} - } - - /** - * put(null) throws NPE - */ - public void testPutNull() { - try { - LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE); - q.put(null); - shouldThrow(); - } - catch (NullPointerException success){ - } - catch (InterruptedException ie) { - unexpectedException(); - } - } - - /** - * all elements successfully put are contained - */ - public void testPut() { - try { - LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - Integer I = new Integer(i); - q.put(I); - assertTrue(q.contains(I)); - } - assertEquals(0, q.remainingCapacity()); - } - catch (InterruptedException ie) { - unexpectedException(); - } - } - - /** - * put blocks interruptibly if full - */ - public void testBlockingPut() { - Thread t = new Thread(new Runnable() { - public void run() { - int added = 0; - try { - LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - q.put(new Integer(i)); - ++added; - } - q.put(new Integer(SIZE)); - threadShouldThrow(); - } catch (InterruptedException ie){ - threadAssertEquals(added, SIZE); - } - }}); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } - catch (InterruptedException ie) { - unexpectedException(); - } - } - - /** - * put blocks waiting for take when full - */ - public void testPutWithTake() { - final LinkedBlockingQueue q = new LinkedBlockingQueue(2); - Thread t = new Thread(new Runnable() { - public void run() { - int added = 0; - try { - q.put(new Object()); - ++added; - q.put(new Object()); - ++added; - q.put(new Object()); - ++added; - q.put(new Object()); - ++added; - threadShouldThrow(); - } catch (InterruptedException e){ - threadAssertTrue(added >= 2); - } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - q.take(); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - /** - * timed offer times out if full and elements not taken - */ - public void testTimedOffer() { - final LinkedBlockingQueue q = new LinkedBlockingQueue(2); - Thread t = new Thread(new Runnable() { - public void run() { - try { - q.put(new Object()); - q.put(new Object()); - threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - q.offer(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch (InterruptedException success){} - } - }); - - try { - t.start(); - Thread.sleep(SMALL_DELAY_MS); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - /** - * take retrieves elements in FIFO order - */ - public void testTake() { - try { - LinkedBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.take()).intValue()); - } - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * take blocks interruptibly when empty - */ - public void testTakeFromEmpty() { - final LinkedBlockingQueue q = new LinkedBlockingQueue(2); - Thread t = new Thread(new Runnable() { - public void run() { - try { - q.take(); - threadShouldThrow(); - } catch (InterruptedException success){ } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - /** - * Take removes existing elements until empty, then blocks interruptibly - */ - public void testBlockingTake() { - Thread t = new Thread(new Runnable() { - public void run() { - try { - LinkedBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.take()).intValue()); - } - q.take(); - threadShouldThrow(); - } catch (InterruptedException success){ - } - }}); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } - catch (InterruptedException ie) { - unexpectedException(); - } - } - - - /** - * poll succeeds unless empty - */ - public void testPoll() { - LinkedBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.poll()).intValue()); - } - assertNull(q.poll()); - } - - /** - * timed pool with zero timeout succeeds when non-empty, else times out - */ - public void testTimedPoll0() { - try { - LinkedBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.poll(0, TimeUnit.MILLISECONDS)).intValue()); - } - assertNull(q.poll(0, TimeUnit.MILLISECONDS)); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * timed pool with nonzero timeout succeeds when non-empty, else times out - */ - public void testTimedPoll() { - try { - LinkedBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); - } - assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * Interrupted timed poll throws InterruptedException instead of - * returning timeout status - */ - public void testInterruptedTimedPoll() { - Thread t = new Thread(new Runnable() { - public void run() { - try { - LinkedBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - threadAssertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); - } - threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch (InterruptedException success){ - } - }}); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } - catch (InterruptedException ie) { - unexpectedException(); - } - } - - /** - * timed poll before a delayed offer fails; after offer succeeds; - * on interruption throws - */ - public void testTimedPollWithOffer() { - final LinkedBlockingQueue q = new LinkedBlockingQueue(2); - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch (InterruptedException success) { } - } - }); - try { - t.start(); - Thread.sleep(SMALL_DELAY_MS); - assertTrue(q.offer(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - /** - * peek returns next element, or null if empty - */ - public void testPeek() { - LinkedBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.peek()).intValue()); - q.poll(); - assertTrue(q.peek() == null || - i != ((Integer)q.peek()).intValue()); - } - assertNull(q.peek()); - } - - /** - * element returns next element, or throws NSEE if empty - */ - public void testElement() { - LinkedBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.element()).intValue()); - q.poll(); - } - try { - q.element(); - shouldThrow(); - } - catch (NoSuchElementException success) {} - } - - /** - * remove removes next element, or throws NSEE if empty - */ - public void testRemove() { - LinkedBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.remove()).intValue()); - } - try { - q.remove(); - shouldThrow(); - } catch (NoSuchElementException success){ - } - } - - /** - * remove(x) removes x and returns true if present - */ - public void testRemoveElement() { - LinkedBlockingQueue q = populatedQueue(SIZE); - for (int i = 1; i < SIZE; i+=2) { - assertTrue(q.remove(new Integer(i))); - } - for (int i = 0; i < SIZE; i+=2) { - assertTrue(q.remove(new Integer(i))); - assertFalse(q.remove(new Integer(i+1))); - } - assertTrue(q.isEmpty()); - } - - /** - * An add following remove(x) succeeds - */ - public void testRemoveElementAndAdd() { - try { - LinkedBlockingQueue q = new LinkedBlockingQueue(); - assertTrue(q.add(new Integer(1))); - assertTrue(q.add(new Integer(2))); - assertTrue(q.remove(new Integer(1))); - assertTrue(q.remove(new Integer(2))); - assertTrue(q.add(new Integer(3))); - assertTrue(q.take() != null); - } catch (Exception e){ - unexpectedException(); - } - } - - /** - * contains(x) reports true when elements added but not yet removed - */ - public void testContains() { - LinkedBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); - q.poll(); - assertFalse(q.contains(new Integer(i))); - } - } - - /** - * clear removes all elements - */ - public void testClear() { - LinkedBlockingQueue q = populatedQueue(SIZE); - q.clear(); - assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - assertEquals(SIZE, q.remainingCapacity()); - q.add(one); - assertFalse(q.isEmpty()); - assertTrue(q.contains(one)); - q.clear(); - assertTrue(q.isEmpty()); - } - - /** - * containsAll(c) is true when c contains a subset of elements - */ - public void testContainsAll() { - LinkedBlockingQueue q = populatedQueue(SIZE); - LinkedBlockingQueue p = new LinkedBlockingQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertTrue(q.containsAll(p)); - assertFalse(p.containsAll(q)); - p.add(new Integer(i)); - } - assertTrue(p.containsAll(q)); - } - - /** - * retainAll(c) retains only those elements of c and reports true if changed - */ - public void testRetainAll() { - LinkedBlockingQueue q = populatedQueue(SIZE); - LinkedBlockingQueue p = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - boolean changed = q.retainAll(p); - if (i == 0) - assertFalse(changed); - else - assertTrue(changed); - - assertTrue(q.containsAll(p)); - assertEquals(SIZE-i, q.size()); - p.remove(); - } - } - - /** - * removeAll(c) removes only those elements of c and reports true if changed - */ - public void testRemoveAll() { - for (int i = 1; i < SIZE; ++i) { - LinkedBlockingQueue q = populatedQueue(SIZE); - LinkedBlockingQueue p = populatedQueue(i); - assertTrue(q.removeAll(p)); - assertEquals(SIZE-i, q.size()); - for (int j = 0; j < i; ++j) { - Integer I = (Integer)(p.remove()); - assertFalse(q.contains(I)); - } - } - } - - /** - * toArray contains all elements - */ - public void testToArray() { - LinkedBlockingQueue q = populatedQueue(SIZE); - Object[] o = q.toArray(); - try { - for(int i = 0; i < o.length; i++) - assertEquals(o[i], q.take()); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * toArray(a) contains all elements - */ - public void testToArray2() { - LinkedBlockingQueue q = populatedQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - ints = (Integer[])q.toArray(ints); - try { - for(int i = 0; i < ints.length; i++) - assertEquals(ints[i], q.take()); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * toArray(null) throws NPE - */ - public void testToArray_BadArg() { - try { - LinkedBlockingQueue q = populatedQueue(SIZE); - Object o[] = q.toArray(null); - shouldThrow(); - } catch(NullPointerException success){} - } - - /** - * toArray with incompatible array type throws CCE - */ - public void testToArray1_BadArg() { - try { - LinkedBlockingQueue q = populatedQueue(SIZE); - Object o[] = q.toArray(new String[10] ); - shouldThrow(); - } catch(ArrayStoreException success){} - } - - - /** - * iterator iterates through all elements - */ - public void testIterator() { - LinkedBlockingQueue q = populatedQueue(SIZE); - Iterator it = q.iterator(); - try { - while(it.hasNext()){ - assertEquals(it.next(), q.take()); - } - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * iterator.remove removes current element - */ - public void testIteratorRemove () { - final LinkedBlockingQueue q = new LinkedBlockingQueue(3); - q.add(two); - q.add(one); - q.add(three); - - Iterator it = q.iterator(); - it.next(); - it.remove(); - - it = q.iterator(); - assertEquals(it.next(), one); - assertEquals(it.next(), three); - assertFalse(it.hasNext()); - } - - - /** - * iterator ordering is FIFO - */ - public void testIteratorOrdering() { - final LinkedBlockingQueue q = new LinkedBlockingQueue(3); - q.add(one); - q.add(two); - q.add(three); - assertEquals(0, q.remainingCapacity()); - int k = 0; - for (Iterator it = q.iterator(); it.hasNext();) { - int i = ((Integer)(it.next())).intValue(); - assertEquals(++k, i); - } - assertEquals(3, k); - } - - /** - * Modifications do not cause iterators to fail - */ - public void testWeaklyConsistentIteration () { - final LinkedBlockingQueue q = new LinkedBlockingQueue(3); - q.add(one); - q.add(two); - q.add(three); - try { - for (Iterator it = q.iterator(); it.hasNext();) { - q.remove(); - it.next(); - } - } - catch (ConcurrentModificationException e) { - unexpectedException(); - } - assertEquals(0, q.size()); - } - - - /** - * toString contains toStrings of elements - */ - public void testToString() { - LinkedBlockingQueue q = populatedQueue(SIZE); - String s = q.toString(); - for (int i = 0; i < SIZE; ++i) { - assertTrue(s.indexOf(String.valueOf(i)) >= 0); - } - } - - - /** - * offer transfers elements across Executor tasks - */ - public void testOfferInExecutor() { - final LinkedBlockingQueue q = new LinkedBlockingQueue(2); - q.add(one); - q.add(two); - ExecutorService executor = Executors.newFixedThreadPool(2); - executor.execute(new Runnable() { - public void run() { - threadAssertFalse(q.offer(three)); - try { - threadAssertTrue(q.offer(three, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS)); - threadAssertEquals(0, q.remainingCapacity()); - } - catch (InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - executor.execute(new Runnable() { - public void run() { - try { - Thread.sleep(SMALL_DELAY_MS); - threadAssertEquals(one, q.take()); - } - catch (InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - joinPool(executor); - } - - /** - * poll retrieves elements across Executor threads - */ - public void testPollInExecutor() { - final LinkedBlockingQueue q = new LinkedBlockingQueue(2); - ExecutorService executor = Executors.newFixedThreadPool(2); - executor.execute(new Runnable() { - public void run() { - threadAssertNull(q.poll()); - try { - threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS)); - threadAssertTrue(q.isEmpty()); - } - catch (InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - executor.execute(new Runnable() { - public void run() { - try { - Thread.sleep(SMALL_DELAY_MS); - q.put(one); - } - catch (InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - joinPool(executor); - } - - /** - * A deserialized serialized queue has same elements in same order - */ - public void testSerialization() { - LinkedBlockingQueue q = populatedQueue(SIZE); - - try { - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(q); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - LinkedBlockingQueue r = (LinkedBlockingQueue)in.readObject(); - assertEquals(q.size(), r.size()); - while (!q.isEmpty()) - assertEquals(q.remove(), r.remove()); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * drainTo(null) throws NPE - */ - public void testDrainToNull() { - LinkedBlockingQueue q = populatedQueue(SIZE); - try { - q.drainTo(null); - shouldThrow(); - } catch(NullPointerException success) { - } - } - - /** - * drainTo(this) throws IAE - */ - public void testDrainToSelf() { - LinkedBlockingQueue q = populatedQueue(SIZE); - try { - q.drainTo(q); - shouldThrow(); - } catch(IllegalArgumentException success) { - } - } - - /** - * drainTo(c) empties queue into another collection c - */ - public void testDrainTo() { - LinkedBlockingQueue q = populatedQueue(SIZE); - ArrayList l = new ArrayList(); - q.drainTo(l); - assertEquals(q.size(), 0); - assertEquals(l.size(), SIZE); - for (int i = 0; i < SIZE; ++i) - assertEquals(l.get(i), new Integer(i)); - q.add(zero); - q.add(one); - assertFalse(q.isEmpty()); - assertTrue(q.contains(zero)); - assertTrue(q.contains(one)); - l.clear(); - q.drainTo(l); - assertEquals(q.size(), 0); - assertEquals(l.size(), 2); - for (int i = 0; i < 2; ++i) - assertEquals(l.get(i), new Integer(i)); - } - - /** - * drainTo empties full queue, unblocking a waiting put. - */ - public void testDrainToWithActivePut() { - final LinkedBlockingQueue q = populatedQueue(SIZE); - Thread t = new Thread(new Runnable() { - public void run() { - try { - q.put(new Integer(SIZE+1)); - } catch (InterruptedException ie){ - threadUnexpectedException(); - } - } - }); - try { - t.start(); - ArrayList l = new ArrayList(); - q.drainTo(l); - assertTrue(l.size() >= SIZE); - for (int i = 0; i < SIZE; ++i) - assertEquals(l.get(i), new Integer(i)); - t.join(); - assertTrue(q.size() + l.size() >= SIZE); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * drainTo(null, n) throws NPE - */ - public void testDrainToNullN() { - LinkedBlockingQueue q = populatedQueue(SIZE); - try { - q.drainTo(null, 0); - shouldThrow(); - } catch(NullPointerException success) { - } - } - - /** - * drainTo(this, n) throws IAE - */ - public void testDrainToSelfN() { - LinkedBlockingQueue q = populatedQueue(SIZE); - try { - q.drainTo(q, 0); - shouldThrow(); - } catch(IllegalArgumentException success) { - } - } - - /** - * drainTo(c, n) empties first max {n, size} elements of queue into c - */ - public void testDrainToN() { - LinkedBlockingQueue q = new LinkedBlockingQueue(); - for (int i = 0; i < SIZE + 2; ++i) { - for(int j = 0; j < SIZE; j++) - assertTrue(q.offer(new Integer(j))); - ArrayList l = new ArrayList(); - q.drainTo(l, i); - int k = (i < SIZE)? i : SIZE; - assertEquals(l.size(), k); - assertEquals(q.size(), SIZE-k); - for (int j = 0; j < k; ++j) - assertEquals(l.get(j), new Integer(j)); - while (q.poll() != null) ; - } - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/LinkedListTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/LinkedListTest.java deleted file mode 100755 index 3a2020713..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/LinkedListTest.java +++ /dev/null @@ -1,453 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; - -public class LinkedListTest extends JSR166TestCase { - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - - public static Test suite() { - return new TestSuite(LinkedListTest.class); - } - - /** - * Create a queue of given size containing consecutive - * Integers 0 ... n. - */ - private LinkedList populatedQueue(int n) { - LinkedList q = new LinkedList(); - assertTrue(q.isEmpty()); - for(int i = 0; i < n; ++i) - assertTrue(q.offer(new Integer(i))); - assertFalse(q.isEmpty()); - assertEquals(n, q.size()); - return q; - } - - /** - * new queue is empty - */ - public void testConstructor1() { - assertEquals(0, new LinkedList().size()); - } - - /** - * Initializing from null Collection throws NPE - */ - public void testConstructor3() { - try { - LinkedList q = new LinkedList((Collection)null); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Queue contains all elements of collection used to initialize - - */ - public void testConstructor6() { - try { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - LinkedList q = new LinkedList(Arrays.asList(ints)); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); - } - finally {} - } - - /** - * isEmpty is true before add, false after - */ - public void testEmpty() { - LinkedList q = new LinkedList(); - assertTrue(q.isEmpty()); - q.add(new Integer(1)); - assertFalse(q.isEmpty()); - q.add(new Integer(2)); - q.remove(); - q.remove(); - assertTrue(q.isEmpty()); - } - - /** - * size changes when elements added and removed - */ - public void testSize() { - LinkedList q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE-i, q.size()); - q.remove(); - } - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - q.add(new Integer(i)); - } - } - - /** - * offer(null) succeeds - */ - public void testOfferNull() { - try { - LinkedList q = new LinkedList(); - q.offer(null); - } catch (NullPointerException ie) { - unexpectedException(); - } - } - - /** - * Offer succeeds - */ - public void testOffer() { - LinkedList q = new LinkedList(); - assertTrue(q.offer(new Integer(0))); - assertTrue(q.offer(new Integer(1))); - } - - /** - * add succeeds - */ - public void testAdd() { - LinkedList q = new LinkedList(); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - assertTrue(q.add(new Integer(i))); - } - } - - /** - * addAll(null) throws NPE - */ - public void testAddAll1() { - try { - LinkedList q = new LinkedList(); - q.addAll(null); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Queue contains all elements, in traversal order, of successful addAll - */ - public void testAddAll5() { - try { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - LinkedList q = new LinkedList(); - assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); - } - finally {} - } - - /** - * addAll with too large an index throws IOOBE - */ - public void testAddAll2_IndexOutOfBoundsException() { - try { - LinkedList l = new LinkedList(); - l.add(new Object()); - LinkedList m = new LinkedList(); - m.add(new Object()); - l.addAll(4,m); - shouldThrow(); - } catch(IndexOutOfBoundsException success) {} - } - - /** - * addAll with negative index throws IOOBE - */ - public void testAddAll4_BadIndex() { - try { - LinkedList l = new LinkedList(); - l.add(new Object()); - LinkedList m = new LinkedList(); - m.add(new Object()); - l.addAll(-1,m); - shouldThrow(); - } catch(IndexOutOfBoundsException success){} - } - - /** - * poll succeeds unless empty - */ - public void testPoll() { - LinkedList q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.poll()).intValue()); - } - assertNull(q.poll()); - } - - /** - * peek returns next element, or null if empty - */ - public void testPeek() { - LinkedList q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.peek()).intValue()); - q.poll(); - assertTrue(q.peek() == null || - i != ((Integer)q.peek()).intValue()); - } - assertNull(q.peek()); - } - - /** - * element returns next element, or throws NSEE if empty - */ - public void testElement() { - LinkedList q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.element()).intValue()); - q.poll(); - } - try { - q.element(); - shouldThrow(); - } - catch (NoSuchElementException success) {} - } - - /** - * remove removes next element, or throws NSEE if empty - */ - public void testRemove() { - LinkedList q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.remove()).intValue()); - } - try { - q.remove(); - shouldThrow(); - } catch (NoSuchElementException success){ - } - } - - /** - * remove(x) removes x and returns true if present - */ - public void testRemoveElement() { - LinkedList q = populatedQueue(SIZE); - for (int i = 1; i < SIZE; i+=2) { - assertTrue(q.remove(new Integer(i))); - } - for (int i = 0; i < SIZE; i+=2) { - assertTrue(q.remove(new Integer(i))); - assertFalse(q.remove(new Integer(i+1))); - } - assertTrue(q.isEmpty()); - } - - /** - * contains(x) reports true when elements added but not yet removed - */ - public void testContains() { - LinkedList q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); - q.poll(); - assertFalse(q.contains(new Integer(i))); - } - } - - /** - * clear removes all elements - */ - public void testClear() { - LinkedList q = populatedQueue(SIZE); - q.clear(); - assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - q.add(new Integer(1)); - assertFalse(q.isEmpty()); - q.clear(); - assertTrue(q.isEmpty()); - } - - /** - * containsAll(c) is true when c contains a subset of elements - */ - public void testContainsAll() { - LinkedList q = populatedQueue(SIZE); - LinkedList p = new LinkedList(); - for (int i = 0; i < SIZE; ++i) { - assertTrue(q.containsAll(p)); - assertFalse(p.containsAll(q)); - p.add(new Integer(i)); - } - assertTrue(p.containsAll(q)); - } - - /** - * retainAll(c) retains only those elements of c and reports true if changed - */ - public void testRetainAll() { - LinkedList q = populatedQueue(SIZE); - LinkedList p = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - boolean changed = q.retainAll(p); - if (i == 0) - assertFalse(changed); - else - assertTrue(changed); - - assertTrue(q.containsAll(p)); - assertEquals(SIZE-i, q.size()); - p.remove(); - } - } - - /** - * removeAll(c) removes only those elements of c and reports true if changed - */ - public void testRemoveAll() { - for (int i = 1; i < SIZE; ++i) { - LinkedList q = populatedQueue(SIZE); - LinkedList p = populatedQueue(i); - assertTrue(q.removeAll(p)); - assertEquals(SIZE-i, q.size()); - for (int j = 0; j < i; ++j) { - Integer I = (Integer)(p.remove()); - assertFalse(q.contains(I)); - } - } - } - - /** - * toArray contains all elements - */ - public void testToArray() { - LinkedList q = populatedQueue(SIZE); - Object[] o = q.toArray(); - Arrays.sort(o); - for(int i = 0; i < o.length; i++) - assertEquals(o[i], q.poll()); - } - - /** - * toArray(a) contains all elements - */ - public void testToArray2() { - LinkedList q = populatedQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - ints = (Integer[])q.toArray(ints); - Arrays.sort(ints); - for(int i = 0; i < ints.length; i++) - assertEquals(ints[i], q.poll()); - } - - /** - * toArray(null) throws NPE - */ - public void testToArray_BadArg() { - try { - LinkedList l = new LinkedList(); - l.add(new Object()); - Object o[] = l.toArray(null); - shouldThrow(); - } catch(NullPointerException success){} - } - - /** - * toArray with incompatable aray type throws CCE - */ - public void testToArray1_BadArg() { - try { - LinkedList l = new LinkedList(); - l.add(new Integer(5)); - Object o[] = l.toArray(new String[10] ); - shouldThrow(); - } catch(ArrayStoreException success){} - } - - /** - * iterator iterates through all elements - */ - public void testIterator() { - LinkedList q = populatedQueue(SIZE); - int i = 0; - Iterator it = q.iterator(); - while(it.hasNext()) { - assertTrue(q.contains(it.next())); - ++i; - } - assertEquals(i, SIZE); - } - - /** - * iterator ordering is FIFO - */ - public void testIteratorOrdering() { - final LinkedList q = new LinkedList(); - q.add(new Integer(1)); - q.add(new Integer(2)); - q.add(new Integer(3)); - int k = 0; - for (Iterator it = q.iterator(); it.hasNext();) { - int i = ((Integer)(it.next())).intValue(); - assertEquals(++k, i); - } - - assertEquals(3, k); - } - - /** - * iterator.remove removes current element - */ - public void testIteratorRemove () { - final LinkedList q = new LinkedList(); - q.add(new Integer(1)); - q.add(new Integer(2)); - q.add(new Integer(3)); - Iterator it = q.iterator(); - it.next(); - it.remove(); - it = q.iterator(); - assertEquals(it.next(), new Integer(2)); - assertEquals(it.next(), new Integer(3)); - assertFalse(it.hasNext()); - } - - - /** - * toString contains toStrings of elements - */ - public void testToString() { - LinkedList q = populatedQueue(SIZE); - String s = q.toString(); - for (int i = 0; i < SIZE; ++i) { - assertTrue(s.indexOf(String.valueOf(i)) >= 0); - } - } - - /** - * peek returns element inserted with addFirst - */ - public void testAddFirst() { - LinkedList q = populatedQueue(3); - q.addFirst(four); - assertEquals(four,q.peek()); - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/LockSupportTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/LockSupportTest.java deleted file mode 100755 index b39db2eda..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/LockSupportTest.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.locks.*; - -public class LockSupportTest extends JSR166TestCase{ - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(LockSupportTest.class); - } - - /** - * park is released by unpark occurring after park - */ - public void testPark() { - Thread t = new Thread(new Runnable() { - public void run() { - try { - LockSupport.park(); - } catch(Exception e){ - threadUnexpectedException(); - } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - LockSupport.unpark(t); - t.join(); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * park is released by unpark occurring before park - */ - public void testPark2() { - Thread t = new Thread(new Runnable() { - public void run() { - try { - Thread.sleep(SHORT_DELAY_MS); - LockSupport.park(); - } catch(Exception e){ - threadUnexpectedException(); - } - } - }); - try { - t.start(); - LockSupport.unpark(t); - t.join(); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * park is released by interrupt - */ - public void testPark3() { - Thread t = new Thread(new Runnable() { - public void run() { - try { - LockSupport.park(); - } catch(Exception e){ - threadUnexpectedException(); - } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * park returns if interrupted before park - */ - public void testPark4() { - final ReentrantLock lock = new ReentrantLock(); - lock.lock(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - lock.lock(); - LockSupport.park(); - } catch(Exception e){ - threadUnexpectedException(); - } - } - }); - try { - t.start(); - t.interrupt(); - lock.unlock(); - t.join(); - } - catch(Exception e) { - unexpectedException(); - } - } - - /** - * parkNanos times out if not unparked - */ - public void testParkNanos() { - Thread t = new Thread(new Runnable() { - public void run() { - try { - LockSupport.parkNanos(1000); - } catch(Exception e){ - threadUnexpectedException(); - } - } - }); - try { - t.start(); - t.join(); - } - catch(Exception e) { - unexpectedException(); - } - } - - - /** - * parkUntil times out if not unparked - */ - public void testParkUntil() { - Thread t = new Thread(new Runnable() { - public void run() { - try { - long d = new Date().getTime() + 100; - LockSupport.parkUntil(d); - } catch(Exception e){ - threadUnexpectedException(); - } - } - }); - try { - t.start(); - t.join(); - } - catch(Exception e) { - unexpectedException(); - } - } -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/PriorityBlockingQueueTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/PriorityBlockingQueueTest.java deleted file mode 100755 index 3857e0f13..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/PriorityBlockingQueueTest.java +++ /dev/null @@ -1,957 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.io.*; - -public class PriorityBlockingQueueTest extends JSR166TestCase { - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(PriorityBlockingQueueTest.class); - } - - private static final int NOCAP = Integer.MAX_VALUE; - - /** Sample Comparator */ - static class MyReverseComparator implements Comparator { - public int compare(Object x, Object y) { - int i = ((Integer)x).intValue(); - int j = ((Integer)y).intValue(); - if (i < j) return 1; - if (i > j) return -1; - return 0; - } - } - - /** - * Create a queue of given size containing consecutive - * Integers 0 ... n. - */ - private PriorityBlockingQueue populatedQueue(int n) { - PriorityBlockingQueue q = new PriorityBlockingQueue(n); - assertTrue(q.isEmpty()); - for(int i = n-1; i >= 0; i-=2) - assertTrue(q.offer(new Integer(i))); - for(int i = (n & 1); i < n; i+=2) - assertTrue(q.offer(new Integer(i))); - assertFalse(q.isEmpty()); - assertEquals(NOCAP, q.remainingCapacity()); - assertEquals(n, q.size()); - return q; - } - - /** - * A new queue has unbounded capacity - */ - public void testConstructor1() { - assertEquals(NOCAP, new PriorityBlockingQueue(SIZE).remainingCapacity()); - } - - /** - * Constructor throws IAE if capacity argument nonpositive - */ - public void testConstructor2() { - try { - PriorityBlockingQueue q = new PriorityBlockingQueue(0); - shouldThrow(); - } - catch (IllegalArgumentException success) {} - } - - /** - * Initializing from null Collection throws NPE - */ - public void testConstructor3() { - try { - PriorityBlockingQueue q = new PriorityBlockingQueue(null); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Initializing from Collection of null elements throws NPE - */ - public void testConstructor4() { - try { - Integer[] ints = new Integer[SIZE]; - PriorityBlockingQueue q = new PriorityBlockingQueue(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Initializing from Collection with some null elements throws NPE - */ - public void testConstructor5() { - try { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new Integer(i); - PriorityBlockingQueue q = new PriorityBlockingQueue(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Queue contains all elements of collection used to initialize - */ - public void testConstructor6() { - try { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - PriorityBlockingQueue q = new PriorityBlockingQueue(Arrays.asList(ints)); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); - } - finally {} - } - - /** - * The comparator used in constructor is used - */ - public void testConstructor7() { - try { - MyReverseComparator cmp = new MyReverseComparator(); - PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE, cmp); - assertEquals(cmp, q.comparator()); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - q.addAll(Arrays.asList(ints)); - for (int i = SIZE-1; i >= 0; --i) - assertEquals(ints[i], q.poll()); - } - finally {} - } - - /** - * isEmpty is true before add, false after - */ - public void testEmpty() { - PriorityBlockingQueue q = new PriorityBlockingQueue(2); - assertTrue(q.isEmpty()); - assertEquals(NOCAP, q.remainingCapacity()); - q.add(one); - assertFalse(q.isEmpty()); - q.add(two); - q.remove(); - q.remove(); - assertTrue(q.isEmpty()); - } - - /** - * remainingCapacity does not change when elements added or removed, - * but size does - */ - public void testRemainingCapacity() { - PriorityBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(NOCAP, q.remainingCapacity()); - assertEquals(SIZE-i, q.size()); - q.remove(); - } - for (int i = 0; i < SIZE; ++i) { - assertEquals(NOCAP, q.remainingCapacity()); - assertEquals(i, q.size()); - q.add(new Integer(i)); - } - } - - /** - * offer(null) throws NPE - */ - public void testOfferNull() { - try { - PriorityBlockingQueue q = new PriorityBlockingQueue(1); - q.offer(null); - shouldThrow(); - } catch (NullPointerException success) { } - } - - /** - * add(null) throws NPE - */ - public void testAddNull() { - try { - PriorityBlockingQueue q = new PriorityBlockingQueue(1); - q.add(null); - shouldThrow(); - } catch (NullPointerException success) { } - } - - /** - * Offer of comparable element succeeds - */ - public void testOffer() { - PriorityBlockingQueue q = new PriorityBlockingQueue(1); - assertTrue(q.offer(zero)); - assertTrue(q.offer(one)); - } - - /** - * Offer of non-Comparable throws CCE - */ - public void testOfferNonComparable() { - try { - PriorityBlockingQueue q = new PriorityBlockingQueue(1); - q.offer(new Object()); - q.offer(new Object()); - q.offer(new Object()); - shouldThrow(); - } - catch(ClassCastException success) {} - } - - /** - * add of comparable succeeds - */ - public void testAdd() { - PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - assertTrue(q.add(new Integer(i))); - } - } - - /** - * addAll(null) throws NPE - */ - public void testAddAll1() { - try { - PriorityBlockingQueue q = new PriorityBlockingQueue(1); - q.addAll(null); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * addAll(this) throws IAE - */ - public void testAddAllSelf() { - try { - PriorityBlockingQueue q = populatedQueue(SIZE); - q.addAll(q); - shouldThrow(); - } - catch (IllegalArgumentException success) {} - } - - /** - * addAll of a collection with null elements throws NPE - */ - public void testAddAll2() { - try { - PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - /** - * addAll of a collection with any null elements throws NPE after - * possibly adding some elements - */ - public void testAddAll3() { - try { - PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new Integer(i); - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Queue contains all elements of successful addAll - */ - public void testAddAll5() { - try { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; - for (int i = SIZE-1; i >= 0; --i) - ints[i] = new Integer(i); - PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); - assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); - } - finally {} - } - - /** - * put(null) throws NPE - */ - public void testPutNull() { - try { - PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); - q.put(null); - shouldThrow(); - } - catch (NullPointerException success){ - } - } - - /** - * all elements successfully put are contained - */ - public void testPut() { - try { - PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - Integer I = new Integer(i); - q.put(I); - assertTrue(q.contains(I)); - } - assertEquals(SIZE, q.size()); - } - finally { - } - } - - /** - * put doesn't block waiting for take - */ - public void testPutWithTake() { - final PriorityBlockingQueue q = new PriorityBlockingQueue(2); - Thread t = new Thread(new Runnable() { - public void run() { - int added = 0; - try { - q.put(new Integer(0)); - ++added; - q.put(new Integer(0)); - ++added; - q.put(new Integer(0)); - ++added; - q.put(new Integer(0)); - ++added; - threadAssertTrue(added == 4); - } finally { - } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - q.take(); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - /** - * timed offer does not time out - */ - public void testTimedOffer() { - final PriorityBlockingQueue q = new PriorityBlockingQueue(2); - Thread t = new Thread(new Runnable() { - public void run() { - try { - q.put(new Integer(0)); - q.put(new Integer(0)); - threadAssertTrue(q.offer(new Integer(0), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - threadAssertTrue(q.offer(new Integer(0), LONG_DELAY_MS, TimeUnit.MILLISECONDS)); - } finally { } - } - }); - - try { - t.start(); - Thread.sleep(SMALL_DELAY_MS); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - /** - * take retrieves elements in priority order - */ - public void testTake() { - try { - PriorityBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.take()).intValue()); - } - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * take blocks interruptibly when empty - */ - public void testTakeFromEmpty() { - final PriorityBlockingQueue q = new PriorityBlockingQueue(2); - Thread t = new Thread(new Runnable() { - public void run() { - try { - q.take(); - threadShouldThrow(); - } catch (InterruptedException success){ } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - /** - * Take removes existing elements until empty, then blocks interruptibly - */ - public void testBlockingTake() { - Thread t = new Thread(new Runnable() { - public void run() { - try { - PriorityBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - threadAssertEquals(i, ((Integer)q.take()).intValue()); - } - q.take(); - threadShouldThrow(); - } catch (InterruptedException success){ - } - }}); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } - catch (InterruptedException ie) { - unexpectedException(); - } - } - - - /** - * poll succeeds unless empty - */ - public void testPoll() { - PriorityBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.poll()).intValue()); - } - assertNull(q.poll()); - } - - /** - * timed pool with zero timeout succeeds when non-empty, else times out - */ - public void testTimedPoll0() { - try { - PriorityBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.poll(0, TimeUnit.MILLISECONDS)).intValue()); - } - assertNull(q.poll(0, TimeUnit.MILLISECONDS)); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * timed pool with nonzero timeout succeeds when non-empty, else times out - */ - public void testTimedPoll() { - try { - PriorityBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); - } - assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * Interrupted timed poll throws InterruptedException instead of - * returning timeout status - */ - public void testInterruptedTimedPoll() { - Thread t = new Thread(new Runnable() { - public void run() { - try { - PriorityBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - threadAssertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); - } - threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch (InterruptedException success){ - } - }}); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } - catch (InterruptedException ie) { - unexpectedException(); - } - } - - /** - * timed poll before a delayed offer fails; after offer succeeds; - * on interruption throws - */ - public void testTimedPollWithOffer() { - final PriorityBlockingQueue q = new PriorityBlockingQueue(2); - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch (InterruptedException success) { } - } - }); - try { - t.start(); - Thread.sleep(SMALL_DELAY_MS); - assertTrue(q.offer(new Integer(0), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - - /** - * peek returns next element, or null if empty - */ - public void testPeek() { - PriorityBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.peek()).intValue()); - q.poll(); - assertTrue(q.peek() == null || - i != ((Integer)q.peek()).intValue()); - } - assertNull(q.peek()); - } - - /** - * element returns next element, or throws NSEE if empty - */ - public void testElement() { - PriorityBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.element()).intValue()); - q.poll(); - } - try { - q.element(); - shouldThrow(); - } - catch (NoSuchElementException success) {} - } - - /** - * remove removes next element, or throws NSEE if empty - */ - public void testRemove() { - PriorityBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.remove()).intValue()); - } - try { - q.remove(); - shouldThrow(); - } catch (NoSuchElementException success){ - } - } - - /** - * remove(x) removes x and returns true if present - */ - public void testRemoveElement() { - PriorityBlockingQueue q = populatedQueue(SIZE); - for (int i = 1; i < SIZE; i+=2) { - assertTrue(q.remove(new Integer(i))); - } - for (int i = 0; i < SIZE; i+=2) { - assertTrue(q.remove(new Integer(i))); - assertFalse(q.remove(new Integer(i+1))); - } - assertTrue(q.isEmpty()); - } - - /** - * contains(x) reports true when elements added but not yet removed - */ - public void testContains() { - PriorityBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); - q.poll(); - assertFalse(q.contains(new Integer(i))); - } - } - - /** - * clear removes all elements - */ - public void testClear() { - PriorityBlockingQueue q = populatedQueue(SIZE); - q.clear(); - assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - q.add(one); - assertFalse(q.isEmpty()); - assertTrue(q.contains(one)); - q.clear(); - assertTrue(q.isEmpty()); - } - - /** - * containsAll(c) is true when c contains a subset of elements - */ - public void testContainsAll() { - PriorityBlockingQueue q = populatedQueue(SIZE); - PriorityBlockingQueue p = new PriorityBlockingQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertTrue(q.containsAll(p)); - assertFalse(p.containsAll(q)); - p.add(new Integer(i)); - } - assertTrue(p.containsAll(q)); - } - - /** - * retainAll(c) retains only those elements of c and reports true if changed - */ - public void testRetainAll() { - PriorityBlockingQueue q = populatedQueue(SIZE); - PriorityBlockingQueue p = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - boolean changed = q.retainAll(p); - if (i == 0) - assertFalse(changed); - else - assertTrue(changed); - - assertTrue(q.containsAll(p)); - assertEquals(SIZE-i, q.size()); - p.remove(); - } - } - - /** - * removeAll(c) removes only those elements of c and reports true if changed - */ - public void testRemoveAll() { - for (int i = 1; i < SIZE; ++i) { - PriorityBlockingQueue q = populatedQueue(SIZE); - PriorityBlockingQueue p = populatedQueue(i); - assertTrue(q.removeAll(p)); - assertEquals(SIZE-i, q.size()); - for (int j = 0; j < i; ++j) { - Integer I = (Integer)(p.remove()); - assertFalse(q.contains(I)); - } - } - } - - /** - * toArray contains all elements - */ - public void testToArray() { - PriorityBlockingQueue q = populatedQueue(SIZE); - Object[] o = q.toArray(); - Arrays.sort(o); - try { - for(int i = 0; i < o.length; i++) - assertEquals(o[i], q.take()); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * toArray(a) contains all elements - */ - public void testToArray2() { - PriorityBlockingQueue q = populatedQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - ints = (Integer[])q.toArray(ints); - Arrays.sort(ints); - try { - for(int i = 0; i < ints.length; i++) - assertEquals(ints[i], q.take()); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * toArray(null) throws NPE - */ - public void testToArray_BadArg() { - try { - PriorityBlockingQueue q = populatedQueue(SIZE); - Object o[] = q.toArray(null); - shouldThrow(); - } catch(NullPointerException success){} - } - - /** - * toArray with incompatible array type throws CCE - */ - public void testToArray1_BadArg() { - try { - PriorityBlockingQueue q = populatedQueue(SIZE); - Object o[] = q.toArray(new String[10] ); - shouldThrow(); - } catch(ArrayStoreException success){} - } - - /** - * iterator iterates through all elements - */ - public void testIterator() { - PriorityBlockingQueue q = populatedQueue(SIZE); - int i = 0; - Iterator it = q.iterator(); - while(it.hasNext()) { - assertTrue(q.contains(it.next())); - ++i; - } - assertEquals(i, SIZE); - } - - /** - * iterator.remove removes current element - */ - public void testIteratorRemove () { - final PriorityBlockingQueue q = new PriorityBlockingQueue(3); - q.add(new Integer(2)); - q.add(new Integer(1)); - q.add(new Integer(3)); - - Iterator it = q.iterator(); - it.next(); - it.remove(); - - it = q.iterator(); - assertEquals(it.next(), new Integer(2)); - assertEquals(it.next(), new Integer(3)); - assertFalse(it.hasNext()); - } - - - /** - * toString contains toStrings of elements - */ - public void testToString() { - PriorityBlockingQueue q = populatedQueue(SIZE); - String s = q.toString(); - for (int i = 0; i < SIZE; ++i) { - assertTrue(s.indexOf(String.valueOf(i)) >= 0); - } - } - - /** - * offer transfers elements across Executor tasks - */ - public void testPollInExecutor() { - final PriorityBlockingQueue q = new PriorityBlockingQueue(2); - ExecutorService executor = Executors.newFixedThreadPool(2); - executor.execute(new Runnable() { - public void run() { - threadAssertNull(q.poll()); - try { - threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS)); - threadAssertTrue(q.isEmpty()); - } - catch (InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - executor.execute(new Runnable() { - public void run() { - try { - Thread.sleep(SMALL_DELAY_MS); - q.put(new Integer(1)); - } - catch (InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - joinPool(executor); - } - - /** - * A deserialized serialized queue has same elements - */ - public void testSerialization() { - PriorityBlockingQueue q = populatedQueue(SIZE); - try { - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(q); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - PriorityBlockingQueue r = (PriorityBlockingQueue)in.readObject(); - assertEquals(q.size(), r.size()); - while (!q.isEmpty()) - assertEquals(q.remove(), r.remove()); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * drainTo(null) throws NPE - */ - public void testDrainToNull() { - PriorityBlockingQueue q = populatedQueue(SIZE); - try { - q.drainTo(null); - shouldThrow(); - } catch(NullPointerException success) { - } - } - - /** - * drainTo(this) throws IAE - */ - public void testDrainToSelf() { - PriorityBlockingQueue q = populatedQueue(SIZE); - try { - q.drainTo(q); - shouldThrow(); - } catch(IllegalArgumentException success) { - } - } - - /** - * drainTo(c) empties queue into another collection c - */ - public void testDrainTo() { - PriorityBlockingQueue q = populatedQueue(SIZE); - ArrayList l = new ArrayList(); - q.drainTo(l); - assertEquals(q.size(), 0); - assertEquals(l.size(), SIZE); - for (int i = 0; i < SIZE; ++i) - assertEquals(l.get(i), new Integer(i)); - q.add(zero); - q.add(one); - assertFalse(q.isEmpty()); - assertTrue(q.contains(zero)); - assertTrue(q.contains(one)); - l.clear(); - q.drainTo(l); - assertEquals(q.size(), 0); - assertEquals(l.size(), 2); - for (int i = 0; i < 2; ++i) - assertEquals(l.get(i), new Integer(i)); - } - - /** - * drainTo empties queue - */ - public void testDrainToWithActivePut() { - final PriorityBlockingQueue q = populatedQueue(SIZE); - Thread t = new Thread(new Runnable() { - public void run() { - q.put(new Integer(SIZE+1)); - } - }); - try { - t.start(); - ArrayList l = new ArrayList(); - q.drainTo(l); - assertTrue(l.size() >= SIZE); - for (int i = 0; i < SIZE; ++i) - assertEquals(l.get(i), new Integer(i)); - t.join(); - assertTrue(q.size() + l.size() >= SIZE); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * drainTo(null, n) throws NPE - */ - public void testDrainToNullN() { - PriorityBlockingQueue q = populatedQueue(SIZE); - try { - q.drainTo(null, 0); - shouldThrow(); - } catch(NullPointerException success) { - } - } - - /** - * drainTo(this, n) throws IAE - */ - public void testDrainToSelfN() { - PriorityBlockingQueue q = populatedQueue(SIZE); - try { - q.drainTo(q, 0); - shouldThrow(); - } catch(IllegalArgumentException success) { - } - } - - /** - * drainTo(c, n) empties first max {n, size} elements of queue into c - */ - public void testDrainToN() { - PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE*2); - for (int i = 0; i < SIZE + 2; ++i) { - for(int j = 0; j < SIZE; j++) - assertTrue(q.offer(new Integer(j))); - ArrayList l = new ArrayList(); - q.drainTo(l, i); - int k = (i < SIZE)? i : SIZE; - assertEquals(l.size(), k); - assertEquals(q.size(), SIZE-k); - for (int j = 0; j < k; ++j) - assertEquals(l.get(j), new Integer(j)); - while (q.poll() != null) ; - } - } - - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/PriorityQueueTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/PriorityQueueTest.java deleted file mode 100755 index 409e1ed72..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/PriorityQueueTest.java +++ /dev/null @@ -1,515 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.io.*; - -public class PriorityQueueTest extends JSR166TestCase { - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(PriorityQueueTest.class); - } - - static class MyReverseComparator implements Comparator { - public int compare(Object x, Object y) { - int i = ((Integer)x).intValue(); - int j = ((Integer)y).intValue(); - if (i < j) return 1; - if (i > j) return -1; - return 0; - } - } - - /** - * Create a queue of given size containing consecutive - * Integers 0 ... n. - */ - private PriorityQueue populatedQueue(int n) { - PriorityQueue q = new PriorityQueue(n); - assertTrue(q.isEmpty()); - for(int i = n-1; i >= 0; i-=2) - assertTrue(q.offer(new Integer(i))); - for(int i = (n & 1); i < n; i+=2) - assertTrue(q.offer(new Integer(i))); - assertFalse(q.isEmpty()); - assertEquals(n, q.size()); - return q; - } - - /** - * A new queue has unbounded capacity - */ - public void testConstructor1() { - assertEquals(0, new PriorityQueue(SIZE).size()); - } - - /** - * Constructor throws IAE if capacity argument nonpositive - */ - public void testConstructor2() { - try { - PriorityQueue q = new PriorityQueue(0); - shouldThrow(); - } - catch (IllegalArgumentException success) {} - } - - /** - * Initializing from null Collection throws NPE - */ - public void testConstructor3() { - try { - PriorityQueue q = new PriorityQueue((Collection)null); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Initializing from Collection of null elements throws NPE - */ - public void testConstructor4() { - try { - Integer[] ints = new Integer[SIZE]; - PriorityQueue q = new PriorityQueue(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Initializing from Collection with some null elements throws NPE - */ - public void testConstructor5() { - try { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new Integer(i); - PriorityQueue q = new PriorityQueue(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Queue contains all elements of collection used to initialize - */ - public void testConstructor6() { - try { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - PriorityQueue q = new PriorityQueue(Arrays.asList(ints)); - for (int i = 0; i < SIZE; ++i) - assertEquals(ints[i], q.poll()); - } - finally {} - } - - /** - * The comparator used in constructor is used - */ - public void testConstructor7() { - try { - MyReverseComparator cmp = new MyReverseComparator(); - PriorityQueue q = new PriorityQueue(SIZE, cmp); - assertEquals(cmp, q.comparator()); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); - q.addAll(Arrays.asList(ints)); - for (int i = SIZE-1; i >= 0; --i) - assertEquals(ints[i], q.poll()); - } - finally {} - } - - /** - * isEmpty is true before add, false after - */ - public void testEmpty() { - PriorityQueue q = new PriorityQueue(2); - assertTrue(q.isEmpty()); - q.add(new Integer(1)); - assertFalse(q.isEmpty()); - q.add(new Integer(2)); - q.remove(); - q.remove(); - assertTrue(q.isEmpty()); - } - - /** - * size changes when elements added and removed - */ - public void testSize() { - PriorityQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE-i, q.size()); - q.remove(); - } - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - q.add(new Integer(i)); - } - } - - /** - * offer(null) throws NPE - */ - public void testOfferNull() { - try { - PriorityQueue q = new PriorityQueue(1); - q.offer(null); - shouldThrow(); - } catch (NullPointerException success) { } - } - - /** - * add(null) throws NPE - */ - public void testAddNull() { - try { - PriorityQueue q = new PriorityQueue(1); - q.add(null); - shouldThrow(); - } catch (NullPointerException success) { } - } - - /** - * Offer of comparable element succeeds - */ - public void testOffer() { - PriorityQueue q = new PriorityQueue(1); - assertTrue(q.offer(zero)); - assertTrue(q.offer(one)); - } - - /** - * Offer of non-Comparable throws CCE - */ - public void testOfferNonComparable() { - try { - PriorityQueue q = new PriorityQueue(1); - q.offer(new Object()); - q.offer(new Object()); - q.offer(new Object()); - shouldThrow(); - } - catch(ClassCastException success) {} - } - - /** - * add of comparable succeeds - */ - public void testAdd() { - PriorityQueue q = new PriorityQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, q.size()); - assertTrue(q.add(new Integer(i))); - } - } - - /** - * addAll(null) throws NPE - */ - public void testAddAll1() { - try { - PriorityQueue q = new PriorityQueue(1); - q.addAll(null); - shouldThrow(); - } - catch (NullPointerException success) {} - } - /** - * addAll of a collection with null elements throws NPE - */ - public void testAddAll2() { - try { - PriorityQueue q = new PriorityQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - /** - * addAll of a collection with any null elements throws NPE after - * possibly adding some elements - */ - public void testAddAll3() { - try { - PriorityQueue q = new PriorityQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new Integer(i); - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * Queue contains all elements of successful addAll - */ - public void testAddAll5() { - try { - Integer[] empty = new Integer[0]; - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(SIZE-1-i); - PriorityQueue q = new PriorityQueue(SIZE); - assertFalse(q.addAll(Arrays.asList(empty))); - assertTrue(q.addAll(Arrays.asList(ints))); - for (int i = 0; i < SIZE; ++i) - assertEquals(new Integer(i), q.poll()); - } - finally {} - } - - /** - * poll succeeds unless empty - */ - public void testPoll() { - PriorityQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.poll()).intValue()); - } - assertNull(q.poll()); - } - - /** - * peek returns next element, or null if empty - */ - public void testPeek() { - PriorityQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.peek()).intValue()); - q.poll(); - assertTrue(q.peek() == null || - i != ((Integer)q.peek()).intValue()); - } - assertNull(q.peek()); - } - - /** - * element returns next element, or throws NSEE if empty - */ - public void testElement() { - PriorityQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.element()).intValue()); - q.poll(); - } - try { - q.element(); - shouldThrow(); - } - catch (NoSuchElementException success) {} - } - - /** - * remove removes next element, or throws NSEE if empty - */ - public void testRemove() { - PriorityQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertEquals(i, ((Integer)q.remove()).intValue()); - } - try { - q.remove(); - shouldThrow(); - } catch (NoSuchElementException success){ - } - } - - /** - * remove(x) removes x and returns true if present - */ - public void testRemoveElement() { - PriorityQueue q = populatedQueue(SIZE); - for (int i = 1; i < SIZE; i+=2) { - assertTrue(q.remove(new Integer(i))); - } - for (int i = 0; i < SIZE; i+=2) { - assertTrue(q.remove(new Integer(i))); - assertFalse(q.remove(new Integer(i+1))); - } - assertTrue(q.isEmpty()); - } - - /** - * contains(x) reports true when elements added but not yet removed - */ - public void testContains() { - PriorityQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertTrue(q.contains(new Integer(i))); - q.poll(); - assertFalse(q.contains(new Integer(i))); - } - } - - /** - * clear removes all elements - */ - public void testClear() { - PriorityQueue q = populatedQueue(SIZE); - q.clear(); - assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - q.add(new Integer(1)); - assertFalse(q.isEmpty()); - q.clear(); - assertTrue(q.isEmpty()); - } - - /** - * containsAll(c) is true when c contains a subset of elements - */ - public void testContainsAll() { - PriorityQueue q = populatedQueue(SIZE); - PriorityQueue p = new PriorityQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - assertTrue(q.containsAll(p)); - assertFalse(p.containsAll(q)); - p.add(new Integer(i)); - } - assertTrue(p.containsAll(q)); - } - - /** - * retainAll(c) retains only those elements of c and reports true if changed - */ - public void testRetainAll() { - PriorityQueue q = populatedQueue(SIZE); - PriorityQueue p = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { - boolean changed = q.retainAll(p); - if (i == 0) - assertFalse(changed); - else - assertTrue(changed); - - assertTrue(q.containsAll(p)); - assertEquals(SIZE-i, q.size()); - p.remove(); - } - } - - /** - * removeAll(c) removes only those elements of c and reports true if changed - */ - public void testRemoveAll() { - for (int i = 1; i < SIZE; ++i) { - PriorityQueue q = populatedQueue(SIZE); - PriorityQueue p = populatedQueue(i); - assertTrue(q.removeAll(p)); - assertEquals(SIZE-i, q.size()); - for (int j = 0; j < i; ++j) { - Integer I = (Integer)(p.remove()); - assertFalse(q.contains(I)); - } - } - } - - /** - * toArray contains all elements - */ - public void testToArray() { - PriorityQueue q = populatedQueue(SIZE); - Object[] o = q.toArray(); - Arrays.sort(o); - for(int i = 0; i < o.length; i++) - assertEquals(o[i], q.poll()); - } - - /** - * toArray(a) contains all elements - */ - public void testToArray2() { - PriorityQueue q = populatedQueue(SIZE); - Integer[] ints = new Integer[SIZE]; - ints = (Integer[])q.toArray(ints); - Arrays.sort(ints); - for(int i = 0; i < ints.length; i++) - assertEquals(ints[i], q.poll()); - } - - /** - * iterator iterates through all elements - */ - public void testIterator() { - PriorityQueue q = populatedQueue(SIZE); - int i = 0; - Iterator it = q.iterator(); - while(it.hasNext()) { - assertTrue(q.contains(it.next())); - ++i; - } - assertEquals(i, SIZE); - } - - /** - * iterator.remove removes current element - */ - public void testIteratorRemove () { - final PriorityQueue q = new PriorityQueue(3); - q.add(new Integer(2)); - q.add(new Integer(1)); - q.add(new Integer(3)); - - Iterator it = q.iterator(); - it.next(); - it.remove(); - - it = q.iterator(); - assertEquals(it.next(), new Integer(2)); - assertEquals(it.next(), new Integer(3)); - assertFalse(it.hasNext()); - } - - - /** - * toString contains toStrings of elements - */ - public void testToString() { - PriorityQueue q = populatedQueue(SIZE); - String s = q.toString(); - for (int i = 0; i < SIZE; ++i) { - assertTrue(s.indexOf(String.valueOf(i)) >= 0); - } - } - - /** - * A deserialized serialized queue has same elements - */ - public void testSerialization() { - PriorityQueue q = populatedQueue(SIZE); - try { - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(q); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - PriorityQueue r = (PriorityQueue)in.readObject(); - assertEquals(q.size(), r.size()); - while (!q.isEmpty()) - assertEquals(q.remove(), r.remove()); - } catch(Exception e){ - unexpectedException(); - } - } -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ReentrantLockTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ReentrantLockTest.java deleted file mode 100755 index c50482d1b..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ReentrantLockTest.java +++ /dev/null @@ -1,1164 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.concurrent.locks.*; -import java.util.concurrent.*; -import java.util.*; -import java.io.*; - -public class ReentrantLockTest extends JSR166TestCase { - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(ReentrantLockTest.class); - } - - /** - * A runnable calling lockInterruptibly - */ - class InterruptibleLockRunnable implements Runnable { - final ReentrantLock lock; - InterruptibleLockRunnable(ReentrantLock l) { lock = l; } - public void run() { - try { - lock.lockInterruptibly(); - } catch(InterruptedException success){} - } - } - - - /** - * A runnable calling lockInterruptibly that expects to be - * interrupted - */ - class InterruptedLockRunnable implements Runnable { - final ReentrantLock lock; - InterruptedLockRunnable(ReentrantLock l) { lock = l; } - public void run() { - try { - lock.lockInterruptibly(); - threadShouldThrow(); - } catch(InterruptedException success){} - } - } - - /** - * Subclass to expose protected methods - */ - static class PublicReentrantLock extends ReentrantLock { - PublicReentrantLock() { super(); } - public Collection getQueuedThreads() { - return super.getQueuedThreads(); - } - public Collection getWaitingThreads(Condition c) { - return super.getWaitingThreads(c); - } - - - } - - /** - * Constructor sets given fairness - */ - public void testConstructor() { - ReentrantLock rl = new ReentrantLock(); - assertFalse(rl.isFair()); - ReentrantLock r2 = new ReentrantLock(true); - assertTrue(r2.isFair()); - } - - /** - * locking an unlocked lock succeeds - */ - public void testLock() { - ReentrantLock rl = new ReentrantLock(); - rl.lock(); - assertTrue(rl.isLocked()); - rl.unlock(); - } - - /** - * locking an unlocked fair lock succeeds - */ - public void testFairLock() { - ReentrantLock rl = new ReentrantLock(true); - rl.lock(); - assertTrue(rl.isLocked()); - rl.unlock(); - } - - /** - * Unlocking an unlocked lock throws IllegalMonitorStateException - */ - public void testUnlock_IllegalMonitorStateException() { - ReentrantLock rl = new ReentrantLock(); - try { - rl.unlock(); - shouldThrow(); - - } catch(IllegalMonitorStateException success){} - } - - /** - * tryLock on an unlocked lock succeeds - */ - public void testTryLock() { - ReentrantLock rl = new ReentrantLock(); - assertTrue(rl.tryLock()); - assertTrue(rl.isLocked()); - rl.unlock(); - } - - - /** - * hasQueuedThreads reports whether there are waiting threads - */ - public void testhasQueuedThreads() { - final ReentrantLock lock = new ReentrantLock(); - Thread t1 = new Thread(new InterruptedLockRunnable(lock)); - Thread t2 = new Thread(new InterruptibleLockRunnable(lock)); - try { - assertFalse(lock.hasQueuedThreads()); - lock.lock(); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.hasQueuedThreads()); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.hasQueuedThreads()); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.hasQueuedThreads()); - lock.unlock(); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(lock.hasQueuedThreads()); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * getQueueLength reports number of waiting threads - */ - public void testGetQueueLength() { - final ReentrantLock lock = new ReentrantLock(); - Thread t1 = new Thread(new InterruptedLockRunnable(lock)); - Thread t2 = new Thread(new InterruptibleLockRunnable(lock)); - try { - assertEquals(0, lock.getQueueLength()); - lock.lock(); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(1, lock.getQueueLength()); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(2, lock.getQueueLength()); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(1, lock.getQueueLength()); - lock.unlock(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(0, lock.getQueueLength()); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * getQueueLength reports number of waiting threads - */ - public void testGetQueueLength_fair() { - final ReentrantLock lock = new ReentrantLock(true); - Thread t1 = new Thread(new InterruptedLockRunnable(lock)); - Thread t2 = new Thread(new InterruptibleLockRunnable(lock)); - try { - assertEquals(0, lock.getQueueLength()); - lock.lock(); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(1, lock.getQueueLength()); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(2, lock.getQueueLength()); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(1, lock.getQueueLength()); - lock.unlock(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(0, lock.getQueueLength()); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * hasQueuedThread(null) throws NPE - */ - public void testHasQueuedThreadNPE() { - final ReentrantLock sync = new ReentrantLock(); - try { - sync.hasQueuedThread(null); - shouldThrow(); - } catch (NullPointerException success) { - } - } - - /** - * hasQueuedThread reports whether a thread is queued. - */ - public void testHasQueuedThread() { - final ReentrantLock sync = new ReentrantLock(); - Thread t1 = new Thread(new InterruptedLockRunnable(sync)); - Thread t2 = new Thread(new InterruptibleLockRunnable(sync)); - try { - assertFalse(sync.hasQueuedThread(t1)); - assertFalse(sync.hasQueuedThread(t2)); - sync.lock(); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.hasQueuedThread(t1)); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.hasQueuedThread(t1)); - assertTrue(sync.hasQueuedThread(t2)); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(sync.hasQueuedThread(t1)); - assertTrue(sync.hasQueuedThread(t2)); - sync.unlock(); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(sync.hasQueuedThread(t1)); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(sync.hasQueuedThread(t2)); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * getQueuedThreads includes waiting threads - */ - public void testGetQueuedThreads() { - final PublicReentrantLock lock = new PublicReentrantLock(); - Thread t1 = new Thread(new InterruptedLockRunnable(lock)); - Thread t2 = new Thread(new InterruptibleLockRunnable(lock)); - try { - assertTrue(lock.getQueuedThreads().isEmpty()); - lock.lock(); - assertTrue(lock.getQueuedThreads().isEmpty()); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.getQueuedThreads().contains(t1)); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.getQueuedThreads().contains(t1)); - assertTrue(lock.getQueuedThreads().contains(t2)); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(lock.getQueuedThreads().contains(t1)); - assertTrue(lock.getQueuedThreads().contains(t2)); - lock.unlock(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.getQueuedThreads().isEmpty()); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * timed tryLock is interruptible. - */ - public void testInterruptedException2() { - final ReentrantLock lock = new ReentrantLock(); - lock.lock(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - lock.tryLock(MEDIUM_DELAY_MS,TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch(InterruptedException success){} - } - }); - try { - t.start(); - t.interrupt(); - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * TryLock on a locked lock fails - */ - public void testTryLockWhenLocked() { - final ReentrantLock lock = new ReentrantLock(); - lock.lock(); - Thread t = new Thread(new Runnable() { - public void run() { - threadAssertFalse(lock.tryLock()); - } - }); - try { - t.start(); - t.join(); - lock.unlock(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * Timed tryLock on a locked lock times out - */ - public void testTryLock_Timeout() { - final ReentrantLock lock = new ReentrantLock(); - lock.lock(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertFalse(lock.tryLock(1, TimeUnit.MILLISECONDS)); - } catch (Exception ex) { - threadUnexpectedException(); - } - } - }); - try { - t.start(); - t.join(); - lock.unlock(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * getHoldCount returns number of recursive holds - */ - public void testGetHoldCount() { - ReentrantLock lock = new ReentrantLock(); - for(int i = 1; i <= SIZE; i++) { - lock.lock(); - assertEquals(i,lock.getHoldCount()); - } - for(int i = SIZE; i > 0; i--) { - lock.unlock(); - assertEquals(i-1,lock.getHoldCount()); - } - } - - - /** - * isLocked is true when locked and false when not - */ - public void testIsLocked() { - final ReentrantLock lock = new ReentrantLock(); - lock.lock(); - assertTrue(lock.isLocked()); - lock.unlock(); - assertFalse(lock.isLocked()); - Thread t = new Thread(new Runnable() { - public void run() { - lock.lock(); - try { - Thread.sleep(SMALL_DELAY_MS); - } - catch(Exception e) { - threadUnexpectedException(); - } - lock.unlock(); - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.isLocked()); - t.join(); - assertFalse(lock.isLocked()); - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * lockInterruptibly is interruptible. - */ - public void testLockInterruptibly1() { - final ReentrantLock lock = new ReentrantLock(); - lock.lock(); - Thread t = new Thread(new InterruptedLockRunnable(lock)); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - lock.unlock(); - t.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * lockInterruptibly succeeds when unlocked, else is interruptible - */ - public void testLockInterruptibly2() { - final ReentrantLock lock = new ReentrantLock(); - try { - lock.lockInterruptibly(); - } catch(Exception e) { - unexpectedException(); - } - Thread t = new Thread(new InterruptedLockRunnable(lock)); - try { - t.start(); - t.interrupt(); - assertTrue(lock.isLocked()); - assertTrue(lock.isHeldByCurrentThread()); - t.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * Calling await without holding lock throws IllegalMonitorStateException - */ - public void testAwait_IllegalMonitor() { - final ReentrantLock lock = new ReentrantLock(); - final Condition c = lock.newCondition(); - try { - c.await(); - shouldThrow(); - } - catch (IllegalMonitorStateException success) { - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * Calling signal without holding lock throws IllegalMonitorStateException - */ - public void testSignal_IllegalMonitor() { - final ReentrantLock lock = new ReentrantLock(); - final Condition c = lock.newCondition(); - try { - c.signal(); - shouldThrow(); - } - catch (IllegalMonitorStateException success) { - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * awaitNanos without a signal times out - */ - public void testAwaitNanos_Timeout() { - final ReentrantLock lock = new ReentrantLock(); - final Condition c = lock.newCondition(); - try { - lock.lock(); - long t = c.awaitNanos(100); - assertTrue(t <= 0); - lock.unlock(); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * timed await without a signal times out - */ - public void testAwait_Timeout() { - final ReentrantLock lock = new ReentrantLock(); - final Condition c = lock.newCondition(); - try { - lock.lock(); - c.await(SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - lock.unlock(); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * awaitUntil without a signal times out - */ - public void testAwaitUntil_Timeout() { - final ReentrantLock lock = new ReentrantLock(); - final Condition c = lock.newCondition(); - try { - lock.lock(); - java.util.Date d = new java.util.Date(); - c.awaitUntil(new java.util.Date(d.getTime() + 10)); - lock.unlock(); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * await returns when signalled - */ - public void testAwait() { - final ReentrantLock lock = new ReentrantLock(); - final Condition c = lock.newCondition(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - lock.lock(); - c.await(); - lock.unlock(); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - lock.lock(); - c.signal(); - lock.unlock(); - t.join(SHORT_DELAY_MS); - assertFalse(t.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * hasWaiters throws NPE if null - */ - public void testHasWaitersNPE() { - final ReentrantLock lock = new ReentrantLock(); - try { - lock.hasWaiters(null); - shouldThrow(); - } catch (NullPointerException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - /** - * getWaitQueueLength throws NPE if null - */ - public void testGetWaitQueueLengthNPE() { - final ReentrantLock lock = new ReentrantLock(); - try { - lock.getWaitQueueLength(null); - shouldThrow(); - } catch (NullPointerException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - - /** - * getWaitingThreads throws NPE if null - */ - public void testGetWaitingThreadsNPE() { - final PublicReentrantLock lock = new PublicReentrantLock(); - try { - lock.getWaitingThreads(null); - shouldThrow(); - } catch (NullPointerException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - - /** - * hasWaiters throws IAE if not owned - */ - public void testHasWaitersIAE() { - final ReentrantLock lock = new ReentrantLock(); - final Condition c = (lock.newCondition()); - final ReentrantLock lock2 = new ReentrantLock(); - try { - lock2.hasWaiters(c); - shouldThrow(); - } catch (IllegalArgumentException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - /** - * hasWaiters throws IMSE if not locked - */ - public void testHasWaitersIMSE() { - final ReentrantLock lock = new ReentrantLock(); - final Condition c = (lock.newCondition()); - try { - lock.hasWaiters(c); - shouldThrow(); - } catch (IllegalMonitorStateException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - - /** - * getWaitQueueLength throws IAE if not owned - */ - public void testGetWaitQueueLengthIAE() { - final ReentrantLock lock = new ReentrantLock(); - final Condition c = (lock.newCondition()); - final ReentrantLock lock2 = new ReentrantLock(); - try { - lock2.getWaitQueueLength(c); - shouldThrow(); - } catch (IllegalArgumentException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - /** - * getWaitQueueLength throws IMSE if not locked - */ - public void testGetWaitQueueLengthIMSE() { - final ReentrantLock lock = new ReentrantLock(); - final Condition c = (lock.newCondition()); - try { - lock.getWaitQueueLength(c); - shouldThrow(); - } catch (IllegalMonitorStateException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - - /** - * getWaitingThreads throws IAE if not owned - */ - public void testGetWaitingThreadsIAE() { - final PublicReentrantLock lock = new PublicReentrantLock(); - final Condition c = (lock.newCondition()); - final PublicReentrantLock lock2 = new PublicReentrantLock(); - try { - lock2.getWaitingThreads(c); - shouldThrow(); - } catch (IllegalArgumentException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - /** - * getWaitingThreads throws IMSE if not locked - */ - public void testGetWaitingThreadsIMSE() { - final PublicReentrantLock lock = new PublicReentrantLock(); - final Condition c = (lock.newCondition()); - try { - lock.getWaitingThreads(c); - shouldThrow(); - } catch (IllegalMonitorStateException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - - - /** - * hasWaiters returns true when a thread is waiting, else false - */ - public void testHasWaiters() { - final ReentrantLock lock = new ReentrantLock(); - final Condition c = lock.newCondition(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - lock.lock(); - threadAssertFalse(lock.hasWaiters(c)); - threadAssertEquals(0, lock.getWaitQueueLength(c)); - c.await(); - lock.unlock(); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - lock.lock(); - assertTrue(lock.hasWaiters(c)); - assertEquals(1, lock.getWaitQueueLength(c)); - c.signal(); - lock.unlock(); - Thread.sleep(SHORT_DELAY_MS); - lock.lock(); - assertFalse(lock.hasWaiters(c)); - assertEquals(0, lock.getWaitQueueLength(c)); - lock.unlock(); - t.join(SHORT_DELAY_MS); - assertFalse(t.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * getWaitQueueLength returns number of waiting threads - */ - public void testGetWaitQueueLength() { - final ReentrantLock lock = new ReentrantLock(); - final Condition c = lock.newCondition(); - Thread t1 = new Thread(new Runnable() { - public void run() { - try { - lock.lock(); - threadAssertFalse(lock.hasWaiters(c)); - threadAssertEquals(0, lock.getWaitQueueLength(c)); - c.await(); - lock.unlock(); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - Thread t2 = new Thread(new Runnable() { - public void run() { - try { - lock.lock(); - threadAssertTrue(lock.hasWaiters(c)); - threadAssertEquals(1, lock.getWaitQueueLength(c)); - c.await(); - lock.unlock(); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - try { - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - lock.lock(); - assertTrue(lock.hasWaiters(c)); - assertEquals(2, lock.getWaitQueueLength(c)); - c.signalAll(); - lock.unlock(); - Thread.sleep(SHORT_DELAY_MS); - lock.lock(); - assertFalse(lock.hasWaiters(c)); - assertEquals(0, lock.getWaitQueueLength(c)); - lock.unlock(); - t1.join(SHORT_DELAY_MS); - t2.join(SHORT_DELAY_MS); - assertFalse(t1.isAlive()); - assertFalse(t2.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * getWaitingThreads returns only and all waiting threads - */ - public void testGetWaitingThreads() { - final PublicReentrantLock lock = new PublicReentrantLock(); - final Condition c = lock.newCondition(); - Thread t1 = new Thread(new Runnable() { - public void run() { - try { - lock.lock(); - threadAssertTrue(lock.getWaitingThreads(c).isEmpty()); - c.await(); - lock.unlock(); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - Thread t2 = new Thread(new Runnable() { - public void run() { - try { - lock.lock(); - threadAssertFalse(lock.getWaitingThreads(c).isEmpty()); - c.await(); - lock.unlock(); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - try { - lock.lock(); - assertTrue(lock.getWaitingThreads(c).isEmpty()); - lock.unlock(); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - lock.lock(); - assertTrue(lock.hasWaiters(c)); - assertTrue(lock.getWaitingThreads(c).contains(t1)); - assertTrue(lock.getWaitingThreads(c).contains(t2)); - c.signalAll(); - lock.unlock(); - Thread.sleep(SHORT_DELAY_MS); - lock.lock(); - assertFalse(lock.hasWaiters(c)); - assertTrue(lock.getWaitingThreads(c).isEmpty()); - lock.unlock(); - t1.join(SHORT_DELAY_MS); - t2.join(SHORT_DELAY_MS); - assertFalse(t1.isAlive()); - assertFalse(t2.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** A helper class for uninterruptible wait tests */ - class UninterruptableThread extends Thread { - private ReentrantLock lock; - private Condition c; - - public volatile boolean canAwake = false; - public volatile boolean interrupted = false; - public volatile boolean lockStarted = false; - - public UninterruptableThread(ReentrantLock lock, Condition c) { - this.lock = lock; - this.c = c; - } - - public synchronized void run() { - lock.lock(); - lockStarted = true; - - while (!canAwake) { - c.awaitUninterruptibly(); - } - - interrupted = isInterrupted(); - lock.unlock(); - } - } - - /** - * awaitUninterruptibly doesn't abort on interrupt - */ - public void testAwaitUninterruptibly() { - final ReentrantLock lock = new ReentrantLock(); - final Condition c = lock.newCondition(); - UninterruptableThread thread = new UninterruptableThread(lock, c); - - try { - thread.start(); - - while (!thread.lockStarted) { - Thread.sleep(100); - } - - lock.lock(); - try { - thread.interrupt(); - thread.canAwake = true; - c.signal(); - } finally { - lock.unlock(); - } - - thread.join(); - assertTrue(thread.interrupted); - assertFalse(thread.isAlive()); - } catch (Exception ex) { - unexpectedException(); - } - } - - /** - * await is interruptible - */ - public void testAwait_Interrupt() { - final ReentrantLock lock = new ReentrantLock(); - final Condition c = lock.newCondition(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - lock.lock(); - c.await(); - lock.unlock(); - threadShouldThrow(); - } - catch(InterruptedException success) { - } - } - }); - - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(SHORT_DELAY_MS); - assertFalse(t.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * awaitNanos is interruptible - */ - public void testAwaitNanos_Interrupt() { - final ReentrantLock lock = new ReentrantLock(); - final Condition c = lock.newCondition(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - lock.lock(); - c.awaitNanos(1000 * 1000 * 1000); // 1 sec - lock.unlock(); - threadShouldThrow(); - } - catch(InterruptedException success) { - } - } - }); - - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(SHORT_DELAY_MS); - assertFalse(t.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * awaitUntil is interruptible - */ - public void testAwaitUntil_Interrupt() { - final ReentrantLock lock = new ReentrantLock(); - final Condition c = lock.newCondition(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - lock.lock(); - java.util.Date d = new java.util.Date(); - c.awaitUntil(new java.util.Date(d.getTime() + 10000)); - lock.unlock(); - threadShouldThrow(); - } - catch(InterruptedException success) { - } - } - }); - - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(SHORT_DELAY_MS); - assertFalse(t.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * signalAll wakes up all threads - */ - public void testSignalAll() { - final ReentrantLock lock = new ReentrantLock(); - final Condition c = lock.newCondition(); - Thread t1 = new Thread(new Runnable() { - public void run() { - try { - lock.lock(); - c.await(); - lock.unlock(); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - Thread t2 = new Thread(new Runnable() { - public void run() { - try { - lock.lock(); - c.await(); - lock.unlock(); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - try { - t1.start(); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - lock.lock(); - c.signalAll(); - lock.unlock(); - t1.join(SHORT_DELAY_MS); - t2.join(SHORT_DELAY_MS); - assertFalse(t1.isAlive()); - assertFalse(t2.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * await after multiple reentrant locking preserves lock count - */ - public void testAwaitLockCount() { - final ReentrantLock lock = new ReentrantLock(); - final Condition c = lock.newCondition(); - Thread t1 = new Thread(new Runnable() { - public void run() { - try { - lock.lock(); - threadAssertEquals(1, lock.getHoldCount()); - c.await(); - threadAssertEquals(1, lock.getHoldCount()); - lock.unlock(); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - Thread t2 = new Thread(new Runnable() { - public void run() { - try { - lock.lock(); - lock.lock(); - threadAssertEquals(2, lock.getHoldCount()); - c.await(); - threadAssertEquals(2, lock.getHoldCount()); - lock.unlock(); - lock.unlock(); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - try { - t1.start(); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - lock.lock(); - c.signalAll(); - lock.unlock(); - t1.join(SHORT_DELAY_MS); - t2.join(SHORT_DELAY_MS); - assertFalse(t1.isAlive()); - assertFalse(t2.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * A serialized lock deserializes as unlocked - */ - public void testSerialization() { - ReentrantLock l = new ReentrantLock(); - l.lock(); - l.unlock(); - - try { - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(l); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - ReentrantLock r = (ReentrantLock) in.readObject(); - r.lock(); - r.unlock(); - } catch(Exception e){ - e.printStackTrace(); - unexpectedException(); - } - } - - /** - * toString indicates current lock state - */ - public void testToString() { - ReentrantLock lock = new ReentrantLock(); - String us = lock.toString(); - assertTrue(us.indexOf("Unlocked") >= 0); - lock.lock(); - String ls = lock.toString(); - assertTrue(ls.indexOf("Locked") >= 0); - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ReentrantReadWriteLockTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ReentrantReadWriteLockTest.java deleted file mode 100644 index e38165ad4..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ReentrantReadWriteLockTest.java +++ /dev/null @@ -1,1662 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.concurrent.locks.*; -import java.util.concurrent.*; -import java.io.*; -import java.util.*; - -public class ReentrantReadWriteLockTest extends JSR166TestCase { - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(ReentrantReadWriteLockTest.class); - } - - /** - * A runnable calling lockInterruptibly - */ - class InterruptibleLockRunnable implements Runnable { - final ReentrantReadWriteLock lock; - InterruptibleLockRunnable(ReentrantReadWriteLock l) { lock = l; } - public void run() { - try { - lock.writeLock().lockInterruptibly(); - } catch(InterruptedException success){} - } - } - - - /** - * A runnable calling lockInterruptibly that expects to be - * interrupted - */ - class InterruptedLockRunnable implements Runnable { - final ReentrantReadWriteLock lock; - InterruptedLockRunnable(ReentrantReadWriteLock l) { lock = l; } - public void run() { - try { - lock.writeLock().lockInterruptibly(); - threadShouldThrow(); - } catch(InterruptedException success){} - } - } - - /** - * Subclass to expose protected methods - */ - static class PublicReentrantReadWriteLock extends ReentrantReadWriteLock { - PublicReentrantReadWriteLock() { super(); } - public Collection getQueuedThreads() { - return super.getQueuedThreads(); - } - public Collection getWaitingThreads(Condition c) { - return super.getWaitingThreads(c); - } - } - - /** - * Constructor sets given fairness, and is in unlocked state - */ - public void testConstructor() { - ReentrantReadWriteLock rl = new ReentrantReadWriteLock(); - assertFalse(rl.isFair()); - assertFalse(rl.isWriteLocked()); - assertEquals(0, rl.getReadLockCount()); - ReentrantReadWriteLock r2 = new ReentrantReadWriteLock(true); - assertTrue(r2.isFair()); - assertFalse(r2.isWriteLocked()); - assertEquals(0, r2.getReadLockCount()); - } - - /** - * write-locking and read-locking an unlocked lock succeed - */ - public void testLock() { - ReentrantReadWriteLock rl = new ReentrantReadWriteLock(); - rl.writeLock().lock(); - assertTrue(rl.isWriteLocked()); - assertTrue(rl.isWriteLockedByCurrentThread()); - assertEquals(0, rl.getReadLockCount()); - rl.writeLock().unlock(); - assertFalse(rl.isWriteLocked()); - assertFalse(rl.isWriteLockedByCurrentThread()); - assertEquals(0, rl.getReadLockCount()); - rl.readLock().lock(); - assertFalse(rl.isWriteLocked()); - assertFalse(rl.isWriteLockedByCurrentThread()); - assertEquals(1, rl.getReadLockCount()); - rl.readLock().unlock(); - assertFalse(rl.isWriteLocked()); - assertFalse(rl.isWriteLockedByCurrentThread()); - assertEquals(0, rl.getReadLockCount()); - } - - - /** - * locking an unlocked fair lock succeeds - */ - public void testFairLock() { - ReentrantReadWriteLock rl = new ReentrantReadWriteLock(true); - rl.writeLock().lock(); - assertTrue(rl.isWriteLocked()); - assertTrue(rl.isWriteLockedByCurrentThread()); - assertEquals(0, rl.getReadLockCount()); - rl.writeLock().unlock(); - assertFalse(rl.isWriteLocked()); - assertFalse(rl.isWriteLockedByCurrentThread()); - assertEquals(0, rl.getReadLockCount()); - rl.readLock().lock(); - assertFalse(rl.isWriteLocked()); - assertFalse(rl.isWriteLockedByCurrentThread()); - assertEquals(1, rl.getReadLockCount()); - rl.readLock().unlock(); - assertFalse(rl.isWriteLocked()); - assertFalse(rl.isWriteLockedByCurrentThread()); - assertEquals(0, rl.getReadLockCount()); - } - - /** - * getWriteHoldCount returns number of recursive holds - */ - public void testGetWriteHoldCount() { - ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - for(int i = 1; i <= SIZE; i++) { - lock.writeLock().lock(); - assertEquals(i,lock.getWriteHoldCount()); - } - for(int i = SIZE; i > 0; i--) { - lock.writeLock().unlock(); - assertEquals(i-1,lock.getWriteHoldCount()); - } - } - - - /** - * write-unlocking an unlocked lock throws IllegalMonitorStateException - */ - public void testUnlock_IllegalMonitorStateException() { - ReentrantReadWriteLock rl = new ReentrantReadWriteLock(); - try { - rl.writeLock().unlock(); - shouldThrow(); - } catch(IllegalMonitorStateException success){} - } - - - /** - * write-lockInterruptibly is interruptible - */ - public void testWriteLockInterruptibly_Interrupted() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - lock.writeLock().lockInterruptibly(); - lock.writeLock().unlock(); - lock.writeLock().lockInterruptibly(); - lock.writeLock().unlock(); - } catch(InterruptedException success){} - } - }); - try { - lock.writeLock().lock(); - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - lock.writeLock().unlock(); - t.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * timed write-tryLock is interruptible - */ - public void testWriteTryLock_Interrupted() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - lock.writeLock().lock(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - lock.writeLock().tryLock(1000,TimeUnit.MILLISECONDS); - } catch(InterruptedException success){} - } - }); - try { - t.start(); - t.interrupt(); - lock.writeLock().unlock(); - t.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * read-lockInterruptibly is interruptible - */ - public void testReadLockInterruptibly_Interrupted() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - lock.writeLock().lock(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - lock.readLock().lockInterruptibly(); - } catch(InterruptedException success){} - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - lock.writeLock().unlock(); - t.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * timed read-tryLock is interruptible - */ - public void testReadTryLock_Interrupted() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - lock.writeLock().lock(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - lock.readLock().tryLock(1000,TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch(InterruptedException success){} - } - }); - try { - t.start(); - t.interrupt(); - t.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * write-tryLock fails if locked - */ - public void testWriteTryLockWhenLocked() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - lock.writeLock().lock(); - Thread t = new Thread(new Runnable() { - public void run() { - threadAssertFalse(lock.writeLock().tryLock()); - } - }); - try { - t.start(); - t.join(); - lock.writeLock().unlock(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * read-tryLock fails if locked - */ - public void testReadTryLockWhenLocked() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - lock.writeLock().lock(); - Thread t = new Thread(new Runnable() { - public void run() { - threadAssertFalse(lock.readLock().tryLock()); - } - }); - try { - t.start(); - t.join(); - lock.writeLock().unlock(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * Multiple threads can hold a read lock when not write-locked - */ - public void testMultipleReadLocks() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - lock.readLock().lock(); - Thread t = new Thread(new Runnable() { - public void run() { - threadAssertTrue(lock.readLock().tryLock()); - lock.readLock().unlock(); - } - }); - try { - t.start(); - t.join(); - lock.readLock().unlock(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * A writelock succeeds after reading threads unlock - */ - public void testWriteAfterMultipleReadLocks() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - lock.readLock().lock(); - Thread t1 = new Thread(new Runnable() { - public void run() { - lock.readLock().lock(); - lock.readLock().unlock(); - } - }); - Thread t2 = new Thread(new Runnable() { - public void run() { - lock.writeLock().lock(); - lock.writeLock().unlock(); - } - }); - - try { - t1.start(); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - lock.readLock().unlock(); - t1.join(MEDIUM_DELAY_MS); - t2.join(MEDIUM_DELAY_MS); - assertTrue(!t1.isAlive()); - assertTrue(!t2.isAlive()); - - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * Readlocks succeed after a writing thread unlocks - */ - public void testReadAfterWriteLock() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - lock.writeLock().lock(); - Thread t1 = new Thread(new Runnable() { - public void run() { - lock.readLock().lock(); - lock.readLock().unlock(); - } - }); - Thread t2 = new Thread(new Runnable() { - public void run() { - lock.readLock().lock(); - lock.readLock().unlock(); - } - }); - - try { - t1.start(); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - lock.writeLock().unlock(); - t1.join(MEDIUM_DELAY_MS); - t2.join(MEDIUM_DELAY_MS); - assertTrue(!t1.isAlive()); - assertTrue(!t2.isAlive()); - - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * Read trylock succeeds if write locked by current thread - */ - public void testReadHoldingWriteLock() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - lock.writeLock().lock(); - assertTrue(lock.readLock().tryLock()); - lock.readLock().unlock(); - lock.writeLock().unlock(); - } - - /** - * Read lock succeeds if write locked by current thread even if - * other threads are waiting for readlock - */ - public void testReadHoldingWriteLock2() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - lock.writeLock().lock(); - Thread t1 = new Thread(new Runnable() { - public void run() { - lock.readLock().lock(); - lock.readLock().unlock(); - } - }); - Thread t2 = new Thread(new Runnable() { - public void run() { - lock.readLock().lock(); - lock.readLock().unlock(); - } - }); - - try { - t1.start(); - t2.start(); - lock.readLock().lock(); - lock.readLock().unlock(); - Thread.sleep(SHORT_DELAY_MS); - lock.readLock().lock(); - lock.readLock().unlock(); - lock.writeLock().unlock(); - t1.join(MEDIUM_DELAY_MS); - t2.join(MEDIUM_DELAY_MS); - assertTrue(!t1.isAlive()); - assertTrue(!t2.isAlive()); - - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * Read lock succeeds if write locked by current thread even if - * other threads are waiting for writelock - */ - public void testReadHoldingWriteLock3() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - lock.writeLock().lock(); - Thread t1 = new Thread(new Runnable() { - public void run() { - lock.writeLock().lock(); - lock.writeLock().unlock(); - } - }); - Thread t2 = new Thread(new Runnable() { - public void run() { - lock.writeLock().lock(); - lock.writeLock().unlock(); - } - }); - - try { - t1.start(); - t2.start(); - lock.readLock().lock(); - lock.readLock().unlock(); - Thread.sleep(SHORT_DELAY_MS); - lock.readLock().lock(); - lock.readLock().unlock(); - lock.writeLock().unlock(); - t1.join(MEDIUM_DELAY_MS); - t2.join(MEDIUM_DELAY_MS); - assertTrue(!t1.isAlive()); - assertTrue(!t2.isAlive()); - - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * Write lock succeeds if write locked by current thread even if - * other threads are waiting for writelock - */ - public void testWriteHoldingWriteLock4() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - lock.writeLock().lock(); - Thread t1 = new Thread(new Runnable() { - public void run() { - lock.writeLock().lock(); - lock.writeLock().unlock(); - } - }); - Thread t2 = new Thread(new Runnable() { - public void run() { - lock.writeLock().lock(); - lock.writeLock().unlock(); - } - }); - - try { - t1.start(); - t2.start(); - lock.writeLock().lock(); - lock.writeLock().unlock(); - Thread.sleep(SHORT_DELAY_MS); - lock.writeLock().lock(); - lock.writeLock().unlock(); - lock.writeLock().unlock(); - t1.join(MEDIUM_DELAY_MS); - t2.join(MEDIUM_DELAY_MS); - assertTrue(!t1.isAlive()); - assertTrue(!t2.isAlive()); - - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * Fair Read trylock succeeds if write locked by current thread - */ - public void testReadHoldingWriteLockFair() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); - lock.writeLock().lock(); - assertTrue(lock.readLock().tryLock()); - lock.readLock().unlock(); - lock.writeLock().unlock(); - } - - /** - * Fair Read lock succeeds if write locked by current thread even if - * other threads are waiting for readlock - */ - public void testReadHoldingWriteLockFair2() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); - lock.writeLock().lock(); - Thread t1 = new Thread(new Runnable() { - public void run() { - lock.readLock().lock(); - lock.readLock().unlock(); - } - }); - Thread t2 = new Thread(new Runnable() { - public void run() { - lock.readLock().lock(); - lock.readLock().unlock(); - } - }); - - try { - t1.start(); - t2.start(); - lock.readLock().lock(); - lock.readLock().unlock(); - Thread.sleep(SHORT_DELAY_MS); - lock.readLock().lock(); - lock.readLock().unlock(); - lock.writeLock().unlock(); - t1.join(MEDIUM_DELAY_MS); - t2.join(MEDIUM_DELAY_MS); - assertTrue(!t1.isAlive()); - assertTrue(!t2.isAlive()); - - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * Fair Read lock succeeds if write locked by current thread even if - * other threads are waiting for writelock - */ - public void testReadHoldingWriteLockFair3() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); - lock.writeLock().lock(); - Thread t1 = new Thread(new Runnable() { - public void run() { - lock.writeLock().lock(); - lock.writeLock().unlock(); - } - }); - Thread t2 = new Thread(new Runnable() { - public void run() { - lock.writeLock().lock(); - lock.writeLock().unlock(); - } - }); - - try { - t1.start(); - t2.start(); - lock.readLock().lock(); - lock.readLock().unlock(); - Thread.sleep(SHORT_DELAY_MS); - lock.readLock().lock(); - lock.readLock().unlock(); - lock.writeLock().unlock(); - t1.join(MEDIUM_DELAY_MS); - t2.join(MEDIUM_DELAY_MS); - assertTrue(!t1.isAlive()); - assertTrue(!t2.isAlive()); - - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * Fair Write lock succeeds if write locked by current thread even if - * other threads are waiting for writelock - */ - public void testWriteHoldingWriteLockFair4() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); - lock.writeLock().lock(); - Thread t1 = new Thread(new Runnable() { - public void run() { - lock.writeLock().lock(); - lock.writeLock().unlock(); - } - }); - Thread t2 = new Thread(new Runnable() { - public void run() { - lock.writeLock().lock(); - lock.writeLock().unlock(); - } - }); - - try { - t1.start(); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.isWriteLockedByCurrentThread()); - assertTrue(lock.getWriteHoldCount() == 1); - lock.writeLock().lock(); - assertTrue(lock.getWriteHoldCount() == 2); - lock.writeLock().unlock(); - lock.writeLock().lock(); - lock.writeLock().unlock(); - lock.writeLock().unlock(); - t1.join(MEDIUM_DELAY_MS); - t2.join(MEDIUM_DELAY_MS); - assertTrue(!t1.isAlive()); - assertTrue(!t2.isAlive()); - - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * Read tryLock succeeds if readlocked but not writelocked - */ - public void testTryLockWhenReadLocked() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - lock.readLock().lock(); - Thread t = new Thread(new Runnable() { - public void run() { - threadAssertTrue(lock.readLock().tryLock()); - lock.readLock().unlock(); - } - }); - try { - t.start(); - t.join(); - lock.readLock().unlock(); - } catch(Exception e){ - unexpectedException(); - } - } - - - - /** - * write tryLock fails when readlocked - */ - public void testWriteTryLockWhenReadLocked() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - lock.readLock().lock(); - Thread t = new Thread(new Runnable() { - public void run() { - threadAssertFalse(lock.writeLock().tryLock()); - } - }); - try { - t.start(); - t.join(); - lock.readLock().unlock(); - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * Fair Read tryLock succeeds if readlocked but not writelocked - */ - public void testTryLockWhenReadLockedFair() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); - lock.readLock().lock(); - Thread t = new Thread(new Runnable() { - public void run() { - threadAssertTrue(lock.readLock().tryLock()); - lock.readLock().unlock(); - } - }); - try { - t.start(); - t.join(); - lock.readLock().unlock(); - } catch(Exception e){ - unexpectedException(); - } - } - - - - /** - * Fair write tryLock fails when readlocked - */ - public void testWriteTryLockWhenReadLockedFair() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); - lock.readLock().lock(); - Thread t = new Thread(new Runnable() { - public void run() { - threadAssertFalse(lock.writeLock().tryLock()); - } - }); - try { - t.start(); - t.join(); - lock.readLock().unlock(); - } catch(Exception e){ - unexpectedException(); - } - } - - - - /** - * write timed tryLock times out if locked - */ - public void testWriteTryLock_Timeout() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - lock.writeLock().lock(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertFalse(lock.writeLock().tryLock(1, TimeUnit.MILLISECONDS)); - } catch (Exception ex) { - threadUnexpectedException(); - } - } - }); - try { - t.start(); - t.join(); - lock.writeLock().unlock(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * read timed tryLock times out if write-locked - */ - public void testReadTryLock_Timeout() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - lock.writeLock().lock(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertFalse(lock.readLock().tryLock(1, TimeUnit.MILLISECONDS)); - } catch (Exception ex) { - threadUnexpectedException(); - } - } - }); - try { - t.start(); - t.join(); - lock.writeLock().unlock(); - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * write lockInterruptibly succeeds if lock free else is interruptible - */ - public void testWriteLockInterruptibly() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - try { - lock.writeLock().lockInterruptibly(); - } catch(Exception e) { - unexpectedException(); - } - Thread t = new Thread(new Runnable() { - public void run() { - try { - lock.writeLock().lockInterruptibly(); - threadShouldThrow(); - } - catch(InterruptedException success) { - } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - t.join(); - lock.writeLock().unlock(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * read lockInterruptibly succeeds if lock free else is interruptible - */ - public void testReadLockInterruptibly() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - try { - lock.writeLock().lockInterruptibly(); - } catch(Exception e) { - unexpectedException(); - } - Thread t = new Thread(new Runnable() { - public void run() { - try { - lock.readLock().lockInterruptibly(); - threadShouldThrow(); - } - catch(InterruptedException success) { - } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - lock.writeLock().unlock(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * Calling await without holding lock throws IllegalMonitorStateException - */ - public void testAwait_IllegalMonitor() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - final Condition c = lock.writeLock().newCondition(); - try { - c.await(); - shouldThrow(); - } - catch (IllegalMonitorStateException success) { - } - catch (Exception ex) { - shouldThrow(); - } - } - - /** - * Calling signal without holding lock throws IllegalMonitorStateException - */ - public void testSignal_IllegalMonitor() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - final Condition c = lock.writeLock().newCondition(); - try { - c.signal(); - shouldThrow(); - } - catch (IllegalMonitorStateException success) { - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * awaitNanos without a signal times out - */ - public void testAwaitNanos_Timeout() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - final Condition c = lock.writeLock().newCondition(); - try { - lock.writeLock().lock(); - long t = c.awaitNanos(100); - assertTrue(t <= 0); - lock.writeLock().unlock(); - } - catch (Exception ex) { - unexpectedException(); - } - } - - - /** - * timed await without a signal times out - */ - public void testAwait_Timeout() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - final Condition c = lock.writeLock().newCondition(); - try { - lock.writeLock().lock(); - lock.writeLock().unlock(); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * awaitUntil without a signal times out - */ - public void testAwaitUntil_Timeout() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - final Condition c = lock.writeLock().newCondition(); - try { - lock.writeLock().lock(); - java.util.Date d = new java.util.Date(); - lock.writeLock().unlock(); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * await returns when signalled - */ - public void testAwait() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - final Condition c = lock.writeLock().newCondition(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - lock.writeLock().lock(); - c.await(); - lock.writeLock().unlock(); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - lock.writeLock().lock(); - c.signal(); - lock.writeLock().unlock(); - t.join(SHORT_DELAY_MS); - assertFalse(t.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** A helper class for uninterruptible wait tests */ - class UninterruptableThread extends Thread { - private Lock lock; - private Condition c; - - public volatile boolean canAwake = false; - public volatile boolean interrupted = false; - public volatile boolean lockStarted = false; - - public UninterruptableThread(Lock lock, Condition c) { - this.lock = lock; - this.c = c; - } - - public synchronized void run() { - lock.lock(); - lockStarted = true; - - while (!canAwake) { - c.awaitUninterruptibly(); - } - - interrupted = isInterrupted(); - lock.unlock(); - } - } - - /** - * awaitUninterruptibly doesn't abort on interrupt - */ - public void testAwaitUninterruptibly() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - final Condition c = lock.writeLock().newCondition(); - UninterruptableThread thread = new UninterruptableThread(lock.writeLock(), c); - - try { - thread.start(); - - while (!thread.lockStarted) { - Thread.sleep(100); - } - - lock.writeLock().lock(); - try { - thread.interrupt(); - thread.canAwake = true; - c.signal(); - } finally { - lock.writeLock().unlock(); - } - - thread.join(); - assertTrue(thread.interrupted); - assertFalse(thread.isAlive()); - } catch (Exception ex) { - unexpectedException(); - } - } - - /** - * await is interruptible - */ - public void testAwait_Interrupt() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - final Condition c = lock.writeLock().newCondition(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - lock.writeLock().lock(); - c.await(); - lock.writeLock().unlock(); - threadShouldThrow(); - } - catch(InterruptedException success) { - } - } - }); - - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(SHORT_DELAY_MS); - assertFalse(t.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * awaitNanos is interruptible - */ - public void testAwaitNanos_Interrupt() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - final Condition c = lock.writeLock().newCondition(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - lock.writeLock().lock(); - c.awaitNanos(SHORT_DELAY_MS * 2 * 1000000); - lock.writeLock().unlock(); - threadShouldThrow(); - } - catch(InterruptedException success) { - } - } - }); - - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(SHORT_DELAY_MS); - assertFalse(t.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * awaitUntil is interruptible - */ - public void testAwaitUntil_Interrupt() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - final Condition c = lock.writeLock().newCondition(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - lock.writeLock().lock(); - java.util.Date d = new java.util.Date(); - c.awaitUntil(new java.util.Date(d.getTime() + 10000)); - lock.writeLock().unlock(); - threadShouldThrow(); - } - catch(InterruptedException success) { - } - } - }); - - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(SHORT_DELAY_MS); - assertFalse(t.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * signalAll wakes up all threads - */ - public void testSignalAll() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - final Condition c = lock.writeLock().newCondition(); - Thread t1 = new Thread(new Runnable() { - public void run() { - try { - lock.writeLock().lock(); - c.await(); - lock.writeLock().unlock(); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - Thread t2 = new Thread(new Runnable() { - public void run() { - try { - lock.writeLock().lock(); - c.await(); - lock.writeLock().unlock(); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - try { - t1.start(); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - lock.writeLock().lock(); - c.signalAll(); - lock.writeLock().unlock(); - t1.join(SHORT_DELAY_MS); - t2.join(SHORT_DELAY_MS); - assertFalse(t1.isAlive()); - assertFalse(t2.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * A serialized lock deserializes as unlocked - */ - public void testSerialization() { - ReentrantReadWriteLock l = new ReentrantReadWriteLock(); - l.readLock().lock(); - l.readLock().unlock(); - - try { - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(l); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - ReentrantReadWriteLock r = (ReentrantReadWriteLock) in.readObject(); - r.readLock().lock(); - r.readLock().unlock(); - } catch(Exception e){ - e.printStackTrace(); - unexpectedException(); - } - } - - /** - * hasQueuedThreads reports whether there are waiting threads - */ - public void testhasQueuedThreads() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - Thread t1 = new Thread(new InterruptedLockRunnable(lock)); - Thread t2 = new Thread(new InterruptibleLockRunnable(lock)); - try { - assertFalse(lock.hasQueuedThreads()); - lock.writeLock().lock(); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.hasQueuedThreads()); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.hasQueuedThreads()); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.hasQueuedThreads()); - lock.writeLock().unlock(); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(lock.hasQueuedThreads()); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * hasQueuedThread(null) throws NPE - */ - public void testHasQueuedThreadNPE() { - final ReentrantReadWriteLock sync = new ReentrantReadWriteLock(); - try { - sync.hasQueuedThread(null); - shouldThrow(); - } catch (NullPointerException success) { - } - } - - /** - * hasQueuedThread reports whether a thread is queued. - */ - public void testHasQueuedThread() { - final ReentrantReadWriteLock sync = new ReentrantReadWriteLock(); - Thread t1 = new Thread(new InterruptedLockRunnable(sync)); - Thread t2 = new Thread(new InterruptibleLockRunnable(sync)); - try { - assertFalse(sync.hasQueuedThread(t1)); - assertFalse(sync.hasQueuedThread(t2)); - sync.writeLock().lock(); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.hasQueuedThread(t1)); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(sync.hasQueuedThread(t1)); - assertTrue(sync.hasQueuedThread(t2)); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(sync.hasQueuedThread(t1)); - assertTrue(sync.hasQueuedThread(t2)); - sync.writeLock().unlock(); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(sync.hasQueuedThread(t1)); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(sync.hasQueuedThread(t2)); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * getQueueLength reports number of waiting threads - */ - public void testGetQueueLength() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - Thread t1 = new Thread(new InterruptedLockRunnable(lock)); - Thread t2 = new Thread(new InterruptibleLockRunnable(lock)); - try { - assertEquals(0, lock.getQueueLength()); - lock.writeLock().lock(); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(1, lock.getQueueLength()); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(2, lock.getQueueLength()); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(1, lock.getQueueLength()); - lock.writeLock().unlock(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(0, lock.getQueueLength()); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * getQueuedThreads includes waiting threads - */ - public void testGetQueuedThreads() { - final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock(); - Thread t1 = new Thread(new InterruptedLockRunnable(lock)); - Thread t2 = new Thread(new InterruptibleLockRunnable(lock)); - try { - assertTrue(lock.getQueuedThreads().isEmpty()); - lock.writeLock().lock(); - assertTrue(lock.getQueuedThreads().isEmpty()); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.getQueuedThreads().contains(t1)); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.getQueuedThreads().contains(t1)); - assertTrue(lock.getQueuedThreads().contains(t2)); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(lock.getQueuedThreads().contains(t1)); - assertTrue(lock.getQueuedThreads().contains(t2)); - lock.writeLock().unlock(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.getQueuedThreads().isEmpty()); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * hasWaiters throws NPE if null - */ - public void testHasWaitersNPE() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - try { - lock.hasWaiters(null); - shouldThrow(); - } catch (NullPointerException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - /** - * getWaitQueueLength throws NPE if null - */ - public void testGetWaitQueueLengthNPE() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - try { - lock.getWaitQueueLength(null); - shouldThrow(); - } catch (NullPointerException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - - /** - * getWaitingThreads throws NPE if null - */ - public void testGetWaitingThreadsNPE() { - final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock(); - try { - lock.getWaitingThreads(null); - shouldThrow(); - } catch (NullPointerException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - /** - * hasWaiters throws IAE if not owned - */ - public void testHasWaitersIAE() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - final Condition c = (lock.writeLock().newCondition()); - final ReentrantReadWriteLock lock2 = new ReentrantReadWriteLock(); - try { - lock2.hasWaiters(c); - shouldThrow(); - } catch (IllegalArgumentException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - /** - * hasWaiters throws IMSE if not locked - */ - public void testHasWaitersIMSE() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - final Condition c = (lock.writeLock().newCondition()); - try { - lock.hasWaiters(c); - shouldThrow(); - } catch (IllegalMonitorStateException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - - /** - * getWaitQueueLength throws IAE if not owned - */ - public void testGetWaitQueueLengthIAE() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - final Condition c = (lock.writeLock().newCondition()); - final ReentrantReadWriteLock lock2 = new ReentrantReadWriteLock(); - try { - lock2.getWaitQueueLength(c); - shouldThrow(); - } catch (IllegalArgumentException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - /** - * getWaitQueueLength throws IMSE if not locked - */ - public void testGetWaitQueueLengthIMSE() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - final Condition c = (lock.writeLock().newCondition()); - try { - lock.getWaitQueueLength(c); - shouldThrow(); - } catch (IllegalMonitorStateException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - - /** - * getWaitingThreads throws IAE if not owned - */ - public void testGetWaitingThreadsIAE() { - final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock(); - final Condition c = (lock.writeLock().newCondition()); - final PublicReentrantReadWriteLock lock2 = new PublicReentrantReadWriteLock(); - try { - lock2.getWaitingThreads(c); - shouldThrow(); - } catch (IllegalArgumentException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - /** - * getWaitingThreads throws IMSE if not locked - */ - public void testGetWaitingThreadsIMSE() { - final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock(); - final Condition c = (lock.writeLock().newCondition()); - try { - lock.getWaitingThreads(c); - shouldThrow(); - } catch (IllegalMonitorStateException success) { - } catch (Exception ex) { - unexpectedException(); - } - } - - - /** - * hasWaiters returns true when a thread is waiting, else false - */ - public void testHasWaiters() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - final Condition c = (lock.writeLock().newCondition()); - Thread t = new Thread(new Runnable() { - public void run() { - try { - lock.writeLock().lock(); - threadAssertFalse(lock.hasWaiters(c)); - threadAssertEquals(0, lock.getWaitQueueLength(c)); - c.await(); - lock.writeLock().unlock(); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - lock.writeLock().lock(); - assertTrue(lock.hasWaiters(c)); - assertEquals(1, lock.getWaitQueueLength(c)); - c.signal(); - lock.writeLock().unlock(); - Thread.sleep(SHORT_DELAY_MS); - lock.writeLock().lock(); - assertFalse(lock.hasWaiters(c)); - assertEquals(0, lock.getWaitQueueLength(c)); - lock.writeLock().unlock(); - t.join(SHORT_DELAY_MS); - assertFalse(t.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * getWaitQueueLength returns number of waiting threads - */ - public void testGetWaitQueueLength() { - final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - final Condition c = (lock.writeLock().newCondition()); - Thread t = new Thread(new Runnable() { - public void run() { - try { - lock.writeLock().lock(); - threadAssertFalse(lock.hasWaiters(c)); - threadAssertEquals(0, lock.getWaitQueueLength(c)); - c.await(); - lock.writeLock().unlock(); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - lock.writeLock().lock(); - assertTrue(lock.hasWaiters(c)); - assertEquals(1, lock.getWaitQueueLength(c)); - c.signal(); - lock.writeLock().unlock(); - Thread.sleep(SHORT_DELAY_MS); - lock.writeLock().lock(); - assertFalse(lock.hasWaiters(c)); - assertEquals(0, lock.getWaitQueueLength(c)); - lock.writeLock().unlock(); - t.join(SHORT_DELAY_MS); - assertFalse(t.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - - /** - * getWaitingThreads returns only and all waiting threads - */ - public void testGetWaitingThreads() { - final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock(); - final Condition c = lock.writeLock().newCondition(); - Thread t1 = new Thread(new Runnable() { - public void run() { - try { - lock.writeLock().lock(); - threadAssertTrue(lock.getWaitingThreads(c).isEmpty()); - c.await(); - lock.writeLock().unlock(); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - Thread t2 = new Thread(new Runnable() { - public void run() { - try { - lock.writeLock().lock(); - threadAssertFalse(lock.getWaitingThreads(c).isEmpty()); - c.await(); - lock.writeLock().unlock(); - } - catch(InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - try { - lock.writeLock().lock(); - assertTrue(lock.getWaitingThreads(c).isEmpty()); - lock.writeLock().unlock(); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - lock.writeLock().lock(); - assertTrue(lock.hasWaiters(c)); - assertTrue(lock.getWaitingThreads(c).contains(t1)); - assertTrue(lock.getWaitingThreads(c).contains(t2)); - c.signalAll(); - lock.writeLock().unlock(); - Thread.sleep(SHORT_DELAY_MS); - lock.writeLock().lock(); - assertFalse(lock.hasWaiters(c)); - assertTrue(lock.getWaitingThreads(c).isEmpty()); - lock.writeLock().unlock(); - t1.join(SHORT_DELAY_MS); - t2.join(SHORT_DELAY_MS); - assertFalse(t1.isAlive()); - assertFalse(t2.isAlive()); - } - catch (Exception ex) { - unexpectedException(); - } - } - - /** - * toString indicates current lock state - */ - public void testToString() { - ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - String us = lock.toString(); - assertTrue(us.indexOf("Write locks = 0") >= 0); - assertTrue(us.indexOf("Read locks = 0") >= 0); - lock.writeLock().lock(); - String ws = lock.toString(); - assertTrue(ws.indexOf("Write locks = 1") >= 0); - assertTrue(ws.indexOf("Read locks = 0") >= 0); - lock.writeLock().unlock(); - lock.readLock().lock(); - lock.readLock().lock(); - String rs = lock.toString(); - assertTrue(rs.indexOf("Write locks = 0") >= 0); - assertTrue(rs.indexOf("Read locks = 2") >= 0); - } - - /** - * readLock.toString indicates current lock state - */ - public void testReadLockToString() { - ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - String us = lock.readLock().toString(); - assertTrue(us.indexOf("Read locks = 0") >= 0); - lock.readLock().lock(); - lock.readLock().lock(); - String rs = lock.readLock().toString(); - assertTrue(rs.indexOf("Read locks = 2") >= 0); - } - - /** - * writeLock.toString indicates current lock state - */ - public void testWriteLockToString() { - ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - String us = lock.writeLock().toString(); - assertTrue(us.indexOf("Unlocked") >= 0); - lock.writeLock().lock(); - String ls = lock.writeLock().toString(); - assertTrue(ls.indexOf("Locked") >= 0); - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ScheduledExecutorTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ScheduledExecutorTest.java deleted file mode 100755 index da5704ef4..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ScheduledExecutorTest.java +++ /dev/null @@ -1,1149 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; - -public class ScheduledExecutorTest extends JSR166TestCase { - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(ScheduledExecutorTest.class); - } - - - /** - * execute successfully executes a runnable - */ - public void testExecute() { - try { - TrackedShortRunnable runnable =new TrackedShortRunnable(); - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - p1.execute(runnable); - assertFalse(runnable.done); - Thread.sleep(SHORT_DELAY_MS); - try { p1.shutdown(); } catch(SecurityException ok) { return; } - try { - Thread.sleep(MEDIUM_DELAY_MS); - } catch(InterruptedException e){ - unexpectedException(); - } - assertTrue(runnable.done); - try { p1.shutdown(); } catch(SecurityException ok) { return; } - joinPool(p1); - } - catch(Exception e){ - unexpectedException(); - } - - } - - - /** - * delayed schedule of callable successfully executes after delay - */ - public void testSchedule1() { - try { - TrackedCallable callable = new TrackedCallable(); - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - Future f = p1.schedule(callable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - assertFalse(callable.done); - Thread.sleep(MEDIUM_DELAY_MS); - assertTrue(callable.done); - assertEquals(Boolean.TRUE, f.get()); - try { p1.shutdown(); } catch(SecurityException ok) { return; } - joinPool(p1); - } catch(RejectedExecutionException e){} - catch(Exception e){ - e.printStackTrace(); - unexpectedException(); - } - } - - /** - * delayed schedule of runnable successfully executes after delay - */ - public void testSchedule3() { - try { - TrackedShortRunnable runnable = new TrackedShortRunnable(); - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - p1.schedule(runnable, SMALL_DELAY_MS, TimeUnit.MILLISECONDS); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(runnable.done); - Thread.sleep(MEDIUM_DELAY_MS); - assertTrue(runnable.done); - try { p1.shutdown(); } catch(SecurityException ok) { return; } - joinPool(p1); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * scheduleAtFixedRate executes runnable after given initial delay - */ - public void testSchedule4() { - try { - TrackedShortRunnable runnable = new TrackedShortRunnable(); - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - ScheduledFuture h = p1.scheduleAtFixedRate(runnable, SHORT_DELAY_MS, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - assertFalse(runnable.done); - Thread.sleep(MEDIUM_DELAY_MS); - assertTrue(runnable.done); - h.cancel(true); - joinPool(p1); - } catch(Exception e){ - unexpectedException(); - } - } - - static class RunnableCounter implements Runnable { - AtomicInteger count = new AtomicInteger(0); - public void run() { count.getAndIncrement(); } - } - - /** - * scheduleWithFixedDelay executes runnable after given initial delay - */ - public void testSchedule5() { - try { - TrackedShortRunnable runnable = new TrackedShortRunnable(); - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - ScheduledFuture h = p1.scheduleWithFixedDelay(runnable, SHORT_DELAY_MS, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - assertFalse(runnable.done); - Thread.sleep(MEDIUM_DELAY_MS); - assertTrue(runnable.done); - h.cancel(true); - joinPool(p1); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * scheduleAtFixedRate executes series of tasks at given rate - */ - public void testFixedRateSequence() { - try { - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - RunnableCounter counter = new RunnableCounter(); - ScheduledFuture h = - p1.scheduleAtFixedRate(counter, 0, 1, TimeUnit.MILLISECONDS); - Thread.sleep(SMALL_DELAY_MS); - h.cancel(true); - int c = counter.count.get(); - // By time scaling conventions, we must have at least - // an execution per SHORT delay, but no more than one SHORT more - assertTrue(c >= SMALL_DELAY_MS / SHORT_DELAY_MS); - assertTrue(c <= SMALL_DELAY_MS + SHORT_DELAY_MS); - joinPool(p1); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * scheduleWithFixedDelay executes series of tasks with given period - */ - public void testFixedDelaySequence() { - try { - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - RunnableCounter counter = new RunnableCounter(); - ScheduledFuture h = - p1.scheduleWithFixedDelay(counter, 0, 1, TimeUnit.MILLISECONDS); - Thread.sleep(SMALL_DELAY_MS); - h.cancel(true); - int c = counter.count.get(); - assertTrue(c >= SMALL_DELAY_MS / SHORT_DELAY_MS); - assertTrue(c <= SMALL_DELAY_MS + SHORT_DELAY_MS); - joinPool(p1); - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * execute (null) throws NPE - */ - public void testExecuteNull() { - ScheduledThreadPoolExecutor se = null; - try { - se = new ScheduledThreadPoolExecutor(1); - se.execute(null); - shouldThrow(); - } catch(NullPointerException success){} - catch(Exception e){ - unexpectedException(); - } - - joinPool(se); - } - - /** - * schedule (null) throws NPE - */ - public void testScheduleNull() { - ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1); - try { - TrackedCallable callable = null; - Future f = se.schedule(callable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - shouldThrow(); - } catch(NullPointerException success){} - catch(Exception e){ - unexpectedException(); - } - joinPool(se); - } - - /** - * execute throws RejectedExecutionException if shutdown - */ - public void testSchedule1_RejectedExecutionException() { - ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1); - try { - se.shutdown(); - se.schedule(new NoOpRunnable(), - MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - shouldThrow(); - } catch(RejectedExecutionException success){ - } catch (SecurityException ok) { - } - - joinPool(se); - - } - - /** - * schedule throws RejectedExecutionException if shutdown - */ - public void testSchedule2_RejectedExecutionException() { - ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1); - try { - se.shutdown(); - se.schedule(new NoOpCallable(), - MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - shouldThrow(); - } catch(RejectedExecutionException success){ - } catch (SecurityException ok) { - } - joinPool(se); - } - - /** - * schedule callable throws RejectedExecutionException if shutdown - */ - public void testSchedule3_RejectedExecutionException() { - ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1); - try { - se.shutdown(); - se.schedule(new NoOpCallable(), - MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - shouldThrow(); - } catch(RejectedExecutionException success){ - } catch (SecurityException ok) { - } - joinPool(se); - } - - /** - * scheduleAtFixedRate throws RejectedExecutionException if shutdown - */ - public void testScheduleAtFixedRate1_RejectedExecutionException() { - ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1); - try { - se.shutdown(); - se.scheduleAtFixedRate(new NoOpRunnable(), - MEDIUM_DELAY_MS, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - shouldThrow(); - } catch(RejectedExecutionException success){ - } catch (SecurityException ok) { - } - joinPool(se); - } - - /** - * scheduleWithFixedDelay throws RejectedExecutionException if shutdown - */ - public void testScheduleWithFixedDelay1_RejectedExecutionException() { - ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1); - try { - se.shutdown(); - se.scheduleWithFixedDelay(new NoOpRunnable(), - MEDIUM_DELAY_MS, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - shouldThrow(); - } catch(RejectedExecutionException success){ - } catch (SecurityException ok) { - } - joinPool(se); - } - - /** - * getActiveCount increases but doesn't overestimate, when a - * thread becomes active - */ - public void testGetActiveCount() { - ScheduledThreadPoolExecutor p2 = new ScheduledThreadPoolExecutor(2); - assertEquals(0, p2.getActiveCount()); - p2.execute(new SmallRunnable()); - try { - Thread.sleep(SHORT_DELAY_MS); - } catch(Exception e){ - unexpectedException(); - } - assertEquals(1, p2.getActiveCount()); - joinPool(p2); - } - - /** - * getCompletedTaskCount increases, but doesn't overestimate, - * when tasks complete - */ - public void testGetCompletedTaskCount() { - ScheduledThreadPoolExecutor p2 = new ScheduledThreadPoolExecutor(2); - assertEquals(0, p2.getCompletedTaskCount()); - p2.execute(new SmallRunnable()); - try { - Thread.sleep(MEDIUM_DELAY_MS); - } catch(Exception e){ - unexpectedException(); - } - assertEquals(1, p2.getCompletedTaskCount()); - joinPool(p2); - } - - /** - * getCorePoolSize returns size given in constructor if not otherwise set - */ - public void testGetCorePoolSize() { - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - assertEquals(1, p1.getCorePoolSize()); - joinPool(p1); - } - - /** - * getLargestPoolSize increases, but doesn't overestimate, when - * multiple threads active - */ - public void testGetLargestPoolSize() { - ScheduledThreadPoolExecutor p2 = new ScheduledThreadPoolExecutor(2); - assertEquals(0, p2.getLargestPoolSize()); - p2.execute(new SmallRunnable()); - p2.execute(new SmallRunnable()); - try { - Thread.sleep(SHORT_DELAY_MS); - } catch(Exception e){ - unexpectedException(); - } - assertEquals(2, p2.getLargestPoolSize()); - joinPool(p2); - } - - /** - * getPoolSize increases, but doesn't overestimate, when threads - * become active - */ - public void testGetPoolSize() { - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - assertEquals(0, p1.getPoolSize()); - p1.execute(new SmallRunnable()); - assertEquals(1, p1.getPoolSize()); - joinPool(p1); - } - - /** - * getTaskCount increases, but doesn't overestimate, when tasks - * submitted - */ - public void testGetTaskCount() { - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - assertEquals(0, p1.getTaskCount()); - for(int i = 0; i < 5; i++) - p1.execute(new SmallRunnable()); - try { - Thread.sleep(SHORT_DELAY_MS); - } catch(Exception e){ - unexpectedException(); - } - assertEquals(5, p1.getTaskCount()); - joinPool(p1); - } - - /** - * getThreadFactory returns factory in constructor if not set - */ - public void testGetThreadFactory() { - ThreadFactory tf = new SimpleThreadFactory(); - ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1, tf); - assertSame(tf, p.getThreadFactory()); - joinPool(p); - } - - /** - * setThreadFactory sets the thread factory returned by getThreadFactory - */ - public void testSetThreadFactory() { - ThreadFactory tf = new SimpleThreadFactory(); - ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1); - p.setThreadFactory(tf); - assertSame(tf, p.getThreadFactory()); - joinPool(p); - } - - /** - * setThreadFactory(null) throws NPE - */ - public void testSetThreadFactoryNull() { - ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1); - try { - p.setThreadFactory(null); - shouldThrow(); - } catch (NullPointerException success) { - } finally { - joinPool(p); - } - } - - /** - * is isShutDown is false before shutdown, true after - */ - public void testIsShutdown() { - - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - try { - assertFalse(p1.isShutdown()); - } - finally { - try { p1.shutdown(); } catch(SecurityException ok) { return; } - } - assertTrue(p1.isShutdown()); - } - - - /** - * isTerminated is false before termination, true after - */ - public void testIsTerminated() { - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - try { - p1.execute(new SmallRunnable()); - } finally { - try { p1.shutdown(); } catch(SecurityException ok) { return; } - } - try { - assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); - assertTrue(p1.isTerminated()); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * isTerminating is not true when running or when terminated - */ - public void testIsTerminating() { - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - assertFalse(p1.isTerminating()); - try { - p1.execute(new SmallRunnable()); - assertFalse(p1.isTerminating()); - } finally { - try { p1.shutdown(); } catch(SecurityException ok) { return; } - } - try { - assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); - assertTrue(p1.isTerminated()); - assertFalse(p1.isTerminating()); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * getQueue returns the work queue, which contains queued tasks - */ - public void testGetQueue() { - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - ScheduledFuture[] tasks = new ScheduledFuture[5]; - for(int i = 0; i < 5; i++){ - tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), 1, TimeUnit.MILLISECONDS); - } - try { - Thread.sleep(SHORT_DELAY_MS); - BlockingQueue q = p1.getQueue(); - assertTrue(q.contains(tasks[4])); - assertFalse(q.contains(tasks[0])); - } catch(Exception e) { - unexpectedException(); - } finally { - joinPool(p1); - } - } - - /** - * remove(task) removes queued task, and fails to remove active task - */ - public void testRemove() { - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - ScheduledFuture[] tasks = new ScheduledFuture[5]; - for(int i = 0; i < 5; i++){ - tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), 1, TimeUnit.MILLISECONDS); - } - try { - Thread.sleep(SHORT_DELAY_MS); - BlockingQueue q = p1.getQueue(); - assertFalse(p1.remove((Runnable)tasks[0])); - assertTrue(q.contains((Runnable)tasks[4])); - assertTrue(q.contains((Runnable)tasks[3])); - assertTrue(p1.remove((Runnable)tasks[4])); - assertFalse(p1.remove((Runnable)tasks[4])); - assertFalse(q.contains((Runnable)tasks[4])); - assertTrue(q.contains((Runnable)tasks[3])); - assertTrue(p1.remove((Runnable)tasks[3])); - assertFalse(q.contains((Runnable)tasks[3])); - } catch(Exception e) { - unexpectedException(); - } finally { - joinPool(p1); - } - } - - /** - * purge removes cancelled tasks from the queue - */ - public void testPurge() { - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - ScheduledFuture[] tasks = new ScheduledFuture[5]; - for(int i = 0; i < 5; i++){ - tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - } - try { - int max = 5; - if (tasks[4].cancel(true)) --max; - if (tasks[3].cancel(true)) --max; - // There must eventually be an interference-free point at - // which purge will not fail. (At worst, when queue is empty.) - int k; - for (k = 0; k < SMALL_DELAY_MS; ++k) { - p1.purge(); - long count = p1.getTaskCount(); - if (count >= 0 && count <= max) - break; - Thread.sleep(1); - } - assertTrue(k < SMALL_DELAY_MS); - } catch(Exception e) { - unexpectedException(); - } finally { - joinPool(p1); - } - } - - /** - * shutDownNow returns a list containing tasks that were not run - */ - public void testShutDownNow() { - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - for(int i = 0; i < 5; i++) - p1.schedule(new SmallPossiblyInterruptedRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - List l; - try { - l = p1.shutdownNow(); - } catch (SecurityException ok) { - return; - } - assertTrue(p1.isShutdown()); - assertTrue(l.size() > 0 && l.size() <= 5); - joinPool(p1); - } - - /** - * In default setting, shutdown cancels periodic but not delayed - * tasks at shutdown - */ - public void testShutDown1() { - try { - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - assertTrue(p1.getExecuteExistingDelayedTasksAfterShutdownPolicy()); - assertFalse(p1.getContinueExistingPeriodicTasksAfterShutdownPolicy()); - - ScheduledFuture[] tasks = new ScheduledFuture[5]; - for(int i = 0; i < 5; i++) - tasks[i] = p1.schedule(new NoOpRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - try { p1.shutdown(); } catch(SecurityException ok) { return; } - BlockingQueue q = p1.getQueue(); - for (Iterator it = q.iterator(); it.hasNext();) { - ScheduledFuture t = (ScheduledFuture)it.next(); - assertFalse(t.isCancelled()); - } - assertTrue(p1.isShutdown()); - Thread.sleep(SMALL_DELAY_MS); - for (int i = 0; i < 5; ++i) { - assertTrue(tasks[i].isDone()); - assertFalse(tasks[i].isCancelled()); - } - - } - catch(Exception ex) { - unexpectedException(); - } - } - - - /** - * If setExecuteExistingDelayedTasksAfterShutdownPolicy is false, - * delayed tasks are cancelled at shutdown - */ - public void testShutDown2() { - try { - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - p1.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); - ScheduledFuture[] tasks = new ScheduledFuture[5]; - for(int i = 0; i < 5; i++) - tasks[i] = p1.schedule(new NoOpRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - try { p1.shutdown(); } catch(SecurityException ok) { return; } - assertTrue(p1.isShutdown()); - BlockingQueue q = p1.getQueue(); - assertTrue(q.isEmpty()); - Thread.sleep(SMALL_DELAY_MS); - assertTrue(p1.isTerminated()); - } - catch(Exception ex) { - unexpectedException(); - } - } - - - /** - * If setContinueExistingPeriodicTasksAfterShutdownPolicy is set false, - * periodic tasks are not cancelled at shutdown - */ - public void testShutDown3() { - try { - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - p1.setContinueExistingPeriodicTasksAfterShutdownPolicy(false); - ScheduledFuture task = - p1.scheduleAtFixedRate(new NoOpRunnable(), 5, 5, TimeUnit.MILLISECONDS); - try { p1.shutdown(); } catch(SecurityException ok) { return; } - assertTrue(p1.isShutdown()); - BlockingQueue q = p1.getQueue(); - assertTrue(q.isEmpty()); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(p1.isTerminated()); - } - catch(Exception ex) { - unexpectedException(); - } - } - - /** - * if setContinueExistingPeriodicTasksAfterShutdownPolicy is true, - * periodic tasks are cancelled at shutdown - */ - public void testShutDown4() { - ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); - try { - p1.setContinueExistingPeriodicTasksAfterShutdownPolicy(true); - ScheduledFuture task = - p1.scheduleAtFixedRate(new NoOpRunnable(), 1, 1, TimeUnit.MILLISECONDS); - assertFalse(task.isCancelled()); - try { p1.shutdown(); } catch(SecurityException ok) { return; } - assertFalse(task.isCancelled()); - assertFalse(p1.isTerminated()); - assertTrue(p1.isShutdown()); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(task.isCancelled()); - assertTrue(task.cancel(true)); - assertTrue(task.isDone()); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(p1.isTerminated()); - } - catch(Exception ex) { - unexpectedException(); - } - finally { - joinPool(p1); - } - } - - /** - * completed submit of callable returns result - */ - public void testSubmitCallable() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - Future future = e.submit(new StringTask()); - String result = future.get(); - assertSame(TEST_STRING, result); - } - catch (ExecutionException ex) { - unexpectedException(); - } - catch (InterruptedException ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * completed submit of runnable returns successfully - */ - public void testSubmitRunnable() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - Future future = e.submit(new NoOpRunnable()); - future.get(); - assertTrue(future.isDone()); - } - catch (ExecutionException ex) { - unexpectedException(); - } - catch (InterruptedException ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * completed submit of (runnable, result) returns result - */ - public void testSubmitRunnable2() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - Future future = e.submit(new NoOpRunnable(), TEST_STRING); - String result = future.get(); - assertSame(TEST_STRING, result); - } - catch (ExecutionException ex) { - unexpectedException(); - } - catch (InterruptedException ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAny(null) throws NPE - */ - public void testInvokeAny1() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - e.invokeAny(null); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAny(empty collection) throws IAE - */ - public void testInvokeAny2() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - e.invokeAny(new ArrayList>()); - } catch (IllegalArgumentException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAny(c) throws NPE if c has null elements - */ - public void testInvokeAny3() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(null); - e.invokeAny(l); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAny(c) throws ExecutionException if no task completes - */ - public void testInvokeAny4() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - ArrayList> l = new ArrayList>(); - l.add(new NPETask()); - e.invokeAny(l); - } catch (ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAny(c) returns result of some task - */ - public void testInvokeAny5() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(new StringTask()); - String result = e.invokeAny(l); - assertSame(TEST_STRING, result); - } catch (ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAll(null) throws NPE - */ - public void testInvokeAll1() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - e.invokeAll(null); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAll(empty collection) returns empty collection - */ - public void testInvokeAll2() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - List> r = e.invokeAll(new ArrayList>()); - assertTrue(r.isEmpty()); - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAll(c) throws NPE if c has null elements - */ - public void testInvokeAll3() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(null); - e.invokeAll(l); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * get of invokeAll(c) throws exception on failed task - */ - public void testInvokeAll4() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - ArrayList> l = new ArrayList>(); - l.add(new NPETask()); - List> result = e.invokeAll(l); - assertEquals(1, result.size()); - for (Iterator> it = result.iterator(); it.hasNext();) - it.next().get(); - } catch(ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAll(c) returns results of all completed tasks - */ - public void testInvokeAll5() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(new StringTask()); - List> result = e.invokeAll(l); - assertEquals(2, result.size()); - for (Iterator> it = result.iterator(); it.hasNext();) - assertSame(TEST_STRING, it.next().get()); - } catch (ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAny(null) throws NPE - */ - public void testTimedInvokeAny1() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - e.invokeAny(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAny(,,null) throws NPE - */ - public void testTimedInvokeAnyNullTimeUnit() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - e.invokeAny(l, MEDIUM_DELAY_MS, null); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAny(empty collection) throws IAE - */ - public void testTimedInvokeAny2() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - e.invokeAny(new ArrayList>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - } catch (IllegalArgumentException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAny(c) throws NPE if c has null elements - */ - public void testTimedInvokeAny3() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(null); - e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - } catch (NullPointerException success) { - } catch(Exception ex) { - ex.printStackTrace(); - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAny(c) throws ExecutionException if no task completes - */ - public void testTimedInvokeAny4() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - ArrayList> l = new ArrayList>(); - l.add(new NPETask()); - e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - } catch(ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAny(c) returns result of some task - */ - public void testTimedInvokeAny5() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(new StringTask()); - String result = e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - assertSame(TEST_STRING, result); - } catch (ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAll(null) throws NPE - */ - public void testTimedInvokeAll1() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - e.invokeAll(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAll(,,null) throws NPE - */ - public void testTimedInvokeAllNullTimeUnit() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - e.invokeAll(l, MEDIUM_DELAY_MS, null); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAll(empty collection) returns empty collection - */ - public void testTimedInvokeAll2() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - List> r = e.invokeAll(new ArrayList>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - assertTrue(r.isEmpty()); - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAll(c) throws NPE if c has null elements - */ - public void testTimedInvokeAll3() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(null); - e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * get of element of invokeAll(c) throws exception on failed task - */ - public void testTimedInvokeAll4() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - ArrayList> l = new ArrayList>(); - l.add(new NPETask()); - List> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - assertEquals(1, result.size()); - for (Iterator> it = result.iterator(); it.hasNext();) - it.next().get(); - } catch(ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAll(c) returns results of all completed tasks - */ - public void testTimedInvokeAll5() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(new StringTask()); - List> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - assertEquals(2, result.size()); - for (Iterator> it = result.iterator(); it.hasNext();) - assertSame(TEST_STRING, it.next().get()); - } catch (ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAll(c) cancels tasks not completed by timeout - */ - public void testTimedInvokeAll6() { - ExecutorService e = new ScheduledThreadPoolExecutor(2); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(Executors.callable(new MediumPossiblyInterruptedRunnable(), TEST_STRING)); - l.add(new StringTask()); - List> result = e.invokeAll(l, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - assertEquals(3, result.size()); - Iterator> it = result.iterator(); - Future f1 = it.next(); - Future f2 = it.next(); - Future f3 = it.next(); - assertTrue(f1.isDone()); - assertTrue(f2.isDone()); - assertTrue(f3.isDone()); - assertFalse(f1.isCancelled()); - assertTrue(f2.isCancelled()); - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/SemaphoreTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/SemaphoreTest.java deleted file mode 100755 index 4019812c5..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/SemaphoreTest.java +++ /dev/null @@ -1,919 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.io.*; - -public class SemaphoreTest extends JSR166TestCase { - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(SemaphoreTest.class); - } - - /** - * Subclass to expose protected methods - */ - static class PublicSemaphore extends Semaphore { - PublicSemaphore(int p, boolean f) { super(p, f); } - public Collection getQueuedThreads() { - return super.getQueuedThreads(); - } - public void reducePermits(int p) { - super.reducePermits(p); - } - } - - /** - * A runnable calling acquire - */ - class InterruptibleLockRunnable implements Runnable { - final Semaphore lock; - InterruptibleLockRunnable(Semaphore l) { lock = l; } - public void run() { - try { - lock.acquire(); - } catch(InterruptedException success){} - } - } - - - /** - * A runnable calling acquire that expects to be - * interrupted - */ - class InterruptedLockRunnable implements Runnable { - final Semaphore lock; - InterruptedLockRunnable(Semaphore l) { lock = l; } - public void run() { - try { - lock.acquire(); - threadShouldThrow(); - } catch(InterruptedException success){} - } - } - - /** - * Zero, negative, and positive initial values are allowed in constructor - */ - public void testConstructor() { - Semaphore s0 = new Semaphore(0, false); - assertEquals(0, s0.availablePermits()); - assertFalse(s0.isFair()); - Semaphore s1 = new Semaphore(-1, false); - assertEquals(-1, s1.availablePermits()); - assertFalse(s1.isFair()); - Semaphore s2 = new Semaphore(-1, false); - assertEquals(-1, s2.availablePermits()); - assertFalse(s2.isFair()); - } - - /** - * Constructor without fairness argument behaves as nonfair - */ - public void testConstructor2() { - Semaphore s0 = new Semaphore(0); - assertEquals(0, s0.availablePermits()); - assertFalse(s0.isFair()); - Semaphore s1 = new Semaphore(-1); - assertEquals(-1, s1.availablePermits()); - assertFalse(s1.isFair()); - Semaphore s2 = new Semaphore(-1); - assertEquals(-1, s2.availablePermits()); - assertFalse(s2.isFair()); - } - - /** - * tryAcquire succeeds when sufficient permits, else fails - */ - public void testTryAcquireInSameThread() { - Semaphore s = new Semaphore(2, false); - assertEquals(2, s.availablePermits()); - assertTrue(s.tryAcquire()); - assertTrue(s.tryAcquire()); - assertEquals(0, s.availablePermits()); - assertFalse(s.tryAcquire()); - } - - /** - * Acquire and release of semaphore succeed if initially available - */ - public void testAcquireReleaseInSameThread() { - Semaphore s = new Semaphore(1, false); - try { - s.acquire(); - s.release(); - s.acquire(); - s.release(); - s.acquire(); - s.release(); - s.acquire(); - s.release(); - s.acquire(); - s.release(); - assertEquals(1, s.availablePermits()); - } catch( InterruptedException e){ - unexpectedException(); - } - } - - /** - * Uninterruptible acquire and release of semaphore succeed if - * initially available - */ - public void testAcquireUninterruptiblyReleaseInSameThread() { - Semaphore s = new Semaphore(1, false); - try { - s.acquireUninterruptibly(); - s.release(); - s.acquireUninterruptibly(); - s.release(); - s.acquireUninterruptibly(); - s.release(); - s.acquireUninterruptibly(); - s.release(); - s.acquireUninterruptibly(); - s.release(); - assertEquals(1, s.availablePermits()); - } finally { - } - } - - /** - * Timed Acquire and release of semaphore succeed if - * initially available - */ - public void testTimedAcquireReleaseInSameThread() { - Semaphore s = new Semaphore(1, false); - try { - assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(); - assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(); - assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(); - assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(); - assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(); - assertEquals(1, s.availablePermits()); - } catch( InterruptedException e){ - unexpectedException(); - } - } - - /** - * A release in one thread enables an acquire in another thread - */ - public void testAcquireReleaseInDifferentThreads() { - final Semaphore s = new Semaphore(0, false); - Thread t = new Thread(new Runnable() { - public void run() { - try { - s.acquire(); - s.release(); - s.release(); - s.acquire(); - } catch(InterruptedException ie){ - threadUnexpectedException(); - } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - s.release(); - s.release(); - s.acquire(); - s.acquire(); - s.release(); - t.join(); - } catch( InterruptedException e){ - unexpectedException(); - } - } - - /** - * A release in one thread enables an uninterruptible acquire in another thread - */ - public void testUninterruptibleAcquireReleaseInDifferentThreads() { - final Semaphore s = new Semaphore(0, false); - Thread t = new Thread(new Runnable() { - public void run() { - s.acquireUninterruptibly(); - s.release(); - s.release(); - s.acquireUninterruptibly(); - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - s.release(); - s.release(); - s.acquireUninterruptibly(); - s.acquireUninterruptibly(); - s.release(); - t.join(); - } catch( InterruptedException e){ - unexpectedException(); - } - } - - - /** - * A release in one thread enables a timed acquire in another thread - */ - public void testTimedAcquireReleaseInDifferentThreads() { - final Semaphore s = new Semaphore(1, false); - Thread t = new Thread(new Runnable() { - public void run() { - try { - s.release(); - threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(); - threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - - } catch(InterruptedException ie){ - threadUnexpectedException(); - } - } - }); - try { - t.start(); - assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(); - assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(); - s.release(); - t.join(); - } catch( InterruptedException e){ - unexpectedException(); - } - } - - /** - * A waiting acquire blocks interruptibly - */ - public void testAcquire_InterruptedException() { - final Semaphore s = new Semaphore(0, false); - Thread t = new Thread(new Runnable() { - public void run() { - try { - s.acquire(); - threadShouldThrow(); - } catch(InterruptedException success){} - } - }); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch(InterruptedException e){ - unexpectedException(); - } - } - - /** - * A waiting timed acquire blocks interruptibly - */ - public void testTryAcquire_InterruptedException() { - final Semaphore s = new Semaphore(0, false); - Thread t = new Thread(new Runnable() { - public void run() { - try { - s.tryAcquire(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch(InterruptedException success){ - } - } - }); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch(InterruptedException e){ - unexpectedException(); - } - } - - /** - * hasQueuedThreads reports whether there are waiting threads - */ - public void testHasQueuedThreads() { - final Semaphore lock = new Semaphore(1, false); - Thread t1 = new Thread(new InterruptedLockRunnable(lock)); - Thread t2 = new Thread(new InterruptibleLockRunnable(lock)); - try { - assertFalse(lock.hasQueuedThreads()); - lock.acquireUninterruptibly(); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.hasQueuedThreads()); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.hasQueuedThreads()); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.hasQueuedThreads()); - lock.release(); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(lock.hasQueuedThreads()); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * getQueueLength reports number of waiting threads - */ - public void testGetQueueLength() { - final Semaphore lock = new Semaphore(1, false); - Thread t1 = new Thread(new InterruptedLockRunnable(lock)); - Thread t2 = new Thread(new InterruptibleLockRunnable(lock)); - try { - assertEquals(0, lock.getQueueLength()); - lock.acquireUninterruptibly(); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(1, lock.getQueueLength()); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(2, lock.getQueueLength()); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(1, lock.getQueueLength()); - lock.release(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(0, lock.getQueueLength()); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * getQueuedThreads includes waiting threads - */ - public void testGetQueuedThreads() { - final PublicSemaphore lock = new PublicSemaphore(1, false); - Thread t1 = new Thread(new InterruptedLockRunnable(lock)); - Thread t2 = new Thread(new InterruptibleLockRunnable(lock)); - try { - assertTrue(lock.getQueuedThreads().isEmpty()); - lock.acquireUninterruptibly(); - assertTrue(lock.getQueuedThreads().isEmpty()); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.getQueuedThreads().contains(t1)); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.getQueuedThreads().contains(t1)); - assertTrue(lock.getQueuedThreads().contains(t2)); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - assertFalse(lock.getQueuedThreads().contains(t1)); - assertTrue(lock.getQueuedThreads().contains(t2)); - lock.release(); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(lock.getQueuedThreads().isEmpty()); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * drainPermits reports and removes given number of permits - */ - public void testDrainPermits() { - Semaphore s = new Semaphore(0, false); - assertEquals(0, s.availablePermits()); - assertEquals(0, s.drainPermits()); - s.release(10); - assertEquals(10, s.availablePermits()); - assertEquals(10, s.drainPermits()); - assertEquals(0, s.availablePermits()); - assertEquals(0, s.drainPermits()); - } - - /** - * reducePermits reduces number of permits - */ - public void testReducePermits() { - PublicSemaphore s = new PublicSemaphore(10, false); - assertEquals(10, s.availablePermits()); - s.reducePermits(1); - assertEquals(9, s.availablePermits()); - s.reducePermits(10); - assertEquals(-1, s.availablePermits()); - } - - /** - * a deserialized serialized semaphore has same number of permits - */ - public void testSerialization() { - Semaphore l = new Semaphore(3, false); - try { - l.acquire(); - l.release(); - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(l); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - Semaphore r = (Semaphore) in.readObject(); - assertEquals(3, r.availablePermits()); - assertFalse(r.isFair()); - r.acquire(); - r.release(); - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * Zero, negative, and positive initial values are allowed in constructor - */ - public void testConstructor_fair() { - Semaphore s0 = new Semaphore(0, true); - assertEquals(0, s0.availablePermits()); - assertTrue(s0.isFair()); - Semaphore s1 = new Semaphore(-1, true); - assertEquals(-1, s1.availablePermits()); - Semaphore s2 = new Semaphore(-1, true); - assertEquals(-1, s2.availablePermits()); - } - - /** - * tryAcquire succeeds when sufficient permits, else fails - */ - public void testTryAcquireInSameThread_fair() { - Semaphore s = new Semaphore(2, true); - assertEquals(2, s.availablePermits()); - assertTrue(s.tryAcquire()); - assertTrue(s.tryAcquire()); - assertEquals(0, s.availablePermits()); - assertFalse(s.tryAcquire()); - } - - /** - * tryAcquire(n) succeeds when sufficient permits, else fails - */ - public void testTryAcquireNInSameThread_fair() { - Semaphore s = new Semaphore(2, true); - assertEquals(2, s.availablePermits()); - assertTrue(s.tryAcquire(2)); - assertEquals(0, s.availablePermits()); - assertFalse(s.tryAcquire()); - } - - /** - * Acquire and release of semaphore succeed if initially available - */ - public void testAcquireReleaseInSameThread_fair() { - Semaphore s = new Semaphore(1, true); - try { - s.acquire(); - s.release(); - s.acquire(); - s.release(); - s.acquire(); - s.release(); - s.acquire(); - s.release(); - s.acquire(); - s.release(); - assertEquals(1, s.availablePermits()); - } catch( InterruptedException e){ - unexpectedException(); - } - } - - /** - * Acquire(n) and release(n) of semaphore succeed if initially available - */ - public void testAcquireReleaseNInSameThread_fair() { - Semaphore s = new Semaphore(1, true); - try { - s.release(1); - s.acquire(1); - s.release(2); - s.acquire(2); - s.release(3); - s.acquire(3); - s.release(4); - s.acquire(4); - s.release(5); - s.acquire(5); - assertEquals(1, s.availablePermits()); - } catch( InterruptedException e){ - unexpectedException(); - } - } - - /** - * Acquire(n) and release(n) of semaphore succeed if initially available - */ - public void testAcquireUninterruptiblyReleaseNInSameThread_fair() { - Semaphore s = new Semaphore(1, true); - try { - s.release(1); - s.acquireUninterruptibly(1); - s.release(2); - s.acquireUninterruptibly(2); - s.release(3); - s.acquireUninterruptibly(3); - s.release(4); - s.acquireUninterruptibly(4); - s.release(5); - s.acquireUninterruptibly(5); - assertEquals(1, s.availablePermits()); - } finally { - } - } - - /** - * release(n) in one thread enables timed acquire(n) in another thread - */ - public void testTimedAcquireReleaseNInSameThread_fair() { - Semaphore s = new Semaphore(1, true); - try { - s.release(1); - assertTrue(s.tryAcquire(1, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(2); - assertTrue(s.tryAcquire(2, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(3); - assertTrue(s.tryAcquire(3, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(4); - assertTrue(s.tryAcquire(4, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(5); - assertTrue(s.tryAcquire(5, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - assertEquals(1, s.availablePermits()); - } catch( InterruptedException e){ - unexpectedException(); - } - } - - /** - * release in one thread enables timed acquire in another thread - */ - public void testTimedAcquireReleaseInSameThread_fair() { - Semaphore s = new Semaphore(1, true); - try { - assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(); - assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(); - assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(); - assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(); - assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(); - assertEquals(1, s.availablePermits()); - } catch( InterruptedException e){ - unexpectedException(); - } - } - - /** - * A release in one thread enables an acquire in another thread - */ - public void testAcquireReleaseInDifferentThreads_fair() { - final Semaphore s = new Semaphore(0, true); - Thread t = new Thread(new Runnable() { - public void run() { - try { - s.acquire(); - s.acquire(); - s.acquire(); - s.acquire(); - } catch(InterruptedException ie){ - threadUnexpectedException(); - } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - s.release(); - s.release(); - s.release(); - s.release(); - s.release(); - s.release(); - t.join(); - assertEquals(2, s.availablePermits()); - } catch( InterruptedException e){ - unexpectedException(); - } - } - - /** - * release(n) in one thread enables acquire(n) in another thread - */ - public void testAcquireReleaseNInDifferentThreads_fair() { - final Semaphore s = new Semaphore(0, true); - Thread t = new Thread(new Runnable() { - public void run() { - try { - s.acquire(); - s.release(2); - s.acquire(); - } catch(InterruptedException ie){ - threadUnexpectedException(); - } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - s.release(2); - s.acquire(2); - s.release(1); - t.join(); - } catch( InterruptedException e){ - unexpectedException(); - } - } - - /** - * release(n) in one thread enables acquire(n) in another thread - */ - public void testAcquireReleaseNInDifferentThreads_fair2() { - final Semaphore s = new Semaphore(0, true); - Thread t = new Thread(new Runnable() { - public void run() { - try { - s.acquire(2); - s.acquire(2); - s.release(4); - } catch(InterruptedException ie){ - threadUnexpectedException(); - } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - s.release(6); - s.acquire(2); - s.acquire(2); - s.release(2); - t.join(); - } catch( InterruptedException e){ - unexpectedException(); - } - } - - - - - - /** - * release in one thread enables timed acquire in another thread - */ - public void testTimedAcquireReleaseInDifferentThreads_fair() { - final Semaphore s = new Semaphore(1, true); - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - - } catch(InterruptedException ie){ - threadUnexpectedException(); - } - } - }); - t.start(); - try { - s.release(); - s.release(); - s.release(); - s.release(); - s.release(); - t.join(); - } catch( InterruptedException e){ - unexpectedException(); - } - } - - /** - * release(n) in one thread enables timed acquire(n) in another thread - */ - public void testTimedAcquireReleaseNInDifferentThreads_fair() { - final Semaphore s = new Semaphore(2, true); - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertTrue(s.tryAcquire(2, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(2); - threadAssertTrue(s.tryAcquire(2, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(2); - } catch(InterruptedException ie){ - threadUnexpectedException(); - } - } - }); - t.start(); - try { - assertTrue(s.tryAcquire(2, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(2); - assertTrue(s.tryAcquire(2, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - s.release(2); - t.join(); - } catch( InterruptedException e){ - unexpectedException(); - } - } - - /** - * A waiting acquire blocks interruptibly - */ - public void testAcquire_InterruptedException_fair() { - final Semaphore s = new Semaphore(0, true); - Thread t = new Thread(new Runnable() { - public void run() { - try { - s.acquire(); - threadShouldThrow(); - } catch(InterruptedException success){} - } - }); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch(InterruptedException e){ - unexpectedException(); - } - } - - /** - * A waiting acquire(n) blocks interruptibly - */ - public void testAcquireN_InterruptedException_fair() { - final Semaphore s = new Semaphore(2, true); - Thread t = new Thread(new Runnable() { - public void run() { - try { - s.acquire(3); - threadShouldThrow(); - } catch(InterruptedException success){} - } - }); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch(InterruptedException e){ - unexpectedException(); - } - } - - /** - * A waiting tryAcquire blocks interruptibly - */ - public void testTryAcquire_InterruptedException_fair() { - final Semaphore s = new Semaphore(0, true); - Thread t = new Thread(new Runnable() { - public void run() { - try { - s.tryAcquire(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch(InterruptedException success){ - } - } - }); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch(InterruptedException e){ - unexpectedException(); - } - } - - /** - * A waiting tryAcquire(n) blocks interruptibly - */ - public void testTryAcquireN_InterruptedException_fair() { - final Semaphore s = new Semaphore(1, true); - Thread t = new Thread(new Runnable() { - public void run() { - try { - s.tryAcquire(4, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch(InterruptedException success){ - } - } - }); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch(InterruptedException e){ - unexpectedException(); - } - } - - /** - * getQueueLength reports number of waiting threads - */ - public void testGetQueueLength_fair() { - final Semaphore lock = new Semaphore(1, true); - Thread t1 = new Thread(new InterruptedLockRunnable(lock)); - Thread t2 = new Thread(new InterruptibleLockRunnable(lock)); - try { - assertEquals(0, lock.getQueueLength()); - lock.acquireUninterruptibly(); - t1.start(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(1, lock.getQueueLength()); - t2.start(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(2, lock.getQueueLength()); - t1.interrupt(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(1, lock.getQueueLength()); - lock.release(); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(0, lock.getQueueLength()); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - - /** - * a deserialized serialized semaphore has same number of permits - */ - public void testSerialization_fair() { - Semaphore l = new Semaphore(3, true); - - try { - l.acquire(); - l.release(); - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(l); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - Semaphore r = (Semaphore) in.readObject(); - assertEquals(3, r.availablePermits()); - assertTrue(r.isFair()); - r.acquire(); - r.release(); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * toString indicates current number of permits - */ - public void testToString() { - Semaphore s = new Semaphore(0); - String us = s.toString(); - assertTrue(us.indexOf("Permits = 0") >= 0); - s.release(); - String s1 = s.toString(); - assertTrue(s1.indexOf("Permits = 1") >= 0); - s.release(); - String s2 = s.toString(); - assertTrue(s2.indexOf("Permits = 2") >= 0); - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/SynchronousQueueTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/SynchronousQueueTest.java deleted file mode 100755 index debce5d6d..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/SynchronousQueueTest.java +++ /dev/null @@ -1,896 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.io.*; - -public class SynchronousQueueTest extends JSR166TestCase { - - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - - public static Test suite() { - return new TestSuite(SynchronousQueueTest.class); - } - - /** - * A SynchronousQueue is both empty and full - */ - public void testEmptyFull() { - SynchronousQueue q = new SynchronousQueue(); - assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - assertEquals(0, q.remainingCapacity()); - assertFalse(q.offer(zero)); - } - - /** - * A fair SynchronousQueue is both empty and full - */ - public void testFairEmptyFull() { - SynchronousQueue q = new SynchronousQueue(true); - assertTrue(q.isEmpty()); - assertEquals(0, q.size()); - assertEquals(0, q.remainingCapacity()); - assertFalse(q.offer(zero)); - } - - /** - * offer(null) throws NPE - */ - public void testOfferNull() { - try { - SynchronousQueue q = new SynchronousQueue(); - q.offer(null); - shouldThrow(); - } catch (NullPointerException success) { } - } - - /** - * add(null) throws NPE - */ - public void testAddNull() { - try { - SynchronousQueue q = new SynchronousQueue(); - q.add(null); - shouldThrow(); - } catch (NullPointerException success) { } - } - - /** - * offer fails if no active taker - */ - public void testOffer() { - SynchronousQueue q = new SynchronousQueue(); - assertFalse(q.offer(one)); - } - - /** - * add throws ISE if no active taker - */ - public void testAdd() { - try { - SynchronousQueue q = new SynchronousQueue(); - assertEquals(0, q.remainingCapacity()); - q.add(one); - shouldThrow(); - } catch (IllegalStateException success){ - } - } - - /** - * addAll(null) throws NPE - */ - public void testAddAll1() { - try { - SynchronousQueue q = new SynchronousQueue(); - q.addAll(null); - shouldThrow(); - } - catch (NullPointerException success) {} - } - - /** - * addAll(this) throws IAE - */ - public void testAddAllSelf() { - try { - SynchronousQueue q = new SynchronousQueue(); - q.addAll(q); - shouldThrow(); - } - catch (IllegalArgumentException success) {} - } - - /** - * addAll of a collection with null elements throws NPE - */ - public void testAddAll2() { - try { - SynchronousQueue q = new SynchronousQueue(); - Integer[] ints = new Integer[1]; - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } - catch (NullPointerException success) {} - } - /** - * addAll throws ISE if no active taker - */ - public void testAddAll4() { - try { - SynchronousQueue q = new SynchronousQueue(); - Integer[] ints = new Integer[1]; - for (int i = 0; i < 1; ++i) - ints[i] = new Integer(i); - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } - catch (IllegalStateException success) {} - } - - /** - * put(null) throws NPE - */ - public void testPutNull() { - try { - SynchronousQueue q = new SynchronousQueue(); - q.put(null); - shouldThrow(); - } - catch (NullPointerException success){ - } - catch (InterruptedException ie) { - unexpectedException(); - } - } - - /** - * put blocks interruptibly if no active taker - */ - public void testBlockingPut() { - Thread t = new Thread(new Runnable() { - public void run() { - try { - SynchronousQueue q = new SynchronousQueue(); - q.put(zero); - threadShouldThrow(); - } catch (InterruptedException ie){ - } - }}); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } - catch (InterruptedException ie) { - unexpectedException(); - } - } - - /** - * put blocks waiting for take - */ - public void testPutWithTake() { - final SynchronousQueue q = new SynchronousQueue(); - Thread t = new Thread(new Runnable() { - public void run() { - int added = 0; - try { - q.put(new Object()); - ++added; - q.put(new Object()); - ++added; - q.put(new Object()); - ++added; - q.put(new Object()); - ++added; - threadShouldThrow(); - } catch (InterruptedException e){ - assertTrue(added >= 1); - } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - q.take(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - /** - * timed offer times out if elements not taken - */ - public void testTimedOffer() { - final SynchronousQueue q = new SynchronousQueue(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - - threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - q.offer(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch (InterruptedException success){} - } - }); - - try { - t.start(); - Thread.sleep(SMALL_DELAY_MS); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - - /** - * take blocks interruptibly when empty - */ - public void testTakeFromEmpty() { - final SynchronousQueue q = new SynchronousQueue(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - q.take(); - threadShouldThrow(); - } catch (InterruptedException success){ } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - - /** - * put blocks interruptibly if no active taker - */ - public void testFairBlockingPut() { - Thread t = new Thread(new Runnable() { - public void run() { - try { - SynchronousQueue q = new SynchronousQueue(true); - q.put(zero); - threadShouldThrow(); - } catch (InterruptedException ie){ - } - }}); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } - catch (InterruptedException ie) { - unexpectedException(); - } - } - - /** - * put blocks waiting for take - */ - public void testFairPutWithTake() { - final SynchronousQueue q = new SynchronousQueue(true); - Thread t = new Thread(new Runnable() { - public void run() { - int added = 0; - try { - q.put(new Object()); - ++added; - q.put(new Object()); - ++added; - q.put(new Object()); - ++added; - q.put(new Object()); - ++added; - threadShouldThrow(); - } catch (InterruptedException e){ - assertTrue(added >= 1); - } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - q.take(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - /** - * timed offer times out if elements not taken - */ - public void testFairTimedOffer() { - final SynchronousQueue q = new SynchronousQueue(true); - Thread t = new Thread(new Runnable() { - public void run() { - try { - - threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - q.offer(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch (InterruptedException success){} - } - }); - - try { - t.start(); - Thread.sleep(SMALL_DELAY_MS); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - - /** - * take blocks interruptibly when empty - */ - public void testFairTakeFromEmpty() { - final SynchronousQueue q = new SynchronousQueue(true); - Thread t = new Thread(new Runnable() { - public void run() { - try { - q.take(); - threadShouldThrow(); - } catch (InterruptedException success){ } - } - }); - try { - t.start(); - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - /** - * poll fails unless active taker - */ - public void testPoll() { - SynchronousQueue q = new SynchronousQueue(); - assertNull(q.poll()); - } - - /** - * timed pool with zero timeout times out if no active taker - */ - public void testTimedPoll0() { - try { - SynchronousQueue q = new SynchronousQueue(); - assertNull(q.poll(0, TimeUnit.MILLISECONDS)); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * timed pool with nonzero timeout times out if no active taker - */ - public void testTimedPoll() { - try { - SynchronousQueue q = new SynchronousQueue(); - assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch (InterruptedException e){ - unexpectedException(); - } - } - - /** - * Interrupted timed poll throws InterruptedException instead of - * returning timeout status - */ - public void testInterruptedTimedPoll() { - Thread t = new Thread(new Runnable() { - public void run() { - try { - SynchronousQueue q = new SynchronousQueue(); - assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch (InterruptedException success){ - } - }}); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } - catch (InterruptedException ie) { - unexpectedException(); - } - } - - /** - * timed poll before a delayed offer fails; after offer succeeds; - * on interruption throws - */ - public void testTimedPollWithOffer() { - final SynchronousQueue q = new SynchronousQueue(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch (InterruptedException success) { } - } - }); - try { - t.start(); - Thread.sleep(SMALL_DELAY_MS); - assertTrue(q.offer(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - /** - * Interrupted timed poll throws InterruptedException instead of - * returning timeout status - */ - public void testFairInterruptedTimedPoll() { - Thread t = new Thread(new Runnable() { - public void run() { - try { - SynchronousQueue q = new SynchronousQueue(true); - assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - } catch (InterruptedException success){ - } - }}); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } - catch (InterruptedException ie) { - unexpectedException(); - } - } - - /** - * timed poll before a delayed offer fails; after offer succeeds; - * on interruption throws - */ - public void testFairTimedPollWithOffer() { - final SynchronousQueue q = new SynchronousQueue(true); - Thread t = new Thread(new Runnable() { - public void run() { - try { - threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); - threadShouldThrow(); - } catch (InterruptedException success) { } - } - }); - try { - t.start(); - Thread.sleep(SMALL_DELAY_MS); - assertTrue(q.offer(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); - t.interrupt(); - t.join(); - } catch (Exception e){ - unexpectedException(); - } - } - - - /** - * peek returns null - */ - public void testPeek() { - SynchronousQueue q = new SynchronousQueue(); - assertNull(q.peek()); - } - - /** - * element throws NSEE - */ - public void testElement() { - SynchronousQueue q = new SynchronousQueue(); - try { - q.element(); - shouldThrow(); - } - catch (NoSuchElementException success) {} - } - - /** - * remove throws NSEE if no active taker - */ - public void testRemove() { - SynchronousQueue q = new SynchronousQueue(); - try { - q.remove(); - shouldThrow(); - } catch (NoSuchElementException success){ - } - } - - /** - * remove(x) returns false - */ - public void testRemoveElement() { - SynchronousQueue q = new SynchronousQueue(); - assertFalse(q.remove(zero)); - assertTrue(q.isEmpty()); - } - - /** - * contains returns false - */ - public void testContains() { - SynchronousQueue q = new SynchronousQueue(); - assertFalse(q.contains(zero)); - } - - /** - * clear ensures isEmpty - */ - public void testClear() { - SynchronousQueue q = new SynchronousQueue(); - q.clear(); - assertTrue(q.isEmpty()); - } - - /** - * containsAll returns false unless empty - */ - public void testContainsAll() { - SynchronousQueue q = new SynchronousQueue(); - Integer[] empty = new Integer[0]; - assertTrue(q.containsAll(Arrays.asList(empty))); - Integer[] ints = new Integer[1]; ints[0] = zero; - assertFalse(q.containsAll(Arrays.asList(ints))); - } - - /** - * retainAll returns false - */ - public void testRetainAll() { - SynchronousQueue q = new SynchronousQueue(); - Integer[] empty = new Integer[0]; - assertFalse(q.retainAll(Arrays.asList(empty))); - Integer[] ints = new Integer[1]; ints[0] = zero; - assertFalse(q.retainAll(Arrays.asList(ints))); - } - - /** - * removeAll returns false - */ - public void testRemoveAll() { - SynchronousQueue q = new SynchronousQueue(); - Integer[] empty = new Integer[0]; - assertFalse(q.removeAll(Arrays.asList(empty))); - Integer[] ints = new Integer[1]; ints[0] = zero; - assertFalse(q.containsAll(Arrays.asList(ints))); - } - - - /** - * toArray is empty - */ - public void testToArray() { - SynchronousQueue q = new SynchronousQueue(); - Object[] o = q.toArray(); - assertEquals(o.length, 0); - } - - /** - * toArray(a) is nulled at position 0 - */ - public void testToArray2() { - SynchronousQueue q = new SynchronousQueue(); - Integer[] ints = new Integer[1]; - assertNull(ints[0]); - } - - /** - * toArray(null) throws NPE - */ - public void testToArray_BadArg() { - try { - SynchronousQueue q = new SynchronousQueue(); - Object o[] = q.toArray(null); - shouldThrow(); - } catch(NullPointerException success){} - } - - - /** - * iterator does not traverse any elements - */ - public void testIterator() { - SynchronousQueue q = new SynchronousQueue(); - Iterator it = q.iterator(); - assertFalse(it.hasNext()); - try { - Object x = it.next(); - shouldThrow(); - } - catch (NoSuchElementException success) {} - } - - /** - * iterator remove throws ISE - */ - public void testIteratorRemove() { - SynchronousQueue q = new SynchronousQueue(); - Iterator it = q.iterator(); - try { - it.remove(); - shouldThrow(); - } - catch (IllegalStateException success) {} - } - - /** - * toString returns a non-null string - */ - public void testToString() { - SynchronousQueue q = new SynchronousQueue(); - String s = q.toString(); - assertNotNull(s); - } - - - /** - * offer transfers elements across Executor tasks - */ - public void testOfferInExecutor() { - final SynchronousQueue q = new SynchronousQueue(); - ExecutorService executor = Executors.newFixedThreadPool(2); - final Integer one = new Integer(1); - - executor.execute(new Runnable() { - public void run() { - threadAssertFalse(q.offer(one)); - try { - threadAssertTrue(q.offer(one, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS)); - threadAssertEquals(0, q.remainingCapacity()); - } - catch (InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - executor.execute(new Runnable() { - public void run() { - try { - Thread.sleep(SMALL_DELAY_MS); - threadAssertEquals(one, q.take()); - } - catch (InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - joinPool(executor); - - } - - /** - * poll retrieves elements across Executor threads - */ - public void testPollInExecutor() { - final SynchronousQueue q = new SynchronousQueue(); - ExecutorService executor = Executors.newFixedThreadPool(2); - executor.execute(new Runnable() { - public void run() { - threadAssertNull(q.poll()); - try { - threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS)); - threadAssertTrue(q.isEmpty()); - } - catch (InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - executor.execute(new Runnable() { - public void run() { - try { - Thread.sleep(SMALL_DELAY_MS); - q.put(new Integer(1)); - } - catch (InterruptedException e) { - threadUnexpectedException(); - } - } - }); - - joinPool(executor); - } - - /** - * a deserialized serialized queue is usable - */ - public void testSerialization() { - SynchronousQueue q = new SynchronousQueue(); - try { - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(q); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - SynchronousQueue r = (SynchronousQueue)in.readObject(); - assertEquals(q.size(), r.size()); - while (!q.isEmpty()) - assertEquals(q.remove(), r.remove()); - } catch(Exception e){ - e.printStackTrace(); - unexpectedException(); - } - } - - /** - * drainTo(null) throws NPE - */ - public void testDrainToNull() { - SynchronousQueue q = new SynchronousQueue(); - try { - q.drainTo(null); - shouldThrow(); - } catch(NullPointerException success) { - } - } - - /** - * drainTo(this) throws IAE - */ - public void testDrainToSelf() { - SynchronousQueue q = new SynchronousQueue(); - try { - q.drainTo(q); - shouldThrow(); - } catch(IllegalArgumentException success) { - } - } - - /** - * drainTo(c) of empty queue doesn't transfer elements - */ - public void testDrainTo() { - SynchronousQueue q = new SynchronousQueue(); - ArrayList l = new ArrayList(); - q.drainTo(l); - assertEquals(q.size(), 0); - assertEquals(l.size(), 0); - } - - /** - * drainTo empties queue, unblocking a waiting put. - */ - public void testDrainToWithActivePut() { - final SynchronousQueue q = new SynchronousQueue(); - Thread t = new Thread(new Runnable() { - public void run() { - try { - q.put(new Integer(1)); - } catch (InterruptedException ie){ - threadUnexpectedException(); - } - } - }); - try { - t.start(); - ArrayList l = new ArrayList(); - Thread.sleep(SHORT_DELAY_MS); - q.drainTo(l); - assertTrue(l.size() <= 1); - if (l.size() > 0) - assertEquals(l.get(0), new Integer(1)); - t.join(); - assertTrue(l.size() <= 1); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * drainTo(null, n) throws NPE - */ - public void testDrainToNullN() { - SynchronousQueue q = new SynchronousQueue(); - try { - q.drainTo(null, 0); - shouldThrow(); - } catch(NullPointerException success) { - } - } - - /** - * drainTo(this, n) throws IAE - */ - public void testDrainToSelfN() { - SynchronousQueue q = new SynchronousQueue(); - try { - q.drainTo(q, 0); - shouldThrow(); - } catch(IllegalArgumentException success) { - } - } - - /** - * drainTo(c, n) empties up to n elements of queue into c - */ - public void testDrainToN() { - final SynchronousQueue q = new SynchronousQueue(); - Thread t1 = new Thread(new Runnable() { - public void run() { - try { - q.put(one); - } catch (InterruptedException ie){ - threadUnexpectedException(); - } - } - }); - Thread t2 = new Thread(new Runnable() { - public void run() { - try { - q.put(two); - } catch (InterruptedException ie){ - threadUnexpectedException(); - } - } - }); - - try { - t1.start(); - t2.start(); - ArrayList l = new ArrayList(); - Thread.sleep(SHORT_DELAY_MS); - q.drainTo(l, 1); - assertTrue(l.size() == 1); - q.drainTo(l, 1); - assertTrue(l.size() == 2); - assertTrue(l.contains(one)); - assertTrue(l.contains(two)); - t1.join(); - t2.join(); - } catch(Exception e){ - unexpectedException(); - } - } - - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/SystemTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/SystemTest.java deleted file mode 100644 index 4433cb19b..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/SystemTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; - -public class SystemTest extends JSR166TestCase { - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } - - public static Test suite() { - return new TestSuite(SystemTest.class); - } - - /** - * Worst case rounding for millisecs; set for 60 cycle millis clock. - * This value might need to be changed os JVMs with coarser - * System.currentTimeMillis clocks. - */ - static final long MILLIS_ROUND = 17; - - /** - * Nanos between readings of millis is no longer than millis (plus - * possible rounding). - * This shows only that nano timing not (much) worse than milli. - */ - public void testNanoTime1() { - try { - long m1 = System.currentTimeMillis(); - Thread.sleep(1); - long n1 = System.nanoTime(); - Thread.sleep(SHORT_DELAY_MS); - long n2 = System.nanoTime(); - Thread.sleep(1); - long m2 = System.currentTimeMillis(); - long millis = m2 - m1; - long nanos = n2 - n1; - assertTrue(nanos >= 0); - long nanosAsMillis = nanos / 1000000; - assertTrue(nanosAsMillis <= millis + MILLIS_ROUND); - } - catch(InterruptedException ie) { - unexpectedException(); - } - } - - /** - * Millis between readings of nanos is less than nanos, adjusting - * for rounding. - * This shows only that nano timing not (much) worse than milli. - */ - public void testNanoTime2() { - try { - long n1 = System.nanoTime(); - Thread.sleep(1); - long m1 = System.currentTimeMillis(); - Thread.sleep(SHORT_DELAY_MS); - long m2 = System.currentTimeMillis(); - Thread.sleep(1); - long n2 = System.nanoTime(); - long millis = m2 - m1; - long nanos = n2 - n1; - - assertTrue(nanos >= 0); - long nanosAsMillis = nanos / 1000000; - assertTrue(millis <= nanosAsMillis + MILLIS_ROUND); - } - catch(InterruptedException ie) { - unexpectedException(); - } - } - -} - diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ThreadLocalTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ThreadLocalTest.java deleted file mode 100644 index 0c2256a05..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ThreadLocalTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.concurrent.Semaphore; - -public class ThreadLocalTest extends JSR166TestCase { - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } - - public static Test suite() { - return new TestSuite(ThreadLocalTest.class); - } - - static ThreadLocal tl = new ThreadLocal() { - public Integer initialValue() { - return one; - } - }; - - static InheritableThreadLocal itl = - new InheritableThreadLocal() { - protected Integer initialValue() { - return zero; - } - - protected Integer childValue(Integer parentValue) { - return new Integer(parentValue.intValue() + 1); - } - }; - - /** - * remove causes next access to return initial value - */ - public void testRemove() { - assertEquals(tl.get(), one); - tl.set(two); - assertEquals(tl.get(), two); - tl.remove(); - assertEquals(tl.get(), one); - } - - /** - * remove in InheritableThreadLocal causes next access to return - * initial value - */ - public void testRemoveITL() { - assertEquals(itl.get(), zero); - itl.set(two); - assertEquals(itl.get(), two); - itl.remove(); - assertEquals(itl.get(), zero); - } - - private class ITLThread extends Thread { - final int[] x; - ITLThread(int[] array) { x = array; } - public void run() { - Thread child = null; - if (itl.get().intValue() < x.length - 1) { - child = new ITLThread(x); - child.start(); - } - Thread.currentThread().yield(); - - int threadId = itl.get().intValue(); - for (int j = 0; j < threadId; j++) { - x[threadId]++; - Thread.currentThread().yield(); - } - - if (child != null) { // Wait for child (if any) - try { - child.join(); - } catch(InterruptedException e) { - threadUnexpectedException(); - } - } - } - } - - /** - * InheritableThreadLocal propagates generic values. - */ - public void testGenericITL() { - final int threadCount = 10; - final int x[] = new int[threadCount]; - Thread progenitor = new ITLThread(x); - try { - progenitor.start(); - progenitor.join(); - for(int i = 0; i < threadCount; i++) { - assertEquals(i, x[i]); - } - } catch(InterruptedException e) { - unexpectedException(); - } - } -} - diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ThreadPoolExecutorTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ThreadPoolExecutorTest.java deleted file mode 100755 index 4f7cc461b..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ThreadPoolExecutorTest.java +++ /dev/null @@ -1,1570 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; -import junit.framework.*; -import java.util.*; - -public class ThreadPoolExecutorTest extends JSR166TestCase { - public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); - } - public static Test suite() { - return new TestSuite(ThreadPoolExecutorTest.class); - } - - static class ExtendedTPE extends ThreadPoolExecutor { - volatile boolean beforeCalled = false; - volatile boolean afterCalled = false; - volatile boolean terminatedCalled = false; - public ExtendedTPE() { - super(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new SynchronousQueue()); - } - protected void beforeExecute(Thread t, Runnable r) { - beforeCalled = true; - } - protected void afterExecute(Runnable r, Throwable t) { - afterCalled = true; - } - protected void terminated() { - terminatedCalled = true; - } - } - - static class FailingThreadFactory implements ThreadFactory{ - int calls = 0; - public Thread newThread(Runnable r){ - if (++calls > 1) return null; - return new Thread(r); - } - } - - - /** - * execute successfully executes a runnable - */ - public void testExecute() { - ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - p1.execute(new Runnable() { - public void run() { - try { - Thread.sleep(SHORT_DELAY_MS); - } catch(InterruptedException e){ - threadUnexpectedException(); - } - } - }); - Thread.sleep(SMALL_DELAY_MS); - } catch(InterruptedException e){ - unexpectedException(); - } - joinPool(p1); - } - - /** - * getActiveCount increases but doesn't overestimate, when a - * thread becomes active - */ - public void testGetActiveCount() { - ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - assertEquals(0, p2.getActiveCount()); - p2.execute(new MediumRunnable()); - try { - Thread.sleep(SHORT_DELAY_MS); - } catch(Exception e){ - unexpectedException(); - } - assertEquals(1, p2.getActiveCount()); - joinPool(p2); - } - - /** - * prestartCoreThread starts a thread if under corePoolSize, else doesn't - */ - public void testPrestartCoreThread() { - ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - assertEquals(0, p2.getPoolSize()); - assertTrue(p2.prestartCoreThread()); - assertEquals(1, p2.getPoolSize()); - assertTrue(p2.prestartCoreThread()); - assertEquals(2, p2.getPoolSize()); - assertFalse(p2.prestartCoreThread()); - assertEquals(2, p2.getPoolSize()); - joinPool(p2); - } - - /** - * prestartAllCoreThreads starts all corePoolSize threads - */ - public void testPrestartAllCoreThreads() { - ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - assertEquals(0, p2.getPoolSize()); - p2.prestartAllCoreThreads(); - assertEquals(2, p2.getPoolSize()); - p2.prestartAllCoreThreads(); - assertEquals(2, p2.getPoolSize()); - joinPool(p2); - } - - /** - * getCompletedTaskCount increases, but doesn't overestimate, - * when tasks complete - */ - public void testGetCompletedTaskCount() { - ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - assertEquals(0, p2.getCompletedTaskCount()); - p2.execute(new ShortRunnable()); - try { - Thread.sleep(SMALL_DELAY_MS); - } catch(Exception e){ - unexpectedException(); - } - assertEquals(1, p2.getCompletedTaskCount()); - try { p2.shutdown(); } catch(SecurityException ok) { return; } - joinPool(p2); - } - - /** - * getCorePoolSize returns size given in constructor if not otherwise set - */ - public void testGetCorePoolSize() { - ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - assertEquals(1, p1.getCorePoolSize()); - joinPool(p1); - } - - /** - * getKeepAliveTime returns value given in constructor if not otherwise set - */ - public void testGetKeepAliveTime() { - ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, 1000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - assertEquals(1, p2.getKeepAliveTime(TimeUnit.SECONDS)); - joinPool(p2); - } - - - /** - * getThreadFactory returns factory in constructor if not set - */ - public void testGetThreadFactory() { - ThreadFactory tf = new SimpleThreadFactory(); - ThreadPoolExecutor p = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10), tf, new NoOpREHandler()); - assertSame(tf, p.getThreadFactory()); - joinPool(p); - } - - /** - * setThreadFactory sets the thread factory returned by getThreadFactory - */ - public void testSetThreadFactory() { - ThreadPoolExecutor p = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - ThreadFactory tf = new SimpleThreadFactory(); - p.setThreadFactory(tf); - assertSame(tf, p.getThreadFactory()); - joinPool(p); - } - - - /** - * setThreadFactory(null) throws NPE - */ - public void testSetThreadFactoryNull() { - ThreadPoolExecutor p = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - p.setThreadFactory(null); - shouldThrow(); - } catch (NullPointerException success) { - } finally { - joinPool(p); - } - } - - /** - * getRejectedExecutionHandler returns handler in constructor if not set - */ - public void testGetRejectedExecutionHandler() { - RejectedExecutionHandler h = new NoOpREHandler(); - ThreadPoolExecutor p = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10), h); - assertSame(h, p.getRejectedExecutionHandler()); - joinPool(p); - } - - /** - * setRejectedExecutionHandler sets the handler returned by - * getRejectedExecutionHandler - */ - public void testSetRejectedExecutionHandler() { - ThreadPoolExecutor p = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - RejectedExecutionHandler h = new NoOpREHandler(); - p.setRejectedExecutionHandler(h); - assertSame(h, p.getRejectedExecutionHandler()); - joinPool(p); - } - - - /** - * setRejectedExecutionHandler(null) throws NPE - */ - public void testSetRejectedExecutionHandlerNull() { - ThreadPoolExecutor p = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - p.setRejectedExecutionHandler(null); - shouldThrow(); - } catch (NullPointerException success) { - } finally { - joinPool(p); - } - } - - - /** - * getLargestPoolSize increases, but doesn't overestimate, when - * multiple threads active - */ - public void testGetLargestPoolSize() { - ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - assertEquals(0, p2.getLargestPoolSize()); - p2.execute(new MediumRunnable()); - p2.execute(new MediumRunnable()); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(2, p2.getLargestPoolSize()); - } catch(Exception e){ - unexpectedException(); - } - joinPool(p2); - } - - /** - * getMaximumPoolSize returns value given in constructor if not - * otherwise set - */ - public void testGetMaximumPoolSize() { - ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - assertEquals(2, p2.getMaximumPoolSize()); - joinPool(p2); - } - - /** - * getPoolSize increases, but doesn't overestimate, when threads - * become active - */ - public void testGetPoolSize() { - ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - assertEquals(0, p1.getPoolSize()); - p1.execute(new MediumRunnable()); - assertEquals(1, p1.getPoolSize()); - joinPool(p1); - } - - /** - * getTaskCount increases, but doesn't overestimate, when tasks submitted - */ - public void testGetTaskCount() { - ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - assertEquals(0, p1.getTaskCount()); - p1.execute(new MediumRunnable()); - Thread.sleep(SHORT_DELAY_MS); - assertEquals(1, p1.getTaskCount()); - } catch(Exception e){ - unexpectedException(); - } - joinPool(p1); - } - - /** - * isShutDown is false before shutdown, true after - */ - public void testIsShutdown() { - - ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - assertFalse(p1.isShutdown()); - try { p1.shutdown(); } catch(SecurityException ok) { return; } - assertTrue(p1.isShutdown()); - joinPool(p1); - } - - - /** - * isTerminated is false before termination, true after - */ - public void testIsTerminated() { - ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - assertFalse(p1.isTerminated()); - try { - p1.execute(new MediumRunnable()); - } finally { - try { p1.shutdown(); } catch(SecurityException ok) { return; } - } - try { - assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); - assertTrue(p1.isTerminated()); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * isTerminating is not true when running or when terminated - */ - public void testIsTerminating() { - ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - assertFalse(p1.isTerminating()); - try { - p1.execute(new SmallRunnable()); - assertFalse(p1.isTerminating()); - } finally { - try { p1.shutdown(); } catch(SecurityException ok) { return; } - } - try { - assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); - assertTrue(p1.isTerminated()); - assertFalse(p1.isTerminating()); - } catch(Exception e){ - unexpectedException(); - } - } - - /** - * getQueue returns the work queue, which contains queued tasks - */ - public void testGetQueue() { - BlockingQueue q = new ArrayBlockingQueue(10); - ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q); - FutureTask[] tasks = new FutureTask[5]; - for(int i = 0; i < 5; i++){ - tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE); - p1.execute(tasks[i]); - } - try { - Thread.sleep(SHORT_DELAY_MS); - BlockingQueue wq = p1.getQueue(); - assertSame(q, wq); - assertFalse(wq.contains(tasks[0])); - assertTrue(wq.contains(tasks[4])); - for (int i = 1; i < 5; ++i) - tasks[i].cancel(true); - p1.shutdownNow(); - } catch(Exception e) { - unexpectedException(); - } finally { - joinPool(p1); - } - } - - /** - * remove(task) removes queued task, and fails to remove active task - */ - public void testRemove() { - BlockingQueue q = new ArrayBlockingQueue(10); - ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q); - FutureTask[] tasks = new FutureTask[5]; - for(int i = 0; i < 5; i++){ - tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE); - p1.execute(tasks[i]); - } - try { - Thread.sleep(SHORT_DELAY_MS); - assertFalse(p1.remove(tasks[0])); - assertTrue(q.contains(tasks[4])); - assertTrue(q.contains(tasks[3])); - assertTrue(p1.remove(tasks[4])); - assertFalse(p1.remove(tasks[4])); - assertFalse(q.contains(tasks[4])); - assertTrue(q.contains(tasks[3])); - assertTrue(p1.remove(tasks[3])); - assertFalse(q.contains(tasks[3])); - } catch(Exception e) { - unexpectedException(); - } finally { - joinPool(p1); - } - } - - /** - * purge removes cancelled tasks from the queue - */ - public void testPurge() { - ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - FutureTask[] tasks = new FutureTask[5]; - for(int i = 0; i < 5; i++){ - tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE); - p1.execute(tasks[i]); - } - tasks[4].cancel(true); - tasks[3].cancel(true); - p1.purge(); - long count = p1.getTaskCount(); - assertTrue(count >= 2 && count < 5); - joinPool(p1); - } - - /** - * shutDownNow returns a list containing tasks that were not run - */ - public void testShutDownNow() { - ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - List l; - try { - for(int i = 0; i < 5; i++) - p1.execute(new MediumPossiblyInterruptedRunnable()); - } - finally { - try { - l = p1.shutdownNow(); - } catch (SecurityException ok) { return; } - - } - assertTrue(p1.isShutdown()); - assertTrue(l.size() <= 4); - } - - // Exception Tests - - - /** - * Constructor throws if corePoolSize argument is less than zero - */ - public void testConstructor1() { - try { - new ThreadPoolExecutor(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - shouldThrow(); - } - catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if maximumPoolSize is less than zero - */ - public void testConstructor2() { - try { - new ThreadPoolExecutor(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - shouldThrow(); - } - catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if maximumPoolSize is equal to zero - */ - public void testConstructor3() { - try { - new ThreadPoolExecutor(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - shouldThrow(); - } - catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if keepAliveTime is less than zero - */ - public void testConstructor4() { - try { - new ThreadPoolExecutor(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - shouldThrow(); - } - catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if corePoolSize is greater than the maximumPoolSize - */ - public void testConstructor5() { - try { - new ThreadPoolExecutor(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - shouldThrow(); - } - catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if workQueue is set to null - */ - public void testConstructorNullPointerException() { - try { - new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null); - shouldThrow(); - } - catch (NullPointerException success){} - } - - - - /** - * Constructor throws if corePoolSize argument is less than zero - */ - public void testConstructor6() { - try { - new ThreadPoolExecutor(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); - shouldThrow(); - } catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if maximumPoolSize is less than zero - */ - public void testConstructor7() { - try { - new ThreadPoolExecutor(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); - shouldThrow(); - } - catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if maximumPoolSize is equal to zero - */ - public void testConstructor8() { - try { - new ThreadPoolExecutor(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); - shouldThrow(); - } - catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if keepAliveTime is less than zero - */ - public void testConstructor9() { - try { - new ThreadPoolExecutor(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); - shouldThrow(); - } - catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if corePoolSize is greater than the maximumPoolSize - */ - public void testConstructor10() { - try { - new ThreadPoolExecutor(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); - shouldThrow(); - } - catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if workQueue is set to null - */ - public void testConstructorNullPointerException2() { - try { - new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new SimpleThreadFactory()); - shouldThrow(); - } - catch (NullPointerException success){} - } - - /** - * Constructor throws if threadFactory is set to null - */ - public void testConstructorNullPointerException3() { - try { - ThreadFactory f = null; - new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10),f); - shouldThrow(); - } - catch (NullPointerException success){} - } - - - /** - * Constructor throws if corePoolSize argument is less than zero - */ - public void testConstructor11() { - try { - new ThreadPoolExecutor(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); - shouldThrow(); - } - catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if maximumPoolSize is less than zero - */ - public void testConstructor12() { - try { - new ThreadPoolExecutor(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); - shouldThrow(); - } - catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if maximumPoolSize is equal to zero - */ - public void testConstructor13() { - try { - new ThreadPoolExecutor(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); - shouldThrow(); - } - catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if keepAliveTime is less than zero - */ - public void testConstructor14() { - try { - new ThreadPoolExecutor(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); - shouldThrow(); - } - catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if corePoolSize is greater than the maximumPoolSize - */ - public void testConstructor15() { - try { - new ThreadPoolExecutor(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); - shouldThrow(); - } - catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if workQueue is set to null - */ - public void testConstructorNullPointerException4() { - try { - new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new NoOpREHandler()); - shouldThrow(); - } - catch (NullPointerException success){} - } - - /** - * Constructor throws if handler is set to null - */ - public void testConstructorNullPointerException5() { - try { - RejectedExecutionHandler r = null; - new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10),r); - shouldThrow(); - } - catch (NullPointerException success){} - } - - - /** - * Constructor throws if corePoolSize argument is less than zero - */ - public void testConstructor16() { - try { - new ThreadPoolExecutor(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); - shouldThrow(); - } - catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if maximumPoolSize is less than zero - */ - public void testConstructor17() { - try { - new ThreadPoolExecutor(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); - shouldThrow(); - } - catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if maximumPoolSize is equal to zero - */ - public void testConstructor18() { - try { - new ThreadPoolExecutor(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); - shouldThrow(); - } - catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if keepAliveTime is less than zero - */ - public void testConstructor19() { - try { - new ThreadPoolExecutor(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); - shouldThrow(); - } - catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if corePoolSize is greater than the maximumPoolSize - */ - public void testConstructor20() { - try { - new ThreadPoolExecutor(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); - shouldThrow(); - } - catch (IllegalArgumentException success){} - } - - /** - * Constructor throws if workQueue is set to null - */ - public void testConstructorNullPointerException6() { - try { - new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new SimpleThreadFactory(),new NoOpREHandler()); - shouldThrow(); - } - catch (NullPointerException success){} - } - - /** - * Constructor throws if handler is set to null - */ - public void testConstructorNullPointerException7() { - try { - RejectedExecutionHandler r = null; - new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10),new SimpleThreadFactory(),r); - shouldThrow(); - } - catch (NullPointerException success){} - } - - /** - * Constructor throws if ThreadFactory is set top null - */ - public void testConstructorNullPointerException8() { - try { - ThreadFactory f = null; - new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10),f,new NoOpREHandler()); - shouldThrow(); - } - catch (NullPointerException successdn8){} - } - - - /** - * execute throws RejectedExecutionException - * if saturated. - */ - public void testSaturatedExecute() { - ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(1)); - try { - - for(int i = 0; i < 5; ++i){ - p.execute(new MediumRunnable()); - } - shouldThrow(); - } catch(RejectedExecutionException success){} - joinPool(p); - } - - /** - * executor using CallerRunsPolicy runs task if saturated. - */ - public void testSaturatedExecute2() { - RejectedExecutionHandler h = new ThreadPoolExecutor.CallerRunsPolicy(); - ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(1), h); - try { - - TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5]; - for(int i = 0; i < 5; ++i){ - tasks[i] = new TrackedNoOpRunnable(); - } - TrackedLongRunnable mr = new TrackedLongRunnable(); - p.execute(mr); - for(int i = 0; i < 5; ++i){ - p.execute(tasks[i]); - } - for(int i = 1; i < 5; ++i) { - assertTrue(tasks[i].done); - } - try { p.shutdownNow(); } catch(SecurityException ok) { return; } - } catch(RejectedExecutionException ex){ - unexpectedException(); - } finally { - joinPool(p); - } - } - - /** - * executor using DiscardPolicy drops task if saturated. - */ - public void testSaturatedExecute3() { - RejectedExecutionHandler h = new ThreadPoolExecutor.DiscardPolicy(); - ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(1), h); - try { - - TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5]; - for(int i = 0; i < 5; ++i){ - tasks[i] = new TrackedNoOpRunnable(); - } - p.execute(new TrackedLongRunnable()); - for(int i = 0; i < 5; ++i){ - p.execute(tasks[i]); - } - for(int i = 0; i < 5; ++i){ - assertFalse(tasks[i].done); - } - try { p.shutdownNow(); } catch(SecurityException ok) { return; } - } catch(RejectedExecutionException ex){ - unexpectedException(); - } finally { - joinPool(p); - } - } - - /** - * executor using DiscardOldestPolicy drops oldest task if saturated. - */ - public void testSaturatedExecute4() { - RejectedExecutionHandler h = new ThreadPoolExecutor.DiscardOldestPolicy(); - ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(1), h); - try { - p.execute(new TrackedLongRunnable()); - TrackedLongRunnable r2 = new TrackedLongRunnable(); - p.execute(r2); - assertTrue(p.getQueue().contains(r2)); - TrackedNoOpRunnable r3 = new TrackedNoOpRunnable(); - p.execute(r3); - assertFalse(p.getQueue().contains(r2)); - assertTrue(p.getQueue().contains(r3)); - try { p.shutdownNow(); } catch(SecurityException ok) { return; } - } catch(RejectedExecutionException ex){ - unexpectedException(); - } finally { - joinPool(p); - } - } - - /** - * execute throws RejectedExecutionException if shutdown - */ - public void testRejectedExecutionExceptionOnShutdown() { - ThreadPoolExecutor tpe = - new ThreadPoolExecutor(1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(1)); - try { tpe.shutdown(); } catch(SecurityException ok) { return; } - try { - tpe.execute(new NoOpRunnable()); - shouldThrow(); - } catch(RejectedExecutionException success){} - - joinPool(tpe); - } - - /** - * execute using CallerRunsPolicy drops task on shutdown - */ - public void testCallerRunsOnShutdown() { - RejectedExecutionHandler h = new ThreadPoolExecutor.CallerRunsPolicy(); - ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(1), h); - - try { p.shutdown(); } catch(SecurityException ok) { return; } - try { - TrackedNoOpRunnable r = new TrackedNoOpRunnable(); - p.execute(r); - assertFalse(r.done); - } catch(RejectedExecutionException success){ - unexpectedException(); - } finally { - joinPool(p); - } - } - - /** - * execute using DiscardPolicy drops task on shutdown - */ - public void testDiscardOnShutdown() { - RejectedExecutionHandler h = new ThreadPoolExecutor.DiscardPolicy(); - ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(1), h); - - try { p.shutdown(); } catch(SecurityException ok) { return; } - try { - TrackedNoOpRunnable r = new TrackedNoOpRunnable(); - p.execute(r); - assertFalse(r.done); - } catch(RejectedExecutionException success){ - unexpectedException(); - } finally { - joinPool(p); - } - } - - - /** - * execute using DiscardOldestPolicy drops task on shutdown - */ - public void testDiscardOldestOnShutdown() { - RejectedExecutionHandler h = new ThreadPoolExecutor.DiscardOldestPolicy(); - ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(1), h); - - try { p.shutdown(); } catch(SecurityException ok) { return; } - try { - TrackedNoOpRunnable r = new TrackedNoOpRunnable(); - p.execute(r); - assertFalse(r.done); - } catch(RejectedExecutionException success){ - unexpectedException(); - } finally { - joinPool(p); - } - } - - - /** - * execute (null) throws NPE - */ - public void testExecuteNull() { - ThreadPoolExecutor tpe = null; - try { - tpe = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10)); - tpe.execute(null); - shouldThrow(); - } catch(NullPointerException success){} - - joinPool(tpe); - } - - /** - * setCorePoolSize of negative value throws IllegalArgumentException - */ - public void testCorePoolSizeIllegalArgumentException() { - ThreadPoolExecutor tpe = null; - try { - tpe = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10)); - } catch(Exception e){} - try { - tpe.setCorePoolSize(-1); - shouldThrow(); - } catch(IllegalArgumentException success){ - } finally { - try { tpe.shutdown(); } catch(SecurityException ok) { return; } - } - joinPool(tpe); - } - - /** - * setMaximumPoolSize(int) throws IllegalArgumentException if - * given a value less the core pool size - */ - public void testMaximumPoolSizeIllegalArgumentException() { - ThreadPoolExecutor tpe = null; - try { - tpe = new ThreadPoolExecutor(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10)); - } catch(Exception e){} - try { - tpe.setMaximumPoolSize(1); - shouldThrow(); - } catch(IllegalArgumentException success){ - } finally { - try { tpe.shutdown(); } catch(SecurityException ok) { return; } - } - joinPool(tpe); - } - - /** - * setMaximumPoolSize throws IllegalArgumentException - * if given a negative value - */ - public void testMaximumPoolSizeIllegalArgumentException2() { - ThreadPoolExecutor tpe = null; - try { - tpe = new ThreadPoolExecutor(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10)); - } catch(Exception e){} - try { - tpe.setMaximumPoolSize(-1); - shouldThrow(); - } catch(IllegalArgumentException success){ - } finally { - try { tpe.shutdown(); } catch(SecurityException ok) { return; } - } - joinPool(tpe); - } - - - /** - * setKeepAliveTime throws IllegalArgumentException - * when given a negative value - */ - public void testKeepAliveTimeIllegalArgumentException() { - ThreadPoolExecutor tpe = null; - try { - tpe = new ThreadPoolExecutor(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10)); - } catch(Exception e){} - - try { - tpe.setKeepAliveTime(-1,TimeUnit.MILLISECONDS); - shouldThrow(); - } catch(IllegalArgumentException success){ - } finally { - try { tpe.shutdown(); } catch(SecurityException ok) { return; } - } - joinPool(tpe); - } - - /** - * terminated() is called on termination - */ - public void testTerminated() { - ExtendedTPE tpe = new ExtendedTPE(); - try { tpe.shutdown(); } catch(SecurityException ok) { return; } - assertTrue(tpe.terminatedCalled); - joinPool(tpe); - } - - /** - * beforeExecute and afterExecute are called when executing task - */ - public void testBeforeAfter() { - ExtendedTPE tpe = new ExtendedTPE(); - try { - TrackedNoOpRunnable r = new TrackedNoOpRunnable(); - tpe.execute(r); - Thread.sleep(SHORT_DELAY_MS); - assertTrue(r.done); - assertTrue(tpe.beforeCalled); - assertTrue(tpe.afterCalled); - try { tpe.shutdown(); } catch(SecurityException ok) { return; } - } - catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(tpe); - } - } - - /** - * completed submit of callable returns result - */ - public void testSubmitCallable() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - Future future = e.submit(new StringTask()); - String result = future.get(); - assertSame(TEST_STRING, result); - } - catch (ExecutionException ex) { - unexpectedException(); - } - catch (InterruptedException ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * completed submit of runnable returns successfully - */ - public void testSubmitRunnable() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - Future future = e.submit(new NoOpRunnable()); - future.get(); - assertTrue(future.isDone()); - } - catch (ExecutionException ex) { - unexpectedException(); - } - catch (InterruptedException ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * completed submit of (runnable, result) returns result - */ - public void testSubmitRunnable2() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - Future future = e.submit(new NoOpRunnable(), TEST_STRING); - String result = future.get(); - assertSame(TEST_STRING, result); - } - catch (ExecutionException ex) { - unexpectedException(); - } - catch (InterruptedException ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - - - - - /** - * invokeAny(null) throws NPE - */ - public void testInvokeAny1() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - e.invokeAny(null); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAny(empty collection) throws IAE - */ - public void testInvokeAny2() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - e.invokeAny(new ArrayList>()); - } catch (IllegalArgumentException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAny(c) throws NPE if c has null elements - */ - public void testInvokeAny3() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(null); - e.invokeAny(l); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAny(c) throws ExecutionException if no task completes - */ - public void testInvokeAny4() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - ArrayList> l = new ArrayList>(); - l.add(new NPETask()); - e.invokeAny(l); - } catch (ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAny(c) returns result of some task - */ - public void testInvokeAny5() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(new StringTask()); - String result = e.invokeAny(l); - assertSame(TEST_STRING, result); - } catch (ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAll(null) throws NPE - */ - public void testInvokeAll1() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - e.invokeAll(null); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAll(empty collection) returns empty collection - */ - public void testInvokeAll2() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - List> r = e.invokeAll(new ArrayList>()); - assertTrue(r.isEmpty()); - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAll(c) throws NPE if c has null elements - */ - public void testInvokeAll3() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(null); - e.invokeAll(l); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * get of element of invokeAll(c) throws exception on failed task - */ - public void testInvokeAll4() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - ArrayList> l = new ArrayList>(); - l.add(new NPETask()); - List> result = e.invokeAll(l); - assertEquals(1, result.size()); - for (Iterator> it = result.iterator(); it.hasNext();) - it.next().get(); - } catch(ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * invokeAll(c) returns results of all completed tasks - */ - public void testInvokeAll5() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(new StringTask()); - List> result = e.invokeAll(l); - assertEquals(2, result.size()); - for (Iterator> it = result.iterator(); it.hasNext();) - assertSame(TEST_STRING, it.next().get()); - } catch (ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - - - /** - * timed invokeAny(null) throws NPE - */ - public void testTimedInvokeAny1() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - e.invokeAny(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAny(,,null) throws NPE - */ - public void testTimedInvokeAnyNullTimeUnit() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - e.invokeAny(l, MEDIUM_DELAY_MS, null); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAny(empty collection) throws IAE - */ - public void testTimedInvokeAny2() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - e.invokeAny(new ArrayList>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - } catch (IllegalArgumentException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAny(c) throws NPE if c has null elements - */ - public void testTimedInvokeAny3() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(null); - e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - } catch (NullPointerException success) { - } catch(Exception ex) { - ex.printStackTrace(); - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAny(c) throws ExecutionException if no task completes - */ - public void testTimedInvokeAny4() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - ArrayList> l = new ArrayList>(); - l.add(new NPETask()); - e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - } catch(ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAny(c) returns result of some task - */ - public void testTimedInvokeAny5() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(new StringTask()); - String result = e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - assertSame(TEST_STRING, result); - } catch (ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAll(null) throws NPE - */ - public void testTimedInvokeAll1() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - e.invokeAll(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAll(,,null) throws NPE - */ - public void testTimedInvokeAllNullTimeUnit() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - e.invokeAll(l, MEDIUM_DELAY_MS, null); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAll(empty collection) returns empty collection - */ - public void testTimedInvokeAll2() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - List> r = e.invokeAll(new ArrayList>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - assertTrue(r.isEmpty()); - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAll(c) throws NPE if c has null elements - */ - public void testTimedInvokeAll3() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(null); - e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - } catch (NullPointerException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * get of element of invokeAll(c) throws exception on failed task - */ - public void testTimedInvokeAll4() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - ArrayList> l = new ArrayList>(); - l.add(new NPETask()); - List> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - assertEquals(1, result.size()); - for (Iterator> it = result.iterator(); it.hasNext();) - it.next().get(); - } catch(ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAll(c) returns results of all completed tasks - */ - public void testTimedInvokeAll5() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(new StringTask()); - List> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); - assertEquals(2, result.size()); - for (Iterator> it = result.iterator(); it.hasNext();) - assertSame(TEST_STRING, it.next().get()); - } catch (ExecutionException success) { - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * timed invokeAll(c) cancels tasks not completed by timeout - */ - public void testTimedInvokeAll6() { - ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); - try { - ArrayList> l = new ArrayList>(); - l.add(new StringTask()); - l.add(Executors.callable(new MediumPossiblyInterruptedRunnable(), TEST_STRING)); - l.add(new StringTask()); - List> result = e.invokeAll(l, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); - assertEquals(3, result.size()); - Iterator> it = result.iterator(); - Future f1 = it.next(); - Future f2 = it.next(); - Future f3 = it.next(); - assertTrue(f1.isDone()); - assertTrue(f2.isDone()); - assertTrue(f3.isDone()); - assertFalse(f1.isCancelled()); - assertTrue(f2.isCancelled()); - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * Execution continues if there is at least one thread even if - * thread factory fails to create more - */ - public void testFailingThreadFactory() { - ExecutorService e = new ThreadPoolExecutor(100, 100, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new FailingThreadFactory()); - try { - ArrayList> l = new ArrayList>(); - for (int k = 0; k < 100; ++k) { - e.execute(new NoOpRunnable()); - } - Thread.sleep(LONG_DELAY_MS); - } catch(Exception ex) { - unexpectedException(); - } finally { - joinPool(e); - } - } - - /** - * execute allows the same task to be submitted multiple times, even - * if rejected - */ - public void testRejectedRecycledTask() { - final int nTasks = 1000; - final AtomicInteger nRun = new AtomicInteger(0); - final Runnable recycledTask = new Runnable() { - public void run() { - nRun.getAndIncrement(); - } }; - final ThreadPoolExecutor p = - new ThreadPoolExecutor(1, 30, 60, TimeUnit.SECONDS, - new ArrayBlockingQueue(30)); - try { - for (int i = 0; i < nTasks; ++i) { - for (;;) { - try { - p.execute(recycledTask); - break; - } - catch (RejectedExecutionException ignore) { - } - } - } - Thread.sleep(5000); // enough time to run all tasks - assertEquals(nRun.get(), nTasks); - } catch(Exception ex) { - ex.printStackTrace(); - unexpectedException(); - } finally { - p.shutdown(); - } - } - -} diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ThreadTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ThreadTest.java deleted file mode 100755 index 253d9ebd3..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/ThreadTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -// BEGIN android-added -import dalvik.annotation.BrokenTest; -// END android-added - -import junit.framework.*; - -public class ThreadTest extends JSR166TestCase { - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } - - public static Test suite() { - return new TestSuite(ThreadTest.class); - } - - static class MyHandler implements Thread.UncaughtExceptionHandler { - public void uncaughtException(Thread t, Throwable e) { - e.printStackTrace(); - } - } - - /** - * getUncaughtExceptionHandler returns ThreadGroup unless set, - * otherwise returning value of last setUncaughtExceptionHandler. - */ - public void testGetAndSetUncaughtExceptionHandler() { - // these must be done all at once to avoid state - // dependencies across tests - Thread current = Thread.currentThread(); - ThreadGroup tg = current.getThreadGroup(); - MyHandler eh = new MyHandler(); - assertEquals(tg, current.getUncaughtExceptionHandler()); - current.setUncaughtExceptionHandler(eh); - assertEquals(eh, current.getUncaughtExceptionHandler()); - current.setUncaughtExceptionHandler(null); - assertEquals(tg, current.getUncaughtExceptionHandler()); - } - - /** - * getDefaultUncaughtExceptionHandler returns value of last - * setDefaultUncaughtExceptionHandler. - */ - // BEGIN android-added - @BrokenTest("Different behavior between run-core-tests and CTS") - // END android-added - public void testGetAndSetDefaultUncaughtExceptionHandler() { - assertEquals(null, Thread.getDefaultUncaughtExceptionHandler()); - // failure due to securityException is OK. - // Would be nice to explicitly test both ways, but cannot yet. - try { - Thread current = Thread.currentThread(); - ThreadGroup tg = current.getThreadGroup(); - MyHandler eh = new MyHandler(); - Thread.setDefaultUncaughtExceptionHandler(eh); - assertEquals(eh, Thread.getDefaultUncaughtExceptionHandler()); - Thread.setDefaultUncaughtExceptionHandler(null); - } - catch(SecurityException ok) { - } - assertEquals(null, Thread.getDefaultUncaughtExceptionHandler()); - } - - - // How to test actually using UEH within junit? - -} - diff --git a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/TimeUnitTest.java b/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/TimeUnitTest.java deleted file mode 100755 index 54fdc6957..000000000 --- a/libcore/concurrent/src/test/java/tests/api/java/util/concurrent/TimeUnitTest.java +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. - */ - -package tests.api.java.util.concurrent; - -import junit.framework.*; -import java.util.concurrent.*; -import java.io.*; - -public class TimeUnitTest extends JSR166TestCase { - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } - - public static Test suite() { - return new TestSuite(TimeUnitTest.class); - } - - // (loops to 88888 check increments at all time divisions.) - - /** - * convert correctly converts sample values across the units - */ - public void testConvert() { - for (long t = 0; t < 88888; ++t) { - assertEquals(t, - TimeUnit.SECONDS.convert(t, - TimeUnit.SECONDS)); - assertEquals(t, - TimeUnit.SECONDS.convert(1000L*t, - TimeUnit.MILLISECONDS)); - assertEquals(t, - TimeUnit.SECONDS.convert(1000000L*t, - TimeUnit.MICROSECONDS)); - assertEquals(t, - TimeUnit.SECONDS.convert(1000000000L*t, - TimeUnit.NANOSECONDS)); - - - assertEquals(1000L*t, - TimeUnit.MILLISECONDS.convert(t, - TimeUnit.SECONDS)); - assertEquals(t, - TimeUnit.MILLISECONDS.convert(t, - TimeUnit.MILLISECONDS)); - assertEquals(t, - TimeUnit.MILLISECONDS.convert(1000L*t, - TimeUnit.MICROSECONDS)); - assertEquals(t, - TimeUnit.MILLISECONDS.convert(1000000L*t, - TimeUnit.NANOSECONDS)); - - assertEquals(1000000L*t, - TimeUnit.MICROSECONDS.convert(t, - TimeUnit.SECONDS)); - assertEquals(1000L*t, - TimeUnit.MICROSECONDS.convert(t, - TimeUnit.MILLISECONDS)); - assertEquals(t, - TimeUnit.MICROSECONDS.convert(t, - TimeUnit.MICROSECONDS)); - assertEquals(t, - TimeUnit.MICROSECONDS.convert(1000L*t, - TimeUnit.NANOSECONDS)); - - assertEquals(1000000000L*t, - TimeUnit.NANOSECONDS.convert(t, - TimeUnit.SECONDS)); - assertEquals(1000000L*t, - TimeUnit.NANOSECONDS.convert(t, - TimeUnit.MILLISECONDS)); - assertEquals(1000L*t, - TimeUnit.NANOSECONDS.convert(t, - TimeUnit.MICROSECONDS)); - assertEquals(t, - TimeUnit.NANOSECONDS.convert(t, - TimeUnit.NANOSECONDS)); - } - } - - /** - * toNanos correctly converts sample values in different units to - * nanoseconds - */ - public void testToNanos() { - for (long t = 0; t < 88888; ++t) { - assertEquals(1000000000L*t, - TimeUnit.SECONDS.toNanos(t)); - assertEquals(1000000L*t, - TimeUnit.MILLISECONDS.toNanos(t)); - assertEquals(1000L*t, - TimeUnit.MICROSECONDS.toNanos(t)); - assertEquals(t, - TimeUnit.NANOSECONDS.toNanos(t)); - } - } - - /** - * toMicros correctly converts sample values in different units to - * microseconds - */ - public void testToMicros() { - for (long t = 0; t < 88888; ++t) { - assertEquals(1000000L*t, - TimeUnit.SECONDS.toMicros(t)); - assertEquals(1000L*t, - TimeUnit.MILLISECONDS.toMicros(t)); - assertEquals(t, - TimeUnit.MICROSECONDS.toMicros(t)); - assertEquals(t, - TimeUnit.NANOSECONDS.toMicros(t*1000L)); - } - } - - /** - * toMillis correctly converts sample values in different units to - * milliseconds - */ - public void testToMillis() { - for (long t = 0; t < 88888; ++t) { - assertEquals(1000L*t, - TimeUnit.SECONDS.toMillis(t)); - assertEquals(t, - TimeUnit.MILLISECONDS.toMillis(t)); - assertEquals(t, - TimeUnit.MICROSECONDS.toMillis(t*1000L)); - assertEquals(t, - TimeUnit.NANOSECONDS.toMillis(t*1000000L)); - } - } - - /** - * toSeconds correctly converts sample values in different units to - * seconds - */ - public void testToSeconds() { - for (long t = 0; t < 88888; ++t) { - assertEquals(t, - TimeUnit.SECONDS.toSeconds(t)); - assertEquals(t, - TimeUnit.MILLISECONDS.toSeconds(t*1000L)); - assertEquals(t, - TimeUnit.MICROSECONDS.toSeconds(t*1000000L)); - assertEquals(t, - TimeUnit.NANOSECONDS.toSeconds(t*1000000000L)); - } - } - - /** - * convert saturates positive too-large values to Long.MAX_VALUE - * and negative to LONG.MIN_VALUE - */ - public void testConvertSaturate() { - assertEquals(Long.MAX_VALUE, - TimeUnit.NANOSECONDS.convert(Long.MAX_VALUE / 2, - TimeUnit.SECONDS)); - assertEquals(Long.MIN_VALUE, - TimeUnit.NANOSECONDS.convert(-Long.MAX_VALUE / 4, - TimeUnit.SECONDS)); - - } - - /** - * toNanos saturates positive too-large values to Long.MAX_VALUE - * and negative to LONG.MIN_VALUE - */ - public void testToNanosSaturate() { - assertEquals(Long.MAX_VALUE, - TimeUnit.MILLISECONDS.toNanos(Long.MAX_VALUE / 2)); - assertEquals(Long.MIN_VALUE, - TimeUnit.MILLISECONDS.toNanos(-Long.MAX_VALUE / 3)); - } - - - /** - * toString returns string containing common name of unit - */ - public void testToString() { - String s = TimeUnit.SECONDS.toString(); - assertTrue(s.indexOf("ECOND") >= 0); - } - - - /** - * Timed wait without holding lock throws - * IllegalMonitorStateException - */ - public void testTimedWait_IllegalMonitorException() { - //created a new thread with anonymous runnable - - Thread t = new Thread(new Runnable() { - public void run() { - Object o = new Object(); - TimeUnit tu = TimeUnit.MILLISECONDS; - try { - tu.timedWait(o,LONG_DELAY_MS); - threadShouldThrow(); - } - catch (InterruptedException ie) { - threadUnexpectedException(); - } - catch(IllegalMonitorStateException success) { - } - - } - }); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch(Exception e) { - unexpectedException(); - } - } - - /** - * timedWait throws InterruptedException when interrupted - */ - public void testTimedWait() { - Thread t = new Thread(new Runnable() { - public void run() { - Object o = new Object(); - - TimeUnit tu = TimeUnit.MILLISECONDS; - try { - synchronized(o) { - tu.timedWait(o,MEDIUM_DELAY_MS); - } - threadShouldThrow(); - } - catch(InterruptedException success) {} - catch(IllegalMonitorStateException failure) { - threadUnexpectedException(); - } - } - }); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch(Exception e) { - unexpectedException(); - } - } - - - /** - * timedJoin throws InterruptedException when interrupted - */ - public void testTimedJoin() { - Thread t = new Thread(new Runnable() { - public void run() { - TimeUnit tu = TimeUnit.MILLISECONDS; - try { - Thread s = new Thread(new Runnable() { - public void run() { - try { - Thread.sleep(MEDIUM_DELAY_MS); - } catch(InterruptedException success){} - } - }); - s.start(); - tu.timedJoin(s,MEDIUM_DELAY_MS); - threadShouldThrow(); - } - catch(Exception e) {} - } - }); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch(Exception e) { - unexpectedException(); - } - } - - /** - * timedSleep throws InterruptedException when interrupted - */ - public void testTimedSleep() { - //created a new thread with anonymous runnable - - Thread t = new Thread(new Runnable() { - public void run() { - TimeUnit tu = TimeUnit.MILLISECONDS; - try { - tu.sleep(MEDIUM_DELAY_MS); - threadShouldThrow(); - } - catch(InterruptedException success) {} - } - }); - t.start(); - try { - Thread.sleep(SHORT_DELAY_MS); - t.interrupt(); - t.join(); - } catch(Exception e) { - unexpectedException(); - } - } - - /** - * a deserialized serialized unit is equal - */ - public void testSerialization() { - TimeUnit q = TimeUnit.MILLISECONDS; - - try { - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(q); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - TimeUnit r = (TimeUnit)in.readObject(); - - assertEquals(q.toString(), r.toString()); - } catch(Exception e){ - e.printStackTrace(); - unexpectedException(); - } - } - -} diff --git a/libcore/concurrent/src/test/java/tests/concurrent/AllTests.java b/libcore/concurrent/src/test/java/tests/concurrent/AllTests.java deleted file mode 100644 index d2ebbebda..000000000 --- a/libcore/concurrent/src/test/java/tests/concurrent/AllTests.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package tests.concurrent; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Test suite for the concurrent module - */ -public class AllTests { - - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } - - /** - * Collects all JSR166 unit tests as one suite - */ - public static Test suite ( ) { - TestSuite suite = tests.TestSuiteFactory.createTestSuite("JSR166 Unit Tests"); - - suite.addTest(tests.api.java.util.concurrent.JSR166TestCase.suite()); - - return suite; - } -} diff --git a/libcore/crypto/MODULE_LICENSE_APACHE2 b/libcore/crypto/MODULE_LICENSE_APACHE2 deleted file mode 100644 index e69de29bb..000000000 diff --git a/libcore/crypto/src/main/java/javax/crypto/BadPaddingException.java b/libcore/crypto/src/main/java/javax/crypto/BadPaddingException.java deleted file mode 100644 index 5e2dd3882..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/BadPaddingException.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.security.GeneralSecurityException; - -/** - * The exception that is thrown when a padding mechanism is expected for the - * input data, but the input data does not have the proper padding bytes. - */ -public class BadPaddingException extends GeneralSecurityException { - - /** - * @serial - */ - private static final long serialVersionUID = -5315033893984728443L; - - /** - * Creates a new instance of {@code BadPaddingException} with a message. - * - * @param msg - * the message - */ - public BadPaddingException(String msg) { - super(msg); - } - - /** - * Creates a new instance of {@code BadPaddingException} with no message. - */ - public BadPaddingException() { - } -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/Cipher.java b/libcore/crypto/src/main/java/javax/crypto/Cipher.java deleted file mode 100644 index 8e084aee9..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/Cipher.java +++ /dev/null @@ -1,1384 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.nio.ByteBuffer; -import java.security.AlgorithmParameters; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.InvalidParameterException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.Provider; -import java.security.SecureRandom; -import java.security.Security; -import java.security.cert.Certificate; -import java.security.cert.X509Certificate; -import java.security.spec.AlgorithmParameterSpec; -import java.util.Set; -import java.util.StringTokenizer; - -import org.apache.harmony.crypto.internal.NullCipherSpi; -import org.apache.harmony.crypto.internal.nls.Messages; -import org.apache.harmony.security.fortress.Engine; - -/** - * This class provides access to implementations of cryptographic ciphers for - * encryption and decryption. Cipher classes can not be instantiated directly, - * one has to call the Cipher's {@code getInstance} method with the name of a - * requested transformation, optionally with a provider. A transformation - * specifies an operation (or a set of operations) as a string in the form: - *
    - *
  • "algorithm/mode/padding"
  • or - *
  • "algorithm"
  • - *
- * algorithm is the name of a cryptographic algorithm, mode is the - * name of a feedback mode and padding is the name of a padding scheme. - * If mode and/or padding values are omitted, provider specific - * default values will be used. - *

- * A valid transformation would be: - *

    - * {@code Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding");} - *
- * When a block cipher is requested in in stream cipher mode, the number of bits - * to be processed at a time can be optionally specified by appending it to the - * mode name. e.g. "AES/CFB8/NoPadding". If no number is specified, a - * provider specific default value is used. - */ -public class Cipher { - - /** - * Constant for decryption operation mode. - */ - public static final int DECRYPT_MODE = 2; - - /** - * Constant for encryption operation mode. - */ - public static final int ENCRYPT_MODE = 1; - - /** - * Constant indicating that the key to be unwrapped is a private key. - */ - public static final int PRIVATE_KEY = 2; - - /** - * Constant indicating that the key to be unwrapped is a public key. - */ - public static final int PUBLIC_KEY = 1; - - /** - * Constant indicating that the key to be unwrapped is a secret key. - */ - public static final int SECRET_KEY = 3; - - /** - * Constant for key unwrapping operation mode. - */ - public static final int UNWRAP_MODE = 4; - - /** - * Constant for key wrapping operation mode. - */ - public static final int WRAP_MODE = 3; - - private int mode; - - /** - * The service name. - */ - private static final String SERVICE = "Cipher"; //$NON-NLS-1$ - - /** - * Used to access common engine functionality. - */ - private static final Engine engine = new Engine(SERVICE); - - /** - * The provider. - */ - private Provider provider; - - /** - * The SPI implementation. - */ - private CipherSpi spiImpl; - - /** - * The transformation. - */ - private String transformation; - - private static SecureRandom sec_rand; - - /** - * Creates a new Cipher instance. - * - * @param cipherSpi - * the implementation delegate of the cipher. - * @param provider - * the provider of the implementation of this cipher. - * @param transformation - * the name of the transformation that this cipher performs. - * @throws NullPointerException - * if either cipherSpi is {@code null} or provider is {@code - * null} and {@code cipherSpi} is a {@code NullCipherSpi}. - */ - protected Cipher(CipherSpi cipherSpi, Provider provider, - String transformation) { - if (cipherSpi == null) { - throw new NullPointerException(); - } - if (!(cipherSpi instanceof NullCipherSpi) && provider == null) { - throw new NullPointerException(); - } - this.provider = provider; - this.transformation = transformation; - this.spiImpl = cipherSpi; - } - - /** - * Creates a new Cipher for the specified transformation. The installed - * providers are searched in order for an implementation of the specified - * transformation. The first found provider providing the transformation is - * used to create the cipher. If no provider is found an exception is - * thrown. - * - * @param transformation - * the name of the transformation to create a cipher for. - * @return a cipher for the requested transformation. - * @throws NoSuchAlgorithmException - * if no installed provider can provide the - * transformation, or it is {@code null}, empty or in an - * invalid format. - * @throws NoSuchPaddingException - * if no installed provider can provide the padding scheme in - * the transformation. - */ - public static final Cipher getInstance(String transformation) - throws NoSuchAlgorithmException, NoSuchPaddingException { - return getCipher(transformation, null); - } - - /** - * Creates a new cipher for the specified transformation provided by the - * specified provider. - * - * @param transformation - * the name of the transformation to create a cipher for. - * @param provider - * the name of the provider to ask for the transformation. - * @return a cipher for the requested transformation. - * @throws NoSuchAlgorithmException - * if the specified provider can not provide the - * transformation, or it is {@code null}, empty or in an - * invalid format. - * @throws NoSuchProviderException - * if no provider with the specified name can be found. - * @throws NoSuchPaddingException - * if the requested padding scheme in the transformation - * is not available. - * @throws IllegalArgumentException - * if the specified provider is {@code null}. - */ - public static final Cipher getInstance(String transformation, - String provider) throws NoSuchAlgorithmException, - NoSuchProviderException, NoSuchPaddingException { - - if (provider == null) { - throw new IllegalArgumentException(Messages.getString("crypto.04")); //$NON-NLS-1$ - } - - Provider p = Security.getProvider(provider); - if (p == null) { - throw new NoSuchProviderException(Messages.getString("crypto.16", provider)); //$NON-NLS-1$ - } - return getInstance(transformation, p); - } - - /** - * Creates a new cipher for the specified transformation. - * - * @param transformation - * the name of the transformation to create a cipher for. - * @param provider - * the provider to ask for the transformation. - * @return a cipher for the requested transformation. - * @throws NoSuchAlgorithmException - * if the specified provider can not provide the - * transformation, or it is {@code null}, empty or in an - * invalid format. - * @throws NoSuchPaddingException - * if the requested padding scheme in the transformation - * is not available. - * @throws IllegalArgumentException - * if the provider is {@code null}. - */ - public static final Cipher getInstance(String transformation, - Provider provider) throws NoSuchAlgorithmException, - NoSuchPaddingException { - if (provider == null) { - throw new IllegalArgumentException(Messages.getString("crypto.04")); //$NON-NLS-1$ - } - Cipher c = getCipher(transformation, provider); - return c; - } - - /** - * Find appropriate Cipher according the specification rules - * - * @param transformation - * @param provider - * @return - * @throws NoSuchAlgorithmException - * @throws NoSuchPaddingException - */ - private static synchronized Cipher getCipher(String transformation, Provider provider) - throws NoSuchAlgorithmException, NoSuchPaddingException { - - if (transformation == null || "".equals(transformation)) { //$NON-NLS-1$ - throw new NoSuchAlgorithmException(Messages.getString("crypto.17", //$NON-NLS-1$ - transformation)); - } - - String[] transf = checkTransformation(transformation); - - boolean needSetPadding = false; - boolean needSetMode = false; - if (transf[1] == null && transf[2] == null) { // "algorithm" - if (provider == null) { - engine.getInstance(transf[0], null); - } else { - engine.getInstance(transf[0], provider, null); - } - } else { - String[] searhOrder = { - transf[0] + "/" + transf[1] + "/" + transf[2], // "algorithm/mode/padding" //$NON-NLS-1$ //$NON-NLS-2$ - transf[0] + "/" + transf[1], // "algorithm/mode" //$NON-NLS-1$ - transf[0] + "//" + transf[2], // "algorithm//padding" //$NON-NLS-1$ - transf[0] // "algorithm" - }; - int i; - for (i = 0; i < searhOrder.length; i++) { - try { - if (provider == null) { - engine.getInstance(searhOrder[i], null); - } else { - engine.getInstance(searhOrder[i], provider, null); - } - break; - } catch (NoSuchAlgorithmException e) { - if ( i == searhOrder.length-1) { - throw new NoSuchAlgorithmException(transformation); - } - } - } - switch (i) { - case 1: // "algorithm/mode" - needSetPadding = true; - break; - case 2: // "algorithm//padding" - needSetMode = true; - break; - case 3: // "algorithm" - needSetPadding = true; - needSetMode = true; - } - } - CipherSpi cspi; - try { - cspi = (CipherSpi) engine.spi; - } catch (ClassCastException e) { - throw new NoSuchAlgorithmException(e); - } - Cipher c = new Cipher(cspi, engine.provider, transformation); - if (needSetMode) { - c.spiImpl.engineSetMode(transf[1]); - } - if (needSetPadding) { - c.spiImpl.engineSetPadding(transf[2]); - } - return c; - } - - private static String[] checkTransformation(String transformation) - throws NoSuchAlgorithmException { - String[] transf = { null, null, null }; - StringTokenizer st; - int i = 0; - for (st = new StringTokenizer(transformation, "/"); st //$NON-NLS-1$ - .hasMoreElements();) { - if (i > 2) { - throw new NoSuchAlgorithmException(Messages.getString("crypto.17", //$NON-NLS-1$ - transformation)); - } - transf[i] = st.nextToken(); - if (transf[i] != null) { - transf[i] = transf[i].trim(); - if ("".equals(transf[i])) { //$NON-NLS-1$ - transf[i] = null; - } - i++; - } - } - if (transf[0] == null) { - throw new NoSuchAlgorithmException(Messages.getString("crypto.17", //$NON-NLS-1$ - transformation)); - } - if (!(transf[1] == null && transf[2] == null) - && (transf[1] == null || transf[2] == null)) { - throw new NoSuchAlgorithmException(Messages.getString("crypto.17", //$NON-NLS-1$ - transformation)); - } - return transf; - } - - /** - * Returns the provider of this cipher instance. - * - * @return the provider of this cipher instance. - */ - public final Provider getProvider() { - return provider; - } - - /** - * Returns the name of the algorithm of this cipher instance. - *

- * This is the name of the transformation argument used in the - * {@code getInstance} call creating this object. - * - * @return the name of the algorithm of this cipher instance. - */ - public final String getAlgorithm() { - return transformation; - } - - /** - * Returns this ciphers block size (in bytes). - * - * @return this ciphers block size. - */ - public final int getBlockSize() { - return spiImpl.engineGetBlockSize(); - } - - /** - * Returns the length in bytes an output buffer needs to be when this cipher - * is updated with {@code inputLen} bytes. - * - * @param inputLen - * the number of bytes of the input. - * @return the output buffer length for the input length. - * @throws IllegalStateException - * if this cipher instance is in an invalid state. - */ - public final int getOutputSize(int inputLen) { - if (mode == 0) { - throw new IllegalStateException( - Messages.getString("crypto.18")); //$NON-NLS-1$ - } - return spiImpl.engineGetOutputSize(inputLen); - } - - /** - * Returns the initialization vector for this cipher instance. - * - * @return the initialization vector for this cipher instance. - */ - public final byte[] getIV() { - return spiImpl.engineGetIV(); - } - - /** - * Returns the parameters that where used to create this cipher instance. - *

- * These may be a the same parameters that were used to create this cipher - * instance, or may be a combination of default and random parameters, - * depending on the underlying cipher implementation. - * - * @return the parameters that where used to create this cipher instance, or - * {@code null} if this cipher instance does not have any - * parameters. - */ - public final AlgorithmParameters getParameters() { - return spiImpl.engineGetParameters(); - } - - /** - * Returns the exemption mechanism associated with this cipher. - * - * @return currently {@code null} - */ - public final ExemptionMechanism getExemptionMechanism() { - //FIXME implement getExemptionMechanism - - // try { - // return ExemptionMechanism.getInstance(transformation, provider); - // } catch (NoSuchAlgorithmException e) { - return null; - // } - - } - - /** - * Initializes this cipher instance with the specified key. - *

- * The cipher is initialized for the specified operational mode (one of: - * encryption, decryption, key wrapping or key unwrapping) depending on - * {@code opmode}. - *

- * If this cipher instance needs any algorithm parameters or random values - * that the specified key can not provide, the underlying implementation of - * this cipher is supposed to generate the required parameters (using its - * provider or random values). - *

- * When a cipher instance is initialized by a call to any of the {@code - * init} methods, the state of the instance is overridden, meaning that it - * is equivalent to creating a new instance and calling its {@code init} - * method. - * - * @param opmode - * the operation this cipher instance should be initialized for - * (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code - * WRAP_MODE} or {@code UNWRAP_MODE}). - * @param key - * the input key for the operation. - * @throws InvalidKeyException - * if the specified key can not be used to initialize this - * cipher instance. - */ - public final void init(int opmode, Key key) throws InvalidKeyException { - if (sec_rand == null) { - // In theory it might be thread-unsafe but in the given case it's OK - // since it does not matter which SecureRandom instance is passed - // to the init() - sec_rand = new SecureRandom(); - } - init(opmode, key, sec_rand); - } - - /** - * Initializes this cipher instance with the specified key and a source of - * randomness. - *

- * The cipher is initialized for the specified operational mode (one of: - * encryption, decryption, key wrapping or key unwrapping) depending on - * {@code opmode}. - *

- * If this cipher instance needs any algorithm parameters or random values - * that the specified key can not provide, the underlying implementation of - * this cipher is supposed to generate the required parameters (using its - * provider or random values). Random values are generated using {@code - * random}; - *

- * When a cipher instance is initialized by a call to any of the {@code - * init} methods, the state of the instance is overridden, means it is - * equivalent to creating a new instance and calling it {@code init} method. - * - * @param opmode - * the operation this cipher instance should be initialized for - * (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code - * WRAP_MODE} or {@code UNWRAP_MODE}). - * @param key - * the input key for the operation. - * @param random - * the source of randomness to use. - * @throws InvalidKeyException - * if the specified key can not be used to initialize this - * cipher instance. - * @throws InvalidParameterException - * if the specified opmode is invalid. - */ - public final void init(int opmode, Key key, SecureRandom random) - throws InvalidKeyException { - if (opmode != ENCRYPT_MODE && opmode != DECRYPT_MODE - && opmode != UNWRAP_MODE && opmode != WRAP_MODE) { - throw new InvalidParameterException(Messages.getString("crypto.19")); //$NON-NLS-1$ - } - // FIXME InvalidKeyException - // if keysize exceeds the maximum allowable keysize - // (jurisdiction policy files) - spiImpl.engineInit(opmode, key, random); - mode = opmode; - } - - /** - * Initializes this cipher instance with the specified key and algorithm - * parameters. - *

- * The cipher is initialized for the specified operational mode (one of: - * encryption, decryption, key wrapping or key unwrapping). - *

- * If this cipher instance needs any algorithm parameters and {@code params} - * is {@code null}, the underlying implementation of this cipher is supposed - * to generate the required parameters (using its provider or random - * values). - *

- * When a cipher instance is initialized by a call to any of the {@code - * init} methods, the state of the instance is overridden, means it is - * equivalent to creating a new instance and calling it {@code init} method. - * - * @param opmode - * the operation this cipher instance should be initialized for - * (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code - * WRAP_MODE} or {@code UNWRAP_MODE}). - * @param key - * the input key for the operation. - * @param params - * the algorithm parameters. - * @throws InvalidKeyException - * if the specified key can not be used to initialize this - * cipher instance. - * @throws InvalidAlgorithmParameterException - * it the specified parameters are inappropriate for this - * cipher. - */ - public final void init(int opmode, Key key, AlgorithmParameterSpec params) - throws InvalidKeyException, InvalidAlgorithmParameterException { - if (sec_rand == null) { - sec_rand = new SecureRandom(); - } - init(opmode, key, params, sec_rand); - } - - /** - * Initializes this cipher instance with the specified key, algorithm - * parameters and a source of randomness. - *

- * The cipher is initialized for the specified operational mode (one of: - * encryption, decryption, key wrapping or key unwrapping) depending on - * {@code opmode}. - *

- * If this cipher instance needs any algorithm parameters and {@code params} - * is {@code null}, the underlying implementation of this cipher is supposed - * to generate the required parameters (using its provider or random - * values). Random values are generated using {@code random}; - *

- * When a cipher instance is initialized by a call to any of the {@code - * init} methods, the state of the instance is overridden, meaning that it - * is equivalent to creating a new instance and calling it {@code init} - * method. - * - * @param opmode - * the operation this cipher instance should be initialized for - * (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code - * WRAP_MODE} or {@code UNWRAP_MODE}). - * @param key - * the input key for the operation. - * @param params - * the algorithm parameters. - * @param random - * the source of randomness to use. - * @throws InvalidKeyException - * if the specified key can not be used to initialize this - * cipher instance. - * @throws InvalidAlgorithmParameterException - * it the specified parameters are inappropriate for this - * cipher. - * @throws InvalidParameterException - * if the specified {@code opmode} is invalid. - */ - public final void init(int opmode, Key key, AlgorithmParameterSpec params, - SecureRandom random) throws InvalidKeyException, - InvalidAlgorithmParameterException { - if (opmode != ENCRYPT_MODE && opmode != DECRYPT_MODE - && opmode != UNWRAP_MODE && opmode != WRAP_MODE) { - throw new InvalidParameterException(Messages.getString("crypto.19")); //$NON-NLS-1$ - } - // FIXME InvalidKeyException - // if keysize exceeds the maximum allowable keysize - // (jurisdiction policy files) - // FIXME InvalidAlgorithmParameterException - // cryptographic strength exceed the legal limits - // (jurisdiction policy files) - spiImpl.engineInit(opmode, key, params, random); - mode = opmode; - } - - /** - * Initializes this cipher instance with the specified key and algorithm - * parameters. - *

- * The cipher is initialized for the specified operation (one of: - * encryption, decryption, key wrapping or key unwrapping) depending on - * {@code opmode}. - *

- * If this cipher instance needs any algorithm parameters and {@code params} - * is {@code null}, the underlying implementation of this cipher is supposed - * to generate the required parameters (using its provider or random - * values). - *

- * When a cipher instance is initialized by a call to any of the {@code - * init} methods, the state of the instance is overridden, meaning that it - * is equivalent to creating a new instance and calling it {@code init} - * method. - * - * @param opmode - * the operation this cipher instance should be initialized for - * (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code - * WRAP_MODE} or {@code UNWRAP_MODE}). - * @param key - * the input key for the operation. - * @param params - * the algorithm parameters. - * @throws InvalidKeyException - * if the specified key can not be used to initialize this - * cipher instance. - * @throws InvalidAlgorithmParameterException - * it the specified parameters are inappropriate for this - * cipher. - */ - public final void init(int opmode, Key key, AlgorithmParameters params) - throws InvalidKeyException, InvalidAlgorithmParameterException { - if (sec_rand == null) { - sec_rand = new SecureRandom(); - } - init(opmode, key, params, sec_rand); - } - - /** - * Initializes this cipher instance with the specified key, algorithm - * parameters and a source of randomness. - *

- * The cipher will be initialized for the specified operation (one of: - * encryption, decryption, key wrapping or key unwrapping) depending on - * {@code opmode}. - *

- * If this cipher instance needs any algorithm parameters and {@code params} - * is {@code null}, the underlying implementation of this cipher is supposed - * to generate the required parameters (using its provider or random - * values). Random values are generated using {@code random}. - *

- * When a cipher instance is initialized by a call to any of the {@code - * init} methods, the state of the instance is overridden, means it is - * equivalent to creating a new instance and calling it {@code init} method. - * - * @param opmode - * the operation this cipher instance should be initialized for - * (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code - * WRAP_MODE} or {@code UNWRAP_MODE}). - * @param key - * the input key for the operation. - * @param params - * the algorithm parameters. - * @param random - * the source of randomness to use. - * @throws InvalidKeyException - * if the specified key can not be used to initialize this - * cipher instance. - * @throws InvalidAlgorithmParameterException - * if the specified parameters are inappropriate for this - * cipher. - * @throws InvalidParameterException - * if the specified {@code opmode} is invalid. - */ - public final void init(int opmode, Key key, AlgorithmParameters params, - SecureRandom random) throws InvalidKeyException, - InvalidAlgorithmParameterException { - if (opmode != ENCRYPT_MODE && opmode != DECRYPT_MODE - && opmode != UNWRAP_MODE && opmode != WRAP_MODE) { - throw new InvalidParameterException(Messages.getString("crypto.19")); //$NON-NLS-1$ - } - // FIXME InvalidKeyException - // if keysize exceeds the maximum allowable keysize - // (jurisdiction policy files) - // FIXME InvalidAlgorithmParameterException - // cryptographic strength exceed the legal limits - // (jurisdiction policy files) - spiImpl.engineInit(opmode, key, params, random); - mode = opmode; - } - - /** - * Initializes this cipher instance with the public key from the specified - * certificate. - *

- * The cipher will be initialized for the specified operation (one of: - * encryption, decryption, key wrapping or key unwrapping) depending on - * {@code opmode}. - *

- * It the type of the certificate is X.509 and the certificate has a key - * usage extension field marked as critical, the specified {@code - * opmode} has the be enabled for this key, otherwise an {@code - * InvalidKeyException} is thrown. - *

- * If this cipher instance needs any algorithm parameters that the key in - * the certificate can not provide, the underlying implementation of this - * cipher is supposed to generate the required parameters (using its - * provider or random values). - *

- * When a cipher instance is initialized by a call to any of the {@code - * init} methods, the state of the instance is overridden, means it is - * equivalent to creating a new instance and calling it {@code init} method. - * - * @param opmode - * the operation this cipher instance should be initialized for - * (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code - * WRAP_MODE} or {@code UNWRAP_MODE}). - * @param certificate - * the certificate. - * @throws InvalidKeyException - * if the public key in the certificate can not be used to - * initialize this cipher instance. - */ - public final void init(int opmode, Certificate certificate) - throws InvalidKeyException { - if (sec_rand == null) { - sec_rand = new SecureRandom(); - } - init(opmode, certificate, sec_rand); - } - - /** - * Initializes this cipher instance with the public key from the specified - * certificate and a source of randomness. - *

- * The cipher will be initialized for the specified operation (one of: - * encryption, decryption, key wrapping or key unwrapping) depending on - * {@code opmode}. - *

- * It the type of the certificate is X.509 and the certificate has a key - * usage extension field marked as critical, the specified {@code - * opmode} has the be enabled for this key, otherwise an {@code - * InvalidKeyException} is thrown. - *

- * If this cipher instance needs any algorithm parameters that the key in - * the certificate can not provide, the underlying implementation of this - * cipher is supposed to generate the required parameters (using its - * provider or random values). Random values are generated using {@code - * random}. - *

- * When a cipher instance is initialized by a call to any of the {@code - * init} methods, the state of the instance is overridden, means it is - * equivalent to creating a new instance and calling it {@code init} method. - * - * @param opmode - * the operation this cipher instance should be initialized for - * (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code - * WRAP_MODE} or {@code UNWRAP_MODE}). - * @param certificate - * the certificate. - * @param random - * the source of randomness to be used. - * @throws InvalidKeyException - * if the public key in the certificate can not be used to - * initialize this cipher instance. - */ - public final void init(int opmode, Certificate certificate, - SecureRandom random) throws InvalidKeyException { - if (opmode != ENCRYPT_MODE && opmode != DECRYPT_MODE - && opmode != UNWRAP_MODE && opmode != WRAP_MODE) { - throw new InvalidParameterException(Messages.getString("crypto.19")); //$NON-NLS-1$ - } - if (certificate instanceof X509Certificate) { - Set ce = ((X509Certificate) certificate).getCriticalExtensionOIDs(); - boolean critical = false; - if (ce != null && !ce.isEmpty()) { - for (String oid : ce) { - if (oid.equals("2.5.29.15")) { //KeyUsage OID = 2.5.29.15 //$NON-NLS-1$ - critical = true; - break; - } - } - if (critical) { - boolean[] keyUsage = ((X509Certificate) certificate) - .getKeyUsage(); - // As specified in RFC 3280 - - // Internet X.509 Public Key Infrastructure - // Certificate and Certificate Revocation List (CRL) Profile. - // (http://www.ietf.org/rfc/rfc3280.txt) - // - // KeyUsage ::= BIT STRING {digitalSignature (0), - // ... - // encipherOnly (7), - // decipherOnly (8) } - if (keyUsage != null) { - if (opmode == ENCRYPT_MODE && (!keyUsage[7])) { - throw new InvalidKeyException( - Messages.getString("crypto.1A")); //$NON-NLS-1$ - } else if (opmode == DECRYPT_MODE && (!keyUsage[8])) { - throw new InvalidKeyException( - Messages.getString("crypto.1B")); //$NON-NLS-1$ - } - } - } - } - } - // FIXME InvalidKeyException - // if keysize exceeds the maximum allowable keysize - // (jurisdiction policy files) - spiImpl.engineInit(opmode, certificate.getPublicKey(), random); - mode = opmode; - } - - /** - * Continues a multi-part transformation (encryption or decryption). The - * transformed bytes are returned. - * - * @param input - * the input bytes to transform. - * @return the transformed bytes in a new buffer, or {@code null} if the - * input has zero length. - * @throws IllegalStateException - * if this cipher instance is not initialized for encryption or - * decryption. - * @throws IllegalArgumentException - * if the input is {@code null}. - */ - public final byte[] update(byte[] input) { - if (mode != ENCRYPT_MODE && mode != DECRYPT_MODE) { - throw new IllegalStateException( - Messages.getString("crypto.1C")); //$NON-NLS-1$ - } - if (input == null) { - throw new IllegalArgumentException(Messages.getString("crypto.1D")); //$NON-NLS-1$ - } - if (input.length == 0) { - return null; - } - return spiImpl.engineUpdate(input, 0, input.length); - } - - /** - * Continues a multi-part transformation (encryption or decryption). The - * transformed bytes are returned. - * - * @param input - * the input bytes to transform. - * @param inputOffset - * the offset in the input to start. - * @param inputLen - * the length of the input to transform. - * @return the transformed bytes in a new buffer, or {@code null} if the - * input has zero length. - * @throws IllegalStateException - * if this cipher instance is not initialized for encryption or - * decryption. - * @throws IllegalArgumentException - * if the input is {@code null}, or if {@code inputOffset} and - * {@code inputLen} do not specify a valid chunk in the input - * buffer. - */ - public final byte[] update(byte[] input, int inputOffset, int inputLen) { - if (mode != ENCRYPT_MODE && mode != DECRYPT_MODE) { - throw new IllegalStateException( - Messages.getString("crypto.1C")); //$NON-NLS-1$ - } - if (input == null) { - throw new IllegalArgumentException(Messages.getString("crypto.1D")); //$NON-NLS-1$ - } - if (inputOffset < 0 || inputLen < 0 - || inputLen > input.length - || inputOffset > input.length - inputLen) { - throw new IllegalArgumentException( - Messages.getString("crypto.1E")); //$NON-NLS-1$ - } - if (input.length == 0) { - return null; - } - return spiImpl.engineUpdate(input, inputOffset, inputLen); - } - - /** - * Continues a multi-part transformation (encryption or decryption). The - * transformed bytes are stored in the {@code output} buffer. - *

- * If the size of the {@code output} buffer is too small to hold the result, - * a {@code ShortBufferException} is thrown. Use - * {@link Cipher#getOutputSize getOutputSize} to check for the size of the - * output buffer. - * - * @param input - * the input bytes to transform. - * @param inputOffset - * the offset in the input to start. - * @param inputLen - * the length of the input to transform. - * @param output - * the output buffer. - * @return the number of bytes placed in output. - * @throws ShortBufferException - * if the size of the {@code output} buffer is too small. - * @throws IllegalStateException - * if this cipher instance is not initialized for encryption or - * decryption. - * @throws IllegalArgumentException - * if the input is {@code null}, the output is {@code null}, or - * if {@code inputOffset} and {@code inputLen} do not specify a - * valid chunk in the input buffer. - */ - public final int update(byte[] input, int inputOffset, int inputLen, - byte[] output) throws ShortBufferException { - return update(input, inputOffset, inputLen, output, 0); - } - - /** - * Continues a multi-part transformation (encryption or decryption). The - * transformed bytes are stored in the {@code output} buffer. - *

- * If the size of the {@code output} buffer is too small to hold the result, - * a {@code ShortBufferException} is thrown. Use - * {@link Cipher#getOutputSize getOutputSize} to check for the size of the - * output buffer. - * - * @param input - * the input bytes to transform. - * @param inputOffset - * the offset in the input to start. - * @param inputLen - * the length of the input to transform. - * @param output - * the output buffer. - * @param outputOffset - * the offset in the output buffer. - * @return the number of bytes placed in output. - * @throws ShortBufferException - * if the size of the {@code output} buffer is too small. - * @throws IllegalStateException - * if this cipher instance is not initialized for encryption or - * decryption. - * @throws IllegalArgumentException - * if the input is {@code null}, the output is {@code null}, or - * if {@code inputOffset} and {@code inputLen} do not specify a - * valid chunk in the input buffer. - */ - public final int update(byte[] input, int inputOffset, int inputLen, - byte[] output, int outputOffset) throws ShortBufferException { - if (mode != ENCRYPT_MODE && mode != DECRYPT_MODE) { - throw new IllegalStateException( - Messages.getString("crypto.1C")); //$NON-NLS-1$ - } - if (input == null) { - throw new IllegalArgumentException(Messages.getString("crypto.1D")); //$NON-NLS-1$ - } - if (output == null) { - throw new IllegalArgumentException(Messages.getString("crypto.1F")); //$NON-NLS-1$ - } - if (outputOffset < 0) { - throw new IllegalArgumentException( - Messages.getString("crypto.20")); //$NON-NLS-1$ - } - if (inputOffset < 0 || inputLen < 0 - || inputLen > input.length - || inputOffset > input.length - inputLen) { - throw new IllegalArgumentException( - Messages.getString("crypto.21")); //$NON-NLS-1$ - } - if (input.length == 0) { - return 0; - } - return spiImpl.engineUpdate(input, inputOffset, inputLen, output, - outputOffset); - } - - /** - * Continues a multi-part transformation (encryption or decryption). The - * {@code input.remaining()} bytes starting at {@code input.position()} are - * transformed and stored in the {@code output} buffer. - *

- * If the {@code output.remaining()} is too small to hold the transformed - * bytes a {@code ShortBufferException} is thrown. Use - * {@link Cipher#getOutputSize getOutputSize} to check for the size of the - * output buffer. - * - * @param input - * the input buffer to transform. - * @param output - * the output buffer to store the result within. - * @return the number of bytes stored in the output buffer. - * @throws ShortBufferException - * if the size of the {@code output} buffer is too small. - * @throws IllegalStateException - * if this cipher instance is not initialized for encryption or - * decryption. - * @throws IllegalArgumentException - * if the input buffer and the output buffer are the identical - * object. - */ - public final int update(ByteBuffer input, ByteBuffer output) - throws ShortBufferException { - if (mode != ENCRYPT_MODE && mode != DECRYPT_MODE) { - throw new IllegalStateException( - Messages.getString("crypto.1C")); //$NON-NLS-1$ - } - if (input == output) { - throw new IllegalArgumentException( - Messages.getString("crypto.22")); //$NON-NLS-1$ - } - return spiImpl.engineUpdate(input, output); - } - - /** - * Finishes a multi-part transformation (encryption or decryption). - *

- * Processes any bytes that may have been buffered in previous {@code - * update} calls. - * - * @return the final bytes from the transformation. - * @throws IllegalBlockSizeException - * if the size of the resulting bytes is not a multiple of the - * cipher block size. - * @throws BadPaddingException - * if the padding of the data does not match the padding scheme. - * @throws IllegalStateException - * if this cipher instance is not initialized for encryption or - * decryption. - */ - public final byte[] doFinal() throws IllegalBlockSizeException, - BadPaddingException { - if (mode != ENCRYPT_MODE && mode != DECRYPT_MODE) { - throw new IllegalStateException( - Messages.getString("crypto.1C")); //$NON-NLS-1$ - } - return spiImpl.engineDoFinal(null, 0, 0); - } - - /** - * Finishes a multi-part transformation (encryption or decryption). - *

- * Processes any bytes that may have been buffered in previous {@code - * update} calls. - *

- * The final transformed bytes are stored in the {@code output} buffer. - * - * @param output - * the output buffer. - * @param outputOffset - * the offset in the output buffer. - * @return the number of bytes placed in the output buffer. - * @throws IllegalBlockSizeException - * if the size of the resulting bytes is not a multiple of the - * cipher block size. - * @throws ShortBufferException - * if the size of the {@code output} buffer is too small. - * @throws BadPaddingException - * if the padding of the data does not match the padding scheme. - * @throws IllegalStateException - * if this cipher instance is not initialized for encryption or - * decryption. - */ - public final int doFinal(byte[] output, int outputOffset) - throws IllegalBlockSizeException, ShortBufferException, - BadPaddingException { - if (mode != ENCRYPT_MODE && mode != DECRYPT_MODE) { - throw new IllegalStateException( - Messages.getString("crypto.1C")); //$NON-NLS-1$ - } - if (outputOffset < 0) { - throw new IllegalArgumentException( - Messages.getString("crypto.20")); //$NON-NLS-1$ - } - return spiImpl.engineDoFinal(null, 0, 0, output, outputOffset); - } - - /** - * Finishes a multi-part transformation (encryption or decryption). - *

- * Processes the bytes in {@code input} buffer, and any bytes that have been - * buffered in previous {@code update} calls. - * - * @param input - * the input buffer. - * @return the final bytes from the transformation. - * @throws IllegalBlockSizeException - * if the size of the resulting bytes is not a multiple of the - * cipher block size. - * @throws BadPaddingException - * if the padding of the data does not match the padding scheme. - * @throws IllegalStateException - * if this cipher instance is not initialized for encryption or - * decryption. - */ - public final byte[] doFinal(byte[] input) throws IllegalBlockSizeException, - BadPaddingException { - if (mode != ENCRYPT_MODE && mode != DECRYPT_MODE) { - throw new IllegalStateException( - Messages.getString("crypto.1C")); //$NON-NLS-1$ - } - return spiImpl.engineDoFinal(input, 0, input.length); - } - - /** - * Finishes a multi-part transformation (encryption or decryption). - *

- * Processes the {@code inputLen} bytes in {@code input} buffer at {@code - * inputOffset}, and any bytes that have been buffered in previous {@code - * update} calls. - * - * @param input - * the input buffer. - * @param inputOffset - * the offset in the input buffer. - * @param inputLen - * the length of the input - * @return the final bytes from the transformation. - * @throws IllegalBlockSizeException - * if the size of the resulting bytes is not a multiple of the - * cipher block size. - * @throws BadPaddingException - * if the padding of the data does not match the padding scheme. - * @throws IllegalStateException - * if this cipher instance is not initialized for encryption or - * decryption. - * @throws IllegalArgumentException - * if {@code inputOffset} and {@code inputLen} do not specify an - * valid chunk in the input buffer. - */ - public final byte[] doFinal(byte[] input, int inputOffset, int inputLen) - throws IllegalBlockSizeException, BadPaddingException { - if (mode != ENCRYPT_MODE && mode != DECRYPT_MODE) { - throw new IllegalStateException( - Messages.getString("crypto.1C")); //$NON-NLS-1$ - } - if (inputOffset < 0 || inputLen < 0 - || inputOffset + inputLen > input.length) { - throw new IllegalArgumentException( - Messages.getString("crypto.1E")); //$NON-NLS-1$ - } - return spiImpl.engineDoFinal(input, inputOffset, inputLen); - } - - /** - * Finishes a multi-part transformation (encryption or decryption). - *

- * Processes the {@code inputLen} bytes in {@code input} buffer at {@code - * inputOffset}, and any bytes that have been buffered in previous {@code - * update} calls. - * - * @param input - * the input buffer. - * @param inputOffset - * the offset in the input buffer. - * @param inputLen - * the length of the input. - * @param output - * the output buffer for the transformed bytes. - * @return the number of bytes placed in the output buffer. - * @throws ShortBufferException - * if the size of the {@code output} buffer is too small. - * @throws IllegalBlockSizeException - * if the size of the resulting bytes is not a multiple of the - * cipher block size. - * @throws BadPaddingException - * if the padding of the data does not match the padding scheme. - * @throws IllegalStateException - * if this cipher instance is not initialized for encryption or - * decryption. - * @throws IllegalArgumentException - * if {@code inputOffset} and {@code inputLen} do not specify an - * valid chunk in the input buffer. - */ - public final int doFinal(byte[] input, int inputOffset, int inputLen, - byte[] output) throws ShortBufferException, - IllegalBlockSizeException, BadPaddingException { - return doFinal(input, inputOffset, inputLen, output, 0); - } - - /** - * Finishes a multi-part transformation (encryption or decryption). - *

- * Processes the {@code inputLen} bytes in {@code input} buffer at {@code - * inputOffset}, and any bytes that have been buffered in previous {@code - * update} calls. - * - * @param input - * the input buffer. - * @param inputOffset - * the offset in the input buffer. - * @param inputLen - * the length of the input. - * @param output - * the output buffer for the transformed bytes. - * @param outputOffset - * the offset in the output buffer. - * @return the number of bytes placed in the output buffer. - * @throws ShortBufferException - * if the size of the {@code output} buffer is too small. - * @throws IllegalBlockSizeException - * if the size of the resulting bytes is not a multiple of the - * cipher block size. - * @throws BadPaddingException - * if the padding of the data does not match the padding scheme. - * @throws IllegalStateException - * if this cipher instance is not initialized for encryption or - * decryption. - * @throws IllegalArgumentException - * if {@code inputOffset} and {@code inputLen} do not specify an - * valid chunk in the input buffer. - */ - public final int doFinal(byte[] input, int inputOffset, int inputLen, - byte[] output, int outputOffset) throws ShortBufferException, - IllegalBlockSizeException, BadPaddingException { - if (mode != ENCRYPT_MODE && mode != DECRYPT_MODE) { - throw new IllegalStateException( - Messages.getString("crypto.1C")); //$NON-NLS-1$ - } - if (inputOffset < 0 || inputLen < 0 - || inputOffset + inputLen > input.length) { - throw new IllegalArgumentException( - Messages.getString("crypto.1E")); //$NON-NLS-1$ - } - return spiImpl.engineDoFinal(input, inputOffset, inputLen, output, - outputOffset); - } - - /** - * Finishes a multi-part transformation (encryption or decryption). - *

- * Processes the {@code input.remaining()} bytes in {@code input} buffer at - * {@code input.position()}, and any bytes that have been buffered in - * previous {@code update} calls. The transformed bytes are placed into - * {@code output} buffer. - * - * @param input - * the input buffer. - * @param output - * the output buffer. - * @return the number of bytes placed into the output buffer. - * @throws ShortBufferException - * if the size of the {@code output} buffer is too small. - * @throws IllegalBlockSizeException - * if the size of the resulting bytes is not a multiple of the - * cipher block size. - * @throws BadPaddingException - * if the padding of the data does not match the padding scheme. - * @throws IllegalArgumentException - * if the input buffer and the output buffer are the same - * object. - * @throws IllegalStateException - * if this cipher instance is not initialized for encryption or - * decryption. - */ - public final int doFinal(ByteBuffer input, ByteBuffer output) - throws ShortBufferException, IllegalBlockSizeException, - BadPaddingException { - if (mode != ENCRYPT_MODE && mode != DECRYPT_MODE) { - throw new IllegalStateException( - Messages.getString("crypto.1C")); //$NON-NLS-1$ - } - if (input == output) { - throw new IllegalArgumentException( - Messages.getString("crypto.2E")); //$NON-NLS-1$ - } - return spiImpl.engineDoFinal(input, output); - } - - /** - * Wraps a key using this cipher instance. - * - * @param key - * the key to wrap. - * @return the wrapped key. - * @throws IllegalBlockSizeException - * if the size of the resulting bytes is not a multiple of the - * cipher block size. - * @throws InvalidKeyException - * if this cipher instance can not wrap this key. - * @throws IllegalStateException - * if this cipher instance is not initialized for wrapping. - */ - public final byte[] wrap(Key key) throws IllegalBlockSizeException, - InvalidKeyException { - if (mode != WRAP_MODE) { - throw new IllegalStateException( - Messages.getString("crypto.1C")); //$NON-NLS-1$ - } - return spiImpl.engineWrap(key); - } - - /** - * Unwraps a key using this cipher instance. - * - * @param wrappedKey - * the wrapped key to unwrap. - * @param wrappedKeyAlgorithm - * the algorithm for the wrapped key. - * @param wrappedKeyType - * the type of the wrapped key (one of: {@code SECRET_KEY - * , PRIVATE_KEY} or {@code PUBLIC_KEY}) - * @return the unwrapped key - * @throws InvalidKeyException - * if the {@code wrappedKey} can not be unwrapped to a key of - * type {@code wrappedKeyType} for the {@code - * wrappedKeyAlgorithm}. - * @throws NoSuchAlgorithmException - * if no provider can be found that can create a key of type - * {@code wrappedKeyType} for the {@code wrappedKeyAlgorithm}. - * @throws IllegalStateException - * if this cipher instance is not initialized for unwrapping. - */ - public final Key unwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, - int wrappedKeyType) throws InvalidKeyException, - NoSuchAlgorithmException { - if (mode != UNWRAP_MODE) { - throw new IllegalStateException( - Messages.getString("crypto.1C")); //$NON-NLS-1$ - } - return spiImpl.engineUnwrap(wrappedKey, wrappedKeyAlgorithm, - wrappedKeyType); - } - - /** - * Returns the maximum key length for the specified transformation. - * - * @param transformation - * the transformation name. - * @return the maximum key length, currently {@code Integer.MAX_VALUE}. - * @throws NoSuchAlgorithmException - * if no provider for the specified {@code transformation} can - * be found. - * @throws NullPointerException - * if {@code transformation} is {@code null}. - */ - public static final int getMaxAllowedKeyLength(String transformation) - throws NoSuchAlgorithmException { - if (transformation == null) { - throw new NullPointerException(); - } - checkTransformation(transformation); - //FIXME jurisdiction policy files - return Integer.MAX_VALUE; - } - - /** - * Returns the maximum cipher parameter value for the specified - * transformation. If there is no maximum limit, {@code null} is returned. - * - * @param transformation - * the transformation name. - * @return a parameter spec holding the maximum value or {@code null}. - * Currently {@code null}. - * @throws NoSuchAlgorithmException - * if no provider for the specified {@code transformation} can - * be found. - * @throws NullPointerException - * if {@code transformation} is {@code null}. - */ - public static final AlgorithmParameterSpec getMaxAllowedParameterSpec( - String transformation) throws NoSuchAlgorithmException { - if (transformation == null) { - throw new NullPointerException(); - } - checkTransformation(transformation); - //FIXME jurisdiction policy files - return null; - } -} diff --git a/libcore/crypto/src/main/java/javax/crypto/CipherInputStream.java b/libcore/crypto/src/main/java/javax/crypto/CipherInputStream.java deleted file mode 100644 index b2c626d6d..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/CipherInputStream.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; -import javax.crypto.NullCipher; -import java.security.GeneralSecurityException; - -/** - * This class wraps an {@code InputStream} and a cipher so that {@code read()} - * methods return data that are read from the underlying {@code InputStream} and - * processed by the cipher. - *

- * The cipher must be initialized for the requested operation before being used - * by a {@code CipherInputStream}. For example, if a cipher initialized for - * decryption is used with a {@code CipherInputStream}, the {@code - * CipherInputStream} tries to read the data an decrypt them before returning. - */ -public class CipherInputStream extends FilterInputStream { - - private final Cipher cipher; - private final int I_BUFFER_SIZE = 20; - private final byte[] i_buffer = new byte[I_BUFFER_SIZE]; - private int index; // index of the bytes to return from o_buffer - private byte[] o_buffer; - private boolean finished; - - /** - * Creates a new {@code CipherInputStream} instance for an {@code - * InputStream} and a cipher. - * - * @param is - * the input stream to read data from. - * @param c - * the cipher to process the data with. - */ - public CipherInputStream(InputStream is, Cipher c) { - super(is); - this.cipher = c; - } - - /** - * Creates a new {@code CipherInputStream} instance for an {@code - * InputStream} without a cipher. - *

- * A {@code NullCipher} is created and used to process the data. - * - * @param is - * the input stream to read data from. - */ - protected CipherInputStream(InputStream is) { - this(is, new NullCipher()); - } - - /** - * Reads the next byte from this cipher input stream. - * - * @return the next byte, or {@code -1} if the end of the stream is reached. - * @throws IOException - * if an error occurs. - */ - @Override - public int read() throws IOException { - if (finished) { - return ((o_buffer == null) || (index == o_buffer.length)) - ? -1 - : o_buffer[index++] & 0xFF; - } - if ((o_buffer != null) && (index < o_buffer.length)) { - return o_buffer[index++] & 0xFF; - } - index = 0; - o_buffer = null; - int num_read; - while (o_buffer == null) { - if ((num_read = in.read(i_buffer)) == -1) { - try { - o_buffer = cipher.doFinal(); - } catch (Exception e) { - throw new IOException(e.getMessage()); - } - finished = true; - break; - } - o_buffer = cipher.update(i_buffer, 0, num_read); - } - return read(); - } - - /** - * Reads the next {@code b.length} bytes from this input stream into buffer - * {@code b}. - * - * @param b - * the buffer to be filled with data. - * @return the number of bytes filled into buffer {@code b}, or {@code -1} - * if the end of the stream is reached. - * @throws IOException - * if an error occurs. - */ - @Override - public int read(byte[] b) throws IOException { - return read(b, 0, b.length); - } - - /** - * Reads the next {@code len} bytes from this input stream into buffer - * {@code b} starting at offset {@code off}. - *

- * if {@code b} is {@code null}, the next {@code len} bytes are read and - * discarded. - * - * @param b - * the buffer to be filled with data. - * @param off - * the offset to start in the buffer. - * @param len - * the maximum number of bytes to read. - * @return the number of bytes filled into buffer {@code b}, or {@code -1} - * of the of the stream is reached. - * @throws IOException - * if an error occurs. - * @throws NullPointerException - * if the underlying input stream is {@code null}. - */ - @Override - public int read(byte[] b, int off, int len) throws IOException { - if (in == null) { - throw new NullPointerException("Underlying input stream is null"); - } - - int read_b; - int i; - for (i=0; i - * The number of bytes skipped depends on the result of a call to - * {@link CipherInputStream#available() available}. The smaller of n and the - * result are the number of bytes being skipped. - * - * @param n - * the number of bytes that should be skipped. - * @return the number of bytes actually skipped. - * @throws IOException - * if an error occurs - */ - @Override - public long skip(long n) throws IOException { - long i = 0; - int available = available(); - if (available < n) { - n = available; - } - while ((i < n) && (read() != -1)) { - i++; - } - return i; - } - - /** - * Returns the number of bytes available without blocking. - * - * @return the number of bytes available, currently zero. - * @throws IOException - * if an error occurs - */ - @Override - public int available() throws IOException { - return 0; - } - - /** - * Closes this {@code CipherInputStream}, also closes the underlying input - * stream and call {@code doFinal} on the cipher object. - * - * @throws IOException - * if an error occurs. - */ - @Override - public void close() throws IOException { - in.close(); - try { - cipher.doFinal(); - } catch (GeneralSecurityException ignore) { - //do like RI does - } - - } - - /** - * Returns whether this input stream supports {@code mark} and - * {@code reset}, which it does not. - * - * @return false, since this input stream does not support {@code mark} and - * {@code reset}. - */ - @Override - public boolean markSupported() { - return false; - } -} - diff --git a/libcore/crypto/src/main/java/javax/crypto/CipherOutputStream.java b/libcore/crypto/src/main/java/javax/crypto/CipherOutputStream.java deleted file mode 100644 index 1f95b99f3..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/CipherOutputStream.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import javax.crypto.NullCipher; - -/** - * This class wraps an output stream and a cipher so that {@code write} methods - * send the data through the cipher before writing them to the underlying output - * stream. - *

- * The cipher must be initialized for the requested operation before being used - * by a {@code CipherOutputStream}. For example, if a cipher initialized for - * encryption is used with a {@code CipherOutputStream}, the {@code - * CipherOutputStream} tries to encrypt the data writing it out. - */ -public class CipherOutputStream extends FilterOutputStream { - - private final Cipher cipher; - private final byte[] arr = new byte[1]; - - /** - * Creates a new {@code CipherOutputStream} instance for an {@code - * OutputStream} and a {@code Cipher}. - * - * @param os - * the output stream to write data to. - * @param c - * the cipher to process the data with. - */ - public CipherOutputStream(OutputStream os, Cipher c) { - super(os); - cipher = c; - } - - /** - * Creates a new {@code CipherOutputStream} instance for an {@code - * OutputStream} without a cipher. - *

- * A {@code NullCipher} is created to process the data. - * - * @param os - * the output stream to write the data to. - */ - protected CipherOutputStream(OutputStream os) { - this(os, new NullCipher()); - } - - /** - * Writes the single byte to this cipher output stream. - * - * @param b - * the byte to write. - * @throws IOException - * if an error occurs. - */ - @Override - public void write(int b) throws IOException { - byte[] result; - arr[0] = (byte) b; - result = cipher.update(arr); - if (result != null) { - out.write(result); - } - } - - /** - * Writes the buffer of bytes to this cipher output stream. - * - * @param b - * the buffer of bytes. - * @throws IOException - * if an error occurs. - */ - @Override - public void write(byte[] b) throws IOException { - write(b, 0, b.length); - } - - /** - * Writes the {@code len} bytes from buffer {@code b} starting at offset - * {@code off} to this cipher output stream. - * - * @param b - * the buffer. - * @param off - * the offset to start at. - * @param len - * the number of bytes. - * @throws IOException - * if an error occurs. - */ - @Override - public void write(byte[] b, int off, int len) throws IOException { - if (len == 0) { - return; - } - byte[] result = cipher.update(b, off, len); - if (result != null) { - out.write(result); - } - } - - /** - * Flushes this cipher output stream. - * - * @throws IOException - * if an error occurs - */ - @Override - public void flush() throws IOException { - out.flush(); - } - - /** - * Close this cipher output stream. - *

- * On the underlying cipher {@code doFinal} will be invoked, and any - * buffered bytes from the cipher are also written out, and the cipher is - * reset to its initial state. The underlying output stream is also closed. - * - * @throws IOException - * if an error occurs. - */ - @Override - public void close() throws IOException { - byte[] result; - try { - if (cipher != null) { - result = cipher.doFinal(); - if (result != null) { - out.write(result); - } - } - if (out != null) { - out.flush(); - } - } catch (BadPaddingException e) { - throw new IOException(e.getMessage()); - } catch (IllegalBlockSizeException e) { - throw new IOException(e.getMessage()); - } finally { - if (out != null) { - out.close(); - } - } - } -} - diff --git a/libcore/crypto/src/main/java/javax/crypto/CipherSpi.java b/libcore/crypto/src/main/java/javax/crypto/CipherSpi.java deleted file mode 100644 index 50fdd497a..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/CipherSpi.java +++ /dev/null @@ -1,557 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.security.AlgorithmParameters; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.security.spec.AlgorithmParameterSpec; -import java.nio.ByteBuffer; - -import org.apache.harmony.crypto.internal.nls.Messages; - -/** - * This class defines the Service Provider Interface (SPI) for - * cryptographic ciphers. - *

- * Implementers of cryptographic ciphers must implement all the abstract methods - * for every cipher they implement. {@code CipherSpi} instances are created - * along with ciphers when the {@link Cipher#getInstance} method is called. A - * {@code Cipher} is referenced by a transformation, which is a string - * that describes the operation (or set of operations), always consisting of the - * cipher's name and optionally followed by a mode and a padding, in the form: - *

    - *
  • "algorithm"
  • or - *
  • "algorithm/mode/padding"
  • - *
- * The following behavior should be implemented for obtaining {@code Cipher} - * instances. - *

- * When one of the {@link Cipher#getInstance} factory methods is called with a - * transformation that is only an algorithm, check if the provider - * defines a {@code CipherSpi} for "algorithm", if so: return it, otherwise - * throw a {@link NoSuchAlgorithmException}. - *

- * The following rules apply when a transformation is of the form - * "algorithm/mode/padding": - *

    - * 1. The Provider has a {@code CipherSpi} subclass registered for - * "algorithm/mode/padding": return it, otherwise go to step 2. - *
- *
    - * 2. The Provider has a {@code CipherSpi} subclass registered for - * "algorithm/mode": instantiate it, call - * {@link CipherSpi#engineSetPadding(String) engineSetPadding(String)} for the - * padding name and return it, otherwise go to step 3. - *
- *
    - * 3. The Provider has a {@code CipherSpi} subclass registered for - * "algorithm//padding": instantiate it, call - * {@link CipherSpi#engineSetMode(String) engineSetMode(String)} for the mode - * name and return it, otherwise go to step 4. - *
- *
    - * 4. The Provider has a {@code CipherSpi} subclass registered for "algorithm": - * instantiate it, call {@link CipherSpi#engineSetMode(String) - * engineSetMode(String)} for the mode name , call - * {@link CipherSpi#engineSetPadding(String) engineSetPadding(String)} for the - * padding name and return it, otherwise throw a - * {@link NoSuchAlgorithmException}. - *
- * - * @see Cipher - */ -public abstract class CipherSpi { - - /** - * Creates a new {@code CipherSpi} instance. - */ - public CipherSpi() { - } - - /** - * Sets the mode for this cipher. - * - * @param mode - * the name of the cipher mode. - * @throws NoSuchAlgorithmException - * if the specified cipher mode is not supported by this - * provider. - */ - protected abstract void engineSetMode(String mode) - throws NoSuchAlgorithmException; - - /** - * Sets the padding method for this cipher. - * - * @param padding - * the name of the padding method. - * @throws NoSuchPaddingException - * if the specified padding method is not supported by this - * cipher. - */ - protected abstract void engineSetPadding(String padding) - throws NoSuchPaddingException; - - /** - * Returns the block size of this cipher (in bytes) - * - * @return the block size of this cipher, or zero if this cipher is not a - * block cipher. - */ - protected abstract int engineGetBlockSize(); - - /** - * Returns the size for a buffer (in bytes), that the next call to {@code - * update} of {@code doFinal} would return, taking into account any buffered - * data from previous {@code update} calls and padding. - *

- * The actual output length of the next call to {@code update} or {@code - * doFinal} may be smaller than the length returned by this method. - * - * @param inputLen - * the length of the input (in bytes). - * @return the size for a buffer (in bytes). - */ - protected abstract int engineGetOutputSize(int inputLen); - - /** - * Returns the Initialization Vector (IV) that was used to initialize this - * cipher or {@code null} if none was used. - * - * @return the Initialization Vector (IV), or {@code null} if none was used. - */ - protected abstract byte[] engineGetIV(); - - /** - * Returns the parameters that where used to create this cipher instance. - *

- * These may be a the same parameters that were used to create this cipher - * instance, or may be a combination of default and random parameters, - * depending on the underlying cipher implementation. - * - * @return the parameters that where used to create this cipher instance, or - * {@code null} if this cipher instance does not have any parameters - * at all. - */ - protected abstract AlgorithmParameters engineGetParameters(); - - /** - * Initializes this cipher instance with the specified key and a source of - * randomness. - *

- * The cipher will be initialized for the specified operation (one of: - * encryption, decryption, key wrapping or key unwrapping) depending on - * {@code opmode}. - *

- * If this cipher instance needs any algorithm parameters or random values - * that the specified key cannot provide, the underlying implementation of - * this cipher is supposed to generate the required parameters (using its - * provider or random values). Random values will be generated using {@code - * random}; - *

- * When a cipher instance is initialized by a call to any of the {@code - * init} methods, the state of the instance is overridden, means it is - * equivalent to creating a new instance and calling it {@code init} method. - * - * @param opmode - * the operation this cipher instance should be initialized for - * (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code - * WRAP_MODE} or {@code UNWRAP_MODE}). - * @param key - * the input key for the operation. - * @param random - * the source of randomness to use. - * @throws InvalidKeyException - * if the specified key cannot be used to initialize this cipher - * instance. - */ - protected abstract void engineInit(int opmode, Key key, SecureRandom random) - throws InvalidKeyException; - - /** - * Initializes this cipher instance with the specified key, algorithm - * parameters and a source of randomness. - *

- * The cipher will be initialized for the specified operation (one of: - * encryption, decryption, key wrapping or key unwrapping) depending on - * {@code opmode}. - *

- * If this cipher instance needs any algorithm parameters and {@code params} - * is {@code null}, the underlying implementation of this cipher is supposed - * to generate the required parameters (using its provider or random - * values). Random values are generated using {@code random}. - *

- * When a cipher instance is initialized by a call to any of the {@code - * init} methods, the state of the instance is overridden, means it is - * equivalent to creating a new instance and calling it {@code init} method. - * - * @param opmode - * the operation this cipher instance should be initialized for - * (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code - * WRAP_MODE} or {@code UNWRAP_MODE}). - * @param key - * the input key for the operation. - * @param params - * the algorithm parameters. - * @param random - * the source of randomness to use. - * @throws InvalidKeyException - * if the specified key cannot be used to initialize this cipher - * instance. - * @throws InvalidAlgorithmParameterException - * it the specified parameters are inappropriate for this - * cipher. - */ - protected abstract void engineInit(int opmode, Key key, - AlgorithmParameterSpec params, SecureRandom random) - throws InvalidKeyException, InvalidAlgorithmParameterException; - - /** - * Initializes this cipher instance with the specified key, algorithm - * parameters and a source of randomness. - *

- * The cipher will be initialized for the specified operation (one of: - * encryption, decryption, key wrapping or key unwrapping) depending on - * {@code opmode}. - *

- * If this cipher instance needs any algorithm parameters and {@code params} - * is {@code null}, the underlying implementation of this cipher is supposed - * to generate the required parameters (using its provider or random - * values). Random values are generated using {@code random}. - *

- * When a cipher instance is initialized by a call to any of the {@code - * init} methods, the state of the instance is overridden, means it is - * equivalent to creating a new instance and calling it {@code init} method. - * - * @param opmode - * the operation this cipher instance should be initialized for - * (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code - * WRAP_MODE} or {@code UNWRAP_MODE}). - * @param key - * the input key for the operation. - * @param params - * the algorithm parameters. - * @param random - * the source of randomness to use. - * @throws InvalidKeyException - * if the specified key cannot be used to initialize this cipher - * instance. - * @throws InvalidAlgorithmParameterException - * if the specified parameters are inappropriate for this - * cipher. - */ - protected abstract void engineInit(int opmode, Key key, - AlgorithmParameters params, SecureRandom random) - throws InvalidKeyException, InvalidAlgorithmParameterException; - - /** - * Continues a multi-part transformation (encryption or decryption). The - * transformed bytes are returned. - * - * @param input - * the input bytes to transform. - * @param inputOffset - * the offset in the input to start. - * @param inputLen - * the length of the input to transform. - * @return the transformed bytes in a new buffer, or {@code null} if the - * input has zero length. - * @throws IllegalStateException - * if this cipher instance is not initialized for encryption or - * decryption. - * @throws IllegalArgumentException - * if the input is null, or if {@code inputOffset} and {@code - * inputLen} do not specify a valid chunk in the input buffer. - */ - protected abstract byte[] engineUpdate(byte[] input, int inputOffset, - int inputLen); - - /** - * Continues a multi-part transformation (encryption or decryption). The - * transformed bytes are stored in the {@code output} buffer. - *

- * If the size of the {@code output} buffer is too small to hold the result, - * a {@code ShortBufferException} is thrown. Use - * {@link Cipher#getOutputSize getOutputSize} to check for the size of the - * output buffer. - * - * @param input - * the input bytes to transform. - * @param inputOffset - * the offset in the input to start. - * @param inputLen - * the length of the input to transform. - * @param output - * the output buffer. - * @param outputOffset - * the offset in the output buffer. - * @return the number of bytes placed in output. - * @throws ShortBufferException - * if the size of the {@code output} buffer is too small. - */ - protected abstract int engineUpdate(byte[] input, int inputOffset, - int inputLen, byte[] output, int outputOffset) - throws ShortBufferException; - - /** - * Continues a multi-part transformation (encryption or decryption). The - * {@code input.remaining()} bytes starting at {@code input.position()} are - * transformed and stored in the {@code output} buffer. - *

- * If the {@code output.remaining()} is too small to hold the transformed - * bytes a {@code ShortBufferException} is thrown. Use - * {@link Cipher#getOutputSize getOutputSize} to check for the size of the - * output buffer. - * - * @param input - * the input buffer to transform. - * @param output - * the output buffer to store the result within. - * @return the number of bytes stored in the output buffer. - * @throws ShortBufferException - * if the size of the {@code output} buffer is too small. - */ - protected int engineUpdate(ByteBuffer input, ByteBuffer output) - throws ShortBufferException { - if (input == null) { - throw new NullPointerException(Messages.getString("crypto.0C")); //$NON-NLS-1$ - } - if (output == null) { - throw new NullPointerException(Messages.getString("crypto.0D")); //$NON-NLS-1$ - } - int position = input.position(); - int limit = input.limit(); - if ((limit - position) <= 0) { - return 0; - } - byte[] bInput; - byte[] bOutput; - if (input.hasArray()) { - bInput = input.array(); - int offset = input.arrayOffset(); - bOutput = engineUpdate(bInput, offset + position, limit - position); - input.position(limit); - } else { - bInput = new byte[limit - position]; - input.get(bInput); - bOutput = engineUpdate(bInput, 0, limit - position); - } - if (output.remaining() < bOutput.length) { - throw new ShortBufferException(Messages.getString("crypto.0E")); //$NON-NLS-1$ - } - try { - output.put(bOutput); - } catch (java.nio.BufferOverflowException e) { - throw new ShortBufferException(Messages.getString("crypto.0F", e)); //$NON-NLS-1$ - } - return bOutput.length; - } - - /** - * Finishes a multi-part transformation (encryption or decryption). - *

- * Processes the {@code inputLen} bytes in {@code input} buffer at {@code - * inputOffset}, and any bytes that have been buffered in previous {@code - * update} calls. - * - * @param input - * the input buffer. - * @param inputOffset - * the offset in the input buffer. - * @param inputLen - * the length of the input. - * @return the final bytes from the transformation. - * @throws IllegalBlockSizeException - * if the size of the resulting bytes is not a multiple of the - * cipher block size. - * @throws BadPaddingException - * if the padding of the data does not match the padding scheme. - */ - protected abstract byte[] engineDoFinal(byte[] input, int inputOffset, - int inputLen) throws IllegalBlockSizeException, BadPaddingException; - - /** - * Finishes a multi-part transformation (encryption or decryption). - *

- * Processes the {@code inputLen} bytes in {@code input} buffer at - * {@code inputOffset}, and any bytes that have been buffered in previous - * {@code update} calls. - * - * @param input - * the input buffer. - * @param inputOffset - * the offset in the input buffer. - * @param inputLen - * the length of the input. - * @param output - * the output buffer for the transformed bytes. - * @param outputOffset - * the offset in the output buffer. - * @return the number of bytes placed in the output buffer. - * @throws ShortBufferException - * if the size of the {@code output} buffer is too small. - * @throws IllegalBlockSizeException - * if the size of the resulting bytes is not a multiple of the - * cipher block size. - * @throws BadPaddingException - * if the padding of the data does not match the padding scheme. - */ - protected abstract int engineDoFinal(byte[] input, int inputOffset, - int inputLen, byte[] output, int outputOffset) - throws ShortBufferException, IllegalBlockSizeException, - BadPaddingException; - - /** - * Finishes a multi-part transformation (encryption or decryption). - *

- * Processes the {@code input.remaining()} bytes in {@code input} buffer at - * {@code input.position()}, and any bytes that have been buffered in - * previous {@code update} calls. The transformed bytes are placed into - * {@code output} buffer. - * - * @param input - * the input buffer. - * @param output - * the output buffer. - * @return the number of bytes placed into the output buffer. - * @throws ShortBufferException - * if the size of the {@code output} buffer is too small. - * @throws IllegalBlockSizeException - * if the size of the resulting bytes is not a multiple of the - * cipher block size. - * @throws BadPaddingException - * if the padding of the data does not match the padding scheme. - * @throws IllegalArgumentException - * if the input buffer and the output buffer are the same - * object. - * @throws IllegalStateException - * if this cipher instance is not initialized for encryption or - * decryption. - */ - protected int engineDoFinal(ByteBuffer input, ByteBuffer output) - throws ShortBufferException, IllegalBlockSizeException, - BadPaddingException { - if (input == null) { - throw new NullPointerException(Messages.getString("crypto.0C")); //$NON-NLS-1$ - } - if (output == null) { - throw new NullPointerException(Messages.getString("crypto.0D")); //$NON-NLS-1$ - } - int position = input.position(); - int limit = input.limit(); - - if ((limit - position) <= 0) { - return 0; - } - byte[] bInput; - byte[] bOutput; - - if (input.hasArray()) { - bInput = input.array(); - int offset = input.arrayOffset(); - bOutput = engineDoFinal(bInput, offset + position, limit - position); - input.position(limit); - } else { - bInput = new byte[limit - position]; - input.get(bInput); - bOutput = engineDoFinal(bInput, 0, limit - position); - } - if (output.remaining() < bOutput.length) { - throw new ShortBufferException(Messages.getString("crypto.0E")); //$NON-NLS-1$ - } - try { - output.put(bOutput); - } catch (java.nio.BufferOverflowException e) { - throw new ShortBufferException(Messages.getString("crypto.0F", e)); //$NON-NLS-1$ - } - return bOutput.length; - } - - /** - * Wraps a key using this cipher instance. This method has been added to - * this class (for backwards compatibility, it cannot be abstract). If this - * method is not overridden, it throws an {@code - * UnsupportedOperationException}. - * - * @param key - * the key to wrap. - * @return the wrapped key - * @throws IllegalBlockSizeException - * if the size of the resulting bytes is not a multiple of the - * cipher block size. - * @throws InvalidKeyException - * if this cipher instance cannot wrap this key. - */ - protected byte[] engineWrap(Key key) throws IllegalBlockSizeException, - InvalidKeyException { - throw new UnsupportedOperationException( - Messages.getString("crypto.10")); //$NON-NLS-1$ - } - - /** - * Unwraps a key using this cipher instance. - *

- * This method has been added to this class (for backwards compatibility, it - * cannot be abstract). If this method is not overridden, it throws an - * {@code UnsupportedOperationException}. - * - * @param wrappedKey - * the wrapped key to unwrap. - * @param wrappedKeyAlgorithm - * the algorithm for the wrapped key. - * @param wrappedKeyType - * the type of the wrapped key (one of: {@code SECRET_KEY}, - * {@code PRIVATE_KEY} or {@code PUBLIC_KEY}) - * @return the unwrapped key. - * @throws InvalidKeyException - * if the {@code wrappedKey} cannot be unwrapped to a key of - * type {@code wrappedKeyType} for the {@code - * wrappedKeyAlgorithm}. - * @throws NoSuchAlgorithmException - * if no provider can be found that can create a key of type - * {@code wrappedKeyType} for the {@code wrappedKeyAlgorithm}. - */ - protected Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, - int wrappedKeyType) throws InvalidKeyException, - NoSuchAlgorithmException { - throw new UnsupportedOperationException( - Messages.getString("crypto.11")); //$NON-NLS-1$ - } - - /** - * Returns the size of a specified key object in bits. This method has been - * added to this class (for backwards compatibility, it cannot be abstract). - * If this method is not overridden, it throws an {@code - * UnsupportedOperationException}. - * - * @param key - * the key to get the size for. - * @return the size of a specified key object in bits. - * @throws InvalidKeyException - * if the size of the key cannot be determined by this - * implementation. - */ - protected int engineGetKeySize(Key key) throws InvalidKeyException { - throw new UnsupportedOperationException( - Messages.getString("crypto.12")); //$NON-NLS-1$ - } -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/EncryptedPrivateKeyInfo.java b/libcore/crypto/src/main/java/javax/crypto/EncryptedPrivateKeyInfo.java deleted file mode 100644 index 2d0fd259d..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/EncryptedPrivateKeyInfo.java +++ /dev/null @@ -1,551 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.io.IOException; -import java.security.AlgorithmParameters; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.Provider; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.PKCS8EncodedKeySpec; - -import org.apache.harmony.crypto.internal.nls.Messages; -import org.apache.harmony.security.asn1.ASN1Any; -import org.apache.harmony.security.asn1.ASN1Implicit; -import org.apache.harmony.security.asn1.ASN1Integer; -import org.apache.harmony.security.asn1.ASN1OctetString; -import org.apache.harmony.security.asn1.ASN1Sequence; -import org.apache.harmony.security.asn1.ASN1SetOf; -import org.apache.harmony.security.asn1.ASN1Type; -import org.apache.harmony.security.utils.AlgNameMapper; -import org.apache.harmony.security.x509.AlgorithmIdentifier; - - -/** - * This class implements the {@code EncryptedPrivateKeyInfo} ASN.1 type as - * specified in PKCS - * #8 - Private-Key Information Syntax Standard. - *

- * The definition of ASN.1 is as follows: - *

- * EncryptedPrivateKeyInfo ::= SEQUENCE { - *
encryptionAlgorithm AlgorithmIdentifier,
- *
encryptedData OCTET STRING }
- *
- *
- * AlgorithmIdentifier ::= SEQUENCE { - *
algorithm OBJECT IDENTIFIER,
- *
parameters ANY DEFINED BY algorithm OPTIONAL }
- *
- */ -public class EncryptedPrivateKeyInfo { - // Encryption algorithm name - private String algName; - // Encryption algorithm parameters - private final AlgorithmParameters algParameters; - // Encrypted private key data - private final byte[] encryptedData; - // Encryption algorithm OID - private String oid; - // This EncryptedPrivateKeyInfo ASN.1 DER encoding - private volatile byte[] encoded; - - /** - * Creates an {@code EncryptedPrivateKeyInfo} instance from its encoded - * representation by parsing it. - * - * @param encoded - * the encoded representation of this object - * @throws IOException - * if parsing the encoded representation fails. - * @throws NullPointerException - * if {@code encoded} is {@code null}. - */ - public EncryptedPrivateKeyInfo(byte[] encoded) - throws IOException { - if (encoded == null) { - throw new NullPointerException(Messages.getString("crypto.22")); //$NON-NLS-1$ - } - this.encoded = new byte[encoded.length]; - System.arraycopy(encoded, 0, this.encoded, 0, encoded.length); - Object[] values; - - values = (Object[])asn1.decode(encoded); - - AlgorithmIdentifier aId = (AlgorithmIdentifier) values[0]; - - algName = aId.getAlgorithm(); - // algName == oid now - boolean mappingExists = mapAlgName(); - // algName == name from map oid->name if mapping exists, or - // algName == oid if mapping does not exist - - AlgorithmParameters aParams = null; - byte[] params = aId.getParameters(); - if (params != null && !isNullValue(params)) { - try { - aParams = AlgorithmParameters.getInstance(algName); - aParams.init(aId.getParameters()); - if (!mappingExists) { - algName = aParams.getAlgorithm(); - } - } catch (NoSuchAlgorithmException e) { - } - } - algParameters = aParams; - - encryptedData = (byte[]) values[1]; - } - - private static boolean isNullValue(byte[] toCheck) { - return toCheck[0] == 5 && toCheck[1] == 0; - } - - /** - * Creates an {@code EncryptedPrivateKeyInfo} instance from an algorithm - * name and its encrypted data. - * - * @param encrAlgName - * the name of an algorithm. - * @param encryptedData - * the encrypted data. - * @throws NoSuchAlgorithmException - * if the {@code encrAlgName} is not a supported algorithm. - * @throws NullPointerException - * if {@code encrAlgName} or {@code encryptedData} is {@code - * null}. - * @throws IllegalArgumentException - * if {@code encryptedData} is empty. - */ - public EncryptedPrivateKeyInfo(String encrAlgName, byte[] encryptedData) - throws NoSuchAlgorithmException { - if (encrAlgName == null) { - throw new NullPointerException(Messages.getString("crypto.23")); //$NON-NLS-1$ - } - this.algName = encrAlgName; - if (!mapAlgName()) { - throw new NoSuchAlgorithmException(Messages.getString("crypto.24", this.algName)); //$NON-NLS-1$ - } - if (encryptedData == null) { - throw new NullPointerException( - Messages.getString("crypto.25")); //$NON-NLS-1$ - } - if (encryptedData.length == 0) { - throw new IllegalArgumentException(Messages.getString("crypto.26")); //$NON-NLS-1$ - } - this.encryptedData = new byte[encryptedData.length]; - System.arraycopy(encryptedData, 0, - this.encryptedData, 0, encryptedData.length); - this.algParameters = null; - } - - /** - * Creates an {@code EncryptedPrivateKeyInfo} instance from the - * encryption algorithm parameters an its encrypted data. - * - * @param algParams - * the encryption algorithm parameters. - * @param encryptedData - * the encrypted data. - * @throws NoSuchAlgorithmException - * if the algorithm name of the specified {@code algParams} - * parameter is not supported. - * @throws NullPointerException - * if {@code algParams} or {@code encryptedData} is - * {@code null}. - */ - public EncryptedPrivateKeyInfo(AlgorithmParameters algParams, - byte[] encryptedData) - throws NoSuchAlgorithmException { - if (algParams == null) { - throw new NullPointerException(Messages.getString("crypto.27")); //$NON-NLS-1$ - } - this.algParameters = algParams; - if (encryptedData == null) { - throw new NullPointerException( - Messages.getString("crypto.25")); //$NON-NLS-1$ - } - if (encryptedData.length == 0) { - throw new IllegalArgumentException(Messages.getString("crypto.26")); //$NON-NLS-1$ - } - this.encryptedData = new byte[encryptedData.length]; - System.arraycopy(encryptedData, 0, - this.encryptedData, 0, encryptedData.length); - this.algName = this.algParameters.getAlgorithm(); - if (!mapAlgName()) { - throw new NoSuchAlgorithmException(Messages.getString("crypto.24", this.algName)); //$NON-NLS-1$ - } - } - - /** - * Returns the name of the encryption algorithm. - * - * @return the name of the encryption algorithm. - */ - public String getAlgName() { - return algName; - } - - /** - * Returns the parameters used by the encryption algorithm. - * - * @return the parameters used by the encryption algorithm. - */ - public AlgorithmParameters getAlgParameters() { - return algParameters; - } - - /** - * Returns the encrypted data of this key. - * - * @return the encrypted data of this key, each time this method is called a - * new array is returned. - */ - public byte[] getEncryptedData() { - byte[] ret = new byte[encryptedData.length]; - System.arraycopy(encryptedData, 0, ret, 0, encryptedData.length); - return ret; - } - - /** - * Returns the {@code PKCS8EncodedKeySpec} object extracted from the - * encrypted data. - *

- * The cipher must be initialize in either {@code Cipher.DECRYPT_MODE} or - * {@code Cipher.UNWRAP_MODE} with the same parameters and key used for - * encrypting this. - * - * @param cipher - * the cipher initialized for decrypting the encrypted data. - * @return the extracted {@code PKCS8EncodedKeySpec}. - * @throws InvalidKeySpecException - * if the specified cipher is not suited to decrypt the - * encrypted data. - * @throws NullPointerException - * if {@code cipher} is {@code null}. - */ - public PKCS8EncodedKeySpec getKeySpec(Cipher cipher) - throws InvalidKeySpecException { - if (cipher == null) { - throw new NullPointerException(Messages.getString("crypto.28")); //$NON-NLS-1$ - } - try { - byte[] decryptedData = cipher.doFinal(encryptedData); - try { - ASN1PrivateKeyInfo.verify(decryptedData); - } catch (IOException e1) { - throw new InvalidKeySpecException( - Messages.getString("crypto.29")); //$NON-NLS-1$ - } - return new PKCS8EncodedKeySpec(decryptedData); - } catch (IllegalStateException e) { - throw new InvalidKeySpecException(e.getMessage()); - } catch (IllegalBlockSizeException e) { - throw new InvalidKeySpecException(e.getMessage()); - } catch (BadPaddingException e) { - throw new InvalidKeySpecException(e.getMessage()); - } - } - - /** - * Returns the {@code PKCS8EncodedKeySpec} object extracted from the - * encrypted data. - * - * @param decryptKey - * the key to decrypt the encrypted data with. - * @return the extracted {@code PKCS8EncodedKeySpec}. - * @throws NoSuchAlgorithmException - * if no usable cipher can be found to decrypt the encrypted - * data. - * @throws InvalidKeyException - * if {@code decryptKey} is not usable to decrypt the encrypted - * data. - * @throws NullPointerException - * if {@code decryptKey} is {@code null}. - */ - public PKCS8EncodedKeySpec getKeySpec(Key decryptKey) - throws NoSuchAlgorithmException, - InvalidKeyException { - if (decryptKey == null) { - throw new NullPointerException(Messages.getString("crypto.2A")); //$NON-NLS-1$ - } - try { - Cipher cipher = Cipher.getInstance(algName); - if (algParameters == null) { - cipher.init(Cipher.DECRYPT_MODE, decryptKey); - } else { - cipher.init(Cipher.DECRYPT_MODE, decryptKey, algParameters); - } - byte[] decryptedData = cipher.doFinal(encryptedData); - try { - ASN1PrivateKeyInfo.verify(decryptedData); - } catch (IOException e1) { - throw new InvalidKeyException( - Messages.getString("crypto.29")); //$NON-NLS-1$ - } - return new PKCS8EncodedKeySpec(decryptedData); - } catch (NoSuchPaddingException e) { - throw new NoSuchAlgorithmException(e.getMessage()); - } catch (InvalidAlgorithmParameterException e) { - throw new NoSuchAlgorithmException(e.getMessage()); - } catch (IllegalStateException e) { - throw new InvalidKeyException(e.getMessage()); - } catch (IllegalBlockSizeException e) { - throw new InvalidKeyException(e.getMessage()); - } catch (BadPaddingException e) { - throw new InvalidKeyException(e.getMessage()); - } - } - - /** - * Returns the {@code PKCS8EncodedKeySpec} object extracted from the - * encrypted data. - * - * @param decryptKey - * the key to decrypt the encrypted data with. - * @param providerName - * the name of a provider whose cipher implementation should be - * used. - * @return the extracted {@code PKCS8EncodedKeySpec}. - * @throws NoSuchProviderException - * if no provider with {@code providerName} can be found. - * @throws NoSuchAlgorithmException - * if no usable cipher can be found to decrypt the encrypted - * data. - * @throws InvalidKeyException - * if {@code decryptKey} is not usable to decrypt the encrypted - * data. - * @throws NullPointerException - * if {@code decryptKey} or {@code providerName} is {@code null} - * . - */ - public PKCS8EncodedKeySpec getKeySpec(Key decryptKey, String providerName) - throws NoSuchProviderException, - NoSuchAlgorithmException, - InvalidKeyException { - if (decryptKey == null) { - throw new NullPointerException(Messages.getString("crypto.2A")); //$NON-NLS-1$ - } - if (providerName == null) { - throw new NullPointerException( - Messages.getString("crypto.2B")); //$NON-NLS-1$ - } - try { - Cipher cipher = Cipher.getInstance(algName, providerName); - if (algParameters == null) { - cipher.init(Cipher.DECRYPT_MODE, decryptKey); - } else { - cipher.init(Cipher.DECRYPT_MODE, decryptKey, algParameters); - } - byte[] decryptedData = cipher.doFinal(encryptedData); - try { - ASN1PrivateKeyInfo.verify(decryptedData); - } catch (IOException e1) { - throw new InvalidKeyException( - Messages.getString("crypto.29")); //$NON-NLS-1$ - } - return new PKCS8EncodedKeySpec(decryptedData); - } catch (NoSuchPaddingException e) { - throw new NoSuchAlgorithmException(e.getMessage()); - } catch (InvalidAlgorithmParameterException e) { - throw new NoSuchAlgorithmException(e.getMessage()); - } catch (IllegalStateException e) { - throw new InvalidKeyException(e.getMessage()); - } catch (IllegalBlockSizeException e) { - throw new InvalidKeyException(e.getMessage()); - } catch (BadPaddingException e) { - throw new InvalidKeyException(e.getMessage()); - } - } - - /** - * Returns the {@code PKCS8EncodedKeySpec} object extracted from the - * encrypted data. - * - * @param decryptKey - * the key to decrypt the encrypted data with. - * @param provider - * the provider whose cipher implementation should be used. - * @return the extracted {@code PKCS8EncodedKeySpec}. - * @throws NoSuchAlgorithmException - * if no usable cipher can be found to decrypt the encrypted - * data. - * @throws InvalidKeyException - * if {@code decryptKey} is not usable to decrypt the encrypted - * data. - * @throws NullPointerException - * if {@code decryptKey} or {@code provider} is {@code null}. - */ - public PKCS8EncodedKeySpec getKeySpec(Key decryptKey, Provider provider) - throws NoSuchAlgorithmException, - InvalidKeyException { - if (decryptKey == null) { - throw new NullPointerException(Messages.getString("crypto.2A")); //$NON-NLS-1$ - } - if (provider == null) { - throw new NullPointerException(Messages.getString("crypto.2C")); //$NON-NLS-1$ - } - try { - Cipher cipher = Cipher.getInstance(algName, provider); - if (algParameters == null) { - cipher.init(Cipher.DECRYPT_MODE, decryptKey); - } else { - cipher.init(Cipher.DECRYPT_MODE, decryptKey, algParameters); - } - byte[] decryptedData = cipher.doFinal(encryptedData); - try { - ASN1PrivateKeyInfo.verify(decryptedData); - } catch (IOException e1) { - throw new InvalidKeyException( - Messages.getString("crypto.29")); //$NON-NLS-1$ - } - return new PKCS8EncodedKeySpec(decryptedData); - } catch (NoSuchPaddingException e) { - throw new NoSuchAlgorithmException(e.getMessage()); - } catch (InvalidAlgorithmParameterException e) { - throw new NoSuchAlgorithmException(e.getMessage()); - } catch (IllegalStateException e) { - throw new InvalidKeyException(e.getMessage()); - } catch (IllegalBlockSizeException e) { - throw new InvalidKeyException(e.getMessage()); - } catch (BadPaddingException e) { - throw new InvalidKeyException(e.getMessage()); - } - } - - /** - * Returns the ASN.1 encoded representation of this object. - * - * @return the ASN.1 encoded representation of this object. - * @throws IOException - * if encoding this object fails. - */ - public byte[] getEncoded() throws IOException { - if (encoded == null) { - // Generate ASN.1 encoding: - encoded = asn1.encode(this); - } - byte[] ret = new byte[encoded.length]; - System.arraycopy(encoded, 0, ret, 0, encoded.length); - return ret; - } - - // Performs all needed alg name mappings. - // Returns 'true' if mapping available 'false' otherwise - private boolean mapAlgName() { - if (AlgNameMapper.isOID(this.algName)) { - // OID provided to the ctor - // get rid of possible leading "OID." - this.oid = AlgNameMapper.normalize(this.algName); - // try to find mapping OID->algName - this.algName = AlgNameMapper.map2AlgName(this.oid); - // if there is no mapping OID->algName - // set OID as algName - if (this.algName == null) { - this.algName = this.oid; - } - } else { - String stdName = AlgNameMapper.getStandardName(this.algName); - // Alg name provided to the ctor - // try to find mapping algName->OID or - // (algName->stdAlgName)->OID - this.oid = AlgNameMapper.map2OID(this.algName); - if (this.oid == null) { - if (stdName == null) { - // no above mappings available - return false; - } - this.oid = AlgNameMapper.map2OID(stdName); - if (this.oid == null) { - return false; - } - this.algName = stdName; - } else if (stdName != null) { - this.algName = stdName; - } - } - return true; - } - - // - // EncryptedPrivateKeyInfo DER encoder/decoder. - // EncryptedPrivateKeyInfo ASN.1 definition - // (as defined in PKCS #8: Private-Key Information Syntax Standard - // http://www.ietf.org/rfc/rfc2313.txt) - // - // EncryptedPrivateKeyInfo ::= SEQUENCE { - // encryptionAlgorithm AlgorithmIdentifier, - // encryptedData OCTET STRING } - // - - private static final byte[] nullParam = new byte[] { 5, 0 }; - - private static final ASN1Sequence asn1 = new ASN1Sequence(new ASN1Type[] { - AlgorithmIdentifier.ASN1, ASN1OctetString.getInstance() }) { - - @Override - protected void getValues(Object object, Object[] values) { - - EncryptedPrivateKeyInfo epki = (EncryptedPrivateKeyInfo) object; - - try { - byte[] algParmsEncoded = (epki.algParameters == null) ? nullParam - : epki.algParameters.getEncoded(); - values[0] = new AlgorithmIdentifier(epki.oid, algParmsEncoded); - values[1] = epki.encryptedData; - } catch (IOException e) { - throw new RuntimeException(e.getMessage()); - } - } - }; - - // PrivateKeyInfo DER decoder. - // PrivateKeyInfo ASN.1 definition - // (as defined in PKCS #8: Private-Key Information Syntax Standard - // http://www.ietf.org/rfc/rfc2313.txt) - // - // - // PrivateKeyInfo ::= SEQUENCE { - // version Version, - // privateKeyAlgorithm PrivateKeyAlgorithmIdentifier, - // privateKey PrivateKey, - // attributes [0] IMPLICIT Attributes OPTIONAL } - // - // Version ::= INTEGER - // - // PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier - // - // PrivateKey ::= OCTET STRING - // - // Attributes ::= SET OF Attribute - - private static final ASN1SetOf ASN1Attributes = new ASN1SetOf(ASN1Any.getInstance()); - - private static final ASN1Sequence ASN1PrivateKeyInfo = new ASN1Sequence( - new ASN1Type[] { ASN1Integer.getInstance(), AlgorithmIdentifier.ASN1, - ASN1OctetString.getInstance(), - new ASN1Implicit(0, ASN1Attributes) }) { - { - setOptional(3); //attributes are optional - } - }; -} diff --git a/libcore/crypto/src/main/java/javax/crypto/ExemptionMechanism.java b/libcore/crypto/src/main/java/javax/crypto/ExemptionMechanism.java deleted file mode 100644 index 76c88cbd0..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/ExemptionMechanism.java +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.security.AlgorithmParameters; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.Provider; -import java.security.Security; -import java.security.spec.AlgorithmParameterSpec; -import java.util.Arrays; - -import org.apache.harmony.crypto.internal.nls.Messages; -import org.apache.harmony.security.fortress.Engine; - -/** - * This class implements the functionality of an exemption mechanism such as - * key recovery, key weakening, or key escrow. - */ -public class ExemptionMechanism { - - // Used to access common engine functionality - private static final Engine engine = new Engine("ExemptionMechanism"); - - // Store used provider - private final Provider provider; - - // Store used spi implementation - private final ExemptionMechanismSpi spiImpl; - - // Store mechanism name - private final String mechanism; - - // Store state (initialized or not) - private boolean isInit; - - // Store initKey value - private Key initKey; - - // Indicates if blob generated successfully - private boolean generated; - - /** - * Creates a {@code ExemptionMechanism} instance. - * - * @param exmechSpi - * the implementation delegate. - * @param provider - * the associated provider. - * @param mechanism - * the name of the mechanism. - */ - protected ExemptionMechanism(ExemptionMechanismSpi exmechSpi, - Provider provider, String mechanism) { - this.mechanism = mechanism; - this.spiImpl = exmechSpi; - this.provider = provider; - isInit = false; - } - - /** - * Returns the name of this {@code ExemptionMechanism}. - * - * @return the name of this {@code ExemptionMechanism}. - */ - public final String getName() { - return mechanism; - } - - /** - * Returns a new {@code ExemptionMechanism} instance that provides the - * specified exemption mechanism algorithm. - * - * @param algorithm - * the name of the requested exemption mechanism. - * @return the new {@code ExemptionMechanism} instance. - * @throws NoSuchAlgorithmException - * if the specified algorithm is not available by any provider. - * @throws NullPointerException - * if the algorithm parameter is {@code null}. - */ - public static final ExemptionMechanism getInstance(String algorithm) - throws NoSuchAlgorithmException { - if (algorithm == null) { - throw new NullPointerException(Messages.getString("crypto.02")); //$NON-NLS-1$ - } - synchronized (engine) { - engine.getInstance(algorithm, null); - return new ExemptionMechanism((ExemptionMechanismSpi) engine.spi, - engine.provider, algorithm); - } - } - - /** - * Returns a new {@code ExemptionMechansm} instance that provides the - * specified exemption mechanism algorithm from the specified provider. - * - * @param algorithm - * the name of the requested exemption mechanism. - * @param provider - * the name of the provider that is providing the algorithm. - * @return the new {@code ExemptionMechanism} instance. - * @throws NoSuchAlgorithmException - * if the specified algorithm is not provided by the specified - * provider. - * @throws NoSuchProviderException - * if the specified provider is not available. - * @throws NullPointerException - * if the algorithm parameter is {@code null}. - * @throws IllegalArgumentException - * if the provider parameter is {@code null}. - */ - public static final ExemptionMechanism getInstance(String algorithm, - String provider) throws NoSuchAlgorithmException, - NoSuchProviderException { - if (provider == null) { - throw new IllegalArgumentException(Messages.getString("crypto.04")); //$NON-NLS-1$ - } - Provider impProvider = Security.getProvider(provider); - if (impProvider == null) { - throw new NoSuchProviderException(provider); - } - if (algorithm == null) { - throw new NullPointerException(Messages.getString("crypto.02")); //$NON-NLS-1$ - } - return getInstance(algorithm, impProvider); - } - - /** - * Returns a new {@code ExemptionMechanism} instance that provides the - * specified exemption mechanism algorithm from the specified provider. - * - * @param algorithm - * the name of the requested exemption mechanism. - * @param provider - * the provider that is providing the algorithm. - * @return the new {@code ExemptionMechanism} instance. - * @throws NoSuchAlgorithmException - * if the specified algorithm is not provided by the specified - * provider. - * @throws NullPointerException - * if the algorithm parameter is {@code null}. - * @throws IllegalArgumentException - * if the provider parameter is {@code null}. - */ - public static final ExemptionMechanism getInstance(String algorithm, - Provider provider) throws NoSuchAlgorithmException { - if (algorithm == null) { - throw new NullPointerException(Messages.getString("crypto.02")); //$NON-NLS-1$ - } - if (provider == null) { - throw new IllegalArgumentException(Messages.getString("crypto.04")); //$NON-NLS-1$ - } - synchronized (engine) { - engine.getInstance(algorithm, provider, null); - return new ExemptionMechanism((ExemptionMechanismSpi) engine.spi, - provider, algorithm); - } - } - - /** - * Returns the provider of this {@code ExemptionMechanism} instance. - * - * @return the provider of this {@code ExemptionMechanism} instance. - */ - public final Provider getProvider() { - return provider; - } - - /** - * Returns whether the result blob for this {@code ExemptionMechanism} - * instance has been generated successfully and that the specified key is - * the same as the one that was used to initialize and generate. - * - * @param key - * the key to verify. - * @return whether the result blob for this {@code ExemptionMechanism} - * instance has been generated successfully. - * @throws ExemptionMechanismException - * if an error occurs while determining whether the result blob - * has been generated successfully. - */ - public final boolean isCryptoAllowed(Key key) - throws ExemptionMechanismException { - - if (generated - && (initKey.equals(key) || Arrays.equals(initKey.getEncoded(), - key.getEncoded()))) { - return true; - } - return false; - } - - /** - * Returns the size in bytes for the output buffer needed to hold the output - * of the next {@link #genExemptionBlob} call, given the specified {@code - * inputLen} (in bytes). - * - * @param inputLen - * the specified input length (in bytes). - * @return the size in bytes for the output buffer. - * @throws IllegalStateException - * if this {@code ExemptionMechanism} instance is not - * initialized. - */ - public final int getOutputSize(int inputLen) throws IllegalStateException { - if (!isInit) { - throw new IllegalStateException(Messages.getString("crypto.2D")); - } - return spiImpl.engineGetOutputSize(inputLen); - } - - /** - * Initializes this {@code ExemptionMechanism} instance with the - * specified key. - * - * @param key - * the key to initialize this instance with. - * @throws InvalidKeyException - * if the key cannot be used to initialize this mechanism. - * @throws ExemptionMechanismException - * if error(s) occur during initialization. - */ - public final void init(Key key) throws InvalidKeyException, - ExemptionMechanismException { - generated = false; - spiImpl.engineInit(key); - initKey = key; - isInit = true; - } - - /** - * Initializes this {@code ExemptionMechanism} instance with the - * specified key and algorithm parameters. - * - * @param key - * the key to initialize this instance with. - * @param param - * the parameters for this exemption mechanism algorithm. - * @throws InvalidKeyException - * if the key cannot be used to initialize this mechanism. - * @throws InvalidAlgorithmParameterException - * if the parameters cannot be used to initialize this - * mechanism. - * @throws ExemptionMechanismException - * if error(s) occur during initialization. - */ - public final void init(Key key, AlgorithmParameters param) - throws InvalidKeyException, InvalidAlgorithmParameterException, - ExemptionMechanismException { - generated = false; - spiImpl.engineInit(key, param); - initKey = key; - isInit = true; - } - - /** - * Initializes this {@code ExemptionMechanism} instance with the - * specified key and algorithm parameters. - * - * @param key - * the key to initialize this instance with. - * @param param - * the parameters for this exemption mechanism algorithm. - * @throws InvalidKeyException - * if the key cannot be used to initialize this mechanism. - * @throws InvalidAlgorithmParameterException - * the the parameters cannot be used to initialize this - * mechanism. - * @throws ExemptionMechanismException - * if error(s) occur during initialization. - */ - public final void init(Key key, AlgorithmParameterSpec param) - throws InvalidKeyException, InvalidAlgorithmParameterException, - ExemptionMechanismException { - generated = false; - spiImpl.engineInit(key, param); - initKey = key; - isInit = true; - } - - /** - * Generates the result key blob for this exemption mechanism. - * - * @return the result key blob for this exemption mechanism. - * @throws IllegalStateException - * if this {@code ExemptionMechanism} instance is not - * initialized. - * @throws ExemptionMechanismException - * if error(s) occur during generation. - */ - public final byte[] genExemptionBlob() throws IllegalStateException, - ExemptionMechanismException { - if (!isInit) { - throw new IllegalStateException(Messages.getString("crypto.2D")); - } - generated = false; - byte[] result = spiImpl.engineGenExemptionBlob(); - generated = true; - return result; - } - - /** - * Generates the result key blob for this exemption mechanism and stores it - * into the {@code output} buffer. - * - * @param output - * the output buffer for the result key blob. - * @return the number of bytes written to the {@code output} buffer. - * @throws IllegalStateException - * if this {@code ExemptionMechanism} instance is not - * initialized. - * @throws ShortBufferException - * if the provided buffer is too small for the result key blob. - * @throws ExemptionMechanismException - * if error(s) occur during generation. - */ - public final int genExemptionBlob(byte[] output) - throws IllegalStateException, ShortBufferException, - ExemptionMechanismException { - return genExemptionBlob(output, 0); - } - - /** - * Generates the result key blob for this exemption mechanism and stores it - * into the {@code output} buffer at offset {@code outputOffset}. - * - * @param output - * the output buffer for the result key blob. - * @param outputOffset - * the offset in the output buffer to start. - * @return the number of bytes written to the {@code output} buffer. - * @throws IllegalStateException - * if this {@code ExemptionMechanism} instance is not - * initialized. - * @throws ShortBufferException - * if the provided buffer is too small for the result key blob. - * @throws ExemptionMechanismException - * if error(s) occur during generation. - */ - public final int genExemptionBlob(byte[] output, int outputOffset) - throws IllegalStateException, ShortBufferException, - ExemptionMechanismException { - if (!isInit) { - throw new IllegalStateException(Messages.getString("crypto.2D")); - } - generated = false; - int len = spiImpl.engineGenExemptionBlob(output, outputOffset); - generated = true; - return len; - } - - /** - * Frees the references to the key used to initialize this instance. - */ - @Override - protected void finalize() { - initKey = null; - } -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/ExemptionMechanismException.java b/libcore/crypto/src/main/java/javax/crypto/ExemptionMechanismException.java deleted file mode 100644 index d094ac359..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/ExemptionMechanismException.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.security.GeneralSecurityException; - -/** - * This is the base class for {@code ExemptionMechanismException}. - */ -public class ExemptionMechanismException extends GeneralSecurityException { - - /** - * @serial - */ - private static final long serialVersionUID = 1572699429277957109L; - - /** - * Creates a new {@code ExemptionMechanismException} with the specified - * message. - * - * @param msg - * the exception message. - */ - public ExemptionMechanismException(String msg) { - super(msg); - } - - /** - * Creates a new {@code ExemptionMechanismException} with no message. - */ - public ExemptionMechanismException() { - } -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/ExemptionMechanismSpi.java b/libcore/crypto/src/main/java/javax/crypto/ExemptionMechanismSpi.java deleted file mode 100644 index 39a27f6ab..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/ExemptionMechanismSpi.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.security.AlgorithmParameters; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.spec.AlgorithmParameterSpec; - -/** - * The Service Provider Interface (SPI) definition for the {@code - * ExemptionMechanism} class. - */ -public abstract class ExemptionMechanismSpi { - - /** - * Creates a new {@code ExemptionMechanismSpi} instance. - */ - public ExemptionMechanismSpi() { - } - - /** - * Generates the result key blob for this exemption mechanism. - * - * @return the result key blob for this exemption mechanism. - * @throws ExemptionMechanismException - * if error(s) occur during generation. - */ - protected abstract byte[] engineGenExemptionBlob() - throws ExemptionMechanismException; - - /** - * Generates the result key blob for this exemption mechanism and stores it - * into the {@code output} buffer at offset {@code outputOffset}. - * - * @param output - * the output buffer for the result key blob. - * @param outputOffset - * the offset in the output buffer to start. - * @return the number of bytes written to the {@code output} buffer. - * @throws ShortBufferException - * if the provided buffer is too small for the result key blob. - * @throws ExemptionMechanismException - * if error(s) occur during generation. - */ - protected abstract int engineGenExemptionBlob(byte[] output, - int outputOffset) throws ShortBufferException, - ExemptionMechanismException; - - /** - * Returns the size in bytes for the output buffer needed to hold the output - * of the next {@link #engineGenExemptionBlob} call, given the specified - * {@code inputLen} (in bytes). - * - * @param inputLen - * the specified input length (in bytes). - * @return the size in bytes for the output buffer. - */ - protected abstract int engineGetOutputSize(int inputLen); - - /** - * Initializes this {@code ExemptionMechanism} instance with the specified - * key. - * - * @param key - * the key to initialize this instance with. - * @throws InvalidKeyException - * if the key cannot be used to initialize this mechanism. - * @throws ExemptionMechanismException - * if error(s) occur during initialization. - */ - protected abstract void engineInit(Key key) throws InvalidKeyException, - ExemptionMechanismException; - - /** - * Initializes this {@code ExemptionMechanism} instance with the specified - * key and algorithm parameters. - * - * @param key - * the key to initialize this instance with. - * @param params - * the parameters for this exemption mechanism algorithm. - * @throws InvalidKeyException - * if the key cannot be used to initialize this mechanism. - * @throws InvalidAlgorithmParameterException - * if the parameters cannot be used to initialize this - * mechanism. - * @throws ExemptionMechanismException - * if error(s) occur during initialization. - */ - protected abstract void engineInit(Key key, AlgorithmParameters params) - throws InvalidKeyException, InvalidAlgorithmParameterException, - ExemptionMechanismException; - - /** - * Initializes this {@code ExemptionMechanism} instance with the specified - * key and algorithm parameters. - * - * @param key - * the key to initialize this instance with. - * @param params - * the parameters for this exemption mechanism algorithm. - * @throws InvalidKeyException - * if the key cannot be used to initialize this mechanism. - * @throws InvalidAlgorithmParameterException - * the the parameters cannot be used to initialize this - * mechanism. - * @throws ExemptionMechanismException - * if error(s) occur during initialization. - */ - protected abstract void engineInit(Key key, AlgorithmParameterSpec params) - throws InvalidKeyException, InvalidAlgorithmParameterException, - ExemptionMechanismException; -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/IllegalBlockSizeException.java b/libcore/crypto/src/main/java/javax/crypto/IllegalBlockSizeException.java deleted file mode 100644 index 0766b7cca..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/IllegalBlockSizeException.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.security.GeneralSecurityException; - -/** - * The exception, that is thrown when the data length provided to a block cipher - * does not match the block size of the cipher. - */ -public class IllegalBlockSizeException extends GeneralSecurityException { - - /** - * @serial - */ - private static final long serialVersionUID = -1965144811953540392L; - - /** - * Creates a new {@code IllegalBlockSizeException} with the specified - * message. - * - * @param msg - * the message - */ - public IllegalBlockSizeException(String msg) { - super(msg); - } - - /** - * Creates a new {@code IllegalBlockSizeException}. - */ - public IllegalBlockSizeException() { - } -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/KeyAgreement.java b/libcore/crypto/src/main/java/javax/crypto/KeyAgreement.java deleted file mode 100644 index 593aa378d..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/KeyAgreement.java +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.Provider; -import java.security.SecureRandom; -import java.security.Security; -import java.security.spec.AlgorithmParameterSpec; - -import org.apache.harmony.crypto.internal.nls.Messages; -import org.apache.harmony.security.fortress.Engine; - -/** - * This class provides the functionality for a key exchange protocol. This - * enables two or more parties to agree on a secret key for symmetric - * cryptography. - */ -public class KeyAgreement { - - // Used to access common engine functionality - private static final Engine engine = new Engine("KeyAgreement"); //$NON-NLS-1$ - - // Store SecureRandom - private static final SecureRandom rndm = new SecureRandom(); - - // Store used provider - private final Provider provider; - - // Store used spi implementation - private final KeyAgreementSpi spiImpl; - - // Store used algorithm name - private final String algorithm; - - /** - * Creates a new {@code KeyAgreement} instance. - * - * @param keyAgreeSpi - * the SPI delegate. - * @param provider - * the provider providing this KeyAgreement. - * @param algorithm - * the name of the key agreement algorithm. - */ - protected KeyAgreement(KeyAgreementSpi keyAgreeSpi, Provider provider, - String algorithm) { - this.provider = provider; - this.algorithm = algorithm; - this.spiImpl = keyAgreeSpi; - } - - /** - * Returns the name of the key agreement algorithm. - * - * @return the name of the key agreement algorithm. - */ - public final String getAlgorithm() { - return algorithm; - } - - /** - * Returns the provider for this {@code KeyAgreement} instance. - * - * @return the provider for this {@code KeyAgreement} instance. - */ - public final Provider getProvider() { - return provider; - } - - /** - * Creates a new {@code KeyAgreement} for the specified algorithm. - * - * @param algorithm - * the name of the key agreement algorithm to create. - * @return a key agreement for the specified algorithm. - * @throws NoSuchAlgorithmException - * if no installed provider can provide the requested algorithm. - * @throws NullPointerException - * if the specified algorithm is {@code null}. - */ - public static final KeyAgreement getInstance(String algorithm) - throws NoSuchAlgorithmException { - if (algorithm == null) { - throw new NullPointerException(Messages.getString("crypto.02")); //$NON-NLS-1$ - } - synchronized (engine) { - engine.getInstance(algorithm, null); - return new KeyAgreement((KeyAgreementSpi) engine.spi, engine.provider, - algorithm); - } - } - - /** - * Creates a new {@code KeyAgreement} for the specified algorithm from the - * specified provider. - * - * @param algorithm - * the name of the key agreement algorithm to create. - * @param provider - * the name of the provider that provides the requested - * algorithm. - * @return a key agreement for the specified algorithm from the specified - * provider. - * @throws NoSuchAlgorithmException - * if the specified provider cannot provide the requested - * algorithm. - * @throws NoSuchProviderException - * if the specified provider does not exist. - * @throws IllegalArgumentException - * if the specified provider name is {@code null} or empty. - */ - public static final KeyAgreement getInstance(String algorithm, - String provider) throws NoSuchAlgorithmException, - NoSuchProviderException { - if ((provider == null) || (provider.length() == 0)) { - throw new IllegalArgumentException(Messages.getString("crypto.03")); //$NON-NLS-1$ - } - Provider impProvider = Security.getProvider(provider); - if (impProvider == null) { - throw new NoSuchProviderException(provider); - } - return getInstance(algorithm, impProvider); - } - - /** - * Create a new {@code KeyAgreement} for the specified algorithm from the - * specified provider. - * - * @param algorithm - * the name of the key agreement algorithm to create. - * @param provider - * the provider that provides the requested algorithm. - * @return a key agreement for the specified algorithm from the specified - * provider. - * @throws NoSuchAlgorithmException - * if the specified provider cannot provide the requested - * algorithm. - * @throws IllegalArgumentException - * if the specified provider is {@code null}. - * @throws NullPointerException - * if the specified algorithm name is {@code null}. - */ - public static final KeyAgreement getInstance(String algorithm, - Provider provider) throws NoSuchAlgorithmException { - if (provider == null) { - throw new IllegalArgumentException(Messages.getString("crypto.04")); //$NON-NLS-1$ - } - if (algorithm == null) { - throw new NullPointerException(Messages.getString("crypto.02")); //$NON-NLS-1$ - } - synchronized (engine) { - engine.getInstance(algorithm, provider, null); - return new KeyAgreement((KeyAgreementSpi) engine.spi, provider, - algorithm); - } - } - - /** - * Initializes this {@code KeyAgreement} with the specified key. - * - * @param key - * the key to initialize this key agreement. - * @throws InvalidKeyException - * if the specified key cannot be used to initialize this key - * agreement. - */ - public final void init(Key key) throws InvalidKeyException { - spiImpl.engineInit(key, rndm);//new SecureRandom()); - } - - /** - * Initializes this {@code KeyAgreement} with the specified key and the - * specified randomness source. - * - * @param key - * the key to initialize this key agreement. - * @param random - * the source for any randomness needed. - * @throws InvalidKeyException - * if the specified key cannot be used to initialize this key - * agreement. - */ - public final void init(Key key, SecureRandom random) - throws InvalidKeyException { - spiImpl.engineInit(key, random); - } - - /** - * Initializes this {@code KeyAgreement} with the specified key and the - * algorithm parameters. - * - * @param key - * the key to initialize this key agreement. - * @param params - * the parameters for this key agreement algorithm. - * @throws InvalidKeyException - * if the specified key cannot be used to initialize this key - * agreement. - * @throws InvalidAlgorithmParameterException - * if the specified parameters are invalid for this key - * agreement algorithm. - */ - public final void init(Key key, AlgorithmParameterSpec params) - throws InvalidKeyException, InvalidAlgorithmParameterException { - spiImpl.engineInit(key, params, rndm);//new SecureRandom()); - } - - /** - * Initializes this {@code KeyAgreement} with the specified key, algorithm - * parameters and randomness source. - * - * @param key - * the key to initialize this key agreement. - * @param params - * the parameters for this key agreement algorithm. - * @param random - * the source for any randomness needed. - * @throws InvalidKeyException - * if the specified key cannot be used to initialize this key - * agreement. - * @throws InvalidAlgorithmParameterException - * if the specified parameters are invalid for this key - * agreement algorithm. - */ - public final void init(Key key, AlgorithmParameterSpec params, - SecureRandom random) throws InvalidKeyException, - InvalidAlgorithmParameterException { - spiImpl.engineInit(key, params, random); - } - - /** - * Does the next (or the last) phase of the key agreement, using the - * specified key. - * - * @param key - * the key received from the other party for this phase. - * @param lastPhase - * set to {@code true} if this is the last phase of this key - * agreement. - * @return the intermediate key from this phase or {@code null} if there is - * no intermediate key for this phase. - * @throws InvalidKeyException - * if the specified key cannot be used in this key agreement or - * this phase, - * @throws IllegalStateException - * if this instance has not been initialized. - */ - public final Key doPhase(Key key, boolean lastPhase) - throws InvalidKeyException, IllegalStateException { - return spiImpl.engineDoPhase(key, lastPhase); - } - - /** - * Generates the shared secret. - * - * @return the generated shared secret. - * @throws IllegalStateException - * if this key agreement is not complete. - */ - public final byte[] generateSecret() throws IllegalStateException { - return spiImpl.engineGenerateSecret(); - } - - /** - * Generates the shared secret and stores it into the buffer {@code - * sharedSecred} at {@code offset}. - * - * @param sharedSecret - * the buffer to store the shared secret. - * @param offset - * the offset in the buffer. - * @return the number of bytes stored in the buffer. - * @throws IllegalStateException - * if this key agreement is not complete. - * @throws ShortBufferException - * if the specified buffer is too small for the shared secret. - */ - public final int generateSecret(byte[] sharedSecret, int offset) - throws IllegalStateException, ShortBufferException { - return spiImpl.engineGenerateSecret(sharedSecret, offset); - } - - /** - * Generates the shared secret. - * - * @param algorithm - * the algorithm to for the {@code SecretKey} - * @return the shared secret as a {@code SecretKey} of the specified - * algorithm. - * @throws IllegalStateException - * if this key agreement is not complete. - * @throws NoSuchAlgorithmException - * if the specified algorithm for the secret key does not - * exists. - * @throws InvalidKeyException - * if a {@code SecretKey} with the specified algorithm cannot be - * created using the generated shared secret. - */ - public final SecretKey generateSecret(String algorithm) - throws IllegalStateException, NoSuchAlgorithmException, - InvalidKeyException { - return spiImpl.engineGenerateSecret(algorithm); - } - -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/KeyAgreementSpi.java b/libcore/crypto/src/main/java/javax/crypto/KeyAgreementSpi.java deleted file mode 100644 index 50111837c..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/KeyAgreementSpi.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.security.spec.AlgorithmParameterSpec; - -/** - * The Service Provider Interface (SPI) definition for the - * {@code KeyAgreement} class. - */ -public abstract class KeyAgreementSpi { - - /** - * Creates a new {@code KeyAgreementSpi} instance. - */ - public KeyAgreementSpi() { - } - - /** - * Does the next (or the last) phase of the key agreement, using the - * specified key. - * - * @param key - * the key received from the other party for this phase. - * @param lastPhase - * set to {@code true} if this is the last phase of this key - * agreement. - * @return the intermediate key from this phase or null if there is no - * intermediate key for this phase. - * @throws InvalidKeyException - * if the specified key cannot be used in this key agreement or - * this phase, - * @throws IllegalStateException - * if this instance has not been initialized. - */ - protected abstract Key engineDoPhase(Key key, boolean lastPhase) - throws InvalidKeyException, IllegalStateException; - - /** - * Generates the shared secret. - * - * @return the generated shared secret. - * @throws IllegalStateException - * if this key agreement is not complete. - */ - protected abstract byte[] engineGenerateSecret() - throws IllegalStateException; - - /** - * Generates the shared secret and stores it into the buffer {@code - * sharedSecred} at {@code offset}. - * - * @param sharedSecret - * the buffer to store the shared secret. - * @param offset - * the offset in the buffer. - * @return the number of bytes stored in the buffer. - * @throws IllegalStateException - * if this key agreement is not complete. - * @throws ShortBufferException - * if the specified buffer is too small for the shared secret. - */ - protected abstract int engineGenerateSecret(byte[] sharedSecret, int offset) - throws IllegalStateException, ShortBufferException; - - /** - * Generates the shared secret. - * - * @param algorithm - * the algorithm to for the {@code SecretKey} - * @return the shared secret as a {@code SecretKey} of the specified - * algorithm. - * @throws IllegalStateException - * if this key agreement is not complete. - * @throws NoSuchAlgorithmException - * if the specified algorithm for the secret key does not - * exists. - * @throws InvalidKeyException - * if a {@code SecretKey} with the specified algorithm cannot be - * created using the generated shared secret. - */ - protected abstract SecretKey engineGenerateSecret(String algorithm) - throws IllegalStateException, NoSuchAlgorithmException, - InvalidKeyException; - - /** - * Initializes this {@code KeyAgreementSpi} with the specified key and the - * specified randomness source. - * - * @param key - * the key to initialize this key agreement. - * @param random - * the source for any randomness needed. - * @throws InvalidKeyException - * if the specified key cannot be used to initialize this key - * agreement. - */ - protected abstract void engineInit(Key key, SecureRandom random) - throws InvalidKeyException; - - /** - * Initializes this {@code KeyAgreementSpi} with the specified key, - * algorithm parameters and randomness source. - * - * @param key - * the key to initialize this key agreement. - * @param params - * the parameters for this key agreement algorithm. - * @param random - * the source for any randomness needed. - * @throws InvalidKeyException - * if the specified key cannot be used to initialize this key - * agreement. - * @throws InvalidAlgorithmParameterException - * if the specified parameters are invalid for this key - * agreement algorithm. - */ - protected abstract void engineInit(Key key, AlgorithmParameterSpec params, - SecureRandom random) throws InvalidKeyException, - InvalidAlgorithmParameterException; -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/KeyGenerator.java b/libcore/crypto/src/main/java/javax/crypto/KeyGenerator.java deleted file mode 100644 index f1dd3b2fb..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/KeyGenerator.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.Provider; -import java.security.SecureRandom; -import java.security.Security; -import java.security.spec.AlgorithmParameterSpec; - -import org.apache.harmony.crypto.internal.nls.Messages; -import org.apache.harmony.security.fortress.Engine; - - -/** - * This class provides the public API for generating symmetric cryptographic - * keys. - */ -public class KeyGenerator { - - // Used to access common engine functionality - private static final Engine engine = new Engine("KeyGenerator"); //$NON-NLS-1$ - - // Store SecureRandom - private static final SecureRandom rndm = new SecureRandom(); - - // Store used provider - private final Provider provider; - - // Store used spi implementation - private final KeyGeneratorSpi spiImpl; - - // Store used algorithm name - private final String algorithm; - - /** - * Creates a new {@code KeyGenerator} instance. - * - * @param keyGenSpi - * the implementation delegate. - * @param provider - * the implementation provider. - * @param algorithm - * the name of the algorithm. - */ - protected KeyGenerator(KeyGeneratorSpi keyGenSpi, Provider provider, - String algorithm) { - this.provider = provider; - this.algorithm = algorithm; - this.spiImpl = keyGenSpi; - } - - /** - * Returns the name of the key generation algorithm. - * - * @return the name of the key generation algorithm. - */ - public final String getAlgorithm() { - return algorithm; - } - - /** - * Returns the provider of this {@code KeyGenerator} instance. - * - * @return the provider of this {@code KeyGenerator} instance. - */ - public final Provider getProvider() { - return provider; - } - - /** - * Creates a new {@code KeyGenerator} instance that provides the specified - * key algorithm, - * - * @param algorithm - * the name of the requested key algorithm - * @return the new {@code KeyGenerator} instance. - * @throws NoSuchAlgorithmException - * if the specified algorithm is not available by any provider. - * @throws NullPointerException - * if {@code algorithm} is {@code null}. - */ - public static final KeyGenerator getInstance(String algorithm) - throws NoSuchAlgorithmException { - if (algorithm == null) { - throw new NullPointerException(Messages.getString("crypto.02")); //$NON-NLS-1$ - } - synchronized (engine) { - engine.getInstance(algorithm, null); - return new KeyGenerator((KeyGeneratorSpi) engine.spi, engine.provider, - algorithm); - } - } - - /** - * Creates a new {@code KeyGenerator} instance that provides the specified - * key algorithm from the specified provider. - * - * @param algorithm - * the name of the requested key algorithm. - * @param provider - * the name of the provider that is providing the algorithm. - * @return the new {@code KeyGenerator} instance. - * @throws NoSuchAlgorithmException - * if the specified algorithm is not provided by the specified - * provider. - * @throws NoSuchProviderException - * if the specified provider is not available. - * @throws IllegalArgumentException - * if the specified provider is name is {@code null} or empty. - * @throws NullPointerException - * if the specified algorithm name is {@code null}. - */ - public static final KeyGenerator getInstance(String algorithm, - String provider) throws NoSuchAlgorithmException, - NoSuchProviderException { - if ((provider == null) || (provider.length() == 0)) { - throw new IllegalArgumentException(Messages.getString("crypto.03")); //$NON-NLS-1$ - } - Provider impProvider = Security.getProvider(provider); - if (impProvider == null) { - throw new NoSuchProviderException(provider); - } - return getInstance(algorithm, impProvider); - } - - /** - * Creates a new {@code KeyGenerator} instance that provides the specified - * key algorithm from the specified provider. - * - * @param algorithm - * the name of the requested key algorithm. - * @param provider - * the provider that is providing the algorithm - * @return the new {@code KeyGenerator} instance. - * @throws NoSuchAlgorithmException - * if the specified algorithm is not provided by the specified - * provider. - * @throws IllegalArgumentException - * if the specified provider is {@code null}. - * @throws NullPointerException - * if the specified algorithm name is {@code null}. - */ - public static final KeyGenerator getInstance(String algorithm, - Provider provider) throws NoSuchAlgorithmException { - if (provider == null) { - throw new IllegalArgumentException(Messages.getString("crypto.04")); //$NON-NLS-1$ - } - if (algorithm == null) { - throw new NullPointerException(Messages.getString("crypto.02")); //$NON-NLS-1$ - } - synchronized (engine) { - engine.getInstance(algorithm, provider, null); - return new KeyGenerator((KeyGeneratorSpi) engine.spi, provider, - algorithm); - } - } - - /** - * Generates a secret key. - * - * @return the generated secret key. - */ - public final SecretKey generateKey() { - return spiImpl.engineGenerateKey(); - } - - /** - * Initializes this {@code KeyGenerator} instance with the specified - * algorithm parameters. - * - * @param params - * the parameters for the key generation algorithm. - * @throws InvalidAlgorithmParameterException - * if the parameters cannot be used to initialize this key - * generator algorithm. - */ - public final void init(AlgorithmParameterSpec params) - throws InvalidAlgorithmParameterException { - spiImpl.engineInit(params, rndm);//new SecureRandom()); - } - - /** - * Initializes this {@code KeyGenerator} instance with the specified - * algorithm parameters and randomness source. - * - * @param params - * the parameters for the key generation algorithm. - * @param random - * the randomness source for any random bytes. - * @throws InvalidAlgorithmParameterException - * if the parameters cannot be uses to initialize this key - * generator algorithm. - */ - public final void init(AlgorithmParameterSpec params, SecureRandom random) - throws InvalidAlgorithmParameterException { - spiImpl.engineInit(params, random); - } - - /** - * Initializes this {@code KeyGenerator} instance for the specified key size - * (in bits). - * - * @param keysize - * the size of the key (in bits). - */ - public final void init(int keysize) { - spiImpl.engineInit(keysize, rndm);//new SecureRandom()); - } - - /** - * Initializes this {@code KeyGenerator} instance for the specified key size - * (in bits) using the specified randomness source. - * - * @param keysize - * the size of the key (in bits). - * @param random - * the randomness source for any random bytes. - */ - public final void init(int keysize, SecureRandom random) { - spiImpl.engineInit(keysize, random); - } - - /** - * Initializes this {@code KeyGenerator} with the specified randomness - * source. - * - * @param random - * the randomness source for any random bytes. - */ - public final void init(SecureRandom random) { - spiImpl.engineInit(random); - } -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/KeyGeneratorSpi.java b/libcore/crypto/src/main/java/javax/crypto/KeyGeneratorSpi.java deleted file mode 100644 index edbbe4321..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/KeyGeneratorSpi.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.security.InvalidAlgorithmParameterException; -import java.security.SecureRandom; -import java.security.spec.AlgorithmParameterSpec; - -/** - * The Service Provider Interface (SPI) definition for the - * {@code KeyGenerator} class. - * - * @see KeyGenerator - */ -public abstract class KeyGeneratorSpi { - - /** - * Creates a new {@code KeyGeneratorSpi} instance. - */ - public KeyGeneratorSpi() { - } - - /** - * Generates a secret key. - * - * @return the generated secret key. - */ - protected abstract SecretKey engineGenerateKey(); - - /** - * Initializes this {@code KeyGeneratorSpi} instance with the specified - * algorithm parameters and randomness source. - * - * @param params - * the parameters for the key generation algorithm. - * @param random - * the randomness source for any random bytes. - * @throws InvalidAlgorithmParameterException - * if the parameters cannot be uses to initialize this key - * generator algorithm. - */ - protected abstract void engineInit(AlgorithmParameterSpec params, - SecureRandom random) throws InvalidAlgorithmParameterException; - - /** - * Initializes this {@code KeyGenerator} instance for the specified key - * size (in bits) using the specified randomness source. - * - * @param keysize - * the size of the key (in bits). - * @param random - * the randomness source for any random bytes. - */ - protected abstract void engineInit(int keysize, SecureRandom random); - - /** - * Initializes this {@code KeyGenerator} with the specified randomness - * source. - * - * @param random - * the randomness source for any random bytes. - */ - protected abstract void engineInit(SecureRandom random); -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/Mac.java b/libcore/crypto/src/main/java/javax/crypto/Mac.java deleted file mode 100644 index 94ea20e25..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/Mac.java +++ /dev/null @@ -1,431 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.nio.ByteBuffer; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.Provider; -import java.security.Security; -import java.security.spec.AlgorithmParameterSpec; - -import org.apache.harmony.crypto.internal.nls.Messages; -import org.apache.harmony.security.fortress.Engine; - - -/** - * This class provides the public API for Message Authentication Code - * (MAC) algorithms. - */ -public class Mac implements Cloneable { - - //Used to access common engine functionality - private static final Engine engine = new Engine("Mac"); //$NON-NLS-1$ - - // Store used provider - private final Provider provider; - - // Store used spi implementation - private final MacSpi spiImpl; - - // Store used algorithm name - private final String algorithm; - - // Store Mac state (initialized or not initialized) - private boolean isInitMac; - - /** - * Creates a new {@code Mac} instance. - * - * @param macSpi - * the implementation delegate. - * @param provider - * the implementation provider. - * @param algorithm - * the name of the MAC algorithm. - */ - protected Mac(MacSpi macSpi, Provider provider, String algorithm) { - this.provider = provider; - this.algorithm = algorithm; - this.spiImpl = macSpi; - this.isInitMac = false; - } - - /** - * Returns the name of the MAC algorithm. - * - * @return the name of the MAC algorithm. - */ - public final String getAlgorithm() { - return algorithm; - } - - /** - * Returns the provider of this {@code Mac} instance. - * - * @return the provider of this {@code Mac} instance. - */ - public final Provider getProvider() { - return provider; - } - - /** - * Creates a new {@code Mac} instance that provides the specified MAC - * algorithm. - * - * @param algorithm - * the name of the requested MAC algorithm. - * @return the new {@code Mac} instance. - * @throws NoSuchAlgorithmException - * if the specified algorithm is not available by any provider. - * @throws NullPointerException - * if {@code algorithm} is {@code null} (instead of - * NoSuchAlgorithmException as in 1.4 release). - */ - public static final Mac getInstance(String algorithm) - throws NoSuchAlgorithmException { - if (algorithm == null) { - throw new NullPointerException(Messages.getString("crypto.02")); //$NON-NLS-1$ - } - synchronized (engine) { - engine.getInstance(algorithm, null); - return new Mac((MacSpi) engine.spi, engine.provider, algorithm); - } - } - - /** - * Creates a new {@code Mac} instance that provides the specified MAC - * algorithm from the specified provider. - * - * @param algorithm - * the name of the requested MAC algorithm. - * @param provider - * the name of the provider that is providing the algorithm. - * @return the new {@code Mac} instance. - * @throws NoSuchAlgorithmException - * if the specified algorithm is not provided by the specified - * provider. - * @throws NoSuchProviderException - * if the specified provider is not available. - * @throws IllegalArgumentException - * if the specified provider name is {@code null} or empty. - * @throws NullPointerException - * if {@code algorithm} is {@code null} (instead of - * NoSuchAlgorithmException as in 1.4 release). - */ - public static final Mac getInstance(String algorithm, String provider) - throws NoSuchAlgorithmException, NoSuchProviderException { - if ((provider == null) || (provider.length() == 0)) { - throw new IllegalArgumentException(Messages.getString("crypto.03")); //$NON-NLS-1$ - } - Provider impProvider = Security.getProvider(provider); - if (impProvider == null) { - throw new NoSuchProviderException(provider); - } - return getInstance(algorithm, impProvider); - } - - /** - * Creates a new {@code Mac} instance that provides the specified MAC - * algorithm from the specified provider. - * - * @param algorithm - * the name of the requested MAC algorithm. - * @param provider - * the provider that is providing the algorithm. - * @return the new {@code Mac} instance. - * @throws NoSuchAlgorithmException - * if the specified algorithm is not provided by the specified - * provider. - * @throws IllegalArgumentException - * if {@code provider} is {@code null}. - * @throws NullPointerException - * if {@code algorithm} is {@code null} (instead of - * NoSuchAlgorithmException as in 1.4 release). - */ - public static final Mac getInstance(String algorithm, Provider provider) - throws NoSuchAlgorithmException { - if (provider == null) { - throw new IllegalArgumentException(Messages.getString("crypto.04")); //$NON-NLS-1$ - } - if (algorithm == null) { - throw new NullPointerException(Messages.getString("crypto.02")); //$NON-NLS-1$ - } - synchronized (engine) { - engine.getInstance(algorithm, provider, null); - return new Mac((MacSpi) engine.spi, provider, algorithm); - } - } - - /** - * Returns the length of this MAC (in bytes). - * - * @return the length of this MAC (in bytes). - */ - public final int getMacLength() { - return spiImpl.engineGetMacLength(); - } - - /** - * Initializes this {@code Mac} instance with the specified key and - * algorithm parameters. - * - * @param key - * the key to initialize this algorithm. - * @param params - * the parameters for this algorithm. - * @throws InvalidKeyException - * if the specified key cannot be used to initialize this - * algorithm, or it is null. - * @throws InvalidAlgorithmParameterException - * if the specified parameters cannot be used to initialize this - * algorithm. - */ - public final void init(Key key, AlgorithmParameterSpec params) - throws InvalidKeyException, InvalidAlgorithmParameterException { - if (key == null) { - throw new InvalidKeyException(Messages.getString("crypto.05")); //$NON-NLS-1$ - } - spiImpl.engineInit(key, params); - isInitMac = true; - } - - /** - * Initializes this {@code Mac} instance with the specified key. - * - * @param key - * the key to initialize this algorithm. - * @throws InvalidKeyException - * if initialization fails because the provided key is {@code - * null}. - * @throws RuntimeException - * if the specified key cannot be used to initialize this - * algorithm. - */ - public final void init(Key key) throws InvalidKeyException { - if (key == null) { - throw new InvalidKeyException(Messages.getString("crypto.05")); //$NON-NLS-1$ - } - try { - spiImpl.engineInit(key, null); - isInitMac = true; - } catch (InvalidAlgorithmParameterException e) { - throw new RuntimeException(e); - } - } - - /** - * Updates this {@code Mac} instance with the specified byte. - * - * @param input - * the byte - * @throws IllegalStateException - * if this MAC is not initialized. - */ - public final void update(byte input) throws IllegalStateException { - if (!isInitMac) { - throw new IllegalStateException(Messages.getString("crypto.01")); - } - spiImpl.engineUpdate(input); - } - - /** - * Updates this {@code Mac} instance with the data from the specified buffer - * {@code input} from the specified {@code offset} and length {@code len}. - * - * @param input - * the buffer. - * @param offset - * the offset in the buffer. - * @param len - * the length of the data in the buffer. - * @throws IllegalStateException - * if this MAC is not initialized. - * @throws IllegalArgumentException - * if {@code offset} and {@code len} do not specified a valid - * chunk in {@code input} buffer. - */ - public final void update(byte[] input, int offset, int len) - throws IllegalStateException { - if (!isInitMac) { - throw new IllegalStateException(Messages.getString("crypto.01")); - } - if (input == null) { - return; - } - if ((offset < 0) || (len < 0) || ((offset + len) > input.length)) { - throw new IllegalArgumentException(Messages.getString("crypto.06")); //$NON-NLS-1$ - } - spiImpl.engineUpdate(input, offset, len); - } - - /** - * Copies the buffer provided as input for further processing. - * - * @param input - * the buffer. - * @throws IllegalStateException - * if this MAC is not initialized. - */ - public final void update(byte[] input) throws IllegalStateException { - if (!isInitMac) { - throw new IllegalStateException(Messages.getString("crypto.01")); - } - if (input != null) { - spiImpl.engineUpdate(input, 0, input.length); - } - } - - /** - * Updates this {@code Mac} instance with the data from the specified - * buffer, starting at {@link ByteBuffer#position()}, including the next - * {@link ByteBuffer#remaining()} bytes. - * - * @param input - * the buffer. - * @throws IllegalStateException - * if this MAC is not initialized. - */ - public final void update(ByteBuffer input) { - if (!isInitMac) { - throw new IllegalStateException(Messages.getString("crypto.01")); - } - if (input != null) { - spiImpl.engineUpdate(input); - } else { - throw new IllegalArgumentException(Messages.getString("crypto.07")); //$NON-NLS-1$ - } - } - - /** - * Computes the digest of this MAC based on the data previously specified in - * {@link #update} calls. - *

- * This {@code Mac} instance is reverted to its initial state and can be - * used to start the next MAC computation with the same parameters or - * initialized with different parameters. - * - * @return the generated digest. - * @throws IllegalStateException - * if this MAC is not initialized. - */ - public final byte[] doFinal() throws IllegalStateException { - if (!isInitMac) { - throw new IllegalStateException(Messages.getString("crypto.01")); - } - return spiImpl.engineDoFinal(); - } - - /** - * Computes the digest of this MAC based on the data previously specified in - * {@link #update} calls and stores the digest in the specified {@code - * output} buffer at offset {@code outOffset}. - *

- * This {@code Mac} instance is reverted to its initial state and can be - * used to start the next MAC computation with the same parameters or - * initialized with different parameters. - * - * @param output - * the output buffer - * @param outOffset - * the offset in the output buffer - * @throws ShortBufferException - * if the specified output buffer is either too small for the - * digest to be stored, the specified output buffer is {@code - * null}, or the specified offset is negative or past the length - * of the output buffer. - * @throws IllegalStateException - * if this MAC is not initialized. - */ - public final void doFinal(byte[] output, int outOffset) - throws ShortBufferException, IllegalStateException { - if (!isInitMac) { - throw new IllegalStateException(Messages.getString("crypto.01")); - } - if (output == null) { - throw new ShortBufferException(Messages.getString("crypto.08")); //$NON-NLS-1$ - } - if ((outOffset < 0) || (outOffset >= output.length)) { - throw new ShortBufferException(Messages.getString("crypto.09", //$NON-NLS-1$ - Integer.toString(outOffset))); - } - int t = spiImpl.engineGetMacLength(); - if (t > (output.length - outOffset)) { - throw new ShortBufferException( - Messages.getString("crypto.0A", //$NON-NLS-1$ - Integer.toString(t))); - } - byte[] result = spiImpl.engineDoFinal(); - System.arraycopy(result, 0, output, outOffset, result.length); - - } - - /** - * Computes the digest of this MAC based on the data previously specified on - * {@link #update} calls and on the final bytes specified by {@code input} - * (or based on those bytes only). - *

- * This {@code Mac} instance is reverted to its initial state and can be - * used to start the next MAC computation with the same parameters or - * initialized with different parameters. - * - * @param input - * the final bytes. - * @return the generated digest. - * @throws IllegalStateException - * if this MAC is not initialized. - */ - public final byte[] doFinal(byte[] input) throws IllegalStateException { - if (!isInitMac) { - throw new IllegalStateException(Messages.getString("crypto.0B")); //$NON-NLS-1$ - } - if (input != null) { - spiImpl.engineUpdate(input, 0, input.length); - } - return spiImpl.engineDoFinal(); - } - - /** - * Resets this {@code Mac} instance to its initial state. - *

- * This {@code Mac} instance is reverted to its initial state and can be - * used to start the next MAC computation with the same parameters or - * initialized with different parameters. - */ - public final void reset() { - spiImpl.engineReset(); - } - - /** - * Clones this {@code Mac} instance and the underlying implementation. - * - * @return the cloned instance. - * @throws CloneNotSupportedException - * if the underlying implementation does not support cloning. - */ - @Override - public final Object clone() throws CloneNotSupportedException { - MacSpi newSpiImpl = (MacSpi)spiImpl.clone(); - Mac mac = new Mac(newSpiImpl, this.provider, this.algorithm); - mac.isInitMac = this.isInitMac; - return mac; - } -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/MacSpi.java b/libcore/crypto/src/main/java/javax/crypto/MacSpi.java deleted file mode 100644 index b2683d226..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/MacSpi.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.security.Key; -import java.security.InvalidKeyException; -import java.security.InvalidAlgorithmParameterException; -import java.security.spec.AlgorithmParameterSpec; -import java.nio.ByteBuffer; - -/** - * The Service-Provider Interface (SPI) definition for the {@code - * Mac} class. - * - * @see Mac - */ -public abstract class MacSpi { - - /** - * Creates a new {@code MacSpi} instance. - */ - public MacSpi() { - } - - /** - * Returns the length of this MAC (in bytes). - * - * @return the length of this MAC (in bytes). - */ - protected abstract int engineGetMacLength(); - - /** - * Initializes this {@code MacSpi} instance with the specified key and - * algorithm parameters. - * - * @param key - * the key to initialize this algorithm. - * @param params - * the parameters for this algorithm. - * @throws InvalidKeyException - * if the specified key cannot be used to initialize this - * algorithm, or it is {@code null}. - * @throws InvalidAlgorithmParameterException - * if the specified parameters cannot be used to initialize this - * algorithm. - */ - protected abstract void engineInit(Key key, AlgorithmParameterSpec params) - throws InvalidKeyException, InvalidAlgorithmParameterException; - - /** - * Updates this {@code MacSpi} instance with the specified byte. - * - * @param input - * the byte. - */ - protected abstract void engineUpdate(byte input); - - /** - * Updates this {@code MacSpi} instance with the data from the specified - * buffer {@code input} from the specified {@code offset} and length {@code - * len}. - * - * @param input - * the buffer. - * @param offset - * the offset in the buffer. - * @param len - * the length of the data in the buffer. - */ - protected abstract void engineUpdate(byte[] input, int offset, int len); - - /** - * Updates this {@code MacSpi} instance with the data from the specified - * buffer, starting at {@link ByteBuffer#position()}, including the next - * {@link ByteBuffer#remaining()} bytes. - * - * @param input - * the buffer. - */ - protected void engineUpdate(ByteBuffer input) { - if (!input.hasRemaining()) { - return; - } - byte[] bInput; - if (input.hasArray()) { - bInput = input.array(); - int offset = input.arrayOffset(); - int position = input.position(); - int limit = input.limit(); - engineUpdate(bInput, offset + position, limit - position); - input.position(limit); - } else { - bInput = new byte[input.limit() - input.position()]; - input.get(bInput); - engineUpdate(bInput, 0, bInput.length); - } - } - - /** - * Computes the digest of this MAC based on the data previously specified in - * {@link #engineUpdate} calls. - *

- * This {@code MacSpi} instance is reverted to its initial state and - * can be used to start the next MAC computation with the same parameters or - * initialized with different parameters. - * - * @return the generated digest. - */ - protected abstract byte[] engineDoFinal(); - - /** - * Resets this {@code MacSpi} instance to its initial state. - *

- * This {@code MacSpi} instance is reverted to its initial state and can be - * used to start the next MAC computation with the same parameters or - * initialized with different parameters. - */ - protected abstract void engineReset(); - - /** - * Clones this {@code MacSpi} instance. - * - * @return the cloned instance. - * @throws CloneNotSupportedException - * if cloning is not supported. - */ - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/NoSuchPaddingException.java b/libcore/crypto/src/main/java/javax/crypto/NoSuchPaddingException.java deleted file mode 100644 index 55e1f1e4e..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/NoSuchPaddingException.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.security.GeneralSecurityException; - -/** - * The exception that is thrown when the requested padding mechanism is not - * supported. - */ -public class NoSuchPaddingException extends GeneralSecurityException { - - /** - * @serial - */ - private static final long serialVersionUID = -4572885201200175466L; - - /** - * Creates a new {@code NoSuchPaddingException} with the specified - * message. - * - * @param msg - * the message. - */ - public NoSuchPaddingException(String msg) { - super(msg); - } - - /** - * Creates a new {@code NoSuchPaddingException}. - */ - public NoSuchPaddingException() { - } -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/NullCipher.java b/libcore/crypto/src/main/java/javax/crypto/NullCipher.java deleted file mode 100644 index fadf3aee9..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/NullCipher.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Boris V. Kuznetsov -* @version $Revision$ -*/ - -package javax.crypto; - -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.SecureRandom; - -import org.apache.harmony.crypto.internal.NullCipherSpi; - - -/** - * This class provides an identity cipher that does not transform the input data - * in any way. The encrypted data is identical to the plain text. - */ -public class NullCipher extends Cipher { - - /** - * Creates a new {@code NullCipher} instance. - */ - public NullCipher() { - super(new NullCipherSpi(), null, null); - try { - this.init(Cipher.ENCRYPT_MODE, (Key)null, (SecureRandom)null); - } catch (InvalidKeyException e) { - } - } - -} diff --git a/libcore/crypto/src/main/java/javax/crypto/SealedObject.java b/libcore/crypto/src/main/java/javax/crypto/SealedObject.java deleted file mode 100644 index bf453db77..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/SealedObject.java +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.security.AlgorithmParameters; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; - -import org.apache.harmony.crypto.internal.nls.Messages; - -/** - * A {@code SealedObject} is a wrapper around a {@code serializable} object - * instance and encrypts it using a cryptographic cipher. - *

- * Since a {@code SealedObject} instance is a serializable object itself it can - * either be stored or transmitted over an insecure channel. - *

- * The wrapped object can later be decrypted (unsealed) using the corresponding - * key and then be deserialized to retrieve the original object.The sealed - * object itself keeps track of the cipher and corresponding parameters. - */ -public class SealedObject implements Serializable { - - private static final long serialVersionUID = 4482838265551344752L; - - /** - * The {@link AlgorithmParameters} in encoded format. - */ - protected byte[] encodedParams; - private byte[] encryptedContent; - private String sealAlg; - private String paramsAlg; - - private void readObject(ObjectInputStream s) - throws IOException, ClassNotFoundException { - encodedParams = (byte []) s.readUnshared(); - encryptedContent = (byte []) s.readUnshared(); - sealAlg = (String) s.readUnshared(); - paramsAlg = (String) s.readUnshared(); - } - - /** - * Creates a new {@code SealedObject} instance wrapping the specified object - * and sealing it using the specified cipher. - *

- * The cipher must be fully initialized. - * - * @param object - * the object to seal, can be {@code null}. - * @param c - * the cipher to encrypt the object. - * @throws IOException - * if the serialization fails. - * @throws IllegalBlockSizeException - * if the specified cipher is a block cipher and the length of - * the serialized data is not a multiple of the ciphers block - * size. - * @throws NullPointerException - * if the cipher is {@code null}. - */ - public SealedObject(Serializable object, Cipher c) - throws IOException, IllegalBlockSizeException { - if (c == null) { - throw new NullPointerException(Messages.getString("crypto.13")); //$NON-NLS-1$ - } - try { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(bos); - oos.writeObject(object); - oos.flush(); - AlgorithmParameters ap = c.getParameters(); - this.encodedParams = (ap == null) ? null : ap.getEncoded(); - this.paramsAlg = (ap == null) ? null : ap.getAlgorithm(); - this.sealAlg = c.getAlgorithm(); - this.encryptedContent = c.doFinal(bos.toByteArray()); - } catch (BadPaddingException e) { - // should be never thrown because the cipher - // should be initialized for encryption - throw new IOException(e.toString()); - } - } - - /** - * Creates a new {@code SealedObject} instance by copying the data from - * the specified object. - * - * @param so - * the object to copy. - */ - protected SealedObject(SealedObject so) { - if (so == null) { - throw new NullPointerException(Messages.getString("crypto.14")); //$NON-NLS-1$ - } - this.encryptedContent = so.encryptedContent; - this.encodedParams = so.encodedParams; - this.sealAlg = so.sealAlg; - this.paramsAlg = so.paramsAlg; - } - - /** - * Returns the algorithm this object was sealed with. - * - * @return the algorithm this object was sealed with. - */ - public final String getAlgorithm() { - return sealAlg; - } - - /** - * Returns the wrapped object, decrypting it using the specified key. - * - * @param key - * the key to decrypt the data with. - * @return the encapsulated object. - * @throws IOException - * if deserialization fails. - * @throws ClassNotFoundException - * if deserialization fails. - * @throws NoSuchAlgorithmException - * if the algorithm to decrypt the data is not available. - * @throws InvalidKeyException - * if the specified key cannot be used to decrypt the data. - */ - public final Object getObject(Key key) - throws IOException, ClassNotFoundException, - NoSuchAlgorithmException, InvalidKeyException { - // BEGIN android-added - if (key == null) { - throw new InvalidKeyException( - Messages.getString("crypto.05")); - } - // END android-added - try { - Cipher cipher = Cipher.getInstance(sealAlg); - if ((paramsAlg != null) && (paramsAlg.length() != 0)) { - AlgorithmParameters params = - AlgorithmParameters.getInstance(paramsAlg); - params.init(encodedParams); - cipher.init(Cipher.DECRYPT_MODE, key, params); - } else { - cipher.init(Cipher.DECRYPT_MODE, key); - } - byte[] serialized = cipher.doFinal(encryptedContent); - ObjectInputStream ois = - new ObjectInputStream( - new ByteArrayInputStream(serialized)); - return ois.readObject(); - } catch (NoSuchPaddingException e) { - // should not be thrown because cipher text was made - // with existing padding - throw new NoSuchAlgorithmException(e.toString()); - } catch (InvalidAlgorithmParameterException e) { - // should not be thrown because cipher text was made - // with correct algorithm parameters - throw new NoSuchAlgorithmException(e.toString()); - } catch (IllegalBlockSizeException e) { - // should not be thrown because the cipher text - // was correctly made - throw new NoSuchAlgorithmException(e.toString()); - } catch (BadPaddingException e) { - // should not be thrown because the cipher text - // was correctly made - throw new NoSuchAlgorithmException(e.toString()); - } catch (IllegalStateException e) { - // should never be thrown because cipher is initialized - throw new NoSuchAlgorithmException(e.toString()); - } - } - - /** - * Returns the wrapped object, decrypting it using the specified - * cipher. - * - * @param c - * the cipher to decrypt the data. - * @return the encapsulated object. - * @throws IOException - * if deserialization fails. - * @throws ClassNotFoundException - * if deserialization fails. - * @throws IllegalBlockSizeException - * if the specified cipher is a block cipher and the length of - * the serialized data is not a multiple of the ciphers block - * size. - * @throws BadPaddingException - * if the padding of the data does not match the padding scheme. - */ - public final Object getObject(Cipher c) - throws IOException, ClassNotFoundException, - IllegalBlockSizeException, BadPaddingException { - if (c == null) { - throw new NullPointerException(Messages.getString("crypto.13")); //$NON-NLS-1$ - } - byte[] serialized = c.doFinal(encryptedContent); - ObjectInputStream ois = - new ObjectInputStream( - new ByteArrayInputStream(serialized)); - return ois.readObject(); - } - - /** - * Returns the wrapped object, decrypting it using the specified key. The - * specified provider is used to retrieve the cipher algorithm. - * - * @param key - * the key to decrypt the data. - * @param provider - * the name of the provider that provides the cipher algorithm. - * @return the encapsulated object. - * @throws IOException - * if deserialization fails. - * @throws ClassNotFoundException - * if deserialization fails. - * @throws NoSuchAlgorithmException - * if the algorithm used to decrypt the data is not available. - * @throws NoSuchProviderException - * if the specified provider is not available. - * @throws InvalidKeyException - * if the specified key cannot be used to decrypt the data. - */ - public final Object getObject(Key key, String provider) - throws IOException, ClassNotFoundException, - NoSuchAlgorithmException, NoSuchProviderException, - InvalidKeyException { - if ((provider == null) || (provider.length() == 0)) { - throw new IllegalArgumentException( - Messages.getString("crypto.15")); //$NON-NLS-1$ - } - try { - Cipher cipher = Cipher.getInstance(sealAlg, provider); - if ((paramsAlg != null) && (paramsAlg.length() != 0)) { - AlgorithmParameters params = - AlgorithmParameters.getInstance(paramsAlg); - params.init(encodedParams); - cipher.init(Cipher.DECRYPT_MODE, key, params); - } else { - cipher.init(Cipher.DECRYPT_MODE, key); - } - byte[] serialized = cipher.doFinal(encryptedContent); - ObjectInputStream ois = - new ObjectInputStream( - new ByteArrayInputStream(serialized)); - return ois.readObject(); - } catch (NoSuchPaddingException e) { - // should not be thrown because cipher text was made - // with existing padding - throw new NoSuchAlgorithmException(e.toString()); - } catch (InvalidAlgorithmParameterException e) { - // should not be thrown because cipher text was made - // with correct algorithm parameters - throw new NoSuchAlgorithmException(e.toString()); - } catch (IllegalBlockSizeException e) { - // should not be thrown because the cipher text - // was correctly made - throw new NoSuchAlgorithmException(e.toString()); - } catch (BadPaddingException e) { - // should not be thrown because the cipher text - // was correctly made - throw new NoSuchAlgorithmException(e.toString()); - } catch (IllegalStateException e) { - // should never be thrown because cipher is initialized - throw new NoSuchAlgorithmException(e.toString()); - } - } -} - diff --git a/libcore/crypto/src/main/java/javax/crypto/SecretKey.java b/libcore/crypto/src/main/java/javax/crypto/SecretKey.java deleted file mode 100644 index ac6107443..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/SecretKey.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.security.Key; - -/** - * A cryptographic secret (symmetric) key. - *

- * This interface is a marker interface to group secret keys and to - * provide type safety for. - *

- * Implementations of this interface have to overwrite the - * {@link Object#equals(Object) equals} and {@link Object#hashCode() hashCode} - * from {@link java.lang.Object} so comparison is done using the actual key data - * and not the object reference. - */ -public interface SecretKey extends Key { - - /** - * The serialization version identifier. - * - * @serial - */ - public static final long serialVersionUID = -4795878709595146952L; -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/SecretKeyFactory.java b/libcore/crypto/src/main/java/javax/crypto/SecretKeyFactory.java deleted file mode 100644 index 57bca3ec7..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/SecretKeyFactory.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.Provider; -import java.security.Security; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.KeySpec; - -import org.apache.harmony.crypto.internal.nls.Messages; -import org.apache.harmony.security.fortress.Engine; - - -/** - * The public API for {@code SecretKeyFactory} implementations. - *

- * Secret key factories provide the following functionality: - *

    - *
  • convert {@link SecretKey} objects to and from {@link KeySpec} objects
  • - *
  • translate {@link SecretKey} objects from one provider implementation to - * another
  • - *
- * Which key specifications are supported by the {@link #generateSecret} and - * {@link #getKeySpec} is provider dependent. - */ -public class SecretKeyFactory { - - // Used to access common engine functionality - private static final Engine engine = new Engine("SecretKeyFactory"); //$NON-NLS-1$ - - // Store used provider - private final Provider provider; - - // Store used spi implementation - private final SecretKeyFactorySpi spiImpl; - - // Store used algorithm name - private final String algorithm; - - /** - * Creates a new {@code SecretKeyFactory} - * - * @param keyFacSpi - * the SPI delegate. - * @param provider - * the provider providing this key factory. - * @param algorithm - * the algorithm name for the secret key. - */ - protected SecretKeyFactory(SecretKeyFactorySpi keyFacSpi, - Provider provider, String algorithm) { - this.provider = provider; - this.algorithm = algorithm; - this.spiImpl = keyFacSpi; - } - - /** - * Returns the name of the secret key algorithm. - * - * @return the name of the secret key algorithm. - */ - public final String getAlgorithm() { - return algorithm; - } - - /** - * Returns the provider for this {@code SecretKeyFactory} instance. - * - * @return the provider for this {@code SecretKeyFactory} instance. - */ - public final Provider getProvider() { - return provider; - } - - /** - * Creates a new {@code SecretKeyFactory} instance for the specified key - * algorithm. - * - * @param algorithm - * the name of the key algorithm. - * @return a secret key factory for the specified key algorithm. - * @throws NoSuchAlgorithmException - * if no installed provider can provide the requested algorithm. - * @throws NullPointerException - * if the specified algorithm is {@code null}. - */ - public static final SecretKeyFactory getInstance(String algorithm) - throws NoSuchAlgorithmException { - if (algorithm == null) { - throw new NullPointerException(Messages.getString("crypto.02")); //$NON-NLS-1$ - } - synchronized (engine) { - engine.getInstance(algorithm, null); - return new SecretKeyFactory((SecretKeyFactorySpi) engine.spi, - engine.provider, algorithm); - } - } - - /** - * Creates a new {@code SecretKeyFactory} instance for the specified key - * algorithm from the specified {@code provider}. - * - * @param algorithm - * the name of the key algorithm. - * @param provider - * the name of the provider that provides the requested - * algorithm. - * @return a secret key factory for the specified key algorithm from the - * specified provider. - * @throws NoSuchAlgorithmException - * if the specified provider cannot provide the requested - * algorithm. - * @throws NoSuchProviderException - * if the specified provider does not exist. - * @throws IllegalArgumentException - * if the specified provider name is {@code null} or empty. - */ - public static final SecretKeyFactory getInstance(String algorithm, - String provider) throws NoSuchAlgorithmException, - NoSuchProviderException { - if ((provider == null) || (provider.length() == 0)) { - throw new IllegalArgumentException(Messages.getString("crypto.03")); //$NON-NLS-1$ - } - Provider impProvider = Security.getProvider(provider); - if (impProvider == null) { - throw new NoSuchProviderException(provider); - } - return getInstance(algorithm, impProvider); - } - - /** - * Creates a new {@code SecretKeyFactory} instance for the specified key - * algorithm from the specified provider. - * - * @param algorithm - * the name of the key algorithm. - * @param provider - * the provider that provides the requested algorithm. - * @return a secret key factory for the specified key algorithm from the - * specified provider. - * @throws NoSuchAlgorithmException - * if the specified provider cannot provider the requested - * algorithm. - * @throws IllegalArgumentException - * if the specified provider is {@code null}. - * @throws NullPointerException - * is the specified algorithm name is {@code null}. - */ - public static final SecretKeyFactory getInstance(String algorithm, - Provider provider) throws NoSuchAlgorithmException { - if (provider == null) { - throw new IllegalArgumentException(Messages.getString("crypto.04")); //$NON-NLS-1$ - } - if (algorithm == null) { - throw new NullPointerException(Messages.getString("crypto.02")); //$NON-NLS-1$ - } - synchronized (engine) { - engine.getInstance(algorithm, provider, null); - return new SecretKeyFactory((SecretKeyFactorySpi) engine.spi, provider, - algorithm); - } - } - - /** - * Generate a secret key from the specified key specification. - * - * @param keySpec - * the key specification. - * @return a secret key. - * @throws InvalidKeySpecException - * if the specified key specification cannot be used to generate - * a secret key. - */ - public final SecretKey generateSecret(KeySpec keySpec) - throws InvalidKeySpecException { - return spiImpl.engineGenerateSecret(keySpec); - } - - /** - * Returns the key specification of the specified secret key. - * - * @param key - * the secret key to get the specification from. - * @param keySpec - * the target key specification class. - * @return an instance of the specified key specification class. - * @throws InvalidKeySpecException - * if the specified secret key cannot be transformed into the - * requested key specification. - */ - @SuppressWarnings("unchecked") - public final KeySpec getKeySpec(SecretKey key, Class keySpec) - throws InvalidKeySpecException { - return spiImpl.engineGetKeySpec(key, keySpec); - } - - /** - * Translates the specified secret key into an instance of the corresponding - * key from the provider of this key factory. - * - * @param key - * the secret key to translate. - * @return the corresponding translated key. - * @throws InvalidKeyException - * if the specified key cannot be translated using this key - * factory. - */ - public final SecretKey translateKey(SecretKey key) - throws InvalidKeyException { - return spiImpl.engineTranslateKey(key); - - } -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/SecretKeyFactorySpi.java b/libcore/crypto/src/main/java/javax/crypto/SecretKeyFactorySpi.java deleted file mode 100644 index 5d7764ed8..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/SecretKeyFactorySpi.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto; - -import java.security.InvalidKeyException; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.KeySpec; - -/** - * The Service Provider Interface (SPI) definition for the {@code - * SecretKeyFactory} class. - */ -public abstract class SecretKeyFactorySpi { - - /** - * Creates a new {@code SecretKeyFactorySpi} instance. - */ - public SecretKeyFactorySpi() { - } - - /** - * Generate a secret key from the specified key specification. - * - * @param keySpec - * the key specification. - * @return a secret key. - * @throws InvalidKeySpecException - * if the specified key specification cannot be used to generate - * a secret key. - */ - protected abstract SecretKey engineGenerateSecret(KeySpec keySpec) - throws InvalidKeySpecException; - - /** - * Returns the key specification of the specified secret key. - * - * @param key - * the secret key to get the specification from. - * @param keySpec - * the target key specification class. - * @return an instance of the specified key specification class. - * @throws InvalidKeySpecException - * if the specified secret key cannot be transformed into the - * requested key specification. - */ - @SuppressWarnings("unchecked") - protected abstract KeySpec engineGetKeySpec(SecretKey key, Class keySpec) - throws InvalidKeySpecException; - - /** - * Translates the specified secret key into an instance of the corresponding - * key from the provider of this key factory. - * - * @param key - * the secret key to translate. - * @return the corresponding translated key. - * @throws InvalidKeyException - * if the specified key cannot be translated using this key - * factory. - */ - protected abstract SecretKey engineTranslateKey(SecretKey key) - throws InvalidKeyException; -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/ShortBufferException.java b/libcore/crypto/src/main/java/javax/crypto/ShortBufferException.java deleted file mode 100644 index 56480a852..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/ShortBufferException.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package javax.crypto; - -import java.security.GeneralSecurityException; - -/** - * The exception that is thrown when the result of an operation is attempted to - * store in a user provided buffer that is too small. - */ -public class ShortBufferException extends GeneralSecurityException { - - /** - * @serial - */ - private static final long serialVersionUID = 8427718640832943747L; - - /** - * Creates a new instance of {@code ShortBufferException} with the - * specified message - * - * @param msg - * the exception message. - */ - public ShortBufferException(String msg) { - super(msg); - } - - /** - * Creates a new instance of {@code ShortBufferException}. - */ - public ShortBufferException() { - } -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/interfaces/DHKey.java b/libcore/crypto/src/main/java/javax/crypto/interfaces/DHKey.java deleted file mode 100644 index 6ef17d406..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/interfaces/DHKey.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto.interfaces; - -import javax.crypto.spec.DHParameterSpec; - -/** - * The interface for a Diffie-Hellman key. - */ -public interface DHKey { - - /** - * Returns the parameters for this key. - * - * @return the parameters for this key. - */ - public DHParameterSpec getParams(); -} - diff --git a/libcore/crypto/src/main/java/javax/crypto/interfaces/DHPrivateKey.java b/libcore/crypto/src/main/java/javax/crypto/interfaces/DHPrivateKey.java deleted file mode 100644 index f63e0cb5e..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/interfaces/DHPrivateKey.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto.interfaces; - -import java.math.BigInteger; -import java.security.PrivateKey; - -/** - * The interface for a private key in the Diffie-Hellman key exchange protocol. - */ -public interface DHPrivateKey extends DHKey, PrivateKey { - - /** - * The serialization version identifier. - */ - public static final long serialVersionUID = 2211791113380396553L; - - /** - * Returns this key's private value x. - * @return this key's private value x. - */ - public BigInteger getX(); - -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/interfaces/DHPublicKey.java b/libcore/crypto/src/main/java/javax/crypto/interfaces/DHPublicKey.java deleted file mode 100644 index 92e8f10f1..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/interfaces/DHPublicKey.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto.interfaces; - -import java.math.BigInteger; -import java.security.PublicKey; - -/** - * The interface for a public key in the Diffie-Hellman key exchange protocol. - */ -public interface DHPublicKey extends DHKey, PublicKey { - - /** - * The serial version identifier. - */ - public static final long serialVersionUID = -6628103563352519193L; - - /** - * Returns this key's public value Y. - * @return this key's public value Y. - */ - public BigInteger getY(); -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/interfaces/PBEKey.java b/libcore/crypto/src/main/java/javax/crypto/interfaces/PBEKey.java deleted file mode 100644 index c718715e9..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/interfaces/PBEKey.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto.interfaces; - -import javax.crypto.SecretKey; - -/** - * The interface to a password-based-encryption key. - */ -public interface PBEKey extends SecretKey { - - /** - * The serial version identifier. - */ - public static final long serialVersionUID = -1430015993304333921L; - - /** - * Returns the iteration count, 0 if not specified. - * - * @return the iteration count, 0 if not specified. - */ - public int getIterationCount(); - - /** - * Returns a copy of the salt data or null if not specified. - * - * @return a copy of the salt data or null if not specified. - */ - public byte[] getSalt(); - - /** - * Returns a copy to the password. - * - * @return a copy to the password. - */ - public char[] getPassword(); - -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/interfaces/package.html b/libcore/crypto/src/main/java/javax/crypto/interfaces/package.html deleted file mode 100644 index 04a7c0bfb..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/interfaces/package.html +++ /dev/null @@ -1,12 +0,0 @@ - - -

- This package provides the interfaces needed to implement the - Diffie-Hellman (DH) key agreement's algorithm as specified by PKCS#3. - - The parameters for the DH algorithm must be accessed without unduly - restriction as for example hardware repository for the parameters material. -

- @since Android 1.0 - - \ No newline at end of file diff --git a/libcore/crypto/src/main/java/javax/crypto/package.html b/libcore/crypto/src/main/java/javax/crypto/package.html deleted file mode 100644 index 3f3bb473a..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/package.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - -

-This package provides the classes and interfaces for cryptographic applications implementing algorithms for encryption, decryption, or -key agreement. -

-Stream ciphers are supported as well as asymmetric, symmetric and block ciphers. Cipher implementations from different providers are easily integratable thanks -to the SPI (Security Provider Interface) abstract classes. With class {@link javax.crypto.SealedObject} a programmer can secure an object by -encrypting it with a cipher. -

-Authentication may be based on MAC (Message Authentication Code) such as HMAC (Hash MAC, i.e. with a SHA-1 hash function). -

-@since Android 1.0 - - diff --git a/libcore/crypto/src/main/java/javax/crypto/spec/DESKeySpec.java b/libcore/crypto/src/main/java/javax/crypto/spec/DESKeySpec.java deleted file mode 100644 index 372a68d00..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/spec/DESKeySpec.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto.spec; - -import java.security.InvalidKeyException; -import java.security.spec.KeySpec; - -import org.apache.harmony.crypto.internal.nls.Messages; - -/** - * The key specification for a DES key. - */ -public class DESKeySpec implements KeySpec { - - /** - * The length of a DES key in bytes. - */ - public static final int DES_KEY_LEN = 8; - - private final byte[] key; - - // DES weak and semi-weak keys - // Got from: - // FIP PUB 74 - // FEDERAL INFORMATION PROCESSING STANDARDS PUBLICATION 1981 - // GUIDELINES FOR IMPLEMENTING AND USING THE NBS DATA ENCRYPTION STANDARD - // http://www.dice.ucl.ac.be/crypto/standards/fips/fip74/fip74-1.pdf - private static final byte[][] SEMIWEAKS = { - {(byte) 0xE0, (byte) 0x01, (byte) 0xE0, (byte) 0x01, - (byte) 0xF1, (byte) 0x01, (byte) 0xF1, (byte) 0x01}, - - {(byte) 0x01, (byte) 0xE0, (byte) 0x01, (byte) 0xE0, - (byte) 0x01, (byte) 0xF1, (byte) 0x01, (byte) 0xF1}, - - {(byte) 0xFE, (byte) 0x1F, (byte) 0xFE, (byte) 0x1F, - (byte) 0xFE, (byte) 0x0E, (byte) 0xFE, (byte) 0x0E}, - - {(byte) 0x1F, (byte) 0xFE, (byte) 0x1F, (byte) 0xFE, - (byte) 0x0E, (byte) 0xFE, (byte) 0x0E, (byte) 0xFE}, - - {(byte) 0xE0, (byte) 0x1F, (byte) 0xE0, (byte) 0x1F, - (byte) 0xF1, (byte) 0x0E, (byte) 0xF1, (byte) 0x0E}, - - {(byte) 0x1F, (byte) 0xE0, (byte) 0x1F, (byte) 0xE0, - (byte) 0x0E, (byte) 0xF1, (byte) 0x0E, (byte) 0xF1}, - - {(byte) 0x01, (byte) 0xFE, (byte) 0x01, (byte) 0xFE, - (byte) 0x01, (byte) 0xFE, (byte) 0x01, (byte) 0xFE}, - - {(byte) 0xFE, (byte) 0x01, (byte) 0xFE, (byte) 0x01, - (byte) 0xFE, (byte) 0x01, (byte) 0xFE, (byte) 0x01}, - - {(byte) 0x01, (byte) 0x1F, (byte) 0x01, (byte) 0x1F, - (byte) 0x01, (byte) 0x0E, (byte) 0x01, (byte) 0x0E}, - - {(byte) 0x1F, (byte) 0x01, (byte) 0x1F, (byte) 0x01, - (byte) 0x0E, (byte) 0x01, (byte) 0x0E, (byte) 0x01}, - - {(byte) 0xE0, (byte) 0xFE, (byte) 0xE0, (byte) 0xFE, - (byte) 0xF1, (byte) 0xFE, (byte) 0xF1, (byte) 0xFE}, - - {(byte) 0xFE, (byte) 0xE0, (byte) 0xFE, (byte) 0xE0, - (byte) 0xFE, (byte) 0xF1, (byte) 0xFE, (byte) 0xF1}, - - {(byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, - (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01}, - - {(byte) 0xFE, (byte) 0xFE, (byte) 0xFE, (byte) 0xFE, - (byte) 0xFE, (byte) 0xFE, (byte) 0xFE, (byte) 0xFE}, - - {(byte) 0xE0, (byte) 0xE0, (byte) 0xE0, (byte) 0xE0, - (byte) 0xF1, (byte) 0xF1, (byte) 0xF1, (byte) 0xF1}, - - {(byte) 0x1F, (byte) 0x1F, (byte) 0x1F, (byte) 0x1F, - (byte) 0x0E, (byte) 0x0E, (byte) 0x0E, (byte) 0x0E}, - - }; - - /** - * Creates a new DESKeySpec from the first 8 bytes of the - * specified key data. - * - * @param key - * the key data. - * @throws InvalidKeyException - * if the length of the specified key data is less than 8. - */ - public DESKeySpec(byte[] key) throws InvalidKeyException { - this(key, 0); - } - - /** - * Creates a new DESKeySpec from the first 8 bytes of the - * specified key data starting at offset. - * - * @param key - * the key data - * @param offset - * the offset to start at. - * @throws InvalidKeyException - * if the length of the specified key data starting at offset is - * less than 8. - */ - public DESKeySpec(byte[] key, int offset) - throws InvalidKeyException { - if (key == null) { - throw new NullPointerException(Messages.getString("crypto.2F")); //$NON-NLS-1$ - } - if (key.length - offset < DES_KEY_LEN) { - throw new InvalidKeyException( - Messages.getString("crypto.40")); //$NON-NLS-1$ - } - this.key = new byte[DES_KEY_LEN]; - System.arraycopy(key, offset, this.key, 0, DES_KEY_LEN); - } - - /** - * Returns a copy of the key. - * - * @return a copy of the key. - */ - public byte[] getKey() { - byte[] result = new byte[DES_KEY_LEN]; - System.arraycopy(this.key, 0, result, 0, DES_KEY_LEN); - return result; - } - - /** - * Returns whether the specified key data starting at offset is - * parity-adjusted. - * - * @param key - * the key data. - * @param offset - * the offset to start checking at. - * @return {@code true} if the specified key data is parity-adjusted, - * {@code false} otherwise. - * @throws InvalidKeyException - * if the length of the key data starting at offset is less than - * 8, or the key is null. - */ - public static boolean isParityAdjusted(byte[] key, int offset) - throws InvalidKeyException { - if (key == null) { - throw new InvalidKeyException(Messages.getString("crypto.2F")); //$NON-NLS-1$ - } - if (key.length - offset < DES_KEY_LEN) { - throw new InvalidKeyException( - Messages.getString("crypto.40")); //$NON-NLS-1$ - } - - int byteKey = 0; - - for (int i = offset; i < DES_KEY_LEN; i++) { - byteKey = key[i]; - - byteKey ^= byteKey >> 1; - byteKey ^= byteKey >> 2; - byteKey ^= byteKey >> 4; - - if ((byteKey & 1) == 0) { - return false; - } - } - return true; - } - - /** - * Returns whether the specified key data starting at offset is - * weak or semi-weak. - * - * @param key - * the key data. - * @param offset - * the offset to start checking at. - * @return {@code true} if the specified key data is weak or semi-weak. - * @throws InvalidKeyException - * if the length of the key data starting at offset is less than - * 8, or it is null. - */ - public static boolean isWeak(byte[] key, int offset) - throws InvalidKeyException { - if (key == null) { - throw new InvalidKeyException(Messages.getString("crypto.2F")); //$NON-NLS-1$ - } - if (key.length - offset < DES_KEY_LEN) { - throw new InvalidKeyException( - Messages.getString("crypto.40")); //$NON-NLS-1$ - } - I: - for (int i=0; iDESedeKeySpec
instance from the first 24 ( - * {@link #DES_EDE_KEY_LEN}) bytes of the specified key data. - * - * @param key - * the key data. - * @throws InvalidKeyException - * if the length of the key data is less than 24. - * @throws NullPointerException - * if the key data is null. - */ - public DESedeKeySpec(byte[] key) - throws InvalidKeyException { - if (key == null) { - throw new NullPointerException(Messages.getString("crypto.2F")); //$NON-NLS-1$ - } - if (key.length < DES_EDE_KEY_LEN) { - throw new InvalidKeyException( - Messages.getString("crypto.30")); //$NON-NLS-1$ - } - this.key = new byte[DES_EDE_KEY_LEN]; - System.arraycopy(key, 0, this.key, 0, DES_EDE_KEY_LEN); - } - - /** - * Creates a new DESedeKeySpec instance from the first 24 ( - * {@link #DES_EDE_KEY_LEN} ) bytes of the specified key data starting at - * offset. - * - * @param key - * the key data - * @param offset - * the offset to start at. - * @throws InvalidKeyException - * if the length of the key data starting at offset is less than - * 24. - * @throws NullPointerException - * if the key data is null. - */ - public DESedeKeySpec(byte[] key, int offset) - throws InvalidKeyException { - if (key == null) { - throw new NullPointerException(Messages.getString("crypto.2F")); //$NON-NLS-1$ - } - if (key.length - offset < DES_EDE_KEY_LEN) { - throw new InvalidKeyException( - Messages.getString("crypto.30")); //$NON-NLS-1$ - } - this.key = new byte[DES_EDE_KEY_LEN]; - System.arraycopy(key, offset, this.key, 0, DES_EDE_KEY_LEN); - } - - /** - * Returns a copy of the key. - * - * @return a copy of the key. - */ - public byte[] getKey() { - byte[] result = new byte [DES_EDE_KEY_LEN]; - System.arraycopy(this.key, 0, result, 0, DES_EDE_KEY_LEN); - return result; - } - - /** - * Returns whether the specified key data starting at offset is - * parity-adjusted. - * - * @param key - * the key data. - * @param offset - * the offset to start checking at. - * @return {@code true} if the specified key data is parity-adjusted, - * {@code false} otherwise. - * @throws InvalidKeyException - * if the length of the key data starting at offset is less than - * 24. - */ - public static boolean isParityAdjusted(byte[] key, int offset) - throws InvalidKeyException { - if (key.length - offset < DES_EDE_KEY_LEN) { - throw new InvalidKeyException( - Messages.getString("crypto.30")); //$NON-NLS-1$ - } - for (int i=offset; i> 1) + ((b & 4) >> 2) - + ((b & 8) >> 3) + ((b & 16) >> 4) + ((b & 32) >> 5) - + ((b & 64) >> 6)) & 1) == ((b & 128) >> 7)) { - return false; - } - } - return true; - } -} - diff --git a/libcore/crypto/src/main/java/javax/crypto/spec/DHGenParameterSpec.java b/libcore/crypto/src/main/java/javax/crypto/spec/DHGenParameterSpec.java deleted file mode 100644 index f6ddc035c..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/spec/DHGenParameterSpec.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto.spec; - -import java.security.spec.AlgorithmParameterSpec; - -/** - * The algorithm parameter specification for generating Diffie-Hellman - * parameters used in Diffie-Hellman key agreement. - */ -public class DHGenParameterSpec implements AlgorithmParameterSpec { - - private final int primeSize; - private final int exponentSize; - - /** - * Creates a new DHGenParameterSpec instance with the specified - * parameters. - * - * @param primeSize - * the size of the prime modulus in bits. - * @param exponentSize - * the size of the random exponent in bits. - */ - public DHGenParameterSpec(int primeSize, int exponentSize) { - this.primeSize = primeSize; - this.exponentSize = exponentSize; - } - - /** - * Returns the size of the prime modulus in bits. - * - * @return the size of the prime modulus in bits. - */ - public int getPrimeSize() { - return primeSize; - } - - /** - * Returns the size of the random exponent in bits. - * - * @return the size of the random exponent in bits. - */ - public int getExponentSize() { - return exponentSize; - } -} - diff --git a/libcore/crypto/src/main/java/javax/crypto/spec/DHParameterSpec.java b/libcore/crypto/src/main/java/javax/crypto/spec/DHParameterSpec.java deleted file mode 100644 index 6030b404b..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/spec/DHParameterSpec.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto.spec; - -import java.math.BigInteger; -import java.security.spec.AlgorithmParameterSpec; - -/** - * The algorithm parameter specification for the Diffie-Hellman algorithm. - */ -public class DHParameterSpec implements AlgorithmParameterSpec { - - private final BigInteger p; - private final BigInteger g; - private final int l; - - /** - * Creates a new DHParameterSpec instance with the specified - * prime modulus and base generator. - * - * @param p - * the prime modulus. - * @param g - * the base generator. - */ - public DHParameterSpec(BigInteger p, BigInteger g) { - this.p = p; - this.g = g; - this.l = 0; - } - - /** - * Creates a new DHParameterSpec instance with the specified - * prime modulus, base generator and size (in bits) of the - * random exponent. - * - * @param p - * the prime modulus. - * @param g - * the base generator. - * @param l - * the size of the random exponent (in bits). - */ - public DHParameterSpec(BigInteger p, BigInteger g, int l) { - this.p = p; - this.g = g; - this.l = l; - } - - /** - * Returns the prime modulus of this parameter specification. - * - * @return the prime modulus. - */ - public BigInteger getP() { - return p; - } - - /** - * Returns the base generator of this parameter specification. - * - * @return the base generator. - */ - public BigInteger getG() { - return g; - } - - /** - * Returns the size (in bits) of the random exponent. - * - * @return the size (in bits) of the random exponent. - */ - public int getL() { - return l; - } -} - diff --git a/libcore/crypto/src/main/java/javax/crypto/spec/DHPrivateKeySpec.java b/libcore/crypto/src/main/java/javax/crypto/spec/DHPrivateKeySpec.java deleted file mode 100644 index 925a00378..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/spec/DHPrivateKeySpec.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto.spec; - -import java.math.BigInteger; -import java.security.spec.KeySpec; - -/** - * The key specification for a Diffie-Hellman private key. - */ -public class DHPrivateKeySpec implements KeySpec { - - private final BigInteger x; - private final BigInteger p; - private final BigInteger g; - - /** - * Creates a new DHPrivateKeySpec with the specified private - * value x. prime modulus p and base - * generator g. - * - * @param x - * the private value. - * @param p - * the prime modulus. - * @param g - * the base generator. - */ - public DHPrivateKeySpec(BigInteger x, BigInteger p, BigInteger g) { - this.x = x; - this.p = p; - this.g = g; - } - - /** - * Returns the private value x. - * - * @return the private value x. - */ - public BigInteger getX() { - return x; - } - - /** - * Returns the prime modulus p. - * - * @return the prime modulus p. - */ - public BigInteger getP() { - return p; - } - - /** - * Returns the base generator g. - * - * @return the base generator g. - */ - public BigInteger getG() { - return g; - } -} - diff --git a/libcore/crypto/src/main/java/javax/crypto/spec/DHPublicKeySpec.java b/libcore/crypto/src/main/java/javax/crypto/spec/DHPublicKeySpec.java deleted file mode 100644 index a5d4461a9..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/spec/DHPublicKeySpec.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto.spec; - -import java.math.BigInteger; -import java.security.spec.KeySpec; - -/** - * The key specification for a Diffie-Hellman public key. - */ -public class DHPublicKeySpec implements KeySpec { - - private final BigInteger y; - private final BigInteger p; - private final BigInteger g; - - /** - * Creates a new DHPublicKeySpec instance with the specified - * public value y, the prime modulus - * p and the base generator g. - * - * @param y - * the public value. - * @param p - * the prime modulus. - * @param g - * the base generator. - */ - public DHPublicKeySpec(BigInteger y, BigInteger p, BigInteger g) { - this.y = y; - this.p = p; - this.g = g; - } - - /** - * Returns the public value y. - * - * @return the public value y. - */ - public BigInteger getY() { - return y; - } - - /** - * Returns the prime modulus p. - * - * @return the prime modulus p. - */ - public BigInteger getP() { - return p; - } - - /** - * Returns the base generator g; - * - * @return the base generator g; - */ - public BigInteger getG() { - return g; - } -} - diff --git a/libcore/crypto/src/main/java/javax/crypto/spec/IvParameterSpec.java b/libcore/crypto/src/main/java/javax/crypto/spec/IvParameterSpec.java deleted file mode 100644 index ce7f9d3c4..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/spec/IvParameterSpec.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** -* @author Alexander Y. Kleymenov -* @version $Revision$ -*/ - -package javax.crypto.spec; - -import java.security.spec.AlgorithmParameterSpec; - -import org.apache.harmony.crypto.internal.nls.Messages; - -/** - * The algorithm parameter specification for an initialization vector. - */ -public class IvParameterSpec implements AlgorithmParameterSpec { - - private final byte[] iv; - - /** - * Creates a new IvParameterSpec instance with the bytes from - * the specified buffer iv used as initialization vector. - * - * @param iv - * the buffer used as initialization vector. - * @throws NullPointerException - * if the specified buffer is null. - */ - public IvParameterSpec(byte[] iv) { - if (iv == null) { - throw new NullPointerException(Messages.getString("crypto.38")); //$NON-NLS-1$ - } - this.iv = new byte[iv.length]; - System.arraycopy(iv, 0, this.iv, 0, iv.length); - } - - /** - * Creates a new IvParameterSpec instance with len - * bytes from the specified buffer iv starting at - * offset. - * - * @param iv - * the buffer used as initialization vector. - * @param offset - * the offset to start in the buffer. - * @param len - * the length of the data. - * @throws IllegalArgumentException - * if the specified buffer is null or offset and - * len do not specify a valid chunk in the - * specified buffer. - * @throws ArrayIndexOutOfBoundsException - * if offset or len are negative. - */ - public IvParameterSpec(byte[] iv, int offset, int len) { - if ((iv == null) || (iv.length - offset < len)) { - throw new IllegalArgumentException( - Messages.getString("crypto.39")); //$NON-NLS-1$ - } - if (offset < 0 || len < 0) { - throw new ArrayIndexOutOfBoundsException(Messages.getString("crypto.3A")); //$NON-NLS-1$ - } - this.iv = new byte[len]; - System.arraycopy(iv, offset, this.iv, 0, len); - } - - /** - * Returns a copy of the initialization vector data. - * - * @return a copy of the initialization vector data. - */ - public byte[] getIV() { - byte[] res = new byte[iv.length]; - System.arraycopy(iv, 0, res, 0, iv.length); - return res; - } -} - diff --git a/libcore/crypto/src/main/java/javax/crypto/spec/OAEPParameterSpec.java b/libcore/crypto/src/main/java/javax/crypto/spec/OAEPParameterSpec.java deleted file mode 100644 index 29b572d8d..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/spec/OAEPParameterSpec.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto.spec; - -import java.security.spec.MGF1ParameterSpec; -import java.security.spec.AlgorithmParameterSpec; -import javax.crypto.spec.PSource; - -/** - * The algorithm parameter specification for the OAEP Padding algorithm. - *

- * This padding algorithm is defined in the PKCS #1 standard. - */ -public class OAEPParameterSpec implements AlgorithmParameterSpec { - - private final String mdName; - private final String mgfName; - private final AlgorithmParameterSpec mgfSpec; - private final PSource pSrc; - - /** - * The algorithm parameter instance with default values. - *

- * It uses the following parameters: - *

  • message digest : "SHA-1"
  • - *
  • mask generation function (mgf) : "MGF1"
  • - *
  • parameters for the mgf : "SHA-1" {@link MGF1ParameterSpec#SHA1}
  • - *
  • the source of the label L: {@link PSource.PSpecified#DEFAULT}
  • - *
- */ - public static final OAEPParameterSpec DEFAULT = new OAEPParameterSpec(); - - private OAEPParameterSpec() { - this.mdName = "SHA-1"; //$NON-NLS-1$ - this.mgfName = "MGF1"; //$NON-NLS-1$ - this.mgfSpec = MGF1ParameterSpec.SHA1; - this.pSrc = PSource.PSpecified.DEFAULT; - } - - /** - * Creates a new OAEPParameterSpec instance with the specified - * message digest algorithm name, mask generation function - * (mgf) algorithm name, parameters for the mgf - * algorithm and the source of the label L. - * - * @param mdName - * the message digest algorithm name. - * @param mgfName - * the mask generation function algorithm name. - * @param mgfSpec - * the algorithm parameter specification for the mask generation - * function algorithm. - * @param pSrc - * the source of the label L. - * @throws NullPointerException - * if one of mdName, mgfName or - * pSrc is null. - */ - public OAEPParameterSpec(String mdName, String mgfName, - AlgorithmParameterSpec mgfSpec, PSource pSrc) { - if ((mdName == null) || (mgfName == null) || (pSrc == null)) { - throw new NullPointerException(); - } - this.mdName = mdName; - this.mgfName = mgfName; - this.mgfSpec = mgfSpec; - this.pSrc = pSrc; - } - - /** - * Returns the algorithm name of the message digest. - * - * @return the algorithm name of the message digest. - */ - public String getDigestAlgorithm() { - return mdName; - } - - /** - * Returns the algorithm name of the mask generation function. - * - * @return the algorithm name of the mask generation function. - */ - public String getMGFAlgorithm() { - return mgfName; - } - - /** - * Returns the algorithm parameter specification for the mask generation - * function algorithm. - * - * @return the algorithm parameter specification for the mask generation - * function algorithm. - */ - public AlgorithmParameterSpec getMGFParameters() { - return mgfSpec; - } - - /** - * Returns the source of the label L. - * - * @return the source of the label L. - */ - public PSource getPSource() { - return pSrc; - } -} - diff --git a/libcore/crypto/src/main/java/javax/crypto/spec/PBEKeySpec.java b/libcore/crypto/src/main/java/javax/crypto/spec/PBEKeySpec.java deleted file mode 100644 index d79fd3c63..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/spec/PBEKeySpec.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto.spec; - -import java.security.spec.KeySpec; -import java.util.Arrays; - -import org.apache.harmony.crypto.internal.nls.Messages; - -/** - * The key specification for a password based encryption key. - *

- * Password based encryption is described in PKCS #5. - */ -public class PBEKeySpec implements KeySpec { - - private char[] password; - private final byte[] salt; - private final int iterationCount; - private final int keyLength; - - /** - * Creates a new PBEKeySpec with the specified password. - * - * @param password - * the password. - */ - public PBEKeySpec(char[] password) { - if (password == null) { - this.password = new char[0]; - } else { - this.password = new char[password.length]; - System.arraycopy(password, 0, this.password, 0, password.length); - } - salt = null; - iterationCount = 0; - keyLength = 0; - } - - /** - * Creates a new PBEKeySpec with the specified password, salt, - * iteration count and the desired length of the derived key. - * - * @param password - * the password. - * @param salt - * the salt. - * @param iterationCount - * the iteration count. - * @param keyLength - * the desired key length of the derived key, - * @throws NullPointerException - * if the salt is null. - * @throws IllegalArgumentException - * if the salt is empty, iteration count is zero or negative or - * the key length is zero or negative. - */ - public PBEKeySpec(char[] password, byte[] salt, int iterationCount, - int keyLength) { - if (salt == null) { - throw new NullPointerException(Messages.getString("crypto.3B")); //$NON-NLS-1$ - } - if (salt.length == 0) { - throw new IllegalArgumentException(Messages.getString("crypto.3C")); //$NON-NLS-1$ - } - if (iterationCount <= 0) { - throw new IllegalArgumentException( - Messages.getString("crypto.3D")); //$NON-NLS-1$ - } - if (keyLength <= 0) { - throw new IllegalArgumentException(Messages.getString("crypto.3E")); //$NON-NLS-1$ - } - - if (password == null) { - this.password = new char[0]; - } else { - this.password = new char[password.length]; - System.arraycopy(password, 0, this.password, 0, password.length); - } - this.salt = new byte[salt.length]; - System.arraycopy(salt, 0, this.salt, 0, salt.length); - this.iterationCount = iterationCount; - this.keyLength = keyLength; - } - - /** - * Creates a new PBEKeySpec with the specified password, salt - * and iteration count. - * - * @param password - * the password. - * @param salt - * the salt. - * @param iterationCount - * the iteration count. - * @throws NullPointerException - * if salt is null. - * @throws IllegalArgumentException - * if the salt is empty or iteration count is zero or negative. - */ - public PBEKeySpec(char[] password, byte[] salt, int iterationCount) { - if (salt == null) { - throw new NullPointerException(Messages.getString("crypto.3B")); //$NON-NLS-1$ - } - if (salt.length == 0) { - throw new IllegalArgumentException(Messages.getString("crypto.3C")); //$NON-NLS-1$ - } - if (iterationCount <= 0) { - throw new IllegalArgumentException( - Messages.getString("crypto.3D")); //$NON-NLS-1$ - } - - if (password == null) { - this.password = new char[0]; - } else { - this.password = new char[password.length]; - System.arraycopy(password, 0, this.password, 0, password.length); - } - this.salt = new byte[salt.length]; - System.arraycopy(salt, 0, this.salt, 0, salt.length); - this.iterationCount = iterationCount; - this.keyLength = 0; - } - - /** - * Clears the password by overwriting it. - */ - public final void clearPassword() { - Arrays.fill(password, '?'); - password = null; - } - - /** - * Returns a copy of the password of this key specification. - * - * @return a copy of the password of this key specification. - * @throws IllegalStateException - * if the password has been cleared before. - */ - public final char[] getPassword() { - if (password == null) { - throw new IllegalStateException(Messages.getString("crypto.3F")); //$NON-NLS-1$ - } - char[] result = new char[password.length]; - System.arraycopy(password, 0, result, 0, password.length); - return result; - } - - /** - * Returns a copy of the salt of this key specification. - * - * @return a copy of the salt of this key specification or null if none is - * specified. - */ - public final byte[] getSalt() { - if (salt == null) { - return null; - } - byte[] result = new byte[salt.length]; - System.arraycopy(salt, 0, result, 0, salt.length); - return result; - } - - /** - * Returns the iteration count of this key specification. - * - * @return the iteration count of this key specification. - */ - public final int getIterationCount() { - return iterationCount; - } - - /** - * Returns the desired key length of the derived key. - * - * @return the desired key length of the derived key. - */ - public final int getKeyLength() { - return keyLength; - } -} - diff --git a/libcore/crypto/src/main/java/javax/crypto/spec/PBEParameterSpec.java b/libcore/crypto/src/main/java/javax/crypto/spec/PBEParameterSpec.java deleted file mode 100644 index cce3832ce..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/spec/PBEParameterSpec.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto.spec; - -import java.security.spec.AlgorithmParameterSpec; - -import org.apache.harmony.crypto.internal.nls.Messages; - -/** - * The algorithm parameter specification for a password based encryption - * algorithm. - *

- * Password based encryption is described in PKCS #5. - * - */ -public class PBEParameterSpec implements AlgorithmParameterSpec { - - private final byte[] salt; - private final int iterationCount; - - /** - * Creates a new PBEParameterSpec with the specified salt and - * iteration count. - * - * @param salt - * the salt. - * @param iterationCount - * the iteration count. - * @throws NullPointerException - * if salt is null. - */ - public PBEParameterSpec(byte[] salt, int iterationCount) { - if (salt == null) { - throw new NullPointerException(Messages.getString("crypto.3B")); //$NON-NLS-1$ - } - this.salt = new byte[salt.length]; - System.arraycopy(salt, 0, this.salt, 0, salt.length); - this.iterationCount = iterationCount; - } - - /** - * Returns a copy to the salt. - * - * @return a copy to the salt. - */ - public byte[] getSalt() { - byte[] result = new byte[salt.length]; - System.arraycopy(salt, 0, result, 0, salt.length); - return result; - } - - /** - * Returns the iteration count. - * - * @return the iteration count. - */ - public int getIterationCount() { - return iterationCount; - } -} - diff --git a/libcore/crypto/src/main/java/javax/crypto/spec/PSource.java b/libcore/crypto/src/main/java/javax/crypto/spec/PSource.java deleted file mode 100644 index 30fd8af49..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/spec/PSource.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto.spec; - -import org.apache.harmony.crypto.internal.nls.Messages; - -/** - * The source of the label L as specified in PKCS #1. - */ -public class PSource { - - private String pSrcName; - - private PSource() {} - - /** - * Creates a new PSource instance with the specified source - * algorithm identifier. - * - * @param pSrcName - * the source algorithm identifier. - * @throws NullPointerException - * if pSrcName is null. - */ - protected PSource(String pSrcName) { - if (pSrcName == null) { - throw new NullPointerException(Messages.getString("crypto.42")); //$NON-NLS-1$ - } - this.pSrcName = pSrcName; - } - - /** - * Returns the source algorithm identifier. - * - * @return the source algorithm identifier. - */ - public String getAlgorithm() { - return pSrcName; - } - - /** - * The explicit specification of the parameter P used in the - * source algorithm. - */ - public static final class PSpecified extends PSource { - - private final byte[] p; - - /** - * The instance of PSpecified with the default value - * byte[0] for P - */ - public static final PSpecified DEFAULT = new PSpecified(); - - private PSpecified() { - super("PSpecified"); //$NON-NLS-1$ - p = new byte[0]; - } - - /** - * Creates a new instance of PSpecified with the specified - * parameter P. - * - * @param p - * the parameter P. - * @throws NullPointerException - * if p is null. - */ - public PSpecified(byte[] p) { - super("PSpecified"); //$NON-NLS-1$ - if (p == null) { - throw new NullPointerException(Messages.getString("crypto.43")); //$NON-NLS-1$ - } - //TODO: It is unknown which name should be used! - //super(""); - this.p = new byte[p.length]; - System.arraycopy(p, 0, this.p, 0, p.length); - } - - /** - * Returns a copy of the value of the parameter P. - * - * @return a copy of the value of the parameter P - */ - public byte[] getValue() { - byte[] result = new byte[p.length]; - System.arraycopy(p, 0, result, 0, p.length); - return result; - } - } -} - diff --git a/libcore/crypto/src/main/java/javax/crypto/spec/RC2ParameterSpec.java b/libcore/crypto/src/main/java/javax/crypto/spec/RC2ParameterSpec.java deleted file mode 100644 index bc7a39cab..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/spec/RC2ParameterSpec.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto.spec; - -import java.security.spec.AlgorithmParameterSpec; -import java.util.Arrays; - -import org.apache.harmony.crypto.internal.nls.Messages; - -/** - * The algorithm parameter specification for the RC2 algorithm. - */ -public class RC2ParameterSpec implements AlgorithmParameterSpec { - - private final int effectiveKeyBits; - private final byte[] iv; - - /** - * Creates a new RC2ParameterSpec instance with the specified - * effective key length (in bits), - * - * @param effectiveKeyBits - * the effective key length (in bits). - */ - public RC2ParameterSpec(int effectiveKeyBits) { - this.effectiveKeyBits = effectiveKeyBits; - iv = null; - } - - /** - * Creates a new RC2ParameterSpec instance with the specified - * effective key length (in bits) and initialization vector. - *

- * The size of the initialization vector must be at least 8 bytes - * which are copied to protect them against modification. - * - * @param effectiveKeyBits - * the effective key length (in bits). - * @param iv - * the initialization vector. - * @throws IllegalArgumentException - * if the initialization vector is null or shorter than 8 bytes. - */ - public RC2ParameterSpec(int effectiveKeyBits, byte[] iv) { - if (iv == null) { - throw new IllegalArgumentException(Messages.getString("crypto.31")); //$NON-NLS-1$ - } - if (iv.length < 8) { - throw new IllegalArgumentException(Messages.getString("crypto.41")); //$NON-NLS-1$ - } - this.effectiveKeyBits = effectiveKeyBits; - this.iv = new byte[8]; - System.arraycopy(iv, 0, this.iv, 0, 8); - } - - /** - * Creates a new RC2ParameterSpec instance with the specified - * effective key length (in bits) and initialization vector. - *

- * The size of the initialization vector starting at - * offset must be at least 8 bytes which are copied to protect - * them against modification. - * - * @param effectiveKeyBits - * the effective key length (in bits). - * @param iv - * the initialization vector. - * @param offset - * the offset in the initialization vector to start at. - * @throws IllegalArgumentException - * if the initialization vector is null or starting at - * offset is shorter than 8 bytes. - */ - public RC2ParameterSpec(int effectiveKeyBits, byte[] iv, int offset) { - if (iv == null) { - throw new IllegalArgumentException(Messages.getString("crypto.31")); //$NON-NLS-1$ - } - if (iv.length - offset < 8) { - throw new IllegalArgumentException(Messages.getString("crypto.41")); //$NON-NLS-1$ - } - this.effectiveKeyBits = effectiveKeyBits; - this.iv = new byte[8]; - System.arraycopy(iv, offset, this.iv, 0, 8); - } - - /** - * Returns the effective key length (in bits). - * - * @return the effective key length (in bits). - */ - public int getEffectiveKeyBits() { - return effectiveKeyBits; - } - - /** - * Returns a copy of the initialization vector. - * - * @return a copy of the initialization vector, or null if none specified. - */ - public byte[] getIV() { - if (iv == null) { - return null; - } - byte[] result = new byte[iv.length]; - System.arraycopy(iv, 0, result, 0, iv.length); - return result; - } - - /** - * Compares the specified object to this RC2ParameterSpec - * instance. - * - * @param obj - * the object to compare. - * @return true if the effective key length and the initialization vector of - * both objects are equal, otherwise false. - */ - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof RC2ParameterSpec)) { - return false; - } - RC2ParameterSpec ps = (RC2ParameterSpec) obj; - return (effectiveKeyBits == ps.effectiveKeyBits) - && (Arrays.equals(iv, ps.iv)); - } - - /** - * Returns the hash code of this RC2ParameterSpec instance. - * - * @return the hash code. - */ - @Override - public int hashCode() { - int result = effectiveKeyBits; - if (iv == null) { - return result; - } - for (byte element : iv) { - result += element; - } - return result; - } -} - diff --git a/libcore/crypto/src/main/java/javax/crypto/spec/RC5ParameterSpec.java b/libcore/crypto/src/main/java/javax/crypto/spec/RC5ParameterSpec.java deleted file mode 100644 index 57010f7d5..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/spec/RC5ParameterSpec.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package javax.crypto.spec; - -import java.security.spec.AlgorithmParameterSpec; -import java.util.Arrays; - -import org.apache.harmony.crypto.internal.nls.Messages; - -/** - * The algorithm parameter specification for the RC5 algorithm. - */ -public class RC5ParameterSpec implements AlgorithmParameterSpec { - - private final int version; - private final int rounds; - private final int wordSize; - private final byte[] iv; - - /** - * Creates a new RC5ParameterSpec instance with the specified - * version, round count an word size (in bits). - * - * @param version - * the version. - * @param rounds - * the round count. - * @param wordSize - * the word size (in bits). - */ - public RC5ParameterSpec(int version, int rounds, int wordSize) { - this.version = version; - this.rounds = rounds; - this.wordSize = wordSize; - this.iv = null; - } - - /** - * Creates a new RC5ParameterSpec instance with the specified - * version, round count, word size (in bits) and an initialization - * vector. - *

- * The size of the initialization vector must be at least - * 2 * (wordSize / 8) bytes which are copied to protect them - * against modification. - * - * @param version - * the version. - * @param rounds - * the round count. - * @param wordSize - * the word size (in bits). - * @param iv - * the initialization vector. - * @throws IllegalArgumentException - * if the initialization vector is null or shorter than 2 - * * (wordSize / 8). - */ - public RC5ParameterSpec(int version, int rounds, int wordSize, byte[] iv) { - if (iv == null) { - throw new IllegalArgumentException(Messages.getString("crypto.31")); //$NON-NLS-1$ - } - if (iv.length < 2 * (wordSize / 8)) { - throw new IllegalArgumentException( - Messages.getString("crypto.32")); //$NON-NLS-1$ - } - this.version = version; - this.rounds = rounds; - this.wordSize = wordSize; - this.iv = new byte[2*(wordSize/8)]; - System.arraycopy(iv, 0, this.iv, 0, 2*(wordSize/8)); - } - - /** - * Creates a new RC5ParameterSpec instance with the specified - * version, round count, wordSize (in bits), an initialization vector - * and an offset. - *

- * The size of the initialization vector must be at least - * offset + (2 * (wordSize / 8)) bytes. The bytes starting at - * offset are copied to protect them against modification. - * - * @param version - * the version. - * @param rounds - * the round count. - * @param wordSize - * the word size (in bits). - * @param iv - * the initialization vector. - * @param offset - * the offset in the initialization vector. - * @throws IllegalArgumentException - * if the initialization vector is null of shorter than - * offset + (2 * (wordSize / 8)). - * @throws ArrayIndexOutOfBoundsException - * if offset is negative. - */ - public RC5ParameterSpec(int version, int rounds, - int wordSize, byte[] iv, int offset) { - if (iv == null) { - throw new IllegalArgumentException(Messages.getString("crypto.31")); //$NON-NLS-1$ - } - if (offset < 0) { - throw new ArrayIndexOutOfBoundsException(Messages.getString("crypto.33")); //$NON-NLS-1$ - } - if (iv.length - offset < 2 * (wordSize / 8)) { - throw new IllegalArgumentException( - Messages.getString("crypto.34")); //$NON-NLS-1$ - } - this.version = version; - this.rounds = rounds; - this.wordSize = wordSize; - this.iv = new byte[offset+2*(wordSize/8)]; - System.arraycopy(iv, offset, this.iv, 0, 2*(wordSize/8)); - } - - /** - * Returns the version. - * - * @return the version. - */ - public int getVersion() { - return version; - } - - /** - * Returns the round count. - * - * @return the round count. - */ - public int getRounds() { - return rounds; - } - - /** - * Returns the word size (in bits). - * - * @return the word size (in bits). - */ - public int getWordSize() { - return wordSize; - } - - /** - * Returns a copy of the initialization vector. - * - * @return a copy of the initialization vector, or null if none specified. - */ - public byte[] getIV() { - if (iv == null) { - return null; - } - byte[] result = new byte[iv.length]; - System.arraycopy(iv, 0, result, 0, iv.length); - return result; - } - - /** - * Compares the specified object with this RC5ParameterSpec - * instance. - * - * @param obj - * the object to compare. - * @return true if version, round count, word size and initializaion vector - * of both objects are equal, otherwise false. - */ - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof RC5ParameterSpec)) { - return false; - } - RC5ParameterSpec ps = (RC5ParameterSpec) obj; - return (version == ps.version) - && (rounds == ps.rounds) - && (wordSize == ps.wordSize) - && (Arrays.equals(iv, ps.iv)); - } - - /** - * Returns the hash code of this RC5ParameterSpec instance. - * - * @return the hash code. - */ - @Override - public int hashCode() { - int result = version + rounds + wordSize; - if (iv == null) { - return result; - } - for (byte element : iv) { - result += element & 0xFF; - } - return result; - } -} - diff --git a/libcore/crypto/src/main/java/javax/crypto/spec/SecretKeySpec.java b/libcore/crypto/src/main/java/javax/crypto/spec/SecretKeySpec.java deleted file mode 100644 index d1eba47cd..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/spec/SecretKeySpec.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Alexander Y. Kleymenov -* @version $Revision$ -*/ - -package javax.crypto.spec; - -import java.io.Serializable; -import java.security.spec.KeySpec; -import java.util.Arrays; -import javax.crypto.SecretKey; - -import org.apache.harmony.crypto.internal.nls.Messages; - -/** - * A key specification for a SecretKey and also a secret key - * implementation that is provider-independent. It can be used for raw secret - * keys that can be specified as byte[]. - */ -public class SecretKeySpec implements SecretKey, KeySpec, Serializable { - - // The 5.0 spec. doesn't declare this serialVersionUID field - // In order to be compatible it is explicitly declared here - // for details see HARMONY-233 - private static final long serialVersionUID = 6577238317307289933L; - - private final byte[] key; - private final String algorithm; - private final String format = "RAW"; //$NON-NLS-1$ - - /** - * Creates a new SecretKeySpec for the specified key data and - * algorithm name. - * - * @param key - * the key data. - * @param algorithm - * the algorithm name. - * @throws IllegalArgumentException - * if the key data or the algorithm name is null or if the key - * data is empty. - */ - public SecretKeySpec(byte[] key, String algorithm) { - if (key == null) { - throw new IllegalArgumentException(Messages.getString("crypto.05")); //$NON-NLS-1$ - } - if (key.length == 0) { - throw new IllegalArgumentException(Messages.getString("crypto.35")); //$NON-NLS-1$ - } - if (algorithm == null) { - throw new IllegalArgumentException(Messages.getString("crypto.02")); //$NON-NLS-1$ - } - - this.algorithm = algorithm; - this.key = new byte[key.length]; - System.arraycopy(key, 0, this.key, 0, key.length); - } - - /** - * Creates a new SecretKeySpec for the key data from the - * specified buffer key starting at offset with - * length len and the specified algorithm name. - * - * @param key - * the key data. - * @param offset - * the offset. - * @param len - * the size of the key data. - * @param algorithm - * the algorithm name. - * @throws IllegalArgumentException - * if the key data or the algorithm name is null, the key data - * is empty or offset and len do not - * specify a valid chunk in the buffer key. - * @throws ArrayIndexOutOfBoundsException - * if offset or len is negative. - */ - public SecretKeySpec(byte[] key, int offset, int len, String algorithm) { - if (key == null) { - throw new IllegalArgumentException(Messages.getString("crypto.05")); //$NON-NLS-1$ - } - if (key.length == 0) { - throw new IllegalArgumentException(Messages.getString("crypto.35")); //$NON-NLS-1$ - } - // BEGIN android-changed - if (len < 0 || offset < 0) { - throw new ArrayIndexOutOfBoundsException(Messages.getString("crypto.36")); //$NON-NLS-1$ - } - // END android-changed - if ((key.length - offset < len)) { - throw new IllegalArgumentException(Messages.getString("crypto.37")); //$NON-NLS-1$ - } - if (algorithm == null) { - throw new IllegalArgumentException(Messages.getString("crypto.02")); //$NON-NLS-1$ - } - this.algorithm = algorithm; - this.key = new byte[len]; - System.arraycopy(key, offset, this.key, 0, len); - } - - /** - * Returns the algorithm name. - * - * @return the algorithm name. - */ - public String getAlgorithm() { - return algorithm; - } - - /** - * Returns the name of the format used to encode the key. - * - * @return the format name "RAW". - */ - public String getFormat() { - return format; - } - - /** - * Returns the encoded form of this secret key. - * - * @return the encoded form of this secret key. - */ - public byte[] getEncoded() { - byte[] result = new byte[key.length]; - System.arraycopy(key, 0, result, 0, key.length); - return result; - } - - /** - * Returns the hash code of this SecretKeySpec object. - * - * @return the hash code. - */ - @Override - public int hashCode() { - int result = algorithm.length(); - for (byte element : key) { - result += element; - } - return result; - } - - /** - * Compares the specified object with this SecretKeySpec - * instance. - * - * @param obj - * the object to compare. - * @return true if the algorithm name and key of both object are equal, - * otherwise false. - */ - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof SecretKeySpec)) { - return false; - } - SecretKeySpec ks = (SecretKeySpec) obj; - return (algorithm.equalsIgnoreCase(ks.algorithm)) - && (Arrays.equals(key, ks.key)); - } -} - diff --git a/libcore/crypto/src/main/java/javax/crypto/spec/package.html b/libcore/crypto/src/main/java/javax/crypto/spec/package.html deleted file mode 100644 index f647f75a9..000000000 --- a/libcore/crypto/src/main/java/javax/crypto/spec/package.html +++ /dev/null @@ -1,17 +0,0 @@ - - -

- This package provides the classes and interfaces needed to specify keys - and parameter for encryption. Following standards are supported: - (1) PKCS#3 Diffie-Hellman ekey agreement's standard; - (2) FIPS-46-2 Data Encryption Standard (DES); - (3) PKCS#5 Password Based Encryption (PBE) standard. - Keys may be specified via algorithm or in a more abstract and general way - with ASN.1. - - Keys and algorithm parameters are specified for the following procedures: - (i) DH, (ii) DES, (iii) TripleDES, (iv) PBE, (v) RC2 and (vi) RC5. -

- @since Android 1.0 - - \ No newline at end of file diff --git a/libcore/crypto/src/main/java/org/apache/harmony/crypto/internal/NullCipherSpi.java b/libcore/crypto/src/main/java/org/apache/harmony/crypto/internal/NullCipherSpi.java deleted file mode 100644 index d6b2619aa..000000000 --- a/libcore/crypto/src/main/java/org/apache/harmony/crypto/internal/NullCipherSpi.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Boris V. Kuznetsov -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.internal; - -import java.nio.ByteBuffer; -import java.security.AlgorithmParameters; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.security.spec.AlgorithmParameterSpec; - -import javax.crypto.BadPaddingException; -import javax.crypto.CipherSpi; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.ShortBufferException; - -import org.apache.harmony.crypto.internal.nls.Messages; - -/** - * CipherSpi implementation for javax.crypto.NullCipher - * - */ -public class NullCipherSpi extends CipherSpi { - - @Override - public void engineSetMode(String arg0) throws NoSuchAlgorithmException { - // Do nothing - } - - @Override - public void engineSetPadding(String arg0) throws NoSuchPaddingException { - // Do nothing - } - - @Override - public int engineGetBlockSize() { - return 1; - } - - @Override - public int engineGetOutputSize(int inputLen) { - return inputLen; - } - - @Override - public byte[] engineGetIV() { - return new byte[8]; // compatible with RI - } - - @Override - public AlgorithmParameters engineGetParameters() { - return null; - } - - @Override - public void engineInit(int opmode, Key key, SecureRandom random) - throws InvalidKeyException { - // Do nothing - } - - @Override - public void engineInit(int opmode, Key key, AlgorithmParameterSpec params, - SecureRandom random) throws InvalidKeyException, - InvalidAlgorithmParameterException { - // Do nothing - } - - @Override - public void engineInit(int opmode, Key key, AlgorithmParameters params, - SecureRandom random) throws InvalidKeyException, - InvalidAlgorithmParameterException { - // Do nothing - } - - @Override - public byte[] engineUpdate(byte[] input, int inputOffset, int inputLen) { - if (input == null) { - return null; - } - byte[] result = new byte[inputLen]; - System.arraycopy(input, inputOffset, result, 0, inputLen); - return result; - } - - @Override - public int engineUpdate(byte[] input, int inputOffset, int inputLen, - byte[] output, int outputOffset) throws ShortBufferException { - if (input == null) { - return 0; - } - System.arraycopy(input, inputOffset, output, outputOffset, inputLen); - return inputLen; - } - - @Override - public int engineUpdate(ByteBuffer input, ByteBuffer output) - throws ShortBufferException { - if (input == null || output == null) { - throw new NullPointerException(); - } - int result = input.limit() - input.position(); - try { - output.put(input); - } catch (java.nio.BufferOverflowException e) { - throw new ShortBufferException(Messages.getString("crypto.0F", e)); //$NON-NLS-1$ - } - return result; - } - - @Override - public byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen) - throws IllegalBlockSizeException, BadPaddingException { - if (input == null) { - return null; - } - return engineUpdate(input, inputOffset, inputLen); - } - - @Override - public int engineDoFinal(byte[] input, int inputOffset, int inputLen, - byte[] output, int outputOffset) throws ShortBufferException, - IllegalBlockSizeException, BadPaddingException { - int result = engineUpdate(input, inputOffset, inputLen, output, - outputOffset); - return result; - } - - @Override - public int engineDoFinal(ByteBuffer input, ByteBuffer output) - throws ShortBufferException, IllegalBlockSizeException, - BadPaddingException { - return engineUpdate(input, output); - } - - @Override - public byte[] engineWrap(Key key) throws IllegalBlockSizeException, - InvalidKeyException { - throw new UnsupportedOperationException(Messages.getString("crypto.44")); //$NON-NLS-1$ - } - - @Override - public Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, - int wrappedKeyType) throws InvalidKeyException, - NoSuchAlgorithmException { - throw new UnsupportedOperationException(Messages.getString("crypto.45")); //$NON-NLS-1$ - } - - @Override - public int engineGetKeySize(Key key) throws InvalidKeyException { - throw new UnsupportedOperationException(Messages.getString("crypto.46")); //$NON-NLS-1$ - } -} \ No newline at end of file diff --git a/libcore/crypto/src/main/java/org/apache/harmony/crypto/internal/nls/Messages.java b/libcore/crypto/src/main/java/org/apache/harmony/crypto/internal/nls/Messages.java deleted file mode 100644 index b61a5cf4f..000000000 --- a/libcore/crypto/src/main/java/org/apache/harmony/crypto/internal/nls/Messages.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL. - * All changes made to this file manually will be overwritten - * if this tool runs again. Better make changes in the template file. - */ - -// BEGIN android-note -// Redundant code has been removed and is now called from MsgHelp. -// END android-note - -package org.apache.harmony.crypto.internal.nls; - - -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -// BEGIN android-changed -import org.apache.harmony.luni.util.MsgHelp; -// END android-changed - -/** - * This class retrieves strings from a resource bundle and returns them, - * formatting them with MessageFormat when required. - *

- * It is used by the system classes to provide national language support, by - * looking up messages in the - * org.apache.harmony.crypto.internal.nls.messages - * - * resource bundle. Note that if this file is not available, or an invalid key - * is looked up, or resource bundle support is not available, the key itself - * will be returned as the associated message. This means that the KEY - * should a reasonable human-readable (english) string. - * - */ -public class Messages { - - // BEGIN android-changed - private static final String sResource = - "org.apache.harmony.crypto.internal.nls.messages"; //$NON-NLS-1$ - // END android-changed - - /** - * Retrieves a message which has no arguments. - * - * @param msg - * String the key to look up. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg) { - // BEGIN android-changed - return MsgHelp.getString(sResource, msg); - // END android-changed - } - - /** - * Retrieves a message which takes 1 argument. - * - * @param msg - * String the key to look up. - * @param arg - * Object the object to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, Object arg) { - return getString(msg, new Object[] { arg }); - } - - /** - * Retrieves a message which takes 1 integer argument. - * - * @param msg - * String the key to look up. - * @param arg - * int the integer to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, int arg) { - return getString(msg, new Object[] { Integer.toString(arg) }); - } - - /** - * Retrieves a message which takes 1 character argument. - * - * @param msg - * String the key to look up. - * @param arg - * char the character to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, char arg) { - return getString(msg, new Object[] { String.valueOf(arg) }); - } - - /** - * Retrieves a message which takes 2 arguments. - * - * @param msg - * String the key to look up. - * @param arg1 - * Object an object to insert in the formatted output. - * @param arg2 - * Object another object to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, Object arg1, Object arg2) { - return getString(msg, new Object[] { arg1, arg2 }); - } - - /** - * Retrieves a message which takes several arguments. - * - * @param msg - * String the key to look up. - * @param args - * Object[] the objects to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, Object[] args) { - // BEGIN android-changed - return MsgHelp.getString(sResource, msg, args); - // END android-changed - } - - // BEGIN android-note - // Duplicate code was dropped in favor of using MsgHelp. - // END android-note -} diff --git a/libcore/crypto/src/main/java/org/apache/harmony/crypto/internal/nls/messages.properties b/libcore/crypto/src/main/java/org/apache/harmony/crypto/internal/nls/messages.properties deleted file mode 100644 index 509e1000b..000000000 --- a/libcore/crypto/src/main/java/org/apache/harmony/crypto/internal/nls/messages.properties +++ /dev/null @@ -1,87 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# messages for EN locale -crypto.01=MAC was not initialized -crypto.02=Algorithm is null -crypto.03=Provider is null or empty -crypto.04=Provider is null -crypto.05=key is null -crypto.06=Incorrect arguments -crypto.07=input is null -crypto.08=Output buffer is null -crypto.09=Incorrect outOffset parameter: {0} -crypto.0A=Output buffer is short. It is needed {0} bytes -crypto.0B=Not initialized Mac -crypto.0C=input byte buffer is null -crypto.0D=output byte buffer is null -crypto.0E=Output is small -crypto.0F=Output buffer is too small: {0} -crypto.10=engineWrap(Key key) is not supported -crypto.11=engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType) is not supported -crypto.12=engineGetKeySize(Key key) is not supported -crypto.13=Cipher is null\! -crypto.14=Specified sealed object is null\! -crypto.15=The provider name is empty or null -crypto.16=Provider {0} is not available -crypto.17=Invalid transformation {0} -crypto.18=Cipher has not yet been initialized -crypto.19=Invalid mode -crypto.1A=The public key in the certificate cannot be used for ENCRYPT_MODE -crypto.1B=The public key in the certificate cannot be used for DECRYPT_MODE -crypto.1C=Cipher has not yet been initialized properly -crypto.1D=The input parameter is null -crypto.1E=Incorrect inputOffset/inputLen parameters -crypto.1F=The output parameter is null -crypto.20=Incorrect outputOffset parameter -crypto.21=Incorrect inputOffset/inputLen parameters -crypto.22=the encoded parameter is null -crypto.23=the algName parameter is null -crypto.24={0} not supported -crypto.25=the encryptedData parameter is null -crypto.26=the encryptedData is empty -crypto.27=the algParams parameter is null -crypto.28=the cipher parameter is null -crypto.29=Decrypted data does not represent valid PKCS\#8 PrivateKeyInfo -crypto.2A=the decryptKey parameter is null -crypto.2B=the providerName parameter is null -crypto.2C=the provider parameter is null -crypto.2D=ExemptionMechanism is not initialized -crypto.2E=Input and output are the same object -crypto.2F=Specified key material is null. -crypto.30=The key material is shorter than 24 bytes. -crypto.31=iv is null -crypto.32=iv.length < 2 * (wordSize / 8) -crypto.33=offset is negative -crypto.34=iv.length - offset < 2 * (wordSize / 8) -crypto.35=key is empty -crypto.36=len is negative -crypto.37=key is too short -crypto.38=Specified IV is null. -crypto.39=iv is null or (iv.length - offset < len) -crypto.3A=offset < 0 or len < 0 -crypto.3B=Specified salt is null. -crypto.3C=salt is empty -crypto.3D=iterationCount is not positive. -crypto.3E=keyLength is not positive. -crypto.3F=The password has been cleared. -crypto.40=The key material is shorter than 8 bytes -crypto.41=iv is shorter than 8 bytes -crypto.42=pSrcName is null\! -crypto.43=encoding input is null\! -crypto.44=Wrap -crypto.45=Unwrap -crypto.46=GetKeySize diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/AllTests.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/AllTests.java deleted file mode 100644 index 5050fc8f8..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/AllTests.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * This is autogenerated source file. Includes tests for package org.apache.harmony.crypto.tests.javax.crypto; - */ - -public class AllTests { - - public static void main(String[] args) { - junit.textui.TestRunner.run(AllTests.suite()); - } - - public static Test suite() { - TestSuite suite = tests.TestSuiteFactory.createTestSuite("All tests for package org.apache.harmony.crypto.tests.javax.crypto;"); - // $JUnit-BEGIN$ - - suite.addTestSuite(BadPaddingExceptionTest.class); - suite.addTestSuite(CipherInputStream1Test.class); - suite.addTestSuite(CipherInputStreamTest.class); - suite.addTestSuite(CipherOutputStream1Test.class); - suite.addTestSuite(CipherOutputStreamTest.class); - suite.addTestSuite(CipherSpiTest.class); - suite.addTestSuite(CipherTest.class); - suite.addTestSuite(EncryptedPrivateKeyInfoTest.class); - suite.addTestSuite(ExemptionMechanismExceptionTest.class); - suite.addTestSuite(ExemptionMechanismSpiTest.class); - suite.addTestSuite(ExemptionMechanismTest.class); - suite.addTestSuite(IllegalBlockSizeExceptionTest.class); - suite.addTestSuite(KeyAgreementSpiTest.class); - suite.addTestSuite(KeyAgreementTest.class); - suite.addTestSuite(KeyGeneratorSpiTest.class); - suite.addTestSuite(KeyGeneratorTest.class); - suite.addTestSuite(MacSpiTest.class); - suite.addTestSuite(MacTest.class); - suite.addTestSuite(NoSuchPaddingExceptionTest.class); - suite.addTestSuite(NullCipherTest.class); - suite.addTestSuite(SealedObjectTest.class); - suite.addTestSuite(SecretKeyFactorySpiTest.class); - suite.addTestSuite(SecretKeyFactoryTest.class); - suite.addTestSuite(SecretKeyTest.class); - suite.addTestSuite(ShortBufferExceptionTest.class); - - // $JUnit-END$ - return suite; - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/BadPaddingExceptionTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/BadPaddingExceptionTest.java deleted file mode 100644 index 62973921c..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/BadPaddingExceptionTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import javax.crypto.BadPaddingException; - -import junit.framework.TestCase; - - -/** - * Tests for BadPaddingException class constructors and methods. - * - */ -@TestTargetClass(BadPaddingException.class) -public class BadPaddingExceptionTest extends TestCase { - - static String[] msgs = { - "", - "Check new message", - "Check new message Check new message Check new message Check new message Check new message" }; - - static Throwable tCause = new Throwable("Throwable for exception"); - - /** - * Test for BadPaddingException() constructor Assertion: - * constructs BadPaddingException with no detail message - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "BadPaddingException", - args = {} - ) - public void testBadPaddingException01() { - BadPaddingException tE = new BadPaddingException(); - assertNull("getMessage() must return null.", tE.getMessage()); - assertNull("getCause() must return null", tE.getCause()); - } - - /** - * Test for BadPaddingException(String) constructor - * Assertion: constructs BadPaddingException with detail message msg. - * Parameter msg is not null. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "BadPaddingException", - args = {java.lang.String.class} - ) - public void testBadPaddingException02() { - BadPaddingException tE; - for (int i = 0; i < msgs.length; i++) { - tE = new BadPaddingException(msgs[i]); - assertEquals("getMessage() must return: ".concat(msgs[i]), tE - .getMessage(), msgs[i]); - assertNull("getCause() must return null", tE.getCause()); - } - } - - /** - * Test for BadPaddingException(String) constructor - * Assertion: constructs BadPaddingException when msg is null - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "BadPaddingException", - args = {java.lang.String.class} - ) - public void testBadPaddingException03() { - String msg = null; - BadPaddingException tE = new BadPaddingException(msg); - assertNull("getMessage() must return null.", tE.getMessage()); - assertNull("getCause() must return null", tE.getCause()); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherInputStream1Test.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherInputStream1Test.java deleted file mode 100644 index 98ea555ac..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherInputStream1Test.java +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Alexander Y. Kleymenov -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.io.ByteArrayInputStream; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; - -import javax.crypto.Cipher; -import javax.crypto.KeyGenerator; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.NullCipher; -import javax.crypto.CipherInputStream; - -import junit.framework.TestCase; - -@TestTargetClass(CipherInputStream.class) -/** - */ - -public class CipherInputStream1Test extends TestCase { - - private static class TestInputStream extends ByteArrayInputStream { - private boolean closed = false; - - public TestInputStream(byte[] data) { - super(data); - } - - public void close() { - closed = true; - } - - public boolean wasClosed() { - return closed; - } - } - - /** - * CipherInputStream(InputStream is) method testing. Tests that - * CipherInputStream uses NullCipher if Cipher is not specified - * in the constructor. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "CipherInputStream", - args = {java.io.InputStream.class} - ) - public void testCipherInputStream() throws Exception { - byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; - TestInputStream tis = new TestInputStream(data); - CipherInputStream cis = new CipherInputStream(tis){}; - - for (int i = 0; i < data.length; i++) { - if ((byte) cis.read() != data[i]) { - fail("NullCipher should be used " - + "if Cipher is not specified."); - } - } - if (cis.read() != -1) { - fail("NullCipher should be used if Cipher is not specified."); - } - } - - /** - * read() method testing. Tests that method returns the correct value - * (related to the InputStream) and that it returns -1 at the end of stream. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Can not check IOException.", - method = "read", - args = {} - ) - public void testRead1() throws Exception { - byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; - TestInputStream tis = new TestInputStream(data); - CipherInputStream cis = new CipherInputStream(tis, new NullCipher()); - byte res; - for (int i = 0; i < data.length; i++) { - if ((res = (byte) cis.read()) != data[i]) { - fail("read() returned the incorrect value. " + "Expected: " - + data[i] + ", Got: " + res + "."); - } - } - if (cis.read() != -1) { - fail("read() should return -1 at the end of the stream."); - } - } - - /** - * read(byte[] b) method testing. Tests that method returns the correct - * value (related to the InputStream) and that it returns -1 at the end of - * stream. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Can not check IOException.", - method = "read", - args = {byte[].class} - ) - public void testRead2() throws Exception { - byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; - TestInputStream tis = new TestInputStream(data); - CipherInputStream cis = new CipherInputStream(tis, new NullCipher()); - - int expected = data.length; - byte[] result = new byte[expected]; - - int ind = 0; // index into the data array (to check the got data) - int got = cis.read(result); // the number of got bytes - while (true) { - for (int j = 0; j < got - ind; j++) { - if (result[j] != data[ind + j]) { - fail("read(byte[] b) returned incorrect data."); - } - } - if (got == expected) { - break; - } else if (got > expected) { - fail("The data returned by read(byte[] b) " - + "is larger than expected."); - } else { - ind = got; - got += cis.read(result); - } - } - if (cis.read(result) != -1) { - fail("read(byte[] b) should return -1 " - + "at the end of the stream."); - } - } - - /** - * read(byte[] b, int off, int len) method testing. Tests that method - * returns the correct value (related to the InputStream), that it discards - * bytes in the case of null buffer, and that it returns -1 at the end of - * stream. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Can not check IOException.", - method = "read", - args = {byte[].class, int.class, int.class} - ) - public void testRead3() throws Exception { - byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; - TestInputStream tis = new TestInputStream(data); - CipherInputStream cis = new CipherInputStream(tis, new NullCipher()); - - int expected = data.length; - byte[] result = new byte[expected]; - - int skip = 2; - int ind = skip; // index into the data array (to check the got data) - // should read and discard bytes; - cis.read(null, 0, skip); - int got = skip + cis.read(result, 0, 1); // the number of got bytes - while (true) { - for (int j = 0; j < got - ind; j++) { - assertEquals("read(byte[] b, int off, int len) " - + "returned incorrect data.", result[j], data[ind + j]); - } - if (got == expected) { - break; - } else if (got > expected) { - fail("The data returned by " - + "read(byte[] b, int off, int len) " - + "is larger than expected."); - } else { - ind = got; - got += cis.read(result, 0, 3); - } - } - if (cis.read(result, 0, 1) != -1) { - fail("read() should return -1 at the end of the stream."); - } - } - - /** - * skip(long n) method testing. Tests that the method correctly skips the - * bytes. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Can not check IOException.", - method = "skip", - args = {long.class} - ) - public void testSkip() throws Exception { - byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; - TestInputStream tis = new TestInputStream(data); - CipherInputStream cis = new CipherInputStream(tis, new NullCipher()); - int expected = data.length; - byte[] result = new byte[expected]; - - int skipped = (int) cis.skip(2); - int ind = skipped; - int got = skipped + cis.read(result, 0, 1); // the number of got bytes - while (true) { - for (int j = 0; j < got - ind; j++) { - if (result[j] != data[ind + j]) { - fail("read(byte[] b, int off, int len) " - + "returned incorrect data: Expected " - + data[ind + j] + ", got: " + result[j]); - } - } - if (got == expected) { - break; - } else if (got > expected) { - fail("The data returned by " - + "read(byte[] b, int off, int len) " - + "is larger than expected."); - } else { - ind = got; - got += cis.read(result, 0, 1); - } - } - if ((got = cis.read(result, 0, 1)) != -1) { - fail("read() should return -1 at the end of the stream. " - + "Output is: " + got + "."); - } - } - - /** - * available() method testing. Tests that the method always return 0. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Can not check IOException.", - method = "available", - args = {} - ) - public void testAvailable() throws Exception { - byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; - TestInputStream tis = new TestInputStream(data); - CipherInputStream cis = new CipherInputStream(tis, new NullCipher()); - assertEquals("The returned by available() method value " - + "should be 0.", cis.available(), 0); - } - - /** - * close() method testing. Tests that the method calls the close() - * method of the underlying input stream. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Can not check IOException.", - method = "close", - args = {} - ) - public void testClose() throws Exception { - byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; - TestInputStream tis = new TestInputStream(data); - CipherInputStream cis = new CipherInputStream(tis, new NullCipher()); - cis.close(); - assertTrue("The close() method should call the close() method " - + "of its underlying input stream.", tis.wasClosed()); - } - - /** - * markSupported() method testing. Tests that mark is not supported. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "markSupported", - args = {} - ) - public void testMarkSupported() { - byte[] data = new byte[] {-127, -100, -50, -10, -1, 0, 1, 10, 50, 127}; - TestInputStream tis = new TestInputStream(data); - CipherInputStream cis = new CipherInputStream(tis, new NullCipher()); - assertFalse("The returned by markSupported() method value " - + "should be false.", cis.markSupported()); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "CipherInputStream", - args = {java.io.InputStream.class, javax.crypto.Cipher.class} - ) - public void test_ConstructorLjava_io_InputStreamLjavax_crypto_Cipher () throws - NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException { - ByteArrayInputStream bais = new ByteArrayInputStream(new byte[100]); - - KeyGenerator kg = KeyGenerator.getInstance("DES"); - kg.init(56, new SecureRandom()); - Key key = kg.generateKey(); - - Cipher c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, key); - - CipherInputStream cis = new CipherInputStream(bais, c); - - assertNotNull(cis); - } - -} - diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherInputStreamTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherInputStreamTest.java deleted file mode 100644 index 64562bb96..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherInputStreamTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.InputStream; - -import junit.framework.TestCase; - -import javax.crypto.Cipher; -import javax.crypto.CipherInputStream; -import javax.crypto.NullCipher; - -@TestTargetClass(CipherInputStream.class) -public class CipherInputStreamTest extends TestCase { - - /** - * @tests javax.crypto.CipherInputStream#read(byte[] b, int off, int len) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Regression test. Checks NullPointerException", - method = "read", - args = {byte[].class, int.class, int.class} - ) - public void testReadBII() throws Exception { - // Regression for HARMONY-1080 - CipherInputStream stream = new CipherInputStream(null, new NullCipher()); - try { - stream.read(new byte[1], 1, 0); - fail("NullPointerException expected"); - } catch (NullPointerException e) { - // expected - } - } - - /** - * @tests javax.crypto.CipherInputStream#close() - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Regression test. Checks IllegalStateException", - method = "close", - args = {} - ) - public void testClose() throws Exception { - // Regression for HARMONY-1087 - try { - new CipherInputStream(new ByteArrayInputStream(new byte[] { 1 }), - Cipher.getInstance("DES/CBC/PKCS5Padding")).close(); - fail("IllegalStateException expected!"); - } catch (IllegalStateException e) { - // expected - } - try { - new CipherInputStream(new BufferedInputStream((InputStream) null), - Cipher.getInstance("DES/CBC/PKCS5Padding")).close(); - fail("IllegalStateException expected!"); - } catch (IllegalStateException e) { - // expected - } - } - -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherOutputStream1Test.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherOutputStream1Test.java deleted file mode 100644 index 237af28bf..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherOutputStream1Test.java +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Alexander Y. Kleymenov -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.io.BufferedOutputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.OutputStream; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.util.Arrays; - -import javax.crypto.KeyGenerator; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.NullCipher; -import javax.crypto.CipherOutputStream; -import javax.crypto.Cipher; - -import junit.framework.TestCase; - -@TestTargetClass(CipherOutputStream.class) -/** - */ - -public class CipherOutputStream1Test extends TestCase { - - private static class TestOutputStream extends ByteArrayOutputStream { - private boolean closed = false; - - public void close() { - closed = true; - } - - public boolean wasClosed() { - return closed; - } - } - - /** - * CipherOutputStream(OutputStream os) method testing. Tests that - * CipherOutputStream uses NullCipher if Cipher is not specified - * in the constructor. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "CipherOutputStream", - args = {java.io.OutputStream.class} - ) - public void testCipherOutputStream() throws Exception { - byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; - TestOutputStream tos = new TestOutputStream(); - CipherOutputStream cos = new CipherOutputStream(tos){}; - cos.write(data); - cos.flush(); - byte[] result = tos.toByteArray(); - if (!Arrays.equals(result, data)) { - fail("NullCipher should be used " + "if Cipher is not specified."); - } - } - - /** - * write(int b) method testing. Tests that method writes correct values to - * the underlying output stream. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Can not check IOException.", - method = "write", - args = {int.class} - ) - public void testWrite1() throws Exception { - byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; - TestOutputStream tos = new TestOutputStream(); - CipherOutputStream cos = new CipherOutputStream(tos, new NullCipher()); - for (int i = 0; i < data.length; i++) { - cos.write(data[i]); - } - cos.flush(); - byte[] result = tos.toByteArray(); - if (!Arrays.equals(result, data)) { - fail("CipherOutputStream wrote incorrect data."); - } - } - - /** - * write(byte[] b) method testing. Tests that method writes correct values - * to the underlying output stream. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Can not check IOException.", - method = "write", - args = {byte[].class} - ) - public void testWrite2() throws Exception { - byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; - TestOutputStream tos = new TestOutputStream(); - CipherOutputStream cos = new CipherOutputStream(tos, new NullCipher()); - cos.write(data); - cos.flush(); - byte[] result = tos.toByteArray(); - if (!Arrays.equals(result, data)) { - fail("CipherOutputStream wrote incorrect data."); - } - - try { - cos.write(null); - fail("NullPointerException expected"); - } catch (NullPointerException e) { - //expected - } - } - - /** - * write(byte[] b, int off, int len) method testing. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Can not check IOException.", - method = "write", - args = {byte[].class, int.class, int.class} - ) - public void testWrite3() throws Exception { - byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; - TestOutputStream tos = new TestOutputStream(); - CipherOutputStream cos = new CipherOutputStream(tos, new NullCipher()); - for (int i = 0; i < data.length; i++) { - cos.write(data, i, 1); - } - cos.flush(); - byte[] result = tos.toByteArray(); - if (!Arrays.equals(result, data)) { - fail("CipherOutputStream wrote incorrect data."); - } - } - - /** - * @tests write(byte[] b, int off, int len) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Regression test. IllegalArgumentException checked.", - method = "write", - args = {byte[].class, int.class, int.class} - ) - public void testWrite4() throws Exception { - //Regression for HARMONY-758 - try { - new CipherOutputStream(new BufferedOutputStream((OutputStream) null), new NullCipher()).write(new byte[] {0}, 1, Integer.MAX_VALUE); - } catch (IllegalArgumentException e) { - } - } - - /** - * @tests write(byte[] b, int off, int len) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Can not check IOException.", - method = "write", - args = {byte[].class, int.class, int.class} - ) - public void testWrite5() throws Exception { - //Regression for HARMONY-758 - Cipher cf = Cipher.getInstance("DES/CBC/PKCS5Padding"); - NullCipher nc = new NullCipher(); - CipherOutputStream stream1 = new CipherOutputStream(new BufferedOutputStream((OutputStream) null), nc); - CipherOutputStream stream2 = new CipherOutputStream(stream1, cf); - CipherOutputStream stream3 = new CipherOutputStream(stream2, nc); - stream3.write(new byte[] {0}, 0, 0); - //no exception expected - } - - /** - * flush() method testing. Tests that method flushes the data to the - * underlying output stream. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Can not check IOException.", - method = "flush", - args = {} - ) - public void testFlush() throws Exception { - byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; - TestOutputStream tos = new TestOutputStream(); - CipherOutputStream cos = new CipherOutputStream(tos){}; - cos.write(data); - cos.flush(); - byte[] result = tos.toByteArray(); - if (!Arrays.equals(result, data)) { - fail("CipherOutputStream did not flush the data."); - } - } - - /** - * close() method testing. Tests that the method calls the close() method of - * the underlying input stream. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Can not check IOException.", - method = "close", - args = {} - ) - public void testClose() throws Exception { - byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; - TestOutputStream tos = new TestOutputStream(); - CipherOutputStream cos = new CipherOutputStream(tos){}; - cos.write(data); - cos.close(); - byte[] result = tos.toByteArray(); - if (!Arrays.equals(result, data)) { - fail("CipherOutputStream did not flush the data."); - } - assertTrue("The close() method should call the close() method " - + "of its underlying output stream.", tos.wasClosed()); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "CipherOutputStream", - args = {java.io.OutputStream.class, javax.crypto.Cipher.class} - ) - public void test_ConstructorLjava_io_OutputStreamLjavax_crypto_Cipher() throws - NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - KeyGenerator kg = KeyGenerator.getInstance("DES"); - kg.init(56, new SecureRandom()); - Key key = kg.generateKey(); - - Cipher c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, key); - - CipherOutputStream cos = new CipherOutputStream(baos, c); - - assertNotNull(cos); - } -} - diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherOutputStreamTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherOutputStreamTest.java deleted file mode 100644 index aadad1abe..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherOutputStreamTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.io.OutputStream; -import javax.crypto.Cipher; -import javax.crypto.CipherOutputStream; - -@TestTargetClass(CipherOutputStream.class) -public class CipherOutputStreamTest extends junit.framework.TestCase { - - /** - * @tests javax.crypto.CipherOutputStream#close() - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Regression test. Checks IllegalStateException.", - method = "close", - args = {} - ) - public void test_close() throws Exception { - // regression test for HARMONY-1139 - try { - new CipherOutputStream((OutputStream) null, Cipher - .getInstance("DES/CBC/PKCS5Padding")).close(); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - // expected - } - - CipherOutputStream ch = new CipherOutputStream((OutputStream) null) {}; - try { - new CipherOutputStream(ch, Cipher - .getInstance("DES/CBC/PKCS5Padding")).close(); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - // expected - } - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherSpiTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherSpiTest.java deleted file mode 100644 index 56e83c67c..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherSpiTest.java +++ /dev/null @@ -1,455 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.security.spec.AlgorithmParameterSpec; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.security.AlgorithmParameters; -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.ShortBufferException; -import javax.crypto.CipherSpi; -import java.nio.ByteBuffer; - -import junit.framework.TestCase; - - -@TestTargetClass(CipherSpi.class) -/** - * Tests for CipherSpi class constructors and methods. - * - */ -public class CipherSpiTest extends TestCase { - class Mock_CipherSpi extends myCipherSpi { - - @Override - protected byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen) - throws IllegalBlockSizeException, BadPaddingException { - return super.engineDoFinal(input, inputOffset, inputLen); - } - - @Override - protected int engineDoFinal(byte[] input, int inputOffset, int inputLen, byte[] output, - int outputOffset) throws ShortBufferException, IllegalBlockSizeException, - BadPaddingException { - return super.engineDoFinal(input, inputOffset, inputLen, output, outputOffset); - } - - @Override - protected int engineGetBlockSize() { - return super.engineGetBlockSize(); - } - - @Override - protected byte[] engineGetIV() { - return super.engineGetIV(); - } - - @Override - protected int engineGetOutputSize(int inputLen) { - return super.engineGetOutputSize(inputLen); - } - - @Override - protected AlgorithmParameters engineGetParameters() { - return super.engineGetParameters(); - } - - @Override - protected void engineInit(int opmode, Key key, SecureRandom random) - throws InvalidKeyException { - super.engineInit(opmode, key, random); - } - - @Override - protected void engineInit(int opmode, Key key, AlgorithmParameterSpec params, - SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException { - super.engineInit(opmode, key, params, random); - } - - @Override - protected void engineInit(int opmode, Key key, AlgorithmParameters params, - SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException { - super.engineInit(opmode, key, params, random); - } - - @Override - protected void engineSetMode(String mode) throws NoSuchAlgorithmException { - super.engineSetMode(mode); - } - - @Override - protected void engineSetPadding(String padding) throws NoSuchPaddingException { - super.engineSetPadding(padding); - } - - @Override - protected byte[] engineUpdate(byte[] input, int inputOffset, int inputLen) { - return super.engineUpdate(input, inputOffset, inputLen); - } - - @Override - protected int engineUpdate(byte[] input, int inputOffset, int inputLen, byte[] output, - int outputOffset) throws ShortBufferException { - return super.engineUpdate(input, inputOffset, inputLen, output, outputOffset); - } - - @Override - protected int engineGetKeySize(Key key) throws InvalidKeyException { - return super.engineGetKeySize(key); - } - - @Override - protected byte[] engineWrap(Key key) throws InvalidKeyException, IllegalBlockSizeException { - return super.engineWrap(key); - } - - @Override - protected Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType) - throws InvalidKeyException, NoSuchAlgorithmException { - return super.engineUnwrap(wrappedKey, wrappedKeyAlgorithm, wrappedKeyType); - } - } - - /** - * Test for CipherSpi constructor - * Assertion: constructs CipherSpi - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "CipherSpi", - args = {} - ) - public void testCipherSpiTests01() throws IllegalBlockSizeException, - BadPaddingException, ShortBufferException { - - Mock_CipherSpi cSpi = new Mock_CipherSpi(); - assertEquals("BlockSize is not 0", cSpi.engineGetBlockSize(), 0); - assertEquals("OutputSize is not 0", cSpi.engineGetOutputSize(1), 0); - byte[] bb = cSpi.engineGetIV(); - assertEquals("Length of result byte array is not 0", bb.length, 0); - assertNull("Not null result", cSpi.engineGetParameters()); - byte[] bb1 = new byte[10]; - byte[] bb2 = new byte[10]; - bb = cSpi.engineUpdate(bb1, 1, 2); - assertEquals("Incorrect result of engineUpdate(byte, int, int)", - bb.length, 2); - bb = cSpi.engineDoFinal(bb1, 1, 2); - assertEquals("Incorrect result of engineDoFinal(byte, int, int)", 2, - bb.length); - assertEquals( - "Incorrect result of engineUpdate(byte, int, int, byte, int)", - cSpi.engineUpdate(bb1, 1, 2, bb2, 7), 2); - assertEquals( - "Incorrect result of engineDoFinal(byte, int, int, byte, int)", - 2, cSpi.engineDoFinal(bb1, 1, 2, bb2, 0)); - } - - /** - * Test for engineGetKeySize(Key) method - * Assertion: It throws UnsupportedOperationException if it is not overridden - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - method = "engineGetKeySize", - args = {java.security.Key.class} - ) - public void testCipherSpi02() throws Exception { - Mock_CipherSpi cSpi = new Mock_CipherSpi(); - try { - cSpi.engineGetKeySize(null); - fail("UnsupportedOperationException must be thrown"); - } catch (UnsupportedOperationException e) { - } - } - - /** - * Test for engineWrap(Key) method - * Assertion: It throws UnsupportedOperationException if it is not overridden - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Functionality not tested.", - method = "engineWrap", - args = {java.security.Key.class} - ) - public void testCipherSpi03() throws Exception { - Mock_CipherSpi cSpi = new Mock_CipherSpi(); - try { - cSpi.engineWrap(null); - fail("UnsupportedOperationException must be thrown"); - } catch (UnsupportedOperationException e) { - } - } - - /** - * Test for engineUnwrap(byte[], String, int) method - * Assertion: It throws UnsupportedOperationException if it is not overridden - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Functionality not tested.", - method = "engineUnwrap", - args = {byte[].class, java.lang.String.class, int.class} - ) - public void testCipherSpi04() throws Exception { - Mock_CipherSpi cSpi = new Mock_CipherSpi(); - try { - cSpi.engineUnwrap(new byte[0], "", 0); - fail("UnsupportedOperationException must be thrown"); - } catch (UnsupportedOperationException e) { - } - } - - /** - * Test for engineUpdate(ByteBuffer, ByteBuffer) method - * Assertions: - * throws NullPointerException if one of these buffers is null; - * throws ShortBufferException is there is no space in output to hold result - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "engineUpdate", - args = {java.nio.ByteBuffer.class, java.nio.ByteBuffer.class} - ) - public void testCipherSpi05() throws ShortBufferException { - Mock_CipherSpi cSpi = new Mock_CipherSpi(); - byte[] bb = { (byte) 0, (byte) 1, (byte) 2, (byte) 3, (byte) 4, - (byte) 5, (byte) 6, (byte) 7, (byte) 8, (byte) 9, (byte) 10 }; - int pos = 5; - int len = bb.length; - ByteBuffer bbNull = null; - ByteBuffer bb1 = ByteBuffer.allocate(len); - bb1.put(bb); - bb1.position(0); - try { - cSpi.engineUpdate(bbNull, bb1); - fail("NullPointerException must be thrown"); - } catch (NullPointerException e) { - } - try { - cSpi.engineUpdate(bb1, bbNull); - fail("NullPointerException must be thrown"); - } catch (NullPointerException e) { - } - ByteBuffer bb2 = ByteBuffer.allocate(bb.length); - bb1.position(len); - assertEquals("Incorrect number of stored bytes", 0, cSpi.engineUpdate( - bb1, bb2)); - - bb1.position(0); - bb2.position(len - 2); - try { - cSpi.engineUpdate(bb1, bb2); - fail("ShortBufferException bust be thrown. Output buffer remaining: " - .concat(Integer.toString(bb2.remaining()))); - } catch (ShortBufferException e) { - } - bb1.position(10); - bb2.position(0); - assertTrue("Incorrect number of stored bytes", cSpi.engineUpdate(bb1, - bb2) > 0); - bb1.position(bb.length); - cSpi.engineUpdate(bb1, bb2); - - bb1.position(pos); - bb2.position(0); - int res = cSpi.engineUpdate(bb1, bb2); - assertTrue("Incorrect result", res > 0); - } - - /** - * Test for engineDoFinal(ByteBuffer, ByteBuffer) method - * Assertions: - * throws NullPointerException if one of these buffers is null; - * throws ShortBufferException is there is no space in output to hold result - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "BadPaddingException & IllegalBlockSizeException checking missed.", - method = "engineDoFinal", - args = {java.nio.ByteBuffer.class, java.nio.ByteBuffer.class} - ) - public void testCipherSpi06() throws BadPaddingException, - ShortBufferException, IllegalBlockSizeException { - Mock_CipherSpi cSpi = new Mock_CipherSpi(); - int len = 10; - byte[] bbuf = new byte[len]; - for (int i = 0; i < bbuf.length; i++) { - bbuf[i] = (byte) i; - } - ByteBuffer bb1 = ByteBuffer.wrap(bbuf); - ByteBuffer bbNull = null; - try { - cSpi.engineDoFinal(bbNull, bb1); - fail("NullPointerException must be thrown"); - } catch (NullPointerException e) { - } - try { - cSpi.engineDoFinal(bb1, bbNull); - fail("NullPointerException must be thrown"); - } catch (NullPointerException e) { - } - ByteBuffer bb2 = ByteBuffer.allocate(len); - bb1.position(bb1.limit()); - assertEquals("Incorrect result", 0, cSpi.engineDoFinal(bb1, bb2)); - - bb1.position(0); - bb2.position(len - 2); - try { - cSpi.engineDoFinal(bb1, bb2); - fail("ShortBufferException must be thrown. Output buffer remaining: " - .concat(Integer.toString(bb2.remaining()))); - } catch (ShortBufferException e) { - } - int pos = 5; - bb1.position(pos); - bb2.position(0); - assertTrue("Incorrect result", cSpi.engineDoFinal(bb1, bb2) > 0); - } -} -/** - * - * Additional class for CipherGeneratorSpi constructor verification - */ - -class myCipherSpi extends CipherSpi { - private byte[] initV; - - private static byte[] resV = { (byte) 7, (byte) 6, (byte) 5, (byte) 4, - (byte) 3, (byte) 2, (byte) 1, (byte) 0 }; - - public myCipherSpi() { - this.initV = new byte[0]; - } - - protected void engineSetMode(String mode) throws NoSuchAlgorithmException { - } - - protected void engineSetPadding(String padding) - throws NoSuchPaddingException { - } - - protected int engineGetBlockSize() { - return 0; - } - - protected int engineGetOutputSize(int inputLen) { - return 0; - } - - protected byte[] engineGetIV() { - return new byte[0]; - } - - protected AlgorithmParameters engineGetParameters() { - return null; - } - - protected void engineInit(int opmode, Key key, SecureRandom random) - throws InvalidKeyException { - } - - protected void engineInit(int opmode, Key key, - AlgorithmParameterSpec params, SecureRandom random) - throws InvalidKeyException, InvalidAlgorithmParameterException { - } - - protected void engineInit(int opmode, Key key, AlgorithmParameters params, - SecureRandom random) throws InvalidKeyException, - InvalidAlgorithmParameterException { - } - - protected byte[] engineUpdate(byte[] input, int inputOffset, int inputLen) { - if (initV.length < inputLen) { - initV = new byte[inputLen]; - } - for (int i = 0; i < inputLen; i++) { - initV[i] = input[inputOffset + i]; - } - return initV; - } - - protected int engineUpdate(byte[] input, int inputOffset, int inputLen, - byte[] output, int outputOffset) throws ShortBufferException { - byte []res = engineUpdate(input, inputOffset, inputLen); - int t = res.length; - if ((output.length - outputOffset) < t) { - throw new ShortBufferException("Update"); - } - for (int i = 0; i < t; i++) { - output[i + outputOffset] = initV[i]; - } - return t; - } - - protected byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen) - throws IllegalBlockSizeException, BadPaddingException { - if (resV.length > inputLen) { - byte[] bb = new byte[inputLen]; - for (int i = 0; i < inputLen; i++) { - bb[i] = resV[i]; - } - return bb; - } - return resV; - } - - protected int engineDoFinal(byte[] input, int inputOffset, int inputLen, - byte[] output, int outputOffset) throws ShortBufferException, - IllegalBlockSizeException, BadPaddingException { - byte[] res = engineDoFinal(input, inputOffset, inputLen); - - int t = res.length; - if ((output.length - outputOffset) < t) { - throw new ShortBufferException("DoFinal"); - } - for (int i = 0; i < t; i++) { - output[i + outputOffset] = res[i]; - } - return t; - } - - - protected int engineUpdate(ByteBuffer input, ByteBuffer output) - throws ShortBufferException { - return super.engineUpdate(input, output); - } - protected int engineDoFinal(ByteBuffer input, ByteBuffer output) - throws ShortBufferException, IllegalBlockSizeException, - BadPaddingException { - return super.engineDoFinal(input, output); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherTest.java deleted file mode 100644 index 1245eb3f1..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/CipherTest.java +++ /dev/null @@ -1,1684 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargets; - -import org.apache.harmony.crypto.tests.support.MyCipher; - -import tests.support.resource.Support_Resources; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.math.BigInteger; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.ByteBuffer; -import java.nio.ReadOnlyBufferException; -import java.security.AlgorithmParameters; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.Provider; -import java.security.SecureRandom; -import java.security.Security; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; -import java.security.spec.AlgorithmParameterSpec; -import java.security.spec.RSAKeyGenParameterSpec; -import java.util.Arrays; - -import javax.crypto.BadPaddingException; -import javax.crypto.Cipher; -import javax.crypto.CipherSpi; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.KeyGenerator; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.SecretKeyFactory; -import javax.crypto.ShortBufferException; -import javax.crypto.spec.DESedeKeySpec; -import javax.crypto.spec.IvParameterSpec; - -@TestTargetClass(Cipher.class) -public class CipherTest extends junit.framework.TestCase { - - static Key cipherKey; - static final String algorithm = "DESede"; - static final int keyLen = 168; - - static Key cipherKeyDES; - static final String algorithmDES = "DES"; - static final int keyLenDES = 56; - - static { - try { - KeyGenerator kg = KeyGenerator.getInstance(algorithm); - kg.init(keyLen, new SecureRandom()); - cipherKey = kg.generateKey(); - - kg = KeyGenerator.getInstance(algorithmDES); - kg.init(keyLenDES, new SecureRandom()); - cipherKeyDES = kg.generateKey(); - } catch (Exception e) { - fail("No key " + e); - } - } - - /** - * @tests javax.crypto.Cipher#getInstance(java.lang.String) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getInstance", - args = {java.lang.String.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineSetMode", - args = {java.lang.String.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineSetPadding", - args = {java.lang.String.class} - ) - }) - public void test_getInstanceLjava_lang_String() throws Exception { - Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding"); - assertNotNull("Received a null Cipher instance", cipher); - - try { - Cipher.getInstance("WrongAlgorithmName"); - fail("NoSuchAlgorithmException expected"); - } catch (NoSuchAlgorithmException e) { - //expected - } -// RI throws NoSuchAlgorithmException for wrong padding. - } - - /** - * @tests javax.crypto.Cipher#getInstance(java.lang.String, - * java.lang.String) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getInstance", - args = {java.lang.String.class, java.lang.String.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineSetMode", - args = {java.lang.String.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineSetPadding", - args = {java.lang.String.class} - ) - }) - public void test_getInstanceLjava_lang_StringLjava_lang_String() - throws Exception { - - Provider[] providers = Security.getProviders("Cipher.DES"); - - assertNotNull("No installed providers support Cipher.DES", providers); - - for (int i = 0; i < providers.length; i++) { - Cipher cipher = Cipher.getInstance("DES", providers[i].getName()); - assertNotNull("Cipher.getInstance() returned a null value", cipher); - - // Exception case - try { - cipher = Cipher.getInstance("DoBeDoBeDo", providers[i]); - fail("Should have thrown an NoSuchAlgorithmException"); - } catch (NoSuchAlgorithmException e) { - // Expected - } - } - - // Exception case - try { - Cipher.getInstance("DES", (String) null); - fail("Should have thrown an IllegalArgumentException"); - } catch (IllegalArgumentException e) { - // Expected - } - - // Exception case - try { - Cipher.getInstance("DES", "IHaveNotBeenConfigured"); - fail("Should have thrown an NoSuchProviderException"); - } catch (NoSuchProviderException e) { - // Expected - } -// RI throws NoSuchAlgorithmException for wrong padding. - } - - /** - * @tests javax.crypto.Cipher#getInstance(java.lang.String, - * java.security.Provider) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getInstance", - args = {java.lang.String.class, java.security.Provider.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineSetMode", - args = {java.lang.String.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineSetPadding", - args = {java.lang.String.class} - ) - }) - public void test_getInstanceLjava_lang_StringLjava_security_Provider() - throws Exception { - - Provider[] providers = Security.getProviders("Cipher.DES"); - - assertNotNull("No installed providers support Cipher.DES", providers); - - for (int i = 0; i < providers.length; i++) { - Cipher cipher = Cipher.getInstance("DES", providers[i]); - assertNotNull("Cipher.getInstance() returned a null value", cipher); - } - - // Exception case - try { - Cipher.getInstance("DES", (Provider) null); - fail("Should have thrown an IllegalArgumentException"); - } catch (IllegalArgumentException e) { - // Expected - } - - // Exception case - try { - Cipher.getInstance("WrongAlg", providers[0]); - fail("NoSuchAlgorithmException expected"); - } catch (NoSuchAlgorithmException e) { - // Expected - } -// RI throws NoSuchAlgorithmException for wrong padding. - } - - /** - * @tests javax.crypto.Cipher#getProvider() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getProvider", - args = {} - ) - public void test_getProvider() throws Exception { - - Provider[] providers = Security.getProviders("Cipher.AES"); - - assertNotNull("No providers support Cipher.AES", providers); - - for (int i = 0; i < providers.length; i++) { - Provider provider = providers[i]; - Cipher cipher = Cipher.getInstance("AES", provider.getName()); - Provider cipherProvider = cipher.getProvider(); - assertTrue("Cipher provider is not the same as that " - + "provided as parameter to getInstance()", cipherProvider - .equals(provider)); - } - } - - /** - * @tests javax.crypto.Cipher#getAlgorithm() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getAlgorithm", - args = {} - ) - public void test_getAlgorithm() throws Exception { - final String algorithm = "DESede/CBC/PKCS5Padding"; - - Cipher cipher = Cipher.getInstance(algorithm); - assertTrue("Cipher algorithm does not match", cipher.getAlgorithm() - .equals(algorithm)); - } - - /** - * @tests javax.crypto.Cipher#getBlockSize() - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getBlockSize", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineGetBlockSize", - args = {} - ) - }) - public void test_getBlockSize() throws Exception { - final String algorithm = "DESede/CBC/PKCS5Padding"; - - Cipher cipher = Cipher.getInstance(algorithm); - assertEquals("Block size does not match", 8, cipher.getBlockSize()); - } - - /** - * @tests javax.crypto.Cipher#getOutputSize(int) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getOutputSize", - args = {int.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineGetOutputSize", - args = {int.class} - ) - }) - public void test_getOutputSizeI() throws Exception { - - SecureRandom sr = new SecureRandom(); - Cipher cipher = Cipher.getInstance(algorithm + "/ECB/PKCS5Padding"); - - try { - cipher.getOutputSize(25); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //expected - } - - cipher.init(Cipher.ENCRYPT_MODE, cipherKey, sr); - - // A 25-byte input could result in at least 4 8-byte blocks - int result = cipher.getOutputSize(25); - assertTrue("Output size too small", result > 31); - - // A 8-byte input should result in 2 8-byte blocks - result = cipher.getOutputSize(8); - assertTrue("Output size too small", result > 15); - } - - /** - * @tests javax.crypto.Cipher#init(int, java.security.Key) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "init", - args = {int.class, java.security.Key.class} - ) - public void test_initILjava_security_Key() throws Exception { - Cipher cipher = Cipher.getInstance(algorithm + "/ECB/PKCS5Padding"); - cipher.init(Cipher.ENCRYPT_MODE, cipherKey); - - - cipher = Cipher.getInstance("DES/CBC/NoPadding"); - try { - cipher.init(Cipher.ENCRYPT_MODE, cipherKey); - fail("InvalidKeyException expected"); - } catch (InvalidKeyException e) { - //expected - } - } - - /** - * @tests javax.crypto.Cipher#init(int, java.security.Key, - * java.security.SecureRandom) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "init", - args = {int.class, java.security.Key.class, java.security.SecureRandom.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineInit", - args = {int.class, java.security.Key.class, java.security.SecureRandom.class} - ) - }) - public void test_initILjava_security_KeyLjava_security_SecureRandom() - throws Exception { - SecureRandom sr = new SecureRandom(); - Cipher cipher = Cipher.getInstance(algorithm + "/ECB/PKCS5Padding"); - cipher.init(Cipher.ENCRYPT_MODE, cipherKey, sr); - - cipher = Cipher.getInstance("DES/CBC/NoPadding"); - try { - cipher.init(Cipher.ENCRYPT_MODE, cipherKey, sr); - fail("InvalidKeyException expected"); - } catch (InvalidKeyException e) { - //expected - } - } - - /** - * @tests javax.crypto.Cipher#init(int, java.security.Key, - * java.security.spec.AlgorithmParameterSpec) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "init", - args = {int.class, java.security.Key.class, java.security.spec.AlgorithmParameterSpec.class} - ) - public void test_initILjava_security_KeyLjava_security_spec_AlgorithmParameterSpec() - throws Exception { - SecureRandom sr = new SecureRandom(); - Cipher cipher = null; - - byte[] iv = null; - AlgorithmParameterSpec ap = null; - - iv = new byte[8]; - sr.nextBytes(iv); - ap = new IvParameterSpec(iv); - - cipher = Cipher.getInstance(algorithm + "/CBC/PKCS5Padding"); - - cipher.init(Cipher.ENCRYPT_MODE, cipherKey, ap); - - byte[] cipherIV = cipher.getIV(); - - assertTrue("IVs differ", Arrays.equals(cipherIV, iv)); - - cipher = Cipher.getInstance("DES/CBC/NoPadding"); - try { - cipher.init(Cipher.ENCRYPT_MODE, cipherKey, ap); - fail("InvalidKeyException expected"); - } catch (InvalidKeyException e) { - //expected - } - - cipher = Cipher.getInstance("DES/CBC/NoPadding"); - ap = new RSAKeyGenParameterSpec(10, new BigInteger("10")); - - try { - cipher.init(Cipher.ENCRYPT_MODE, cipherKeyDES, ap); - fail("InvalidAlgorithmParameterException expected"); - } catch (InvalidAlgorithmParameterException e) { - //expected - } - } - - /** - * @tests javax.crypto.Cipher#init(int, java.security.Key, - * java.security.spec.AlgorithmParameterSpec, - * java.security.SecureRandom) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "init", - args = {int.class, java.security.Key.class, java.security.spec.AlgorithmParameterSpec.class, java.security.SecureRandom.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineInit", - args = {int.class, java.security.Key.class, java.security.spec.AlgorithmParameterSpec.class, java.security.SecureRandom.class} - ) - }) - public void test_initILjava_security_KeyLjava_security_spec_AlgorithmParameterSpecLjava_security_SecureRandom() - throws Exception { - SecureRandom sr = new SecureRandom(); - Cipher cipher = null; - - byte[] iv = null; - AlgorithmParameterSpec ap = null; - - iv = new byte[8]; - sr.nextBytes(iv); - ap = new IvParameterSpec(iv); - - cipher = Cipher.getInstance(algorithm + "/CBC/PKCS5Padding"); - - cipher.init(Cipher.ENCRYPT_MODE, cipherKey, ap, sr); - - byte[] cipherIV = cipher.getIV(); - - assertTrue("IVs differ", Arrays.equals(cipherIV, iv)); - cipher = Cipher.getInstance("DES/CBC/NoPadding"); - try { - cipher.init(Cipher.ENCRYPT_MODE, cipherKey, ap, sr); - fail("InvalidKeyException expected"); - } catch (InvalidKeyException e) { - //expected - } - - cipher = Cipher.getInstance("DES/CBC/NoPadding"); - ap = new RSAKeyGenParameterSpec(10, new BigInteger("10")); - - try { - cipher.init(Cipher.ENCRYPT_MODE, cipherKeyDES, ap, sr); - fail("InvalidAlgorithmParameterException expected"); - } catch (InvalidAlgorithmParameterException e) { - //expected - } - } - - /** - * @tests javax.crypto.Cipher#update(byte[], int, int) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "update", - args = {byte[].class, int.class, int.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineUpdate", - args = {byte[].class, int.class, int.class} - ) - }) - public void test_update$BII() throws Exception { - for (int index = 1; index < 4; index++) { - Cipher c = Cipher.getInstance("DESEDE/CBC/PKCS5Padding"); - - byte[] keyMaterial = loadBytes("hyts_" + "des-ede3-cbc.test" - + index + ".key"); - DESedeKeySpec keySpec = new DESedeKeySpec(keyMaterial); - SecretKeyFactory skf = SecretKeyFactory.getInstance("DESEDE"); - Key k = skf.generateSecret(keySpec); - - byte[] ivMaterial = loadBytes("hyts_" + "des-ede3-cbc.test" + index - + ".iv"); - IvParameterSpec iv = new IvParameterSpec(ivMaterial); - - c.init(Cipher.DECRYPT_MODE, k, iv); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] input = new byte[256]; - String resPath = "hyts_" + "des-ede3-cbc.test" + index - + ".ciphertext"; - File resources = Support_Resources.createTempFolder(); - Support_Resources.copyFile(resources, null, resPath); - InputStream is = Support_Resources.getStream(resPath); - - int bytesRead = is.read(input, 0, 256); - while (bytesRead > 0) { - byte[] output = c.update(input, 0, bytesRead); - if (output != null) { - baos.write(output); - } - bytesRead = is.read(input, 0, 256); - } - - byte[] output = c.doFinal(); - if (output != null) { - baos.write(output); - } - - byte[] decipheredCipherText = baos.toByteArray(); - is.close(); - - byte[] plaintextBytes = loadBytes("hyts_" + "des-ede3-cbc.test" - + index + ".plaintext"); - assertTrue("Operation produced incorrect results", Arrays.equals( - plaintextBytes, decipheredCipherText)); - }// end for - - Cipher cipher = Cipher.getInstance("DESEDE/CBC/PKCS5Padding"); - try { - cipher.update(new byte[64], 0, 32); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //expected - } - } - - /** - * @tests javax.crypto.Cipher#doFinal() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "doFinal", - args = {} - ) - public void test_doFinal() throws Exception { - for (int index = 1; index < 4; index++) { - Cipher c = Cipher.getInstance("DESEDE/CBC/PKCS5Padding"); - - byte[] keyMaterial = loadBytes("hyts_" + "des-ede3-cbc.test" - + index + ".key"); - DESedeKeySpec keySpec = new DESedeKeySpec(keyMaterial); - SecretKeyFactory skf = SecretKeyFactory.getInstance("DESEDE"); - Key k = skf.generateSecret(keySpec); - - byte[] ivMaterial = loadBytes("hyts_" + "des-ede3-cbc.test" + index - + ".iv"); - IvParameterSpec iv = new IvParameterSpec(ivMaterial); - - c.init(Cipher.ENCRYPT_MODE, k, iv); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] input = new byte[256]; - String resPath = "hyts_" + "des-ede3-cbc.test" + index - + ".plaintext"; - File resources = Support_Resources.createTempFolder(); - Support_Resources.copyFile(resources, null, resPath); - InputStream is = Support_Resources.getStream(resPath); - - int bytesRead = is.read(input, 0, 256); - while (bytesRead > 0) { - byte[] output = c.update(input, 0, bytesRead); - if (output != null) { - baos.write(output); - } - bytesRead = is.read(input, 0, 256); - } - byte[] output = c.doFinal(); - if (output != null) { - baos.write(output); - } - byte[] encryptedPlaintext = baos.toByteArray(); - is.close(); - - byte[] cipherText = loadBytes("hyts_" + "des-ede3-cbc.test" + index - + ".ciphertext"); - assertTrue("Operation produced incorrect results", Arrays.equals( - encryptedPlaintext, cipherText)); - }// end for - - byte[] b = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; - byte[] b1 = new byte[30]; - - Cipher c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - c.update(b, 0, 10, b1, 5); - try { - c.doFinal(); - fail("IllegalBlockSizeException expected"); - } catch (IllegalBlockSizeException e) { - //expected - } - - c = Cipher.getInstance("DES/CBC/NoPadding"); - try { - c.doFinal(); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //expected - } - - c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - c.doFinal(b, 0, 16, b1, 0); - - SecureRandom sr = new SecureRandom(); - byte[] iv = new byte[8]; - sr.nextBytes(iv); - AlgorithmParameterSpec ap = new IvParameterSpec(iv); - - c = Cipher.getInstance("DES/CBC/PKCS5Padding"); - c.init(Cipher.DECRYPT_MODE, cipherKeyDES, ap); - - c.update(b1, 0, 24, b, 0); - try { - c.doFinal(); - fail("BadPaddingException expected"); - } catch (BadPaddingException e) { - //expected - } - } - - private byte[] loadBytes(String resPath) { - try { - File resources = Support_Resources.createTempFolder(); - Support_Resources.copyFile(resources, null, resPath); - InputStream is = Support_Resources.getStream(resPath); - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - byte[] buff = new byte[1024]; - int readlen; - while ((readlen = is.read(buff)) > 0) { - out.write(buff, 0, readlen); - } - is.close(); - return out.toByteArray(); - } catch (IOException e) { - return null; - } - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getParameters", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineGetParameters", - args = {} - ) - }) - public void testGetParameters() throws Exception { - Cipher c = Cipher.getInstance("DES"); - assertNull(c.getParameters()); - } - - /* - * Class under test for int update(byte[], int, int, byte[], int) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "update", - args = {byte[].class, int.class, int.class, byte[].class, int.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineUpdate", - args = {byte[].class, int.class, int.class, byte[].class, int.class} - ) - }) - public void testUpdatebyteArrayintintbyteArrayint() throws Exception { - byte[] b = {1,2,3,4,5,6,7,8,9,10}; - byte[] b1 = new byte[6]; - Cipher c = Cipher.getInstance("DESede"); - - try { - c.update(b, 0, 10, b1, 5); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //expected - } - - c.init(Cipher.ENCRYPT_MODE, cipherKey); - try { - c.update(b, 0, 10, b1, 5); - fail("ShortBufferException expected"); - } catch (ShortBufferException e) { - //expected - } - - b1 = new byte[30]; - c.update(b, 0, 10, b1, 5); - } - - /* - * Class under test for int doFinal(byte[], int, int, byte[], int) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "doFinal", - args = {byte[].class, int.class, int.class, byte[].class, int.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineDoFinal", - args = {byte[].class, int.class, int.class, byte[].class, int.class} - ) - }) - public void testDoFinalbyteArrayintintbyteArrayint() throws Exception { - byte[] b = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; - byte[] b1 = new byte[30]; - - Cipher c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - try { - c.doFinal(b, 0, 10, b1, 5); - fail("IllegalBlockSizeException expected"); - } catch (IllegalBlockSizeException e) { - //expected - } - - c = Cipher.getInstance("DES/CBC/NoPadding"); - try { - c.doFinal(b, 0, 10, b1, 5); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //expected - } - - c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - c.doFinal(b, 0, 16, b1, 0); - - SecureRandom sr = new SecureRandom(); - byte[] iv = new byte[8]; - sr.nextBytes(iv); - AlgorithmParameterSpec ap = new IvParameterSpec(iv); - - c = Cipher.getInstance("DES/CBC/PKCS5Padding"); - c.init(Cipher.DECRYPT_MODE, cipherKeyDES, ap); - - try { - c.doFinal(b1, 0, 24, new byte[42], 0); - fail("BadPaddingException expected"); - } catch (BadPaddingException e) { - //expected - } - - b1 = new byte[6]; - c = Cipher.getInstance("DESede"); - c.init(Cipher.ENCRYPT_MODE, cipherKey); - try { - c.doFinal(b, 3, 6, b1, 5); - fail("No expected ShortBufferException"); - } catch (ShortBufferException e) { - //expected - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getMaxAllowedKeyLength", - args = {java.lang.String.class} - ) - public void testGetMaxAllowedKeyLength() throws NoSuchAlgorithmException { - try { - Cipher.getMaxAllowedKeyLength(null); - fail("No expected NullPointerException"); - } catch (NullPointerException e) { - } - try { - Cipher.getMaxAllowedKeyLength("//CBC/PKCS5Paddin"); - fail("No expected NoSuchAlgorithmException"); - } catch (NoSuchAlgorithmException e) { - } - try { - Cipher.getMaxAllowedKeyLength("/DES/CBC/PKCS5Paddin/1"); - fail("No expected NoSuchAlgorithmException"); - } catch (NoSuchAlgorithmException e) { - } - assertTrue(Cipher.getMaxAllowedKeyLength("/DES/CBC/PKCS5Paddin") > 0); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getMaxAllowedParameterSpec", - args = {java.lang.String.class} - ) - public void testGetMaxAllowedParameterSpec() - throws NoSuchAlgorithmException, Exception { - try { - Cipher.getMaxAllowedParameterSpec(null); - fail("No expected NullPointerException"); - } catch (NullPointerException e) { - } - try { - Cipher.getMaxAllowedParameterSpec("/DES//PKCS5Paddin"); - fail("No expected NoSuchAlgorithmException"); - } catch (NoSuchAlgorithmException e) { - } - try { - Cipher.getMaxAllowedParameterSpec("/DES/CBC/ /1"); - fail("No expected NoSuchAlgorithmException"); - } catch (NoSuchAlgorithmException e) { - } - Cipher.getMaxAllowedParameterSpec("DES/CBC/PKCS5Paddin"); - Cipher.getMaxAllowedParameterSpec("RSA"); - } - - /** - * @tests javax.crypto.Cipher#Cipher(CipherSpi cipherSpi, Provider provider, - * String transformation) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "Cipher", - args = {javax.crypto.CipherSpi.class, java.security.Provider.class, java.lang.String.class} - ) - public void test_Ctor() throws Exception { - // Regression for Harmony-1184 - try { - new testCipher(null, null, "s"); - fail("NullPointerException expected"); - } catch (NullPointerException e) { - // expected - } - - try { - new testCipher(new MyCipher(), null, "s"); - fail("NullPointerException expected for 'null' provider"); - } catch (NullPointerException e) { - // expected - } - - try { - new testCipher(null, new Provider("qwerty", 1.0, "qwerty") {}, "s"); - fail("NullPointerException expected for 'null' cipherSpi"); - } catch (NullPointerException e) { - // expected - } - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "doFinal", - args = {java.nio.ByteBuffer.class, java.nio.ByteBuffer.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineDoFinal", - args = {java.nio.ByteBuffer.class, java.nio.ByteBuffer.class} - ) - }) - public void test_doFinalLjava_nio_ByteBufferLjava_nio_ByteBuffer () - throws NoSuchAlgorithmException, NoSuchPaddingException, - InvalidKeyException, ShortBufferException, BadPaddingException, - IllegalBlockSizeException, InvalidAlgorithmParameterException { - byte[] b = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; - ByteBuffer bInput = ByteBuffer.allocate(64); - ByteBuffer bOutput = ByteBuffer.allocate(64); - - Cipher c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - bInput.put(b, 0, 10); - try { - c.doFinal(bInput, bOutput); - fail("IllegalBlockSizeException expected"); - } catch (IllegalBlockSizeException e) { - //expected - } - - c = Cipher.getInstance("DES/CBC/NoPadding"); - try { - c.doFinal(bInput, bOutput); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //expected - } - - c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - bInput = ByteBuffer.allocate(16); - bInput.put(b, 0, 16); - c.doFinal(bInput, bOutput); - - SecureRandom sr = new SecureRandom(); - byte[] iv = new byte[8]; - sr.nextBytes(iv); - AlgorithmParameterSpec ap = new IvParameterSpec(iv); - - c = Cipher.getInstance("DES/CBC/PKCS5Padding"); - c.init(Cipher.DECRYPT_MODE, cipherKeyDES, ap); - bInput = ByteBuffer.allocate(64); - - try { - c.doFinal(bOutput, bInput); - fail("BadPaddingException expected"); - } catch (BadPaddingException e) { - //expected - } - - c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - bInput.put(b, 0, 16); - try { - c.doFinal(bInput, bInput); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException e) { - //expected - } - - c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - bInput.put(b, 0, 16); - try { - c.doFinal(bInput, bOutput.asReadOnlyBuffer()); - fail("ReadOnlyBufferException expected"); - } catch (ReadOnlyBufferException e) { - //expected - } - - bInput.rewind(); - bInput.put(b, 0, 16); - bOutput = ByteBuffer.allocate(8); - c = Cipher.getInstance("DESede"); - c.init(Cipher.ENCRYPT_MODE, cipherKey); - try { - c.doFinal(bInput, bOutput); - fail("No expected ShortBufferException"); - } catch (ShortBufferException e) { - //expected - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "init", - args = {int.class, java.security.Key.class, java.security.AlgorithmParameters.class} - ) - public void test_initILjava_security_KeyLjava_security_AlgorithmParameters () - throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, - InvalidAlgorithmParameterException { - SecureRandom sr = new SecureRandom(); - byte[] iv = new byte[8]; - sr.nextBytes(iv); - AlgorithmParameterSpec ap = new IvParameterSpec(iv); - - Cipher c = Cipher.getInstance("DES/CBC/PKCS5Padding"); - c.init(Cipher.DECRYPT_MODE, cipherKeyDES, ap); - assertNotNull(c.getParameters()); - - try { - c.init(Cipher.DECRYPT_MODE, cipherKey, ap); - fail("InvalidKeyException e"); - } catch (InvalidKeyException e) { - //expected - } - - try { - c.init(Cipher.DECRYPT_MODE, cipherKeyDES, (AlgorithmParameters)null); - fail("InvalidAlgorithmParameterException e"); - } catch (InvalidAlgorithmParameterException e) { - //expected - } - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "init", - args = {int.class, java.security.Key.class, java.security.AlgorithmParameters.class, java.security.SecureRandom.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineInit", - args = {int.class, java.security.Key.class, java.security.AlgorithmParameters.class, java.security.SecureRandom.class} - ) - }) - public void test_initILjava_security_KeyLjava_security_AlgorithmParametersLjava_security_SecureRandom () - throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, - InvalidAlgorithmParameterException { - SecureRandom sr = new SecureRandom(); - byte[] iv = new byte[8]; - sr.nextBytes(iv); - AlgorithmParameterSpec ap = new IvParameterSpec(iv); - - Cipher c = Cipher.getInstance("DES/CBC/PKCS5Padding"); - c.init(Cipher.DECRYPT_MODE, cipherKeyDES, ap, sr); - assertNotNull(c.getParameters()); - - try { - c.init(Cipher.DECRYPT_MODE, cipherKey, ap, new SecureRandom()); - fail("InvalidKeyException e"); - } catch (InvalidKeyException e) { - //expected - } - - try { - c.init(Cipher.DECRYPT_MODE, cipherKeyDES, (AlgorithmParameters)null, sr); - fail("InvalidAlgorithmParameterException e"); - } catch (InvalidAlgorithmParameterException e) { - //expected - } - - c.init(Cipher.DECRYPT_MODE, cipherKeyDES, ap, (SecureRandom)null); - assertNotNull(c.getParameters()); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "init", - args = {int.class, java.security.cert.Certificate.class} - ) - public void test_initILjava_security_cert_Certificate () - throws MalformedURLException, IOException, CertificateException, - NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException { - - /* Certificate creation notes: certificate should be valid 37273 starting - * from 13 Nov 2008 - * If it brcomes invalidated regenerate it using following commands: - * 1. openssl genrsa -des3 -out test.key 1024 - * 2. openssl req -new -key test.key -out test.csr - * 3. cp test.key test.key.org - * 4. openssl rsa -in test.key.org -out test.key - * 5. openssl x509 -req -days 37273 -in test.csr -signkey test.key -out test.cert - * */ - - String certName = Support_Resources.getURL("test.cert"); - InputStream is = new URL(certName).openConnection().getInputStream(); - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - - Certificate cert = cf.generateCertificate(is); - - Cipher c = Cipher.getInstance("RSA"); - - c.init(Cipher.ENCRYPT_MODE, cert); - c = Cipher.getInstance("DES/CBC/PKCS5Padding"); - try { - c.init(Cipher.ENCRYPT_MODE, cert); - fail("InvalidKeyException expected"); - } catch (InvalidKeyException e) { - //expected - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "init", - args = {int.class, java.security.cert.Certificate.class, java.security.SecureRandom.class} - ) - public void test_initILjava_security_cert_Certificate_java_security_SecureRandom () - throws MalformedURLException, IOException, CertificateException, - NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException { - - /* Certificate creation notes: certificate should be valid 37273 starting - * from 13 Nov 2008 - * If it brcomes invalidated regenerate it using following commands: - * 1. openssl genrsa -des3 -out test.key 1024 - * 2. openssl req -new -key test.key -out test.csr - * 3. cp test.key test.key.org - * 4. openssl rsa -in test.key.org -out test.key - * 5. openssl x509 -req -days 37273 -in test.csr -signkey test.key -out test.cert - * */ - - String certName = Support_Resources.getURL("test.cert"); - InputStream is = new URL(certName).openConnection().getInputStream(); - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - - Certificate cert = cf.generateCertificate(is); - - Cipher c = Cipher.getInstance("RSA"); - - c.init(Cipher.ENCRYPT_MODE, cert, new SecureRandom()); - c = Cipher.getInstance("DES/CBC/PKCS5Padding"); - try { - c.init(Cipher.ENCRYPT_MODE, cert, new SecureRandom()); - fail("InvalidKeyException expected"); - } catch (InvalidKeyException e) { - //expected - } - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "unwrap", - args = {byte[].class, java.lang.String.class, int.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineUnwrap", - args = {byte[].class, java.lang.String.class, int.class} - ) - }) - public void test_unwrap$BLjava_lang_StringI () throws NoSuchAlgorithmException, - NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, - IllegalBlockSizeException { - SecureRandom sr = new SecureRandom(); - byte[] iv = new byte[8]; - sr.nextBytes(iv); - AlgorithmParameterSpec ap = new IvParameterSpec(iv); - - Cipher c = Cipher.getInstance("DES/CBC/PKCS5Padding"); - - c.init(Cipher.WRAP_MODE, cipherKeyDES, ap, sr); - byte[] arDES = c.wrap(cipherKeyDES); - byte[] ar = c.wrap(cipherKey); - - try { - c.unwrap(arDES, "DES", Cipher.SECRET_KEY); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //expected - } - - c.init(Cipher.UNWRAP_MODE, cipherKeyDES, ap, sr); - assertTrue(cipherKeyDES.equals(c.unwrap(arDES, "DES", Cipher.SECRET_KEY))); - assertFalse(cipherKeyDES.equals(c.unwrap(ar, "DES", Cipher.SECRET_KEY))); - - try { - c.unwrap(arDES, "RSA38", Cipher.PUBLIC_KEY); - fail("NoSuchAlgorithmException expected"); - } catch (NoSuchAlgorithmException e) { - //expected - } - - c = Cipher.getInstance("DESede/CBC/PKCS5Padding"); - c.init(Cipher.UNWRAP_MODE, cipherKey, ap, sr); - try { - c.unwrap(arDES, "DESede", Cipher.SECRET_KEY); - fail("InvalidKeyException expected"); - } catch (InvalidKeyException e) { - //expected - } - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "update", - args = {java.nio.ByteBuffer.class, java.nio.ByteBuffer.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineUpdate", - args = {java.nio.ByteBuffer.class, java.nio.ByteBuffer.class} - ) - }) - public void test_updateLjava_nio_ByteBufferLjava_nio_ByteBuffer () throws - NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, - ShortBufferException, InvalidAlgorithmParameterException { - byte[] b = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; - ByteBuffer bInput = ByteBuffer.allocate(256); - ByteBuffer bOutput = ByteBuffer.allocate(256); - - Cipher c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - bInput.put(b, 0, 10); - bInput.rewind(); - bOutput.rewind(); - c.update(bInput, bOutput); - - c = Cipher.getInstance("DES/CBC/NoPadding"); - try { - c.update(bInput, bOutput); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //expected - } - - c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - bInput = ByteBuffer.allocate(16); - bInput.put(b, 0, 16); - bInput.rewind(); - bOutput.rewind(); - c.update(bInput, bOutput); - - SecureRandom sr = new SecureRandom(); - byte[] iv = new byte[8]; - sr.nextBytes(iv); - AlgorithmParameterSpec ap = new IvParameterSpec(iv); - - c = Cipher.getInstance("DES/CBC/PKCS5Padding"); - c.init(Cipher.DECRYPT_MODE, cipherKeyDES, ap); - bInput = ByteBuffer.allocate(64); - - c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - bInput.put(b, 0, 16); - bInput.rewind(); - try { - c.update(bInput, bInput); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException e) { - //expected - } - - c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - bInput.put(b, 0, 16); - bInput.rewind(); - bOutput.rewind(); - try { - c.update(bInput, bOutput.asReadOnlyBuffer()); - fail("ReadOnlyBufferException expected"); - } catch (ReadOnlyBufferException e) { - //expected - } - - bInput.rewind(); - bInput.put(b, 0, 16); - bInput.rewind(); - bOutput = ByteBuffer.allocate(8); - c = Cipher.getInstance("DESede"); - c.init(Cipher.ENCRYPT_MODE, cipherKey); - try { - c.update(bInput, bOutput); - fail("No expected ShortBufferException"); - } catch (ShortBufferException e) { - //expected - } - } - - class Mock_Key implements Key { - public String getAlgorithm() { - return null; - } - - public byte[] getEncoded() { - return null; - } - - public String getFormat() { - return null; - } - - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "wrap", - args = {java.security.Key.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineWrap", - args = {java.security.Key.class} - ) - }) - public void test_wrap_java_security_Key () throws NoSuchAlgorithmException, - NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, - InvalidAlgorithmParameterException, MalformedURLException, IOException, - CertificateException { - SecureRandom sr = new SecureRandom(); - byte[] iv = new byte[8]; - sr.nextBytes(iv); - AlgorithmParameterSpec ap = new IvParameterSpec(iv); - - Cipher c = Cipher.getInstance("DES/CBC/PKCS5Padding"); - - c.init(Cipher.WRAP_MODE, cipherKeyDES, ap, sr); - assertNotNull(c.wrap(cipherKeyDES)); - assertNotNull(c.wrap(cipherKey)); - String certName = Support_Resources.getURL("test.cert"); - InputStream is = new URL(certName).openConnection().getInputStream(); - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - - Certificate cert = cf.generateCertificate(is); - assertNotNull(c.wrap(cert.getPublicKey())); - - c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.WRAP_MODE, cipherKeyDES, ap, sr); - try { - assertNotNull(c.wrap(cert.getPublicKey())); - fail("IllegalBlockSizeException expected"); - } catch (IllegalBlockSizeException e) { - //expected - } - - c.init(Cipher.DECRYPT_MODE, cipherKeyDES, ap, sr); - - try { - c.wrap(cipherKeyDES); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //expected - } - - c.init(Cipher.WRAP_MODE, cipherKeyDES, ap, sr); - try { - c.wrap(new Mock_Key()); - fail("InvalidKeyException expected"); - } catch (InvalidKeyException e) { - //expected - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "doFinal", - args = {byte[].class, int.class} - ) - public void test_doFinal$BI() throws Exception { - byte[] b = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; - byte[] b1 = new byte[30]; - - Cipher c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - c.update(b, 0, 10); - try { - c.doFinal(b1, 5); - fail("IllegalBlockSizeException expected"); - } catch (IllegalBlockSizeException e) { - //expected - } - - c = Cipher.getInstance("DES/CBC/NoPadding"); - try { - c.doFinal(b1, 5); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //expected - } - - c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - c.update(b, 3, 8); - c.doFinal(b1, 0); - - SecureRandom sr = new SecureRandom(); - byte[] iv = new byte[8]; - sr.nextBytes(iv); - AlgorithmParameterSpec ap = new IvParameterSpec(iv); - - c = Cipher.getInstance("DES/CBC/PKCS5Padding"); - c.init(Cipher.DECRYPT_MODE, cipherKeyDES, ap); - - c.update(b1, 0, 24); - try { - c.doFinal(b, 0); - fail("BadPaddingException expected"); - } catch (BadPaddingException e) { - //expected - } - - b1 = new byte[6]; - c = Cipher.getInstance("DESede"); - c.init(Cipher.ENCRYPT_MODE, cipherKey); - c.update(b, 3, 6); - try { - c.doFinal(b1, 5); - fail("No expected ShortBufferException"); - } catch (ShortBufferException e) { - //expected - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "doFinal", - args = {byte[].class} - ) - public void test_doFinal$B() throws Exception { - byte[] b1 = new byte[32]; - byte[] bI1 = {1,2,3,4,5,6,7,8,9,10}; - byte[] bI2 = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; - byte[] bI3 = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; - byte[] bI4 = {1,2,3}; - - Cipher c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - try { - c.doFinal(bI1); - fail("IllegalBlockSizeException expected"); - } catch (IllegalBlockSizeException e) { - //expected - } - - c = Cipher.getInstance("DES/CBC/NoPadding"); - try { - c.doFinal(bI1); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //expected - } - - c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - c.doFinal(bI2); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - c.doFinal(bI3, 0, 16, b1, 0); - - SecureRandom sr = new SecureRandom(); - byte[] iv = new byte[8]; - sr.nextBytes(iv); - AlgorithmParameterSpec ap = new IvParameterSpec(iv); - - c = Cipher.getInstance("DES/CBC/PKCS5Padding"); - c.init(Cipher.DECRYPT_MODE, cipherKeyDES, ap); - - try { - c.doFinal(b1); - fail("BadPaddingException expected"); - } catch (BadPaddingException e) { - //expected - } - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "doFinal", - args = {byte[].class, int.class, int.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = CipherSpi.class, - method = "engineDoFinal", - args = {byte[].class, int.class, int.class} - ) - }) - public void test_doFinal$BII() throws Exception { - byte[] b = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; - byte[] b1 = new byte[30]; - - Cipher c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - try { - c.doFinal(b, 0, 10); - fail("IllegalBlockSizeException expected"); - } catch (IllegalBlockSizeException e) { - //expected - } - - c = Cipher.getInstance("DES/CBC/NoPadding"); - try { - c.doFinal(b, 0, 10); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //expected - } - - c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - c.doFinal(b, 0, 16); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - c.doFinal(b, 0, 16, b1, 0); - - SecureRandom sr = new SecureRandom(); - byte[] iv = new byte[8]; - sr.nextBytes(iv); - AlgorithmParameterSpec ap = new IvParameterSpec(iv); - - c = Cipher.getInstance("DES/CBC/PKCS5Padding"); - c.init(Cipher.DECRYPT_MODE, cipherKeyDES, ap); - - try { - c.doFinal(b1, 0, 24); - fail("BadPaddingException expected"); - } catch (BadPaddingException e) { - //expected - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "doFinal", - args = {byte[].class, int.class, int.class, byte[].class} - ) - public void test_doFinal$BII$B() throws Exception { - byte[] b = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; - byte[] b1 = new byte[30]; - - Cipher c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - try { - c.doFinal(b, 0, 10, b1); - fail("IllegalBlockSizeException expected"); - } catch (IllegalBlockSizeException e) { - //expected - } - - c = Cipher.getInstance("DES/CBC/NoPadding"); - try { - c.doFinal(b, 0, 10, b1); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //expected - } - - c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - c.doFinal(b, 0, 16, b1); - - SecureRandom sr = new SecureRandom(); - byte[] iv = new byte[8]; - sr.nextBytes(iv); - AlgorithmParameterSpec ap = new IvParameterSpec(iv); - - c = Cipher.getInstance("DES/CBC/PKCS5Padding"); - c.init(Cipher.DECRYPT_MODE, cipherKeyDES, ap); - - try { - c.doFinal(b1, 0, 24, new byte[42]); - fail("BadPaddingException expected"); - } catch (BadPaddingException e) { - //expected - } - - b1 = new byte[6]; - c = Cipher.getInstance("DESede"); - c.init(Cipher.ENCRYPT_MODE, cipherKey); - try { - c.doFinal(b, 3, 6, b1); - fail("No expected ShortBufferException"); - } catch (ShortBufferException e) { - //expected - } - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks exception", - method = "update", - args = {byte[].class} - ) - public void test_update$B() throws Exception { - Cipher cipher = Cipher.getInstance("DESEDE/CBC/PKCS5Padding"); - try { - cipher.update(new byte[64]); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //expected - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "update", - args = {byte[].class, int.class, int.class, byte[].class} - ) - public void test_() throws Exception { - byte[] b = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; - byte[] b1 = new byte[30]; - - Cipher c = Cipher.getInstance("DES/CBC/NoPadding"); - - try { - c.update(b, 0, 10, b1); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //expected - } - - c = Cipher.getInstance("DES/CBC/NoPadding"); - c.init(Cipher.ENCRYPT_MODE, cipherKeyDES); - c.update(b, 0, 16, b1); - - b1 = new byte[3]; - - try { - c.update(b, 3, 15, b1); - fail("No expected ShortBufferException"); - } catch (ShortBufferException e) { - //expected - } - } - - class testCipher extends Cipher { - testCipher(CipherSpi c, Provider p, String s) { - super(c, p, s); - } - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/EncryptedPrivateKeyInfoTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/EncryptedPrivateKeyInfoTest.java deleted file mode 100644 index d3d085793..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/EncryptedPrivateKeyInfoTest.java +++ /dev/null @@ -1,2252 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vladimir N. Molotkov -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.io.IOException; -import java.security.AlgorithmParameters; -import java.security.AlgorithmParametersSpi; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.KeyPair; -import java.security.KeyPairGenerator; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.Provider; -import java.security.Security; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.InvalidParameterSpecException; -import java.security.spec.PKCS8EncodedKeySpec; -import java.util.Arrays; - -import javax.crypto.BadPaddingException; -import javax.crypto.Cipher; -import javax.crypto.EncryptedPrivateKeyInfo; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.KeyGenerator; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.SecretKeyFactory; -import javax.crypto.spec.PBEKeySpec; -import javax.crypto.spec.PBEParameterSpec; - -import org.apache.harmony.crypto.tests.support.EncryptedPrivateKeyInfoData; - -import junit.framework.TestCase; - -@TestTargetClass(EncryptedPrivateKeyInfo.class) -/** - * Test for EncryptedPrivateKeyInfo class. - * - * All binary data for this test were generated using BEA JRockit j2sdk1.4.2_04 - * (http://www.bea.com) with security providers list extended by Bouncy Castle's - * one (http://www.bouncycastle.org) - */ -public class EncryptedPrivateKeyInfoTest extends TestCase { - - private static final Provider[] provider = Security.getProviders(); - - /** - * Algorithm names/transformations used in roundtrip tests of - * getKeySpec(...) methods - */ - private static final String[][] algName = { - // AES - { "AES", null}, - // {"AES", "AES/ECB/PKCS5Padding"}, - // {"AES", "AES/CBC/PKCS5Padding"}, - // {"AES", "AES/OFB/PKCS5Padding"}, - // {"AES", "AES/CFB/PKCS5Padding"}, - // {"2.16.840.1.101.3.4.1.1", null}, - // {"2.16.840.1.101.3.4.1.2", null}, - // {"2.16.840.1.101.3.4.1.3", null}, - // {"2.16.840.1.101.3.4.1.4", null}, - // {"2.16.840.1.101.3.4.1.5", null}, - // {"2.16.840.1.101.3.4.1.21", null}, - // {"2.16.840.1.101.3.4.1.22", null}, - // {"2.16.840.1.101.3.4.1.23", null}, - // {"2.16.840.1.101.3.4.1.24", null}, - // {"2.16.840.1.101.3.4.1.25", null}, - // {"2.16.840.1.101.3.4.1.41", null}, - // {"2.16.840.1.101.3.4.1.42", null}, - // {"2.16.840.1.101.3.4.1.43", null}, - // {"2.16.840.1.101.3.4.1.44", null}, - // {"2.16.840.1.101.3.4.1.45", null}, - - // Blowfish - // NO OIDs for Blowfish defined (?) - { "Blowfish", null }, - // {"Blowfish","Blowfish/CBC/PKCS5Padding"}, - // {"Blowfish","Blowfish/CFB/PKCS5Padding"}, - // {"Blowfish","Blowfish/OFB/PKCS5Padding"}, - // {"Blowfish","Blowfish/PCBC/PKCS5Padding"}, - - // DES: OIW OIDs only - // {iso(1) identified-organization(3) oiw(14) secsig(3) - // algorithms(2) desECB(6)} - // 1.3.14.3.2.6 - // 1.3.14.3.2.7 - // 1.3.14.3.2.8 - // 1.3.14.3.2.9 - { "DES", null }, - // {"DES", "DES/CBC/PKCS5Padding"}, - // {"DES","DES/CFB/PKCS5Padding"}, - // {"DES","DES/OFB/PKCS5Padding"}, - // {"DES","DES/PCBC/PKCS5Padding"}, - - // DESede (=TripleDes) - //{iso(1) identified-organization(3) oiw(14) secsig(3) - // algorithms(2) desEDE(17)} - // 1.3.14.3.2.17 - // {"DESede",null}, - // {"DESede","DESede/CBC/PKCS5Padding"}, - // {"DESede","DESede/CFB/PKCS5Padding"}, - // {"DESede","DESede/OFB/PKCS5Padding"}, - // {"DESede","DESede/PCBC/PKCS5Padding"}, - { "TripleDES", null }, - // {"TripleDES","TripleDES/CBC/PKCS5Padding"}, - // {"TripleDES","TripleDES/CFB/PKCS5Padding"}, - // {"TripleDES","TripleDES/OFB/PKCS5Padding"}, - // {"TripleDES","TripleDES/PCBC/PKCS5Padding"}, - - // PBEWithAnd - { "PBEWithMD5AndTripleDES", null }, - // {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-5(5) - // pbeWithMD5AndDES-CBC(3)} - { "PBEWithMD5AndDES", "PBEWithMD5AndDES/CBC/PKCS5Padding", "PBEWithMD5AndDES"}, - { "PBEWithMD5AndDES", null, "PBEWithMD5AndDES"}, { "PBEWithHmacSHA1AndDESede", null }, - // more oids: - // {iso(1) member-body(2) us(840) nortelnetworks(113533) entrust(7) - // algorithms(66) pbeWithMD5AndCAST5-CBC(12)} - // - // also named pbeWithSHAAnd128BitRC4, pbeWithSHA1And128BitRC4: - // {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-12(12) - // pkcs-12-PbeIds(1) pkcs-12-OfflineTransportMode(1)} - // - // {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-12(12) - // pkcs-12-PbeIds(1)} + - // pbeWithSHAAnd40BitRC4(2) pbeWithSHAAnd3-KeyTripleDES-CBC(3) - // pbeWithSHAAnd2-KeyTripleDES-CBC(4) pbeWithSHAAnd128BitRC2-CBC(5) - // pbeWithSHAAnd40BitRC2-CBC(6) - - // DiffieHellman - { "DiffieHellman", null }, // 1.2.840.10046.2.1 - // {"DH",null}, // 1.2.840.10046.2.1 - // {"1.2.840.113549.1.3.1", null}, - - { "DSA", null }, // 1.2.840.10040.4.1 - - { "RC2", null }, - - { "RC4", null }, - - { "RC5", null }, - - // {"1.2.840.113549.1.12.1.1",null}, - // {"1.2.840.113549.1.12.1.2",null}, - //{ "1.2.840.113549.1.12.1.3", null, "PBEWithSHA1AndDESede"}, - //{ "PBEWithSHA1AndDESede", null, "PBEWithSHA1AndDESede"}, - // {"1.2.840.113549.1.12.1.4",null}, - // {"1.2.840.113549.1.12.1.5",null}, - // {"1.2.840.113549.1.12.1.6",null}, - // {"ELGAMAL/PKCS1", "ELGAMAL/ECB/PKCS1PADDING"}, - // {"ELGAMAL/PKCS1","ELGAMAL/NONE/PKCS1PADDING"}, - // {"PBEWITHSHAAND3-KEYTRIPLEDES-CBC", null}, - // {"PBEWITHSHA1ANDDESEDE", null}, - // {"PBEWithSHAAnd3KeyTripleDES",null}, - // {"PBEWITHSHAAND3-KEYTRIPLEDES-CBC",null}, - // - // {"RC5-32",null}, - // - // {"RSA/1", "RSA/1/PKCS1PADDING"}, - // {"RSA/2", "RSA/2/PKCS1PADDING"}, - // {"RSA/ISO9796-1", "RSA/ECB/ISO9796-1PADDING"}, - // {"RSA", "RSA/ECB/NOPADDING"}, - // {"RSA/OAEP", "RSA/ECB/OAEPPADDING"}, - // {"RSA/PKCS1", "RSA/ECB/PKCS1PADDING"}, - // {"RSA/ISO9796-1", "RSA/NONE/ISO9796-1PADDING"}, - // {"RSA", "RSA/NONE/NOPADDING"}, - // {"RSA/OAEP", "RSA/NONE/OAEPPADDING"}, - // {"RSA/PKCS1", "RSA/NONE/PKCS1PADDING"}, - // {"RSA",null}, // 1.2.840.113549.1.1.1 - // {"1.2.840.113549.1.1.1", null}, - }; - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getAlgName", - args = {} - ) - public void test_getAlgName () { - boolean performed = false; - for (int i = 0; i < algName.length; i++) { - try { - // generate test data - TestDataGenerator g = new TestDataGenerator(algName[i][0], - algName[i][1], privateKeyInfoDamaged, null); - - // create test object - EncryptedPrivateKeyInfo epki; - if (g.ap() == null) { - epki = new EncryptedPrivateKeyInfo(algName[i][0], g.ct()); - } else { - epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct()); - } - - // call methods under test - if (algName[i].length == 3) { - assertEquals(algName[i][2], epki.getAlgName()); - } - - performed = true; - } catch (TestDataGenerator.AllowedFailure allowedFailure) { - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - /** - * Test #1 for EncryptedPrivateKeyInfo(byte[]) constructor - *
- * Assertion: creates EncryptedPrivateKeyInfo instance
- * Test preconditions: valid parameters passed
- * Expected: must pass without any exceptions - * - * @throws IOException - * @throws NoSuchAlgorithmException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(byte[]) constructor.", - method = "EncryptedPrivateKeyInfo", - args = {byte[].class} - ) - public final void testEncryptedPrivateKeyInfobyteArray1() throws Exception { - new EncryptedPrivateKeyInfo(EncryptedPrivateKeyInfoData - .getValidEncryptedPrivateKeyInfoEncoding("DH")); - } - - /** - * Test #2 for EncryptedPrivateKeyInfo(byte[]) constructor - *
- * Assertion: NullPointerException if encoding is - * null
- * Test preconditions: null passed as a parameter
- * Expected: NullPointerException - * - * @throws IOException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(byte[]) constructor.", - method = "EncryptedPrivateKeyInfo", - args = {byte[].class} - ) - public final void testEncryptedPrivateKeyInfobyteArray2() - throws IOException { - try { - new EncryptedPrivateKeyInfo(null); - fail(getName() + ": NullPointerException has not been thrown"); - } catch (NullPointerException ok) { - } - } - - /** - * Test #3 for EncryptedPrivateKeyInfo(byte[]) constructor - *
- * Assertion: IOException if encoding is wrong
- * Test preconditions: wrong encoding passed as a parameter
- * Expected: IOException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(byte[]) constructor.", - method = "EncryptedPrivateKeyInfo", - args = {byte[].class} - ) - public final void testEncryptedPrivateKeyInfobyteArray3() { - try { - new EncryptedPrivateKeyInfo(new byte[0]); - fail(getName() + ": IOException has not been thrown"); - } catch (IOException ok) { - } - } - - /** - * Test #4 for EncryptedPrivateKeyInfo(byte[]) constructor - *
- * Assertion: IOException if encoding is wrong
- * Test preconditions: wrong encoding passed as a parameter
- * Expected: IOException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(byte[]) constructor.", - method = "EncryptedPrivateKeyInfo", - args = {byte[].class} - ) - public final void testEncryptedPrivateKeyInfobyteArray4() { - try { - new EncryptedPrivateKeyInfo(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10 }); - fail(getName() + ": IOException has not been thrown"); - } catch (IOException ok) { - } - } - - /** - * Test #5 for EncryptedPrivateKeyInfo(byte[]) constructor - *
- * Assertion: IOException if encoding is wrong
- * Test preconditions: wrong encoding passed as a parameter
- * Expected: IOException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(byte[]) constructor.", - method = "EncryptedPrivateKeyInfo", - args = {byte[].class} - ) - public final void testEncryptedPrivateKeyInfobyteArray5() throws Exception { - byte[] enc = null; - try { - // 1: get valid encoding - enc = EncryptedPrivateKeyInfoData - .getValidEncryptedPrivateKeyInfoEncoding("DSA"); - - // ... and corrupt it (set wrong alg OID length) - enc[9] = (byte) 6; - - new EncryptedPrivateKeyInfo(enc); - fail(getName() + "(1): IOException has not been thrown"); - } catch (IOException ok) { - } - - try { - // 2: get valid encoding - enc = EncryptedPrivateKeyInfoData - .getValidEncryptedPrivateKeyInfoEncoding("DSA"); - // ... and corrupt it (set wrong encrypted data tag) - enc[307] = (byte) 6; - new EncryptedPrivateKeyInfo(enc); - fail(getName() + "(2): IOException has not been thrown"); - } catch (IOException ok) { - } - - try { - // 3: get valid encoding - enc = EncryptedPrivateKeyInfoData - .getValidEncryptedPrivateKeyInfoEncoding("DSA"); - // ... and corrupt it (set wrong encrypted data length) - enc[310] = (byte) 1; - new EncryptedPrivateKeyInfo(enc); - fail(getName() + "(3): IOException has not been thrown"); - } catch (IOException ok) { - } - - try { - // 4: get valid encoding - enc = EncryptedPrivateKeyInfoData - .getValidEncryptedPrivateKeyInfoEncoding("DSA"); - // ... and corrupt it (set wrong tag for alg params sequence) - enc[17] = (byte) 0x29; - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(enc); - - if (epki.getAlgParameters() == null) { - // This kind of encoding corruption can - // be only determined while AlgorithmParameters - // initialization BUT No AlgorithmParameters instance - // available for algName0[i][0]. - // So just skip this sub test - } else { - fail(getName() + "(4): IOException has not been thrown"); - } - - } catch (IOException ok) { - } - - try { - // 5: get valid encoding - enc = EncryptedPrivateKeyInfoData - .getValidEncryptedPrivateKeyInfoEncoding("DSA"); - // ... and corrupt it (set wrong length for alg params sequence) - enc[20] = (byte) 0x1d; - new EncryptedPrivateKeyInfo(enc); - fail(getName() + "(5): IOException has not been thrown"); - } catch (IOException ok) { - } - - try { - // 6: get valid encoding - enc = EncryptedPrivateKeyInfoData - .getValidEncryptedPrivateKeyInfoEncoding("DSA"); - // ... and corrupt it (set wrong length for alg params sequence) - enc[20] = (byte) 0x1f; - new EncryptedPrivateKeyInfo(enc); - fail(getName() + "(6): IOException has not been thrown"); - } catch (IOException ok) { - } - } - - /** - * Test #6 for EncryptedPrivateKeyInfo(byte[]) constructor - *
- * Assertion: byte array is copied to prevent subsequent modification
- * Test preconditions: valid array passed then modified
- * Expected: getEncoded(), invoked after above modification, must return - * array as it was before the modification - * - * @throws IOException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(byte[]) constructor.", - method = "EncryptedPrivateKeyInfo", - args = {byte[].class} - ) - public final void testEncryptedPrivateKeyInfobyteArray6() throws Exception { - byte[] encoded = EncryptedPrivateKeyInfoData - .getValidEncryptedPrivateKeyInfoEncoding("DSA"); - byte[] encodedCopy = encoded.clone(); - // pass valid array - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(encodedCopy); - // modify array passed - encodedCopy[9] = (byte) 6; - // check that internal state has not been affected - assertTrue(Arrays.equals(encoded, epki.getEncoded())); - } - - /** - * Test #1 for EncryptedPrivateKeyInfo(String, byte[]) - * constructor
- * Assertion: creates EncryptedPrivateKeyInfo instance
- * Test preconditions: valid parameters passed
- * Expected: must pass without any exceptions - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(String, byte[]) constructor.", - method = "EncryptedPrivateKeyInfo", - args = {java.lang.String.class, byte[].class} - ) - public final void testEncryptedPrivateKeyInfoStringbyteArray1() { - boolean performed = false; - - for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { - try { - new EncryptedPrivateKeyInfo( - EncryptedPrivateKeyInfoData.algName0[i][0], - EncryptedPrivateKeyInfoData.encryptedData); - performed = true; - } catch (NoSuchAlgorithmException allowed) { - } - } - - assertTrue("Test not performed", performed); - } - - /** - * Test #2 for EncryptedPrivateKeyInfo(String, byte[]) - * constructor
- * Assertion: NoSuchAlgorithmException- if the specified - * algorithm is not supported
- * Test preconditions: pass nonexistent algorithm name
- * Expected: NoSuchAlgorithmException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(String, byte[]) constructor.", - method = "EncryptedPrivateKeyInfo", - args = {java.lang.String.class, byte[].class} - ) - public final void testEncryptedPrivateKeyInfoStringbyteArray2() { - try { - new EncryptedPrivateKeyInfo("bla-bla", - EncryptedPrivateKeyInfoData.encryptedData); - fail(getName() + ": NoSuchAlgorithmException has not been thrown"); - } catch (NoSuchAlgorithmException ok) { - } - - try { - new EncryptedPrivateKeyInfo("", - EncryptedPrivateKeyInfoData.encryptedData); - fail(getName() + ": NoSuchAlgorithmException has not been thrown"); - } catch (NoSuchAlgorithmException ok) { - } - } - - /** - * Test #3 for EncryptedPrivateKeyInfo(String, byte[]) - * constructor
- * Assertion: NullPointerException- if the specified - * algorithm or encrypted data is null
- * Test preconditions: pass null as algorithm name then as - * encrypted data
- * Expected: NullPointerException in both cases - * - * @throws NoSuchAlgorithmException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(String, byte[]) constructor.", - method = "EncryptedPrivateKeyInfo", - args = {java.lang.String.class, byte[].class} - ) - public final void testEncryptedPrivateKeyInfoStringbyteArray3() - throws NoSuchAlgorithmException { - // pass null as name - try { - new EncryptedPrivateKeyInfo((String) null, - EncryptedPrivateKeyInfoData.encryptedData); - fail(getName() + ": NullPointerException has not been thrown"); - } catch (NullPointerException ok) { - } - - // pass null as encrypted data - try { - new EncryptedPrivateKeyInfo("DSA", null); - fail(getName() + ": NullPointerException has not been thrown"); - } catch (NullPointerException ok) { - } - } - - /** - * Test #4 for EncryptedPrivateKeyInfo(String, byte[]) - * constructor
- * Assertion: IllegalArgumentException- if encrypted data is - * empty, i.e. 0-length
- * Test preconditions: pass empty encrypted data
- * Expected: IllegalArgumentException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(String, byte[]) constructor.", - method = "EncryptedPrivateKeyInfo", - args = {java.lang.String.class, byte[].class} - ) - public final void testEncryptedPrivateKeyInfoStringbyteArray4() - throws Exception { - try { - new EncryptedPrivateKeyInfo("DSA", new byte[] {}); - fail(getName() + ": IllegalArgumentException has not been thrown"); - } catch (IllegalArgumentException ok) { - } - } - - /** - * Test #5 for EncryptedPrivateKeyInfo(String, byte[]) - * constructor
- * Assertion: byte array is copied to prevent subsequent modification
- * Test preconditions: valid array passed then modified
- * Expected: getEncryptedData(), invoked after above modification, must - * return array as it was before the modification - * - * @throws IOException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(String, byte[]) constructor.", - method = "EncryptedPrivateKeyInfo", - args = {java.lang.String.class, byte[].class} - ) - public final void testEncryptedPrivateKeyInfoStringbyteArray5() - throws Exception { - byte[] encryptedDataCopy = EncryptedPrivateKeyInfoData.encryptedData - .clone(); - // pass valid array - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo("DSA", - encryptedDataCopy); - // modify array passed - encryptedDataCopy[0] = (byte) 6; - // check that internal state has not been affected - assertTrue(Arrays.equals(EncryptedPrivateKeyInfoData.encryptedData, - epki.getEncryptedData())); - } - - /** - * @tests javax/crypto/EncryptedPrivateKeyInfo(String, byte[]) - * Checks exception order - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(String, byte[]) constructor.", - method = "EncryptedPrivateKeyInfo", - args = {java.lang.String.class, byte[].class} - ) - public final void testEncryptedPrivateKeyInfoStringbyteArray6() { - //Regression for HARMONY-768 - try { - new EncryptedPrivateKeyInfo("0", new byte[] {}); - fail("NoSuchAlgorithmException expected"); - } catch (NoSuchAlgorithmException e) { - //expected - } - } - - class Mock_AlgorithmParameters extends AlgorithmParameters { - protected Mock_AlgorithmParameters(AlgorithmParametersSpi paramSpi, Provider provider, String algorithm) { - super(paramSpi, provider, algorithm); - } - } - -/** - * Test #1 for - * EncryptedPrivateKeyInfo(java.security.AlgorithmParameters, byte[]) - * - * constructor
- * Assertion: creates EncryptedPrivateKeyInfo instance
- * Test preconditions: valid parameters passed
- * Expected: must pass without any exceptions - * - * @throws IOException - * @throws NoSuchAlgorithmException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Functionality checked. NoSuchAlgorithmException should be tested for complete tests subset.", - method = "EncryptedPrivateKeyInfo", - args = {java.security.AlgorithmParameters.class, byte[].class} - ) - public final void testEncryptedPrivateKeyInfoAlgorithmParametersbyteArray1() - throws IOException, NoSuchAlgorithmException { - AlgorithmParameters ap = null; - - boolean performed = false; - for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { - try { - ap = AlgorithmParameters - .getInstance(EncryptedPrivateKeyInfoData.algName0[i][0]); - // use pregenerated AlgorithmParameters encodings - ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding( - EncryptedPrivateKeyInfoData.algName0[i][0])); - - new EncryptedPrivateKeyInfo(ap, - EncryptedPrivateKeyInfoData.encryptedData); - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - - ap = new Mock_AlgorithmParameters(null, null, "Wrong alg name"); - - try { - new EncryptedPrivateKeyInfo(ap, - EncryptedPrivateKeyInfoData.encryptedData); - fail("NoSuchAlgorithmException expected"); - } catch (NoSuchAlgorithmException e) { - //expected - } - } - - /** - * Test #2 for - * EncryptedPrivateKeyInfo(java.security.AlgorithmParameters, byte[]) - * - * constructor
- * Assertion: NullPointerException- if the specified - * algorithm parameters or encrypted data is null
- * Test preconditions: pass null as algorithm parameters then - * as encrypted data
- * Expected: NullPointerException in both cases - * - * @throws NoSuchAlgorithmException - * @throws IOException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "NullPointerException checked.", - method = "EncryptedPrivateKeyInfo", - args = {java.security.AlgorithmParameters.class, byte[].class} - ) - public final void testEncryptedPrivateKeyInfoAlgorithmParametersbyteArray2() - throws NoSuchAlgorithmException, IOException { - // 1: pass null as AlgorithmParameters - try { - new EncryptedPrivateKeyInfo((AlgorithmParameters) null, - EncryptedPrivateKeyInfoData.encryptedData); - fail(getName() + ": NullPointerException has not been thrown"); - } catch (NullPointerException ok) { - } - - // 2: pass null as encrypted data - try { - AlgorithmParameters ap = AlgorithmParameters.getInstance("DSA"); - // use pregenerated AlgorithmParameters encodings - ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding("DSA")); - new EncryptedPrivateKeyInfo(ap, null); - fail(getName() + ": NullPointerException has not been thrown"); - } catch (NullPointerException ok) { - } - } - - /** - * Test #3 for - * EncryptedPrivateKeyInfo(java.security.AlgorithmParameters, byte[]) - * - * constructor
- * Assertion: IllegalArgumentException- if encrypted data is - * empty, i.e. 0-length
- * Test preconditions: pass empty encrypted data
- * Expected: IllegalArgumentException - * - * @throws NoSuchAlgorithmException - * @throws IOException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "IllegalArgumentException checked.", - method = "EncryptedPrivateKeyInfo", - args = {java.security.AlgorithmParameters.class, byte[].class} - ) - public final void testEncryptedPrivateKeyInfoAlgorithmParametersbyteArray3() - throws Exception { - try { - AlgorithmParameters ap = AlgorithmParameters.getInstance("DSA"); - // use pregenerated AlgorithmParameters encodings - ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding("DSA")); - - new EncryptedPrivateKeyInfo(ap, new byte[] {}); - fail(getName() + ": IllegalArgumentException has not been thrown"); - - } catch (IllegalArgumentException ok) { - } - } - - /** - * Test #4 for - * EncryptedPrivateKeyInfo(java.security.AlgorithmParameters, byte[]) - * - * constructor
- * Assertion: byte array is copied to prevent subsequent modification
- * Test preconditions: valid array passed then modified
- * Expected: getEncryptedData(), invoked after above modification, must - * return array as it was before the modification - * - * @throws IOException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Functionality checked.", - method = "EncryptedPrivateKeyInfo", - args = {java.security.AlgorithmParameters.class, byte[].class} - ) - public final void testEncryptedPrivateKeyInfoAlgorithmParametersbyteArray4() - throws Exception { - AlgorithmParameters ap = AlgorithmParameters.getInstance("DSA"); - // use pregenerated AlgorithmParameters encodings - ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding("DSA")); - - byte[] encryptedDataCopy = EncryptedPrivateKeyInfoData.encryptedData.clone(); - // pass valid array - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap, - encryptedDataCopy); - - // modify array passed - encryptedDataCopy[0] = (byte) 6; - - // check that internal state has not been affected - assertTrue(Arrays.equals(EncryptedPrivateKeyInfoData.encryptedData, - epki.getEncryptedData())); - } - - /** - * Test #1 for getAlgParameters() method
- * Assertion: returns the algorithm parameters
- * Test preconditions: test object created using ctor which takes encoded - * form as the only parameter; encoded form passed contains algorithm - * parameters encoding
- * Expected: corresponding algorithm parameters must be returned - * - * @throws IOException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getAlgParameters method.", - method = "getAlgParameters", - args = {} - ) - public final void testGetAlgParameters01() throws IOException { - boolean performed = false; - for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { - try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - EncryptedPrivateKeyInfoData - .getValidEncryptedPrivateKeyInfoEncoding( - EncryptedPrivateKeyInfoData.algName0[i][0])); - - AlgorithmParameters apar = epki.getAlgParameters(); - if (apar == null) { - continue; - } - - // check that method under test returns - // parameters with the same encoded form - assertTrue(Arrays - .equals( - EncryptedPrivateKeyInfoData - .getParametersEncoding(EncryptedPrivateKeyInfoData.algName0[i][0]), - apar.getEncoded())); - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getAlgParameters method.", - method = "getAlgParameters", - args = {} - ) - public final void testGetAlgParameters01_01() throws Exception { - byte[] validEncodingWithUnknownAlgOID = EncryptedPrivateKeyInfoData - .getValidEncryptedPrivateKeyInfoEncoding("DH"); - // correct oid value - validEncodingWithUnknownAlgOID[18] = 0; - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - validEncodingWithUnknownAlgOID); - - assertNull(epki.getAlgParameters()); - } - - /** - * Test #2 for getAlgParameters() method
- * Assertion: returns the algorithm parameters
- * Test preconditions: test object created using ctor which takes encoded - * form as the only parameter; encoded form passed does not contain - * algorithm parameters encoding
- * Expected: null must be returned - * - * @throws IOException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getAlgParameters method.", - method = "getAlgParameters", - args = {} - ) - public final void testGetAlgParameters02() throws IOException { - boolean performed = false; - for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { - try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - EncryptedPrivateKeyInfoData - .getValidEncryptedPrivateKeyInfoEncoding( - EncryptedPrivateKeyInfoData.algName0[i][0], - false)); - - // check that method under test returns null - assertNull(epki.getAlgParameters()); - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - /** - * Test #3 for getAlgParameters() method
- * Assertion: returns the algorithm parameters
- * Test #6 for EncryptedPrivateKeyInfo(String, byte[]) - * constructor
- * Assertion: ...This constructor will use null as the value of the - * algorithm parameters.
- * Test preconditions: test object created using ctor which takes algorithm - * name and encrypted data as a parameters
- * Expected: null must be returned - * - * @throws IOException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getAlgParameters method.", - method = "getAlgParameters", - args = {} - ) - public final void testGetAlgParameters03() throws IOException { - boolean performed = false; - for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { - try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - EncryptedPrivateKeyInfoData.algName0[i][0], - EncryptedPrivateKeyInfoData.encryptedData); - - // check that method under test returns null - // for object constructed in such a way - assertNull(epki.getAlgParameters()); - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - /** - * Test #4 for getAlgParameters() method
- * Assertion: returns the algorithm parameters
- * Test preconditions: test object created using ctor which takes - * AlgorithmParameters and encrypted data as a parameters;
- * Expected: the same algorithm parameters as ones passed to the ctor must be - * returned - * - * @throws IOException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getAlgParameters method.", - method = "getAlgParameters", - args = {} - ) - public final void testGetAlgParameters04() throws IOException { - boolean performed = false; - for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { - try { - AlgorithmParameters ap = AlgorithmParameters - .getInstance(EncryptedPrivateKeyInfoData.algName0[i][0]); - // use pregenerated AlgorithmParameters encodings - ap - .init(EncryptedPrivateKeyInfoData - .getParametersEncoding( - EncryptedPrivateKeyInfoData.algName0[i][0])); - - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap, - EncryptedPrivateKeyInfoData.encryptedData); - - // check that method under test returns - // the same parameters instance - assertSame(ap, epki.getAlgParameters()); - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - /** - * Test #1 for getEncryptedData() method
- * Assertion: returns the encrypted data
- * Test preconditions: test object created using ctor which takes encoded - * form as the only parameter; encoded form passed contains encrypted data - *
- * Expected: the equivalent encrypted data must be returned - * - * @throws IOException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getEncryptedData method.", - method = "getEncryptedData", - args = {} - ) - public final void testGetEncryptedData01() throws IOException { - boolean performed = false; - for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { - try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - EncryptedPrivateKeyInfoData - .getValidEncryptedPrivateKeyInfoEncoding( - EncryptedPrivateKeyInfoData.algName0[i][0])); - - // check that method under test returns - // valid encrypted data - assertTrue(Arrays.equals( - EncryptedPrivateKeyInfoData.encryptedData, epki - .getEncryptedData())); - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - /** - * Test #2 for getEncryptedData() method
- * Assertion: returns the encrypted data
- * Test preconditions: test object created using ctor which takes algorithm - * name and encrypted data as a parameters
- * Expected: the equivalent encrypted data must be returned - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getEncryptedData method.", - method = "getEncryptedData", - args = {} - ) - public final void testGetEncryptedData02() { - boolean performed = false; - for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { - try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - EncryptedPrivateKeyInfoData.algName0[i][0], - EncryptedPrivateKeyInfoData.encryptedData); - - // check that method under test returns - // valid encrypted data - assertTrue(Arrays.equals( - EncryptedPrivateKeyInfoData.encryptedData, epki - .getEncryptedData())); - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - /** - * Test #3 for getEncryptedData() method
- * Assertion: returns the encrypted data
- * Test preconditions: test object created using ctor which takes algorithm - * parameters and encrypted data as a parameters
- * Expected: the equivalent encrypted data must be returned - * - * @throws IOException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getEncryptedData method.", - method = "getEncryptedData", - args = {} - ) - public final void testGetEncryptedData03() throws IOException { - boolean performed = false; - for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { - try { - AlgorithmParameters ap = AlgorithmParameters - .getInstance(EncryptedPrivateKeyInfoData.algName0[i][0]); - // use pregenerated AlgorithmParameters encodings - ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding( - EncryptedPrivateKeyInfoData.algName0[i][0])); - - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap, - EncryptedPrivateKeyInfoData.encryptedData); - - // check that method under test returns - // valid encrypted data - assertTrue(Arrays.equals( - EncryptedPrivateKeyInfoData.encryptedData, epki - .getEncryptedData())); - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - /** - * Test #4 for getEncryptedData() method
- * Assertion: returns a new array each time this method is called
- * Test preconditions: test object created using ctor which takes algorithm - * name and encrypted data as a parameters
- * Expected: refs to encrypted data byte array passed to the ctor and - * returned by the method under test must be different - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getEncryptedData method.", - method = "getEncryptedData", - args = {} - ) - public final void testGetEncryptedData04() { - boolean performed = false; - for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { - try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - EncryptedPrivateKeyInfoData.algName0[i][0], - EncryptedPrivateKeyInfoData.encryptedData); - - // check that method under test returns - // new array each time - byte[] ecd1 = epki.getEncryptedData(); - byte[] ecd2 = epki.getEncryptedData(); - assertNotSame(EncryptedPrivateKeyInfoData.encryptedData, ecd1); - assertNotSame(EncryptedPrivateKeyInfoData.encryptedData, ecd2); - assertNotSame(ecd1, ecd2); - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - /** - * Test #1 for getEncoded() method
- * Assertion: returns the ASN.1 encoding of this object
- * Test preconditions: test object created using ctor which takes encoded - * form as the only parameter
- * Expected: equivalent encoded form must be returned - * - * @throws IOException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Can not check IOException", - method = "getEncoded", - args = {} - ) - public final void testGetEncoded01() throws IOException { - boolean performed = false; - for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { - try { - byte[] enc = EncryptedPrivateKeyInfoData - .getValidEncryptedPrivateKeyInfoEncoding( - EncryptedPrivateKeyInfoData.algName0[i][0]); - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(enc); - - // check that method under test returns - // valid encoded form - assertTrue(Arrays.equals(enc, epki.getEncoded())); - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - /** - * Test #2 for getEncoded() method
- * Assertion: returns the ASN.1 encoding of this object
- * Test preconditions: test object created using ctor which takes algorithm - * name and encrypted data as a parameters
- * Expected: equivalent encoded form (without alg params) must be returned - * - * @throws IOException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Can not check IOException", - method = "getEncoded", - args = {} - ) - public final void testGetEncoded02() throws IOException { - boolean performed = false; - for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { - try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - EncryptedPrivateKeyInfoData.algName0[i][0], - EncryptedPrivateKeyInfoData.encryptedData); - - // check that method under test returns - // valid encoded form - byte[] refEnc = EncryptedPrivateKeyInfoData - .getValidEncryptedPrivateKeyInfoEncoding( - EncryptedPrivateKeyInfoData.algName0[i][0], - false); - // System.out.println(Array.toString(refEnc, " ")); - byte[] actEnc = epki.getEncoded(); - // System.out.println(Array.toString(actEnc, " ")); - assertTrue(Arrays.equals(refEnc, actEnc)); - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - /** - * Test #3 for getEncoded() method
- * Assertion: returns the ASN.1 encoding of this object
- * Test preconditions: test object created using ctor which takes algorithm - * name and encrypted data as a parameters
- * Expected: equivalent encoded form (without alg params) must be returned - * - * @throws IOException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Can not check IOException", - method = "getEncoded", - args = {} - ) - public final void testGetEncoded03() throws IOException { - boolean performed = false; - for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { - try { - AlgorithmParameters ap = AlgorithmParameters - .getInstance(EncryptedPrivateKeyInfoData.algName0[i][0]); - // use pregenerated AlgorithmParameters encodings - ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding( - EncryptedPrivateKeyInfoData.algName0[i][0])); - - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap, - EncryptedPrivateKeyInfoData.encryptedData); - - // check that method under test returns - // valid encoded form - assertTrue(Arrays.equals( - EncryptedPrivateKeyInfoData - .getValidEncryptedPrivateKeyInfoEncoding( - EncryptedPrivateKeyInfoData.algName0[i][0]), - epki.getEncoded())); - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - /** - * Test #4 for getEncoded() method
- * Assertion: returns a new array each time this method is called
- * Test preconditions: test object created using ctor which takes algorithm - * name and encrypted data as a parameters
- * Expected: several refs to byte array returned by the method under test - * must be different - * - * @throws IOException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Can not check IOException", - method = "getEncoded", - args = {} - ) - public final void testGetEncoded04() throws IOException { - boolean performed = false; - for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { - try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - EncryptedPrivateKeyInfoData.algName0[i][0], - EncryptedPrivateKeyInfoData.encryptedData); - - // check that method under test returns - // new array each time - byte[] ec1 = epki.getEncoded(); - byte[] ec2 = epki.getEncoded(); - byte[] ec3 = epki.getEncoded(); - assertNotSame(ec1, ec2); - assertNotSame(ec2, ec3); - assertNotSame(ec1, ec3); - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getKeySpec method.", - method = "getKeySpec", - args = {javax.crypto.Cipher.class} - ) - public final void testGetKeySpecCipher01() { - boolean performed = false; - for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { - try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - EncryptedPrivateKeyInfoData.algName0[i][0], - EncryptedPrivateKeyInfoData.encryptedData); - - try { - - // check that method under test throws NPE - epki.getKeySpec((Cipher) null); - fail(getName() + "NullPointerException has not been thrown"); - - } catch (NullPointerException ok) { - } catch (InvalidKeySpecException e) { - fail(getName() + "Unexpected exception: " + e); - } - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - /** - * Encrypted data contains valid PKCS8 key info encoding - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getKeySpec method.", - method = "getKeySpec", - args = {javax.crypto.Cipher.class} - ) - public final void test_ROUNDTRIP_GetKeySpecCipher01() { - boolean performed = false; - - for (int i = 0; i < algName.length; i++) { - try { - // generate test data - TestDataGenerator g = new TestDataGenerator(algName[i][0], - algName[i][1], privateKeyInfo, null); - - // create test object - EncryptedPrivateKeyInfo epki; - if (g.ap() == null) { - epki = new EncryptedPrivateKeyInfo(algName[i][0], g.ct()); - } else { - epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct()); - } - - // call methods under test - try { - - PKCS8EncodedKeySpec eks = epki.getKeySpec(g.c()); - - if (!Arrays.equals(privateKeyInfo, eks.getEncoded())) { - fail(algName[i][0] + " != " + algName[i][1]); - } - } catch (InvalidKeySpecException e) { - fail(algName[i][0] + ", " + algName[i][1] + e + "\n"); - } - performed = true; - - } catch (TestDataGenerator.AllowedFailure allowedFailure) { - } catch (NoSuchAlgorithmException allowed) { - } - } - assertTrue("Test not performed", performed); - } - - /** - * Encrypted data contains invalid PKCS8 key info encoding - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getKeySpec method.", - method = "getKeySpec", - args = {javax.crypto.Cipher.class} - ) - public final void test_ROUNDTRIP_GetKeySpecCipher02() { - boolean performed = false; - for (int i = 0; i < algName.length; i++) { - try { - // generate test data - TestDataGenerator g = new TestDataGenerator(algName[i][0], - algName[i][1], privateKeyInfoDamaged, null); - - // create test object - EncryptedPrivateKeyInfo epki; - if (g.ap() == null) { - epki = new EncryptedPrivateKeyInfo(algName[i][0], g.ct()); - } else { - epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct()); - } - - // call methods under test - try { - epki.getKeySpec(g.c()); - - // must not get here because decrypted data does - // not represent valid PKCS8 encoding - fail(algName[i][0] + ", " + algName[i][1]); - } catch (InvalidKeySpecException ok) { - } - - performed = true; - } catch (TestDataGenerator.AllowedFailure allowedFailure) { - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Can not check NoSuchAlgorithmException", - method = "getKeySpec", - args = {java.security.Key.class} - ) - public final void testGetKeySpecKey01() { - boolean performed = false; - for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { - try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - EncryptedPrivateKeyInfoData.algName0[i][0], - EncryptedPrivateKeyInfoData.encryptedData); - - try { - - // check that method under test throws NPE - epki.getKeySpec((Key) null); - fail(getName() + "NullPointerException has not been thrown"); - - } catch (NullPointerException ok) { - } catch (InvalidKeyException e) { - fail(getName() + "Unexpected exception: " + e); - } - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - /** - * Encrypted data contains valid PKCS8 key info encoding - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Can not check NoSuchAlgorithmException", - method = "getKeySpec", - args = {java.security.Key.class} - ) - public final void test_ROUNDTRIP_GetKeySpecKey01() { - boolean performed = false; - for (int i = 0; i < algName.length; i++) { - try { - // generate test data - TestDataGenerator g = new TestDataGenerator(algName[i][0], - algName[i][1], privateKeyInfo, null); - - // create test object - EncryptedPrivateKeyInfo epki; - if (g.ap() == null) { - epki = new EncryptedPrivateKeyInfo(algName[i][0], g.ct()); - } else { - epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct()); - } - - try { - PKCS8EncodedKeySpec eks = epki - .getKeySpec(g.pubK() == null ? g.k() : g.pubK()); - - if (!Arrays.equals(privateKeyInfo, eks.getEncoded())) { - fail(algName[i][0] + " != " + algName[i][1]); - } - } catch (InvalidKeyException e) { - fail(algName[i][0] + ", " + algName[i][1] + ": " + e); - } - - performed = true; - } catch (TestDataGenerator.AllowedFailure allowedFailure) { - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - /** - * Encrypted data contains invalid PKCS8 key info encoding - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Can not check NoSuchAlgorithmException", - method = "getKeySpec", - args = {java.security.Key.class} - ) - public final void test_ROUNDTRIP_GetKeySpecKey02() { - boolean performed = false; - for (int i = 0; i < algName.length; i++) { - try { - // generate test data - TestDataGenerator g = new TestDataGenerator(algName[i][0], - algName[i][1], privateKeyInfoDamaged, null); - - // create test object - EncryptedPrivateKeyInfo epki; - if (g.ap() == null) { - epki = new EncryptedPrivateKeyInfo(algName[i][0], g.ct()); - } else { - epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct()); - } - - try { - epki.getKeySpec(g.pubK() == null ? g.k() : g.pubK()); - fail(algName[i][0] + ", " + algName[i][1]); - } catch (InvalidKeyException e) { - } - - performed = true; - } catch (TestDataGenerator.AllowedFailure allowedFailure) { - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "NoSuchAlgorithmException can not be checking", - method = "getKeySpec", - args = {java.security.Key.class, java.lang.String.class} - ) - public final void testGetKeySpecKeyString01() throws Exception { - boolean performed = false; - for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { - try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - EncryptedPrivateKeyInfoData.algName0[i][0], - EncryptedPrivateKeyInfoData.encryptedData); - - try { - // check that method under test throws NPE - epki.getKeySpec((Key) null, "SomeProviderName"); - fail(getName() + "NullPointerException has not been thrown"); - - } catch (NullPointerException ok) { - } - - try { - epki.getKeySpec(new Key() { - public String getAlgorithm() { - return "alg"; - } - - public String getFormat() { - return "fmt"; - } - - public byte[] getEncoded() { - return new byte[] {}; - } - }, "StrangeProviderName"); - fail(getName() + "NoSuchProviderException has not been thrown"); - } catch (NoSuchProviderException ok) { - //expected - } - - try { - - // check that method under test throws NPE - epki.getKeySpec(new Key() { - public String getAlgorithm() { - return "alg"; - } - - public String getFormat() { - return "fmt"; - } - - public byte[] getEncoded() { - return new byte[] {}; - } - }, (String) null); - - fail(getName() + "NullPointerException has not been thrown"); - - } catch (NullPointerException ok) { - } - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - /** - * Encrypted data contains valid PKCS8 key info encoding - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "In subset missed NoSuchProviderException & NoSuchAlgorithmException checking", - method = "getKeySpec", - args = {java.security.Key.class, java.lang.String.class} - ) - public final void test_ROUNDTRIP_GetKeySpecKeyString01() throws Exception { - boolean performed = false; - for (int i = 0; i < algName.length; i++) { - for (int l = 0; l < provider.length; l++) { - if (provider[l] == null) { - continue; - } - TestDataGenerator g; - try { - // generate test data - g = new TestDataGenerator(algName[i][0], algName[i][1], - privateKeyInfo, provider[l]); - } catch (TestDataGenerator.AllowedFailure allowedFailure) { - continue; - } - - try { - // create test object - EncryptedPrivateKeyInfo epki; - if (g.ap() == null) { - epki = new EncryptedPrivateKeyInfo(algName[i][0], g - .ct()); - } else { - epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct()); - } - try { - - PKCS8EncodedKeySpec eks = epki.getKeySpec( - g.pubK() == null ? g.k() : g.pubK(), - provider[l].getName()); - - if (!Arrays.equals(privateKeyInfo, eks.getEncoded())) { - fail(algName[i][0] + " != " + algName[i][1]); - } - } catch (InvalidKeyException e) { - fail(algName[i][0] + ", " + algName[i][1] + ": " + e); - } - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - } - assertTrue("Test not performed", performed); - } - - /** - * Encrypted data contains invalid PKCS8 key info encoding - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "In subset missed NoSuchProviderException & NoSuchAlgorithmException checking", - method = "getKeySpec", - args = {java.security.Key.class, java.lang.String.class} - ) - public final void test_ROUNDTRIP_GetKeySpecKeyString02() throws Exception { - boolean performed = false; - for (int i = 0; i < algName.length; i++) { - for (int l = 0; l < provider.length; l++) { - if (provider[l] == null) { - continue; - } - TestDataGenerator g; - try { - // generate test data - g = new TestDataGenerator(algName[i][0], algName[i][1], - privateKeyInfoDamaged, provider[l]); - } catch (TestDataGenerator.AllowedFailure allowedFailure) { - continue; - } - - try { - // create test object - EncryptedPrivateKeyInfo epki; - if (g.ap() == null) { - epki = new EncryptedPrivateKeyInfo(algName[i][0], g - .ct()); - } else { - epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct()); - } - - try { - - epki.getKeySpec(g.pubK() == null ? g.k() : g.pubK(), - provider[l].getName()); - - fail(algName[i][0] + ", " + algName[i][1]); - - } catch (InvalidKeyException e) { - } - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - } - assertTrue("Test not performed", performed); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Can not check NoSuchAlgorithmException", - method = "getKeySpec", - args = {java.security.Key.class, java.security.Provider.class} - ) - public final void testGetKeySpecKeyProvider01() throws Exception { - boolean performed = false; - - for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { - try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - EncryptedPrivateKeyInfoData.algName0[i][0], - EncryptedPrivateKeyInfoData.encryptedData); - - try { - - // check that method under test throws NPE - epki.getKeySpec((Key) null, (Provider) null); - fail(getName() + "NullPointerException has not been thrown"); - } catch (NullPointerException ok) { - } - - try { - - // check that method under test throws NPE - epki.getKeySpec(new Key() { - public String getAlgorithm() { - return "alg"; - } - - public String getFormat() { - return "fmt"; - } - - public byte[] getEncoded() { - return new byte[] {}; - } - }, (Provider) null); - - fail(getName() + "NullPointerException has not been thrown"); - } catch (NullPointerException ok) { - } - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not performed", performed); - } - - /** - * Encrypted data contains valid PKCS8 key info encoding - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Can not check NoSuchAlgorithmException", - method = "getKeySpec", - args = {java.security.Key.class, java.security.Provider.class} - ) - public final void test_ROUNDTRIP_GetKeySpecKeyProvider01() { - boolean performed = false; - - for (int i = 0; i < algName.length; i++) { - for (int l = 0; l < provider.length; l++) { - if (provider[l] == null) { - continue; - } - TestDataGenerator g; - try { - // generate test data - g = new TestDataGenerator(algName[i][0], algName[i][1], - privateKeyInfo, provider[l]); - } catch (TestDataGenerator.AllowedFailure allowedFailure) { - continue; - } - try { - // create test object - EncryptedPrivateKeyInfo epki; - if (g.ap() == null) { - epki = new EncryptedPrivateKeyInfo(algName[i][0], g - .ct()); - } else { - epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct()); - } - try { - - PKCS8EncodedKeySpec eks = epki.getKeySpec( - g.pubK() == null ? g.k() : g.pubK(), - provider[l]); - - if (!Arrays.equals(privateKeyInfo, eks.getEncoded())) { - fail(algName[i][0] + " != " + algName[i][1]); - } - } catch (InvalidKeyException e) { - fail(algName[i][0] + ", " + algName[i][1] + ": " + e); - } - performed = true; - - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - } - assertTrue("Test not performed", performed); - } - - /** - * Encrypted data contains invalid PKCS8 key info encoding - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Can not check NoSuchAlgorithmException", - method = "getKeySpec", - args = {java.security.Key.class, java.security.Provider.class} - ) - public final void test_ROUNDTRIP_GetKeySpecKeyProvider02() { - boolean performed = false; - - for (int i = 0; i < algName.length; i++) { - for (int l = 0; l < provider.length; l++) { - if (provider[l] == null) { - continue; - } - TestDataGenerator g; - try { - // generate test data - g = new TestDataGenerator(algName[i][0], algName[i][1], - privateKeyInfoDamaged, provider[l]); - } catch (TestDataGenerator.AllowedFailure allowedFailure) { - continue; - } - - try { - // create test object - EncryptedPrivateKeyInfo epki; - if (g.ap() == null) { - epki = new EncryptedPrivateKeyInfo(algName[i][0], g - .ct()); - } else { - epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct()); - } - try { - - epki.getKeySpec(g.pubK() == null ? g.k() : g.pubK(), - provider[l]); - - fail(algName[i][0] + ", " + algName[i][1]); - - } catch (InvalidKeyException e) { - } - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - } - assertTrue("Test not performed", performed); - } - - public static class TestDataGenerator { - - public static class AllowedFailure extends Exception { - AllowedFailure(String msg) { - super(msg); - } - } - - private Cipher c = null; - - private Key k = null, pubK = null; - - private AlgorithmParameters ap = null; - - byte[] ct; - - public TestDataGenerator(String algName, String transformation, - byte[] privateKeyInfo, Provider provider) throws AllowedFailure { - try { - c = (provider == null) ? Cipher - .getInstance(transformation != null ? transformation - : algName) : Cipher.getInstance( - transformation != null ? transformation : algName, - provider); - } catch (NoSuchAlgorithmException e) { - throw new AllowedFailure(e.getMessage()); - } catch (NoSuchPaddingException e) { - throw new AllowedFailure(e.getMessage()); - } - - try { - KeyGenerator kg = (provider == null) ? KeyGenerator - .getInstance(algName) : KeyGenerator.getInstance( - algName, provider); - k = kg.generateKey(); - } catch (NoSuchAlgorithmException e) { - } - - if (k == null) { - try { - KeyPairGenerator kpg = (provider == null) ? KeyPairGenerator - .getInstance(algName) - : KeyPairGenerator.getInstance(algName, provider); - KeyPair kp = kpg.genKeyPair(); - k = kp.getPrivate(); - pubK = kp.getPublic(); - } catch (NoSuchAlgorithmException e) { - } - } - - PBEParameterSpec pbeParamSpec = null; - if (k == null) { - try { - pbeParamSpec = new PBEParameterSpec(new byte[] { 1, 2, 3, - 4, 5, 6, 7, 8 }, 10); - SecretKeyFactory skf = (provider == null) ? SecretKeyFactory - .getInstance(algName) - : SecretKeyFactory.getInstance(algName, provider); - PBEKeySpec ks = new PBEKeySpec("12345678".toCharArray()); - try { - k = skf.generateSecret(ks); - } catch (InvalidKeySpecException e) { - throw new AllowedFailure(e.getMessage()); - } - - } catch (NoSuchAlgorithmException e) { - throw new AllowedFailure(e.getMessage()); - } - } - - try { - if (pbeParamSpec == null) { - c.init(Cipher.ENCRYPT_MODE, k); - } else { - c.init(Cipher.ENCRYPT_MODE, k, pbeParamSpec); - } - } catch (InvalidKeyException e) { - throw new AllowedFailure(e.getMessage()); - } catch (SecurityException e) { - throw new AllowedFailure(e.getMessage()); - } catch (InvalidAlgorithmParameterException e) { - throw new AllowedFailure(e.getMessage()); - } - - ap = c.getParameters(); - - try { - ct = c.doFinal(privateKeyInfo); - } catch (IllegalStateException e) { - throw new AllowedFailure(e.getMessage()); - } catch (IllegalBlockSizeException e) { - throw new AllowedFailure(e.getMessage()); - } catch (BadPaddingException e) { - throw new AllowedFailure(e.getMessage()); - } catch (RuntimeException e) { - throw new AllowedFailure(e.getMessage()); - } - - try { - // try to convert pbeParamSpec->ap - if (pbeParamSpec != null) { - try { - ap = (provider == null) ? AlgorithmParameters - .getInstance(algName) : AlgorithmParameters - .getInstance(algName, provider); - ap.init(pbeParamSpec); - pbeParamSpec = null; - } catch (NoSuchAlgorithmException e) { - // couldn't convert - throw new AllowedFailure(e.getMessage()); - } catch (InvalidParameterSpecException e) { - // couldn't convert - throw new AllowedFailure(e.getMessage()); - } - } - - if (ap == null) { - c.init(Cipher.DECRYPT_MODE, pubK == null ? k : pubK); - } else { - c.init(Cipher.DECRYPT_MODE, pubK == null ? k : pubK, ap); - } - - } catch (InvalidKeyException e) { - throw new AllowedFailure(e.getMessage()); - } catch (SecurityException e) { - throw new AllowedFailure(e.getMessage()); - } catch (InvalidAlgorithmParameterException e) { - throw new AllowedFailure(e.getMessage()); - } - } - - public Key k() { - return k; - } - - public Key pubK() { - return pubK; - } - - public Cipher c() { - return c; - } - - public byte[] ct() { - return ct; - } - - public AlgorithmParameters ap() { - return ap; - } - } - - // valid PrivateKeyInfo encoding - private static final byte[] privateKeyInfo = { (byte) 0x30, (byte) 0x82, - (byte) 0x02, (byte) 0x77, (byte) 0x02, (byte) 0x01, (byte) 0x00, - (byte) 0x30, (byte) 0x0d, (byte) 0x06, (byte) 0x09, (byte) 0x2a, - (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7, (byte) 0x0d, - (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x05, (byte) 0x00, - (byte) 0x04, (byte) 0x82, (byte) 0x02, (byte) 0x61, (byte) 0x30, - (byte) 0x82, (byte) 0x02, (byte) 0x5d, (byte) 0x02, (byte) 0x01, - (byte) 0x00, (byte) 0x02, (byte) 0x81, (byte) 0x81, (byte) 0x00, - (byte) 0xb2, (byte) 0x4a, (byte) 0x9b, (byte) 0x5b, (byte) 0xba, - (byte) 0x01, (byte) 0xc0, (byte) 0xcd, (byte) 0x65, (byte) 0x09, - (byte) 0x63, (byte) 0x70, (byte) 0x0b, (byte) 0x5a, (byte) 0x1b, - (byte) 0x92, (byte) 0x08, (byte) 0xf8, (byte) 0x55, (byte) 0x5e, - (byte) 0x7c, (byte) 0x1b, (byte) 0x50, (byte) 0x17, (byte) 0xec, - (byte) 0x44, (byte) 0x4c, (byte) 0x58, (byte) 0x42, (byte) 0x2b, - (byte) 0x41, (byte) 0x09, (byte) 0x59, (byte) 0xf2, (byte) 0xe1, - (byte) 0x5d, (byte) 0x43, (byte) 0x71, (byte) 0x4d, (byte) 0x92, - (byte) 0x03, (byte) 0x1d, (byte) 0xb6, (byte) 0x6c, (byte) 0x7f, - (byte) 0x5d, (byte) 0x48, (byte) 0xcd, (byte) 0x17, (byte) 0xec, - (byte) 0xd7, (byte) 0x4c, (byte) 0x39, (byte) 0xb1, (byte) 0x7b, - (byte) 0xe2, (byte) 0xbf, (byte) 0x96, (byte) 0x77, (byte) 0xbe, - (byte) 0xd0, (byte) 0xa0, (byte) 0xf0, (byte) 0x2d, (byte) 0x6b, - (byte) 0x24, (byte) 0xaa, (byte) 0x14, (byte) 0xba, (byte) 0x82, - (byte) 0x79, (byte) 0x10, (byte) 0x9b, (byte) 0x16, (byte) 0x68, - (byte) 0x47, (byte) 0x81, (byte) 0x54, (byte) 0xa2, (byte) 0xfa, - (byte) 0x91, (byte) 0x9e, (byte) 0x0a, (byte) 0x2a, (byte) 0x53, - (byte) 0xa6, (byte) 0xe7, (byte) 0x9e, (byte) 0x7d, (byte) 0x29, - (byte) 0x33, (byte) 0xd8, (byte) 0x05, (byte) 0xfc, (byte) 0x02, - (byte) 0x3f, (byte) 0xbd, (byte) 0xc7, (byte) 0x6e, (byte) 0xed, - (byte) 0xaa, (byte) 0x30, (byte) 0x6c, (byte) 0x5f, (byte) 0x52, - (byte) 0xed, (byte) 0x35, (byte) 0x65, (byte) 0x4b, (byte) 0x0e, - (byte) 0xc8, (byte) 0xa7, (byte) 0x12, (byte) 0x10, (byte) 0x56, - (byte) 0x37, (byte) 0xaf, (byte) 0x11, (byte) 0xfa, (byte) 0x21, - (byte) 0x0e, (byte) 0x99, (byte) 0xff, (byte) 0xfa, (byte) 0x8c, - (byte) 0x65, (byte) 0x8e, (byte) 0x6d, (byte) 0x02, (byte) 0x03, - (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x81, - (byte) 0x80, (byte) 0x78, (byte) 0x41, (byte) 0x72, (byte) 0x40, - (byte) 0x90, (byte) 0x59, (byte) 0x96, (byte) 0x5d, (byte) 0xf3, - (byte) 0x84, (byte) 0x3d, (byte) 0x99, (byte) 0xd9, (byte) 0x4e, - (byte) 0x51, (byte) 0xc2, (byte) 0x52, (byte) 0x62, (byte) 0x8d, - (byte) 0xd2, (byte) 0x49, (byte) 0x0b, (byte) 0x73, (byte) 0x1e, - (byte) 0x6f, (byte) 0xb2, (byte) 0x31, (byte) 0x7c, (byte) 0x66, - (byte) 0x45, (byte) 0x1e, (byte) 0x7c, (byte) 0xdc, (byte) 0x3a, - (byte) 0xc2, (byte) 0x5f, (byte) 0x51, (byte) 0x9a, (byte) 0x1e, - (byte) 0xa4, (byte) 0x19, (byte) 0x8d, (byte) 0xf4, (byte) 0xf9, - (byte) 0x81, (byte) 0x7e, (byte) 0xbe, (byte) 0x17, (byte) 0xf7, - (byte) 0xc7, (byte) 0x3c, (byte) 0x00, (byte) 0xa1, (byte) 0xf9, - (byte) 0x60, (byte) 0x82, (byte) 0x34, (byte) 0x8f, (byte) 0x9c, - (byte) 0xfd, (byte) 0x0b, (byte) 0x63, (byte) 0x42, (byte) 0x1b, - (byte) 0x7f, (byte) 0x45, (byte) 0xf1, (byte) 0x31, (byte) 0xc3, - (byte) 0x63, (byte) 0x47, (byte) 0x5c, (byte) 0xc1, (byte) 0xb2, - (byte) 0x5f, (byte) 0x57, (byte) 0xee, (byte) 0x02, (byte) 0x9f, - (byte) 0x5e, (byte) 0x08, (byte) 0x48, (byte) 0xba, (byte) 0x74, - (byte) 0xba, (byte) 0x81, (byte) 0xb7, (byte) 0x30, (byte) 0xac, - (byte) 0x4c, (byte) 0x01, (byte) 0x35, (byte) 0xce, (byte) 0x46, - (byte) 0x47, (byte) 0x8c, (byte) 0xe4, (byte) 0x62, (byte) 0x36, - (byte) 0x1a, (byte) 0x65, (byte) 0x0e, (byte) 0x33, (byte) 0x56, - (byte) 0xf9, (byte) 0xb7, (byte) 0xa0, (byte) 0xc4, (byte) 0xb6, - (byte) 0x82, (byte) 0x55, (byte) 0x7d, (byte) 0x36, (byte) 0x55, - (byte) 0xc0, (byte) 0x52, (byte) 0x5e, (byte) 0x35, (byte) 0x54, - (byte) 0xbd, (byte) 0x97, (byte) 0x01, (byte) 0x00, (byte) 0xbf, - (byte) 0x10, (byte) 0xdc, (byte) 0x1b, (byte) 0x51, (byte) 0x02, - (byte) 0x41, (byte) 0x00, (byte) 0xe7, (byte) 0x68, (byte) 0x03, - (byte) 0x3e, (byte) 0x21, (byte) 0x64, (byte) 0x68, (byte) 0x24, - (byte) 0x7b, (byte) 0xd0, (byte) 0x31, (byte) 0xa0, (byte) 0xa2, - (byte) 0xd9, (byte) 0x87, (byte) 0x6d, (byte) 0x79, (byte) 0x81, - (byte) 0x8f, (byte) 0x8f, (byte) 0x2d, (byte) 0x7a, (byte) 0x95, - (byte) 0x2e, (byte) 0x55, (byte) 0x9f, (byte) 0xd7, (byte) 0x86, - (byte) 0x29, (byte) 0x93, (byte) 0xbd, (byte) 0x04, (byte) 0x7e, - (byte) 0x4f, (byte) 0xdb, (byte) 0x56, (byte) 0xf1, (byte) 0x75, - (byte) 0xd0, (byte) 0x4b, (byte) 0x00, (byte) 0x3a, (byte) 0xe0, - (byte) 0x26, (byte) 0xf6, (byte) 0xab, (byte) 0x9e, (byte) 0x0b, - (byte) 0x2a, (byte) 0xf4, (byte) 0xa8, (byte) 0xd7, (byte) 0xff, - (byte) 0xbe, (byte) 0x01, (byte) 0xeb, (byte) 0x9b, (byte) 0x81, - (byte) 0xc7, (byte) 0x5f, (byte) 0x02, (byte) 0x73, (byte) 0xe1, - (byte) 0x2b, (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0xc5, - (byte) 0x3d, (byte) 0x78, (byte) 0xab, (byte) 0xe6, (byte) 0xab, - (byte) 0x3e, (byte) 0x29, (byte) 0xfd, (byte) 0x98, (byte) 0xd0, - (byte) 0xa4, (byte) 0x3e, (byte) 0x58, (byte) 0xee, (byte) 0x48, - (byte) 0x45, (byte) 0xa3, (byte) 0x66, (byte) 0xac, (byte) 0xe9, - (byte) 0x4d, (byte) 0xbd, (byte) 0x60, (byte) 0xea, (byte) 0x24, - (byte) 0xff, (byte) 0xed, (byte) 0x0c, (byte) 0x67, (byte) 0xc5, - (byte) 0xfd, (byte) 0x36, (byte) 0x28, (byte) 0xea, (byte) 0x74, - (byte) 0x88, (byte) 0xd1, (byte) 0xd1, (byte) 0xad, (byte) 0x58, - (byte) 0xd7, (byte) 0xf0, (byte) 0x67, (byte) 0x20, (byte) 0xc1, - (byte) 0xe3, (byte) 0xb3, (byte) 0xdb, (byte) 0x52, (byte) 0xad, - (byte) 0xf3, (byte) 0xc4, (byte) 0x21, (byte) 0xd8, (byte) 0x8c, - (byte) 0x4c, (byte) 0x41, (byte) 0x27, (byte) 0xdb, (byte) 0xd0, - (byte) 0x35, (byte) 0x92, (byte) 0xc7, (byte) 0x02, (byte) 0x41, - (byte) 0x00, (byte) 0xe0, (byte) 0x99, (byte) 0x42, (byte) 0xb4, - (byte) 0x76, (byte) 0x02, (byte) 0x97, (byte) 0x55, (byte) 0xf9, - (byte) 0xda, (byte) 0x3b, (byte) 0xa0, (byte) 0xd7, (byte) 0x0e, - (byte) 0xdc, (byte) 0xf4, (byte) 0x33, (byte) 0x7f, (byte) 0xbd, - (byte) 0xcf, (byte) 0xd0, (byte) 0xeb, (byte) 0x6e, (byte) 0x89, - (byte) 0xf7, (byte) 0x4f, (byte) 0x5a, (byte) 0x07, (byte) 0x7c, - (byte) 0xa9, (byte) 0x49, (byte) 0x47, (byte) 0x68, (byte) 0x35, - (byte) 0xa8, (byte) 0x05, (byte) 0x3d, (byte) 0xfd, (byte) 0x04, - (byte) 0x7b, (byte) 0x17, (byte) 0x31, (byte) 0x0d, (byte) 0xc8, - (byte) 0xa3, (byte) 0x98, (byte) 0x34, (byte) 0xa0, (byte) 0x50, - (byte) 0x44, (byte) 0x00, (byte) 0xf1, (byte) 0x0c, (byte) 0xe6, - (byte) 0xe5, (byte) 0xc4, (byte) 0x41, (byte) 0x3d, (byte) 0xf8, - (byte) 0x3d, (byte) 0x4e, (byte) 0x0b, (byte) 0x1c, (byte) 0xdb, - (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0x82, (byte) 0x9b, - (byte) 0x8a, (byte) 0xfd, (byte) 0xa1, (byte) 0x98, (byte) 0x41, - (byte) 0x68, (byte) 0xc2, (byte) 0xd1, (byte) 0xdf, (byte) 0x4e, - (byte) 0xf3, (byte) 0x2e, (byte) 0x26, (byte) 0x53, (byte) 0x5b, - (byte) 0x31, (byte) 0xb1, (byte) 0x7a, (byte) 0xcc, (byte) 0x5e, - (byte) 0xbb, (byte) 0x09, (byte) 0xa2, (byte) 0xe2, (byte) 0x6f, - (byte) 0x4a, (byte) 0x04, (byte) 0x0d, (byte) 0xef, (byte) 0x90, - (byte) 0x15, (byte) 0xbe, (byte) 0x10, (byte) 0x4a, (byte) 0xac, - (byte) 0x92, (byte) 0xeb, (byte) 0xda, (byte) 0x72, (byte) 0xdb, - (byte) 0x43, (byte) 0x08, (byte) 0xb7, (byte) 0x2b, (byte) 0x4c, - (byte) 0xe1, (byte) 0xbb, (byte) 0x58, (byte) 0xcb, (byte) 0x71, - (byte) 0x80, (byte) 0xad, (byte) 0xbc, (byte) 0xdc, (byte) 0x62, - (byte) 0x5e, (byte) 0x3e, (byte) 0xcb, (byte) 0x92, (byte) 0xda, - (byte) 0xf6, (byte) 0xdf, (byte) 0x02, (byte) 0x40, (byte) 0x4d, - (byte) 0x81, (byte) 0x90, (byte) 0xc5, (byte) 0x77, (byte) 0x30, - (byte) 0xb7, (byte) 0x29, (byte) 0x00, (byte) 0xa8, (byte) 0xf1, - (byte) 0xb4, (byte) 0xae, (byte) 0x52, (byte) 0x63, (byte) 0x00, - (byte) 0xb2, (byte) 0x2d, (byte) 0x3e, (byte) 0x7d, (byte) 0xd6, - (byte) 0x4d, (byte) 0xf9, (byte) 0x8a, (byte) 0xc1, (byte) 0xb1, - (byte) 0x98, (byte) 0x89, (byte) 0x52, (byte) 0x40, (byte) 0x14, - (byte) 0x1b, (byte) 0x0e, (byte) 0x61, (byte) 0x8f, (byte) 0xf4, - (byte) 0xbe, (byte) 0x59, (byte) 0x79, (byte) 0x79, (byte) 0x95, - (byte) 0x19, (byte) 0x5c, (byte) 0x51, (byte) 0x08, (byte) 0x66, - (byte) 0xc1, (byte) 0x42, (byte) 0x30, (byte) 0xb3, (byte) 0x7a, - (byte) 0x86, (byte) 0x9f, (byte) 0x3e, (byte) 0xf5, (byte) 0x19, - (byte) 0xa3, (byte) 0xae, (byte) 0x64, (byte) 0x69, (byte) 0x14, - (byte) 0x07, (byte) 0x50, (byte) 0x97, }; - - // valid PrivateKeyInfo encoding (Damaged) - private static final byte[] privateKeyInfoDamaged = { (byte) 0x30, - (byte) 0x82, (byte) 0x02, (byte) 0x77, (byte) 0x02, (byte) 0x01, - (byte) 0x00, (byte) 0x30, (byte) 0x0d, (byte) 0x06, (byte) 0x09, - (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7, - (byte) 0x0d, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x05, - (byte) 0x00, (byte) 0x04, // private key octet str - (byte) 0x82, (byte) 0x02, (byte) 0x62, // Damage: l=460->461 - // (0x61->0x62) - (byte) 0x30, (byte) 0x82, (byte) 0x02, (byte) 0x5d, (byte) 0x02, - (byte) 0x01, (byte) 0x00, (byte) 0x02, (byte) 0x81, (byte) 0x81, - (byte) 0x00, (byte) 0xb2, (byte) 0x4a, (byte) 0x9b, (byte) 0x5b, - (byte) 0xba, (byte) 0x01, (byte) 0xc0, (byte) 0xcd, (byte) 0x65, - (byte) 0x09, (byte) 0x63, (byte) 0x70, (byte) 0x0b, (byte) 0x5a, - (byte) 0x1b, (byte) 0x92, (byte) 0x08, (byte) 0xf8, (byte) 0x55, - (byte) 0x5e, (byte) 0x7c, (byte) 0x1b, (byte) 0x50, (byte) 0x17, - (byte) 0xec, (byte) 0x44, (byte) 0x4c, (byte) 0x58, (byte) 0x42, - (byte) 0x2b, (byte) 0x41, (byte) 0x09, (byte) 0x59, (byte) 0xf2, - (byte) 0xe1, (byte) 0x5d, (byte) 0x43, (byte) 0x71, (byte) 0x4d, - (byte) 0x92, (byte) 0x03, (byte) 0x1d, (byte) 0xb6, (byte) 0x6c, - (byte) 0x7f, (byte) 0x5d, (byte) 0x48, (byte) 0xcd, (byte) 0x17, - (byte) 0xec, (byte) 0xd7, (byte) 0x4c, (byte) 0x39, (byte) 0xb1, - (byte) 0x7b, (byte) 0xe2, (byte) 0xbf, (byte) 0x96, (byte) 0x77, - (byte) 0xbe, (byte) 0xd0, (byte) 0xa0, (byte) 0xf0, (byte) 0x2d, - (byte) 0x6b, (byte) 0x24, (byte) 0xaa, (byte) 0x14, (byte) 0xba, - (byte) 0x82, (byte) 0x79, (byte) 0x10, (byte) 0x9b, (byte) 0x16, - (byte) 0x68, (byte) 0x47, (byte) 0x81, (byte) 0x54, (byte) 0xa2, - (byte) 0xfa, (byte) 0x91, (byte) 0x9e, (byte) 0x0a, (byte) 0x2a, - (byte) 0x53, (byte) 0xa6, (byte) 0xe7, (byte) 0x9e, (byte) 0x7d, - (byte) 0x29, (byte) 0x33, (byte) 0xd8, (byte) 0x05, (byte) 0xfc, - (byte) 0x02, (byte) 0x3f, (byte) 0xbd, (byte) 0xc7, (byte) 0x6e, - (byte) 0xed, (byte) 0xaa, (byte) 0x30, (byte) 0x6c, (byte) 0x5f, - (byte) 0x52, (byte) 0xed, (byte) 0x35, (byte) 0x65, (byte) 0x4b, - (byte) 0x0e, (byte) 0xc8, (byte) 0xa7, (byte) 0x12, (byte) 0x10, - (byte) 0x56, (byte) 0x37, (byte) 0xaf, (byte) 0x11, (byte) 0xfa, - (byte) 0x21, (byte) 0x0e, (byte) 0x99, (byte) 0xff, (byte) 0xfa, - (byte) 0x8c, (byte) 0x65, (byte) 0x8e, (byte) 0x6d, (byte) 0x02, - (byte) 0x03, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x02, - (byte) 0x81, (byte) 0x80, (byte) 0x78, (byte) 0x41, (byte) 0x72, - (byte) 0x40, (byte) 0x90, (byte) 0x59, (byte) 0x96, (byte) 0x5d, - (byte) 0xf3, (byte) 0x84, (byte) 0x3d, (byte) 0x99, (byte) 0xd9, - (byte) 0x4e, (byte) 0x51, (byte) 0xc2, (byte) 0x52, (byte) 0x62, - (byte) 0x8d, (byte) 0xd2, (byte) 0x49, (byte) 0x0b, (byte) 0x73, - (byte) 0x1e, (byte) 0x6f, (byte) 0xb2, (byte) 0x31, (byte) 0x7c, - (byte) 0x66, (byte) 0x45, (byte) 0x1e, (byte) 0x7c, (byte) 0xdc, - (byte) 0x3a, (byte) 0xc2, (byte) 0x5f, (byte) 0x51, (byte) 0x9a, - (byte) 0x1e, (byte) 0xa4, (byte) 0x19, (byte) 0x8d, (byte) 0xf4, - (byte) 0xf9, (byte) 0x81, (byte) 0x7e, (byte) 0xbe, (byte) 0x17, - (byte) 0xf7, (byte) 0xc7, (byte) 0x3c, (byte) 0x00, (byte) 0xa1, - (byte) 0xf9, (byte) 0x60, (byte) 0x82, (byte) 0x34, (byte) 0x8f, - (byte) 0x9c, (byte) 0xfd, (byte) 0x0b, (byte) 0x63, (byte) 0x42, - (byte) 0x1b, (byte) 0x7f, (byte) 0x45, (byte) 0xf1, (byte) 0x31, - (byte) 0xc3, (byte) 0x63, (byte) 0x47, (byte) 0x5c, (byte) 0xc1, - (byte) 0xb2, (byte) 0x5f, (byte) 0x57, (byte) 0xee, (byte) 0x02, - (byte) 0x9f, (byte) 0x5e, (byte) 0x08, (byte) 0x48, (byte) 0xba, - (byte) 0x74, (byte) 0xba, (byte) 0x81, (byte) 0xb7, (byte) 0x30, - (byte) 0xac, (byte) 0x4c, (byte) 0x01, (byte) 0x35, (byte) 0xce, - (byte) 0x46, (byte) 0x47, (byte) 0x8c, (byte) 0xe4, (byte) 0x62, - (byte) 0x36, (byte) 0x1a, (byte) 0x65, (byte) 0x0e, (byte) 0x33, - (byte) 0x56, (byte) 0xf9, (byte) 0xb7, (byte) 0xa0, (byte) 0xc4, - (byte) 0xb6, (byte) 0x82, (byte) 0x55, (byte) 0x7d, (byte) 0x36, - (byte) 0x55, (byte) 0xc0, (byte) 0x52, (byte) 0x5e, (byte) 0x35, - (byte) 0x54, (byte) 0xbd, (byte) 0x97, (byte) 0x01, (byte) 0x00, - (byte) 0xbf, (byte) 0x10, (byte) 0xdc, (byte) 0x1b, (byte) 0x51, - (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0xe7, (byte) 0x68, - (byte) 0x03, (byte) 0x3e, (byte) 0x21, (byte) 0x64, (byte) 0x68, - (byte) 0x24, (byte) 0x7b, (byte) 0xd0, (byte) 0x31, (byte) 0xa0, - (byte) 0xa2, (byte) 0xd9, (byte) 0x87, (byte) 0x6d, (byte) 0x79, - (byte) 0x81, (byte) 0x8f, (byte) 0x8f, (byte) 0x2d, (byte) 0x7a, - (byte) 0x95, (byte) 0x2e, (byte) 0x55, (byte) 0x9f, (byte) 0xd7, - (byte) 0x86, (byte) 0x29, (byte) 0x93, (byte) 0xbd, (byte) 0x04, - (byte) 0x7e, (byte) 0x4f, (byte) 0xdb, (byte) 0x56, (byte) 0xf1, - (byte) 0x75, (byte) 0xd0, (byte) 0x4b, (byte) 0x00, (byte) 0x3a, - (byte) 0xe0, (byte) 0x26, (byte) 0xf6, (byte) 0xab, (byte) 0x9e, - (byte) 0x0b, (byte) 0x2a, (byte) 0xf4, (byte) 0xa8, (byte) 0xd7, - (byte) 0xff, (byte) 0xbe, (byte) 0x01, (byte) 0xeb, (byte) 0x9b, - (byte) 0x81, (byte) 0xc7, (byte) 0x5f, (byte) 0x02, (byte) 0x73, - (byte) 0xe1, (byte) 0x2b, (byte) 0x02, (byte) 0x41, (byte) 0x00, - (byte) 0xc5, (byte) 0x3d, (byte) 0x78, (byte) 0xab, (byte) 0xe6, - (byte) 0xab, (byte) 0x3e, (byte) 0x29, (byte) 0xfd, // 88 - (byte) 0x98, (byte) 0xd0, (byte) 0xa4, (byte) 0x3e, (byte) 0x58, - (byte) 0xee, (byte) 0x48, (byte) 0x45, (byte) 0xa3, (byte) 0x66, - (byte) 0xac, (byte) 0xe9, (byte) 0x4d, (byte) 0xbd, (byte) 0x60, - (byte) 0xea, (byte) 0x24, (byte) 0xff, (byte) 0xed, (byte) 0x0c, - (byte) 0x67, (byte) 0xc5, (byte) 0xfd, (byte) 0x36, (byte) 0x28, - (byte) 0xea, (byte) 0x74, (byte) 0x88, (byte) 0xd1, (byte) 0xd1, - (byte) 0xad, (byte) 0x58, (byte) 0xd7, (byte) 0xf0, (byte) 0x67, - (byte) 0x20, (byte) 0xc1, (byte) 0xe3, (byte) 0xb3, (byte) 0xdb, - (byte) 0x52, (byte) 0xad, (byte) 0xf3, (byte) 0xc4, (byte) 0x21, - (byte) 0xd8, (byte) 0x8c, (byte) 0x4c, (byte) 0x41, (byte) 0x27, - (byte) 0xdb, (byte) 0xd0, (byte) 0x35, (byte) 0x92, (byte) 0xc7, - (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0xe0, (byte) 0x99, - (byte) 0x42, (byte) 0xb4, (byte) 0x76, (byte) 0x02, (byte) 0x97, - (byte) 0x55, (byte) 0xf9, (byte) 0xda, (byte) 0x3b, (byte) 0xa0, - (byte) 0xd7, (byte) 0x0e, (byte) 0xdc, (byte) 0xf4, (byte) 0x33, - (byte) 0x7f, (byte) 0xbd, (byte) 0xcf, (byte) 0xd0, (byte) 0xeb, - (byte) 0x6e, (byte) 0x89, (byte) 0xf7, (byte) 0x4f, (byte) 0x5a, - (byte) 0x07, (byte) 0x7c, (byte) 0xa9, (byte) 0x49, (byte) 0x47, - (byte) 0x68, (byte) 0x35, (byte) 0xa8, (byte) 0x05, (byte) 0x3d, - (byte) 0xfd, (byte) 0x04, (byte) 0x7b, (byte) 0x17, (byte) 0x31, - (byte) 0x0d, (byte) 0xc8, (byte) 0xa3, (byte) 0x98, (byte) 0x34, - (byte) 0xa0, (byte) 0x50, (byte) 0x44, (byte) 0x00, (byte) 0xf1, - (byte) 0x0c, (byte) 0xe6, (byte) 0xe5, (byte) 0xc4, (byte) 0x41, - (byte) 0x3d, (byte) 0xf8, (byte) 0x3d, (byte) 0x4e, (byte) 0x0b, // 118 - (byte) 0x1c, (byte) 0xdb, (byte) 0x02, (byte) 0x41, (byte) 0x00, - (byte) 0x82, (byte) 0x9b, (byte) 0x8a, (byte) 0xfd, (byte) 0xa1, - (byte) 0x98, (byte) 0x41, (byte) 0x68, (byte) 0xc2, (byte) 0xd1, - (byte) 0xdf, (byte) 0x4e, (byte) 0xf3, (byte) 0x2e, (byte) 0x26, - (byte) 0x53, (byte) 0x5b, (byte) 0x31, (byte) 0xb1, (byte) 0x7a, - (byte) 0xcc, (byte) 0x5e, (byte) 0xbb, (byte) 0x09, (byte) 0xa2, - (byte) 0xe2, (byte) 0x6f, (byte) 0x4a, (byte) 0x04, (byte) 0x0d, - (byte) 0xef, (byte) 0x90, (byte) 0x15, (byte) 0xbe, (byte) 0x10, - (byte) 0x4a, (byte) 0xac, (byte) 0x92, (byte) 0xeb, (byte) 0xda, - (byte) 0x72, (byte) 0xdb, (byte) 0x43, (byte) 0x08, (byte) 0xb7, - (byte) 0x2b, (byte) 0x4c, (byte) 0xe1, (byte) 0xbb, (byte) 0x58, - (byte) 0xcb, (byte) 0x71, (byte) 0x80, (byte) 0xad, (byte) 0xbc, - (byte) 0xdc, (byte) 0x62, (byte) 0x5e, (byte) 0x3e, (byte) 0xcb, - (byte) 0x92, (byte) 0xda, (byte) 0xf6, (byte) 0xdf, (byte) 0x02, - (byte) 0x40, (byte) 0x4d, (byte) 0x81, (byte) 0x90, (byte) 0xc5, - (byte) 0x77, (byte) 0x30, (byte) 0xb7, (byte) 0x29, (byte) 0x00, - (byte) 0xa8, (byte) 0xf1, (byte) 0xb4, (byte) 0xae, (byte) 0x52, - (byte) 0x63, (byte) 0x00, (byte) 0xb2, // 140 - (byte) 0x2d, (byte) 0x3e, (byte) 0x7d, (byte) 0xd6, (byte) 0x4d, - (byte) 0xf9, (byte) 0x8a, (byte) 0xc1, (byte) 0xb1, (byte) 0x98, - (byte) 0x89, (byte) 0x52, (byte) 0x40, (byte) 0x14, (byte) 0x1b, - (byte) 0x0e, (byte) 0x61, (byte) 0x8f, (byte) 0xf4, (byte) 0xbe, - (byte) 0x59, (byte) 0x79, (byte) 0x79, (byte) 0x95, (byte) 0x19, - (byte) 0x5c, (byte) 0x51, (byte) 0x08, (byte) 0x66, (byte) 0xc1, - (byte) 0x42, (byte) 0x30, (byte) 0xb3, (byte) 0x7a, (byte) 0x86, - (byte) 0x9f, (byte) 0x3e, (byte) 0xf5, (byte) 0x19, (byte) 0xa3, // 150 - (byte) 0xae, (byte) 0x64, (byte) 0x69, (byte) 0x14, (byte) 0x07, - (byte) 0x50, (byte) 0x97, }; -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismExceptionTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismExceptionTest.java deleted file mode 100644 index a26e60584..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismExceptionTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import javax.crypto.ExemptionMechanismException; - -import junit.framework.TestCase; - - -@TestTargetClass(ExemptionMechanismException.class) -/** - * Tests for ExemptionMechanismException class constructors and - * methods. - * - */ -public class ExemptionMechanismExceptionTest extends TestCase { - - static String[] msgs = { - "", - "Check new message", - "Check new message Check new message Check new message Check new message Check new message" }; - - static Throwable tCause = new Throwable("Throwable for exception"); - - static String createErr(Exception tE, Exception eE) { - return "ExemptionMechanismException: ".concat(tE.toString()).concat( - " is not equal to caught exception: ").concat(eE.toString()); - } - - /** - * Test for ExemptionMechanismException() constructor - * Assertion: constructs ExemptionMechanismException with no detail message - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "ExemptionMechanismException", - args = {} - ) - public void testExemptionMechanismException01() { - ExemptionMechanismException tE = new ExemptionMechanismException(); - assertNull("getMessage() must return null.", tE.getMessage()); - assertNull("getCause() must return null", tE.getCause()); - try { - throw tE; - } catch (Exception e) { - assertTrue(createErr(tE, e), tE.equals(e)); - } - } - - /** - * Test for ExemptionMechanismException(String) constructor - * Assertion: constructs ExemptionMechanismException with detail message - * msg. Parameter msg is not null. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "ExemptionMechanismException", - args = {java.lang.String.class} - ) - public void testExemptionMechanismException02() { - ExemptionMechanismException tE; - for (int i = 0; i < msgs.length; i++) { - tE = new ExemptionMechanismException(msgs[i]); - assertEquals("getMessage() must return: ".concat(msgs[i]), tE - .getMessage(), msgs[i]); - assertNull("getCause() must return null", tE.getCause()); - try { - throw tE; - } catch (Exception e) { - assertTrue(createErr(tE, e), tE.equals(e)); - } - } - } - - /** - * Test for ExemptionMechanismException(String) constructor - * Assertion: constructs ExemptionMechanismException when msg - * is null - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "ExemptionMechanismException", - args = {java.lang.String.class} - ) - public void testExemptionMechanismException03() { - String msg = null; - ExemptionMechanismException tE = new ExemptionMechanismException(msg); - assertNull("getMessage() must return null.", tE.getMessage()); - assertNull("getCause() must return null", tE.getCause()); - try { - throw tE; - } catch (Exception e) { - assertTrue(createErr(tE, e), tE.equals(e)); - } - } - -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismSpiTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismSpiTest.java deleted file mode 100644 index 793edcb61..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismSpiTest.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.math.BigInteger; -import java.security.AlgorithmParameters; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.spec.AlgorithmParameterSpec; -import java.security.spec.RSAKeyGenParameterSpec; - -import javax.crypto.ExemptionMechanismException; -import javax.crypto.ShortBufferException; -import javax.crypto.ExemptionMechanismSpi; -import org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi; - -import junit.framework.TestCase; - - -@TestTargetClass(ExemptionMechanismSpi.class) -/** - * Tests for ExemptionMechanismSpi class constructors and - * methods. - * - */ -public class ExemptionMechanismSpiTest extends TestCase { -class Mock_ExemptionMechanismSpi extends MyExemptionMechanismSpi{ - - @Override - protected byte[] engineGenExemptionBlob() throws ExemptionMechanismException { - return super.engineGenExemptionBlob(); - } - - @Override - protected int engineGenExemptionBlob(byte[] output, int outputOffset) throws ShortBufferException, ExemptionMechanismException { - return super.engineGenExemptionBlob(output, outputOffset); - } - - @Override - protected int engineGetOutputSize(int inputLen) { - return super.engineGetOutputSize(inputLen); - } - - @Override - protected void engineInit(Key key) throws InvalidKeyException, ExemptionMechanismException { - super.engineInit(key); - - } - - @Override - protected void engineInit(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException, ExemptionMechanismException { - super.engineInit(key, params); - - } - - @Override - protected void engineInit(Key key, AlgorithmParameters params) throws InvalidKeyException, InvalidAlgorithmParameterException, ExemptionMechanismException { - super.engineInit(key, params); - - } - -} - - /** - * Test for ExemptionMechanismSpi constructor Assertion: - * constructs ExemptionMechanismSpi - * @throws Exception - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "ExemptionMechanismSpi", - args = {} - ) - public void testExemptionMechanismSpi01() throws Exception { - Mock_ExemptionMechanismSpi emSpi = new Mock_ExemptionMechanismSpi(){}; - int len = MyExemptionMechanismSpi.getLength(); - byte [] bbRes = emSpi.engineGenExemptionBlob(); - assertEquals("Incorrect length", bbRes.length, len); - assertEquals("Incorrect result", - emSpi.engineGenExemptionBlob(new byte[1], len), len); - assertEquals("Incorrect output size", 10, emSpi.engineGetOutputSize(100)); - Key key = null; - AlgorithmParameters params = null; - AlgorithmParameterSpec parSpec = null; - try { - emSpi.engineInit(key); - fail("InvalidKeyException must be thrown"); - } catch (InvalidKeyException e) { - } - try { - emSpi.engineInit(key, params); - fail("InvalidKeyException must be thrown"); - } catch (InvalidKeyException e) { - } - try { - emSpi.engineInit(key, parSpec); - fail("InvalidKeyException must be thrown"); - } catch (InvalidKeyException e) { - } - key = ((MyExemptionMechanismSpi)emSpi).new tmp1Key("Proba", new byte[0]); - try { - emSpi.engineInit(key); - fail("ExemptionMechanismException must be thrown"); - } catch (ExemptionMechanismException e) { - } - try { - emSpi.engineInit(key, params); - fail("ExemptionMechanismException must be thrown"); - } catch (ExemptionMechanismException e) { - } - try { - emSpi.engineInit(key, parSpec); - fail("ExemptionMechanismException must be thrown"); - } catch (ExemptionMechanismException e) { - } - key = ((MyExemptionMechanismSpi)emSpi).new tmpKey("Proba", new byte[0]); - emSpi.engineInit(key); - emSpi.engineInit(key, AlgorithmParameters.getInstance("DH")); - emSpi.engineInit(key, new RSAKeyGenParameterSpec(10, new BigInteger ("10"))); - - assertEquals("Incorrect result", 10, emSpi.engineGetOutputSize(100)); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismTest.java deleted file mode 100644 index d93c15610..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismTest.java +++ /dev/null @@ -1,736 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.SideEffect; - -import java.math.BigInteger; -import java.security.AlgorithmParameters; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.Provider; -import java.security.SecureRandom; -import java.security.spec.AlgorithmParameterSpec; -import java.security.spec.RSAKeyGenParameterSpec; -import java.util.Vector; - -import javax.crypto.ExemptionMechanism; -import javax.crypto.ExemptionMechanismException; -import javax.crypto.ExemptionMechanismSpi; -import javax.crypto.KeyGenerator; -import javax.crypto.ShortBufferException; - -import org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi; -import org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi.tmpKey; -import org.apache.harmony.security.tests.support.SpiEngUtils; - -import junit.framework.TestCase; - -@TestTargetClass(ExemptionMechanism.class) -/** - * Tests for ExemptionMechanism class constructors and methods - * - */ - -public class ExemptionMechanismTest extends TestCase { - - private static final String srvExemptionMechanism = "ExemptionMechanism"; - - private static final String defaultAlg = "EMech"; - - private static final String ExemptionMechanismProviderClass = "org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi"; - - /** - * Test for ExemptionMechanism constructor - * Assertion: creates new object using provider and mechanism name - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "ExemptionMechanism", - args = {javax.crypto.ExemptionMechanismSpi.class, java.security.Provider.class, java.lang.String.class} - ) - public void testExemptionMechanism() throws Exception { - Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", - "Provider for ExemptionMechanism testing", - srvExemptionMechanism.concat(".").concat(defaultAlg), - ExemptionMechanismProviderClass); - - ExemptionMechanismSpi spi = new MyExemptionMechanismSpi(); - - ExemptionMechanism em = new ExemptionMechanism(spi, mProv, defaultAlg) {}; - assertEquals("Incorrect provider", em.getProvider(), mProv); - assertEquals("Incorrect algorithm", em.getName(), defaultAlg); - try { - em.init(null); - fail("InvalidKeyException must be thrown"); - } catch (InvalidKeyException e) {} - - try { - em.getOutputSize(100); - fail("IllegalStateException must be thrown"); - } catch (IllegalStateException e) {} - - - em = new ExemptionMechanism(null, null, null) {}; - assertNull("Incorrect mechanism", em.getName()); - assertNull("Incorrect provider", em.getProvider()); - try { - em.init(null); - fail("NullPointerException must be thrown"); - } catch (NullPointerException e) {} - try { - em.getOutputSize(100); - fail("IllegalStateException must be thrown"); - } catch (IllegalStateException e) {} - } - - /** - * @tests javax/crypto/ExemptionMechanism#getInstance(String algorithm, String provider) - * Checks exception order - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getInstance", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testGetInstance() throws Exception { - //Regression for HARMONY-762 - try { - ExemptionMechanism.getInstance((String) null, "aaa"); - fail("NoSuchProviderException must be thrown"); - } catch (NoSuchProviderException pe) { - //expected - } - try { - ExemptionMechanism.getInstance("AlgName", (String)null); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException e) { - //expected - } - } - - /** - * Test for isCryptoAllowed(Key key) method - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "isCryptoAllowed", - args = {java.security.Key.class} - ) - public void testIsCryptoAllowed() throws Exception { - - //Regression for HARMONY-1029 - Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", - "Provider for ExemptionMechanism testing", - srvExemptionMechanism.concat(".").concat(defaultAlg), - ExemptionMechanismProviderClass); - - ExemptionMechanism em = new ExemptionMechanism( - new MyExemptionMechanismSpi(), mProv, defaultAlg) { - }; - - Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]); - - assertFalse(em.isCryptoAllowed(key)); - - em.init(key); - assertFalse(em.isCryptoAllowed(key)); - - em.genExemptionBlob(); - assertTrue(em.isCryptoAllowed(key)); - - Key key1 = new MyExemptionMechanismSpi().new tmpKey("Proba", - new byte[] { 1 }); - assertFalse(em.isCryptoAllowed(key1)); - - em.init(key1); - assertFalse(em.isCryptoAllowed(key)); - } - - /** - * Test for genExemptionBlob((byte[] output, int outputOffset) method - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Regression test", - method = "genExemptionBlob", - args = {byte[].class, int.class} - ) - public void testGenExemptionBlob() throws Exception { - //Regression for HARMONY-1029 - Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", - "Provider for ExemptionMechanism testing", - srvExemptionMechanism.concat(".").concat(defaultAlg), - ExemptionMechanismProviderClass); - - ExemptionMechanism em = new ExemptionMechanism( - new MyExemptionMechanismSpi(), mProv, defaultAlg) { - }; - - Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]); - - em.init(key); - // ExemptionMechanism doesn't check parameters - // it is a responsibility of ExemptionMechanismSpi - em.genExemptionBlob(null, 0); - em.genExemptionBlob(new byte[0], 0); - em.genExemptionBlob(new byte[10], -5); - } - - static boolean flag = false; - - class Mock_ExemptionMechanism extends ExemptionMechanism { - protected Mock_ExemptionMechanism(ExemptionMechanismSpi exmechSpi, Provider provider, String mechanism) { - super(exmechSpi, provider, mechanism); - } - - @Override - protected void finalize() { - flag = true; - super.finalize(); - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "finalize", - args = {} - ) - @SideEffect("Causes OutOfMemoryError to test finalization") - public void test_finalize () { - Mock_ExemptionMechanism mem = new Mock_ExemptionMechanism(null, null, "Name"); - assertNotNull(mem); - mem = null; - assertFalse(flag); - Vector v = new Vector(); - int capacity; - try { - while(true) { - v.add(this); - } - } catch (OutOfMemoryError e) { - capacity = v.size(); - v = null; - } - - v = new Vector(); - for (int i = 0; i < capacity/2; i++) { - v.add(this); - } - v = null; - assertTrue(flag); - } - - class Mock_ExemptionMechanismSpi extends MyExemptionMechanismSpi { - @Override - protected byte[] engineGenExemptionBlob() - throws ExemptionMechanismException { - throw new ExemptionMechanismException(); - } - - @Override - protected int engineGenExemptionBlob(byte[] output, int outputOffset) - throws ShortBufferException, ExemptionMechanismException { - if (output.length - outputOffset < - super.engineGenExemptionBlob(output, outputOffset)) { - throw new ShortBufferException(); - } - if (output[outputOffset + 3] == 33) { - throw new ExemptionMechanismException(); - } - return super.engineGenExemptionBlob(output, outputOffset); - } - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "genExemptionBlob", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = ExemptionMechanismSpi.class, - method = "engineGenExemptionBlob", - args = {} - ) - }) - public void test_genExemptionBlob() throws InvalidKeyException, - ExemptionMechanismException { - Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", - "Provider for ExemptionMechanism testing", - srvExemptionMechanism.concat(".").concat(defaultAlg), - ExemptionMechanismProviderClass); - - ExemptionMechanism em = new ExemptionMechanism( - new MyExemptionMechanismSpi(), mProv, defaultAlg) { - }; - - Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]); - - try { - em.genExemptionBlob(); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //failed - } - - em.init(key); - - assertNotNull(em.genExemptionBlob()); - - em = new ExemptionMechanism( - new Mock_ExemptionMechanismSpi(), mProv, defaultAlg) { - }; - key = new Mock_ExemptionMechanismSpi().new tmpKey("Proba", new byte[0]); - em.init(key); - - try { - em.genExemptionBlob(); - fail("ExemptionMechanismException expected"); - } catch (ExemptionMechanismException e) { - //failed - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "genExemptionBlob", - args = {byte[].class} - ) - public void test_genExemptionBlob$B() throws InvalidKeyException, - ExemptionMechanismException, ShortBufferException { - Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", - "Provider for ExemptionMechanism testing", - srvExemptionMechanism.concat(".").concat(defaultAlg), - ExemptionMechanismProviderClass); - - ExemptionMechanism em = new ExemptionMechanism( - new Mock_ExemptionMechanismSpi(), mProv, defaultAlg) { - }; - - Key key = new Mock_ExemptionMechanismSpi().new tmpKey("Proba", new byte[0]); - - try { - em.genExemptionBlob(new byte[10]); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //failed - } - - em.init(key); - - assertEquals(5, (em.genExemptionBlob(new byte[10]))); - - try { - em.genExemptionBlob(new byte[2]); - fail("ShortBufferException expected"); - } catch (ShortBufferException e) { - //failed - } - byte[] b = new byte[] {0,0,0,33,0}; - - try { - em.genExemptionBlob(b); - fail("ExemptionMechanismException expected"); - } catch (ExemptionMechanismException e) { - //failed - } - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "genExemptionBlob", - args = {byte[].class, int.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = ExemptionMechanismSpi.class, - method = "engineGenExemptionBlob", - args = {byte[].class, int.class} - ) - }) - public void test_genExemptionBlob$BI() throws InvalidKeyException, - ExemptionMechanismException, ShortBufferException { - Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", - "Provider for ExemptionMechanism testing", - srvExemptionMechanism.concat(".").concat(defaultAlg), - ExemptionMechanismProviderClass); - - ExemptionMechanism em = new ExemptionMechanism( - new Mock_ExemptionMechanismSpi(), mProv, defaultAlg) { - }; - - Key key = new Mock_ExemptionMechanismSpi().new tmpKey("Proba", new byte[0]); - - try { - em.genExemptionBlob(new byte[10], 2); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //failed - } - - em.init(key); - - assertEquals(5, (em.genExemptionBlob(new byte[10], 5))); - - try { - em.genExemptionBlob(new byte[7], 3); - fail("ShortBufferException expected"); - } catch (ShortBufferException e) { - //failed - } - byte[] b = new byte[] {0, 0, 0, 1, 2, 3, 33, 0}; - - try { - em.genExemptionBlob(b, 3); - fail("ExemptionMechanismException expected"); - } catch (ExemptionMechanismException e) { - //failed - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Tests Exceptions", - method = "getInstance", - args = {java.lang.String.class} - ) - public void test_getInstanceLjava_lang_String() throws Exception { - try { - ExemptionMechanism.getInstance((String) null); - fail("NullPointerException expected"); - } catch (NullPointerException e) { - //expected - } - - Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", - "Provider for ExemptionMechanism testing", - srvExemptionMechanism.concat(".").concat(defaultAlg), - ExemptionMechanismProviderClass); - - ExemptionMechanism em = new ExemptionMechanism( - new Mock_ExemptionMechanismSpi(), mProv, defaultAlg) { - }; - - try { - em.getInstance("WrongAlgName"); - fail("NoSuchAlgorithmException expected"); - } catch (NoSuchAlgorithmException e) { - //expected - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Tests Exceptions", - method = "getInstance", - args = {java.lang.String.class, java.security.Provider.class} - ) - public void test_getInstanceLjava_lang_StringLjava_security_Provider() - throws Exception { - Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", - "Provider for ExemptionMechanism testing", - srvExemptionMechanism.concat(".").concat(defaultAlg), - ExemptionMechanismProviderClass); - - try { - ExemptionMechanism.getInstance((String) null, mProv); - fail("NullPointerException expected"); - } catch (NullPointerException e) { - //expected - } - - ExemptionMechanism em = new ExemptionMechanism( - new Mock_ExemptionMechanismSpi(), mProv, defaultAlg) { - }; - - try { - em.getInstance("WrongAlgName", mProv); - fail("NoSuchAlgorithmException expected"); - } catch (NoSuchAlgorithmException e) { - //expected - } - - try { - em.getInstance("WrongAlgName", (Provider)null); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException e) { - //expected - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getName", - args = {} - ) - public void test_getName() throws Exception { - Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", - "Provider for ExemptionMechanism testing", - srvExemptionMechanism.concat(".").concat(defaultAlg), - ExemptionMechanismProviderClass); - - ExemptionMechanism em = new ExemptionMechanism( - new MyExemptionMechanismSpi(), mProv, defaultAlg) { - }; - - Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]); - - assertEquals(defaultAlg, em.getName()); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getOutputSize", - args = {int.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = ExemptionMechanismSpi.class, - method = "engineGetOutputSize", - args = {int.class} - ) - }) - public void test_getOutputSizeI() throws Exception { - Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", - "Provider for ExemptionMechanism testing", - srvExemptionMechanism.concat(".").concat(defaultAlg), - ExemptionMechanismProviderClass); - - ExemptionMechanism em = new ExemptionMechanism( - new MyExemptionMechanismSpi(), mProv, defaultAlg) { - }; - - Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]); - - try { - em.getOutputSize(10); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //failed - } - - em.init(key); - assertEquals(10, em.getOutputSize(10)); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getProvider", - args = {} - ) - public void test_getProvider() throws Exception { - Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", - "Provider for ExemptionMechanism testing", - srvExemptionMechanism.concat(".").concat(defaultAlg), - ExemptionMechanismProviderClass); - - ExemptionMechanism em = new ExemptionMechanism( - new MyExemptionMechanismSpi(), mProv, defaultAlg) { - }; - - Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]); - - assertEquals(mProv, em.getProvider()); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "init", - args = {java.security.Key.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = ExemptionMechanismSpi.class, - method = "engineInit", - args = {java.security.Key.class} - ) - }) - public void test_initLjava_security_Key() throws Exception { - Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", - "Provider for ExemptionMechanism testing", - srvExemptionMechanism.concat(".").concat(defaultAlg), - ExemptionMechanismProviderClass); - - ExemptionMechanism em = new ExemptionMechanism( - new MyExemptionMechanismSpi(), mProv, defaultAlg) { - }; - - Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]); - - em.init(key); - - KeyGenerator kg = KeyGenerator.getInstance("DES"); - kg.init(56, new SecureRandom()); - key = kg.generateKey(); - - try { - em.init(null); - fail("InvalidKeyException expected"); - } catch (InvalidKeyException e) { - //expected - } - - try { - em.init(key); - fail("ExemptionMechanismException expected"); - } catch (ExemptionMechanismException e) { - //expected - } - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "init", - args = {java.security.Key.class, java.security.AlgorithmParameters.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = ExemptionMechanismSpi.class, - method = "engineInit", - args = {java.security.Key.class, java.security.AlgorithmParameters.class} - ) - }) - public void test_initLjava_security_KeyLjava_security_AlgorithmParameters() - throws Exception { - Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", - "Provider for ExemptionMechanism testing", - srvExemptionMechanism.concat(".").concat(defaultAlg), - ExemptionMechanismProviderClass); - - ExemptionMechanism em = new ExemptionMechanism( - new MyExemptionMechanismSpi(), mProv, defaultAlg) { - }; - - Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]); - - em.init(key, AlgorithmParameters.getInstance("DES")); - - try { - em.init(key, (AlgorithmParameters)null); - fail("InvalidAlgorithmParameterException expected"); - } catch (InvalidAlgorithmParameterException e) { - //expected - } - - KeyGenerator kg = KeyGenerator.getInstance("DES"); - kg.init(56, new SecureRandom()); - key = kg.generateKey(); - - try { - em.init(null, AlgorithmParameters.getInstance("DES")); - fail("InvalidKeyException expected"); - } catch (InvalidKeyException e) { - //expected - } - - try { - em.init(key, AlgorithmParameters.getInstance("DES")); - fail("ExemptionMechanismException expected"); - } catch (ExemptionMechanismException e) { - //expected - } - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "init", - args = {java.security.Key.class, java.security.spec.AlgorithmParameterSpec.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = ExemptionMechanismSpi.class, - method = "engineInit", - args = {java.security.Key.class, java.security.spec.AlgorithmParameterSpec.class} - ) - }) - public void test_initLjava_security_KeyLjava_security_spec_AlgorithmParameterSpec() - throws Exception{ - Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", - "Provider for ExemptionMechanism testing", - srvExemptionMechanism.concat(".").concat(defaultAlg), - ExemptionMechanismProviderClass); - - ExemptionMechanism em = new ExemptionMechanism( - new MyExemptionMechanismSpi(), mProv, defaultAlg) { - }; - - Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]); - - em.init(key, new RSAKeyGenParameterSpec(10, new BigInteger("10"))); - - try { - em.init(key, (AlgorithmParameterSpec)null); - fail("InvalidAlgorithmParameterException expected"); - } catch (InvalidAlgorithmParameterException e) { - //expected - } - - KeyGenerator kg = KeyGenerator.getInstance("DES"); - kg.init(56, new SecureRandom()); - key = kg.generateKey(); - - try { - em.init(null, new RSAKeyGenParameterSpec(10, new BigInteger("10"))); - fail("InvalidKeyException expected"); - } catch (InvalidKeyException e) { - //expected - } - - try { - em.init(key, new RSAKeyGenParameterSpec(10, new BigInteger("10"))); - fail("ExemptionMechanismException expected"); - } catch (ExemptionMechanismException e) { - //expected - } - } -} - - diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/IllegalBlockSizeExceptionTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/IllegalBlockSizeExceptionTest.java deleted file mode 100644 index b98297d21..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/IllegalBlockSizeExceptionTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import javax.crypto.IllegalBlockSizeException; - -import junit.framework.TestCase; - - -@TestTargetClass(IllegalBlockSizeException.class) -/** - * Tests for IllegalBlockSizeException class constructors and - * methods. - * - */ -public class IllegalBlockSizeExceptionTest extends TestCase { - - static String[] msgs = { - "", - "Check new message", - "Check new message Check new message Check new message Check new message Check new message" }; - - static Throwable tCause = new Throwable("Throwable for exception"); - - /** - * Test for IllegalBlockSizeException() constructor - * Assertion: constructs IllegalBlockSizeException with no detail message - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "IllegalBlockSizeException", - args = {} - ) - public void testIllegalBlockSizeException01() { - IllegalBlockSizeException tE = new IllegalBlockSizeException(); - assertNull("getMessage() must return null.", tE.getMessage()); - assertNull("getCause() must return null", tE.getCause()); - } - - /** - * Test for IllegalBlockSizeException(String) constructor - * Assertion: constructs IllegalBlockSizeException with detail message msg. - * Parameter msg is not null. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "IllegalBlockSizeException", - args = {java.lang.String.class} - ) - public void testIllegalBlockSizeException02() { - IllegalBlockSizeException tE; - for (int i = 0; i < msgs.length; i++) { - tE = new IllegalBlockSizeException(msgs[i]); - assertEquals("getMessage() must return: ".concat(msgs[i]), tE - .getMessage(), msgs[i]); - assertNull("getCause() must return null", tE.getCause()); - } - } - - /** - * Test for IllegalBlockSizeException(String) constructor - * Assertion: constructs IllegalBlockSizeException when msg - * is null - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "IllegalBlockSizeException", - args = {java.lang.String.class} - ) - public void testIllegalBlockSizeException03() { - String msg = null; - IllegalBlockSizeException tE = new IllegalBlockSizeException(msg); - assertNull("getMessage() must return null.", tE.getMessage()); - assertNull("getCause() must return null", tE.getCause()); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreementSpiTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreementSpiTest.java deleted file mode 100644 index 395460831..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreementSpiTest.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.security.spec.AlgorithmParameterSpec; - -import javax.crypto.KeyAgreementSpi; -import javax.crypto.SecretKey; -import javax.crypto.ShortBufferException; - -import junit.framework.TestCase; - -import org.apache.harmony.crypto.tests.support.MyKeyAgreementSpi; - -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; - -@TestTargetClass(KeyAgreementSpi.class) -/** - * Tests for KeyAgreementSpi class constructors and methods. - * - */ - -public class KeyAgreementSpiTest extends TestCase { - class Mock_KeyAgreementSpi extends MyKeyAgreementSpi { - - @Override - protected Key engineDoPhase(Key key, boolean lastPhase) throws InvalidKeyException, - IllegalStateException { - return super.engineDoPhase(key, lastPhase); - } - - @Override - protected byte[] engineGenerateSecret() throws IllegalStateException { - return super.engineGenerateSecret(); - } - - @Override - protected SecretKey engineGenerateSecret(String algorithm) throws IllegalStateException, - NoSuchAlgorithmException, InvalidKeyException { - return super.engineGenerateSecret(algorithm); - } - - @Override - protected int engineGenerateSecret(byte[] sharedSecret, int offset) - throws IllegalStateException, ShortBufferException { - return super.engineGenerateSecret(sharedSecret, offset); - } - - @Override - protected void engineInit(Key key, SecureRandom random) throws InvalidKeyException { - super.engineInit(key, random); - } - - @Override - protected void engineInit(Key key, AlgorithmParameterSpec params, SecureRandom random) - throws InvalidKeyException, InvalidAlgorithmParameterException { - super.engineInit(key, params, random); - } - - } - - /** - * Test for KeyAgreementSpi constructor Assertion: constructs - * KeyAgreementSpi - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "KeyAgreementSpi", - args = {} - ) - public void testKeyAgreementSpi01() throws InvalidKeyException, - ShortBufferException, NoSuchAlgorithmException, - InvalidAlgorithmParameterException { - Mock_KeyAgreementSpi kaSpi = new Mock_KeyAgreementSpi(); - - assertNull("Not null result", kaSpi.engineDoPhase(null, true)); - try { - kaSpi.engineDoPhase(null, false); - fail("IllegalStateException must be thrown"); - } catch (IllegalStateException e) { - } - byte[] bb = kaSpi.engineGenerateSecret(); - assertEquals("Length is not 0", bb.length, 0); - assertEquals("Returned integer is not 0", kaSpi.engineGenerateSecret(new byte[1], 10), -1); - assertNull("Not null result", kaSpi.engineGenerateSecret("aaa")); - try { - kaSpi.engineGenerateSecret(""); - fail("NoSuchAlgorithmException must be thrown"); - } catch (NoSuchAlgorithmException e) { - } - Key key = null; - try { - kaSpi.engineInit(key, new SecureRandom()); - fail("IllegalArgumentException must be thrown"); - } catch (IllegalArgumentException e) { - } - AlgorithmParameterSpec params = null; - try { - kaSpi.engineInit(key, params, new SecureRandom()); - fail("IllegalArgumentException must be thrown"); - } catch (IllegalArgumentException e) { - } - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreementTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreementTest.java deleted file mode 100644 index 220c6c67f..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreementTest.java +++ /dev/null @@ -1,975 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.KnownFailure; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.math.BigInteger; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.PrivateKey; -import java.security.Provider; -import java.security.PublicKey; -import java.security.SecureRandom; -import java.security.spec.AlgorithmParameterSpec; -import java.security.spec.DSAParameterSpec; -import java.security.spec.RSAKeyGenParameterSpec; - -import javax.crypto.KeyAgreement; -import javax.crypto.KeyAgreementSpi; -import javax.crypto.ShortBufferException; -import javax.crypto.interfaces.DHPrivateKey; -import javax.crypto.spec.DHParameterSpec; - -import org.apache.harmony.crypto.tests.support.MyKeyAgreementSpi; -import org.apache.harmony.security.tests.support.SpiEngUtils; -import org.apache.harmony.security.tests.support.TestKeyPair; - -import junit.framework.TestCase; - - -@TestTargetClass(KeyAgreement.class) -/** - * Tests for KeyAgreement constructor and methods - * - */ - -public class KeyAgreementTest extends TestCase { - - public static final String srvKeyAgreement = "KeyAgreement"; - - private static String defaultAlgorithm = "DH"; - - private static String defaultProviderName = null; - - private static Provider defaultProvider = null; - - private static boolean DEFSupported = false; - - private static final String NotSupportMsg = "There is no suitable provider for KeyAgreement"; - - private static final String[] invalidValues = SpiEngUtils.invalidValues; - - private static String[] validValues = { "DH", "dH", - "Dh", "dh" }; - - private static PrivateKey privKey = null; - - private static PublicKey publKey = null; - - private static boolean initKeys = false; - - static { - defaultProvider = SpiEngUtils.isSupport(defaultAlgorithm, - srvKeyAgreement); - DEFSupported = (defaultProvider != null); - defaultProviderName = (DEFSupported ? defaultProvider.getName() : null); - } - - private void createKeys() throws Exception { - if (!initKeys) { - TestKeyPair tkp = new TestKeyPair(defaultAlgorithm); - privKey = tkp.getPrivate(); - publKey = tkp.getPublic(); - initKeys = true; - } - - } - - private KeyAgreement[] createKAs() throws Exception { - if (!DEFSupported) { - fail(NotSupportMsg); - } - - KeyAgreement[] ka = new KeyAgreement[3]; - ka[0] = KeyAgreement.getInstance(defaultAlgorithm); - ka[1] = KeyAgreement.getInstance(defaultAlgorithm, defaultProvider); - ka[2] = KeyAgreement.getInstance(defaultAlgorithm, - defaultProviderName); - return ka; - } - - public static String getDefAlg() { - return defaultAlgorithm; - } - - /** - * Test for getInstance(String algorithm) method Assertions: - * throws NullPointerException when algorithm is null throws - * NoSuchAlgorithmException when algorithm isnot available - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class} - ) - public void testGetInstanceString01() throws NoSuchAlgorithmException { - try { - KeyAgreement.getInstance(null); - fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - KeyAgreement.getInstance(invalidValues[i]); - fail("NoSuchAlgorithmException must be thrown"); - } catch (NoSuchAlgorithmException e) { - } - } - } - - /** - * Test for getInstance(String algorithm) method Assertions: - * returns KeyAgreement object - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class} - ) - public void testGetInstanceString02() throws NoSuchAlgorithmException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - KeyAgreement keyA; - for (int i = 0; i < validValues.length; i++) { - keyA = KeyAgreement.getInstance(validValues[i]); - assertEquals("Incorrect algorithm", keyA.getAlgorithm(), - validValues[i]); - } - } - - /** - * Test for getInstance(String algorithm, String provider) - * method Assertions: throws NullPointerException when algorithm is null - * throws NoSuchAlgorithmException when algorithm is not available - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testGetInstanceStringString01() - throws NoSuchAlgorithmException, IllegalArgumentException, - NoSuchProviderException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - try { - KeyAgreement.getInstance(null, defaultProviderName); - fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - KeyAgreement.getInstance(invalidValues[i], defaultProviderName); - fail("NoSuchAlgorithmException must be thrown"); - } catch (NoSuchAlgorithmException e) { - } - } - } - - /** - * Test for getInstance(String algorithm, String provider) - * method Assertions: throws IllegalArgumentException when provider is null - * or empty throws NoSuchProviderException when provider has not be - * configured - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testGetInstanceStringString02() - throws IllegalArgumentException, NoSuchAlgorithmException, - NoSuchProviderException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - String provider = null; - for (int i = 0; i < validValues.length; i++) { - try { - KeyAgreement.getInstance(validValues[i], provider); - fail("IllegalArgumentException must be thrown when provider is null"); - } catch (IllegalArgumentException e) { - } - try { - KeyAgreement.getInstance(validValues[i], ""); - fail("IllegalArgumentException must be thrown when provider is empty"); - } catch (IllegalArgumentException e) { - } - for (int j = 1; j < invalidValues.length; j++) { - try { - KeyAgreement.getInstance(validValues[i], invalidValues[j]); - fail("NoSuchProviderException must be thrown (algorithm: " - .concat(validValues[i]).concat(" provider: ") - .concat(invalidValues[j]).concat(")")); - } catch (NoSuchProviderException e) { - } - } - } - } - - /** - * Test for getInstance(String algorithm, String provider) - * method Assertions: returns KeyAgreement object - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testGetInstanceStringString03() - throws IllegalArgumentException, NoSuchAlgorithmException, - NoSuchProviderException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - KeyAgreement keyA; - for (int i = 0; i < validValues.length; i++) { - keyA = KeyAgreement - .getInstance(validValues[i], defaultProviderName); - assertEquals("Incorrect algorithm", keyA.getAlgorithm(), - validValues[i]); - assertEquals("Incorrect provider", keyA.getProvider().getName(), - defaultProviderName); - } - } - - /** - * Test for getInstance(String algorithm, Provider provider) - * method Assertions: throws NullPointerException when algorithm is null - * throws NoSuchAlgorithmException when algorithm isnot available - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.security.Provider.class} - ) - public void testGetInstanceStringProvider01() - throws NoSuchAlgorithmException, IllegalArgumentException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - try { - KeyAgreement.getInstance(null, defaultProvider); - fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - KeyAgreement.getInstance(invalidValues[i], defaultProvider); - fail("NoSuchAlgorithmException must be thrown"); - } catch (NoSuchAlgorithmException e) { - } - } - } - - /** - * Test for getInstance(String algorithm, Provider provider) - * method Assertions: throws IllegalArgumentException when provider is null - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.security.Provider.class} - ) - public void testGetInstanceStringProvider02() - throws NoSuchAlgorithmException, IllegalArgumentException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - Provider provider = null; - for (int i = 0; i < invalidValues.length; i++) { - try { - KeyAgreement.getInstance(invalidValues[i], provider); - fail("IllegalArgumentException must be thrown"); - } catch (IllegalArgumentException e) { - } - } - } - - /** - * Test for getInstance(String algorithm, Provider provider) - * method Assertions: returns KeyAgreement object - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.security.Provider.class} - ) - public void testGetInstanceStringProvider03() - throws IllegalArgumentException, NoSuchAlgorithmException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - KeyAgreement keyA; - for (int i = 0; i < validValues.length; i++) { - keyA = KeyAgreement.getInstance(validValues[i], defaultProvider); - assertEquals("Incorrect algorithm", keyA.getAlgorithm(), - validValues[i]); - assertEquals("Incorrect provider", keyA.getProvider(), - defaultProvider); - } - } - - /** - * Test for the methods: init(Key key) - * generateSecret() - * generateSecret(byte[] sharedsecret, int offset) - * generateSecret(String algorithm) - * Assertions: initializes KeyAgreement; returns sharedSecret; puts - * sharedsecret in buffer and return numbers of bytes; returns SecretKey - * object - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality only.", - method = "init", - args = {java.security.Key.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality only.", - method = "generateSecret", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality only.", - method = "generateSecret", - args = {byte[].class, int.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality only.", - method = "generateSecret", - args = {java.lang.String.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality only.", - clazz = KeyAgreementSpi.class, - method = "engineGenerateSecret", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality only.", - clazz = KeyAgreementSpi.class, - method = "engineGenerateSecret", - args = {byte[].class, int.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality only.", - clazz = KeyAgreementSpi.class, - method = "engineGenerateSecret", - args = {java.lang.String.class} - ) - }) - public void testGenerateSecret03() throws Exception { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - createKeys(); - KeyAgreement[] kAgs = createKAs(); - - byte[] bb; - byte[] bb1 = new byte[10]; - for (int i = 0; i < kAgs.length; i++) { - kAgs[i].init(privKey); - kAgs[i].doPhase(publKey, true); - bb = kAgs[i].generateSecret(); - kAgs[i].init(privKey); - kAgs[i].doPhase(publKey, true); - bb1 = new byte[bb.length + 10]; - kAgs[i].generateSecret(bb1, 9); - kAgs[i].init(privKey); - kAgs[i].doPhase(publKey, true); - kAgs[i].generateSecret("DES"); - } - } - - /** - * Test for doPhase(Key key, boolean lastPhase) method - * Assertion: throws InvalidKeyException if key is not appropriate - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "doPhase", - args = {java.security.Key.class, boolean.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = KeyAgreementSpi.class, - method = "engineDoPhase", - args = {java.security.Key.class, boolean.class} - ) - }) - public void testDoPhase() throws Exception { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - createKeys(); - KeyAgreement[] kAgs = createKAs(); - DHParameterSpec dhPs = ((DHPrivateKey) privKey).getParams(); - SecureRandom randomNull = null; - SecureRandom random = new SecureRandom(); - - for (int i = 0; i < kAgs.length; i++) { - try { - kAgs[i].doPhase(publKey, true); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //expected - } - - kAgs[i].init(privKey); - - try { - kAgs[i].doPhase(privKey, false); - fail("InvalidKeyException must be throw"); - } catch (InvalidKeyException e) { - } - - try { - kAgs[i].doPhase(privKey, true); - fail("InvalidKeyException must be throw"); - } catch (InvalidKeyException e) { - } - - kAgs[i].init(privKey, dhPs); - kAgs[i].doPhase(publKey, true); - kAgs[i].init(privKey, dhPs, random); - kAgs[i].doPhase(publKey, true); - } - } - - /** - * Test for the methods init(Key key) - * init(Key key, SecureRandom random) - * init(Key key, AlgorithmParameterSpec params) - * init(Key key, AlgorithmParameterSpec params, SecureRandom random) - * Assertion: throws InvalidKeyException when key is inappropriate - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks InvalidKeyException.", - method = "init", - args = {java.security.Key.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks InvalidKeyException.", - method = "init", - args = {java.security.Key.class, java.security.spec.AlgorithmParameterSpec.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks InvalidKeyException.", - clazz = KeyAgreementSpi.class, - method = "engineInit", - args = {java.security.Key.class, java.security.spec.AlgorithmParameterSpec.class, java.security.SecureRandom.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks InvalidKeyException.", - clazz = KeyAgreementSpi.class, - method = "engineInit", - args = {java.security.Key.class, java.security.SecureRandom.class} - ) - }) - public void testInit01() throws Exception { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - createKeys(); - KeyAgreement[] kAgs = createKAs(); - - SecureRandom random = null; - AlgorithmParameterSpec aps = null; - DHParameterSpec dhPs = new DHParameterSpec(new BigInteger("56"), - new BigInteger("56")); - for (int i = 0; i < kAgs.length; i++) { - try { - kAgs[i].init(publKey); - fail("InvalidKeyException must be throw"); - } catch (InvalidKeyException e) { - } - try { - kAgs[i].init(publKey, new SecureRandom()); - fail("InvalidKeyException must be throw"); - } catch (InvalidKeyException e) { - } - try { - kAgs[i].init(publKey, random); - fail("InvalidKeyException must be throw"); - } catch (InvalidKeyException e) { - } - try { - kAgs[i].init(publKey, dhPs); - fail("InvalidKeyException must be throw"); - } catch (InvalidKeyException e) { - } - try { - kAgs[i].init(publKey, aps); - fail("InvalidKeyException must be throw"); - } catch (InvalidKeyException e) { - } - try { - kAgs[i].init(publKey, dhPs, new SecureRandom()); - fail("InvalidKeyException must be throw"); - } catch (InvalidKeyException e) { - } - } - } - - /** - * Test for the methods - * init(Key key, AlgorithmParameterSpec params) - * init(Key key, AlgorithmParameterSpec params, SecureRandom random) - * Assertion: throws AlgorithmParameterException when params are - * inappropriate - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks InvalidAlgorithmParameterException.This is a complete subset of tests for exceptions checking for init methods group", - method = "init", - args = {java.security.Key.class, java.security.spec.AlgorithmParameterSpec.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks InvalidAlgorithmParameterException.This is a complete subset of tests for exceptions checking for init methods group", - clazz = KeyAgreementSpi.class, - method = "engineInit", - args = {java.security.Key.class, java.security.spec.AlgorithmParameterSpec.class, java.security.SecureRandom.class} - ) - }) - public void testInit02() throws Exception { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - createKeys(); - KeyAgreement[] kAgs = createKAs(); - - SecureRandom random = null; - DSAParameterSpec dsa = new DSAParameterSpec(new BigInteger("56"), - new BigInteger("56"), new BigInteger("56")); - for (int i = 0; i < kAgs.length; i++) { - try { - kAgs[i].init(privKey, dsa); - fail("InvalidAlgorithmParameterException or InvalidKeyException must be throw"); - } catch (InvalidAlgorithmParameterException e) { - } catch (InvalidKeyException e) { - } - try { - kAgs[i].init(privKey, dsa, new SecureRandom()); - fail("InvalidAlgorithmParameterException or InvalidKeyException must be throw"); - } catch (InvalidAlgorithmParameterException e) { - } catch (InvalidKeyException e) { - } - try { - kAgs[i].init(privKey, dsa, random); - fail("InvalidAlgorithmParameterException or InvalidKeyException must be throw"); - } catch (InvalidAlgorithmParameterException e) { - } catch (InvalidKeyException e) { - } - } - } - - /** - * Test for the methods: init(Key key) - * init(Key key, SecureRandom random) - * generateSecret() - * Assertions: initializes KeyAgreement and returns byte array - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality.", - method = "init", - args = {java.security.Key.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality.", - method = "init", - args = {java.security.Key.class, java.security.SecureRandom.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality.", - method = "generateSecret", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality.", - clazz = KeyAgreementSpi.class, - method = "engineInit", - args = {java.security.Key.class, java.security.SecureRandom.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality.", - clazz = KeyAgreementSpi.class, - method = "engineInit", - args = {java.security.Key.class, java.security.spec.AlgorithmParameterSpec.class, java.security.SecureRandom.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality.", - clazz = KeyAgreementSpi.class, - method = "engineGenerateSecret", - args = {} - ) - }) - public void testInit03() throws Exception { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - createKeys(); - KeyAgreement[] kAgs = createKAs(); - - byte[] bbRes1; - byte[] bbRes2; - byte[] bbRes3; - SecureRandom randomNull = null; - SecureRandom random = new SecureRandom(); - for (int i = 0; i < kAgs.length; i++) { - kAgs[i].init(privKey); - kAgs[i].doPhase(publKey, true); - bbRes1 = kAgs[i].generateSecret(); - kAgs[i].init(privKey, random); - kAgs[i].doPhase(publKey, true); - bbRes2 = kAgs[i].generateSecret(); - assertEquals("Incorrect byte array length", bbRes1.length, - bbRes2.length); - for (int j = 0; j < bbRes1.length; j++) { - assertEquals("Incorrect byte (index: ".concat( - Integer.toString(i)).concat(")"), bbRes1[j], bbRes2[j]); - } - kAgs[i].init(privKey, randomNull); - kAgs[i].doPhase(publKey, true); - bbRes3 = kAgs[i].generateSecret(); - assertEquals("Incorrect byte array length", bbRes1.length, - bbRes3.length); - for (int j = 0; j < bbRes1.length; j++) { - assertEquals("Incorrect byte (index: ".concat( - Integer.toString(i)).concat(")"), bbRes1[j], bbRes3[j]); - } - } - } - - /** - * Test for the methods: - * init(Key key, AlgorithmParameterSpec params) - * init(Key key, AlgorithmParameterSpec params, SecureRandom random) - * generateSecret() - * Assertions: initializes KeyAgreement and returns byte array - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Checks functionality.", - method = "init", - args = {java.security.Key.class, java.security.spec.AlgorithmParameterSpec.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks functionality.", - method = "init", - args = {java.security.Key.class, java.security.spec.AlgorithmParameterSpec.class, java.security.SecureRandom.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Checks functionality.", - method = "generateSecret", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Checks functionality.", - clazz = KeyAgreementSpi.class, - method = "engineInit", - args = {java.security.Key.class, SecureRandom.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Checks functionality.", - clazz = KeyAgreementSpi.class, - method = "engineInit", - args = {java.security.Key.class, java.security.spec.AlgorithmParameterSpec.class, java.security.SecureRandom.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Checks functionality.", - clazz = KeyAgreementSpi.class, - method = "engineGenerateSecret", - args = {} - ) - }) - public void testInit04() throws Exception, - InvalidAlgorithmParameterException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - createKeys(); - KeyAgreement[] kAgs = createKAs(); - - DHParameterSpec dhPs = ((DHPrivateKey) privKey).getParams(); - AlgorithmParameterSpec aps = new RSAKeyGenParameterSpec(10, new BigInteger("10")); - - byte[] bbRes1; - byte[] bbRes2; - byte[] bbRes3; - SecureRandom randomNull = null; - SecureRandom random = new SecureRandom(); - for (int i = 0; i < kAgs.length; i++) { - kAgs[i].init(privKey, dhPs); - kAgs[i].doPhase(publKey, true); - bbRes1 = kAgs[i].generateSecret(); - kAgs[i].init(privKey, dhPs, random); - kAgs[i].doPhase(publKey, true); - bbRes2 = kAgs[i].generateSecret(); - assertEquals("Incorrect byte array length", bbRes1.length, - bbRes2.length); - for (int j = 0; j < bbRes1.length; j++) { - assertEquals("Incorrect byte (index: ".concat( - Integer.toString(i)).concat(")"), bbRes1[j], bbRes2[j]); - } - kAgs[i].init(privKey, dhPs, randomNull); - kAgs[i].doPhase(publKey, true); - bbRes3 = kAgs[i].generateSecret(); - assertEquals("Incorrect byte array length", bbRes1.length, - bbRes3.length); - for (int j = 0; j < bbRes1.length; j++) { - assertEquals("Incorrect byte (index: ".concat( - Integer.toString(i)).concat(")"), bbRes1[j], bbRes3[j]); - } - - try { - kAgs[i].init(publKey, dhPs, random); - fail("InvalidKeyException expected"); - } catch (InvalidKeyException e) { - //expected - } - try { - kAgs[i].init(privKey, aps, random); - fail("InvalidAlgorithmParameterException expected"); - } catch (InvalidAlgorithmParameterException e) { - //expected - } - } - } - - class Mock_KeyAgreement extends KeyAgreement { - protected Mock_KeyAgreement(KeyAgreementSpi arg0, Provider arg1, String arg2) { - super(arg0, arg1, arg2); - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "KeyAgreement", - args = {javax.crypto.KeyAgreementSpi.class, java.security.Provider.class, java.lang.String.class} - ) - public void test_constructor() { - assertNotNull(new Mock_KeyAgreement(null, null, null)); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getAlgorithm", - args = {} - ) - public void test_getAlgorithm() throws NoSuchAlgorithmException { - Mock_KeyAgreement mka = new Mock_KeyAgreement(null, null, null); - assertNull(mka.getAlgorithm()); - - KeyAgreement keyA; - for (int i = 0; i < validValues.length; i++) { - keyA = KeyAgreement.getInstance(validValues[i]); - assertEquals("Incorrect algorithm", keyA.getAlgorithm(), - validValues[i]); - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getProvider", - args = {} - ) - public void test_getProvider() throws NoSuchAlgorithmException { - KeyAgreement keyA; - for (int i = 0; i < validValues.length; i++) { - keyA = KeyAgreement.getInstance(validValues[i]); - assertNotNull(keyA.getProvider()); - } - } - -@TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "generateSecret", - args = {byte[].class, int.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - clazz = KeyAgreementSpi.class, - method = "engineGenerateSecret", - args = {byte[].class, int.class} - )}) - public void test_generateSecret$BI() throws Exception { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - createKeys(); - KeyAgreement[] kAgs = createKAs(); - KeyAgreement ka = KeyAgreement.getInstance("DH"); - - byte[] bb1 = new byte[1]; - try { - ka.generateSecret(bb1, 0); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //expected - } - ka.init(privKey); - ka.doPhase(publKey, true); - try { - ka.generateSecret(bb1, 0); - fail("ShortBufferException expected"); - } catch (ShortBufferException e) { - //expected - } - } - -@TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "generateSecret", - args = {java.lang.String.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - clazz = KeyAgreementSpi.class, - method = "engineGenerateSecret", - args = {java.lang.String.class} - )}) - @KnownFailure("Does not throw expected exception") - public void test_generateSecretLjava_lang_String() throws Exception { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - createKeys(); - KeyAgreement[] kAgs = createKAs(); - KeyAgreement ka = KeyAgreement.getInstance("DH"); - - byte[] bb1 = new byte[1]; - try { - ka.generateSecret("dh"); - fail("IllegalStateException expected"); - } catch (IllegalStateException e) { - //expected - } - ka.init(privKey); - ka.doPhase(publKey, true); - try { - ka.generateSecret("Wrong alg name"); - fail("NoSuchAlgorithmException expected"); - } catch (NoSuchAlgorithmException e) { - //expected - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "init", - args = {java.security.Key.class, java.security.SecureRandom.class} - ) - public void test_initLjava_security_KeyLjava_security_SecureRandom() throws Exception { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - createKeys(); - KeyAgreement[] kAgs = createKAs(); - KeyAgreement ka = KeyAgreement.getInstance("DH"); - - ka.init(privKey, new SecureRandom()); - try { - ka.init(publKey, new SecureRandom()); - fail("InvalidKeyException expected"); - } catch (InvalidKeyException e) { - //expected - } - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGeneratorSpiTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGeneratorSpiTest.java deleted file mode 100644 index 06059866f..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGeneratorSpiTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.security.InvalidAlgorithmParameterException; -import java.security.SecureRandom; -import java.security.spec.AlgorithmParameterSpec; -import javax.crypto.KeyGeneratorSpi; -import javax.crypto.SecretKey; - -import org.apache.harmony.crypto.tests.support.MyKeyGeneratorSpi; - -import junit.framework.TestCase; - -@TestTargetClass(KeyGeneratorSpi.class) -/** - * Tests for KeyGeneratorSpi class constructors and methods. - * - */ - -public class KeyGeneratorSpiTest extends TestCase { - class Mock_KeyGeneratorSpi extends MyKeyGeneratorSpi { - - @Override - protected SecretKey engineGenerateKey() { - return super.engineGenerateKey(); - } - - @Override - protected void engineInit(SecureRandom random) { - super.engineInit(random); - } - - @Override - protected void engineInit(AlgorithmParameterSpec params, SecureRandom random) - throws InvalidAlgorithmParameterException { - super.engineInit(params, random); - } - - @Override - protected void engineInit(int keysize, SecureRandom random) { - super.engineInit(keysize, random); - } - - } - - /** - * Test for KeyGeneratorSpi constructor Assertion: constructs - * KeyGeneratorSpi - */ - @TestTargetNew(level = TestLevel.COMPLETE, notes = "", method = "KeyGeneratorSpi", args = {}) - public void testKeyGeneratorSpi01() throws InvalidAlgorithmParameterException { - Mock_KeyGeneratorSpi kgSpi = new Mock_KeyGeneratorSpi(); - assertNull("Not null result", kgSpi.engineGenerateKey()); - try { - kgSpi.engineInit(77, new SecureRandom()); - fail("IllegalArgumentException must be thrown"); - } catch (IllegalArgumentException e) { - } - try { - kgSpi.engineInit(new SecureRandom()); - fail("IllegalArgumentException must be thrown"); - } catch (IllegalArgumentException e) { - } - AlgorithmParameterSpec aps = null; - try { - kgSpi.engineInit(aps, new SecureRandom()); - fail("InvalidAlgorithmParameterException must be thrown when parameter is null"); - } catch (InvalidAlgorithmParameterException e) { - } - aps = new APSpecSpi(); - kgSpi.engineInit(aps, new SecureRandom()); - } - -} - -class APSpecSpi implements AlgorithmParameterSpec { - -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGeneratorTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGeneratorTest.java deleted file mode 100644 index 8451979fa..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGeneratorTest.java +++ /dev/null @@ -1,690 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.math.BigInteger; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidParameterException; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.Provider; -import java.security.SecureRandom; -import java.security.spec.AlgorithmParameterSpec; -import java.security.spec.DSAParameterSpec; -import java.security.spec.RSAKeyGenParameterSpec; - -import javax.crypto.Cipher; -import javax.crypto.KeyGenerator; -import javax.crypto.KeyGeneratorSpi; -import javax.crypto.SecretKey; -import javax.crypto.spec.IvParameterSpec; - -import org.apache.harmony.crypto.tests.support.MyKeyGeneratorSpi; -import org.apache.harmony.security.tests.support.SpiEngUtils; - -import junit.framework.TestCase; - - -@TestTargetClass(KeyGenerator.class) -/** - * Tests for KeyGenerator constructor and methods - * - */ - -public class KeyGeneratorTest extends TestCase { - - public static final String srvKeyGenerator = "KeyGenerator"; - - public static final String validAlgorithmsKeyGenerator [] = - {"DESede", "DES", "AES", "HmacMD5"}; - - private static final int [] validKeySizes = { 168, 56, 256, 56}; - - private static int defaultKeySize = -1; - - private static String defaultAlgorithm = null; - - private static String defaultProviderName = null; - - private static Provider defaultProvider = null; - - private static boolean DEFSupported = false; - - private static final String NotSupportMsg = "There is no suitable provider for KeyGenerator"; - - private static final String[] invalidValues = SpiEngUtils.invalidValues; - - private static String[] validValues = new String[3]; - - static { - for (int i = 0; i < validAlgorithmsKeyGenerator.length; i++) { - defaultProvider = SpiEngUtils.isSupport(validAlgorithmsKeyGenerator[i], - srvKeyGenerator); - DEFSupported = (defaultProvider != null); - if (DEFSupported) { - defaultAlgorithm = validAlgorithmsKeyGenerator[i]; - defaultKeySize = validKeySizes[i]; - defaultProviderName = defaultProvider.getName(); - validValues[0] = defaultAlgorithm; - validValues[1] = defaultAlgorithm.toUpperCase(); - validValues[2] = defaultAlgorithm.toLowerCase(); - break; - } - } - } - - private KeyGenerator[] createKGs() throws Exception { - if (!DEFSupported) { - fail(NotSupportMsg); - } - - KeyGenerator [] kg = new KeyGenerator[3]; - kg[0] = KeyGenerator.getInstance(defaultAlgorithm); - kg[1] = KeyGenerator.getInstance(defaultAlgorithm, defaultProvider); - kg[2] = KeyGenerator.getInstance(defaultAlgorithm, defaultProviderName); - return kg; - } - - - /** - * Test for KeyGenerator constructor Assertion: returns - * KeyGenerator object - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "KeyGenerator", - args = {javax.crypto.KeyGeneratorSpi.class, java.security.Provider.class, java.lang.String.class} - ) - public void testKeyGenerator() throws NoSuchAlgorithmException, - InvalidAlgorithmParameterException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - KeyGeneratorSpi spi = new MyKeyGeneratorSpi(); - KeyGenerator keyG = new myKeyGenerator(spi, defaultProvider, - defaultAlgorithm); - assertEquals("Incorrect algorithm", keyG.getAlgorithm(), - defaultAlgorithm); - assertEquals("Incorrect provider", keyG.getProvider(), defaultProvider); - AlgorithmParameterSpec params = null; - int keysize = 0; - try { - keyG.init(params, null); - fail("InvalidAlgorithmParameterException must be thrown"); - } catch (InvalidAlgorithmParameterException e) { - } - try { - keyG.init(keysize, null); - fail("IllegalArgumentException must be thrown"); - } catch (IllegalArgumentException e) { - } - keyG = new myKeyGenerator(null, null, null); - assertNull("Algorithm must be null", keyG.getAlgorithm()); - assertNull("Provider must be null", keyG.getProvider()); - - try { - keyG.init(params, null); - fail("NullPointerException must be thrown"); - } catch (NullPointerException e) { - } - try { - keyG.init(keysize, null); - fail("NullPointerException or InvalidParameterException must be thrown"); - } catch (InvalidParameterException e) { - } catch (NullPointerException e) { - } - } - - /* - * Test for getInstance(String algorithm) method Assertions: - * throws NullPointerException when algorithm is null throws - * NoSuchAlgorithmException when algorithm isnot available - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class} - ) - public void testGetInstanceString01() throws NoSuchAlgorithmException { - try { - KeyGenerator.getInstance(null); - fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - KeyGenerator.getInstance(invalidValues[i]); - fail("NoSuchAlgorithmException should be thrown"); - } catch (NoSuchAlgorithmException e) { - } - } - } - - /* - * Test for getInstance(String algorithm) method - * Assertions: returns KeyGenerator object - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class} - ) - public void testGetInstanceString02() throws NoSuchAlgorithmException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - KeyGenerator keyG; - for (int i = 0; i < validValues.length; i++) { - keyG = KeyGenerator.getInstance(validValues[i]); - assertEquals("Incorrect algorithm", keyG.getAlgorithm(), validValues[i]); - } - } - - /* - * Test for getInstance(String algorithm, String provider) method - * Assertions: - * throws NullPointerException when algorithm is null - * throws NoSuchAlgorithmException when algorithm isnot available - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testGetInstanceStringString01() throws - NoSuchAlgorithmException, IllegalArgumentException, - NoSuchProviderException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - try { - KeyGenerator.getInstance(null, defaultProviderName); - fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - KeyGenerator.getInstance(invalidValues[i], defaultProviderName); - fail("NoSuchAlgorithmException must be thrown"); - } catch (NoSuchAlgorithmException e) { - } - } - } - - /* - * Test for getInstance(String algorithm, String provider) method - * Assertions: - * throws IllegalArgumentException when provider is null or empty - * throws NoSuchProviderException when provider has not be configured - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testGetInstanceStringString02() throws IllegalArgumentException, - NoSuchAlgorithmException, NoSuchProviderException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - String provider = null; - for (int i = 0; i < validValues.length; i++) { - try { - KeyGenerator.getInstance(validValues[i], provider); - fail("IllegalArgumentException must be thrown when provider is null"); - } catch (IllegalArgumentException e) { - } - try { - KeyGenerator.getInstance(validValues[i], ""); - fail("IllegalArgumentException must be thrown when provider is empty"); - } catch (IllegalArgumentException e) { - } - for (int j = 1; j < invalidValues.length; j++) { - try { - KeyGenerator.getInstance(validValues[i], invalidValues[j]); - fail("NoSuchProviderException must be thrown (algorithm: " - .concat(validValues[i]).concat(" provider: ") - .concat(invalidValues[j]).concat(")")); - } catch (NoSuchProviderException e) { - } - } - } - } - - /* - * Test for getInstance(String algorithm, String provider) method - * Assertions: returns KeyGenerator object - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testGetInstanceStringString03() throws IllegalArgumentException, - NoSuchAlgorithmException, NoSuchProviderException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - KeyGenerator keyG; - for (int i = 0; i < validValues.length; i++) { - keyG = KeyGenerator.getInstance(validValues[i], defaultProviderName); - assertEquals("Incorrect algorithm", keyG.getAlgorithm(), validValues[i]); - assertEquals("Incorrect provider", keyG.getProvider().getName(), defaultProviderName); - } - } - - /* - * Test for getInstance(String algorithm, Provider provider) method - * Assertions: - * throws NullPointerException when algorithm is null - * throws NoSuchAlgorithmException when algorithm isnot available - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.security.Provider.class} - ) - public void testGetInstanceStringProvider01() throws NoSuchAlgorithmException, - IllegalArgumentException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - try { - KeyGenerator.getInstance(null, defaultProvider); - fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - KeyGenerator.getInstance(invalidValues[i], defaultProvider); - fail("NoSuchAlgorithmException must be thrown"); - } catch (NoSuchAlgorithmException e) { - } - } - } - /* - * Test for getInstance(String algorithm, Provider provider) method - * Assertions: - * throws IllegalArgumentException when provider is null - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.security.Provider.class} - ) - public void testGetInstanceStringProvider02() throws NoSuchAlgorithmException, - IllegalArgumentException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - Provider provider = null; - for (int i = 0; i < invalidValues.length; i++) { - try { - KeyGenerator.getInstance(invalidValues[i], provider); - fail("IllegalArgumentException must be thrown"); - } catch (IllegalArgumentException e) { - } - } - } - - /* - * Test for getInstance(String algorithm, Provider provider) method - * Assertions: returns KeyGenerator object - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.security.Provider.class} - ) - public void testGetInstanceStringProvider03() throws IllegalArgumentException, - NoSuchAlgorithmException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - KeyGenerator keyA; - for (int i = 0; i < validValues.length; i++) { - keyA = KeyGenerator.getInstance(validValues[i], defaultProvider); - assertEquals("Incorrect algorithm", keyA.getAlgorithm(), validValues[i]); - assertEquals("Incorrect provider", keyA.getProvider(), defaultProvider); - } - } - - /* - * Test for init(int keysize) and - * init(int keysize, SecureRandom random) methods - * Assertion: throws InvalidParameterException if keysize is wrong - * - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - method = "init", - args = {int.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - method = "init", - args = {int.class, java.security.SecureRandom.class} - ) - }) - public void testInitKey() throws Exception { - byte flag = 0xF; - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - if (defaultAlgorithm - .equals(validAlgorithmsKeyGenerator[validAlgorithmsKeyGenerator.length - 1])) { - return; - } - int[] size = { Integer.MIN_VALUE, -1, 0, 112, 168, Integer.MAX_VALUE }; - KeyGenerator[] kgs = createKGs(); - SecureRandom random = new SecureRandom(); - - for (int i = 0; i < kgs.length; i++) { - for (int j = 0; j < size.length; j++) { - try { - kgs[i].init(size[j]); - flag &= 0xE; - } catch (InvalidParameterException ignore) { - flag &= 0xD; - } - - try { - kgs[i].init(size[j], random); - flag &= 0xB; - } catch (InvalidParameterException ignore) { - flag &= 0x7; - } - } - } - assertTrue(flag == 0); - } - - /* - * Test for init(AlgorithmParameterSpec params) and - * init(AlgorithmParameterSpec params, SecureRandom random) methods - * Assertion: throws InvalidAlgorithmParameterException when params is null - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks exceptions only", - method = "init", - args = {java.security.spec.AlgorithmParameterSpec.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks exceptions only", - method = "init", - args = {java.security.spec.AlgorithmParameterSpec.class, java.security.SecureRandom.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks exceptions only", - clazz = KeyGeneratorSpi.class, - method = "engineInit", - args = {java.security.spec.AlgorithmParameterSpec.class, java.security.SecureRandom.class} - ) - }) - public void testInitParams() throws Exception { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - KeyGenerator [] kgs = createKGs(); - AlgorithmParameterSpec aps = null; - - for (int i = 0; i < kgs.length; i++) { - try { - kgs[i].init(aps); - fail("InvalidAlgorithmParameterException must be thrown"); - } catch (InvalidAlgorithmParameterException e) { - } - try { - kgs[i].init(aps, new SecureRandom()); - fail("InvalidAlgorithmParameterException must be thrown"); - } catch (InvalidAlgorithmParameterException e) { - } - } - } - - /* - * Test for generateKey() and - * init(SecureRandom random) methods - * init(int keysize, SecureRandom random) methods - * init(int keysize) methods - * init(AlgorithmParameterSpec params, SecureRandom random) methods - * init(AlgorithmParameterSpec params) methods - * Assertions: - * initializes KeyGenerator; - * returns SecretKey object - * - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "generateKey", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = KeyGeneratorSpi.class, - method = "engineGenerateKey", - args = {} - ) - }) - public void testGenerateKey() throws Exception { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - SecretKey sKey; - String dAl = defaultAlgorithm.toUpperCase(); - - KeyGenerator[] kgs = createKGs(); - - for (int i = 0; i < kgs.length; i++) { - sKey = kgs[i].generateKey(); - assertEquals("Incorrect algorithm", sKey.getAlgorithm() - .toUpperCase(), dAl); - kgs[i].init(new SecureRandom()); - sKey = kgs[i].generateKey(); - assertEquals("Incorrect algorithm", sKey.getAlgorithm() - .toUpperCase(), dAl); - kgs[i].init(defaultKeySize); - sKey = kgs[i].generateKey(); - assertEquals("Incorrect algorithm", sKey.getAlgorithm() - .toUpperCase(), dAl); - kgs[i].init(defaultKeySize, new SecureRandom()); - sKey = kgs[i].generateKey(); - assertEquals("Incorrect algorithm", sKey.getAlgorithm() - .toUpperCase(), dAl); - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getAlgorithm", - args = {} - ) - public void test_getAlgorithm() throws NoSuchAlgorithmException { - KeyGenerator kg = null; - - for (int i = 0; i < validAlgorithmsKeyGenerator.length; i++) { - kg = KeyGenerator.getInstance(validAlgorithmsKeyGenerator[i]); - assertEquals(validAlgorithmsKeyGenerator[i], kg.getAlgorithm()); - } - - kg = new myKeyGenerator(null, null, null); - assertNull(kg.getAlgorithm()); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getProvider", - args = {} - ) - public void test_getProvider () throws NoSuchAlgorithmException { - KeyGenerator kg = null; - - for (int i = 0; i < validAlgorithmsKeyGenerator.length; i++) { - kg = KeyGenerator.getInstance(validAlgorithmsKeyGenerator[i]); - assertNotNull(kg.getProvider()); - } - - kg = new myKeyGenerator(null, null, null); - assertNull(kg.getProvider()); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "init", - args = {int.class, java.security.SecureRandom.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = KeyGeneratorSpi.class, - method = "engineInit", - args = {int.class, java.security.SecureRandom.class} - ) - }) - public void test_initILjava_security_SecureRandom() throws NoSuchAlgorithmException { - SecureRandom random = null; - KeyGenerator kg = null; - - for (int i = 0; i < validAlgorithmsKeyGenerator.length; i++) { - kg = KeyGenerator.getInstance(validAlgorithmsKeyGenerator[i]); - random = new SecureRandom(); - kg.init(validKeySizes[i], random); - assertNotNull(kg.getProvider()); - } - - kg = KeyGenerator.getInstance(validAlgorithmsKeyGenerator[0]); - - try { - kg.init(5, random); - fail("InvalidParameterException expected"); - } catch (InvalidParameterException e) { - //expected - } - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "init", - args = {java.security.SecureRandom.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = KeyGeneratorSpi.class, - method = "engineInit", - args = {java.security.SecureRandom.class} - ) - }) - public void test_Ljava_security_SecureRandom() throws NoSuchAlgorithmException { - SecureRandom random = null; - KeyGenerator kg = null; - - for (int i = 0; i < validAlgorithmsKeyGenerator.length; i++) { - kg = KeyGenerator.getInstance(validAlgorithmsKeyGenerator[i]); - random = new SecureRandom(); - kg.init(random); - assertNotNull(kg.getProvider()); - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "init", - args = {java.security.spec.AlgorithmParameterSpec.class} - ) - public void test_initLjava_security_spec_AlgorithmParameterSpec () - throws Exception { - KeyGenerator kg = null; - - IvParameterSpec aps = null; - SecureRandom sr = new SecureRandom(); - - byte[] iv = null; - iv = new byte[8]; - sr.nextBytes(iv); - aps = new IvParameterSpec(iv); - - for (int i = 0; i < validAlgorithmsKeyGenerator.length; i++) { - kg = KeyGenerator.getInstance(validAlgorithmsKeyGenerator[i]); - try { - kg.init(aps); - } catch (InvalidAlgorithmParameterException e) { - } - assertNotNull(kg.getProvider()); - } - } -} - -/** - * Additional class for KeyGenerator constructor verification - */ -class myKeyGenerator extends KeyGenerator { - - public myKeyGenerator(KeyGeneratorSpi keyAgreeSpi, Provider provider, - String algorithm) { - super(keyAgreeSpi, provider, algorithm); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/MacSpiTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/MacSpiTest.java deleted file mode 100644 index 270adaa24..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/MacSpiTest.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.nio.ByteBuffer; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.spec.AlgorithmParameterSpec; - -import javax.crypto.spec.SecretKeySpec; -import javax.crypto.MacSpi; - -import org.apache.harmony.crypto.tests.support.MyMacSpi; - -import junit.framework.TestCase; - - -@TestTargetClass(MacSpi.class) -/** - * Tests for MacSpi class constructors and methods. - * - */ - -public class MacSpiTest extends TestCase { -class Mock_MacSpi extends MyMacSpi { - - @Override - protected byte[] engineDoFinal() { - return super.engineDoFinal(); - } - - @Override - protected int engineGetMacLength() { - return super.engineGetMacLength(); - } - - @Override - protected void engineInit(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException { - super.engineInit(key, params); - } - - @Override - protected void engineReset() { - super.engineReset(); - } - - @Override - protected void engineUpdate(byte input) { - super.engineUpdate(input); - } - - @Override - protected void engineUpdate(byte[] input, int offset, int len) { - super.engineUpdate(input, offset, len); - } - -} - -class Mock_MacSpi1 extends MyMacSpi1 { - - @Override - protected byte[] engineDoFinal() { - return super.engineDoFinal(); - } - - @Override - protected int engineGetMacLength() { - return super.engineGetMacLength(); - } - - @Override - protected void engineInit(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException { - super.engineInit(key, params); - } - - @Override - protected void engineReset() { - super.engineReset(); - } - - @Override - protected void engineUpdate(byte input) { - super.engineUpdate(input); - } - - @Override - protected void engineUpdate(byte[] input, int offset, int len) { - super.engineUpdate(input, offset, len); - } - - protected void engineUpdate(ByteBuffer input) { - super.engineUpdate(input); - } - -} - - -class Mock_MacSpi2 extends MyMacSpi2 { - - @Override - protected byte[] engineDoFinal() { - return super.engineDoFinal(); - } - - @Override - protected int engineGetMacLength() { - return super.engineGetMacLength(); - } - - @Override - protected void engineInit(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException { - super.engineInit(key, params); - } - - @Override - protected void engineReset() { - super.engineReset(); - } - - @Override - protected void engineUpdate(byte input) { - super.engineUpdate(input); - } - - @Override - protected void engineUpdate(byte[] input, int offset, int len) { - super.engineUpdate(input, offset, len); - } - - protected void engineUpdate(ByteBuffer input) { - super.engineUpdate(input); - } - -} - - - /** - * Test for MacSpi constructor - * Assertion: constructs MacSpi - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "All others methods are abstract.", - method = "MacSpi", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "All others methods are abstract.", - method = "engineUpdate", - args = {java.nio.ByteBuffer.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "All others methods are abstract.", - method = "clone", - args = {} - ) - }) - public void testMacSpiTests01() throws Exception { - Mock_MacSpi mSpi = new Mock_MacSpi(); - - byte [] bb1 = {(byte)1, (byte)2, (byte)3, (byte)4, (byte)5}; - SecretKeySpec sks = new SecretKeySpec(bb1, "SHA1"); - - assertEquals("Incorrect MacLength", mSpi.engineGetMacLength(), 0); - - try { - mSpi.engineInit(null, null); - fail("IllegalArgumentException must be thrown"); - } catch (IllegalArgumentException e) { - } - - mSpi.engineInit(sks, null); - - byte[] bb = mSpi.engineDoFinal(); - assertEquals(bb.length, 0); - try { - mSpi.clone(); - fail("CloneNotSupportedException was not thrown as expected"); - } catch (CloneNotSupportedException e) { - } - - Mock_MacSpi1 mSpi1 = new Mock_MacSpi1(); - mSpi1.clone(); - - byte [] bbb = new byte[10]; - for (int i = 0; i < bbb.length; i++) { - bbb[i] = (byte)i; - } - try { - mSpi1.engineInit(null, null); - fail("IllegalArgumentException must be thrown"); - } catch (IllegalArgumentException e) { - } - mSpi1.engineInit(sks, null); - - ByteBuffer byteBuf = ByteBuffer.allocate(10); - byteBuf.put(bbb); - byteBuf.position(5); - int beforeUp = byteBuf.remaining(); - mSpi1.engineUpdate(byteBuf); - bb = mSpi1.engineDoFinal(); - assertEquals("Incorrect result of engineDoFinal", bb.length, beforeUp); - - Mock_MacSpi2 mSpi2 = new Mock_MacSpi2(); - - mSpi2.engineInit(null, null); - mSpi2.engineInit(sks, null); - - try { - mSpi2.clone(); - } catch (CloneNotSupportedException e) { - } - - byte [] bbuf = {(byte)5, (byte)4, (byte)3, (byte)2, (byte)1}; - byteBuf = ByteBuffer.allocate(5); - byteBuf.put(bbuf); - byteBuf.position(5); - if (!byteBuf.hasRemaining()) { - mSpi2.engineUpdate(byteBuf); - } - } -} - - -class MyMacSpi1 extends MyMacSpi { - public Object clone() throws CloneNotSupportedException { - return new MyMacSpi1(); - } -} - -class MyMacSpi2 extends MacSpi { - protected int engineGetMacLength() { - return 0; - } - - protected void engineInit(Key key, AlgorithmParameterSpec params) - throws InvalidKeyException, InvalidAlgorithmParameterException { - } - - protected void engineUpdate(byte input) { - } - - protected void engineUpdate(byte[] input, int offset, int len) { - } - - protected byte[] engineDoFinal() { - return new byte[0]; - } - - protected void engineReset() { - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java deleted file mode 100644 index 750342caa..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java +++ /dev/null @@ -1,1189 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.math.BigInteger; -import java.nio.ByteBuffer; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.Provider; -import java.security.spec.DSAParameterSpec; -import java.security.spec.PSSParameterSpec; - -import javax.crypto.Mac; -import javax.crypto.MacSpi; -import javax.crypto.ShortBufferException; -import javax.crypto.spec.DHGenParameterSpec; - -import javax.crypto.spec.SecretKeySpec; - -import org.apache.harmony.crypto.tests.support.MyMacSpi; -import org.apache.harmony.security.tests.support.SpiEngUtils; - -import junit.framework.TestCase; - -import junit.framework.Test; -import junit.framework.TestSuite; - -@TestTargetClass(Mac.class) -/** - * Tests for Mac class constructors and methods - * - */ - -public class MacTest extends TestCase { - - public static final String srvMac = "Mac"; - - private static String defaultAlgorithm = null; - - private static String defaultProviderName = null; - - private static Provider defaultProvider = null; - - private static boolean DEFSupported = false; - - private static final String NotSupportedMsg = "There is no suitable provider for Mac"; - - private static final String[] invalidValues = SpiEngUtils.invalidValues; - - private static String[] validValues = new String[3]; - - public static final String validAlgorithmsMac [] = - {"HmacSHA1", "HmacMD5", "HmacSHA256", "HmacSHA384", "HmacSHA512"}; - - - static { - for (int i = 0; i < validAlgorithmsMac.length; i++) { - defaultProvider = SpiEngUtils.isSupport(validAlgorithmsMac[i], - srvMac); - DEFSupported = (defaultProvider != null); - if (DEFSupported) { - defaultAlgorithm = validAlgorithmsMac[i]; - defaultProviderName = defaultProvider.getName(); - validValues[0] = defaultAlgorithm; - validValues[1] = defaultAlgorithm.toUpperCase(); - validValues[2] = defaultAlgorithm.toLowerCase(); - break; - } - } - } - - private Mac [] createMacs() { - if (!DEFSupported) { - fail(NotSupportedMsg); - return null; - } - try { - Mac m [] = new Mac[3]; - m[0] = Mac.getInstance(defaultAlgorithm); - m[1] = Mac.getInstance(defaultAlgorithm, defaultProvider); - m[2] = Mac.getInstance(defaultAlgorithm, defaultProviderName); - return m; - } catch (Exception e) { - return null; - } - } - - /** - * Test for getInstance(String algorithm) method - * Assertion: - * throws NullPointerException when algorithm is null - * throws NoSuchAlgorithmException when algorithm is not available - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class} - ) - public void testMac01() { - try { - Mac.getInstance(null); - fail("NullPointerException or NoSuchAlgorithmException should be thrown when algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - Mac.getInstance(invalidValues[i]); - fail("NoSuchAlgorithmException must be thrown when algorithm is not available: " - .concat(invalidValues[i])); - } catch (NoSuchAlgorithmException e) { - } - } - } - - /** - * Test for getInstance(String algorithm) method - * Assertion: returns Mac object - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class} - ) - public void testMac02() throws NoSuchAlgorithmException { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - Mac mac; - for (int i = 0; i < validValues.length; i++) { - mac = Mac.getInstance(validValues[i]); - assertEquals("Incorrect algorithm", mac.getAlgorithm(), validValues[i]); - } - } - /** - * Test for getInstance(String algorithm, String provider) method - * Assertion: - * throws IllegalArgumentException when provider is null or empty - * throws NoSuchProviderException when provider is not available - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testMac03() throws NoSuchAlgorithmException, NoSuchProviderException { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - String provider = null; - for (int i = 0; i < validValues.length; i++) { - try { - Mac.getInstance(validValues[i], provider); - fail("IllegalArgumentException must be thrown when provider is null"); - } catch (IllegalArgumentException e) { - } - try { - Mac.getInstance(validValues[i], ""); - fail("IllegalArgumentException must be thrown when provider is empty"); - } catch (IllegalArgumentException e) { - } - for (int j = 1; j < invalidValues.length; j++) { - try { - Mac.getInstance(validValues[i], invalidValues[j]); - fail("NoSuchProviderException must be thrown (algorithm: " - .concat(validValues[i]).concat(" provider: ") - .concat(invalidValues[j]).concat(")")); - } catch (NoSuchProviderException e) { - } - } - } - } - - /** - * Test for getInstance(String algorithm, String provider) method - * Assertion: - * throws NullPointerException when algorithm is null - * throws NoSuchAlgorithmException when algorithm is not available - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testMac04() throws NoSuchAlgorithmException, - IllegalArgumentException, NoSuchProviderException { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - try { - Mac.getInstance(null, defaultProviderName); - fail("NullPointerException or NoSuchAlgorithmException should be thrown when algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - Mac.getInstance(invalidValues[i], defaultProviderName); - fail("NoSuchAlgorithmException must be throws when algorithm is not available: " - .concat(invalidValues[i])); - } catch( NoSuchAlgorithmException e) { - } - } - } - /** - * Test for getInstance(String algorithm, String provider) method - * Assertion: returns Mac object - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testMac05() throws NoSuchAlgorithmException, NoSuchProviderException, - IllegalArgumentException { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - Mac mac; - for (int i = 0; i < validValues.length; i++) { - mac = Mac.getInstance(validValues[i], defaultProviderName); - assertEquals("Incorrect algorithm", mac.getAlgorithm(), validValues[i]); - assertEquals("Incorrect provider", mac.getProvider().getName(), - defaultProviderName); - } - } - - /** - * Test for getInstance(String algorithm, Provider provider) method - * Assertion: throws IllegalArgumentException when provider is null - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.security.Provider.class} - ) - public void testMac06() throws NoSuchAlgorithmException, NoSuchProviderException { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - Provider provider = null; - for (int i = 0; i < validValues.length; i++) { - try { - Mac.getInstance(validValues[i], provider); - fail("IllegalArgumentException must be thrown when provider is null"); - } catch (IllegalArgumentException e) { - } - } - } - /** - * Test for getInstance(String algorithm, Provider provider) method - * Assertion: - * throws NullPointerException when algorithm is null - * throws NoSuchAlgorithmException when algorithm is not available - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.security.Provider.class} - ) - public void testMac07() throws NoSuchAlgorithmException, - NoSuchProviderException, IllegalArgumentException { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - try { - Mac.getInstance(null, defaultProvider); - fail("NullPointerException or NoSuchAlgorithmException should be thrown when algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - Mac.getInstance(invalidValues[i], defaultProvider); - fail("NoSuchAlgorithmException must be thrown when algorithm is not available: " - .concat(invalidValues[i])); - } catch (NoSuchAlgorithmException e) { - } - } - } - - /** - * Test for getInstance(String algorithm, Provider provider) method - * Assertion: returns Mac object - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.security.Provider.class} - ) - public void testMac08() throws NoSuchAlgorithmException, NoSuchProviderException, - IllegalArgumentException { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - Mac mac; - for (int i = 0; i < validValues.length; i++) { - mac = Mac.getInstance(validValues[i], defaultProvider); - assertEquals("Incorrect algorithm", mac.getAlgorithm(), validValues[i]); - assertEquals("Incorrect provider", mac.getProvider(), defaultProvider); - } - } - /** - * Test for update and doFinal methods - * Assertion: throws IllegalStateException when Mac is not initialized - * @throws Exception - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks IllegalStateException only but for all methods. Not enough for doFinal(byte[] output, int outOffset) - it can throw ShortBufferException", - method = "doFinal", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks IllegalStateException only but for all methods. Not enough for doFinal(byte[] output, int outOffset) - it can throw ShortBufferException", - clazz = MacSpi.class, - method = "engineDoFinal", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks IllegalStateException only but for all methods. Not enough for doFinal(byte[] output, int outOffset) - it can throw ShortBufferException", - method = "doFinal", - args = {byte[].class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks IllegalStateException only but for all methods. Not enough for doFinal(byte[] output, int outOffset) - it can throw ShortBufferException", - method = "doFinal", - args = {byte[].class, int.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks IllegalStateException only but for all methods. Not enough for doFinal(byte[] output, int outOffset) - it can throw ShortBufferException", - method = "update", - args = {byte.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks IllegalStateException only but for all methods. Not enough for doFinal(byte[] output, int outOffset) - it can throw ShortBufferException", - clazz = MacSpi.class, - method = "engineUpdate", - args = {byte.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks IllegalStateException only but for all methods. Not enough for doFinal(byte[] output, int outOffset) - it can throw ShortBufferException", - method = "update", - args = {byte[].class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks IllegalStateException only but for all methods. Not enough for doFinal(byte[] output, int outOffset) - it can throw ShortBufferException", - method = "update", - args = {byte[].class, int.class, int.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks IllegalStateException only but for all methods. Not enough for doFinal(byte[] output, int outOffset) - it can throw ShortBufferException", - clazz = MacSpi.class, - method = "engineUpdate", - args = {byte[].class, int.class, int.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks IllegalStateException only but for all methods. Not enough for doFinal(byte[] output, int outOffset) - it can throw ShortBufferException", - method = "update", - args = {java.nio.ByteBuffer.class} - ) - }) - public void testMac09() throws Exception { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - Mac [] macs = createMacs(); - assertNotNull("Mac objects were not created", macs); - byte [] buf = new byte[10]; - ByteBuffer bBuf = ByteBuffer.wrap(buf, 0, 10); - byte [] bb = {(byte)1, (byte)2, (byte)3, (byte)4, (byte)5}; - SecretKeySpec sks = new SecretKeySpec(bb, "SHA1"); - for (int i = 0; i < macs.length; i++) { - try { - macs[i].update((byte)0); - fail("IllegalStateException must be thrown"); - } catch (IllegalStateException e) { - } - try { - macs[i].update(buf); - fail("IllegalStateException must be thrown"); - } catch (IllegalStateException e) { - } - try { - macs[i].update(buf, 0, 3); - fail("IllegalStateException must be thrown"); - } catch (IllegalStateException e) { - } - try { - macs[i].update(bBuf); - fail("IllegalStateException must be thrown"); - } catch (IllegalStateException e) { - } - try { - macs[i].doFinal(); - fail("IllegalStateException must be thrown"); - } catch (IllegalStateException e) { - } - try { - macs[i].doFinal(new byte[10]); - fail("IllegalStateException must be thrown"); - } catch (IllegalStateException e) { - } - try { - macs[i].doFinal(new byte[10], 0); - fail("IllegalStateException must be thrown"); - } catch (IllegalStateException e) { - } - - macs[i].init(sks); - try { - macs[i].doFinal(new byte[1], 0); - fail("ShortBufferException expected"); - } catch (ShortBufferException e) { - //expected - } - } - } - /** - * Test for doFinal(byte[] output, int outOffset) method - * Assertion: - * throws ShotBufferException when outOffset is negative or - * outOffset >= output.length or when given buffer is small - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks ShortBufferException", - method = "doFinal", - args = {byte[].class, int.class} - ) - public void testMac10() throws NoSuchAlgorithmException, - NoSuchProviderException, IllegalArgumentException, - IllegalStateException, InvalidKeyException { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - Mac[] macs = createMacs(); - assertNotNull("Mac objects were not created", macs); - byte[] b = { (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 }; - byte[] byteA = new byte[b.length]; - SecretKeySpec sks = new SecretKeySpec(b, "SHA1"); - for (int i = 0; i < macs.length; i++) { - macs[i].init(sks); - try { - macs[i].doFinal(null, 10); - fail("ShortBufferException must be thrown"); - } catch (ShortBufferException e) { - } - try { - macs[i].doFinal(byteA, -4); - fail("ShortBufferException must be thrown"); - } catch (ShortBufferException e) { - } - try { - macs[i].doFinal(byteA, 10); - fail("ShortBufferException must be thrown"); - } catch (ShortBufferException e) { - } - try { - macs[i].doFinal(new byte[1], 0); - fail("ShortBufferException must be thrown"); - } catch (ShortBufferException e) { - } - byte[] res = macs[i].doFinal(); - try { - macs[i].doFinal(new byte[res.length - 1], 0); - fail("ShortBufferException must be thrown"); - } catch (ShortBufferException e) { - } - } - } - - /** - * Test for doFinal(byte[] output, int outOffset) and - * doFinal() methods Assertion: Mac result is stored in - * output buffer - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality.", - method = "doFinal", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks IllegalStateException only but for all methods. Not enough for doFinal(byte[] output, int outOffset) - it can throw ShortBufferException", - clazz = MacSpi.class, - method = "engineDoFinal", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality.", - method = "doFinal", - args = {byte[].class, int.class} - ) - }) - public void testMac11() throws NoSuchAlgorithmException, NoSuchProviderException, - IllegalArgumentException, IllegalStateException, - InvalidKeyException, ShortBufferException { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - Mac [] macs = createMacs(); - assertNotNull("Mac objects were not created", macs); - byte [] b = {(byte)0, (byte)0, (byte)0, (byte)0, (byte)0}; - SecretKeySpec scs = new SecretKeySpec(b, "SHA1"); - for (int i = 0; i < macs.length; i++) { - macs[i].init(scs); - byte [] res1 = macs[i].doFinal(); - byte [] res2 = new byte[res1.length + 10]; - macs[i].doFinal(res2, 0); - for (int j = 0; j < res1.length; j++) { - assertEquals("Not equals byte number: " - .concat(Integer.toString(j)), res1[j], res2[j]); - } - } - } - /** - * Test for doFinal(byte[] input) method - * Assertion: update Mac and returns result - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality.", - method = "doFinal", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks IllegalStateException only but for all methods. Not enough for doFinal(byte[] output, int outOffset) - it can throw ShortBufferException", - clazz = MacSpi.class, - method = "engineDoFinal", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality.", - method = "doFinal", - args = {byte[].class} - ) - }) - public void testMac12() throws NoSuchAlgorithmException, NoSuchProviderException, - IllegalArgumentException, IllegalStateException, - InvalidKeyException { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - Mac [] macs = createMacs(); - assertNotNull("Mac objects were not created", macs); - byte [] b = {(byte)0, (byte)0, (byte)0, (byte)0, (byte)0}; - byte [] upd = {(byte)5, (byte)4, (byte)3, (byte)2, (byte)1, (byte)0}; - SecretKeySpec scs = new SecretKeySpec(b, "SHA1"); - for (int i = 0; i < macs.length; i++) { - macs[i].init(scs); - byte [] res1 = macs[i].doFinal(); - byte [] res2 = macs[i].doFinal(); - assertEquals("Results are not the same", res1.length, res2.length); - for(int t = 0; t < res1.length; t++) { - assertEquals("Results are not the same", res1[t], res2[t]); - } - res2 = macs[i].doFinal(upd); - macs[i].update(upd); - res1 = macs[i].doFinal(); - assertEquals("Results are not the same", res1.length, res2.length); - for(int t = 0; t < res1.length; t++) { - assertEquals("Results are not the same", res1[t], res2[t]); - } - } - } - - /** - * Test for update(byte[] input, int outset, int len) method - * Assertion: throws IllegalArgumentException when offset or len is negative, - * offset + len >= input.length - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks IllegalArgumentException", - method = "update", - args = {byte[].class, int.class, int.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks IllegalStateException only but for all methods. Not enough for doFinal(byte[] output, int outOffset) - it can throw ShortBufferException", - clazz = MacSpi.class, - method = "engineUpdate", - args = {byte[].class, int.class, int.class} - ) - }) - public void testMac13() throws NoSuchAlgorithmException, - NoSuchProviderException, IllegalArgumentException, IllegalStateException, - InvalidKeyException { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - Mac [] macs = createMacs(); - assertNotNull("Mac objects were not created", macs); - byte [] b = {(byte)0, (byte)0, (byte)0, (byte)0, (byte)0}; - SecretKeySpec scs = new SecretKeySpec(b, "SHA1"); - for (int i = 0; i < macs.length; i++) { - macs[i].init(scs); - try { - macs[i].update(b, -10, b.length); - fail("IllegalArgumentException must be thrown"); - } catch (IllegalArgumentException e) { - } - try { - macs[i].update(b, 0, -10); - fail("IllegalArgumentException must be thrown"); - } catch (IllegalArgumentException e) { - } - try { - macs[i].update(b, 0, b.length + 1); - fail("IllegalArgumentException must be thrown"); - } catch (IllegalArgumentException e) { - } - try { - macs[i].update(b, b.length - 1, 2); - fail("IllegalArgumentException must be thrown"); - } catch (IllegalArgumentException e) { - } - } - } - /** - * Test for update(byte[] input, int outset, int len) and - * update(byte[] input - * methods - * Assertion: updates Mac - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality.", - method = "update", - args = {byte.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks IllegalStateException only but for all methods. Not enough for doFinal(byte[] output, int outOffset) - it can throw ShortBufferException", - clazz = MacSpi.class, - method = "engineUpdate", - args = {byte.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality.", - method = "update", - args = {byte[].class, int.class, int.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks IllegalStateException only but for all methods. Not enough for doFinal(byte[] output, int outOffset) - it can throw ShortBufferException", - clazz = MacSpi.class, - method = "engineUpdate", - args = {byte[].class, int.class, int.class} - ) - }) - public void testMac14() throws NoSuchAlgorithmException, - NoSuchProviderException, IllegalArgumentException, IllegalStateException, - InvalidKeyException { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - Mac [] macs = createMacs(); - assertNotNull("Mac objects were not created", macs); - byte [] b = {(byte)0, (byte)0, (byte)0, (byte)0, (byte)0}; - byte [] upd1 = {(byte)0, (byte)1, (byte)5, (byte)4, (byte)3, (byte)2}; - byte [] upd2 = {(byte)5, (byte)4, (byte)3, (byte)2}; - byte [] res1; - byte [] res2; - SecretKeySpec scs = new SecretKeySpec(b, "SHA1"); - for (int i = 0; i < macs.length; i++) { - macs[i].init(scs); - macs[i].update(upd1, 2, 4); - res1 = macs[i].doFinal(); - macs[i].init(scs); - macs[i].update(upd2); - res2 = macs[i].doFinal(); - assertEquals("Results are not the same", res1.length, res2.length); - for(int t = 0; t < res1.length; t++) { - assertEquals("Results are not the same", res1[t], res2[t]); - } - macs[i].init(scs); - macs[i].update((byte)5); - res1 = macs[i].doFinal(); - macs[i].init(scs); - macs[i].update(upd1,2,1); - res2 = macs[i].doFinal(); - assertEquals("Results are not the same", res1.length, res2.length); - for(int t = 0; t < res1.length; t++) { - assertEquals("Results are not the same", res1[t], res2[t]); - } - } - } - /** - * Test for clone() method - * Assertion: returns Mac object or throws CloneNotSupportedException - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "clone", - args = {} - ) - public void testMacClone() throws NoSuchAlgorithmException, CloneNotSupportedException { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - Mac [] macs = createMacs(); - assertNotNull("Mac objects were not created", macs); - for (int i = 0; i < macs.length; i++) { - try { - Mac mac1 = (Mac) macs[i].clone(); - assertEquals(mac1.getAlgorithm(), macs[i].getAlgorithm()); - assertEquals(mac1.getProvider(), macs[i].getProvider()); - assertFalse(macs[i].equals(mac1)); - } catch (CloneNotSupportedException e) { - } - } - } - /** - * Test for - * init(Key key, AlgorithmParameterSpec params) - * init(Key key) - * methods - * Assertion: throws InvalidKeyException and InvalidAlgorithmParameterException - * when parameters are not appropriate - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks exceptions", - method = "init", - args = {java.security.Key.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks exceptions", - method = "init", - args = {java.security.Key.class, java.security.spec.AlgorithmParameterSpec.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks exceptions", - clazz = MacSpi.class, - method = "engineInit", - args = {java.security.Key.class, java.security.spec.AlgorithmParameterSpec.class} - ) - }) - public void testInit() throws NoSuchAlgorithmException, NoSuchProviderException, - IllegalArgumentException, IllegalStateException, InvalidAlgorithmParameterException, - InvalidKeyException { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - Mac [] macs = createMacs(); - assertNotNull("Mac objects were not created", macs); - byte [] b = {(byte)1, (byte)2, (byte)3, (byte)4, (byte)5}; - SecretKeySpec sks = new SecretKeySpec(b, "SHA1"); - DHGenParameterSpec algPS = new DHGenParameterSpec(1, 2); - PSSParameterSpec algPSS = new PSSParameterSpec(20); - SecretKeySpec sks1 = new SecretKeySpec(b, "RSA"); - - for (int i = 0; i < macs.length; i++) { - macs[i].init(sks); - try { - macs[i].init(sks1, algPSS); - fail("init(..) accepts incorrect AlgorithmParameterSpec parameter"); - } catch (InvalidAlgorithmParameterException e) { - } - try { - macs[i].init(sks, algPS); - fail("init(..) accepts incorrect AlgorithmParameterSpec parameter"); - } catch (InvalidAlgorithmParameterException e) { - } - - try { - macs[i].init(null, null); - fail("InvalidKeyException must be thrown"); - } catch (InvalidKeyException e) { - } - - try { - macs[i].init(null); - fail("InvalidKeyException must be thrown"); - } catch (InvalidKeyException e) { - } -// macs[i].init(sks, null); - } - } - - /** - * Test for update(ByteBuffer input) - * update(byte[] input, int offset, int len) - * methods - * Assertion: processes Mac; if input is null then do nothing - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality", - method = "update", - args = {byte[].class, int.class, int.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks IllegalStateException only but for all methods. Not enough for doFinal(byte[] output, int outOffset) - it can throw ShortBufferException", - clazz = MacSpi.class, - method = "engineUpdate", - args = {byte[].class, int.class, int.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality", - method = "update", - args = {java.nio.ByteBuffer.class} - ) - }) - public void testUpdateByteBuffer01() throws NoSuchAlgorithmException, NoSuchProviderException, - IllegalArgumentException, IllegalStateException, InvalidAlgorithmParameterException, - InvalidKeyException { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - Mac [] macs = createMacs(); - assertNotNull("Mac objects were not created", macs); - byte [] bb = {(byte)1, (byte)2, (byte)3, (byte)4, (byte)5}; - SecretKeySpec sks = new SecretKeySpec(bb, "SHA1"); - ByteBuffer byteNull = null; - ByteBuffer byteBuff = ByteBuffer.allocate(0); - byte [] bb1; - byte [] bb2; - for (int i = 0; i < macs.length; i++) { - macs[i].init(sks); - bb1 = macs[i].doFinal(); - try { - macs[i].update(byteNull); - fail("IllegalArgumentException must be thrown because buffer is null"); - } catch (IllegalArgumentException e) { - } - macs[i].update(byteBuff); - bb2 = macs[i].doFinal(); - for (int t = 0; t < bb1.length; t++) { - assertEquals("Incorrect doFinal result", bb1[t], bb2[t]); - } - macs[i].init(sks); - bb1 = macs[i].doFinal(); - macs[i].update(null, 0, 0); - bb2 = macs[i].doFinal(); - for (int t = 0; t < bb1.length; t++) { - assertEquals("Incorrect doFinal result", bb1[t], bb2[t]); - } - } - } - /** - * Test for update(ByteBuffer input) - * update(byte[] input, int offset, int len) - * methods - * Assertion: processes Mac - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality", - method = "update", - args = {java.nio.ByteBuffer.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks functionality", - method = "update", - args = {byte[].class, int.class, int.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks IllegalStateException only but for all methods. Not enough for doFinal(byte[] output, int outOffset) - it can throw ShortBufferException", - clazz = MacSpi.class, - method = "engineUpdate", - args = {byte[].class, int.class, int.class} - ) - }) - public void testUpdateByteBuffer02() throws NoSuchAlgorithmException, NoSuchProviderException, - IllegalArgumentException, IllegalStateException, InvalidAlgorithmParameterException, - InvalidKeyException { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - Mac [] macs = createMacs(); - assertNotNull("Mac objects were not created", macs); - byte [] bb = {(byte)1, (byte)2, (byte)3, (byte)4, (byte)5}; - SecretKeySpec sks = new SecretKeySpec(bb, "SHA1"); - byte [] bbuf = {(byte)5, (byte)4, (byte)3, (byte)2, (byte)1}; - ByteBuffer byteBuf; - byte [] bb1; - byte [] bb2; - for (int i = 0; i < macs.length; i++) { - byteBuf = ByteBuffer.allocate(5); - byteBuf.put(bbuf); - byteBuf.position(2); - macs[i].init(sks); - macs[i].update(byteBuf); - bb1 = macs[i].doFinal(); - - macs[i].init(sks); - macs[i].update(bbuf, 2, 3); - bb2 = macs[i].doFinal(); - for (int t = 0; t < bb1.length; t++) { - assertEquals("Incorrect doFinal result", bb1[t], bb2[t]); - } - } - } - /** - * Test for clone() method - * Assertion: clone if provider is clo - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "clone", - args = {} - ) - public void testClone() { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - Mac [] macs = createMacs(); - assertNotNull("Mac objects were not created", macs); - Mac res; - for (int i = 0; i < macs.length; i++) { - try { - res = (Mac)macs[i].clone(); - assertTrue("Object should not be equals", !macs[i].equals(res)); - assertEquals("Incorrect class", macs[i].getClass(), res.getClass()); - } catch (CloneNotSupportedException e) { - } - } - } - /** - * Test for getMacLength() method - * Assertion: return Mac length - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getMacLength", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = MacSpi.class, - method = "engineGetMacLength", - args = {} - ) - }) - public void testGetMacLength() { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - Mac [] macs = createMacs(); - assertNotNull("Mac objects were not created", macs); - for (int i = 0; i < macs.length; i++) { - assertTrue("Length should be positive", (macs[i].getMacLength() >= 0)); - } - } - - /** - * Test for reset() method - * Assertion: return Mac length - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "reset", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = MacSpi.class, - method = "engineReset", - args = {} - ) - }) - public void testReset() throws InvalidKeyException { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - Mac [] macs = createMacs(); - assertNotNull("Mac objects were not created", macs); - byte [] bb = {(byte)1, (byte)2, (byte)3, (byte)4, (byte)5}; - SecretKeySpec sks = new SecretKeySpec(bb, "SHA1"); - byte [] bbuf = {(byte)5, (byte)4, (byte)3, (byte)2, (byte)1}; - byte [] bb1; - byte [] bb2; - for (int i = 0; i < macs.length; i++) { - macs[i].init(sks); - bb1 = macs[i].doFinal(); - macs[i].reset(); - bb2 = macs[i].doFinal(); - assertEquals("incorrect result",bb1.length, bb2.length); - for (int t = 0; t < bb1.length; t++) { - assertEquals("Incorrect doFinal result", bb1[t], bb2[t]); - } - macs[i].reset(); - macs[i].update(bbuf); - bb1 = macs[i].doFinal(); - macs[i].reset(); - macs[i].update(bbuf, 0, bbuf.length); - bb2 = macs[i].doFinal(); - assertEquals("incorrect result",bb1.length, bb2.length); - for (int t = 0; t < bb1.length; t++) { - assertEquals("Incorrect doFinal result", bb1[t], bb2[t]); - } - } - } - /** - * Test for Mac constructor - * Assertion: returns Mac object - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "Mac", - args = {javax.crypto.MacSpi.class, java.security.Provider.class, java.lang.String.class} - ) - public void testMacConstructor() throws NoSuchAlgorithmException, - InvalidKeyException, InvalidAlgorithmParameterException { - if (!DEFSupported) { - fail(NotSupportedMsg); - return; - } - MacSpi spi = new MyMacSpi(); - Mac mac = new myMac(spi, defaultProvider, defaultAlgorithm); - assertEquals("Incorrect algorithm", mac.getAlgorithm(), - defaultAlgorithm); - assertEquals("Incorrect provider", mac.getProvider(), defaultProvider); - try { - mac.init(null, null); - fail("Exception should be thrown because init(..) uses incorrect parameters"); - } catch (Exception e) { - } - assertEquals("Invalid mac length", mac.getMacLength(), 0); - - mac = new myMac(null, null, null); - assertNull("Algorithm must be null", mac.getAlgorithm()); - assertNull("Provider must be null", mac.getProvider()); - try { - mac.init(null, null); - fail("Exception should be thrown because init(..) uses incorrect parameters"); - } catch (Exception e) { - } - try { - mac.getMacLength(); - fail("NullPointerException must be thrown"); - } catch (NullPointerException e) { - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getAlgorithm", - args = {} - ) - public void test_getAlgorithm() throws NoSuchAlgorithmException { - Mac mac; - for (int i = 0; i < validValues.length; i++) { - mac = Mac.getInstance(validValues[i]); - assertEquals("Incorrect algorithm", mac.getAlgorithm(), validValues[i]); - } - - mac = new Mock_Mac(null, null, null); - assertNull(mac.getAlgorithm()); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getProvider", - args = {} - ) - public void test_getProvider() throws NoSuchAlgorithmException { - Mac mac; - for (int i = 0; i < validValues.length; i++) { - mac = Mac.getInstance(validValues[i]); - assertNotNull(mac.getProvider()); - } - - mac = new Mock_Mac(null, null, null); - assertNull(mac.getProvider()); - } - - class Mock_Mac extends Mac { - protected Mock_Mac(MacSpi arg0, Provider arg1, String arg2) { - super(arg0, arg1, arg2); - } - } - - public static Test suite() { - return new TestSuite(MacTest.class); - } - - public static void main(String args[]) { - junit.textui.TestRunner.run(suite()); - - } -} -/** - * Additional class for Mac constructor verification - */ -class myMac extends Mac { - - public myMac(MacSpi macSpi, Provider provider, - String algorithm) { - super(macSpi, provider, algorithm); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/NoSuchPaddingExceptionTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/NoSuchPaddingExceptionTest.java deleted file mode 100644 index da4a94de8..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/NoSuchPaddingExceptionTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import javax.crypto.NoSuchPaddingException; - -import junit.framework.TestCase; - - -@TestTargetClass(NoSuchPaddingException.class) -/** - * Tests for NoSuchPaddingException class constructors and - * methods. - * - */ -public class NoSuchPaddingExceptionTest extends TestCase { - - static String[] msgs = { - "", - "Check new message", - "Check new message Check new message Check new message Check new message Check new message" }; - - static Throwable tCause = new Throwable("Throwable for exception"); - - /** - * Test for NoSuchPaddingException() constructor Assertion: - * constructs NoSuchPaddingException with no detail message - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "NoSuchPaddingException", - args = {} - ) - public void testNoSuchPaddingException01() { - NoSuchPaddingException tE = new NoSuchPaddingException(); - assertNull("getMessage() must return null.", tE.getMessage()); - assertNull("getCause() must return null", tE.getCause()); - } - - /** - * Test for NoSuchPaddingException(String) constructor - * Assertion: constructs NoSuchPaddingException with detail message msg. - * Parameter msg is not null. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "NoSuchPaddingException", - args = {java.lang.String.class} - ) - public void testNoSuchPaddingException02() { - NoSuchPaddingException tE; - for (int i = 0; i < msgs.length; i++) { - tE = new NoSuchPaddingException(msgs[i]); - assertEquals("getMessage() must return: ".concat(msgs[i]), tE - .getMessage(), msgs[i]); - assertNull("getCause() must return null", tE.getCause()); - } - } - - /** - * Test for NoSuchPaddingException(String) constructor - * Assertion: constructs NoSuchPaddingException when msg is - * null - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "NoSuchPaddingException", - args = {java.lang.String.class} - ) - public void testNoSuchPaddingException03() { - String msg = null; - NoSuchPaddingException tE = new NoSuchPaddingException(msg); - assertNull("getMessage() must return null.", tE.getMessage()); - assertNull("getCause() must return null", tE.getCause()); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/NullCipherTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/NullCipherTest.java deleted file mode 100644 index f5216901b..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/NullCipherTest.java +++ /dev/null @@ -1,435 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Boris V. Kuznetsov -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.security.SecureRandom; -import java.util.Arrays; - -import javax.crypto.Cipher; -import javax.crypto.CipherSpi; -import javax.crypto.NullCipher; -import javax.crypto.spec.SecretKeySpec; - -import junit.framework.TestCase; - -@TestTargetClass(NullCipher.class) -/** - * - * Tests for NullCipher - */ -public class NullCipherTest extends TestCase { - - private Cipher c; - - protected void setUp() throws Exception { - super.setUp(); - c = new NullCipher(); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Class checks inherited methods.", - method = "getAlgorithm", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Class checks inherited methods.", - method = "NullCipher", - args = {} - ) - }) - public void testGetAlgorithm() { - c.getAlgorithm(); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks inherited method from Cipher.", - method = "getBlockSize", - args = {} - ) - public void testGetBlockSize() { - assertEquals("Incorrect BlockSize", 1, c.getBlockSize()); - } - - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "IllegalStateException checking missed. Checks inherited method from Cipher.", - method = "getOutputSize", - args = {int.class} - ) - public void testGetOutputSize() { - assertEquals("Incorrect OutputSize", 111, c.getOutputSize(111)); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks inherited method from Cipher.", - method = "getIV", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks inherited method from Cipher.", - clazz = CipherSpi.class, - method = "engineGetIV", - args = {} - ) - }) - public void testGetIV() { - assertTrue("Incorrect IV", Arrays.equals(c.getIV(), new byte[8])); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks inherited method from Cipher.", - method = "getParameters", - args = {} - ) - public void testGetParameters() { - assertNull("Incorrect Parameters", c.getParameters()); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks inherited method from Cipher.", - method = "getExemptionMechanism", - args = {} - ) - public void testGetExemptionMechanism() { - assertNull("Incorrect ExemptionMechanism", c.getExemptionMechanism()); - } - - /* - * Class under test for void init(int, Key) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "InvalidKeyException checking missed. Checks inherited method from Cipher.", - method = "init", - args = {int.class, java.security.Key.class} - ) - public void testInitintKey() throws Exception { - c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(new byte[1], "algorithm")); - - } - - /* - * Class under test for void init(int, Key, SecureRandom) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "InvalidKeyException checking missed. Checks inherited method from Cipher.", - method = "init", - args = {int.class, java.security.Key.class, java.security.SecureRandom.class} - ) - public void testInitintKeySecureRandom() throws Exception { - c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(new byte[1], - "algorithm"), new SecureRandom()); - } - - /* - * Class under test for void init(int, Key, AlgorithmParameterSpec) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Exceptions checking missed. Checks inherited method from Cipher.", - method = "init", - args = {int.class, java.security.Key.class, java.security.spec.AlgorithmParameterSpec.class} - ) - public void testInitintKeyAlgorithmParameterSpec() throws Exception { - class myAlgorithmParameterSpec implements java.security.spec.AlgorithmParameterSpec {} - c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(new byte[1], - "algorithm"), new myAlgorithmParameterSpec()); - } - - /* - * Class under test for byte[] update(byte[]) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "IllegalStateException checking missed. Checks inherited method from Cipher.", - method = "update", - args = {byte[].class} - ) - public void testUpdatebyteArray() throws Exception { - byte [] b = {1, 2, 3, 4, 5}; - byte [] r = c.update(b); - assertEquals("different length", b.length, r.length); - assertTrue("different content", Arrays.equals(b, r)); - } - - /* - * Class under test for byte[] update(byte[], int, int) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "IllegalStateException checking missed. Checks inherited method from Cipher.", - method = "update", - args = {byte[].class, int.class, int.class} - ) - public void testUpdatebyteArrayintint() throws Exception { - byte [] b = {1, 2, 3, 4, 5}; - byte [] r = c.update(b, 0, 5); - assertEquals("different length", b.length, r.length); - assertTrue("different content", Arrays.equals(b, r)); - - r = c.update(b, 1, 3); - assertEquals("different length", 3, r.length); - for (int i = 0; i < 3; i++) { - assertEquals("different content", b[i + 1], r[i]); - } - } - - /* - * Class under test for int update(byte[], int, int, byte[]) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Exceptions checking missed. Checks inherited method from Cipher.", - method = "update", - args = {byte[].class, int.class, int.class, byte[].class} - ) - public void testUpdatebyteArrayintintbyteArray() throws Exception { - byte [] b = {1, 2, 3, 4, 5}; - byte [] r = new byte[5]; - c.update(b, 0, 5, r); - assertTrue("different content", Arrays.equals(b, r)); - } - - /* - * Class under test for int update(byte[], int, int, byte[], int) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Exceptions checking missed. Checks inherited method from Cipher.", - method = "update", - args = {byte[].class, int.class, int.class, byte[].class, int.class} - ) - public void testUpdatebyteArrayintintbyteArrayint() throws Exception { - byte [] b = {1, 2, 3, 4, 5}; - byte [] r = new byte[5]; - c.update(b, 0, 5, r, 0); - assertTrue("different content", Arrays.equals(b, r)); - } - - /* - * Class under test for byte[] doFinal() - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Exceptions checking missed. Checks inherited method from Cipher.", - method = "doFinal", - args = {} - ) - public void testDoFinal() throws Exception { - assertNull("doFinal failed", c.doFinal()); - } - - /* - * Class under test for int doFinal(byte[], int) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Exceptions checking missed. Checks inherited method from Cipher.", - method = "doFinal", - args = {byte[].class, int.class} - ) - public void testDoFinalbyteArrayint() throws Exception { - byte [] r = new byte[5]; - assertEquals("doFinal failed", 0, c.doFinal(r, 0)); - } - - /* - * Class under test for byte[] doFinal(byte[]) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Exceptions checking missed. Checks inherited method from Cipher.", - method = "doFinal", - args = {byte[].class} - ) - public void testDoFinalbyteArray() throws Exception { - byte [] b = {1, 2, 3, 4, 5}; - byte [] r = null; - r = c.doFinal(b); - assertEquals("different length", b.length, r.length); - assertTrue("different content", Arrays.equals(b, r)); - } - - /* - * Class under test for byte[] doFinal(byte[], int, int) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Exceptions checking missed. Checks inherited method from Cipher.", - method = "doFinal", - args = {byte[].class, int.class, int.class} - ) - public void testDoFinalbyteArrayintint() throws Exception { - byte [] b = {1, 2, 3, 4, 5}; - byte [] r = null; - r = c.doFinal(b, 0, 5); - assertEquals("different length", b.length, r.length); - assertTrue("different content", Arrays.equals(b, r)); - - r = c.doFinal(b, 1, 3); - assertEquals("different length", 3, r.length); - for (int i = 0; i < 3; i++) { - assertEquals("different content", b[i + 1], r[i]); - } - } - - /* - * Class under test for byte[] update(byte[], int, int) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Exceptions checking missed. Checks inherited method from Cipher.", - method = "update", - args = {byte[].class, int.class, int.class} - ) - public void testUpdatebyteArrayintint2() { - //Regression for HARMONY-758 - try { - new NullCipher().update(new byte[1], 1, Integer.MAX_VALUE); - fail("Expected IllegalArgumentException was not thrown"); - } catch (IllegalArgumentException e) { - } - } - - /* - * Class under test for int doFinal(byte[], int, int, byte[]) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Exceptions checking missed. Checks inherited method from Cipher.", - method = "doFinal", - args = {byte[].class, int.class, int.class, byte[].class} - ) - public void testDoFinalbyteArrayintintbyteArray() throws Exception { - byte [] b = {1, 2, 3, 4, 5}; - byte [] r = new byte[5]; - c.doFinal(b, 0, 5, r); - assertTrue("different content", Arrays.equals(b, r)); - } - - /* - * Class under test for int doFinal(byte[], int, int, byte[]) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Exceptions checking missed. Checks inherited method from Cipher.", - method = "doFinal", - args = {byte[].class, int.class, int.class, byte[].class} - ) - public void testDoFinalbyteArrayintintbyteArray2() throws Exception { - //Regression for HARMONY-758 - try { - new NullCipher().update(new byte[1], 1, Integer.MAX_VALUE, - new byte[1]); - fail("Expected IllegalArgumentException was not thrown"); - } catch (IllegalArgumentException e) { - } - } - - /* - * Class under test for int doFinal(byte[], int, int, byte[]) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Exceptions checking missed. Checks inherited method from Cipher.", - method = "doFinal", - args = {byte[].class, int.class, int.class, byte[].class} - ) - public void testDoFinalbyteArrayintintbyteArray3() throws Exception { - //Regression for HARMONY-758 - try { - new NullCipher().update(new byte[1], 0, 1, new byte[0]); - fail("Expected IndexOutOfBoundsException was not thrown"); - } catch (IndexOutOfBoundsException e) { - } - } - - /* - * Class under test for int doFinal(byte[], int, int, byte[], int) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Exceptions checking missed. Checks inherited method from Cipher.", - method = "doFinal", - args = {byte[].class, int.class, int.class, byte[].class, int.class} - ) - public void testDoFinalbyteArrayintintbyteArrayint() throws Exception { - byte [] b = {1, 2, 3, 4, 5}; - byte [] r = new byte[5]; - c.doFinal(b, 0, 5, r, 0); - assertTrue("different content", Arrays.equals(b, r)); - } - - /* - * Class under test for int doFinal(byte[], int, int, byte[], int) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Exceptions checking missed. Checks inherited method from Cipher.", - method = "doFinal", - args = {byte[].class, int.class, int.class, byte[].class, int.class} - ) - public void testDoFinalbyteArrayintintbyteArrayint2() throws Exception { - //Regression for HARMONY-758 - try { - new NullCipher().update(new byte[1], 1, Integer.MAX_VALUE, - new byte[1], 0); - fail("Expected IllegalArgumentException was not thrown"); - } catch (IllegalArgumentException e) { - } - } - - /* - * Class under test for int doFinal(byte[], int, int, byte[], int) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Exceptions checking missed. Checks inherited method from Cipher.", - method = "doFinal", - args = {byte[].class, int.class, int.class, byte[].class, int.class} - ) - public void testDoFinalbyteArrayintintbyteArrayint3() throws Exception { - //Regression for HARMONY-758 - try { - new NullCipher().update(new byte[1], 0, 1, - new byte[0], 0); - fail("Expected IndexOutOfBoundsException was not thrown"); - } catch (IndexOutOfBoundsException e) { - } - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/SealedObjectTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/SealedObjectTest.java deleted file mode 100644 index 5fb0245ac..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/SealedObjectTest.java +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with this - * work for additional information regarding copyright ownership. The ASF - * licenses this file to You under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -/** - * @author Alexander Y. Kleymenov - * @version $Revision$ - */ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; - -import junit.framework.TestCase; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchProviderException; -import java.util.Arrays; - -import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.KeyGenerator; -import javax.crypto.NullCipher; -import javax.crypto.SealedObject; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; - -@TestTargetClass(SealedObject.class) -/** - */ -public class SealedObjectTest extends TestCase { - class Mock_SealedObject extends SealedObject { - public Mock_SealedObject(Serializable object, Cipher c) - throws IOException, IllegalBlockSizeException { - super(object, c); - } - - public byte[] get_encodedParams() { - return super.encodedParams; - } - - } - - /** - * readObject(ObjectInputStream s) method testing. Tests if the - * serialization/deserialization works correctly: object is serialized, - * deserialized, the content od deserialized object equals to the content of - * initial object. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "!Serialization", - args = {} - ) - public void testReadObject() throws Exception { - String secret = "secret string"; - SealedObject so = new SealedObject(secret, new NullCipher()); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(bos); - oos.writeObject(so); - - ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream( - bos.toByteArray())); - - SealedObject so_des = (SealedObject) ois.readObject(); - assertEquals("The secret content of deserialized object " - + "should be equal to the secret content of initial object", - secret, so_des.getObject(new NullCipher())); - assertEquals("The value returned by getAlgorithm() method of " - + "deserialized object should be equal to the value returned " - + "by getAlgorithm() method of initial object", so - .getAlgorithm(), so_des.getAlgorithm()); - } - - /** - * SealedObject(Serializable object, Cipher c) method testing. Tests if the - * NullPointerException is thrown in the case of null cipher. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - method = "SealedObject", - args = {java.io.Serializable.class, javax.crypto.Cipher.class} - ) - public void testSealedObject1() throws Exception { - String secret = "secret string"; - try { - new SealedObject(secret, null); - fail("NullPointerException should be thrown in the case " - + "of null cipher."); - } catch (NullPointerException e) { - } - - KeyGenerator kg = KeyGenerator.getInstance("DES"); - Key key = kg.generateKey(); - - IvParameterSpec ips = new IvParameterSpec(new byte[] { - 1, 2, 3, 4, 5, 6, 7, 8}); - - Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding"); - cipher.init(Cipher.ENCRYPT_MODE, key, ips); - - SealedObject so = new SealedObject(secret, cipher); - - cipher = Cipher.getInstance("DES/CBC/NoPadding"); - cipher.init(Cipher.ENCRYPT_MODE, key, ips); - - try { - new SealedObject(secret, cipher); - fail("IllegalBlockSizeException expected"); - } catch (IllegalBlockSizeException e) { - //expected - } - } - - /** - * SealedObject(SealedObject so) method testing. Tests if the - * NullPointerException is thrown in the case of null SealedObject. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "SealedObject", - args = {javax.crypto.SealedObject.class} - ) - public void testSealedObject2() throws Exception { - try { - new SealedObject(null) {}; - fail("NullPointerException should be thrown in the case " - + "of null SealedObject."); - } catch (NullPointerException e) { - } - - String secret = "secret string"; - Cipher cipher = new NullCipher(); - SealedObject so1 = new SealedObject(secret, cipher); - SealedObject so2 = new SealedObject(so1) {}; - - assertEquals("The secret content of the object should equals " - + "to the secret content of initial object.", secret, so2 - .getObject(cipher)); - assertEquals("The algorithm which was used to seal the object " - + "should be the same as the algorithm used to seal the " - + "initial object", so1.getAlgorithm(), so2.getAlgorithm()); - } - - /** - * getAlgorithm() method testing. Tests if the returned value equals to the - * corresponding value of Cipher object. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getAlgorithm", - args = {} - ) - public void testGetAlgorithm() throws Exception { - String secret = "secret string"; - String algorithm = "DES"; - KeyGenerator kg = KeyGenerator.getInstance(algorithm); - Key key = kg.generateKey(); - - Cipher cipher = Cipher.getInstance(algorithm); - cipher.init(Cipher.ENCRYPT_MODE, key); - SealedObject so = new SealedObject(secret, cipher); - - assertEquals("The algorithm name should be the same as used " - + "in cipher.", algorithm, so.getAlgorithm()); - } - - /** - * getObject(Key key) method testing. Tests if the object sealed with - * encryption algorithm and specified parameters can be retrieved by - * specifying the cryptographic key. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Not all exceptions can be checked.", - method = "getObject", - args = {java.security.Key.class} - ) - public void testGetObject1() throws Exception { - KeyGenerator kg = KeyGenerator.getInstance("DES"); - Key key = kg.generateKey(); - - IvParameterSpec ips = new IvParameterSpec(new byte[] { - 1, 2, 3, 4, 5, 6, 7, 8}); - - Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding"); - cipher.init(Cipher.ENCRYPT_MODE, key, ips); - - String secret = "secret string"; - Mock_SealedObject so = new Mock_SealedObject(secret, cipher); - - assertEquals("The returned object does not equals to the " - + "original object.", secret, so.getObject(key)); - - assertTrue("The encodedParams field of SealedObject object " - + "should contain the encoded algorithm parameters.", Arrays - .equals(so.get_encodedParams(), cipher.getParameters() - .getEncoded())); - try { - so.getObject((Key)null); - fail("InvalidKeyException expected"); - } catch (InvalidKeyException e) { - //expected - } catch (NullPointerException e) { - //also ok - } - } - - /** - * getObject(Cipher c) method testing. Tests if the proper exception is - * thrown in the case of incorrect input parameters and if the object sealed - * with encryption algorithm and specified parameters can be retrieved by - * specifying the initialized Cipher object. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Not all exceptions can be checked.", - method = "getObject", - args = {javax.crypto.Cipher.class} - ) - public void testGetObject2() throws Exception { - try { - new SealedObject("secret string", new NullCipher()) - .getObject((Cipher) null); - fail("NullPointerException should be thrown in the case of " - + "null cipher."); - } catch (NullPointerException e) { - } - - KeyGenerator kg = KeyGenerator.getInstance("DES"); - Key key = kg.generateKey(); - - IvParameterSpec ips = new IvParameterSpec(new byte[] { - 1, 2, 3, 4, 5, 6, 7, 8}); - - Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding"); - cipher.init(Cipher.ENCRYPT_MODE, key, ips); - - String secret = "secret string"; - SealedObject so = new SealedObject(secret, cipher); - - cipher.init(Cipher.DECRYPT_MODE, key, ips); - assertEquals("The returned object does not equals to the " - + "original object.", secret, so.getObject(cipher)); - - try { - so.getObject((Cipher)null); - fail("NullPointerException expected"); - } catch (NullPointerException e) { - //expected - } - } - - /** - * getObject(Key key, String provider) method testing. Tests if the proper - * exception is thrown in the case of incorrect input parameters and if the - * object sealed with encryption algorithm can be retrieved by specifying - * the cryptographic key and provider name. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Not all exceptions can be checked.", - method = "getObject", - args = {java.security.Key.class, java.lang.String.class} - ) - public void testGetObject3() throws Exception { - try { - new SealedObject("secret string", new NullCipher()).getObject( - new SecretKeySpec(new byte[] {0, 0, 0}, "algorithm"), null); - fail("IllegalArgumentException should be thrown in the case of " - + "null provider."); - } catch (IllegalArgumentException e) { - } - - try { - new SealedObject("secret string", new NullCipher()).getObject( - new SecretKeySpec(new byte[] {0, 0, 0}, "algorithm"), ""); - fail("IllegalArgumentException should be thrown in the case of " - + "empty provider."); - } catch (IllegalArgumentException e) { - } - - KeyGenerator kg = KeyGenerator.getInstance("DES"); - Key key = kg.generateKey(); - - Cipher cipher = Cipher.getInstance("DES"); - String provider = cipher.getProvider().getName(); - cipher.init(Cipher.ENCRYPT_MODE, key); - - String secret = "secret string"; - SealedObject so = new SealedObject(secret, cipher); - - cipher.init(Cipher.DECRYPT_MODE, key); - assertEquals("The returned object does not equals to the " - + "original object.", secret, so.getObject(key, provider)); - - kg = KeyGenerator.getInstance("DESede"); - key = kg.generateKey(); - - try { - so.getObject(key, provider); - fail("InvalidKeyException expected"); - } catch (InvalidKeyException e) { - //expected - } - - try { - so.getObject(key, "Wrong provider name"); - fail("NoSuchProviderException expected"); - } catch (NoSuchProviderException e) { - //expected - } - } - -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactorySpiTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactorySpiTest.java deleted file mode 100644 index bcc05a2c1..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactorySpiTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @author Vera Y. Petrashkova - * @version $Revision$ - */ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.security.InvalidKeyException; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.KeySpec; -import javax.crypto.SecretKeyFactorySpi; -import javax.crypto.SecretKey; -import org.apache.harmony.crypto.tests.support.MySecretKeyFactorySpi; - -import junit.framework.TestCase; - -/** - * Tests for SecretKeyFactorySpi class constructors and methods. - */ - -@TestTargetClass(SecretKeyFactorySpi.class) -public class SecretKeyFactorySpiTest extends TestCase { - class Mock_SecretKeyFactorySpi extends MySecretKeyFactorySpi { - - @Override - protected SecretKey engineGenerateSecret(KeySpec keySpec) throws InvalidKeySpecException { - return super.engineGenerateSecret(keySpec); - } - - @Override - protected KeySpec engineGetKeySpec(SecretKey key, Class keySpec) - throws InvalidKeySpecException { - return super.engineGetKeySpec(key, keySpec); - } - - @Override - protected SecretKey engineTranslateKey(SecretKey key) throws InvalidKeyException { - return super.engineTranslateKey(key); - } - - } - - /** - * Test for SecretKeyFactorySpi constructor Assertion: - * constructs SecretKeyFactorySpi - */ - @TestTargetNew(level = TestLevel.COMPLETE, notes = "", method = "SecretKeyFactorySpi", args = {}) - public void testSecretKeyFactorySpi01() throws InvalidKeyException, InvalidKeySpecException { - Mock_SecretKeyFactorySpi skfSpi = new Mock_SecretKeyFactorySpi(); - SecretKey sk = null; - assertNull("Not null result", skfSpi.engineTranslateKey(sk)); - - KeySpec kspec = null; - assertNull("Not null result", skfSpi.engineGenerateSecret(kspec)); - - assertNull("Not null result", skfSpi.engineGetKeySpec(sk, null)); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactoryTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactoryTest.java deleted file mode 100644 index 6526239d0..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactoryTest.java +++ /dev/null @@ -1,596 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.Provider; -import java.security.SecureRandom; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.KeySpec; - -import javax.crypto.KeyGenerator; -import javax.crypto.SecretKey; -import javax.crypto.SecretKeyFactory; -import javax.crypto.SecretKeyFactorySpi; -import javax.crypto.spec.DESKeySpec; -import javax.crypto.spec.DESedeKeySpec; -import javax.crypto.spec.SecretKeySpec; - -import org.apache.harmony.crypto.tests.support.MySecretKeyFactorySpi; -import org.apache.harmony.security.tests.support.SpiEngUtils; - -import junit.framework.TestCase; - -@TestTargetClass(SecretKeyFactory.class) -/** - * Tests for SecretKeyFactory class constructors and methods. - * - */ - -public class SecretKeyFactoryTest extends TestCase { - - public static final String srvSecretKeyFactory = "SecretKeyFactory"; - - private static String defaultAlgorithm1 = "DESede"; - private static String defaultAlgorithm2 = "DES"; - - public static String defaultAlgorithm = null; - - private static String defaultProviderName = null; - - private static Provider defaultProvider = null; - - private static final String[] invalidValues = SpiEngUtils.invalidValues; - - public static final String[] validValues = new String[2]; - private static boolean DEFSupported = false; - - private static final String NotSupportMsg = "Default algorithm is not supported"; - - static { - defaultProvider = SpiEngUtils.isSupport(defaultAlgorithm1, - srvSecretKeyFactory); - DEFSupported = (defaultProvider != null); - if (DEFSupported) { - defaultAlgorithm = defaultAlgorithm1; - validValues[0] = defaultAlgorithm.toUpperCase(); - validValues[1] = defaultAlgorithm.toLowerCase(); - defaultProviderName = defaultProvider.getName(); - } else { - defaultProvider = SpiEngUtils.isSupport(defaultAlgorithm2, - srvSecretKeyFactory); - DEFSupported = (defaultProvider != null); - if (DEFSupported) { - defaultAlgorithm = defaultAlgorithm2; - validValues[0] = defaultAlgorithm.toUpperCase(); - validValues[2] = defaultAlgorithm.toLowerCase(); - defaultProviderName = defaultProvider.getName(); - } else { - defaultAlgorithm = null; - defaultProviderName = null; - defaultProvider = null; - } - } - } - - protected SecretKeyFactory[] createSKFac() { - if (!DEFSupported) { - fail(defaultAlgorithm + " algorithm is not supported"); - return null; - } - SecretKeyFactory[] skF = new SecretKeyFactory[3]; - try { - skF[0] = SecretKeyFactory.getInstance(defaultAlgorithm); - skF[1] = SecretKeyFactory.getInstance(defaultAlgorithm, - defaultProvider); - skF[2] = SecretKeyFactory.getInstance(defaultAlgorithm, - defaultProviderName); - return skF; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - /** - * Test for SecretKeyFactory constructor - * Assertion: returns SecretKeyFactory object - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "SecretKeyFactory", - args = {javax.crypto.SecretKeyFactorySpi.class, java.security.Provider.class, java.lang.String.class} - ) - public void testSecretKeyFactory01() throws NoSuchAlgorithmException, - InvalidKeySpecException, InvalidKeyException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - SecretKeyFactorySpi spi = new MySecretKeyFactorySpi(); - SecretKeyFactory secKF = new mySecretKeyFactory(spi, defaultProvider, - defaultAlgorithm); - assertEquals("Incorrect algorithm", secKF.getAlgorithm(), - defaultAlgorithm); - assertEquals("Incorrect provider", secKF.getProvider(), defaultProvider); - assertNull("Incorrect result", secKF.generateSecret(null)); - assertNull("Incorrect result", secKF.getKeySpec(null, null)); - assertNull("Incorrect result", secKF.translateKey(null)); - secKF = new mySecretKeyFactory(null, null, null); - assertNull("Algorithm must be null", secKF.getAlgorithm()); - assertNull("Provider must be null", secKF.getProvider()); - try { - secKF.translateKey(null); - fail("NullPointerException must be thrown"); - } catch (NullPointerException e) { - } - } - - /** - * Test for getInstance(String algorithm) method - * Assertions: - * throws NullPointerException when algorithm is null; - * throws NoSuchAlgorithmException when algorithm has invalid value - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class} - ) - public void testSecretKeyFactory02() throws NoSuchAlgorithmException { - try { - SecretKeyFactory.getInstance(null); - fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - SecretKeyFactory.getInstance(invalidValues[i]); - fail("NoSuchAlgorithmException was not thrown as expected"); - } catch (NoSuchAlgorithmException e) { - } - } - } - - /** - * Test for getInstance(String algorithm) method - * Assertion: returns SecretKeyObject - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class} - ) - public void testSecretKeyFactory03() throws NoSuchAlgorithmException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - for (int i = 0; i < validValues.length; i++) { - SecretKeyFactory secKF = SecretKeyFactory - .getInstance(validValues[i]); - assertEquals("Incorrect algorithm", secKF.getAlgorithm(), - validValues[i]); - } - } - - /** - * Test for getInstance(String algorithm, String provider) - * method - * Assertion: - * throws NullPointerException when algorithm is null; - * throws NoSuchAlgorithmException when algorithm is invalid - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testSecretKeyFactory04() throws NoSuchAlgorithmException, - NoSuchProviderException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - try { - SecretKeyFactory.getInstance(null, defaultProviderName); - fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - SecretKeyFactory.getInstance(invalidValues[i], - defaultProviderName); - fail("NoSuchAlgorithmException was not thrown as expected (algorithm: " - .concat(invalidValues[i]).concat(")")); - } catch (NoSuchAlgorithmException e) { - } - } - } - - /** - * Test for getInstance(String algorithm, String provider) - * method - * Assertion: - * throws IllegalArgumentException when provider is null or empty; - * throws NoSuchProviderException when provider has invalid value - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testSecretKeyFactory05() throws NoSuchAlgorithmException, - NoSuchProviderException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - String prov = null; - for (int i = 0; i < validValues.length; i++) { - try { - SecretKeyFactory.getInstance(validValues[i], prov); - fail("IllegalArgumentException was not thrown as expected (algorithm: " - .concat(validValues[i]).concat(" provider: null")); - } catch (IllegalArgumentException e) { - } - try { - SecretKeyFactory.getInstance(validValues[i], ""); - fail("IllegalArgumentException was not thrown as expected (algorithm: " - .concat(validValues[i]).concat(" provider: empty")); - } catch (IllegalArgumentException e) { - } - for (int j = 1; j < invalidValues.length; j++) { - try { - SecretKeyFactory.getInstance(validValues[i], - invalidValues[j]); - fail("NoSuchProviderException was not thrown as expected (algorithm: " - .concat(validValues[i]).concat(" provider: ") - .concat(invalidValues[j]).concat(")")); - } catch (NoSuchProviderException e) { - } - } - } - } - - /** - * Test for getInstance(String algorithm, String provider) - * method - * Assertion: returns SecretKeyFactory object - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testSecretKeyFactory06() throws NoSuchProviderException, - NoSuchAlgorithmException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - for (int i = 0; i < validValues.length; i++) { - SecretKeyFactory secKF = SecretKeyFactory.getInstance( - validValues[i], defaultProviderName); - assertEquals("Incorrect algorithm", secKF.getAlgorithm(), - validValues[i]); - assertEquals("Incorrect provider", secKF.getProvider().getName(), - defaultProviderName); - } - } - - /** - * Test for getInstance(String algorithm, Provider provider) - * method - * Assertion: throws NullPointerException when algorithm is null; - * throws NoSuchAlgorithmException when algorithm is invalid - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.security.Provider.class} - ) - public void testSecretKeyFactory07() throws NoSuchAlgorithmException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - try { - SecretKeyFactory.getInstance(null, defaultProvider); - fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - SecretKeyFactory.getInstance(invalidValues[i], defaultProvider); - fail("NoSuchAlgorithmException was not thrown as expected (algorithm: " - .concat(invalidValues[i]).concat(")")); - } catch (NoSuchAlgorithmException e) { - } - } - } - - /** - * Test for getInstance(String algorithm, Provider provider) - * method - * Assertion: throws IllegalArgumentException when provider is null - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.security.Provider.class} - ) - public void testSecretKeyFactory08() throws NoSuchAlgorithmException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - Provider prov = null; - for (int i = 0; i < validValues.length; i++) { - try { - SecretKeyFactory.getInstance(validValues[i], prov); - fail("IllegalArgumentException was not thrown as expected (provider is null, algorithm: " - .concat(validValues[i]).concat(")")); - } catch (IllegalArgumentException e) { - } - } - } - - /** - * Test for getInstance(String algorithm, Provider provider) - * method - * Assertion: returns SecretKeyFactory object - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "This is a complete subset of tests for getInstance method.", - method = "getInstance", - args = {java.lang.String.class, java.security.Provider.class} - ) - public void testSecretKeyFactory09() throws NoSuchAlgorithmException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - for (int i = 0; i < validValues.length; i++) { - SecretKeyFactory secKF = SecretKeyFactory.getInstance( - validValues[i], defaultProvider); - assertEquals("Incorrect algorithm", secKF.getAlgorithm(), - validValues[i]); - assertEquals("Incorrect provider", secKF.getProvider(), - defaultProvider); - } - } - - /** - * Test for generateSecret(KeySpec keySpec) and - * getKeySpec(SecretKey key, Class keySpec) - * methods - * Assertion: - * throw InvalidKeySpecException if parameter is inappropriate - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Tis test is checking two methods.", - method = "generateSecret", - args = {java.security.spec.KeySpec.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Tis test is checking two methods.", - clazz = SecretKeyFactorySpi.class, - method = "engineGenerateSecret", - args = {java.security.spec.KeySpec.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Tis test is checking two methods.", - method = "getKeySpec", - args = {javax.crypto.SecretKey.class, java.lang.Class.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Tis test is checking two methods.", - clazz = SecretKeyFactorySpi.class, - method = "engineGetKeySpec", - args = {javax.crypto.SecretKey.class, java.lang.Class.class} - ) - }) - public void testSecretKeyFactory10() throws InvalidKeyException, - InvalidKeySpecException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - byte[] bb = new byte[24]; - KeySpec ks = (defaultAlgorithm.equals(defaultAlgorithm2) ? (KeySpec)new DESKeySpec(bb) : - (KeySpec)new DESedeKeySpec(bb)); - KeySpec rks = null; - SecretKeySpec secKeySpec = new SecretKeySpec(bb, defaultAlgorithm); - SecretKey secKey = null; - SecretKeyFactory[] skF = createSKFac(); - assertNotNull("SecretKeyFactory object were not created", skF); - for (int i = 0; i < skF.length; i++) { - try { - skF[i].generateSecret(null); - fail("generateSecret(null): InvalidKeySpecException must be thrown"); - } catch (InvalidKeySpecException e) { - } - - secKey = skF[i].generateSecret(ks); - try { - skF[i].getKeySpec(null, null); - fail("getKeySpec(null,null): InvalidKeySpecException must be thrown"); - } catch (InvalidKeySpecException e) { - } - try { - skF[i].getKeySpec(null, ks.getClass()); - fail("getKeySpec(null, Class): InvalidKeySpecException must be thrown"); - } catch (InvalidKeySpecException e) { - } - try { - skF[i].getKeySpec(secKey, null); - fail("getKeySpec(secKey, null): NullPointerException or InvalidKeySpecException must be thrown"); - } catch (InvalidKeySpecException e) { - // Expected - } catch (NullPointerException e) { - // Expected - } - - try { - Class c; - if (defaultAlgorithm.equals(defaultAlgorithm2)) { - c = DESedeKeySpec.class; - } else { - c = DESKeySpec.class; - } - skF[i].getKeySpec(secKeySpec, c); - fail("getKeySpec(secKey, Class): InvalidKeySpecException must be thrown"); - } catch (InvalidKeySpecException e) { - } - rks = skF[i].getKeySpec(secKeySpec, ks.getClass()); - if (defaultAlgorithm.equals(defaultAlgorithm1)) { - assertTrue("Incorrect getKeySpec() result 1", - rks instanceof DESedeKeySpec); - } else { - assertTrue("Incorrect getKeySpec() result 1", - rks instanceof DESKeySpec); - } - - rks = skF[i].getKeySpec(secKey, ks.getClass()); - if (defaultAlgorithm.equals(defaultAlgorithm1)) { - assertTrue("Incorrect getKeySpec() result 2", - rks instanceof DESedeKeySpec); - } else { - assertTrue("Incorrect getKeySpec() result 2", - rks instanceof DESKeySpec); - } - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getAlgorithm", - args = {} - ) - public void test_getAlgorithm() throws NoSuchAlgorithmException { - for (int i = 0; i < validValues.length; i++) { - SecretKeyFactory secKF = SecretKeyFactory - .getInstance(validValues[i]); - assertEquals("Incorrect algorithm", secKF.getAlgorithm(), - validValues[i]); - } - - Mock_SecretKeyFactory msf = new Mock_SecretKeyFactory(null, null, null); - assertNull(msf.getAlgorithm()); - } - - class Mock_SecretKeyFactory extends SecretKeyFactory{ - protected Mock_SecretKeyFactory(SecretKeyFactorySpi arg0, Provider arg1, String arg2) { - super(arg0, arg1, arg2); - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getProvider", - args = {} - ) - public void test_getProvider() throws NoSuchAlgorithmException { - for (int i = 0; i < validValues.length; i++) { - SecretKeyFactory secKF = SecretKeyFactory - .getInstance(validValues[i]); - assertNotNull(secKF.getProvider()); - } - - Mock_SecretKeyFactory msf = new Mock_SecretKeyFactory(null, null, null); - assertNull(msf.getProvider()); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "translateKey", - args = {javax.crypto.SecretKey.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = SecretKeyFactorySpi.class, - method = "engineTranslateKey", - args = {javax.crypto.SecretKey.class} - ) - }) - public void test_translateKeyLjavax_crypto_SecretKey() - throws NoSuchAlgorithmException, InvalidKeyException { - KeyGenerator kg = null; - Key key = null; - SecretKeyFactory secKF = null; - - for (int i = 0; i < validValues.length; i++) { - secKF = SecretKeyFactory - .getInstance(validValues[i]); - assertNotNull(secKF.getProvider()); - kg = KeyGenerator.getInstance(secKF.getAlgorithm()); - kg.init(new SecureRandom()); - key = kg.generateKey(); - - secKF.translateKey((SecretKey) key); - } - try { - secKF.translateKey(null); - fail("InvalidKeyException expected"); - } catch (InvalidKeyException e) { - //expected - } - } -} - -class mySecretKeyFactory extends SecretKeyFactory { - public mySecretKeyFactory(SecretKeyFactorySpi spi, Provider prov, String alg) { - super(spi, prov, alg); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyTest.java deleted file mode 100644 index 4e34ed224..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import javax.crypto.SecretKey; - -import junit.framework.TestCase; - - -@TestTargetClass(SecretKey.class) -/** - * Tests for SecretKey class field - * - */ -public class SecretKeyTest extends TestCase { - - /** - * Test for serialVersionUID field - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "!Constants", - args = {} - ) - public void testField() { - checkSecretKey sk = new checkSecretKey(); - assertEquals("Incorrect serialVersionUID", - sk.getSerVerUID(), //SecretKey.serialVersionUID - -4795878709595146952L); - } - - public class checkSecretKey implements SecretKey { - public String getAlgorithm() { - return "SecretKey"; - } - public String getFormat() { - return "Format"; - } - public byte[] getEncoded() { - return new byte[0]; - } - public long getSerVerUID() { - return serialVersionUID; - } - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/ShortBufferExceptionTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/ShortBufferExceptionTest.java deleted file mode 100644 index 4390994bd..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/ShortBufferExceptionTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import javax.crypto.ShortBufferException; - -import junit.framework.TestCase; - -@TestTargetClass(ShortBufferException.class) -/** - * Tests for ShortBufferException class constructors and methods. - * - */ -public class ShortBufferExceptionTest extends TestCase { - - static String[] msgs = { - "", - "Check new message", - "Check new message Check new message Check new message Check new message Check new message" }; - - static Throwable tCause = new Throwable("Throwable for exception"); - - /** - * Test for ShortBufferException() constructor Assertion: - * constructs ShortBufferException with no detail message - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "ShortBufferException", - args = {} - ) - public void testShortBufferException01() { - ShortBufferException tE = new ShortBufferException(); - assertNull("getMessage() must return null.", tE.getMessage()); - assertNull("getCause() must return null", tE.getCause()); - } - - /** - * Test for ShortBufferException(String) constructor - * Assertion: constructs ShortBufferException with detail message msg. - * Parameter msg is not null. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "ShortBufferException", - args = {java.lang.String.class} - ) - public void testShortBufferException02() { - ShortBufferException tE; - for (int i = 0; i < msgs.length; i++) { - tE = new ShortBufferException(msgs[i]); - assertEquals("getMessage() must return: ".concat(msgs[i]), tE - .getMessage(), msgs[i]); - assertNull("getCause() must return null", tE.getCause()); - } - } - - /** - * Test for ShortBufferException(String) constructor - * Assertion: constructs ShortBufferException when msg is - * null - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "ShortBufferException", - args = {java.lang.String.class} - ) - public void testShortBufferException03() { - String msg = null; - ShortBufferException tE = new ShortBufferException(msg); - assertNull("getMessage() must return null.", tE.getMessage()); - assertNull("getCause() must return null", tE.getCause()); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/AllTests.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/AllTests.java deleted file mode 100644 index 906057bf4..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/AllTests.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.crypto.tests.javax.crypto.func; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * This is autogenerated source file. Includes tests for package org.apache.harmony.crypto.tests.javax.crypto; - */ - -public class AllTests { - - public static void main(String[] args) { - junit.textui.TestRunner.run(AllTests.suite()); - } - - public static Test suite() { - TestSuite suite = new TestSuite("All tests for package org.apache.harmony.crypto.tests.javax.crypto.func;"); - // $JUnit-BEGIN$ - - suite.addTestSuite(CipherAesTest.class); - suite.addTestSuite(CipherAesWrapTest.class); - suite.addTestSuite(CipherDESedeTest.class); - suite.addTestSuite(CipherDESedeWrapTest.class); - suite.addTestSuite(CipherDesTest.class); - suite.addTestSuite(CipherPBETest.class); - suite.addTestSuite(CipherRSATest.class); - suite.addTestSuite(KeyAgreementFunctionalTest.class); - suite.addTestSuite(KeyGeneratorFunctionalTest.class); - suite.addTestSuite(MacFunctionalTest.class); - suite.addTestSuite(SecretKeyFactoryFunctionalTest.class); - - // $JUnit-END$ - return suite; - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesTest.java deleted file mode 100644 index d00c62bd7..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; - -import junit.framework.TestCase; - -import targets.Cipher; - -@TestTargetClass(Cipher.AES.class) -public class CipherAesTest extends TestCase { -// 216 cases checked - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void test_AesNoISO() { - CipherSymmetricKeyThread aesNoISO = new CipherSymmetricKeyThread("AES", - new int[] {128, 192, 256}, // Keysize must be 128, 192, 256. - new String[] { - "ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", "CFB32", - "CFB40", "CFB48", "CFB56", "CFB64", "CFB72", "CFB80", - "CFB88", "CFB96", "CFB104", "CFB112", "CFB120", - "CFB128", "OFB", "OFB8", "OFB16", "OFB24", "OFB32", - "OFB40", "OFB48", "OFB56", "OFB64", "OFB72", "OFB80", - "OFB88", "OFB96", "OFB104", "OFB112", "OFB120", - "OFB128"}, new String[] {"NoPadding", "PKCS5Padding"}); - - aesNoISO.launcher(); - - assertEquals(aesNoISO.getFailureMessages(), 0, aesNoISO - .getTotalFailuresNumber()); - } - -// 108 cases checked - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void test_AesISO() { - CipherSymmetricKeyThread aesISO = new CipherSymmetricKeyThread("AES", - new int[] {128, 192, 256}, // Keysize must be 128, 192, 256. - new String[] { - "ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", "CFB32", - "CFB40", "CFB48", "CFB56", "CFB64", "CFB72", "CFB80", - "CFB88", "CFB96", "CFB104", "CFB112", "CFB120", - "CFB128", "OFB", "OFB8", "OFB16", "OFB24", "OFB32", - "OFB40", "OFB48", "OFB56", "OFB64", "OFB72", "OFB80", - "OFB88", "OFB96", "OFB104", "OFB112", "OFB120", - "OFB128"}, new String[] {"ISO10126PADDING"}); - - aesISO.launcher(); - - assertEquals(aesISO.getFailureMessages(), 0, aesISO - .getTotalFailuresNumber()); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesWrapTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesWrapTest.java deleted file mode 100644 index d196edc05..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesWrapTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; - -import junit.framework.TestCase; - -import targets.Cipher; - -@TestTargetClass(Cipher.AESWrap.class) -public class CipherAesWrapTest extends TestCase { -// 3 cases checked - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void test_AesWrap() { - CipherWrapThread aesWrap = new CipherWrapThread("AESWrap", new int[] { - 128, 192, 256}, // Keysize must be 128, 192, 256. - new String[] {"ECB"}, new String[] {"NoPadding"}); - - aesWrap.launcher(); - - assertEquals(aesWrap.getFailureMessages(), 0, aesWrap - .getTotalFailuresNumber()); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeTest.java deleted file mode 100644 index 7352e83b9..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; - -import junit.framework.TestCase; - -import targets.Cipher; - -@TestTargetClass(Cipher.DESede.class) -public class CipherDESedeTest extends TestCase { -// 80 cases checked - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void test_DESedeNoISO() { - CipherSymmetricKeyThread DESedeNoISO = new CipherSymmetricKeyThread( - "DESede", new int[] {112, 168},// Keysize must be 112 or 168. - new String[] { - "ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", "CFB32", - "CFB40", "CFB48", "CFB56", "CFB64", "OFB", "OFB8", - "OFB16", "OFB24", "OFB32", "OFB40", "OFB48", "OFB56", - "OFB64"}, new String[] {"NoPadding", "PKCS5Padding"}); - - DESedeNoISO.launcher(); - - assertEquals(DESedeNoISO.getFailureMessages(), 0, DESedeNoISO - .getTotalFailuresNumber()); - } - -// 40 cases checked - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void test_DESedeISO() { - CipherSymmetricKeyThread DESedeISO = new CipherSymmetricKeyThread( - "DESede", new int[] {112, 168},// Keysize must be 112 or 168. - new String[] { - "ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", "CFB32", - "CFB40", "CFB48", "CFB56", "CFB64", "OFB", "OFB8", - "OFB16", "OFB24", "OFB32", "OFB40", "OFB48", "OFB56", - "OFB64"}, new String[] {"ISO10126PADDING"}); - - DESedeISO.launcher(); - - assertEquals(DESedeISO.getFailureMessages(), 0, DESedeISO - .getTotalFailuresNumber()); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeWrapTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeWrapTest.java deleted file mode 100644 index 2169a9321..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeWrapTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import junit.framework.TestCase; - -import targets.Cipher; - -@TestTargetClass(Cipher.DESedeWrap.class) -public class CipherDESedeWrapTest extends TestCase { -// 2 cases checked. - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void test_DESedeWrap() { - CipherWrapThread DESedeWrap = new CipherWrapThread("DESedeWrap", - new int[] {112, 168}, // Keysize must be 112 or 168. - new String[] {"CBC"}, new String[] {"NoPadding"}); - - DESedeWrap.launcher(); - - assertEquals(DESedeWrap.getFailureMessages(), 0, DESedeWrap - .getTotalFailuresNumber()); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDesTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDesTest.java deleted file mode 100644 index 6f8fbc30e..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDesTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; - -import junit.framework.TestCase; - -import targets.Cipher; - -@TestTargetClass(Cipher.DES.class) -public class CipherDesTest extends TestCase { -// 40 cases checked - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void test_DesNoISO() { - CipherSymmetricKeyThread desNoISO = new CipherSymmetricKeyThread("DES", - new int[] {56},// Keysize must be 56. - new String[] { - "ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", "CFB32", - "CFB40", "CFB48", "CFB56", "CFB64", "OFB", "OFB8", - "OFB16", "OFB24", "OFB32", "OFB40", "OFB48", "OFB56", - "OFB64"}, new String[] {"NoPadding", "PKCS5Padding"}); - - desNoISO.launcher(); - - assertEquals(desNoISO.getFailureMessages(), 0, desNoISO - .getTotalFailuresNumber()); - } - -// 20 cases checked - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void test_DesISO() { - CipherSymmetricKeyThread desISO = new CipherSymmetricKeyThread("DES", - new int[] {56},// Keysize must be 56. - new String[] { - "ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", "CFB32", - "CFB40", "CFB48", "CFB56", "CFB64", "OFB", "OFB8", - "OFB16", "OFB24", "OFB32", "OFB40", "OFB48", "OFB56", - "OFB64"}, new String[] {"ISO10126PADDING"}); - - desISO.launcher(); - - assertEquals(desISO.getFailureMessages(), 0, desISO - .getTotalFailuresNumber()); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBETest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBETest.java deleted file mode 100644 index 3ea1f1394..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBETest.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - -import dalvik.annotation.AndroidOnly; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; - -import junit.framework.TestCase; - -import targets.Cipher; - -@TestTargetClass(Cipher.PBE.class) -public class CipherPBETest extends TestCase { - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void test_PBEWithMD5AndDES() throws Exception { - CipherPBEThread PBEWithMD5AndDES = new CipherPBEThread( - "PBEWithMD5AndDES", new int[] {56}, new String[] {"CBC"}, - new String[] {"PKCS5Padding"}); - - PBEWithMD5AndDES.launcher(); - - assertEquals(PBEWithMD5AndDES.getFailureMessages(), 0, PBEWithMD5AndDES - .getTotalFailuresNumber()); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "method", - args = {} - ) - @AndroidOnly("Not supported by RI (maybe with a different name)") - public void test_PBEWithSHAand3KeyTripleDES() throws Exception { - CipherPBEThread PBEWITHSHAAND3KEYTRIPLEDESCBC = new CipherPBEThread( - "PBEWITHSHAAND3-KEYTRIPLEDES-CBC", new int[] {112, 168}, - new String[] {"CBC"}, new String[] {"PKCS5Padding"}); - - PBEWITHSHAAND3KEYTRIPLEDESCBC.launcher(); - - assertEquals(PBEWITHSHAAND3KEYTRIPLEDESCBC.getFailureMessages(), 0, - PBEWITHSHAAND3KEYTRIPLEDESCBC.getTotalFailuresNumber()); - } - - // Supported, but not part of mandatory components for Android - public void disabled_test_PBEWithSHA1And40BitRC2() throws Exception { - CipherPBEThread PBEWithSHA1AndRC2_40 = new CipherPBEThread( - "PBEWITHSHAAND40BITRC2-CBC", new int[] {40}, - new String[] {"CBC"}, new String[] {"PKCS5Padding"}); - - PBEWithSHA1AndRC2_40.launcher(); - - assertEquals(PBEWithSHA1AndRC2_40.getFailureMessages(), 0, - PBEWithSHA1AndRC2_40.getTotalFailuresNumber()); - } - - - // Not supported by Android - public void disabled_test_PBEWithMD5AndTripleDES() throws Exception { - CipherPBEThread PBEWithMD5AndTripleDES = new CipherPBEThread( - "PBEWithMD5AndTripleDES", new int[] {112, 168}, - new String[] {"CBC"}, new String[] {"PKCS5Padding"}); - - PBEWithMD5AndTripleDES.launcher(); - - assertEquals(PBEWithMD5AndTripleDES.getFailureMessages(), 0, - PBEWithMD5AndTripleDES.getTotalFailuresNumber()); - } - - // Not supported by Android - public void disabled_test_PBEWithSHA1AndDESede() throws Exception { - CipherPBEThread PBEWithSHA1AndDESede = new CipherPBEThread( - "PBEWithSHA1AndDESede", new int[] {112, 168}, - new String[] {"CBC"}, new String[] {"PKCS5Padding"}); - - PBEWithSHA1AndDESede.launcher(); - - assertEquals(PBEWithSHA1AndDESede.getFailureMessages(), 0, - PBEWithSHA1AndDESede.getTotalFailuresNumber()); - } - - // Not supported by Android - public void disabled_test_PBEWithSHA1AndRC2_40() throws Exception { - CipherPBEThread PBEWithSHA1AndRC2_40 = new CipherPBEThread( - "PBEWithSHA1AndRC2_40", new int[] {40}, new String[] {"CBC"}, - new String[] {"PKCS5Padding"}); - - PBEWithSHA1AndRC2_40.launcher(); - - assertEquals(PBEWithSHA1AndRC2_40.getFailureMessages(), 0, - PBEWithSHA1AndRC2_40.getTotalFailuresNumber()); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBEThread.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBEThread.java deleted file mode 100644 index 0e8dc4d1f..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBEThread.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - - -import java.security.SecureRandom; -import java.security.spec.AlgorithmParameterSpec; - -import javax.crypto.Cipher; -import javax.crypto.SecretKey; -import javax.crypto.SecretKeyFactory; -import javax.crypto.spec.PBEKeySpec; -import javax.crypto.spec.PBEParameterSpec; - -public class CipherPBEThread extends CipherThread { - - CipherPBEThread(String name, int[] keys, String[] modes, String[] paddings) { - super(name, keys, modes, paddings); - } - - @Override - public void crypt() throws Exception { - byte[] output = new byte[128]; - byte[] decrypted = new byte[128]; - byte[] input = getData().getBytes(); - byte[] salt = new byte[8]; - SecureRandom sr = new SecureRandom(); - - PBEKeySpec keySpec = new PBEKeySpec("top sicret password".toCharArray()); - SecretKeyFactory skf = SecretKeyFactory.getInstance(getAlgName()); - SecretKey key = skf.generateSecret(keySpec); - - Cipher cip = Cipher.getInstance(getAlgName() + "/" + getMode() + "/" + - getPadding()); - - sr.nextBytes(salt); - PBEParameterSpec parSpec = new PBEParameterSpec(salt, getKeyLength()); - - cip.init(Cipher.ENCRYPT_MODE, key, parSpec); - cip.doFinal(input, 0, input.length, output); - int outputSize = cip.getOutputSize(input.length); - cip.init(Cipher.DECRYPT_MODE, key, parSpec); - cip.doFinal(output, 0, outputSize, decrypted); - - checkEncodedData(getData().getBytes(), decrypted); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherRSATest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherRSATest.java deleted file mode 100644 index 5acc5b5cc..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherRSATest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - -import dalvik.annotation.AndroidOnly; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; - -import junit.framework.TestCase; - -import targets.Cipher; - -@TestTargetClass(Cipher.RSA.class) -public class CipherRSATest extends TestCase { -// 3 cases checked - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void test_RSAShortKey() { - CipherRSAThread rsa = new CipherRSAThread("RSA", new int[] {512}, - new String[] {"ECB"}, new String[] { - "PKCS1PADDING", "OAEPWITHMD5ANDMGF1PADDING", - "OAEPWITHSHA1ANDMGF1PADDING"}); - - rsa.launcher(); - - assertEquals(rsa.getFailureMessages(), 0, rsa.getTotalFailuresNumber()); - } - - // Not supported by Android - public void disabled_test_RSALongKey() { - CipherRSAThread rsa = new CipherRSAThread("RSA", new int[] {1024}, - new String[] {"ECB"}, - new String[] {"OAEPWITHSHA-384ANDMGF1PADDING", - "OAEPWITHSHA-256ANDMGF1PADDING"}); - - rsa.launcher(); - - assertEquals(rsa.getFailureMessages(), 0, rsa.getTotalFailuresNumber()); - } - - // Not supported by Android - public void disabled_test_RSAXXXLKey() { - CipherRSAThread rsa = new CipherRSAThread("RSA", new int[] {2048}, - new String[] {"ECB"}, - new String[] {"OAEPWITHSHA-512ANDMGF1PADDING"}); - - rsa.launcher(); - - assertEquals(rsa.getFailureMessages(), 0, rsa.getTotalFailuresNumber()); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - @AndroidOnly("Fails on RI but succeeds on Android.") - public void test_RSANoPadding() { - CipherRSAThread rsa = new CipherRSAThread("RSA", new int[] {1024}, - new String[] {"ECB"}, new String[] {"NOPADDING"}); - - rsa.launcher(); - - assertEquals(rsa.getFailureMessages(), 0, rsa.getTotalFailuresNumber()); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherRSAThread.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherRSAThread.java deleted file mode 100644 index 8efc0f698..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherRSAThread.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - - -import java.security.KeyPair; -import java.security.KeyPairGenerator; - -import javax.crypto.Cipher; - -public class CipherRSAThread extends CipherThread { - - CipherRSAThread(String name, int[] keys, String[] modes, String[] paddings) { - super(name, keys, modes, paddings); - } - - @Override - public void crypt() throws Exception { - byte[] output = new byte[256]; - byte[] decrypted = new byte[256]; - int dataBlock = 20; - byte[] input = getData().substring(0, dataBlock).getBytes(); - KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); - kpg.initialize(getKeyLength()); - KeyPair kp = kpg.generateKeyPair(); - - Cipher cip = Cipher.getInstance(getAlgName() + "/" + getMode() + "/" + - getPadding()); - cip.init(Cipher.ENCRYPT_MODE, kp.getPublic()); - cip.doFinal(input, 0, input.length, output); - int outputSize = cip.getOutputSize(input.length); - cip.init(Cipher.DECRYPT_MODE, kp.getPrivate()); - cip.doFinal(output, 0, outputSize, decrypted); - - checkEncodedData(input, decrypted); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherSymmetricKeyThread.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherSymmetricKeyThread.java deleted file mode 100644 index 63faadade..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherSymmetricKeyThread.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - - -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; - -import javax.crypto.Cipher; -import javax.crypto.KeyGenerator; -import javax.crypto.spec.IvParameterSpec; - -public class CipherSymmetricKeyThread extends CipherThread { - CipherSymmetricKeyThread(String name, int[] keys, String[] modes, String[] paddings) { - super(name, keys, modes, paddings); - } - - - @Override - public void crypt() throws Exception { - byte[] output = new byte[128]; - byte[] decrypted = new byte[128]; - byte[] input = getData().getBytes(); - SecureRandom sr = new SecureRandom(); - byte[] iv = null;//new byte[16]; - int outputSize = 0; - - KeyGenerator kg = KeyGenerator.getInstance(getAlgName()); - kg.init(getKeyLength(), new SecureRandom()); - Key key = kg.generateKey(); - - Cipher cip = Cipher.getInstance(getAlgName() + "/" + getMode() + "/" + - getPadding()); - if (getAlgName() != "AES") { - iv = new byte[8]; - } else { - iv = new byte[16]; - } - sr.nextBytes(iv); - IvParameterSpec ivspec = new IvParameterSpec(iv); - if (getMode() != "ECB") { - cip.init(Cipher.ENCRYPT_MODE, key, ivspec); - cip.doFinal(input, 0, input.length, output); - outputSize = cip.getOutputSize(input.length); - iv = cip.getIV(); - ivspec = new IvParameterSpec(iv); - cip.init(Cipher.DECRYPT_MODE, key, ivspec); - cip.doFinal(output, 0, outputSize, decrypted); - } else { - cip.init(Cipher.ENCRYPT_MODE, key); - cip.doFinal(input, 0, input.length, output); - outputSize = cip.getOutputSize(input.length); - cip.init(Cipher.DECRYPT_MODE, key); - cip.doFinal(output, 0, outputSize, decrypted); - } - - checkEncodedData(getData().getBytes(), decrypted); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherThread.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherThread.java deleted file mode 100644 index 25d51c4bc..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherThread.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - -import javax.crypto.Cipher; - -public abstract class CipherThread implements Runnable { - private int[] keyLengthAr = null; - private String[] modeAr = null; - private String[] paddingModeAr = null; - private int kCounter = 0; - private int mCounter = 0; - private int pCounter = 0; - private StringBuffer errorSB = null; - - private boolean flagTestResult = false; - private String data = " Albert Einstein was a German-born " + - "theoretical physicist. "; - private String algName = null; - private int keyLength = 0; - private String mode = null; - private String paddingMode = null; - private int fails = 0; - - abstract public void crypt() throws Exception; - - CipherThread(String name, int[] keys, String[] modes, String[] paddings) { - algName = name; - keyLengthAr = keys; - modeAr = modes; - paddingModeAr = paddings; - kCounter = 0; - mCounter = 0; - pCounter = 0; - } - - public void checkEncodedData(byte[] original, byte[] encoded) - throws Exception { - for(int i = 0; i < original.length; i++) { - if (original[i] != encoded[i]) { - throw new Exception("Source and encoded data not match " + - getCipherParameters()); - } - } - } - - public void launcher() { - Thread thread = null; - - do { - keyLength = getNextKey(); - do { - mode = getNextMode(); - do { - paddingMode = getNextPadding(); - thread = new Thread(this); - thread.start(); - try { - thread.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } while (hasNextPadding()); - } while (hasNextMode()); - } while (hasNextKey()); - } - - public void run() { - try { - crypt(); - } catch (Exception e) { - if(errorSB == null) { - errorSB = new StringBuffer(); - } - errorSB.append(e.getMessage()); - errorSB.append("\n"); - errorSB.append(getCipherParameters()); - errorSB.append("\n"); - StackTraceElement[] st = e.getStackTrace(); - for (int i = 0; i < st.length; i++) { - errorSB.append(st[i].toString()); - errorSB.append("\n"); - } - fails++; - return; - } - flagTestResult = true; - } - - public String getAlgName() { - return algName; - } - - public int getKeyLength() { - return keyLength; - } - - public String getData() { - return data; - } - - public String getPadding() { - return paddingMode; - } - - public String getMode() { - return mode; - } - - public String getCipherParameters() { - return "Alg name:" + algName + " Key:" + keyLength + " Mode:" + mode + - " Padding:" + paddingMode; - } - - public boolean getTestStatus() { - return flagTestResult; - } - - public String getAlgorithmName() { - return algName; - } - - public boolean hasNextKey() { - return (kCounter < keyLengthAr.length); - } - - public boolean hasNextMode() { - return (mCounter < modeAr.length); - } - - public boolean hasNextPadding() { - return (pCounter < paddingModeAr.length); - } - - public int getNextKey() { - kCounter = (hasNextKey()) ? kCounter : 0; - return keyLengthAr[kCounter++]; - } - - public String getNextMode() { - mCounter = (hasNextMode()) ? mCounter : 0; - return modeAr[mCounter++]; - } - - public String getNextPadding() { - pCounter = (hasNextPadding()) ? pCounter : 0; - return paddingModeAr[pCounter++]; - } - - public long getTotalCasesNumber() { - return keyLengthAr.length * modeAr.length * paddingModeAr.length; - } - - public long getTotalFailuresNumber() { - return fails; - } - - public String getFailureMessages() { - return (errorSB == null) ? "" : new String(errorSB); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherWrapThread.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherWrapThread.java deleted file mode 100644 index b0eabe25d..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherWrapThread.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - - -import java.security.Key; -import java.security.SecureRandom; - -import javax.crypto.Cipher; -import javax.crypto.KeyGenerator; - -public class CipherWrapThread extends CipherThread { - CipherWrapThread(String name, int[] keys, String[] modes, String[] paddings) { - super(name, keys, modes, paddings); - } - - @Override - public void crypt() throws Exception { - KeyGenerator kg = KeyGenerator.getInstance(getAlgName().replace("Wrap", "")); - kg.init(getKeyLength(), new SecureRandom()); - Key key = kg.generateKey(); - - // ignore mode and padding - Cipher cip = Cipher.getInstance(getAlgName()); - - cip.init(Cipher.WRAP_MODE, key); - byte[] output = cip.wrap(key); - cip.init(Cipher.UNWRAP_MODE, key); - Key decrypted = cip.unwrap(output, getAlgName(), Cipher.SECRET_KEY); - - checkEncodedData(key.getFormat().getBytes(), decrypted.getFormat().getBytes()); - checkEncodedData(key.getEncoded(), decrypted.getEncoded()); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementFunctionalTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementFunctionalTest.java deleted file mode 100644 index 2027df181..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementFunctionalTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - -import dalvik.annotation.BrokenTest; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargets; - -import junit.framework.TestCase; - -import targets.KeyAgreement; - -public class KeyAgreementFunctionalTest extends TestCase { - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = KeyAgreement.DH.class, - method = "method", - args = {} - ) - }) - @BrokenTest("Too slow - disabling for now") - public void test_KeyAgreement() throws Exception { - String[] algArray = {"DES", "DESede"}; - - KeyAgreementThread kat = new KeyAgreementThread(algArray); - kat.launcher(); - - assertEquals(kat.getFailureMessages(), 0, kat.getTotalFailuresNumber()); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementThread.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementThread.java deleted file mode 100644 index b8453c2ab..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementThread.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - -import java.security.AlgorithmParameterGenerator; -import java.security.AlgorithmParameters; -import java.security.KeyFactory; -import java.security.KeyPair; -import java.security.KeyPairGenerator; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.SecureRandom; -import java.security.spec.X509EncodedKeySpec; - -import javax.crypto.KeyAgreement; -import javax.crypto.spec.DHParameterSpec; - -import org.bouncycastle.util.Arrays; - -public class KeyAgreementThread extends TestThread { - class KeyAgreementGen { - private PrivateKey privateKey = null; - private byte[] publicKeyBytes = null; - - KeyAgreementGen(DHParameterSpec parameterSpec) - throws Exception { - KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DH"); - keyGen.initialize(parameterSpec); - KeyPair keypair = keyGen.generateKeyPair(); - - privateKey = keypair.getPrivate(); - publicKeyBytes = keypair.getPublic().getEncoded(); - } - - public byte[] getPublicKeyBytes () { - return publicKeyBytes; - } - - public byte[] getSecretKey(String alg, byte[] publicKey) throws Exception { - X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(publicKey); - KeyFactory keyFact = KeyFactory.getInstance("DH"); - PublicKey pubKey = keyFact.generatePublic(x509KeySpec); - - KeyAgreement ka = KeyAgreement.getInstance("DH"); - ka.init(privateKey); - ka.doPhase(pubKey, true); - - return ka.generateSecret(); - } - } - - public KeyAgreementThread(String[] names) { - super(names); - } - - @Override - public void test() throws Exception { - AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance("DH"); - apg.init(1024, new SecureRandom()); - AlgorithmParameters ap = apg.generateParameters(); - DHParameterSpec ps = ap.getParameterSpec(DHParameterSpec.class); - - KeyAgreementGen kag1 = new KeyAgreementGen(ps); - KeyAgreementGen kag2 = new KeyAgreementGen(ps); - - byte[] bArray1 = kag1.getPublicKeyBytes(); - byte[] bArray2 = kag2.getPublicKeyBytes(); - - byte[] sk1 = kag1.getSecretKey(algName, bArray2); - byte[] sk2 = kag2.getSecretKey(algName, bArray1); - - if (Arrays.areEqual(sk1, sk2) == false) { - throw new Exception ("Generated keys are not the same"); - } - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyGeneratorFunctionalTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyGeneratorFunctionalTest.java deleted file mode 100644 index 50b6ef669..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyGeneratorFunctionalTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargets; - -import junit.framework.TestCase; - -import targets.KeyGenerator; - -public class KeyGeneratorFunctionalTest extends TestCase { - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = KeyGenerator.AES.class, - method = "method", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = KeyGenerator.DES.class, - method = "method", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = KeyGenerator.DESede.class, - method = "method", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = KeyGenerator.HMACMD5.class, - method = "method", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = KeyGenerator.HMACSHA1.class, - method = "method", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = KeyGenerator.HMACSHA256.class, - method = "method", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = KeyGenerator.HMACSHA384.class, - method = "method", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = KeyGenerator.HMACSHA512.class, - method = "method", - args = {} - ) - }) - public void test_() throws Exception { - String[] algArray = {"AES", "DES", "DESEDE", "DESede", - "HMACMD5", "HmacMD5", "HMACSHA1", "HmacSHA1", "HMACSHA256", - "HmacSHA256", "HMACSHA384", "HmacSHA384", "HMACSHA512", - "HmacSHA512"}; - - KeyGeneratorThread kgt = new KeyGeneratorThread(algArray); - kgt.launcher(); - - assertEquals(kgt.getFailureMessages(), 0, kgt.getTotalFailuresNumber()); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyGeneratorThread.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyGeneratorThread.java deleted file mode 100644 index 52a7b5d4e..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyGeneratorThread.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - - -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; - -import javax.crypto.KeyGenerator; - -public class KeyGeneratorThread extends TestThread { - KeyGeneratorThread(String[] names) { - super(names); - } - - public void test() throws Exception { - KeyGenerator kg = KeyGenerator.getInstance(algName); - Key k = kg.generateKey(); - if(kg.getAlgorithm().toLowerCase().equals(k.getAlgorithm().toLowerCase()) != true) { - throw new Exception ("Algorithm names not matched for KeyGenerator" + - " and for Key objects"); - } - if(kg.getAlgorithm().toLowerCase().equals(algName.toLowerCase()) != true) { - throw new Exception ("Algorithm names not matched for KeyGenerator" + - " and for Key objects"); - } - byte[] array1 = k.getEncoded(); - k = kg.generateKey(); - byte[] array2 = k.getEncoded(); - int matches = 0; - for (int i = 0; i < array1.length; i++) { - if (array1[i] == array2[i]) { - matches++; - } - } - if (matches > array1.length / 2) { - throw new Exception("Generated keys are simular"); - } - SecureRandom random = new SecureRandom(); - kg.init(random); - matches = 0; - k = kg.generateKey(); - array1 = k.getEncoded(); - random = new SecureRandom(); - kg.init(random); - k = kg.generateKey(); - array2 = k.getEncoded(); - for (int i = 0; i < array1.length; i++) { - if (array1[i] == array2[i]) { - matches++; - } - } - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/MacFunctionalTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/MacFunctionalTest.java deleted file mode 100644 index 6452cb444..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/MacFunctionalTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargets; - -import junit.framework.TestCase; - -import targets.Mac; - -public class MacFunctionalTest extends TestCase { - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = Mac.HMACMD5.class, - method = "method", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = Mac.HMACSHA1.class, - method = "method", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = Mac.HMACSHA256.class, - method = "method", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = Mac.HMACSHA384.class, - method = "method", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = Mac.HMACSHA512.class, - method = "method", - args = {} - ) - }) - public void test_Mac() throws Exception { - String[] algArray = {"HMACSHA1", "HMACSHA256", "HMACSHA384", - "HMACSHA512", "HMACMD5"}; - - MacThread mt = new MacThread(algArray); - mt.launcher(); - - assertEquals(mt.getFailureMessages(), 0, mt.getTotalFailuresNumber()); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/MacThread.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/MacThread.java deleted file mode 100644 index de519d706..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/MacThread.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - -import javax.crypto.Mac; -import javax.crypto.spec.SecretKeySpec; - -public class MacThread extends TestThread { - MacThread(String[] names) { - super(names); - } - - @Override - public void test() throws Exception { - int size = 256; - byte[] src1 = new byte[size]; - byte[] src2 = new byte[size]; - byte[] src3 = new byte[size]; - int i; - - for (i = 0; i < size; i++) { - src1[i] = (byte)i; - src2[i] = (byte)i; - src3[i] = (byte)(size - i - 1); - } - Mac m = Mac.getInstance(algName); - byte[] b = {(byte)0, (byte)0, (byte)0, (byte)0, (byte)0}; - SecretKeySpec sks = new SecretKeySpec(b, "SHA1"); - m.init(sks); - - byte[] res = m.doFinal(src1); - String sign1 = new String(res); - m.init(sks); - res = m.doFinal(src2); - String sign2 = new String(res); - m.init(sks); - res = m.doFinal(src3); - String sign3 = new String(res); - if (sign1.compareTo(sign2) != 0 || sign1.compareTo(sign3) == 0 || - sign2.compareTo(sign3) == 0) { - throw new Exception ("Signature is not correct for algorithm " + algName); - } - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/SecretKeyFactoryFunctionalTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/SecretKeyFactoryFunctionalTest.java deleted file mode 100644 index 35fb49030..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/SecretKeyFactoryFunctionalTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - -import dalvik.annotation.KnownFailure; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargets; - -import junit.framework.TestCase; - -import targets.SecretKeyFactory; - -public class SecretKeyFactoryFunctionalTest extends TestCase { - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = SecretKeyFactory.DES.class, - method = "method", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = SecretKeyFactory.DESede.class, - method = "method", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - clazz = SecretKeyFactory.PBEWITHMD5ANDDES.class, - method = "method", - args = {} - ) - }) - public void test_() throws Exception { - String[] algArray = {"DES", "DESede", "PBEWITHMD5ANDDES"}; - - SecretKeyFactoryThread skft = new SecretKeyFactoryThread(algArray); - skft.launcher(); - - assertEquals(skft.getFailureMessages(), 0, skft.getTotalFailuresNumber()); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/SecretKeyFactoryThread.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/SecretKeyFactoryThread.java deleted file mode 100644 index d426939c7..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/SecretKeyFactoryThread.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - -import java.security.spec.KeySpec; - -import javax.crypto.SecretKeyFactory; -import javax.crypto.spec.DESKeySpec; -import javax.crypto.spec.DESedeKeySpec; -import javax.crypto.spec.PBEKeySpec; - -public class SecretKeyFactoryThread extends TestThread { - SecretKeyFactoryThread(String[] names) { - super(names); - } - - @Override - public void test() throws Exception { - SecretKeyFactory skf = SecretKeyFactory.getInstance(algName); - byte[] b = new byte[24]; - KeySpec ks = (KeySpec) ((algName == "DES") ? new DESKeySpec(b) : - (algName == "DESede") ? new DESedeKeySpec(b) : - new PBEKeySpec("passw".toCharArray())); - skf.generateSecret(ks); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/TestThread.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/TestThread.java deleted file mode 100644 index f970b1a02..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/TestThread.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.crypto.tests.javax.crypto.func; - -public abstract class TestThread implements Runnable { - public String[] algNamesArray = null; - public int aCounter = 0; - public String algName = null; - public StringBuffer errorSB = null; - public int fails = 0; - public boolean flagTestResult = false; - - TestThread(String[] names) { - algNamesArray = names; - aCounter = 0; - } - - public abstract void test() throws Exception; - - public void launcher() { - Thread thread = null; - - do { - algName = getNextAlgorithmName(); - thread = new Thread(this); - thread.start(); - try { - thread.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } while (hasAlgorithmName()); - } - - public void run() { - try { - test(); - } catch (Exception e) { - if(errorSB == null) { - errorSB = new StringBuffer(); - } - errorSB.append(e.getMessage()); - errorSB.append("\n"); - errorSB.append(getAlgorithmName()); - errorSB.append("\n"); - StackTraceElement[] st = e.getStackTrace(); - for (int i = 0; i < st.length; i++) { - errorSB.append(st[i].toString()); - errorSB.append("\n"); - } - fails++; - return; - } - flagTestResult = true; - } - - public String getAlgorithmName() { - return algName; - } - - public boolean hasAlgorithmName() { - return (aCounter < algNamesArray.length); - } - - public String getNextAlgorithmName() { - aCounter = (hasAlgorithmName()) ? aCounter : 0; - return algNamesArray[aCounter++]; - } - - public long getTotalFailuresNumber() { - return fails; - } - - public String getFailureMessages() { - return (errorSB == null) ? "" : new String(errorSB); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/AllTests.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/AllTests.java deleted file mode 100644 index b66a384f8..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/AllTests.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.crypto.tests.javax.crypto.interfaces; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * This is autogenerated source file. Includes tests for package org.apache.harmony.crypto.tests.javax.crypto.interfaces; - */ - -public class AllTests { - - public static void main(String[] args) { - junit.textui.TestRunner.run(AllTests.suite()); - } - - public static Test suite() { - TestSuite suite = tests.TestSuiteFactory.createTestSuite("All tests for package org.apache.harmony.crypto.tests.javax.crypto.interfaces;"); - // $JUnit-BEGIN$ - - suite.addTestSuite(DHPrivateKeyTest.class); - suite.addTestSuite(DHPublicKeyTest.class); - suite.addTestSuite(PBEKeyTest.class); - - // $JUnit-END$ - return suite; - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPrivateKeyTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPrivateKeyTest.java deleted file mode 100644 index 5130e1ec3..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPrivateKeyTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto.interfaces; - -import java.math.BigInteger; -import java.security.KeyPair; -import java.security.KeyPairGenerator; - -import javax.crypto.interfaces.DHKey; -import javax.crypto.interfaces.DHPrivateKey; -import javax.crypto.spec.DHParameterSpec; - -import junit.framework.TestCase; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargets; -import dalvik.annotation.BrokenTest; - - -/** - * Tests for DHPrivateKey class field - * - */ -@TestTargetClass(DHPrivateKey.class) -public class DHPrivateKeyTest extends TestCase { - - /** - * Test for serialVersionUID field - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "tests serialVersionUID for a fixed value", - method = "!field:serialVersionUID" - ) - public void testField() { - checkDHPrivateKey key = new checkDHPrivateKey(); - assertEquals("Incorrect serialVersionUID", - key.getSerVerUID(), //DHPrivateKey.serialVersionUID - 2211791113380396553L); - } - -@TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - method = "getX", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - clazz = DHKey.class, - method = "getParams", - args = {} - ) - }) - @BrokenTest("Too slow - disabling for now") - public void test_getParams() throws Exception { - KeyPairGenerator kg = KeyPairGenerator.getInstance("DH"); - kg.initialize(1024); - KeyPair kp1 = kg.genKeyPair(); - KeyPair kp2 = kg.genKeyPair(); - DHPrivateKey pk1 = (DHPrivateKey) kp1.getPrivate(); - DHPrivateKey pk2 = (DHPrivateKey) kp2.getPrivate(); - - assertTrue(pk1.getX().getClass().getCanonicalName().equals("java.math.BigInteger")); - assertTrue(pk1.getParams().getClass().getCanonicalName().equals("javax.crypto.spec.DHParameterSpec")); - assertFalse(pk1.equals(pk2)); - assertTrue(pk1.getX().equals(pk1.getX())); - } - - public class checkDHPrivateKey implements DHPrivateKey { - public String getAlgorithm() { - return "SecretKey"; - } - public String getFormat() { - return "Format"; - } - public byte[] getEncoded() { - return new byte[0]; - } - public long getSerVerUID() { - return serialVersionUID; - } - public BigInteger getX() { - return null; - } - public DHParameterSpec getParams() { - return null; - } - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPublicKeyTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPublicKeyTest.java deleted file mode 100644 index da39db043..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/DHPublicKeyTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto.interfaces; - -import dalvik.annotation.BrokenTest; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargets; - -import junit.framework.TestCase; - -import java.math.BigInteger; -import java.security.KeyPair; -import java.security.KeyPairGenerator; - -import javax.crypto.interfaces.DHKey; -import javax.crypto.interfaces.DHPublicKey; -import javax.crypto.spec.DHParameterSpec; - - -/** - * Tests for DHPublicKey class field - * - */ -@TestTargetClass(DHPublicKey.class) -public class DHPublicKeyTest extends TestCase { - - /** - * Test for serialVersionUID field - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "tests serialVersionUID for a fixed value", - method = "!field:serialVersionUID" - ) - public void testField() { - checkDHPublicKey key = new checkDHPublicKey(); - assertEquals("Incorrect serialVersionUID", - key.getSerVerUID(), //DHPublicKey.serialVersionUID - -6628103563352519193L); - } - -@TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - method = "getY", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - clazz = DHKey.class, - method = "getParams", - args = {} - ) - }) - @BrokenTest("Too slow - disabling for now") - public void test_getParams() throws Exception { - KeyPairGenerator kg = KeyPairGenerator.getInstance("DH"); - kg.initialize(1024); - KeyPair kp1 = kg.genKeyPair(); - KeyPair kp2 = kg.genKeyPair(); - DHPublicKey pk1 = (DHPublicKey) kp1.getPublic(); - DHPublicKey pk2 = (DHPublicKey) kp2.getPublic(); - - assertTrue(pk1.getY().getClass().getCanonicalName().equals("java.math.BigInteger")); - assertTrue(pk2.getParams().getClass().getCanonicalName().equals("javax.crypto.spec.DHParameterSpec")); - assertFalse(pk1.equals(pk2)); - assertTrue(pk1.getY().equals(pk1.getY())); - } - - public class checkDHPublicKey implements DHPublicKey { - public String getAlgorithm() { - return "SecretKey"; - } - public String getFormat() { - return "Format"; - } - public byte[] getEncoded() { - return new byte[0]; - } - public long getSerVerUID() { - return serialVersionUID; - } - public BigInteger getY() { - return null; - } - public DHParameterSpec getParams() { - return null; - } - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/PBEKeyTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/PBEKeyTest.java deleted file mode 100644 index 43d92652c..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/interfaces/PBEKeyTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto.interfaces; - -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; - -import junit.framework.TestCase; - -import java.math.BigInteger; - -import javax.crypto.interfaces.PBEKey; - - -/** - * Tests for PBEKey class field - * - */ -@TestTargetClass(PBEKey.class) -public class PBEKeyTest extends TestCase { - - - /** - * Test for serialVersionUID field - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "tests serialVersionUID for a fixed value", - method = "!field:serialVersionUID" - ) - public void testField() { - checkPBEKey key = new checkPBEKey(); - assertEquals("Incorrect serialVersionUID", - key.getSerVerUID(), //PBEKey.serialVersionUID - -1430015993304333921L); - } - -@TestTargetNew( - level = TestLevel.COMPLETE, - method = "getIterationCount", - args = {} - ) - public void test_getIterationCount() throws Exception { - checkPBEKey key = new checkPBEKey(); - - key.getIterationCount(); - } - -@TestTargetNew( - level = TestLevel.COMPLETE, - method = "getPassword", - args = {} - ) - public void test_getPassword() throws Exception { - checkPBEKey key = new checkPBEKey(); - - key.getPassword(); - } - -@TestTargetNew( - level = TestLevel.COMPLETE, - method = "getSalt", - args = {} - ) - public void test_getSalt() throws Exception { - checkPBEKey key = new checkPBEKey(); - - key.getSalt(); - } - - public class checkPBEKey implements PBEKey { - public String getAlgorithm() { - return "SecretKey"; - } - public String getFormat() { - return "Format"; - } - public byte[] getEncoded() { - return new byte[0]; - } - public long getSerVerUID() { - return serialVersionUID; - } - public BigInteger getY() { - return null; - } - public int getIterationCount() { - return 0; - } - public byte[] getSalt() { - return new byte[0]; - } - public char[] getPassword() { - return new char[0]; - } - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/AllTests.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/AllTests.java deleted file mode 100644 index 0be596e53..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/AllTests.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.crypto.tests.javax.crypto.serialization; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * This is autogenerated source file. Includes tests for package org.apache.harmony.crypto.tests.javax.crypto.serialization; - */ - -public class AllTests { - - public static void main(String[] args) { - junit.textui.TestRunner.run(AllTests.suite()); - } - - public static Test suite() { - TestSuite suite = tests.TestSuiteFactory.createTestSuite("All tests for package org.apache.harmony.crypto.tests.javax.crypto.serialization;"); - // $JUnit-BEGIN$ - - suite.addTestSuite(BadPaddingExceptionTest.class); - suite.addTestSuite(ExemptionMechanismExceptionTest.class); - suite.addTestSuite(IllegalBlockSizeExceptionTest.class); - suite.addTestSuite(NoSuchPaddingExceptionTest.class); - suite.addTestSuite(ShortBufferExceptionTest.class); - - // $JUnit-END$ - return suite; - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.java deleted file mode 100644 index 2f632aeb4..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto.serialization; - -import javax.crypto.BadPaddingException; - -import org.apache.harmony.testframework.serialization.SerializationTest; - - -/** - * Test for BadPaddingException serialization - * - */ - -public class BadPaddingExceptionTest extends SerializationTest { - - public static String[] msgs = { - "New message", - "Long message for Exception. Long message for Exception. Long message for Exception." }; - - protected Object[] getData() { - return new Object[] { new BadPaddingException(), - new BadPaddingException(null), new BadPaddingException(msgs[1]) }; - } - - public static void main(String[] args) { - junit.textui.TestRunner.run(BadPaddingExceptionTest.class); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.java deleted file mode 100644 index 7fd8cd016..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto.serialization; - -import javax.crypto.ExemptionMechanismException; - -import org.apache.harmony.testframework.serialization.SerializationTest; - - -/** - * Test for ExemptionMechanismException serialization - * - */ - -public class ExemptionMechanismExceptionTest extends SerializationTest { - - public static String[] msgs = { - "New message", - "Long message for Exception. Long message for Exception. Long message for Exception." }; - - protected Object[] getData() { - return new Object[] { new ExemptionMechanismException(), - new ExemptionMechanismException(null), new ExemptionMechanismException(msgs[1]) }; - } - - public static void main(String[] args) { - junit.textui.TestRunner.run(ExemptionMechanismExceptionTest.class); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.java deleted file mode 100644 index 2cc1daa30..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto.serialization; - -import javax.crypto.IllegalBlockSizeException; - -import org.apache.harmony.testframework.serialization.SerializationTest; - - -/** - * Test for IllegalBlockSizeException serialization - * - */ - -public class IllegalBlockSizeExceptionTest extends SerializationTest { - - public static String[] msgs = { - "New message", - "Long message for Exception. Long message for Exception. Long message for Exception." }; - - protected Object[] getData() { - return new Object[] { new IllegalBlockSizeException(), - new IllegalBlockSizeException(null), new IllegalBlockSizeException(msgs[1]) }; - } - - public static void main(String[] args) { - junit.textui.TestRunner.run(IllegalBlockSizeExceptionTest.class); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.java deleted file mode 100644 index 475bd2f2b..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto.serialization; - -import javax.crypto.NoSuchPaddingException; - -import org.apache.harmony.testframework.serialization.SerializationTest; - - -/** - * Test for NuSuchPaddingException serialization - * - */ - -public class NoSuchPaddingExceptionTest extends SerializationTest { - - public static String[] msgs = { - "New message", - "Long message for Exception. Long message for Exception. Long message for Exception." }; - - protected Object[] getData() { - return new Object[] { new NoSuchPaddingException(), - new NoSuchPaddingException(null), new NoSuchPaddingException(msgs[1]) }; - } - - public static void main(String[] args) { - junit.textui.TestRunner.run(NoSuchPaddingExceptionTest.class); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.java deleted file mode 100644 index ab696e829..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto.serialization; - -import javax.crypto.ShortBufferException; - -import org.apache.harmony.testframework.serialization.SerializationTest; - - -/** - * Test for ShortBufferException serialization - * - */ - -public class ShortBufferExceptionTest extends SerializationTest { - - public static String[] msgs = { - "New message", - "Long message for Exception. Long message for Exception. Long message for Exception." }; - - protected Object[] getData() { - return new Object[] { new ShortBufferException(), - new ShortBufferException(null), new ShortBufferException(msgs[1]) }; - } - - public static void main(String[] args) { - junit.textui.TestRunner.run(ShortBufferExceptionTest.class); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/AllTests.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/AllTests.java deleted file mode 100644 index d31dc5464..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/AllTests.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.crypto.tests.javax.crypto.spec; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * This is autogenerated source file. Includes tests for package org.apache.harmony.crypto.tests.javax.crypto.spec; - */ - -public class AllTests { - - public static void main(String[] args) { - junit.textui.TestRunner.run(AllTests.suite()); - } - - public static Test suite() { - TestSuite suite = tests.TestSuiteFactory.createTestSuite("All tests for package org.apache.harmony.crypto.tests.javax.crypto.spec;"); - // $JUnit-BEGIN$ - - suite.addTestSuite(DESKeySpecTest.class); - suite.addTestSuite(DESedeKeySpecTest.class); - suite.addTestSuite(DHGenParameterSpecTest.class); - suite.addTestSuite(DHParameterSpecTest.class); - suite.addTestSuite(DHPrivateKeySpecTest.class); - suite.addTestSuite(DHPublicKeySpecTest.class); - suite.addTestSuite(IvParameterSpecTest.class); - suite.addTestSuite(OAEPParameterSpecTest.class); - suite.addTestSuite(PBEKeySpecTest.class); - suite.addTestSuite(PBEParameterSpecTest.class); - suite.addTestSuite(PSourceTest.class); - suite.addTestSuite(RC2ParameterSpecTest.class); - suite.addTestSuite(RC5ParameterSpecTest.class); - suite.addTestSuite(SecretKeySpecTest.class); - - // $JUnit-END$ - return suite; - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESKeySpecTest.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESKeySpecTest.java deleted file mode 100644 index 9904eed7d..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESKeySpecTest.java +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** -* @author Alexander Y. Kleymenov -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.javax.crypto.spec; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.lang.NullPointerException; -import java.security.InvalidKeyException; -import java.util.Arrays; - -import javax.crypto.spec.DESKeySpec; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -@TestTargetClass(DESKeySpec.class) -/** - */ - -public class DESKeySpecTest extends TestCase { - - // DES weak and semi-weak keys - // Got from: - // FIP PUB 74 - // FEDERAL INFORMATION PROCESSING STANDARDS PUBLICATION 1981 - // GUIDELINES FOR IMPLEMENTING AND USING THE NBS DATA ENCRYPTION STANDARD - // http://www.dice.ucl.ac.be/crypto/standards/fips/fip74/fip74-1.pdf - private static final byte[][] semiweaks = { - {(byte) 0xE0, (byte) 0x01, (byte) 0xE0, (byte) 0x01, - (byte) 0xF1, (byte) 0x01, (byte) 0xF1, (byte) 0x01}, - - {(byte) 0x01, (byte) 0xE0, (byte) 0x01, (byte) 0xE0, - (byte) 0x01, (byte) 0xF1, (byte) 0x01, (byte) 0xF1}, - - {(byte) 0xFE, (byte) 0x1F, (byte) 0xFE, (byte) 0x1F, - (byte) 0xFE, (byte) 0x0E, (byte) 0xFE, (byte) 0x0E}, - - {(byte) 0x1F, (byte) 0xFE, (byte) 0x1F, (byte) 0xFE, - (byte) 0x0E, (byte) 0xFE, (byte) 0x0E, (byte) 0xFE}, - - {(byte) 0xE0, (byte) 0x1F, (byte) 0xE0, (byte) 0x1F, - (byte) 0xF1, (byte) 0x0E, (byte) 0xF1, (byte) 0x0E}, - - {(byte) 0x1F, (byte) 0xE0, (byte) 0x1F, (byte) 0xE0, - (byte) 0x0E, (byte) 0xF1, (byte) 0x0E, (byte) 0xF1}, - - {(byte) 0x01, (byte) 0xFE, (byte) 0x01, (byte) 0xFE, - (byte) 0x01, (byte) 0xFE, (byte) 0x01, (byte) 0xFE}, - - {(byte) 0xFE, (byte) 0x01, (byte) 0xFE, (byte) 0x01, - (byte) 0xFE, (byte) 0x01, (byte) 0xFE, (byte) 0x01}, - - {(byte) 0x01, (byte) 0x1F, (byte) 0x01, (byte) 0x1F, - (byte) 0x01, (byte) 0x0E, (byte) 0x01, (byte) 0x0E}, - - {(byte) 0x1F, (byte) 0x01, (byte) 0x1F, (byte) 0x01, - (byte) 0x0E, (byte) 0x01, (byte) 0x0E, (byte) 0x01}, - - {(byte) 0xE0, (byte) 0xFE, (byte) 0xE0, (byte) 0xFE, - (byte) 0xF1, (byte) 0xFE, (byte) 0xF1, (byte) 0xFE}, - - {(byte) 0xFE, (byte) 0xE0, (byte) 0xFE, (byte) 0xE0, - (byte) 0xFE, (byte) 0xF1, (byte) 0xFE, (byte) 0xF1}, - - {(byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, - (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01}, - - {(byte) 0xFE, (byte) 0xFE, (byte) 0xFE, (byte) 0xFE, - (byte) 0xFE, (byte) 0xFE, (byte) 0xFE, (byte) 0xFE}, - - {(byte) 0xE0, (byte) 0xE0, (byte) 0xE0, (byte) 0xE0, - (byte) 0xF1, (byte) 0xF1, (byte) 0xF1, (byte) 0xF1}, - - {(byte) 0x1F, (byte) 0x1F, (byte) 0x1F, (byte) 0x1F, - (byte) 0x0E, (byte) 0x0E, (byte) 0x0E, (byte) 0x0E}, - }; - - /* DES not weak or semi-weak keys */ - private static final byte[][] notsemiweaks = { - {(byte) 0x1f, (byte) 0x1f, (byte) 0x1f, (byte) 0x1f, - (byte) 0x1f, (byte) 0x1f, (byte) 0x1f, (byte) 0x1f}, - - {(byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, - (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0} - }; - /** - * Constructors testing. Tests behavior of each of two constructors - * in the cases of: null array, short array, normal array. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks both constructors.", - method = "DESKeySpec", - args = {byte[].class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Checks both constructors.", - method = "DESKeySpec", - args = {byte[].class, int.class} - ) - }) - public void testDESKeySpec() { - try { - new DESKeySpec((byte []) null); - fail("Should raise an NullPointerException " - + "in case of null byte array."); - } catch (NullPointerException e) { - } catch (InvalidKeyException e) { - fail("Should raise an NullPointerException " - + "in case of null byte array."); - } - try { - new DESKeySpec(new byte [] {1, 2, 3}); - fail("Should raise an InvalidKeyException on a short byte array."); - } catch (NullPointerException e) { - fail("Unexpected NullPointerException was thrown."); - } catch (InvalidKeyException e) { - } - try { - new DESKeySpec(new byte[] {1, 2, 3, 4, 5, 6, 7, 8}); - } catch (NullPointerException e) { - fail("Unexpected NullPointerException was thrown."); - } catch (InvalidKeyException e) { - fail("Unexpected InvalidKeyException was thrown."); - } - try { - new DESKeySpec((byte []) null, 1); - fail("Should raise an NullPointerException " - + "in case of null byte array."); - } catch (NullPointerException e) { - } catch (InvalidKeyException e) { - fail("Should raise an NullPointerException " - + "in case of null byte array."); - } - try { - new DESKeySpec(new byte [] {1, 2, 3, 4, 5, 6, 7, 8}, 1); - fail("Should raise an InvalidKeyException on a short byte array."); - } catch (NullPointerException e) { - fail("Unexpected NullPointerException was thrown."); - } catch (InvalidKeyException e) { - } - try { - new DESKeySpec(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9}, 1); - } catch (NullPointerException e) { - fail("Unexpected NullPointerException was thrown."); - } catch (InvalidKeyException e) { - fail("Unexpected InvalidKeyException was thrown."); - } - } - - /** - * getKey() method testing. Checks that modification of returned key - * does not affect the internal key. Also test check an equality of - * the key with the key specified in the constructor. The object under - * the test is created by different constructors. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getKey", - args = {} - ) - public void testGetKey() { - byte[] key = {1, 2, 3, 4, 5, 6, 7, 8}; - DESKeySpec ks; - try { - ks = new DESKeySpec(key); - } catch (InvalidKeyException e) { - fail("InvalidKeyException should not be thrown."); - return; - } - byte[] res = ks.getKey(); - assertTrue("The returned array should be equal to the specified " - + "in constructor.", Arrays.equals(key, res)); - res[0] += 1; - assertFalse("The modification of returned key should not affect" - + "the underlying key.", key[0] == res[0]); - - byte[] key1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; - try { - ks = new DESKeySpec(key1, 2); - } catch (InvalidKeyException e) { - fail("InvalidKeyException should not be thrown."); - return; - } - res = ks.getKey(); - assertNotSame("The returned array should not be the same object " - + "as specified in a constructor.", key1, res); - byte[] exp = new byte[8]; - System.arraycopy(key1, 2, exp, 0, 8); - assertTrue("The returned array should be equal to the specified " - + "in constructor.", Arrays.equals(exp, res)); - } - - /** - * isParityAdjusted(byte[] key, offset) method testing. Tests if the - * method throws appropriate exceptions on incorrect byte array, if - * it returns false on the key which is not parity adjusted, and if - * it returns true on parity adjusted key. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "isParityAdjusted", - args = {byte[].class, int.class} - ) - public void testIsParityAdjusted() { - try { - DESKeySpec.isParityAdjusted(null, 1); - fail("Should raise an InvalidKeyException " - + "in case of null byte array."); - } catch (NullPointerException e) { - fail("Unexpected NullPointerException was thrown."); - } catch (InvalidKeyException e) { - } - - byte[] key = {1, 2, 3, 4, 5, 6, 7, 8}; - try { - DESKeySpec.isParityAdjusted(key, 1); - fail("Should raise an InvalidKeyException " - + "in case of short byte array."); - } catch (NullPointerException e) { - fail("Unexpected NullPointerException was thrown."); - } catch (InvalidKeyException e) { - } - - byte[] key_not_pa = {1, 2, 3, 4, 5, 6, 7, 8}; - try { - assertFalse("Method returns true when false is expected.", - DESKeySpec.isParityAdjusted(key_not_pa, 0)); - } catch (NullPointerException e) { - fail("Unexpected NullPointerException was thrown."); - } catch (InvalidKeyException e) { - fail("Unexpected InvalidKeyException was thrown."); - } - - byte[] key_pa = {(byte) 128, (byte) 131, (byte) 133, (byte) 134, - (byte) 137, (byte) 138, (byte) 140, (byte) 143}; - try { - assertTrue("Method returns false when true is expected.", - DESKeySpec.isParityAdjusted(key_pa, 0)); - } catch (NullPointerException e) { - fail("Unexpected NullPointerException was thrown."); - } catch (InvalidKeyException e) { - fail("Unexpected InvalidKeyException was thrown."); - } - } - - /** - * isWeak(byte[] key, int offset) method testing. Tests if the - * method throws appropriate exceptions on incorrect byte array, if - * it returns true on weak or semi-weak keys, and if it returns - * false on other keys. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "isWeak", - args = {byte[].class, int.class} - ) - public void testIsWeak() { - try { - DESKeySpec.isWeak(null, 1); - fail("Should raise an InvalidKeyException " - + "in case of null byte array."); - } catch (NullPointerException e) { - fail("Unexpected NullPointerException was thrown."); - } catch (InvalidKeyException e) { - } - - byte[] key = {1, 2, 3, 4, 5, 6, 7, 8}; - try { - DESKeySpec.isWeak(key, 1); - fail("Should raise an InvalidKeyException " - + "in case of short byte array."); - } catch (NullPointerException e) { - fail("Unexpected NullPointerException was thrown."); - } catch (InvalidKeyException e) { - } - - for (int i=0; i validEPKIEncodings = new HashMap(); - - private static final HashMap validEPKIEncodingsNP = new HashMap(); - - private static final HashMap validAPEncodings = new HashMap(); - - static { - validEPKIEncodings.put("DH", dhEncryptedPrivateKeyInfo); - validEPKIEncodings.put("DIFFIEHELLMAN", dhEncryptedPrivateKeyInfo); - validEPKIEncodings.put("DIFFIE-HELLMAN", dhEncryptedPrivateKeyInfo); - validEPKIEncodings.put("1.2.840.113549.1.3.1", - dhEncryptedPrivateKeyInfo); - validEPKIEncodingsNP.put("DH", dhEncryptedPrivateKeyInfoNP); - validEPKIEncodingsNP.put("DIFFIEHELLMAN", dhEncryptedPrivateKeyInfoNP); - validEPKIEncodingsNP.put("DIFFIE-HELLMAN", dhEncryptedPrivateKeyInfoNP); - validEPKIEncodings.put("DSA", dsaEncryptedPrivateKeyInfo); - validEPKIEncodings.put("1.2.840.10040.4.1", dsaEncryptedPrivateKeyInfo); - validEPKIEncodingsNP.put("DIFFIE-HELLMAN", dhEncryptedPrivateKeyInfoNP); - validEPKIEncodingsNP.put("DSA", dsaEncryptedPrivateKeyInfoNP); - validAPEncodings.put("DH", dhParamsEncoded); - validAPEncodings.put("DIFFIEHELLMAN", dhParamsEncoded); - validAPEncodings.put("DIFFIE-HELLMAN", dhParamsEncoded); - validAPEncodings.put("1.2.840.113549.1.3.1", dhParamsEncoded); - validAPEncodings.put("DSA", dsaParamsEncoded); - validAPEncodings.put("1.2.840.10040.4.1", dsaParamsEncoded); - - encryptedData = new byte[1024]; - for (int i = 0; i < encryptedData.length; i++) { - encryptedData[i] = (byte) i; - } - } - - /** - * Algorithm_names/standard_names to be used in tests "DSA" and "DH" must be - * always presented - */ - public final static String[][] algName0 = new String[][] { - { "DSA", "DSA" }, - { "DH", "DiffieHellman", "Diffie-Hellman" }, - { "1.2.840.10040.4.1", "DSA" }, - { "1.2.840.113549.1.1.1", "RSA" }, - { "1.2.840.113549.1.3.1", "DiffieHellman" }, - { "1.2.840.113549.1.5.3", "pbeWithMD5AndDES-CBC" }, - { "1.2.840.113549.1.12.1.3", "pbeWithSHAAnd3-KeyTripleDES-CBC" }, - // {"1.2.840.113549.1.12.1.6", "pbeWithSHAAnd40BitRC2-CBC"}, - { "1.2.840.113549.3.2", "RC2-CBC" }, - { "1.2.840.113549.3.3", "RC2-EBC" }, - { "1.2.840.113549.3.4", "RC4" }, - { "1.2.840.113549.3.5", "RC4WithMAC" }, - { "1.2.840.113549.3.6", "DESx-CBC" }, - { "1.2.840.113549.3.7", "TripleDES-CBC" }, - { "1.2.840.113549.3.8", "rc5CBC" }, - { "1.2.840.113549.3.9", "RC5-CBC" }, - { "1.2.840.113549.3.10", "DESCDMF" }, }; - - /** - * Returns valid encoding of EncryptedPrivateKeyInfo However encoded private - * key field (encryptedData) does not contain valid encrypted data. - * - * @throws NoSuchAlgorithmException - */ - public static byte[] getValidEncryptedPrivateKeyInfoEncoding( - String algName, boolean includingAlgParameters) - throws NoSuchAlgorithmException { - String algNameUC = algName.toUpperCase(); - byte[] ret = includingAlgParameters ? validEPKIEncodings - .get(algNameUC) : validEPKIEncodingsNP.get(algNameUC); - if (ret != null) { - return ret.clone(); - } - throw new NoSuchAlgorithmException("No encoding available for " - + algName); - } - - public static byte[] getValidEncryptedPrivateKeyInfoEncoding(String algName) - throws NoSuchAlgorithmException { - return getValidEncryptedPrivateKeyInfoEncoding(algName, true); - } - - /** - * Returns valid encoding of EncryptedPrivateKeyInfo However encoded private - * key field (encryptedData) does not contain valid encrypted data. - * - * @throws NoSuchAlgorithmException - */ - public static byte[] getParametersEncoding(String algName) - throws NoSuchAlgorithmException { - String algNameUC = algName.toUpperCase(); - byte[] ret = validAPEncodings.get(algNameUC); - if (ret != null) { - return ret; - } - throw new NoSuchAlgorithmException("No AP encoding available for " - + algName); - } - -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyCipher.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyCipher.java deleted file mode 100644 index c9eb26e74..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyCipher.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** -* @author Boris V. Kuznetsov -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.support; - -import java.security.AlgorithmParameters; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.security.spec.AlgorithmParameterSpec; - -import javax.crypto.BadPaddingException; -import javax.crypto.CipherSpi; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.ShortBufferException; - -/** - * - * Cipher implementation for testing - */ -public class MyCipher extends CipherSpi { - - public MyCipher() { - super(); - } - - @Override - protected void engineSetMode(String mode) throws NoSuchAlgorithmException { - } - - @Override - protected void engineSetPadding(String padding) - throws NoSuchPaddingException { - if (!"PKCS5Padding".equals(padding)) { - throw new NoSuchPaddingException(padding); - } - } - - @Override - protected int engineGetBlockSize() { - return 111; - } - - @Override - protected int engineGetOutputSize(int inputLen) { - return inputLen + 10; - } - - @Override - protected byte[] engineGetIV() { - byte[] b = {1,2,3}; - return b; - } - - @Override - protected AlgorithmParameters engineGetParameters() { - return null; - } - - @Override - protected void engineInit(int opmode, Key key, SecureRandom random) - throws InvalidKeyException { - } - - @Override - protected void engineInit(int opmode, Key key, - AlgorithmParameterSpec params, SecureRandom random) - throws InvalidKeyException, InvalidAlgorithmParameterException { - } - - @Override - protected void engineInit(int opmode, Key key, AlgorithmParameters params, - SecureRandom random) throws InvalidKeyException, - InvalidAlgorithmParameterException { - } - - @Override - protected byte[] engineUpdate(byte[] input, int inputOffset, int inputLen) { - return null; - } - - @Override - protected int engineUpdate(byte[] input, int inputOffset, int inputLen, - byte[] output, int outputOffset) throws ShortBufferException { - return 0; - } - - @Override - protected byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen) - throws IllegalBlockSizeException, BadPaddingException { - return null; - } - - @Override - protected int engineDoFinal(byte[] input, int inputOffset, int inputLen, - byte[] output, int outputOffset) throws ShortBufferException, - IllegalBlockSizeException, BadPaddingException { - return 0; - } - -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyExemptionMechanismSpi.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyExemptionMechanismSpi.java deleted file mode 100644 index ddd6f2690..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyExemptionMechanismSpi.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.support; - -import java.security.AlgorithmParameters; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.spec.AlgorithmParameterSpec; - -import javax.crypto.ExemptionMechanismException; -import javax.crypto.ExemptionMechanismSpi; -import javax.crypto.ShortBufferException; - -/** - * Additional class for verification ExemptionMechanismSpi - * and ExemptionMechanism classes - * - */ - -public class MyExemptionMechanismSpi extends ExemptionMechanismSpi { - - private static final int byteArrayLength = 5; - - public static final int getLength() { - return byteArrayLength; - } - @Override - protected byte[] engineGenExemptionBlob() - throws ExemptionMechanismException { - return new byte[byteArrayLength]; - } - - @Override - protected int engineGenExemptionBlob(byte[] output, int outputOffset) - throws ShortBufferException, ExemptionMechanismException { - return byteArrayLength; - } - - @Override - protected int engineGetOutputSize(int inputLen) { - return 10; - } - - @Override - protected void engineInit(Key key) throws InvalidKeyException, - ExemptionMechanismException { - if (key == null) { - throw new InvalidKeyException("key is null"); - } - if (!(key instanceof tmpKey)) { - throw new ExemptionMechanismException("Incorrect key"); - } - } - - @Override - protected void engineInit(Key key, AlgorithmParameters params) - throws InvalidKeyException, InvalidAlgorithmParameterException, - ExemptionMechanismException { - if (key == null) { - throw new InvalidKeyException("key is null"); - } - if (!(key instanceof tmpKey)) { - throw new ExemptionMechanismException("Incorrect key"); - } - if (params == null) { - throw new InvalidAlgorithmParameterException("params is null"); - } - } - - @Override - protected void engineInit(Key key, AlgorithmParameterSpec params) - throws InvalidKeyException, InvalidAlgorithmParameterException, - ExemptionMechanismException { - if (key == null) { - throw new InvalidKeyException("key is null"); - } - if (!(key instanceof tmpKey)) { - throw new ExemptionMechanismException("Incorrect key"); - } - if (params == null) { - throw new InvalidAlgorithmParameterException("params is null"); - } - } - - @SuppressWarnings("serial") - public class tmpKey implements Key { - private String alg; - private byte[] enc; - public tmpKey(String alg, byte[] enc) { - this.alg = alg; - this.enc = enc; - } - public String getFormat() { - return "tmpKey"; - } - public String getAlgorithm() { - return alg; - } - public byte[] getEncoded() { - return enc; - } - } - @SuppressWarnings("serial") - public class tmp1Key implements Key { - private byte[] enc; - public tmp1Key(String alg, byte[] enc) { - this.enc = enc; - } - public String getAlgorithm() { - return "tmp1Key"; - } - public String getFormat() { - return "tmp1Key"; - } - public byte[] getEncoded() { - return enc; - } - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyKeyAgreementSpi.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyKeyAgreementSpi.java deleted file mode 100644 index 51e541afe..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyKeyAgreementSpi.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.support; - -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.security.spec.AlgorithmParameterSpec; - -import javax.crypto.KeyAgreementSpi; -import javax.crypto.SecretKey; -import javax.crypto.ShortBufferException; - -/** - * Additional class for verification of KeyAgreementSpi - * and KeyAgreement functionality - * - */ - -public class MyKeyAgreementSpi extends KeyAgreementSpi { - - @Override - protected Key engineDoPhase(Key key, boolean lastPhase) - throws InvalidKeyException, IllegalStateException { - if (!lastPhase) { - throw new IllegalStateException("last Phase is false"); - } - return null; - } - - @Override - protected byte[] engineGenerateSecret() throws IllegalStateException { - return new byte[0]; - } - - @Override - protected int engineGenerateSecret(byte[] sharedSecret, int offset) - throws IllegalStateException, ShortBufferException { - return -1; - } - - @Override - protected SecretKey engineGenerateSecret(String algorithm) - throws IllegalStateException, NoSuchAlgorithmException, - InvalidKeyException { - if (algorithm.length() == 0) { - throw new NoSuchAlgorithmException("Algorithm is empty"); - } - return null; - } - - @Override - protected void engineInit(Key key, SecureRandom random) - throws InvalidKeyException { - throw new IllegalArgumentException("Invalid parameter"); - } - - @Override - protected void engineInit(Key key, AlgorithmParameterSpec params, - SecureRandom random) throws InvalidKeyException, - InvalidAlgorithmParameterException { - throw new IllegalArgumentException("Invalid parameter"); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyKeyGeneratorSpi.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyKeyGeneratorSpi.java deleted file mode 100644 index 86b21c21f..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyKeyGeneratorSpi.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.support; - -import java.security.InvalidAlgorithmParameterException; -import java.security.SecureRandom; -import java.security.spec.AlgorithmParameterSpec; - -import javax.crypto.KeyGeneratorSpi; -import javax.crypto.SecretKey; - -/** - * Additional class for verification of - * KeyGeneratorSpi and KeyGenerator functionality - * - */ - -public class MyKeyGeneratorSpi extends KeyGeneratorSpi { - - @Override - protected SecretKey engineGenerateKey() { - return null; - } - - @Override - protected void engineInit(AlgorithmParameterSpec params, SecureRandom random) - throws InvalidAlgorithmParameterException { - if (params == null) { - throw new InvalidAlgorithmParameterException("params is null"); - } - } - - @Override - protected void engineInit(int keysize, SecureRandom random) { - if (keysize <= 77) { - throw new IllegalArgumentException("Invalid keysize"); - } - } - - @Override - protected void engineInit(SecureRandom random) { - throw new IllegalArgumentException("Invalid random"); - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyMacSpi.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyMacSpi.java deleted file mode 100644 index 8913c2e62..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MyMacSpi.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.support; - -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.spec.AlgorithmParameterSpec; - -import javax.crypto.MacSpi; -import javax.crypto.spec.SecretKeySpec; - -/** - * Additional class for verification of MacGeneratorSpi and MacSpi - * - */ - -public class MyMacSpi extends MacSpi { - - private int length = 0; - @Override - protected int engineGetMacLength() { - return length; - } - - @Override - protected void engineInit(Key key, AlgorithmParameterSpec params) - throws InvalidKeyException, InvalidAlgorithmParameterException { - if (params == null) { - if (!(key instanceof SecretKeySpec)) { - throw new IllegalArgumentException("params is null and key is SecretKeySpec"); - } - } - } - - @Override - protected void engineUpdate(byte input) { - } - - @Override - protected void engineUpdate(byte[] input, int offset, int len) { - if (offset >= 0 && len >= 0) { - length = len; - } - } - - @Override - protected byte[] engineDoFinal() { - return new byte[length]; - } - - @Override - protected void engineReset() { - length++; - } -} diff --git a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MySecretKeyFactorySpi.java b/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MySecretKeyFactorySpi.java deleted file mode 100644 index 0dbff5d9e..000000000 --- a/libcore/crypto/src/test/java/org/apache/harmony/crypto/tests/support/MySecretKeyFactorySpi.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.crypto.tests.support; - -import java.security.InvalidKeyException; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.KeySpec; - -import javax.crypto.SecretKey; -import javax.crypto.SecretKeyFactorySpi; - -/** - * Additional class for verification of SecretKeyFactorySpi - * and SecretKeyFactory functionality - * - */ - -public class MySecretKeyFactorySpi extends SecretKeyFactorySpi { - @Override - protected SecretKey engineGenerateSecret(KeySpec keySpec) - throws InvalidKeySpecException { - return null; - } - - @SuppressWarnings("unchecked") - @Override - protected KeySpec engineGetKeySpec(SecretKey key, Class keySpec) - throws InvalidKeySpecException { - return null; - } - - @Override - protected SecretKey engineTranslateKey(SecretKey key) - throws InvalidKeyException { - return null; - } -} diff --git a/libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.0.ser b/libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.0.ser deleted file mode 100644 index a7d633312d6042b26e09495e2496e4759c333b09..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1388 zcmZ4UmVvdnh(RGMu`IDdFS)3)pd??9rA3(~m3r=}d8tK-Il)jqToX^$H?>V0M3+J|34=A|B<7{-!Bt%N zD{m)dEpr4zMMy?betBY2PU_WTrs|gEJ5Dn*F#9mDCMT8_r7F!KtDGBEpbUKNh}5h9v1@xLuUztVRC-1UVcGpUS?iNYK~q?Q4S*gl%y7y=mjHN4Kl2R zK@39-YJpHeQGQBka;kfNPD*N?TV_sbG2AYDkfp+SG_x0#<~b!6rNVV&l`zO;mF8uZ z=%p1U=BAeC7iH^#91xURT$)p&Vpzh!kKjUGz+O<4Uy_Y0m5^We(LN*E-tS?8Px${)NS_kx&E*P>{>P{JUIO>1yzW=U!Z z10P5)m<`no3NMft-0ssLCu(9*iDFGj34=Jqnv&FtlG02_ke24It7z~I|=mByJR)r|8u_R8JI{pmdn3DrZlJEiy955veGB{+Qo@2>P%*?9*0OJAF A0{{R3 diff --git a/libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.1.ser b/libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.1.ser deleted file mode 100644 index 447c1f47db054429ef2bb898ca4d772e4630df2e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1388 zcmZ4UmVvdnh(RGMu`IDdFS)3)pd??9rA3(~m3r=}d8tK-Il)jqToX^$H?>V0M3+J|34=A|B<7{-!Bt%N zD{m)dEpr4zMMy?betBY2PU_WTrs|gEJ5Dn*F#9mDCMT8_r7F!KtDGBEpbUKNh}5h9v1@xLuUztVRC-1UVcGpUS?iNYK~q?Q4S*gl%y7y=mjHN4Kl2R zK@39-YJpHeQGQBka;kfNPD*N?TV_sbG2AYDkfp+SG_x0#<~b!6rNVV&l`zO;mF8uZ z=%p1U=BAeC7iH^#91xURT$)p&Vpzh!kKjUGz+O<4Uy_Y0m5^We(LN*E-tS?8Px${)NS_kx&E*P>{>P{JUIO>1yzW=U!Z z10P5)m<`no3NMft-0ssLCu(9*iDFGj34=Jqnv&FtlG02_ke24It7z~I|=mByJR)r|8u_R8JI{pmdn3DrZlJEiy955veGB{+Qo@2>P%*?9*0OoJh A1ONa4 diff --git a/libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.2.ser b/libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.golden.2.ser deleted file mode 100644 index ae028bdab607338357b492c84774dd2f921adcff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1473 zcmZ4UmVvdnh(RGMu`IDdFS)3)pd??9rA3(~m3r=}d8tK-Il)jqToX^$H?>V0M3+J|34=A|B<7{-!Bt%N zD{m)dEpr4zMMy?betBY2PU_WTrs|gEJ5Dn*F#9mDCMT8_r|A=oEBFI^!QVz5G5evty)4|)n@%9R$utk(niL@yZbE|~R9Zdx`r zf0Zmj!BfD%z`$2r#2^jwIt~qqoJVJ=ncZz=Vqo!P;L6F&OZ6+wO-e2DVc<(iP0mRK zg@AKTVsSCnpz&egNXyJg^-Ijf9&|noT)C+w8TlzVRaAf+sZ_#X1ac!hITfcCWhUli zRwaTG61Kz@l3H9+!XSes*@0yAK!%ktu&1Y%xFnV&7K37hn}LC$vxLDgIX_n~zaTX) zGp{5yM=zx)2azaCQj1IUf|0ET8CJp|h9L&EK&YT7KczG|)jdBaB{k12GbgneZkIjC zQV~3w*^5f^oDz#t;X1NP7-X_a^D;~H(uxvuQ_J& zFDS|{Nlh++8&XrkAcflyY)0@DmF5LNOi4|Fo0AK2zC1Sd%tfVnaAjpB3=-I^b4~Rt&o?zWBQY%moA_$zNGWi4|ALq$kNQGR)1QcmjCW2Wks6fiI_@D&#^NP}F7 zLqj6x(OGI{cUzelSUefHax(K${YrC_Qj2^T_)=1na}q(0brH7Ez;*t^u6+9^h zq(Tp5cnJf0dTNPFVo72#C@{Gg7#KQB7z~s1bM^8IQu8wNN>X$5Qi^gA>8T{OxI`}) z*(o5yN*Kg2#Gn=k6%^&ClqRRT=jWuP=DB6&q!z>NvIkizj7KwjQE8r2Vo@qwM^*`g zOjc=LW{F-}QDSatd45s09>@Vfsl}x^B`Ss`4EzW#)CKGXMfoME$t7?@YDyTSa2tZn z2%e(Sya0$PsVQ)CazW0Q!=|3Os5B3*tgM7V0-JTtiJ<(#3vw@r33V-s)(a&JlGwBc zmu8lvmN4*v^n%$?&7klCiNWnY4RWF;7L_R0l$0=tL#!!DttctYgam16US4Vu%y(c8 z)E3s1{2(O%frG(-2!$RX$6!^6;u=fhlxdVO7=h9-jtt_MlLJYT@B$4SFeMB!IAoxn LW64d-%&PzZeo5bG diff --git a/libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.golden.1.ser b/libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.golden.1.ser deleted file mode 100644 index 58b303fe550bff83ca4c252ee6a83144d0f3f6f2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1412 zcmZ4UmVvdnh(RMOu`IDdFS)3)pd??Rt&o?zWBQY%moA_$zNGWi4|ALq$kNQGR)1QcmjCW2Wks6fiI_@D&#^NP}F7 zLqj6x(OGI{cUzelSUefHax(K${YrC_Qj2^T_)=1na}q(0brH7Ez;*t^u6+9^h zq(Tp5cnJf0dTNPFVo72#C@{Gg7#KQB7z~s1bM^8IQu8wNN>X$5Qi^gA>8T{OxI`}) z*(o5yN*Kg2#Gn=k6%^&ClqRRT=jWuP=DB6&q!z>NvIkizj7KwjQE8r2Vo@qwM^*`g zOjc=LW{F-}QDSatd45s09>@Vfsl}x^B`Ss`4EzW#)CKGXMfoME$t7?@YDyTSa2tZn z2%e(Sya0$PsVQ)CazW0Q!=|3Os5B3*tgM7V0-JTtiJ<(#3vw@r33V-s)(a&JlGwBc zmu8lvmN4*v^n%$?&7klCiNWnY4RWF;7L_R0l$0=tL#!!DttctYgam16US4Vu%y(c8 z)E3s1{2(O%frG(-2!$RX$6!^6;u=fhlxdVO7=h9-jtt_MlLJYT@B$4SFeMB!IAoxn LW64d-%&PzZfyduz diff --git a/libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.golden.2.ser b/libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.golden.2.ser deleted file mode 100644 index ee41ad6a6dd1480423b9cafd6a40bdc1031d123c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1497 zcmZ4UmVvdnh(RMOu`IDdFS)3)pd??Rt&o?zWBQY%moA_$zNGWi4|ALq$kNQGR)1QcmjCW2WksHh+~YLBUhNz`(#)T*M#^@;VL;iJV7gshQnvWny6QWZ=rl%uDqv%}q)z@?qdh zNlng41ciWePGWH})}ZlW;7H5NN%c$2#U6A%3|zUXB^miCI8{`D9H~^oUBEpbUKNh}7%5H|w@LuUztVRC-1 zUVcGpUS?iNYK~q?Q4S)JmZTP!=mjG?1!PzWgBXSw)B>S`qWqN7 zVz^!QAWKE?Xl5@e&2vgDN`>plDq)bxD$UC*(Mu~z%uOxNFUr;fIUp#txHP9k#ju2d zAHjvXfW4q7za%xe1a3%834;`FL$DdaQ&gH405K&s1#V6*$ocZv)H4^A=E0Sfl`u$P zv(7mYlnHr3?gcTSu0_#$p@cyao7Ujc%#zd+20oBpFdM2F6kZ@PxZS5gPSnDp62+R5 z5(aUIH6^JPC8e2=AT7Rt@5!!o zlYYNVH<%b0DxjM5ic^zIi!w_p_1shQQi~FEf}wo4CZ4QsYMVBQE`?|k2HB*SlbDyT z2Ul_7ue_aNoO!0f}onw(f#oLa&l>H{)MA7qw3 zT&1-S18+)dNn&P>Z)$OIVtQ%`gAkIs;F6-uymaem2Cm|g#N_OdqQvCX5(c?w6eTbT z*PPVc)Vvbwih@FhItKQF(ju5jhzEkfq}2Mh(Q|UN*o#z zIgid#GrQZ$#K7Xoz?GAkm+DuVo0MAQ!@!r4nw*mea;$SsVsSB6U-&R^q-Ex$`X%OK z_oWX5S8i%aMt%xT6%`;yDwZ%m&2x>xu`S`uB@ztK?0j~&WWJB!V7XQhzWHqiq;Dy43gNi2A5`* zq?R!7f%JmeP|cw50*S%xJ`HlBCKi<_)|8Ymh(oL?Nv$X;&4dJLX8th|AB+SfCz;iAje=;h~gSc;*@EYFc^W-FpkXOn3DrZlJLR|955veGB{+Qo@2>P I%*?9*0EhhCW&i*H diff --git a/libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.golden.1.ser b/libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.golden.1.ser deleted file mode 100644 index a69ae56f5ccab3fcc5f2cd0befaee7e537be89a2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1406 zcmZ4UmVvdnh(RqYu`IDdFS)3)pd??Rt@5!!o zlYYNVH<%b0DxjM5ic^zIi!w_p_1shQQi~FEf}wo4CZ4QsYMVBQE`?|k2HB*SlbDyT z2Ul_7ue_aNoO!0f}onw(f#oLa&l>H{)MA7qw3 zT&1-S18+)dNn&P>Z)$OIVtQ%`gAkIs;F6-uymaem2Cm|g#N_OdqQvCX5(c?w6eTbT z*PPVc)Vvbwih@FhItKQF(ju5jhzEkfq}2Mh(Q|UN*o#z zIgid#GrQZ$#K7Xoz?GAkm+DuVo0MAQ!@!r4nw*mea;$SsVsSB6U-&R^q-Ex$`X%OK z_oWX5S8i%aMt%xT6%`;yDwQx;fZPa=|Kil5%*33`szgwn<4z4Bsl_EF3`#gt3rJoM zWN--sdwOb#OJYf4F(@Fp7#J8jOBf83^Km&2x>xu`S`uB@ztK?0j~&WWJB!V7XQhzWHqiq;Dy43gNi2A5`* zq?R!7f%JmeP|cw50*S%xJ`HlBCKi<_)|8Ymh(oL?Nv$X;&4dJLX8th|AB+SfCz;iAje=;h~gSc;*@EYFc^W-FpkXOn3DrZlJLR|955veGB{+Qo@2>P I%*?9*0E>3qX8-^I diff --git a/libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.golden.2.ser b/libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.golden.2.ser deleted file mode 100644 index f23826c4f93281154edaa6885d27c9c3a6d3de32..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1491 zcmZ4UmVvdnh(RqYu`IDdFS)3)pd??Rt@5!!o zlYYNVH<%b0DxjM5ic^zIi!w_p_1shQQi~FEf}wo4CZ4QsYMVBQE`?|k2HB*SlbDyT z2Ul_7ue_aNoO!0f}onw(f#oLa&l>H{)MA7qw3 zT&1-S18+)dNn&P>Z)$OIVtQ%`gAkIs;F6-uymaem2Cm|g#N_OdqQvCX5(c?w6eTbT z*PPVc)Vvbwih@FhItKOo5 zva$KAWC;qM0tN;KzTzSVX^_`(Xh`HdI!n#$ZYvW5izfqDPG(-JUukYqYLO2EUrK6n zP9i7-oO2S3i?Ifc4+BS9W=^VKVlMWe^I_o1O)bgDPr<380^~@g5(W#98{vtnIJGD< zF(T%s3@>H_wHqWqH7xB{qNo-n!OEXJSOBnb-dcka{W>9#6#Nc+H202j+i%Jx0N=g{S zA=Z?nR+N-xLV~n3FE6zS<~uM4Y71*heh`xXz`+0yc{~a|K#swx5XCi?#3|D(VK4%v gVH}ymF((I-B;lnCIABT`WN^qpJ;#!pn3-1r0BR}v`~Uy| diff --git a/libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.golden.0.ser b/libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.golden.0.ser deleted file mode 100644 index 0cdc09d95bfac085e1e354e8ec2a7a975044080f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1397 zcmZ4UmVvdnh(S3ku`IDdFS)3)pd??2O=bH_ z%ce0gFjN#VsDX6o6{jYb7G;)H>ba-pr4}XT1Vj07O*~oO)HZDpT?)}84AzvBn3t{x zS8?I5yq%P_%n=L~AsI#a<%vl-saKDgs#})tIL*w!?8CsCoLE|%TEZae12Rh=WR^Z$ zrL_+OZ%S%OVrGtSYH@L5dTI%S5R$s!lA_GKbn9pauHur!q36&T%A#kksOm5(atf=>#OH z2QspRfjvF7#3ivLu^1GDTnr2hoh1y0$@#f@`30$YnRz9tIeIBYIfztLl3HA%7mVxx zkYObZVi;mj3xo=a@>5EaQ{D4(Qd0BWGILUk;da@BEEUG1nZ2kq&ndAe6|N(zgh3{& zG%vG6FRdssH?=&!C|eKYfS}ak(wq_%!x9F51Q+T8_JX4PlGNl9xFIzq3{toa!Da+c zQE6TP#FW$&xH-8X=gVPJ&s2O=bH_ z%ce0gFjN#VsDX6o6{jYb7G;)H>ba-pr4}XT1Vj07O*~oO)HZDpT?)}84AzvBn3t{x zS8?I5yq%P_%n=L~AsI#a<%vl-saKDgs#})tIL*w!?8CsCoLE|%TEZae12Rh=WR^Z$ zrL_+OZ%S%OVrGtSYH@L5dTI%S5R$s!lA_GKbn9pauHur!q36&T%A#kksOm5(atf=>#OH z2QspRfjvF7#3ivLu^1GDTnr2hoh1y0$@#f@`30$YnRz9tIeIBYIfztLl3HA%7mVxx zkYObZVi;mj3xo=a@>5EaQ{D4(Qd0BWGILUk;da@BEEUG1nZ2kq&ndAe6|N(zgh3{& zG%vG6FRdssH?=&!C|eKYfS}ak(wq_%!x9F51Q+T8_JX4PlGNl9xFIzq3{toa!Da+c zQE6TP#FW$&xH-8X=gVPJ&s2O=bH_ z%ce0gFjN#VsDX6o6{jYb7G;)H>ba-pr4}XT1Vj07O*~oO)HZDpT?)}84AzvBn3t{x zS8?I5yq%P_%n=L~AsI#a<%vl-saKDgs#})tIL*w!?8CsCoLE|%TEZae12Rh=WR^Z$ zrL_+OZ%S%OVrGtSYH@L5dTI%S5R$s!lA_GKbn9pauHur!0YH>*kgFN=c2a?nS8Ck->o}OCbl30>h42lsd;XhIjO~P zyX--hir~@AUR0XrlvtDs*O67iAd^*^msz5hR+N~VTAp8&tp{>IP-<~$PKk}QY%VIGa*4*nwOVa1oIu31GR-UB|iwsf8bz%hddsI9w5hHRfysmOX8Gil`t5A h(lCx};h2*HNs{n#1spIX3^F)mpq^vNP0Y-z004+v_d5Up diff --git a/libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.golden.0.ser b/libcore/crypto/src/test/java/serialization/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.golden.0.ser deleted file mode 100644 index 1f8e55f9562c95d2844d61414ad0480555605d29..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1391 zcmZ4UmVvdnh(R$cu`IDdFS)3)pd?=}I3vHP#HlnbEw#wCB0067Br`v+%moA z_$zNGWi4|ALq$kNQGR)1QcmjCW2Wks6fiI_@D&#^NP}F7Lqj6x z(OGI{cUzelSUefHax(K${YrC_Qj2^T_)=1na}q(0bN>L6X1(l>0m*@o}TMja; zgh32L3~GT;K~a86X>zK2eojhio?B*4YBAg{dyu8Vcr>#YmF77m7Nx>P+ zmguDwCFZ7<=NDz`fgBK&T3nh_qGDLWz>nZUUBF&YlwXpXTmmm+iA`&8X=X`k z2?HNUFPIJ03<@uh7~JmDASY^KQHf$rNeP2E#F~=SijvYyNRXE1<)s$Ed%moA z_$zNGWi4|ALq$kNQGR)1QcmjCW2Wks6fiI_@D&#^NP}F7Lqj6x z(OGI{cUzelSUefHax(K${YrC_Qj2^T_)=1na}q(0bN>L6X1(l>0m*@o}TMja; zgh32L3~GT;K~a86X>zK2eojhio?B*4YBAg{dyu8Vcr>#YmF77m7Nx>P+ zmguDwCFZ7<=NDz`fgBK&T3nh_qGDLWz>nZUUBF&YlwXpXTmmm+iA`&8X=X`k z2?HNUFPIJ03<@uh7~JmDASY^KQHf$rNeP2E#F~=SijvYyNRXE1<)s$Ed%moA z_$zNGWi4|ALq$kNQGR)1QcmjCW2Wks zHh+~YLBUhNz`(#)T*M#^@;VL;iJV7gshQnvWny6QWZ=rl%uDqv%}q)z@?qdhNlng4 z1ciWePGWH})}ZlW;7H5NN%c$2#U6A%3|zUXB^miCI8{`D9H~^oU<`62JUtbs7G);p zWL71D5)#(b6_Q$9Qo3>gqwkZp|ga+FgZV0FTWr) zFEg(sHAgR{CE-M- z)0TKVTrU}^!gO{ n?o9q|hT@8%Nv9l}T;6T|cCpv)TbWS^+xK6ucLw_HGSdP80FOl0 diff --git a/libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test2.iv b/libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test2.iv deleted file mode 100644 index 72660fc6b..000000000 --- a/libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test2.iv +++ /dev/null @@ -1 +0,0 @@ -@ö"З< \ No newline at end of file diff --git a/libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test2.key b/libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test2.key deleted file mode 100644 index 9876f3f9c..000000000 --- a/libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test2.key +++ /dev/null @@ -1 +0,0 @@ -q’<»Å(GåâÁΡԑ€Iž:Æá¹' \ No newline at end of file diff --git a/libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test2.plaintext b/libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test2.plaintext deleted file mode 100644 index 1b5ef4a4edf10c820353702b09f0c8748d1b1d6a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 126 zcmaF6%SyUabn)jPztWYK-1k0N9OZqxd@kd1A20T}vs&}B6h0Pxa9HZdU}2gS+5cL4 zy~iapy)Ch6>rXWX?T_g3V7m8b;ttC%G83(qFgBHK@U^(HzlTd~>AvN?N839bJ66lC j?yKyStXdhSKWmkf;C5DHhy23_Rn<4W-`U2+Ew2p#qBc3C diff --git a/libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test3.ciphertext b/libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test3.ciphertext deleted file mode 100644 index b9dd600a71ffeabc1f6b948fb6a6903fd96dd1ff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10008 zcmZ=(d%gV2d+i-5$-mZ3Jz1`QB$IDpa7TmhYKNG{IyKYx>I-b;9trXJ7~IY^7Gu26 zHK(lG@5Vbu=P!ADk=5H9?pXZ#WWVoipoxH%xYfkg=xsJ5OkdJUU}( z;lAqJf_n#^%#rQ=+;_TvpY(*Bt#ze8-^Hc(J3XJw_VuR4kv#Fczh224t6cfxsM7M} z-ZgR(Pc9ehRGY8RU6H=0MeCD~_{SzfZBUY+mzp*z3B)&!iK@Y3$? zqu}?`%ZiN@4o4oU2o%Uk&^C1CI3BU|pPG15%wNf8%5N`Ea=+j4%!@NR%9pKQr1SN` zx6A$ah(7!9+4POMwcSY**KiLGrUE4GWxcjW zh_LzmaBX8tl&iv&BY_EtTRqn+ZT)(=#P(2|g2%&J_657_eB2nnoITUG@QHD0Ogn{8%t=ACJva;lIwc4hQl!=I7X- znOGDt zlybUm;l(_+`U|V{1>+vp**#5qDDFOS^^G2p>w%M$A{PC7aJ2FAHaEs(UE#Yw!|P(A ze;XeT%D5iqT0N7&K{f4Fu`82IOv9=_r?QNy{|cIx&9r~vcPJ!tMnx*?_CTh@h8}gb zC>DN&sq@n!H@;o|?B}F*)guD4`Hy*+21d+u+btpZ_L94a{k@&Fhs?MiCF&c*zEFq` zIcLjK_Tfx)hGJRdGsOh^`^%y)^@#gC<-Pc}bHRpHetUlWOP$oCI{&YglyG-zb>tDF z4oIB|n;Qp6dAff7QiJrYEJ0OdmAtxXaAl_3N6i zrf)=1>a46K;SOCk(*NG_>#e5_yi+)4)C16p7p0$%lfqMzR5b)MJpPr7uuU?aEqpBPfYU<@H|ubc=zc`zsBzY!Qjs4tRiK?mP zs*4~0uRZOp;P7Pw*U7nFrc+fvmNhk2*==gDXzsoJi&Z0ZUtjjB4r|9n2HPuKTpYj6 znBBUDPpvEU(PXP1=6viM1yi=#sU9;<-zOa2ow&;Fn_ZGibmg50r&Cg98`%pwHsz`p z%$hAa^5nmsDVYuk{wY; z=lkzTs<5bIoO@6{m04lNR_3{DUd+8SrL#LP=U~l}`rui=>YseNpk42K&1AX7lSNmj zRNZ>^-Z5^u0@tHewyr;`*+cg|+&oKz@11)6|2NrE+SWoh*?VXBZnAcjY2R@;Id7fe zGy6}1JC5%OjG8g+VBWF7b>9yLRr+5EJtcMXiptjJ2$`Z~2hOeech$|oKl;JeEetmo zr#4)?mk^%Q`hjP8;yXogme}Odn!rG9&lH7(`)gI4-~2s3;qOIzg;i$ux4zWQGYg7K z6W*zxF_~lXo2ki#InK}Jz1njZ?U73;XIm=37C1%qu_7ABDTz)YNXLvo$U85B?an+F!;pIjQaSz2eyy(>C(7OtG;J z6;Cmne6*Nf&E7UQSMp_Ld}M#C^NZuF4lfEx5MguMW5A&lp89y>JAq^KEu!Y!;3``8}o`}@6CU5=R4cwmm3vtHgs#T ze`%DMCh+KI=#I)cY=TiA&t(-Bw4MJEf1^wOiSdo#V^h=@3MzeG+C`1@Mzb0VAL1j`q8ShyIv&R8gZ zEqY%4+3z=&{h4piRY%a#56LCLI154j!8BANV($E5EI%Jbd{|Q@^^r-N{zdM=3(e{_ExU zwJRRj(tKjY8NthEFGS|;`(t%vrI|<2j1@~I=L<_Sl^>qRy`;Oc<;X`DA-$p%XTEt_ zPs{ip@S0^7ud%nO_Msb~+!W2}rGYw#MDmdfD{f7au>fSueIrWUFuU>uoVNdNUU9&sdWh<+tO;!sPg` zQ&pUA=4J>Nrr%#X`DuOi-1-^$(+q?HJ-8ubfaL{Vqvz3((>$%^=`&{}zO-TOvLp}aYKALRd zTg2nDZdA3uFkq`*pEW&Yfyv6J7tb2cF=9IQ>FwUdr3aN?Hmr>;pWt5p^^BmkWZa9b z%NMF&-ty(qRO#DRp*~Y)RDaBWa;EG0tn%j_?=6ZR%;9xix8%3)qBAPbzb${${?OHG zx#QupNAw==b zwfwgxL+d*8XS?G+Y`$rBNq;x1+R_`_Yx zEprnpFLkVAl5Z7X)9KXA>s?%N&V$GN#>1mwFSIAsz9=(%rn{f_VTYv5))Gmpg)GP7 zKdtX$n6+k$k9XON>%~@>&R^8xZ@EFrYL!^n zf)mcqj3xdX@LhXzD3AB{t{E1V!hDnEPFt*-cmDOWN*Te8+mu<^Y=lkCpT?R_a@^J9 zepK@G<(MR~I0jkGJL+>oHXdebiAcS8@vmFU$&37(U*3OWX~5iv z;$3uDGrxXW|NIDN)!RFtR@~&-@#e*o#AOz}htD<6Kl-lcl+d#S*#WG+e+?dYf96e= z^gVM}t8%KtJ0Vz?GT0wOxqIO{0df zf6-PxKacW&^>1nyuaM|Zi`)8gnv85w@@?ix0Xj=07f;%AHB;5$;DOak;;I~8&)D7U zTQuzmyY8`#th<7q-(LQxdaM81{kkEd+!=dzZBiE~mAdhG!D_EGr#=rhnD>ia#WCbV`=j~DJv{}Nr z+IY7>nE%2Bt?WF^CzeHhJ>8HsA=IfYZiZ>z)Hq9i!7%wLO_Q#)YwTv*mcAv&z+NK5 zMSXW~lLymVk6TaLR9yaEki1c)x?1B|N`Zq|%j0mPeeD%{ABB9_ekE`2T*;1!(~s@X zTvV7l?Ot`;YhPEvl5@%j+Vi8MQ@v(Axu|3FUdSboKQ1D=cdOEk-JRQaZQ6VIYE9kr zfFFii*X-Q)KsQwB?d_$8&ibLzbv!W#9gRccs+T@FxHH-NWYrhuRtYpS3IkZD}=f23S-RfHZk@tEEU?g`pmo2$!SH)FD+qh+IOs(jf>e$ z_UG-LB04?{g}Ha!Sn73Um#FHl+q}R!>{9u*!W<6%om!_0mnHh&%3I30jYHr;!;6Wt zew}J%$lA=!e`F5b2&_3by4>wDV* zQ@N}))+emueX5z7_V?k(rrXS4O_zQ=+G9OswXN{XXU}5Y_x}l#d^7iqn>2$=|6aD` z4VD}XTbOzcX@=>;b_k3@zR7RF+&cZ5uZu$dV~5`%T}S>Xdmx5g%^da9T9!QnrP_5hGqZaeX#v0muJ~3PfsSZ)#0^ z<9D&bMRIy+_M1yHk`fv&G*q+;>aDrI_0GkfMO!Oh6>psjWtYnI{>N%BAek;^rsmD6M#Gf|bw$J)eW4HycV zOc@OpiSYXR24P)OET%J9d{&{Hahw#y2Np z`zD?&GJGK+W4AhUXLaQ31}_=QiG5<1_USKLeC+kDllGdPYH#jL61$ses9zQ*>791| zRQS$Xkq;$#@v`Svq+V8bi(25gqti$}gKOmqyY9dCaeN83?f!3970f<=zD72zN#|wW zW#x?(8+NQTUCr`Ckw2+!#m{6$HJX_w)5QS$VQ8{tPEK5#p-|IxwucOO@% zCUMD|xvC3(4Hq@rP;r6x=OMS2v|j$5i?aXb99VOG-jd|Z^99d8uK2Bg=YFQo#Yzt8 z!kw0$Q$i2j65^Bh%7dU*A6EUfRCR zncVVaS9e{x=-|_Jj;}KJUdV*C(VH*St#>loeD`6>vww%BH6=EjjH&n;x%EKBnQ;Gs7%>-8ak9rQ5v~CoZ&{k?_K| zKyHs~^~3!tmGv7I9aHuDIk{j~o<&zpCqp!g!IRTm;XGQGCe&}NjQkd19y6IE_O9sD z!j;t<{!V!|HA1HK;4MgjOkG63NiV;8)GCVeES@p{q_na{!T)+&E^paC=edF5z14Ed zWAmm&H7QxY7cyJ@J$BCN#QDzU#>L@}CW^3c;kz^OeN26OgT(IJJrB=S?w@pbv0Q6S z-OITj_lxwLKYDf2cj2q5%lK=I{~V1I>JNQBb&Kr(ymbjV&RUT%FVzezXET~DetF9N zMDPBXQ`25Pj*1iT)_z#ZWpg(DFU!uA`cMBb%%4*=Eq{H_KXtifOk5di9$oV1--$RL zP`xJfHS2K}*TbK`G_78(&b6(d z@(y_$NS;k;K6^mn!#-xqWmn!jcH%$l^7@APYDwNns^2d=J!Lq&*|YlolglgBa{ zXQz7Xsmx5Ay*!)$b^B8J80+WK0{UFHIrY~bng8~5#Z9J}*Y`|te0Dn~G^r$F%8v~T z=eEAeHSW8_e5ESjxv65!0coB6Y?}46b~t2vYUl0!=`&ULZVD@_@@7u=({VF??kfM) zGht2zLx)~h?cF_H%Ui-P594u%1L$ao11xar^j!ZmGJpC$K9~# zdFd{(YxiAGnXobI4`<}xnb9O)C@eX0%AUIW?>A-5I`;uwelTV(X zY*`bPlQq|L-4Dl?ZnwUFb!0x4^u}YozRyw{uJ5jMT3t_ED*boRFk19#(TgkX>tqkM z7*6$=bvN;Ae*edw=+9Ntep@TQ=2vt&#Ii#BrPmLcXLpsqA4xt|t3UTqouu|lIV+pl zI|}OFPj!)>ReN52qPEUbE34%``4ibH_XjRmcx?7^zxA!hj@CFx+!K9MRr)fUZzro% zZ&{;M#1AWuwSS}M{rNZbU$9Dr-Xu9y(~R1bZJs$kw;sO^-YyccB4fp?EBmwho*JFf z?2z%A^eWnmBPgW1?DOrEl0R4748BfZQW^Vu+tm-t6=hy7e!VM9E91p{ugh$W|6}4q z&#yn_b1dNWk`MXo^mcBu(frO7�uaEWf;x9PNCwLg?*@X;%*&NU4td(0A?EDI1T)HC!A{CPlyZ?)Qv%^xSCM zloScMh=Q-y24Tz3N8ECMZ8+UKM`-RO#<)Y>2Loj@y?qsww=FfwiaEXRywh&4s?Pj) zo`}Vh4W?#td=Wi1i(~!y{azb{C*@`^zq$6xWL3x{qnl=i?^d^`Y`pO9x#L>H4R_Lv z5}!(Su?5x#FlYp9b<2oy(kkTfvpH&>Sv%|CvX&E_fxaKab&2`_V91Wz~IIiAS$T0UmI z!Qvn3PnzA;zt}5p(9Mr_R#U7$Kixmvx4&0r{>lB-8to~w+BtkSS(*ozs{WStWIwpQ zU(tUi-{h^q3ohJx&;Q$-V;SG#W&LF{%DN2AQtPJ5{y8LvwlU#%+)sa0ip}0$nZNP4d-(3^ zYYO~#0(K+>cLlO^C(O`hx+KA=c`@KY0n5{)&Gj6)mk(t8_@LmHX#PxOZ}@t3U+H~i z`^2vQ7h;;-5>ZreOX|Z*$1N6Lc6I(bq|30eR>tx?9P+oayQ^=avoA?}N z_U+Q$agFu7tXD}av%$p4aW+ZsT25B~bvJnIQjwZzCV#}_p-b0DTs>?$}hIlES_;fAxRYu8iRu)PdRstqJ2wtV9`KEm}b!VRX{?Es@apB48_~zqQ*QfZ1S3f=UaFyw*OL56ncFMB_g!LnK z#0l&=Iw50IW#m;k_U}>!2Dz@CTVAUrKDqbPMd}l-{lToYC*6p7T36 zSwLgIy;JE#3+4c2m-%JeI^8#4{E_!;{@#yUXUS!h7<@9{=Jn`};SZGpa~oM_xh)rR z7XJOC_q}eu#FVwy6YIXQ*EHsA&rvql*%fBw*;Z0|<XSPj*%j()UOujIQ-rDHp@pgT)QkNY?+=>)>09ROx7=sV-iBAVE}L{~d_3Qi`%z2wADmI9=O_5kdc|KkE~}q5t=v<51Y9bWGw(J>nKbf>UfHOA?CoFHYf-!k zcaCVjtgO>YSlnI{QPQe-fp?m%uG=RoF{3xEyH@1YPkW$#G$?;k*P-Ln)3){59~Rxz zX4&y@rse807L5T$OF#3b?pktl!FwltsThsLS>5vN87Yqr@VVD%U-{>}O6|iH*ISFY z+*#h0ef%Oa<CngWuELo-PZVdz`CX z<-?KQxv4pu^*G<~O>EE*vaT1k-K}t_$CRZpgroFE#{!UjqZ`-^{;|X-AkNcuj;n=`)b3ePt)fu zy!z@}+L}PaWiO2;=p$q^r>-oyAhPh9JbOgo16^j1ud|?#InV);;m+#T$S?%2~+M^P>*1qL!PG;~+`L&=~ zso=e**!C;OcnYqG)+pUNl&AL4-{{B-*7Vc;EXIsH$1aC@y-xXjg5ldqAD`v3-j#)I zpM1pFM@~9cYUZm{{zDIZ-yEq?Ztwt{-%nLiw%S4)M~CfzgJbxSTOMI zzw+Lyh1uRdj#peIw=G$5yhilL6J=Ae8CMMX|4w7Owx?6(+S~0OcYFhv2ENpsCaC!7 zxpn`fyK^&V8TuQZ49=}O*-&&r%FFJbqnYrU^Ldx+cJT+Q&2Bt#M8AwN_2BGl8Yfwr z6U7d$<$fTRrMutt{K;2=QMP@Lg1agu;{Eo-%XhEd_xg<_@9E@P_qa8)Z*S0*d1{gB zCAuzZik_={*~JIn7M>22cWCLEMy;y(LgIX{Ceo zN`}w23zjULQy`(d+L9s}!z5kZ4 z4O<;|Kw|E{s;4p9kK|Yl41R9%ywoReeM;+>!9n5K%5t)%x%&+SuOwfJd1U-z;e$2v zo&*@wP2-mKQn4^!d3)Nsy?N@Q4Uga0{N~Ve5SS^KWVd7De6BU2VxpY)90gv4EnrSO zb@*n^bD9pLfg5mST?49_-%CAX#J~1yOooF6{pvGPggAZ5M%ji!$+y9 zvI1Hsq&#EXt#?@8pWV7Y_U1aT#SL|a?r(l(xm;0y^5>z)@wi}yLpaQy z$jkf1bC1(ejj!2VM&CZU33i?RSM%>@V&AhrKR#Xd7QX9zVQS@}`7AOnd+PPREZCd5 zRA<%sOsRSNM<4Gjv7H!d>h+rZ;VDO-dz(j}mYCc9NV&F_fJe`z4n|v;oUAd351HmYdr_LqniU5O*SWRi z94#sjF4-(G`-LOljVA`4PN#yV-t~UI6Zm%6gf0-?pF#p`#5|A^ADJT;e1 zxZFDx^>GXf-&Sc28sBw|Zvt6Z0rwj5o|B%trXI!<|x@TJY50$H$ zEYoXV%vs)~q_8qx>`a3Ji{XFIefQlA3q!T$KFB&3Ub7)%^V46cAMXEZyv}kyr9%GP z@3YTjPkinvi%Yz<%JJ4#6@8z*-&Zv77ewv8e4{HxaKBsIa?RC=cfM&cw!~lb@cNRm z^xU;&Z4+k4<}Zo9XuLYnj-}0q#U*pm%H*;OS-Qq=tbQ-6n7WAN*6js%R=do+>fjS( zD(Iubf77s-RUpZI>mzf+uWKXiZ-zXx5uBC(^LM)C^8378CF|lUrt{6NeIha~r65yb z$>z2b>yl+HttvxVEsD)wZ=7s6&*J~F&3ig7DS1?s+-m&Mq!w=d()-l*YfXoGcy ztjluc@tqjceIdEUu@lJi@4^oY7N4kT(%)>6JnPfBz`{C_*oCK8RC)&II^|`kuC`LJ zW7KV|+p)do@Rca*#?U>{VH{ij?@sio4g0zO)#Mbu{ESUC7d#x~Q>(g??03|9)c)hD zezNkbTliy>6&{m4zA0PJbzCw1(xlm!OiHyQs`p-q*4?fq)_Qp1w8h~mg{Kt@_Wuu+ zVhoOWZFlN*V&)I0_K0WfD_HdmU)V~Nr(S;g?;QVv@UM!sKXrfm>KxLx_%Z9y=i+(C zH|%(u+kJczQtFYI~OQA&?=|T}-N_J^q$o}TDYsL*b y27%Y_&K$U9pgCKyJZ#>xc$=((XqFA0lPp8r1n(_;u>Uwq#--V_n{QnAN(KN{WM~)w diff --git a/libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test3.iv b/libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test3.iv deleted file mode 100644 index 7a6ded50f..000000000 --- a/libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test3.iv +++ /dev/null @@ -1 +0,0 @@ -÷–~ÞSr[ \ No newline at end of file diff --git a/libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test3.key b/libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test3.key deleted file mode 100644 index e18fd8903..000000000 --- a/libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test3.key +++ /dev/null @@ -1 +0,0 @@ -ïÝ/]o³¨DÐεžPeɵ®à¸0?6 \ No newline at end of file diff --git a/libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test3.plaintext b/libcore/crypto/src/test/resources/hyts_des-ede3-cbc.test3.plaintext deleted file mode 100644 index f45bd88eeee17cdac9e380171235ed5fa8c1410f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10000 zcmd=6&AuvQLAilYm6>+aJ9ocar@hignuK3v>pwj`uaNQOSBsV3?37|Rf3#j#IQiB0 zI#b6dX`P%L6?PN2KSX-1y|d}*ybrZpvz(_J+P~+An*vpipWn z&y_m)Ddxf)C6hK^JbQe}gjH8IP20Hi{Kv`LT&KG??h1DPyOWi{BQ28c?tQk`0;hEz zX?|jrT$Dh8N`D*X8nE}g7mT3yua%{9=Iektqh2g^0ETM~CjOs5hm~7^f z`Kx>Nq3vPDpPCK3&W3D1(KpSbt3sHi@ND24^Hoonqr0YWFfuQeG}-rTqLI{$2i*B< zZr=S89H-v+ccTBqPiFGFURPgz9oxjdGFw*0acSq_yD1M>x&N4K#8=z5Lh8<3HI~F_ zeQcBBHNG9NK6A|WN`B-%_SP>SuG;+ToBjL#o9VOKV(T&^LSE#?L{yZ=R=+Nk+$i1r z;>m-bUnC=vmpDhQG+iqBNw8|p#`|&qCTKp~-PM|&b)@}8-&f5WdrsxPS^1yy=!tWY zi3tm9?nD+{P7$gNsnRVjzIND_tyC%MLa>|vo~$>f-&GR&bvItUd8Sl>JJ?jE&h+4; z7}*q$$XRd2_$I#Gy)4K?=6ZkR>ihRU#jh-GPu{-p-HMdO7gW8Da%zs1GnXH!E%14@eNOHnRpI2K553<7EM^{>{LST~ zdindPjUuZb3hw*Eukufd>v~7ZmycgtPAyxrMCH+|9VeoTAAM|@pOdvMa?z>v+nH7B zF4wQM+Z9pwKq;apcb_ezS9;bi`6-Q?v?l)Uz3`@dxA!8!z6OrV0^d{T?`C^wZGG3h zU4OB(@8b>Imd{A_WA_r0yPljJS;y}iExOn0hga2&{Y)HhlCw18-eh|}3TvN|z5R1C z<36YNF>X3$EbV1G?(B&B{8i*`_5MPqzn*K3>s`puIC-wAp}cTTwtL0TBw16@q|fo* zK8mj<+_|uKf#9!sNuBKTKC8aDy<&ahlSWaU7D-LvSMj%Au011ucb1KB!atsAu6iNI zzi&$W$+-1g?Vl}kZ%=&IXr!z0E$E(>qX6UbUJIuZJ>hBM&GxllRyC|BnPs0DcOu2a z(cMUO#-h9}%lwYa|9G;N z&6MXUcJ7{JU8j@h-WQPlx>M)N-HP`mE15Z)wl&o`b)33c!u3*4^?+%L;9&<=pWq@v z4g<+8SI$)jT`Rny((_+WXwJSQTO+X;-LIP#eGC2^;jgW`UVPVs%{S{DxSRvcd$(_y z|M=vjwpkM=%HOP7vsLQghg+w&6&HDL6n*$Nb54dGFIV{db6S6Yu-f+3E!h^VcFA+U z&GEQ~hdojEbv}vj)r?xWk?+La8z4hZ{x=^3wxyV7n|Ci{87~^5hJ<2YG>Bu zkGyv6Rdcn>Dz7rOaong)six6V}v4h;^|%SDN_jw(;uoyFZKmJg1t$ z^GlmcUMpbz6Ylv>pECYC?U8GIS91GRp69WXwj7`JfvI#G$C}E&_wG;K6T!-pZhSYK z_2bT-mz@V|I&DrqWd3{C%Ub21PusP>)pb)(+PgdwDE{tavfysb?=LOiS+8GrmYSF@ zvzH~V*VXN*UR{U&5uMbgZ?`2qBo}>djgf8Pdv+>cZ)MZde`+RGfBjxQQFXfAbJgo} zY$Fc@bg2Z>0$2f1@-OSJ1*xezRWPix%V$mXR)IuYyGS> zp{MQ~p41aNM@}gE(c|yyQ_BK#?(Q$Y(#n5LrS1FV6B<|5vbNajuK%AHf4|&cZN@7( zJr~xaS`k?_jht5;FK)?mZCqH!bIie>vwMnc%qiv8^L#fqZ+~1j?XjB6(HQPFl`B(E zuGw>2&HtSPQ{%b0tvrvvxV}5}@8e{D)jMmKSM2+BXYHNJT@J5jMT8b_W9|@rutV~W z@AaO~X&h?l-fn*L4Kl5wEKAH|ubRgc%e6VC)N)mR7By?y^^xdt|i7_4ojAMrb_u%%v~yd>Py=7C)H2yY`k~e zMuI8s!pu6gDlVsphrAc1&xD^iARu;Ve&fyyGg&9>Yk70r_qNg_`AYfyhhH4`2@Hs;>~Y{vfn}5bF5~U zg@k)6|H+#myJl@b<{Olz9`J99f&qH)|@&D;b7Pm)J5( zymOt6-efJkhny2U#PS!Py?lAs0bLtLxp$@x;zssn6&j{ei-TWZxmfMq@HVY=`();a z-Wz!mZZzS+P39i`Od9* zBiPgGzu7mtOA7-TIefO=VW{}R7%P2hPgrKvL$3unv*MZ(ZZ4Bg_ZNM_?Hg5G=~?gA zciv2SlK=C%-^=AMG&dezb)da7&Dths)uOQ5t9OeqKg-KIm9_JujipTw^Xy_FSAI9; ztxwj3|6abKam!z>Z?WPGo$}y%S34f^ir|P42tN>Du~=G3A^T@EvvKv*6Mr|=q+f9 zKygi+@D`8dZzO(uS?3Bd9GbrIu?&l`PGo;&^Zeas9@k9{p5kKmnxRqaq^yI+UHetr z!~eTIVzurmoX&T#DZ#Y6$ths}&vUl-jna&>j&54X+D4Btu=gw9r@c9-Z>V% zF!S_-pT{-0r)+Ec#(ko}Mf<$$P3Nj2h8-31>Dn!i4sDw!9I#>gz6$3Icbhb}xkYwb zi`)M^lG}51r?RQ)^vVAx3iw6-efVAI?3+i6ANjY36L6-?ht zOzD$PrW!2$|MKeC|0kc_JSWuW`Q$eaF^eBDB!ARczT5qmn2_Gyzn+BC9auWtx@ z%^g!!f1s>dp)qB{qzU}ZYdd~RTN(XYyk_1}%a6*>ryZ34Cl*x~TDW9}wB^2TpZ&Ka zShcITiXS$;oxfn`f%ZH#ocTHs!NUFj|9y{AY|Y~e65svA;OnLyZ_a+VdbMY%Tc&3Iu-drF zI%u)p`iHmYJ!Uj`b|q(_(83fY9k1{?UK6uQdJ?_Pu^G<^97Y*}+WLT-^U@%~L8dd2&L-mcOR3@0??Z zpkPCe|B4OQmMBO0)_dNYyQ%u$_G2N2Njmw;8hWDZCoVactEziA=b6u&S7H9qVN-1a zHx&JGIu)YUXX@ziUsEnnBc3n%hf(ny--OzTFB{wM8_gAGDp{GeX<^7DhO-=pQ(d{H zt^7H+{kZDnHJgpszP{4BQ}fvxj!Q2yFK_8s^KWC!(FsrMKl?rJ-(AI6YaONYSHU~K z;IrPQDQ#^#`ciYwI+>kVQms(nm@g69@LO$KPL3)$pec;vQN zb`rN_(Q*E>mmSS{3R)McH0_$?6nJ&U&VuJBKJL%@77)DR=?19_Kc>V)NUi9J3|n|) zVuYzz&;98KWNcrh?ey{u3b-?c^+e(s>9sE|Uv!V~>c7VK{_gpJ}WXnzCzOnI$(GuKK!$^@rXW)}DKB|2Md= zuu1)U`1i6yDXW?v3D3Cqr?$K5@PS;OJ)5+O86T}U@f1 zj{0PjsXN#3$A@Rn?BWdg9d=!h|9*b^NWOOTZFL*jrP?2aIp%VG-f~~z#;nAylj=o> zlLfC!b_)jX6M3c*9e#xlLmSDj(MU}N}1<{vz6moshowabeNWW2e2PA+lZ;<9)HkNwjy z|yq3H=_t?GMXPsePN%C7R zMTll`Fw2=4a)sYzajNxYk73up!Q*4+aQc+&uDOw}FRtA^^l@L_S~aCb+gaaTXIrZ* z9VG8NJFQjrl=jE^rpH3(=hR(r&nbR!#LzTt!|ng~&e=C@44Npab;);=?c3DA9u2{R z0(%wyhu>5)j|+dR$XJr}kL$TgEZbf&holql%`dA4`<|6Ox?^*fujn4PXT6g47BN{8 zOBYQ3;G4>7yg{#1pPTFL=IX8#r+sJTL%aM}zna~%_6f61qu=BHlMfu8)d?$|h~0Fg z$MN5aDTh^kLw`-kMc)KUyManhSCkM_ZS8V!lOY>&)9hLe^$3pXp7lo|+HUF#4 zJ3h_ytIY1bXLJ>!(-RV9=TFv}yD;Z3>tdJ13b*u+O*y!B#f2+Y&tya@b6u`E?LYsU z>2NOl=GaePuO1G~W!QFNzuoWIzxFR$mN{d|DgoIl(K+=$S5EBMBYtkmhS;#YnJOt) zKS)jcpF4%gP3G4_A+e*ECz=HRxv<;)6GN%(G+j1@YsIAubIRpvcUmX$oM_^fwVJB* zG@{Q}=;iOD;_LEv{_dQc5wCUo-RY&eR@KYy{taw@th?^k{)oimv-gDcFDp;{9>HRI z{?d`cbvbw5Eo*$rtz}RV-zlqOf;QP_w5EOU*qFk0<;Lj;|8l8)-aJ++GyD!p+_5 z)t9DOZ%)gm@Vg7VpRspa!=g)*C6~l$E`9i<)qBN?{0FrL_gjCP^NHmAUMR`@ zUhG!N4i~N} zZtM9RtaddsZ-;;PM!w<>xtlj!;}1^@e(3I|Zph1M$0#~ylE1~by>hA|tRG@N746H` zx%#)%oP}WrQxjKf#e$Egmo1o;`SOcd)=r+^ZfBeJ%{Os1IJWxux2*k&@9m;OTSK&V z?Oc`TxYJVm>93tXFG(oI+39&+T`=+1CX1J+{?vs=u6XfvR_o2a&J7lhDo_y`%b`W~%p3kwx3Stp4^-Ie59K zwFv)iyBjr}O3WvZUw&ZPEwe~h|9^>(-i+xPSC;Re({wuV${u~TqbfJv-#F`acFU|4 zOv{@!YuB{+&7L(WkWVh{N9v}~*-KoPJwKUbwU4Xi{mrDxJ5T(lKd@W&*|hTcb?L?c ziF?PrjV}yZP}B??>Cu zF{t&e4zp0~t`$8xpia|E?3#e4GJ8#A0P{PNfK?9 zQw)D~wQ&Qpq|Mp*D-qH4ztfs#S41&y-6g#^Qk5@9gIV<1e}Oue7?zEk+Q_?El_D&kPH0oNWE>sJhQBXZxci zUi{6e)3$QBiCM(N9bWPyJ;q4&wq330dRD`wA^#38R#(>IyIa~Xr&!8q*XF$Hul&Mn z|F=>bvX8WQxpCU9sAZCMZ7vBBTK342>FtF)tvxD_V=_F9)=jp^4HITu;B&84t5V;72YO0EG-`ak7hh$5(#7<2*EX)NO4D8UU(*mW zb9+CjCufCCN`^pIvg?XZxhLixWzx&uRBKhx?!Y!l=J`y;S2|v&Rv32tey`)rBpcHZ zu5EH$Idra?QO^%`&*s#<`@iy+R-C<;wLaM6i{0Z*8c(NwZa-ecy>UuakGo9$8|~#X zlb4n&SleIn-1}?OhnAYj(Gvoz%%)vSvSeE*YWM%C?DoznZfxt5r3td>@!qBGeOfv^J4- zn*qC9g-nKy3**hDy6y)>Q~6zW{C6&jn9QebnfETdYU{0+xmJG-;XKO{HCEN0_q+*eyusz4 z?&^g8&(V7>EAq8&|BAm~w{dBQiSPN*X>r!9W zyZhHUT=d%+l})9!rL#2`JeW{#H%~l(VQTi4BiYUj35L9){}tpM_cna|dXq!q?DvO@ zwG`@w`)5p9bt0f(!je<@$~AZLjy?-ko5sAM*qrrBbEGQgx1;g~a*4C`qrabd+Nu^f z)4BDVg63V{2aL}*J^v8Jey_cC{mHp+kFCx*rShdVf`7{2H$hAnmOl#T(Q}fB7Fg6b zH}A6N&v#$W*#?|E-#(h_87@>4$YZkp!kz;)?w3#9 zIrC9s^`Y9`0n8JRxjEQwUa1h4Yt#2I!0^R)t~qzm)S&-dhHm<_XF^^BY`mEluiP|10bz$NjhGf9jsFKRIW^jC&t1u3S=)9DTpY zHEr=Xhi2u6{4(y_j&E%^w#M1UW?IH?u_?Vak+bJ%>UMjz%)j}0*}9lTYftJotI2YF z;afD1IXkm4acb^&=_?6)ncX!dgudyojXgW}#x4a(MgB`g88vFPOVT{5CVsp9I?wuB zX%VZ}S)uRN&c)xWM0U&89WE;S_0%P3^6irf&QFTjgEaKt&HEFnx}~YX)k3G(Nb}n3 znn(@_&okzoEXPvHIQoWn)p!~s{ zozXrs)2`-Lo+zsSTVB0%-^2f&r=rHH%zhzZn&7xi43_tB!q3$?Z0>p#;T7}f4eUkMMQmbPm0dV$~Iy7vZzAL z=l;oK4vJS&FLHTza<gaej2aX)llKH?~DvIDh87{d@Pw zj%9gT6ZHA#y*?*2f7PVce-;UXH9U4x59MjqiEwk9)XkH4n)ayrL-8GD58b?VFFG9gWo{GK~DJu+0)xBWNs-8Sy61#%Io-FqT$&3$*Vqo~MKC{CTN z_07M%iWfNgOs*>k>s;CS$4PuqM5Wt@`zL!;jvFRSk2=nH_FL@?r_62bbCpijUO6Mk z?k{mkYkKCE6B1i5ElgMZ^3BTl+N#o1LUNTB#obT6mioJycl2A`=!|Q*6(QfZiO-_& zphNq2j+=?AXZY&8{Psar!{WpCfJqrvbIT+gy?mAhu-y{9CbHwl``gotrES93?agdo z+269i`N985&srQUlv}raY2I*YhWpEc*(Fg~v%Jp{ItCCctb1t2iJ2ZE}x%%3M`JUda zao3*)SubK#GW0l9`tYhAUjqLl^*7=V{8CD{DxF@<8t43WlXZDU+JpNyZ%tBNkSM!e zXJU}le34%{O4}DX%?k)P6MV^AUFoAUuX4*~yGMKX9bue5*MaHEv@E0i+Qh$@*g@P79KLm&)h8i58u8(WwvPA>cm}Y-AJagxz&llBLd}BXp-Tk|NM&`#nA#0(%JAY5qUiDt|>yBubsgoY9R=xVs zwtgQM@B42$Hx=^g&pX?u&vQ*@UGYX^^-2Cc{~e#HENRp$-aB(brk+pbN4IN5b_oUb zZ#ABB9iOy(63=<=wWVeo-lU6nP1-EW7nA?%u(;~BfA7D9ynN^Ey7bkfvu{54*KL*c zk^d2`ac)AxAO8P8++Wml#+iNiKQDe?jQ6&t`iw)%)OmvDo%RTb3Cy%o70(RFe7rr? z-*D5DBd)>u-725A+wGhmq1}DM$E;DsWKDu|&$J5TK0ZS~Jd zCQO`tbK$nwk2j-_d6lv6cn~D5d_?jC|L=H1PMeI2`mJpKoW_zGLT-n1=e=z0UznSc z$En2;*pYGdMzrF;A9bQy8zg-qmN6-eSWGeH;=mtpKWVO*$`7Scg@KE=z;DvLgtoN->ElCx%qnpmZ5 z+`xMfFS&eR5%i*M4;-)83v) z-KR1K8dOeu&OWr*?#z^lYU(QLu@<7wMb2v+vtN7tK&-80%dDw^!bcRQmHpGU-<^Nh zKdQCn_tV*mhbB#^P~Ti)&s}&~wEcMa?zWu~U*0Y2UgOXd($Ao;u*7LIyZc*Rx#=4g z^&L&Dn0fsTyOFZj_A?FjyeYdAwc{^dx6&@}P;WeG<6p{9aWlC3BfBN@i(ePY8e?_{ z-;2_7`!f5<)GlVje$J`uLr?U-yL?YB+wsrrKNF%=1^;Z-y1S+J(^c7;s(s7+KS`W1 zEU464xanAYmXY%7`5DXR{w)wTcFC$j?upy9-f;Qc zkmD3u{V1$)x8RC1M&CY8v6w07(!V_;#`U1I=P!f2wu=Tyi?*n|wQ%$A?|$9J*WlW{ zZrahqF+$EJi&hyO(#bJ?)*bgwmwR$dkt_4M)TV^;I|(*1=U*gLTFx_8J0D@Te^=Wn zy_cu#za2lT>CJMy`qd&n|C1@9ub#!ZuHEDPr>}Q0bNzgQx2pZQpMcnc0IqqvGr2%qG^uT>-?V{YH5kR@@2zD*K;fOJ?vU_qPI}}`EG56 zw5F=pQ7NVDTv0a-cfE3d>!Qh@!liJUO;NkIZEOC?-M;&AHSZycXf|X_Wk{_ znNL28sV6J0{ljeX#D%r9SDUM*$r~TK z-mR9sJ-3=6c1viC-T#$VD(atu_Q^bY6?;4T_Rphh&fc^MJ!7e|W;NfZ2?{Fvu5W!; zV3)G@cZ~SW_KQ!xKQdI5-(hamqRknmw+auV;5<)>+M& z8jGK1)eG)E`RkaVgzAf$H@x@VzQtwOG{|qizHa-MS;4=|T9ybFMYg;QeBJ%_In#9W z?#~9Z-g7S~W6GW1nLRzJx{lwQn;$Fg zn`Y5?_T!bSPi3_EZsqQrY_-VEnd3V1*COVrn|r@rF|Z3tTliq_x?Pj+MFi$}OD<^3 zl6*HMZ}T11%deF!d}XhR@J+JI?!0N4|E}u!U)@)Mhi7d$Y#4ktxIxu+x6RVSjE^=x zX`SE2b86$0%Ql~7SQeaOJ!RU{uDkAX{`IaJpMDf@P<43nz9IiC+Hdg=45t;~q(?BuIRbBjp( zkx*TFgJH*qV78kkn=6G=LOu8FS>KW&r1@^|oOx>x&e[] methodArgs() default {}; - -} diff --git a/libcore/dalvik/src/main/java/dalvik/annotation/TestTargetClass.java b/libcore/dalvik/src/main/java/dalvik/annotation/TestTargetClass.java deleted file mode 100644 index acbc1f12e..000000000 --- a/libcore/dalvik/src/main/java/dalvik/annotation/TestTargetClass.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import dalvik.annotation.TestTargetNew; - -/** - * Defines an annotation for test classes that allows to link them to the class - * that is being tested. The current assumption is that the test are somewhat - * organized according to the API classes they test. Might be too strict for - * some cases. - * - * @since Android 1.0 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE }) -public @interface TestTargetClass { - - /** - * Specifies the class being tested. - */ - Class value(); - - /** - * Option to specify untested methods for the class. - * @hide - */ - TestTargetNew[] untestedMethods() default {}; -} \ No newline at end of file diff --git a/libcore/dalvik/src/main/java/dalvik/annotation/TestTargetNew.java b/libcore/dalvik/src/main/java/dalvik/annotation/TestTargetNew.java deleted file mode 100644 index c00e37b00..000000000 --- a/libcore/dalvik/src/main/java/dalvik/annotation/TestTargetNew.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Defines an annotation used be used within the TestInfo annotation. It - * specifies a single method target for the test (but can be used multiple - * times). - * - * @since Android 1.0 - * @hide - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.ANNOTATION_TYPE, ElementType.METHOD }) -public @interface TestTargetNew { - - /** - * Specifies the name of the API method that is being tested. This field - * may be left empty if the test target is a concept implemented in a - * class rather than a concrete API method. - */ - String method() default ""; - - /** - * Specifies the signature of the API method that is being tested, in terms - * of Java classes. - */ - Class[] args() default {}; - - /** - * Specifies the class to which the tested method belongs. If this value is - * not provided, the class identified in @TestTargetClass is used by the - * test progress doclet. - */ - Class clazz() default void.class; - - /** - * Specifies the level of coverage the tested API method has. - */ - TestLevel level(); - - /** - * Specifies noteworthy plain-text information about the test, for example - * if something is NOT covered by the test method. - */ - String notes() default ""; -} diff --git a/libcore/dalvik/src/main/java/dalvik/annotation/TestTargets.java b/libcore/dalvik/src/main/java/dalvik/annotation/TestTargets.java deleted file mode 100644 index ead614953..000000000 --- a/libcore/dalvik/src/main/java/dalvik/annotation/TestTargets.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import dalvik.annotation.TestTargetNew; - -/** - * Defines an annotation for test classes that allows to link them to the class - * that is being tested. The current assumption is that the test are somewhat - * organized according to the API classes they test. Might be too strict for - * some cases. - * - * @since Android 1.0 - * @hide - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.METHOD }) -public @interface TestTargets { - - /** - * Specifies the API methods that are tested by the annotated test method. - */ - TestTargetNew[] value(); -} \ No newline at end of file diff --git a/libcore/dalvik/src/main/java/dalvik/annotation/Throws.java b/libcore/dalvik/src/main/java/dalvik/annotation/Throws.java deleted file mode 100644 index 342d890f4..000000000 --- a/libcore/dalvik/src/main/java/dalvik/annotation/Throws.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.annotation; - -import java.lang.annotation.*; - -/** - * A "system annotation" used to provide the Exceptions attribute. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -@interface Throws {} - diff --git a/libcore/dalvik/src/main/java/dalvik/annotation/Timeout.java b/libcore/dalvik/src/main/java/dalvik/annotation/Timeout.java deleted file mode 100644 index 74c8d10bb..000000000 --- a/libcore/dalvik/src/main/java/dalvik/annotation/Timeout.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Defines an annotation to be used for specifying a test timeout. A test - * harness that supports timeouts should allow a test to be run for at least - * this time before killing it. Time is measured in seconds. - * - * @hide - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.ANNOTATION_TYPE, ElementType.METHOD }) -public @interface Timeout { - - /** - * Specifies the test timeout in seconds. - */ - int value(); - -} diff --git a/libcore/dalvik/src/main/java/dalvik/annotation/ToBeFixed.java b/libcore/dalvik/src/main/java/dalvik/annotation/ToBeFixed.java deleted file mode 100644 index 69859291a..000000000 --- a/libcore/dalvik/src/main/java/dalvik/annotation/ToBeFixed.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Defines an annotation for test methods that indicate the test method - * need to be fixed in future. - * {@hide pending API Council approval} - * - * @since Android 1.0 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.METHOD }) -public @interface ToBeFixed { - - /** - * Specifies the related bug number on CTS bug tracking system. - */ - String bug() default ""; - - /** - * Specifies why this method need to be fixed. If we think it's a bug, explain - * the expectation and the actual result. - */ - String explanation() default ""; -} diff --git a/libcore/dalvik/src/main/java/dalvik/annotation/VirtualTestTarget.java b/libcore/dalvik/src/main/java/dalvik/annotation/VirtualTestTarget.java deleted file mode 100644 index 019e4b039..000000000 --- a/libcore/dalvik/src/main/java/dalvik/annotation/VirtualTestTarget.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation for "virtual" implementation classes. These are classes that have - * the following attributes: - *

    - *
  • they implement a public interface or are a concrete implementation of a - * public abstract class,
  • - *
  • they are not public,
  • - *
  • instances can only be retrieved through some kind of factory method.
  • - *
- *

- * Example: {@code MessageDigest} is an abstract class. Concrete implementations - * of message digest algorithms such as MD5 and SHA-1 can only be retrieved - * through one of the static {@code getInstance} methods of - * {@code MessageDigest}, which accept the desired algorithm as a string - * parameter and return an implementation accordingly. - *

- *

- * Even though the concrete implementation class for a message digest algorithm - * is not known, we need to be able to indicate that such a class exists and - * that it must be tested. This is done by defining corresponding classes and - * annotating them with {@code @VirtualTestTarget}. This class can then be - * used in the {@code @TestTargetClass} annotation with which we annotate - * {@code TestCase} subclasses. - * - * @since Android 1.0 - * @hide - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE }) -public @interface VirtualTestTarget { - - /** - * Field for comments. - */ - String value() default ""; -} \ No newline at end of file diff --git a/libcore/dalvik/src/main/java/dalvik/annotation/package.html b/libcore/dalvik/src/main/java/dalvik/annotation/package.html deleted file mode 100644 index fc7cf071a..000000000 --- a/libcore/dalvik/src/main/java/dalvik/annotation/package.html +++ /dev/null @@ -1,9 +0,0 @@ - - -

- Defines some annotations that are used within the Android system, either - for the core libraries or for testing purposes. -

- @since Android 1.0 - - diff --git a/libcore/dalvik/src/main/java/dalvik/bytecode/Opcodes.java b/libcore/dalvik/src/main/java/dalvik/bytecode/Opcodes.java deleted file mode 100644 index 4d5602df4..000000000 --- a/libcore/dalvik/src/main/java/dalvik/bytecode/Opcodes.java +++ /dev/null @@ -1,316 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.bytecode; - -/** - * This is a list of Dalvik opcodes. - * - * (This was converted from //device/dalvik/libdex/OpCode.h) - */ -public interface Opcodes { - int OP_NOP = 0x00; - - int OP_MOVE = 0x01; - int OP_MOVE_FROM16 = 0x02; - int OP_MOVE_16 = 0x03; - int OP_MOVE_WIDE = 0x04; - int OP_MOVE_WIDE_FROM16 = 0x05; - int OP_MOVE_WIDE_16 = 0x06; - int OP_MOVE_OBJECT = 0x07; - int OP_MOVE_OBJECT_FROM16 = 0x08; - int OP_MOVE_OBJECT_16 = 0x09; - - int OP_MOVE_RESULT = 0x0a; - int OP_MOVE_RESULT_WIDE = 0x0b; - int OP_MOVE_RESULT_OBJECT = 0x0c; - int OP_MOVE_EXCEPTION = 0x0d; - - int OP_RETURN_VOID = 0x0e; - int OP_RETURN = 0x0f; - int OP_RETURN_WIDE = 0x10; - int OP_RETURN_OBJECT = 0x11; - - int OP_CONST_4 = 0x12; - int OP_CONST_16 = 0x13; - int OP_CONST = 0x14; - int OP_CONST_HIGH16 = 0x15; - int OP_CONST_WIDE_16 = 0x16; - int OP_CONST_WIDE_32 = 0x17; - int OP_CONST_WIDE = 0x18; - int OP_CONST_WIDE_HIGH16 = 0x19; - int OP_CONST_STRING = 0x1a; - int OP_CONST_STRING_JUMBO = 0x1b; - int OP_CONST_CLASS = 0x1c; - - int OP_MONITOR_ENTER = 0x1d; - int OP_MONITOR_EXIT = 0x1e; - - int OP_CHECK_CAST = 0x1f; - int OP_INSTANCE_OF = 0x20; - - int OP_ARRAY_LENGTH = 0x21; - - int OP_NEW_INSTANCE = 0x22; - int OP_NEW_ARRAY = 0x23; - - int OP_FILLED_NEW_ARRAY = 0x24; - int OP_FILLED_NEW_ARRAY_RANGE = 0x25; - int OP_FILL_ARRAY_DATA = 0x26; - - int OP_THROW = 0x27; - int OP_GOTO = 0x28; - int OP_GOTO_16 = 0x29; - int OP_GOTO_32 = 0x2a; - int OP_PACKED_SWITCH = 0x2b; - int OP_SPARSE_SWITCH = 0x2c; - - int OP_CMPL_FLOAT = 0x2d; - int OP_CMPG_FLOAT = 0x2e; - int OP_CMPL_DOUBLE = 0x2f; - int OP_CMPG_DOUBLE = 0x30; - int OP_CMP_LONG = 0x31; - - int OP_IF_EQ = 0x32; - int OP_IF_NE = 0x33; - int OP_IF_LT = 0x34; - int OP_IF_GE = 0x35; - int OP_IF_GT = 0x36; - int OP_IF_LE = 0x37; - int OP_IF_EQZ = 0x38; - int OP_IF_NEZ = 0x39; - int OP_IF_LTZ = 0x3a; - int OP_IF_GEZ = 0x3b; - int OP_IF_GTZ = 0x3c; - int OP_IF_LEZ = 0x3d; - - int OP_UNUSED_3e = 0x3e; - int OP_UNUSED_3f = 0x3f; - int OP_UNUSED_40 = 0x40; - int OP_UNUSED_41 = 0x41; - int OP_UNUSED_42 = 0x42; - int OP_UNUSED_43 = 0x43; - - int OP_AGET = 0x44; - int OP_AGET_WIDE = 0x45; - int OP_AGET_OBJECT = 0x46; - int OP_AGET_BOOLEAN = 0x47; - int OP_AGET_BYTE = 0x48; - int OP_AGET_CHAR = 0x49; - int OP_AGET_SHORT = 0x4a; - int OP_APUT = 0x4b; - int OP_APUT_WIDE = 0x4c; - int OP_APUT_OBJECT = 0x4d; - int OP_APUT_BOOLEAN = 0x4e; - int OP_APUT_BYTE = 0x4f; - int OP_APUT_CHAR = 0x50; - int OP_APUT_SHORT = 0x51; - - int OP_IGET = 0x52; - int OP_IGET_WIDE = 0x53; - int OP_IGET_OBJECT = 0x54; - int OP_IGET_BOOLEAN = 0x55; - int OP_IGET_BYTE = 0x56; - int OP_IGET_CHAR = 0x57; - int OP_IGET_SHORT = 0x58; - int OP_IPUT = 0x59; - int OP_IPUT_WIDE = 0x5a; - int OP_IPUT_OBJECT = 0x5b; - int OP_IPUT_BOOLEAN = 0x5c; - int OP_IPUT_BYTE = 0x5d; - int OP_IPUT_CHAR = 0x5e; - int OP_IPUT_SHORT = 0x5f; - - int OP_SGET = 0x60; - int OP_SGET_WIDE = 0x61; - int OP_SGET_OBJECT = 0x62; - int OP_SGET_BOOLEAN = 0x63; - int OP_SGET_BYTE = 0x64; - int OP_SGET_CHAR = 0x65; - int OP_SGET_SHORT = 0x66; - int OP_SPUT = 0x67; - int OP_SPUT_WIDE = 0x68; - int OP_SPUT_OBJECT = 0x69; - int OP_SPUT_BOOLEAN = 0x6a; - int OP_SPUT_BYTE = 0x6b; - int OP_SPUT_CHAR = 0x6c; - int OP_SPUT_SHORT = 0x6d; - - int OP_INVOKE_VIRTUAL = 0x6e; - int OP_INVOKE_SUPER = 0x6f; - int OP_INVOKE_DIRECT = 0x70; - int OP_INVOKE_STATIC = 0x71; - int OP_INVOKE_INTERFACE = 0x72; - - int OP_UNUSED_73 = 0x73; - - int OP_INVOKE_VIRTUAL_RANGE = 0x74; - int OP_INVOKE_SUPER_RANGE = 0x75; - int OP_INVOKE_DIRECT_RANGE = 0x76; - int OP_INVOKE_STATIC_RANGE = 0x77; - int OP_INVOKE_INTERFACE_RANGE = 0x78; - - int OP_UNUSED_79 = 0x79; - int OP_UNUSED_7A = 0x7a; - - int OP_NEG_INT = 0x7b; - int OP_NOT_INT = 0x7c; - int OP_NEG_LONG = 0x7d; - int OP_NOT_LONG = 0x7e; - int OP_NEG_FLOAT = 0x7f; - int OP_NEG_DOUBLE = 0x80; - int OP_INT_TO_LONG = 0x81; - int OP_INT_TO_FLOAT = 0x82; - int OP_INT_TO_DOUBLE = 0x83; - int OP_LONG_TO_INT = 0x84; - int OP_LONG_TO_FLOAT = 0x85; - int OP_LONG_TO_DOUBLE = 0x86; - int OP_FLOAT_TO_INT = 0x87; - int OP_FLOAT_TO_LONG = 0x88; - int OP_FLOAT_TO_DOUBLE = 0x89; - int OP_DOUBLE_TO_INT = 0x8a; - int OP_DOUBLE_TO_LONG = 0x8b; - int OP_DOUBLE_TO_FLOAT = 0x8c; - int OP_INT_TO_BYTE = 0x8d; - int OP_INT_TO_CHAR = 0x8e; - int OP_INT_TO_SHORT = 0x8f; - - int OP_ADD_INT = 0x90; - int OP_SUB_INT = 0x91; - int OP_MUL_INT = 0x92; - int OP_DIV_INT = 0x93; - int OP_REM_INT = 0x94; - int OP_AND_INT = 0x95; - int OP_OR_INT = 0x96; - int OP_XOR_INT = 0x97; - int OP_SHL_INT = 0x98; - int OP_SHR_INT = 0x99; - int OP_USHR_INT = 0x9a; - - int OP_ADD_LONG = 0x9b; - int OP_SUB_LONG = 0x9c; - int OP_MUL_LONG = 0x9d; - int OP_DIV_LONG = 0x9e; - int OP_REM_LONG = 0x9f; - int OP_AND_LONG = 0xa0; - int OP_OR_LONG = 0xa1; - int OP_XOR_LONG = 0xa2; - int OP_SHL_LONG = 0xa3; - int OP_SHR_LONG = 0xa4; - int OP_USHR_LONG = 0xa5; - - int OP_ADD_FLOAT = 0xa6; - int OP_SUB_FLOAT = 0xa7; - int OP_MUL_FLOAT = 0xa8; - int OP_DIV_FLOAT = 0xa9; - int OP_REM_FLOAT = 0xaa; - int OP_ADD_DOUBLE = 0xab; - int OP_SUB_DOUBLE = 0xac; - int OP_MUL_DOUBLE = 0xad; - int OP_DIV_DOUBLE = 0xae; - int OP_REM_DOUBLE = 0xaf; - - int OP_ADD_INT_2ADDR = 0xb0; - int OP_SUB_INT_2ADDR = 0xb1; - int OP_MUL_INT_2ADDR = 0xb2; - int OP_DIV_INT_2ADDR = 0xb3; - int OP_REM_INT_2ADDR = 0xb4; - int OP_AND_INT_2ADDR = 0xb5; - int OP_OR_INT_2ADDR = 0xb6; - int OP_XOR_INT_2ADDR = 0xb7; - int OP_SHL_INT_2ADDR = 0xb8; - int OP_SHR_INT_2ADDR = 0xb9; - int OP_USHR_INT_2ADDR = 0xba; - - int OP_ADD_LONG_2ADDR = 0xbb; - int OP_SUB_LONG_2ADDR = 0xbc; - int OP_MUL_LONG_2ADDR = 0xbd; - int OP_DIV_LONG_2ADDR = 0xbe; - int OP_REM_LONG_2ADDR = 0xbf; - int OP_AND_LONG_2ADDR = 0xc0; - int OP_OR_LONG_2ADDR = 0xc1; - int OP_XOR_LONG_2ADDR = 0xc2; - int OP_SHL_LONG_2ADDR = 0xc3; - int OP_SHR_LONG_2ADDR = 0xc4; - int OP_USHR_LONG_2ADDR = 0xc5; - - int OP_ADD_FLOAT_2ADDR = 0xc6; - int OP_SUB_FLOAT_2ADDR = 0xc7; - int OP_MUL_FLOAT_2ADDR = 0xc8; - int OP_DIV_FLOAT_2ADDR = 0xc9; - int OP_REM_FLOAT_2ADDR = 0xca; - int OP_ADD_DOUBLE_2ADDR = 0xcb; - int OP_SUB_DOUBLE_2ADDR = 0xcc; - int OP_MUL_DOUBLE_2ADDR = 0xcd; - int OP_DIV_DOUBLE_2ADDR = 0xce; - int OP_REM_DOUBLE_2ADDR = 0xcf; - - int OP_ADD_INT_LIT16 = 0xd0; - int OP_RSUB_INT = 0xd1; /* no _LIT16 suffix for this */ - int OP_MUL_INT_LIT16 = 0xd2; - int OP_DIV_INT_LIT16 = 0xd3; - int OP_REM_INT_LIT16 = 0xd4; - int OP_AND_INT_LIT16 = 0xd5; - int OP_OR_INT_LIT16 = 0xd6; - int OP_XOR_INT_LIT16 = 0xd7; - - int OP_ADD_INT_LIT8 = 0xd8; - int OP_RSUB_INT_LIT8 = 0xd9; - int OP_MUL_INT_LIT8 = 0xda; - int OP_DIV_INT_LIT8 = 0xdb; - int OP_REM_INT_LIT8 = 0xdc; - int OP_AND_INT_LIT8 = 0xdd; - int OP_OR_INT_LIT8 = 0xde; - int OP_XOR_INT_LIT8 = 0xdf; - int OP_SHL_INT_LIT8 = 0xe0; - int OP_SHR_INT_LIT8 = 0xe1; - int OP_USHR_INT_LIT8 = 0xe2; - - int OP_UNUSED_E3 = 0xe3; - int OP_UNUSED_E4 = 0xe4; - int OP_UNUSED_E5 = 0xe5; - int OP_UNUSED_E6 = 0xe6; - int OP_UNUSED_E7 = 0xe7; - int OP_UNUSED_E8 = 0xe8; - int OP_UNUSED_E9 = 0xe9; - int OP_UNUSED_EA = 0xea; - int OP_UNUSED_EB = 0xeb; - int OP_UNUSED_EC = 0xec; - int OP_UNUSED_ED = 0xed; - - /* optimizer output -- these are never generated by "dx" */ - int OP_EXECUTE_INLINE = 0xee; - int OP_UNUSED_EF = 0xef; /* OP_EXECUTE_INLINE_RANGE? */ - - int OP_INVOKE_DIRECT_EMPTY = 0xf0; - int OP_UNUSED_F1 = 0xf1; /* OP_INVOKE_DIRECT_EMPTY_RANGE? */ - int OP_IGET_QUICK = 0xf2; - int OP_IGET_WIDE_QUICK = 0xf3; - int OP_IGET_OBJECT_QUICK = 0xf4; - int OP_IPUT_QUICK = 0xf5; - int OP_IPUT_WIDE_QUICK = 0xf6; - int OP_IPUT_OBJECT_QUICK = 0xf7; - - int OP_INVOKE_VIRTUAL_QUICK = 0xf8; - int OP_INVOKE_VIRTUAL_QUICK_RANGE = 0xf9; - int OP_INVOKE_SUPER_QUICK = 0xfa; - int OP_INVOKE_SUPER_QUICK_RANGE = 0xfb; - int OP_UNUSED_FC = 0xfc; /* OP_INVOKE_DIRECT_QUICK? */ - int OP_UNUSED_FD = 0xfd; /* OP_INVOKE_DIRECT_QUICK_RANGE? */ - int OP_UNUSED_FE = 0xfe; /* OP_INVOKE_INTERFACE_QUICK? */ - int OP_UNUSED_FF = 0xff; /* OP_INVOKE_INTERFACE_QUICK_RANGE*/ -} - diff --git a/libcore/dalvik/src/main/java/dalvik/bytecode/package.html b/libcore/dalvik/src/main/java/dalvik/bytecode/package.html deleted file mode 100644 index 1a6d7c498..000000000 --- a/libcore/dalvik/src/main/java/dalvik/bytecode/package.html +++ /dev/null @@ -1,8 +0,0 @@ - - -

- Provides classes surrounding the Dalvik bytecode. -

- @since Android 1.0 - - diff --git a/libcore/dalvik/src/main/java/dalvik/system/AllocationLimitError.java b/libcore/dalvik/src/main/java/dalvik/system/AllocationLimitError.java deleted file mode 100644 index 9118199c6..000000000 --- a/libcore/dalvik/src/main/java/dalvik/system/AllocationLimitError.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.system; - -/** - * Is thrown when an allocation limit is exceeded. - * - * @deprecated this is an internal Dalvik class that is not appropriate for - * general use. It will be removed from the public API in a future release. - */ -public class AllocationLimitError extends VirtualMachineError { - /** - * Creates a new exception instance and initializes it with default values. - */ - public AllocationLimitError() { - super(); - } - - /** - * Creates a new exception instance and initializes it with a given message. - * - * @param detailMessage the error message - */ - public AllocationLimitError(String detailMessage) { - super(detailMessage); - } -} - diff --git a/libcore/dalvik/src/main/java/dalvik/system/DexClassLoader.java b/libcore/dalvik/src/main/java/dalvik/system/DexClassLoader.java deleted file mode 100644 index 73e6fe430..000000000 --- a/libcore/dalvik/src/main/java/dalvik/system/DexClassLoader.java +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.system; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.zip.ZipFile; -import java.net.MalformedURLException; - -import dalvik.system.DexFile; - -/** - * Provides a simple {@link ClassLoader} implementation that operates on a - * list of jar/apk files with classes.dex entries. The directory that - * holds the optimized form of the files is specified explicitly. This - * can be used to execute code not installed as part of an application. - * - * The best place to put the optimized DEX files is in app-specific - * storage, so that removal of the app will automatically remove the - * optimized DEX files. If other storage is used (e.g. /sdcard), the - * app may not have an opportunity to remove them. - */ -public class DexClassLoader extends ClassLoader { - - private static final boolean VERBOSE_DEBUG = false; - - /* constructor args, held for init */ - private final String mRawDexPath; - private final String mRawLibPath; - private final String mDexOutputPath; - - private boolean mInitialized; - - /* - * Parallel arrays for jar/apk files. - * - * (could stuff these into an object and have a single array; - * improves clarity but adds overhead) - */ - private File[] mFiles; // source file Files, for rsrc URLs - private ZipFile[] mZips; // source zip files, with resources - private DexFile[] mDexs; // opened, prepped DEX files - - /* - * Native library path. - */ - private String[] mLibPaths; - - - /** - * Creates a {@code DexClassLoader} that finds interpreted and native - * code. Interpreted classes are found in a set of DEX files contained - * in Jar or APK files. - * - * The path lists are separated using the character specified by - * the "path.separator" system property, which defaults to ":". - * - * @param dexPath - * the list of jar/apk files containing classes and resources - * @param dexOutputDir - * directory where optimized DEX files should be written - * @param libPath - * the list of directories containing native libraries; may be null - * @param parent - * the parent class loader - */ - public DexClassLoader(String dexPath, String dexOutputDir, String libPath, - ClassLoader parent) { - - super(parent); - - if (dexPath == null || dexOutputDir == null) - throw new NullPointerException(); - - mRawDexPath = dexPath; - mDexOutputPath = dexOutputDir; - mRawLibPath = libPath; - } - - /** - * Complete initialization on first use of the class loader. - */ - private synchronized void ensureInit() { - if (mInitialized) { - return; - } - - String[] dexPathList; - - mInitialized = true; - - dexPathList = mRawDexPath.split(":"); - int length = dexPathList.length; - - //System.out.println("DexClassLoader: " + dexPathList); - mFiles = new File[length]; - mZips = new ZipFile[length]; - mDexs = new DexFile[length]; - - /* open all Zip and DEX files up front */ - for (int i = 0; i < length; i++) { - System.out.println("My path is: " + dexPathList[i]); - File pathFile = new File(dexPathList[i]); - mFiles[i] = pathFile; - - if (pathFile.isFile()) { - try { - mZips[i] = new ZipFile(pathFile); - } catch (IOException ioex) { - // expecting IOException and ZipException - System.out.println("Failed opening '" + pathFile - + "': " + ioex); - //ioex.printStackTrace(); - } - - /* we need both DEX and Zip, because dex has no resources */ - try { - String outputName = - generateOutputName(dexPathList[i], mDexOutputPath); - mDexs[i] = DexFile.loadDex(dexPathList[i], outputName, 0); - } catch (IOException ioex) { - // might be a resource-only zip - System.out.println("Failed loadDex '" + pathFile - + "': " + ioex); - } - } else { - if (VERBOSE_DEBUG) - System.out.println("Not found: " + pathFile.getPath()); - } - } - - /* - * Prep for native library loading. - */ - String pathList = System.getProperty("java.library.path", "."); - String pathSep = System.getProperty("path.separator", ":"); - String fileSep = System.getProperty("file.separator", "/"); - - if (mRawLibPath != null) { - if (pathList.length() > 0) { - pathList += pathSep + mRawLibPath; - } - else { - pathList = mRawLibPath; - } - } - - mLibPaths = pathList.split(pathSep); - length = mLibPaths.length; - - // Add a '/' to the end so we don't have to do the property lookup - // and concatenation later. - for (int i = 0; i < length; i++) { - if (!mLibPaths[i].endsWith(fileSep)) - mLibPaths[i] += fileSep; - if (VERBOSE_DEBUG) - System.out.println("Native lib path " +i+ ": " + mLibPaths[i]); - } - } - - /** - * Convert a source path name and an output directory to an output - * file name. - */ - private static String generateOutputName(String sourcePathName, - String outputDir) { - - StringBuilder newStr = new StringBuilder(80); - - /* start with the output directory */ - newStr.append(outputDir); - if (!outputDir.endsWith("/")) - newStr.append("/"); - - /* get the filename component of the path */ - String sourceFileName; - int lastSlash = sourcePathName.lastIndexOf("/"); - if (lastSlash < 0) - sourceFileName = sourcePathName; - else - sourceFileName = sourcePathName.substring(lastSlash+1); - - /* - * Replace ".jar", ".zip", whatever with ".dex". We don't want to - * use ".odex", because the build system uses that for files that - * are paired with resource-only jar files. If the VM can assume - * that there's no classes.dex in the matching jar, it doesn't need - * to open the jar to check for updated dependencies, providing a - * slight performance boost at startup. The use of ".dex" here - * matches the use on files in /data/dalvik-cache. - */ - int lastDot = sourceFileName.lastIndexOf("."); - if (lastDot < 0) - newStr.append(sourceFileName); - else - newStr.append(sourceFileName, 0, lastDot); - newStr.append(".dex"); - - if (VERBOSE_DEBUG) - System.out.println("Output file will be " + newStr.toString()); - return newStr.toString(); - } - - /** - * Finds a class. This method is called by {@code loadClass()} after the - * parent ClassLoader has failed to find a loaded class of the same name. - * - * @param name - * The name of the class to search for, in a human-readable form - * like "java.lang.String" or "java.net.URLClassLoader$3$1". - * @return the {@link Class} object representing the class - * @throws ClassNotFoundException - * if the class cannot be found - */ - @Override - protected Class findClass(String name) throws ClassNotFoundException { - ensureInit(); - - if (VERBOSE_DEBUG) - System.out.println("DexClassLoader " + this - + ": findClass '" + name + "'"); - - byte[] data = null; - int length = mFiles.length; - - for (int i = 0; i < length; i++) { - if (VERBOSE_DEBUG) - System.out.println(" Now searching: " + mFiles[i].getPath()); - - if (mDexs[i] != null) { - String slashName = name.replace('.', '/'); - Class clazz = mDexs[i].loadClass(slashName, this); - if (clazz != null) { - if (VERBOSE_DEBUG) - System.out.println(" found"); - return clazz; - } - } - } - - throw new ClassNotFoundException(name + " in loader " + this); - } - - /** - * Finds a resource. This method is called by {@code getResource()} after - * the parent ClassLoader has failed to find a loaded resource of the same - * name. - * - * @param name - * The name of the resource to find - * @return the location of the resource as a URL, or {@code null} if the - * resource is not found. - */ - @Override - protected URL findResource(String name) { - ensureInit(); - - int length = mFiles.length; - - for (int i = 0; i < length; i++) { - File pathFile = mFiles[i]; - ZipFile zip = mZips[i]; - - if (zip.getEntry(name) != null) { - if (VERBOSE_DEBUG) - System.out.println(" found " + name + " in " + pathFile); - try { - // File.toURL() is compliant with RFC 1738 in always - // creating absolute path names. If we construct the - // URL by concatenating strings, we might end up with - // illegal URLs for relative names. - return new URL("jar:" + pathFile.toURL() + "!/" + name); - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - } - - if (VERBOSE_DEBUG) - System.out.println(" resource " + name + " not found"); - - return null; - } - - /** - * Finds a native library. This method is called after the parent - * ClassLoader has failed to find a native library of the same name. - * - * @param libname - * The name of the library to find - * @return the complete path of the library, or {@code null} if the library - * is not found. - */ - @Override - protected String findLibrary(String libname) { - ensureInit(); - - String fileName = System.mapLibraryName(libname); - for (int i = 0; i < mLibPaths.length; i++) { - String pathName = mLibPaths[i] + fileName; - File test = new File(pathName); - - if (test.exists()) { - if (VERBOSE_DEBUG) - System.out.println(" found " + libname); - return pathName; - } - } - - if (VERBOSE_DEBUG) - System.out.println(" library " + libname + " not found"); - return null; - } - - /** - * Returns package information for the given package. Unfortunately, the - * DexClassLoader doesn't really have this information, and as a non-secure - * ClassLoader, it isn't even required to, according to the spec. Yet, we - * want to provide it, in order to make all those hopeful callers of - * myClass.getPackage().getName() happy. Thus we construct a - * Package object the first time it is being requested and fill most of the - * fields with dummy values. The Package object is then put into the - * ClassLoader's Package cache, so we see the same one next time. We don't - * create Package objects for null arguments or for the default package. - *

- * There a limited chance that we end up with multiple Package objects - * representing the same package: It can happen when when a package is - * scattered across different JAR files being loaded by different - * ClassLoaders. Rather unlikely, and given that this whole thing is more or - * less a workaround, probably not worth the effort. - * - * @param name - * the name of the class - * @return the package information for the class, or {@code null} if there - * is not package information available for it - */ - @Override - protected Package getPackage(String name) { - if (name != null && !"".equals(name)) { - synchronized(this) { - Package pack = super.getPackage(name); - - if (pack == null) { - pack = definePackage(name, "Unknown", "0.0", "Unknown", - "Unknown", "0.0", "Unknown", null); - } - - return pack; - } - } - - return null; - } -} - diff --git a/libcore/dalvik/src/main/java/dalvik/system/DexFile.java b/libcore/dalvik/src/main/java/dalvik/system/DexFile.java deleted file mode 100644 index 00de31454..000000000 --- a/libcore/dalvik/src/main/java/dalvik/system/DexFile.java +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.system; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.security.ProtectionDomain; -import java.util.Enumeration; - - -/** - * Manipulates DEX files. The class is similar in principle to - * {@link java.util.zip.ZipFile}. It is used primarily by class loaders. - *

- * Note we don't directly open and read the DEX file here. They're memory-mapped - * read-only by the VM. - * - * @since Android 1.0 - */ -public final class DexFile { - private final int mCookie; - private String mFileName; - - /** - * Opens a DEX file from a given File object. This will usually be a ZIP/JAR - * file with a "classes.dex" inside. - * - * The VM will generate the name of the coresponding file in - * /data/dalvik-cache and open it, possibly creating or updating - * it first if system permissions allow. Don't pass in the name of - * a file in /data/dalvik-cache, as the named file is expected to be - * in its original (pre-dexopt) state. - * - * @param file - * the File object referencing the actual DEX file - * - * @throws IOException - * if an I/O error occurs, such as the file not being found or - * access rights missing for opening it - */ - public DexFile(File file) throws IOException { - this(file.getPath()); - } - - /** - * Opens a DEX file from a given filename. This will usually be a ZIP/JAR - * file with a "classes.dex" inside. - * - * The VM will generate the name of the coresponding file in - * /data/dalvik-cache and open it, possibly creating or updating - * it first if system permissions allow. Don't pass in the name of - * a file in /data/dalvik-cache, as the named file is expected to be - * in its original (pre-dexopt) state. - * - * @param fileName - * the filename of the DEX file - * - * @throws IOException - * if an I/O error occurs, such as the file not being found or - * access rights missing for opening it - */ - public DexFile(String fileName) throws IOException { - String wantDex = System.getProperty("android.vm.dexfile", "false"); - if (!wantDex.equals("true")) - throw new UnsupportedOperationException("No dex in this VM"); - - mCookie = openDexFile(fileName, null, 0); - mFileName = fileName; - //System.out.println("DEX FILE cookie is " + mCookie); - } - - /** - * Opens a DEX file from a given filename, using a specified file - * to hold the optimized data. - * - * @param sourceName - * Jar or APK file with "classes.dex". - * @param outputName - * File that will hold the optimized form of the DEX data. - * @param flags - * Enable optional features. - */ - private DexFile(String sourceName, String outputName, int flags) - throws IOException { - - String wantDex = System.getProperty("android.vm.dexfile", "false"); - if (!wantDex.equals("true")) - throw new UnsupportedOperationException("No dex in this VM"); - - mCookie = openDexFile(sourceName, outputName, flags); - mFileName = sourceName; - //System.out.println("DEX FILE cookie is " + mCookie); - } - - /** - * Open a DEX file, specifying the file in which the optimized DEX - * data should be written. If the optimized form exists and appears - * to be current, it will be used; if not, the VM will attempt to - * regenerate it. - * - * This is intended for use by applications that wish to download - * and execute DEX files outside the usual application installation - * mechanism. This function should not be called directly by an - * application; instead, use a class loader such as - * dalvik.system.DexClassLoader. - * - * @param sourcePathName - * Jar or APK file with "classes.dex". (May expand this to include - * "raw DEX" in the future.) - * @param outputPathName - * File that will hold the optimized form of the DEX data. - * @param flags - * Enable optional features. (Currently none defined.) - * @return - * A new or previously-opened DexFile. - * @throws IOException - * If unable to open the source or output file. - */ - static public DexFile loadDex(String sourcePathName, String outputPathName, - int flags) throws IOException { - - /* - * TODO: we may want to cache previously-opened DexFile objects. - * The cache would be synchronized with close(). This would help - * us avoid mapping the same DEX more than once when an app - * decided to open it multiple times. In practice this may not - * be a real issue. - */ - return new DexFile(sourcePathName, outputPathName, flags); - } - - /** - * Gets the name of the (already opened) DEX file. - * - * @return the file name - */ - public String getName() { - return mFileName; - } - - /** - * Closes the DEX file. - *

- * This may not be able to release any resources. If classes have been - * loaded, the underlying storage can't be discarded. - * - * @throws IOException - * if an I/O error occurs during closing the file, which - * normally should not happen - * - * @cts Second sentence is a bit cryptic. - */ - public void close() throws IOException { - closeDexFile(mCookie); - } - - /** - * Loads a class. Returns the class on success, or a {@code null} reference - * on failure. - *

- * If you are not calling this from a class loader, this is most likely not - * going to do what you want. Use {@link Class#forName(String)} instead. - *

- * The method does not throw {@link ClassNotFoundException} if the class - * isn't found because it isn't feasible to throw exceptions wildly every - * time a class is not found in the first DEX file we look at. It will - * throw exceptions for other failures, though. - * - * @param name - * the class name, which should look like "java/lang/String" - * - * @param loader - * the class loader that tries to load the class (in most cases - * the caller of the method - * - * @return the {@link Class} object representing the class, or {@code null} - * if the class cannot be loaded - * - * @cts Exception comment is a bit cryptic. What exception will be thrown? - */ - public Class loadClass(String name, ClassLoader loader) { - String slashName = name.replace('.', '/'); - return loadClassBinaryName(slashName, loader); - } - - /** - * See {@link #loadClass(String, ClassLoader)}. - * - * This takes a "binary" class name to better match ClassLoader semantics. - * - * {@hide} - */ - public Class loadClassBinaryName(String name, ClassLoader loader) { - return defineClass(name, loader, mCookie, - null); - //new ProtectionDomain(name) /*DEBUG ONLY*/); - } - - native private static Class defineClass(String name, ClassLoader loader, - int cookie, ProtectionDomain pd); - - /** - * Enumerate the names of the classes in this DEX file. - * - * @return an enumeration of names of classes contained in the DEX file, in - * the usual internal form (like "java/lang/String"). - */ - public Enumeration entries() { - return new DFEnum(this); - } - - /* - * Helper class. - */ - private class DFEnum implements Enumeration { - private int mIndex; - private String[] mNameList; - - DFEnum(DexFile df) { - mIndex = 0; - mNameList = getClassNameList(mCookie); - } - - public boolean hasMoreElements() { - return (mIndex < mNameList.length); - } - - public String nextElement() { - return mNameList[mIndex++]; - } - } - - /* return a String array with class names */ - native private static String[] getClassNameList(int cookie); - - /** - * Called when the class is finalized. Makes sure the DEX file is closed. - * - * @throws IOException - * if an I/O error occurs during closing the file, which - * normally should not happen - */ - protected void finalize() throws IOException { - close(); - } - - /* - * Open a DEX file. The value returned is a magic VM cookie. On - * failure, an IOException is thrown. - */ - native private static int openDexFile(String sourceName, String outputName, - int flags) throws IOException; - - /* - * Close DEX file. - */ - native private static void closeDexFile(int cookie); - - /** - * Returns true if the VM believes that the apk/jar file is out of date - * and should be passed through "dexopt" again. - * - * @param fileName the absolute path to the apk/jar file to examine. - * @return true if dexopt should be called on the file, false otherwise. - * @throws java.io.FileNotFoundException if fileName is not readable, - * not a file, or not present. - * @throws java.io.IOException if fileName is not a valid apk/jar file or - * if problems occur while parsing it. - * @throws java.lang.NullPointerException if fileName is null. - * @throws dalvik.system.StaleDexCacheError if the optimized dex file - * is stale but exists on a read-only partition. - */ - native public static boolean isDexOptNeeded(String fileName) - throws FileNotFoundException, IOException; -} - diff --git a/libcore/dalvik/src/main/java/dalvik/system/NativeStart.java b/libcore/dalvik/src/main/java/dalvik/system/NativeStart.java deleted file mode 100644 index ee360fffd..000000000 --- a/libcore/dalvik/src/main/java/dalvik/system/NativeStart.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.system; - -/** - * Dummy class used during JNI initialization. The JNI functions want - * to be able to create objects, and the VM needs to discard the references - * when the function returns. That gets a little weird when we're - * calling JNI functions from the C main(), and there's no Java stack frame - * to hitch the references onto. - * - * Rather than having some special-case code, we create this simple little - * class and pretend that it called the C main(). - * - * This also comes in handy when a native thread attaches itself with the - * JNI AttachCurrentThread call. If they attach the thread and start - * creating objects, we need a fake frame to store stuff in. - */ -class NativeStart implements Runnable { - private NativeStart() {} - - private static native void main(String[] dummy); - - public native void run(); -} - diff --git a/libcore/dalvik/src/main/java/dalvik/system/PathClassLoader.java b/libcore/dalvik/src/main/java/dalvik/system/PathClassLoader.java deleted file mode 100644 index 597eb5b99..000000000 --- a/libcore/dalvik/src/main/java/dalvik/system/PathClassLoader.java +++ /dev/null @@ -1,498 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.system; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.net.URL; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.NoSuchElementException; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -import java.net.MalformedURLException; - -import dalvik.system.DexFile; - -/** - * Provides a simple {@link ClassLoader} implementation that operates on a list - * of files and directories in the local file system, but does not attempt to - * load classes from the network. Android uses this class for its system class - * loader and for its application class loader(s). - * - * @since Android 1.0 - */ -public class PathClassLoader extends ClassLoader { - - private final String path; - private final String libPath; - - private boolean initialized; - - private String[] mPaths; - private File[] mFiles; - private ZipFile[] mZips; - private DexFile[] mDexs; - private String[] mLibPaths; - - /** - * Creates a {@code PathClassLoader} that operates on a given list of files - * and directories. This method is equivalent to calling - * {@link #PathClassLoader(String, String, ClassLoader)} with a - * {@code null} value for the second argument (see description there). - * - * @param path - * the list of files and directories - * - * @param parent - * the parent class loader - */ - public PathClassLoader(String path, ClassLoader parent) { - this(path, null, parent); - } - - /** - * Creates a {@code PathClassLoader} that operates on two given lists of - * files and directories. The entries of the first list should be one of the - * following: - *

    - *
  • Directories containing classes or resources. - *
  • JAR/ZIP/APK files, possibly containing a "classes.dex" file. - *
  • "classes.dex" files. - *
- * The entries of the second list should be directories containing native - * library files. Both lists are separated using the character specified by - * the "path.separator" system property, which, on Android, defaults to ":". - * - * @param path - * the list of files and directories containing classes and - * resources - * - * @param libPath - * the list of directories containing native libraries - * - * @param parent - * the parent class loader - */ - public PathClassLoader(String path, String libPath, ClassLoader parent) { - super(parent); - - if (path == null) - throw new NullPointerException(); - - this.path = path; - this.libPath = libPath; - } - - private synchronized void ensureInit() { - if (initialized) { - return; - } - - initialized = true; - - mPaths = path.split(":"); - int length = mPaths.length; - - //System.out.println("PathClassLoader: " + mPaths); - mFiles = new File[length]; - mZips = new ZipFile[length]; - mDexs = new DexFile[length]; - - boolean wantDex = - System.getProperty("android.vm.dexfile", "").equals("true"); - - /* open all Zip and DEX files up front */ - for (int i = 0; i < length; i++) { - //System.out.println("My path is: " + mPaths[i]); - File pathFile = new File(mPaths[i]); - mFiles[i] = pathFile; - - if (pathFile.isFile()) { - try { - mZips[i] = new ZipFile(pathFile); - } - catch (IOException ioex) { - // expecting IOException and ZipException - //System.out.println("Failed opening '" + archive + "': " + ioex); - //ioex.printStackTrace(); - } - if (wantDex) { - /* we need both DEX and Zip, because dex has no resources */ - try { - mDexs[i] = new DexFile(pathFile); - } - catch (IOException ioex) {} - } - } - } - - /* - * Prep for native library loading. - */ - String pathList = System.getProperty("java.library.path", "."); - String pathSep = System.getProperty("path.separator", ":"); - String fileSep = System.getProperty("file.separator", "/"); - - if (libPath != null) { - if (pathList.length() > 0) { - pathList += pathSep + libPath; - } - else { - pathList = libPath; - } - } - - mLibPaths = pathList.split(pathSep); - length = mLibPaths.length; - - // Add a '/' to the end so we don't have to do the property lookup - // and concatenation later. - for (int i = 0; i < length; i++) { - if (!mLibPaths[i].endsWith(fileSep)) - mLibPaths[i] += fileSep; - if (false) - System.out.println("Native lib path: " + mLibPaths[i]); - } - } - - /** - * Finds a class. This method is called by {@code loadClass()} after the - * parent ClassLoader has failed to find a loaded class of the same name. - * - * @param name - * The "binary name" of the class to search for, in a - * human-readable form like "java.lang.String" or - * "java.net.URLClassLoader$3$1". - * @return the {@link Class} object representing the class - * @throws ClassNotFoundException - * if the class cannot be found - */ - @Override - protected Class findClass(String name) throws ClassNotFoundException - { - ensureInit(); - - //System.out.println("PathClassLoader " + this + ": findClass '" + name + "'"); - - byte[] data = null; - int length = mPaths.length; - - for (int i = 0; i < length; i++) { - //System.out.println("My path is: " + mPaths[i]); - - if (mDexs[i] != null) { - Class clazz = mDexs[i].loadClassBinaryName(name, this); - if (clazz != null) - return clazz; - } else if (mZips[i] != null) { - String fileName = name.replace('.', '/') + ".class"; - data = loadFromArchive(mZips[i], fileName); - } else { - File pathFile = mFiles[i]; - if (pathFile.isDirectory()) { - String fileName = - mPaths[i] + "/" + name.replace('.', '/') + ".class"; - data = loadFromDirectory(fileName); - } else { - //System.out.println("PathClassLoader: can't find '" - // + mPaths[i] + "'"); - } - - } - - /* --this doesn't work in current version of Dalvik-- - if (data != null) { - System.out.println("--- Found class " + name - + " in zip[" + i + "] '" + mZips[i].getName() + "'"); - int dotIndex = name.lastIndexOf('.'); - if (dotIndex != -1) { - String packageName = name.substring(0, dotIndex); - synchronized (this) { - Package packageObj = getPackage(packageName); - if (packageObj == null) { - definePackage(packageName, null, null, - null, null, null, null, null); - } - } - } - - return defineClass(name, data, 0, data.length); - } - */ - } - - throw new ClassNotFoundException(name + " in loader " + this); - } - - /** - * Finds a resource. This method is called by {@code getResource()} after - * the parent ClassLoader has failed to find a loaded resource of the same - * name. - * - * @param name - * The name of the resource to find - * @return the location of the resource as a URL, or {@code null} if the - * resource is not found. - */ - @Override - protected URL findResource(String name) { - ensureInit(); - - //java.util.logging.Logger.global.severe("findResource: " + name); - - int length = mPaths.length; - - for (int i = 0; i < length; i++) { - URL result = findResource(name, i); - if(result != null) { - return result; - } - } - - return null; - } - - /** - * Finds an enumeration of URLs for the resource with the specified name. - * - * @param resName - * the name of the resource to find. - * @return an enumeration of {@code URL} objects for the requested resource. - * @since Android 1.0 - */ - @Override - protected Enumeration findResources(String resName) { - ensureInit(); - - int length = mPaths.length; - ArrayList results = new ArrayList(); - - for (int i = 0; i < length; i++) { - URL result = findResource(resName, i); - if(result != null) { - results.add(result); - } - } - return new EnumerateListArray(results); - } - - private URL findResource(String name, int i) { - File pathFile = mFiles[i]; - ZipFile zip = mZips[i]; - if (zip != null) { - if (isInArchive(zip, name)) { - //System.out.println(" found " + name + " in " + pathFile); - try { - // File.toURL() is compliant with RFC 1738 in always - // creating absolute path names. If we construct the - // URL by concatenating strings, we might end up with - // illegal URLs for relative names. - return new URL("jar:" + pathFile.toURL() + "!/" + name); - } - catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - } else if (pathFile.isDirectory()) { - File dataFile = new File(mPaths[i] + "/" + name); - if (dataFile.exists()) { - //System.out.println(" found resource " + name); - try { - // Same as archive case regarding URL construction. - return dataFile.toURL(); - } - catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - } else if (pathFile.isFile()) { - } else { - System.err.println("PathClassLoader: can't find '" - + mPaths[i] + "'"); - } - return null; - } - - /* - * Load the contents of a file from a file in a directory. - * - * Returns null if the class wasn't found. - */ - private byte[] loadFromDirectory(String path) { - RandomAccessFile raf; - byte[] fileData; - - //System.out.println("Trying to load from " + path); - try { - raf = new RandomAccessFile(path, "r"); - } - catch (FileNotFoundException fnfe) { - //System.out.println(" Not found: " + path); - return null; - } - - try { - fileData = new byte[(int) raf.length()]; - raf.read(fileData); - raf.close(); - } - catch (IOException ioe) { - System.err.println("Error reading from " + path); - // swallow it, return null instead - fileData = null; - } - - return fileData; - } - - /* - * Load a class from a file in an archive. We currently assume that - * the file is a Zip archive. - * - * Returns null if the class wasn't found. - */ - private byte[] loadFromArchive(ZipFile zip, String name) { - ZipEntry entry; - - entry = zip.getEntry(name); - if (entry == null) - return null; - - ByteArrayOutputStream byteStream; - InputStream stream; - int count; - - /* - * Copy the data out of the stream. Because we got the ZipEntry - * from a ZipFile, the uncompressed size is known, and we can set - * the initial size of the ByteArrayOutputStream appropriately. - */ - try { - stream = zip.getInputStream(entry); - byteStream = new ByteArrayOutputStream((int) entry.getSize()); - byte[] buf = new byte[4096]; - while ((count = stream.read(buf)) > 0) - byteStream.write(buf, 0, count); - - stream.close(); - } - catch (IOException ioex) { - //System.out.println("Failed extracting '" + archive + "': " +ioex); - return null; - } - - //System.out.println(" loaded from Zip"); - return byteStream.toByteArray(); - } - - /* - * Figure out if "name" is a member of "archive". - */ - private boolean isInArchive(ZipFile zip, String name) { - return zip.getEntry(name) != null; - } - - /** - * Finds a native library. This method is called after the parent - * ClassLoader has failed to find a native library of the same name. - * - * @param libname - * The name of the library to find - * @return the complete path of the library, or {@code null} if the library - * is not found. - */ - protected String findLibrary(String libname) { - ensureInit(); - - String fileName = System.mapLibraryName(libname); - for (int i = 0; i < mLibPaths.length; i++) { - String pathName = mLibPaths[i] + fileName; - File test = new File(pathName); - - if (test.exists()) - return pathName; - } - - return null; - } - - /** - * Returns package information for the given package. Unfortunately, the - * PathClassLoader doesn't really have this information, and as a non-secure - * ClassLoader, it isn't even required to, according to the spec. Yet, we - * want to provide it, in order to make all those hopeful callers of - * myClass.getPackage().getName() happy. Thus we construct a - * Package object the first time it is being requested and fill most of the - * fields with dummy values. The Package object is then put into the - * ClassLoader's Package cache, so we see the same one next time. We don't - * create Package objects for null arguments or for the default package. - *

- * There a limited chance that we end up with multiple Package objects - * representing the same package: It can happen when when a package is - * scattered across different JAR files being loaded by different - * ClassLoaders. Rather unlikely, and given that this whole thing is more or - * less a workaround, probably not worth the effort. - * - * @param name - * the name of the class - * @return the package information for the class, or {@code null} if there - * is not package information available for it - */ - @Override - protected Package getPackage(String name) { - if (name != null && !"".equals(name)) { - synchronized(this) { - Package pack = super.getPackage(name); - - if (pack == null) { - pack = definePackage(name, "Unknown", "0.0", "Unknown", "Unknown", "0.0", "Unknown", null); - } - - return pack; - } - } - - return null; - } - - /* - * Create an Enumeration for an ArrayList. - */ - private static class EnumerateListArray implements Enumeration { - private final ArrayList mList; - private int i = 0; - - EnumerateListArray(ArrayList list) { - mList = list; - } - - public boolean hasMoreElements() { - return i < mList.size(); - } - - public T nextElement() { - if (i >= mList.size()) - throw new NoSuchElementException(); - return (T) mList.get(i++); - } - }; -} diff --git a/libcore/dalvik/src/main/java/dalvik/system/PotentialDeadlockError.java b/libcore/dalvik/src/main/java/dalvik/system/PotentialDeadlockError.java deleted file mode 100644 index 938a5cd6e..000000000 --- a/libcore/dalvik/src/main/java/dalvik/system/PotentialDeadlockError.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.system; - -/** - * Is thrown when the VM identifies a potential deadlock. - * - * @deprecated this is an internal Dalvik class that is not appropriate for - * general use. It will be removed from the public API in a future release. - */ -public class PotentialDeadlockError extends VirtualMachineError { - /** - * Creates a new exception instance and initializes it with default values. - */ - public PotentialDeadlockError() { - super(); - } - - /** - * Creates a new exception instance and initializes it with a given message. - * - * @param detailMessage the error message - */ - public PotentialDeadlockError(String detailMessage) { - super(detailMessage); - } -} - diff --git a/libcore/dalvik/src/main/java/dalvik/system/SamplingProfiler.java b/libcore/dalvik/src/main/java/dalvik/system/SamplingProfiler.java deleted file mode 100644 index 1d88dd170..000000000 --- a/libcore/dalvik/src/main/java/dalvik/system/SamplingProfiler.java +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.system; - -import java.util.logging.Logger; -import java.io.DataInputStream; -import java.io.ByteArrayInputStream; -import java.io.IOException; - -/** - * A sampling profiler. - * - * @hide - */ -public class SamplingProfiler { - - private static final Logger logger = Logger.getLogger( - SamplingProfiler.class.getName()); - - static final boolean DEBUG = false; - - enum State { - /** The sampling thread hasn't started or is waiting to resume. */ - PAUSED, - /** The sampling thread is collecting samples. */ - RUNNING, - /** The sampling thread is shutting down. */ - SHUTTING_DOWN - } - - /** Pointer to native state. */ - int pointer = 0; - - /** The thread that collects samples. */ - Thread samplingThread; - - /** Time between samples. */ - volatile int delay; // ms - - /** Number of samples taken (~samples per second * number of threads). */ - int totalThreadsSampled = 0; - - /** Total time spent collecting samples. */ - long totalSampleTime = 0; - - /** The state of the profiler. */ - volatile State state = State.PAUSED; - - private SamplingProfiler() {} - - /** - * Returns true if the profiler is running. - */ - public boolean isRunning() { - return state == State.RUNNING; - } - - /** - * Starts collecting samples. - * - * @param samplesPerSecond number of times to sample each thread per second - * @throws IllegalStateException if the profiler is - * {@linkplain #shutDown()} shutting down} - */ - public synchronized void start(int samplesPerSecond) { - if (samplesPerSecond < 1) { - throw new IllegalArgumentException("samplesPerSecond < 1"); - } - ensureNotShuttingDown(); - delay = 1000 / samplesPerSecond; - if (!isRunning()) { - if (DEBUG) logger.info("Starting profiler..."); - state = State.RUNNING; - if (samplingThread == null) { - // TODO: Priority? - samplingThread = new Thread(new Sampler(), "SamplingProfiler"); - samplingThread.setDaemon(true); - samplingThread.start(); - } else { - notifyAll(); - } - } - } - - /** - * Pauses sample collection. - */ - public synchronized void pause() { - if (isRunning()) { - if (DEBUG) logger.info("Pausing profiler..."); - state = State.PAUSED; - } - } - - /** - * Captures collected samples and clears the sample set. Returns null - * if no data has been captured. - * - *

Note: The exact format is not documented because it's not set in - * stone yet. - * - * @throws IllegalStateException if the profiler is - * {@linkplain #shutDown()} shutting down} - */ - public synchronized byte[] snapshot() { - ensureNotShuttingDown(); - if (pointer == 0 || totalThreadsSampled == 0) { - return null; - } - - if (DEBUG) { - int size = size(pointer); - int collisions = collisions(pointer); - - long start = System.nanoTime(); - byte[] bytes = snapshot(pointer); - long elapsed = System.nanoTime() - start; - - /* - * We shifted the times by 10 bits in the sampling thread to avoid - * overflow. Undo the shift and then convert from ns to us. - */ - long averageSampleTime = ((totalSampleTime / totalThreadsSampled) - << 10) / 1000; - logger.info("Grabbed snapshot in " + (elapsed / 1000) + "us." - + " Samples collected: " + totalThreadsSampled - + ", Average sample time (per thread): " - + averageSampleTime + "us" - + ", Set size: " + size - + ", Collisions: " + collisions); - totalThreadsSampled = 0; - totalSampleTime = 0; - - return bytes; - } else { - totalThreadsSampled = 0; - return snapshot(pointer); - } - } - - /** - * Identifies the "event thread". For a user-facing application, this - * might be the UI thread. For a background process, this might be the - * thread that processes incoming requests. - * - * @throws IllegalStateException if the profiler is - * {@linkplain #shutDown()} shutting down} - */ - public synchronized void setEventThread(Thread eventThread) { - ensureNotShuttingDown(); - if (pointer == 0) { - pointer = allocate(); - } - setEventThread(pointer, eventThread); - } - - private void ensureNotShuttingDown() { - if (state == State.SHUTTING_DOWN) { - throw new IllegalStateException("Profiler is shutting down."); - } - } - - /** - * Shuts down the profiler thread and frees native memory. The profiler - * will recreate the thread the next time {@link #start(int)} is called. - * - * @throws IllegalStateException if the profiler is already shutting down - * or if it hasn't started yet - * - */ - public void shutDown() { - Thread toStop; - synchronized (this) { - ensureNotShuttingDown(); - - toStop = samplingThread; - if (toStop == null) { - throw new IllegalStateException( - "The profiler was never started."); - } - - state = State.SHUTTING_DOWN; - samplingThread = null; - notifyAll(); - } - - // Release lock to 'this' so background thread can grab it and stop. - // Interrupt the thread in case it's sleeping. - toStop.interrupt(); - while (true) { - try { - toStop.join(); - break; - } catch (InterruptedException e) { /* ignore */ } - } - - synchronized (this) { - if (pointer != 0) { - free(pointer); - pointer = 0; - } - - totalThreadsSampled = 0; - totalSampleTime = 0; - state = State.PAUSED; - } - } - - /** Collects some data. Returns number of threads sampled. */ - private static native int sample(int pointer); - - /** Allocates native state. */ - private static native int allocate(); - - /** Frees native state. */ - private static native void free(int pointer); - - /** Gets the number of methods in the sample set. */ - private static native int size(int pointer); - - /** Gets the number of collisions in the sample set. */ - private static native int collisions(int pointer); - - /** Captures data. */ - private static native byte[] snapshot(int pointer); - - /** Identifies the "event thread". */ - private static native void setEventThread(int pointer, Thread thread); - - /** - * Background thread that collects samples. - */ - class Sampler implements Runnable { - public void run() { - boolean firstSample = true; - while (true) { - synchronized (SamplingProfiler.this) { - if (!isRunning()) { - if (DEBUG) logger.info("Paused profiler."); - while (!isRunning()) { - if (state == State.SHUTTING_DOWN) { - // Stop thread. - return; - } - - try { - SamplingProfiler.this.wait(); - } catch (InterruptedException e) { /* ignore */ } - } - firstSample = true; - } - - if (pointer == 0) { - pointer = allocate(); - } - - if (firstSample) { - if (DEBUG) logger.info("Started profiler."); - firstSample = false; - } - - if (DEBUG) { - long start = System.nanoTime(); - int threadsSampled = sample(pointer); - long elapsed = System.nanoTime() - start; - - totalThreadsSampled += threadsSampled; - totalSampleTime += elapsed >> 10; // avoids overflow. - } else { - totalThreadsSampled += sample(pointer); - } - } - - try { - Thread.sleep(delay); - } catch (InterruptedException e) { /* ignore */ } - } - } - } - - /** - * Dumps a snapshot to the log. Useful for debugging. - */ - public static void logSnapshot(byte[] snapshot) { - DataInputStream in = new DataInputStream( - new ByteArrayInputStream(snapshot)); - try { - int version = in.readUnsignedShort(); - int classCount = in.readUnsignedShort(); - StringBuilder sb = new StringBuilder(); - sb.append("version=").append(version).append(' ') - .append("classes=").append(classCount).append('\n'); - logger.info(sb.toString()); - for (int i = 0; i < classCount; i++) { - sb = new StringBuilder(); - sb.append("class ").append(in.readUTF()).append('\n'); - int methodCount = in.readUnsignedShort(); - for (int m = 0; m < methodCount; m++) { - sb.append(" ").append(in.readUTF()).append(":\n"); - sb.append(" event:\n"); - appendCounts(in, sb); - sb.append(" other:\n"); - appendCounts(in, sb); - } - logger.info(sb.toString()); - } - } catch (IOException e) { - logger.warning(e.toString()); - } - } - - private static void appendCounts(DataInputStream in, StringBuilder sb) - throws IOException { - sb.append(" running:\n"); - sb.append(" caller: ").append(in.readShort()).append('\n'); - sb.append(" leaf: ").append(in.readShort()).append('\n'); - sb.append(" suspended:\n"); - sb.append(" caller: ").append(in.readShort()).append('\n'); - sb.append(" leaf: ").append(in.readShort()).append('\n'); - } - - /** This will be allocated when the user calls getInstance(). */ - private static final SamplingProfiler instance = new SamplingProfiler(); - - /** - * Gets the profiler. The profiler is not running by default. Start it - * with {@link #start(int)}. - */ - public static synchronized SamplingProfiler getInstance() { - return instance; - } -} diff --git a/libcore/dalvik/src/main/java/dalvik/system/StaleDexCacheError.java b/libcore/dalvik/src/main/java/dalvik/system/StaleDexCacheError.java deleted file mode 100644 index ffde7cb21..000000000 --- a/libcore/dalvik/src/main/java/dalvik/system/StaleDexCacheError.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.system; - -/** - * Is thrown when the VM determines that a DEX file's cache is out of date, and - * that there is no way to recreate it. - * - * @deprecated this is an internal Dalvik class that is not appropriate for - * general use. It will be removed from the public API in a future release. - */ -public class StaleDexCacheError extends VirtualMachineError { - /** - * Creates a new exception instance and initializes it with default values. - */ - public StaleDexCacheError() { - super(); - } - - /** - * Creates a new exception instance and initializes it with a given message. - * - * @param detailMessage the error message - */ - public StaleDexCacheError(String detailMessage) { - super(detailMessage); - } -} diff --git a/libcore/dalvik/src/main/java/dalvik/system/TemporaryDirectory.java b/libcore/dalvik/src/main/java/dalvik/system/TemporaryDirectory.java deleted file mode 100644 index 0e26a70ed..000000000 --- a/libcore/dalvik/src/main/java/dalvik/system/TemporaryDirectory.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.system; - -import java.io.File; -import java.util.logging.Logger; - -/** - * Utility class to handle the setup of the core library's concept of - * what the "default temporary directory" is. Application code may - * call into this class with an appropriate base directory during its - * startup, as a reasonably easy way to get the standard property - * java.io.tmpdir to point at something useful. - * - * @deprecated this is an internal Dalvik class that is not appropriate for - * general use. It will be removed from the public API in a future release. - */ -public class TemporaryDirectory { - /** system property name for the temporary directory */ - private static final String PROPERTY = "java.io.tmpdir"; - - /** final path component name for the temporary directory */ - private static final String PATH_NAME = "tmp"; - - /** whether a temporary directory has been configured yet */ - private static boolean configured = false; - - /** - * Convenience method which is equivalent to - * setupDirectory(new File(baseDir)). - * - * @param baseDir the base directory of the temporary directory - */ - public static void setUpDirectory(String baseDir) { - setUpDirectory(new File(baseDir)); - } - - /** - * Sets up the temporary directory, but only if one isn't already - * defined for this process, and only if it is possible (e.g., the - * directory already exists and is read-write, or the directory - * can be created). This call will do one of three things: - * - *

    - *
  • return without error and without doing anything, if a - * previous call to this method succeeded
  • - *
  • return without error, having either created a temporary - * directory under the given base or verified that such a directory - * already exists
  • - *
  • throw UnsupportedOperationException if the - * directory could not be created or accessed
  • - *
- * - * @param baseDir the base directory of the temporary directory - */ - public static synchronized void setUpDirectory(File baseDir) { - if (configured) { - Logger.global.info("Already set to: " + - System.getProperty(PROPERTY)); - return; - } - - File dir = new File(baseDir, PATH_NAME); - String absolute = dir.getAbsolutePath(); - - if (dir.exists()) { - if (!dir.isDirectory()) { - throw new UnsupportedOperationException( - "Name is used by a non-directory file: " + - absolute); - } else if (!(dir.canRead() && dir.canWrite())) { - throw new UnsupportedOperationException( - "Existing directory is not readable and writable: " + - absolute); - } - } else { - if (!dir.mkdirs()) { - throw new UnsupportedOperationException( - "Failed to create directory: " + absolute); - } - } - - System.setProperty(PROPERTY, absolute); - configured = true; - } -} diff --git a/libcore/dalvik/src/main/java/dalvik/system/TouchDex.java b/libcore/dalvik/src/main/java/dalvik/system/TouchDex.java deleted file mode 100644 index 04c654656..000000000 --- a/libcore/dalvik/src/main/java/dalvik/system/TouchDex.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.system; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.io.IOException; -import java.io.File; -import java.io.FilenameFilter; - -/** - * Induces optimization/verification of a set of DEX files. - * - * @deprecated this is an internal Dalvik class that is not appropriate for - * general use. It will be removed from the public API in a future release. - */ -public class TouchDex { - - /** - * Forks a process, makes sure the DEX files are prepared, and returns - * when everything is finished. - *

- * The filenames must be the same as will be used when the files are - * actually opened, because the dalvik-cache filename is based upon - * this filename. (The absolute path to the JAR/ZIP/APK should work.) - * - * @param dexFiles a colon-separated list of DEX files. - * @return zero on success - * - * @cts What about error cases? - */ - public static int start(String dexFiles) { - return trampoline(dexFiles, System.getProperty("java.boot.class.path")); - } - - /** - * This calls fork() and then, in the child, calls cont(dexFiles). - * - * @param dexFiles Colon-separated list of DEX files. - * @return zero on success - */ - native private static int trampoline(String dexFiles, String bcp); - - /** - * The entry point for the child process. args[0] can be a colon-separated - * path list, or "-" to read from stdin. - *

- * Alternatively, if we're invoked directly from the command line we - * just start here (skipping the fork/exec stuff). - * - * @param args command line args - */ - public static void main(String[] args) { - - if ("-".equals(args[0])) { - BufferedReader in = new BufferedReader( - new InputStreamReader(System.in), 256); - - String line; - try { - while ((line = in.readLine()) != null) { - prepFiles(line); - } - } catch (IOException ex) { - throw new RuntimeException ("Error processing stdin"); - } - } else { - prepFiles(args[0]); - } - - System.out.println(" Prep complete"); - } - - - private static String expandDirectories(String dexPath) { - String[] parts = dexPath.split(":"); - StringBuilder outPath = new StringBuilder(dexPath.length()); - - // A filename filter accepting *.jar and *.apk - FilenameFilter filter = new FilenameFilter() { - public boolean accept(File dir, String name) { - return name.endsWith(".jar") || name.endsWith(".apk"); - } - }; - - for (String part: parts) { - File f = new File(part); - - if (f.isFile()) { - outPath.append(part); - outPath.append(':'); - } else if (f.isDirectory()) { - String[] filenames = f.list(filter); - - if (filenames == null) { - System.err.println("I/O error with directory: " + part); - continue; - } - - for (String filename: filenames) { - outPath.append(part); - outPath.append(File.separatorChar); - outPath.append(filename); - outPath.append(':'); - } - } else { - System.err.println("File not found: " + part); - } - } - - - return outPath.toString(); - } - - private static void prepFiles(String dexPath) { - - System.out.println(" Prepping: " + dexPath); - - TouchDexLoader loader - = new TouchDexLoader(expandDirectories(dexPath), null); - - try { - /* By looking for a nonexistent class, we'll trick TouchDexLoader - * into trying to load something from every file on dexPath, - * optimizing all of them as a side-effect. - * - * The optimization happens implicitly in the VM the first time - * someone tries to load a class from an unoptimized dex file. - */ - loader.loadClass("com.google.NonexistentClassNeverFound"); - throw new RuntimeException("nonexistent class loaded?!"); - } catch (ClassNotFoundException cnfe) { - //System.out.println("got expected dnfe"); - } - } -} - diff --git a/libcore/dalvik/src/main/java/dalvik/system/TouchDexLoader.java b/libcore/dalvik/src/main/java/dalvik/system/TouchDexLoader.java deleted file mode 100644 index 18669c560..000000000 --- a/libcore/dalvik/src/main/java/dalvik/system/TouchDexLoader.java +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.system; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.net.URL; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -import java.net.MalformedURLException; - -import dalvik.system.DexFile; - -/** - * Cloned out of PathClassLoader for TouchDex. This could be made - * substantially smaller, since we don't need most of this. - */ -class TouchDexLoader extends ClassLoader { - - private String path; - - private boolean initialized; - - /** - * Create a ClassLoader that finds files in the specified path. - */ - public TouchDexLoader(String path, ClassLoader parent) { - super(parent); - - if (path == null) - throw new NullPointerException(); - - this.path = path; - } - - private void ensureInit() { - if (initialized) { - return; - } - - initialized = true; - - mPaths = path.split(":"); - //System.out.println("TouchDexLoader: " + mPaths); - mFiles = new File[mPaths.length]; - mZips = new ZipFile[mPaths.length]; - mDexs = new DexFile[mPaths.length]; - - boolean wantDex = - System.getProperty("android.vm.dexfile", "").equals("true"); - - /* open all Zip and DEX files up front */ - for (int i = 0; i < mPaths.length; i++) { - //System.out.println("My path is: " + mPaths[i]); - File pathFile = new File(mPaths[i]); - mFiles[i] = pathFile; - - if (pathFile.isFile()) { - if (false) { //-------------------- - try { - mZips[i] = new ZipFile(pathFile); - } - catch (IOException ioex) { - // expecting IOException and ZipException - //System.out.println("Failed opening '" + archive + "': " + ioex); - //ioex.printStackTrace(); - } - } //-------------------- - if (wantDex) { - /* we need both DEX and Zip, because dex has no resources */ - try { - mDexs[i] = new DexFile(pathFile); - } - catch (IOException ioex) { - System.err.println("Couldn't open " + mPaths[i] - + " as DEX"); - } - } - } else { - System.err.println("File not found: " + mPaths[i]); - } - } - - /* - * Prep for native library loading. - */ - String pathList = System.getProperty("java.library.path", "."); - String pathSep = System.getProperty("path.separator", ":"); - String fileSep = System.getProperty("file.separator", "/"); - - mLibPaths = pathList.split(pathSep); - - // Add a '/' to the end so we don't have to do the property lookup - // and concatenation later. - for (int i = 0; i < mLibPaths.length; i++) { - if (!mLibPaths[i].endsWith(fileSep)) - mLibPaths[i] += fileSep; - if (false) - System.out.println("Native lib path: " + mLibPaths[i]); - } - } - - /** - * Find the class with the specified name. None of our ancestors were - * able to find it, so it's up to us now. - * - * "name" is a "binary name", e.g. "java.lang.String" or - * "java.net.URLClassLoader$3$1". - * - * This method will either return a valid Class object or throw an - * exception. Does not return null. - */ - protected Class findClass(String name) throws ClassNotFoundException - { - ensureInit(); - - byte[] data = null; - int i; - - //System.out.println("TouchDexLoader " + this + ": findClass '" + name + "'"); - - for (i = 0; i < mPaths.length; i++) { - //System.out.println("My path is: " + mPaths[i]); - - if (mDexs[i] != null) { - String slashName = name.replace('.', '/'); - Class clazz = mDexs[i].loadClass(slashName, this); - if (clazz != null) - return clazz; - } else if (mZips[i] != null) { - String fileName = name.replace('.', '/') + ".class"; - data = loadFromArchive(mZips[i], fileName); - } else { - File pathFile = mFiles[i]; - if (pathFile.isDirectory()) { - String fileName = - mPaths[i] + "/" + name.replace('.', '/') + ".class"; - data = loadFromDirectory(fileName); - } else { - //System.out.println("TouchDexLoader: can't find '" - // + mPaths[i] + "'"); - } - - } - - if (data != null) { - //System.out.println(" found class " + name); - int dotIndex = name.lastIndexOf('.'); - if (dotIndex != -1) { - String packageName = name.substring(0, dotIndex); - synchronized (this) { - Package packageObj = getPackage(packageName); - if (packageObj == null) { - definePackage(packageName, null, null, - null, null, null, null, null); - } - } - } - - return defineClass(name, data, 0, data.length); - } - } - - throw new ClassNotFoundException(name + " in loader " + this); - } - - /* - * Find a resource by name. This could be in a directory or in an - * archive. - */ - protected URL findResource(String name) { - ensureInit(); - - byte[] data = null; - int i; - - //System.out.println("TouchDexLoader: findResource '" + name + "'"); - - for (i = 0; i < mPaths.length; i++) { - File pathFile = mFiles[i]; - ZipFile zip = mZips[i]; - if (zip != null) { - if (isInArchive(zip, name)) { - //System.out.println(" found " + name + " in " + pathFile); - // Create URL correctly - was XXX, new code should be ok. - try { - return new URL("jar:file://" + pathFile + "!/" + name); - } - catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - } else if (pathFile.isDirectory()) { - File dataFile = new File(mPaths[i] + "/" + name); - if (dataFile.exists()) { - //System.out.println(" found resource " + name); - // Create URL correctly - was XXX, new code should be ok. - try { - return new URL("file:" + name); - } - catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - } else if (pathFile.isFile()) { - } else { - System.err.println("TouchDexLoader: can't find '" - + mPaths[i] + "'"); - } - } - - return null; - } - - - /* - * Load the contents of a file from a file in a directory. - * - * Returns null if the class wasn't found. - */ - private byte[] loadFromDirectory(String path) { - RandomAccessFile raf; - byte[] fileData; - - //System.out.println("Trying to load from " + path); - try { - raf = new RandomAccessFile(path, "r"); - } - catch (FileNotFoundException fnfe) { - //System.out.println(" Not found: " + path); - return null; - } - - try { - fileData = new byte[(int) raf.length()]; - raf.read(fileData); - raf.close(); - } - catch (IOException ioe) { - System.err.println("Error reading from " + path); - // swallow it, return null instead - fileData = null; - } - - return fileData; - } - - /* - * Load a class from a file in an archive. We currently assume that - * the file is a Zip archive. - * - * Returns null if the class wasn't found. - */ - private byte[] loadFromArchive(ZipFile zip, String name) { - ZipEntry entry; - - entry = zip.getEntry(name); - if (entry == null) - return null; - - ByteArrayOutputStream byteStream; - InputStream stream; - int count; - - /* - * Copy the data out of the stream. Because we got the ZipEntry - * from a ZipFile, the uncompressed size is known, and we can set - * the initial size of the ByteArrayOutputStream appropriately. - */ - try { - stream = zip.getInputStream(entry); - byteStream = new ByteArrayOutputStream((int) entry.getSize()); - byte[] buf = new byte[4096]; - while ((count = stream.read(buf)) > 0) - byteStream.write(buf, 0, count); - - stream.close(); - } - catch (IOException ioex) { - //System.out.println("Failed extracting '" + archive + "': " +ioex); - return null; - } - - //System.out.println(" loaded from Zip"); - return byteStream.toByteArray(); - } - - /* - * Figure out if "name" is a member of "archive". - */ - private boolean isInArchive(ZipFile zip, String name) { - return zip.getEntry(name) != null; - } - - /** - * Find a native library. - * - * Return the full pathname of the first appropriate-looking file - * we find. - */ - protected String findLibrary(String libname) { - ensureInit(); - - String fileName = System.mapLibraryName(libname); - for (int i = 0; i < mLibPaths.length; i++) { - String pathName = mLibPaths[i] + fileName; - File test = new File(pathName); - - if (test.exists()) - return pathName; - } - - return null; - } - - private String[] mPaths; - private File[] mFiles; - private ZipFile[] mZips; - private DexFile[] mDexs; - private String[] mLibPaths; -} - diff --git a/libcore/dalvik/src/main/java/dalvik/system/VMDebug.java b/libcore/dalvik/src/main/java/dalvik/system/VMDebug.java deleted file mode 100644 index 365388aaa..000000000 --- a/libcore/dalvik/src/main/java/dalvik/system/VMDebug.java +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.system; - -import java.io.FileDescriptor; -import java.io.IOException; - -/** - * Provides access to some VM-specific debug features. Though this class and - * many of its members are public, this class is meant to be wrapped in a more - * friendly way for use by application developers. On the Android platform, the - * recommended way to access this functionality is through the class - * android.os.Debug. - * - * @cts Please complete the spec. - * - * @deprecated this is an internal Dalvik class that is not appropriate for - * general use. It will be removed from the public API in a future release. - */ -public final class VMDebug { - /** - * Specifies the default method trace data file name. - */ - static public final String DEFAULT_METHOD_TRACE_FILE_NAME = "/sdcard/dmtrace.trace"; - - /** - * flag for startMethodTracing(), which adds the results from - * startAllocCounting to the trace key file. - */ - public static final int TRACE_COUNT_ALLOCS = 1; - - /* constants for getAllocCount */ - private static final int KIND_ALLOCATED_OBJECTS = 1<<0; - private static final int KIND_ALLOCATED_BYTES = 1<<1; - private static final int KIND_FREED_OBJECTS = 1<<2; - private static final int KIND_FREED_BYTES = 1<<3; - private static final int KIND_GC_INVOCATIONS = 1<<4; - private static final int KIND_EXT_ALLOCATED_OBJECTS = 1<<12; - private static final int KIND_EXT_ALLOCATED_BYTES = 1<<13; - private static final int KIND_EXT_FREED_OBJECTS = 1<<14; - private static final int KIND_EXT_FREED_BYTES = 1<<15; - - public static final int KIND_GLOBAL_ALLOCATED_OBJECTS = - KIND_ALLOCATED_OBJECTS; - public static final int KIND_GLOBAL_ALLOCATED_BYTES = - KIND_ALLOCATED_BYTES; - public static final int KIND_GLOBAL_FREED_OBJECTS = - KIND_FREED_OBJECTS; - public static final int KIND_GLOBAL_FREED_BYTES = - KIND_FREED_BYTES; - public static final int KIND_GLOBAL_GC_INVOCATIONS = - KIND_GC_INVOCATIONS; - public static final int KIND_GLOBAL_EXT_ALLOCATED_OBJECTS = - KIND_EXT_ALLOCATED_OBJECTS; - public static final int KIND_GLOBAL_EXT_ALLOCATED_BYTES = - KIND_EXT_ALLOCATED_BYTES; - public static final int KIND_GLOBAL_EXT_FREED_OBJECTS = - KIND_EXT_FREED_OBJECTS; - public static final int KIND_GLOBAL_EXT_FREED_BYTES = - KIND_EXT_FREED_BYTES; - - public static final int KIND_THREAD_ALLOCATED_OBJECTS = - KIND_ALLOCATED_OBJECTS << 16; - public static final int KIND_THREAD_ALLOCATED_BYTES = - KIND_ALLOCATED_BYTES << 16; - public static final int KIND_THREAD_FREED_OBJECTS = - KIND_FREED_OBJECTS << 16; - public static final int KIND_THREAD_FREED_BYTES = - KIND_FREED_BYTES << 16; - public static final int KIND_THREAD_GC_INVOCATIONS = - KIND_GC_INVOCATIONS << 16; - public static final int KIND_THREAD_EXT_ALLOCATED_OBJECTS = - KIND_EXT_ALLOCATED_OBJECTS << 16; - public static final int KIND_THREAD_EXT_ALLOCATED_BYTES = - KIND_EXT_ALLOCATED_BYTES << 16; - public static final int KIND_THREAD_EXT_FREED_OBJECTS = - KIND_EXT_FREED_OBJECTS << 16; - public static final int KIND_THREAD_EXT_FREED_BYTES = - KIND_EXT_FREED_BYTES << 16; - - public static final int KIND_ALL_COUNTS = 0xffffffff; - - /* all methods are static */ - private VMDebug() {} - - /** - * Returns the time since the last known debugger activity. - * - * @return the time in milliseconds, or -1 if the debugger is not connected - */ - public static native long lastDebuggerActivity(); - - /** - * Determines if debugging is enabled in this VM. If debugging is not - * enabled, a debugger cannot be attached. - * - * @return true if debugging is enabled - */ - public static native boolean isDebuggingEnabled(); - - /** - * Determines if a debugger is currently attached. - * - * @return true if (and only if) a debugger is connected - */ - public static native boolean isDebuggerConnected(); - - /** - * Enable object allocation count logging and reporting. Call with - * a depth of zero to disable. This produces "top N" lists on every GC. - */ - //public static native void enableTopAllocCounts(int depth); - - /** - * Start method tracing with default name, size, and with 0 - * flags. - */ - public static void startMethodTracing() { - startMethodTracing(DEFAULT_METHOD_TRACE_FILE_NAME, 0, 0); - } - - /** - * Start method tracing, specifying a file name as well as a default - * buffer size. See Running the - * Traceview Debugging Program for information about reading - * trace files. - * - *

You can use either a fully qualified path and - * name, or just a name. If only a name is specified, the file will - * be created under the /sdcard/ directory. If a name is not given, - * the default is /sdcard/dmtrace.trace.

- * - * @param traceFileName name to give the trace file - * @param bufferSize the maximum size of both files combined. If passed - * as 0, it defaults to 8MB. - * @param flags flags to control method tracing. The only one that - * is currently defined is {@link #TRACE_COUNT_ALLOCS}. - */ - public static void startMethodTracing(String traceFileName, - int bufferSize, int flags) { - startMethodTracing(traceFileName, null, bufferSize, flags); - } - - /** - * Like startMethodTracing(String, int, int), but taking an already-opened - * FileDescriptor in which the trace is written. The file name is also - * supplied simply for logging. Makes a dup of the file descriptor. - * - * Not exposed in the SDK unless we are really comfortable with supporting - * this and find it would be useful. - * @hide - */ - public static native void startMethodTracing(String traceFileName, - FileDescriptor fd, int bufferSize, int flags); - - /** - * Determine whether method tracing is currently active. - * @hide - */ - public static native boolean isMethodTracingActive(); - - /** - * Stops method tracing. - */ - public static native void stopMethodTracing(); - - /** - * Starts sending Dalvik method trace info to the emulator. - */ - public static native void startEmulatorTracing(); - - /** - * Stops sending Dalvik method trace info to the emulator. - */ - public static native void stopEmulatorTracing(); - - /** - * Get an indication of thread CPU usage. The value returned indicates the - * amount of time that the current thread has spent executing code or - * waiting for certain types of I/O. - *

- * The time is expressed in nanoseconds, and is only meaningful when - * compared to the result from an earlier call. Note that nanosecond - * resolution does not imply nanosecond accuracy. - * - * @return the CPU usage. A value of -1 means the system does not support - * this feature. - */ - public static native long threadCpuTimeNanos(); - - /** - * Count the number and aggregate size of memory allocations between - * two points. - */ - public static native void startAllocCounting(); - public static native void stopAllocCounting(); - public static native int getAllocCount(int kind); - public static native void resetAllocCount(int kinds); - - /** - * Establishes an object allocation limit in the current thread. Useful for - * catching regressions in code that is expected to operate without causing - * any allocations. The limit is valid from the return of this method until - * it is either changed or the thread terminates. - * - * @param limit - * the new limit. A value of 0 means not a single new object may - * be allocated. A value of -1 disables the limit. - * - * @return the previous limit, or -1 if no limit was set - * - * @see #setGlobalAllocationLimit(int) - */ - public static native int setAllocationLimit(int limit); - - /** - * Establishes an object allocation limit for the entire VM. Useful for - * catching regressions in code that is expected to operate without causing - * any allocations. The limit is valid from the return of this method until - * it is either changed or the thread terminates. - * - * @param limit - * the new limit. A value of 0 means not a single new object may - * be allocated. A value of -1 disables the limit. - * - * @return the previous limit, or -1 if no limit was set - * - * @see #setAllocationLimit(int) - */ - public static native int setGlobalAllocationLimit(int limit); - - /** - * Count the number of instructions executed between two points. - */ - public static native void startInstructionCounting(); - public static native void stopInstructionCounting(); - public static native void getInstructionCount(int[] counts); - public static native void resetInstructionCount(); - - /** - * Dumps a list of loaded class to the log file. - */ - public static native void printLoadedClasses(int flags); - - /** - * Gets the number of loaded classes. - * - * @return the number of loaded classes - */ - public static native int getLoadedClassCount(); - - /** - * Dump "hprof" data to the specified file. This will cause a GC. - * - * The VM may create a temporary file in the same directory. - * - * @param fileName Full pathname of output file (e.g. "/sdcard/dump.hprof"). - * @throws UnsupportedOperationException if the VM was built without - * HPROF support. - * @throws IOException if an error occurs while opening or writing files. - */ - public static native void dumpHprofData(String fileName) throws IOException; - - /** - * Primes the register map cache. - * - * @hide - */ - public static native boolean cacheRegisterMap(String classAndMethodDesc); - - /** - * Crashes the VM. Seriously. Dumps the stack trace for the current - * thread and then aborts the VM so you can see the native stack trace. - * Useful for figuring out how you got somewhere when lots of native - * code is involved. - * - * @hide - */ - public static native void crash(); - - /* - * Fake method, inserted into dmtrace output when the garbage collector - * runs. Not actually called. - */ - private static void startGC() {} - - /* - * Fake method, inserted into dmtrace output during class preparation - * (loading and linking, but not verification or initialization). Not - * actually called. - */ - private static void startClassPrep() {} -} diff --git a/libcore/dalvik/src/main/java/dalvik/system/VMRuntime.java b/libcore/dalvik/src/main/java/dalvik/system/VMRuntime.java deleted file mode 100644 index 7ac0849e9..000000000 --- a/libcore/dalvik/src/main/java/dalvik/system/VMRuntime.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.system; - -/** - * Provides an interface to VM-global, Dalvik-specific features. - * An application cannot create its own Runtime instance, and must obtain - * one from the getRuntime method. - * - * @deprecated this is an internal Dalvik class that is not appropriate for - * general use. It will be removed from the public API in a future release. - * - * @since Android 1.0 - */ -public final class VMRuntime { - - /** - * Holds the VMRuntime singleton. - */ - private static final VMRuntime THE_ONE = new VMRuntime(); - - /** - * Prevents this class from being instantiated. - */ - private VMRuntime() { - } - - /** - * Returns the object that represents the VM instance's Dalvik-specific - * runtime environment. - * - * @return the runtime object - */ - public static VMRuntime getRuntime() { - return THE_ONE; - } - - /** - * Gets the current ideal heap utilization, represented as a number - * between zero and one. After a GC happens, the Dalvik heap may - * be resized so that (size of live objects) / (size of heap) is - * equal to this number. - * - * @return the current ideal heap utilization - */ - public native float getTargetHeapUtilization(); - - /** - * Sets the current ideal heap utilization, represented as a number - * between zero and one. After a GC happens, the Dalvik heap may - * be resized so that (size of live objects) / (size of heap) is - * equal to this number. - * - *

This is only a hint to the garbage collector and may be ignored. - * - * @param newTarget the new suggested ideal heap utilization. - * This value may be adjusted internally. - * @return the previous ideal heap utilization - * @throws IllegalArgumentException if newTarget is <= 0.0 or >= 1.0 - */ - public float setTargetHeapUtilization(float newTarget) { - if (newTarget <= 0.0 || newTarget >= 1.0) { - throw new IllegalArgumentException(newTarget + - " out of range (0,1)"); - } - /* Synchronize to make sure that only one thread gets - * a given "old" value if both update at the same time. - * Allows for reliable save-and-restore semantics. - */ - synchronized (this) { - float oldTarget = getTargetHeapUtilization(); - nativeSetTargetHeapUtilization(newTarget); - return oldTarget; - } - } - - /** - * Returns the minimum heap size, or zero if no minimum is in effect. - * - * @return the minimum heap size value - */ - public long getMinimumHeapSize() { - return nativeMinimumHeapSize(0, false); - } - - /** - * Sets the desired minimum heap size, and returns the - * old minimum size. If size is larger than the maximum - * size, the maximum size will be used. If size is zero - * or negative, the minimum size constraint will be removed. - * - *

Synchronized to make the order of the exchange reliable. - * - *

This is only a hint to the garbage collector and may be ignored. - * - * @param size the new suggested minimum heap size, in bytes - * @return the old minimum heap size value - */ - public synchronized long setMinimumHeapSize(long size) { - return nativeMinimumHeapSize(size, true); - } - - /** - * If set is true, sets the new minimum heap size to size; always - * returns the current (or previous) size. - * - * @param size the new suggested minimum heap size, in bytes - * @param set if true, set the size based on the size parameter, - * otherwise ignore it - * @return the old or current minimum heap size value - */ - private native long nativeMinimumHeapSize(long size, boolean set); - - /** - * Requests that the virtual machine collect available memory, - * and collects any SoftReferences that are not strongly-reachable. - */ - public native void gcSoftReferences(); - - /** - * Does not return until any pending finalizers have been called. - * This may or may not happen in the context of the calling thread. - * No exceptions will escape. - */ - public native void runFinalizationSync(); - - /** - * Implements setTargetHeapUtilization(). - * - * @param newTarget the new suggested ideal heap utilization. - * This value may be adjusted internally. - */ - private native void nativeSetTargetHeapUtilization(float newTarget); - - /** - * Asks the VM if <size> bytes can be allocated in an external heap. - * This information may be used to limit the amount of memory available - * to Dalvik threads. Returns false if the VM would rather that the caller - * did not allocate that much memory. If the call returns false, the VM - * will not update its internal counts. May cause one or more GCs as a - * side-effect. - * - * Called by JNI code. - * - * {@hide} - * - * @param size The number of bytes that have been allocated. - * @return true if the VM thinks there's enough process memory - * to satisfy this request, or false if not. - */ - public native boolean trackExternalAllocation(long size); - - /** - * Tells the VM that <size> bytes have been freed in an external - * heap. This information may be used to control the amount of memory - * available to Dalvik threads. - * - * Called by JNI code. - * - * {@hide} - * - * @param size The number of bytes that have been freed. This same number - * should have been passed to trackExternalAlloc() when - * the underlying memory was originally allocated. - */ - public native void trackExternalFree(long size); - - /** - * Returns the number of externally-allocated bytes being tracked by - * trackExternalAllocation/Free(). - * - * @return the number of bytes - */ - public native long getExternalBytesAllocated(); -} diff --git a/libcore/dalvik/src/main/java/dalvik/system/VMStack.java b/libcore/dalvik/src/main/java/dalvik/system/VMStack.java deleted file mode 100644 index b04996290..000000000 --- a/libcore/dalvik/src/main/java/dalvik/system/VMStack.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.system; - -/** - * Provides a limited interface to the Dalvik VM stack. This class is mostly - * used for implementing security checks. - * - * @deprecated this is an internal Dalvik class that is not appropriate for - * general use. It will be removed from the public API in a future release. - */ -public final class VMStack { - /** - * Returns the defining class loader of the caller's caller. - * - * @return the requested class loader, or {@code null} if this is the - * bootstrap class loader. - */ - native public static ClassLoader getCallingClassLoader(); - - /** - * Returns the defining class loader of the caller's caller's caller. - * - * @return the requested class loader, or {@code null} if this is the - * bootstrap class loader. - */ - native public static ClassLoader getCallingClassLoader2(); - - /** - * Returns the class of the caller's caller's caller. - * - * @hide - * @return the requested class, or {@code null}. - */ - native public static Class getStackClass2(); - - /** - * Creates an array of classes from the methods at the top of the stack. - * We continue until we reach the bottom of the stack or exceed the - * specified maximum depth. If stopAtPrivileged is set, the last - * element of the array will be the caller of the most-recent privileged - * method. - *

- * The topmost stack frame (this method) and the one above that (the - * caller) are excluded from the array. Frames with java.lang.reflect - * classes are skipped over. - *

- * The classes in the array are the defining classes of the methods. - *

- * This is expected to be identical to Harmony's VMStack.getClasses. - * - * @param maxDepth - * maximum number of classes to return, or -1 for all - * @param stopAtPrivileged - * stop when a privileged frame is reached - * @return an array with classes for the most-recent methods on the stack - */ - native public static Class[] getClasses(int maxDepth, - boolean stopAtPrivileged); - - /** - * Retrieves the stack trace from the specified thread. - * - * @param t - * thread of interest - * @return an array of stack trace elements, or null if the thread - * doesn't have a stack trace (e.g. because it exited) - */ - native public static StackTraceElement[] getThreadStackTrace(Thread t); -} - diff --git a/libcore/dalvik/src/main/java/dalvik/system/Zygote.java b/libcore/dalvik/src/main/java/dalvik/system/Zygote.java deleted file mode 100644 index 13e756114..000000000 --- a/libcore/dalvik/src/main/java/dalvik/system/Zygote.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dalvik.system; - -/** - * Provides access to the Dalvik "zygote" feature, which allows a VM instance to - * be partially initialized and then fork()'d from the partially initialized - * state. - * - * @deprecated this is an internal Dalvik class that is not appropriate for - * general use. It will be removed from the public API in a future release. - */ -public class Zygote { - /* - * Bit values for "debugFlags" argument. The definitions are duplicated - * in the native code. - */ - /** enable debugging over JDWP */ - public static final int DEBUG_ENABLE_DEBUGGER = 1; - /** enable JNI checks */ - public static final int DEBUG_ENABLE_CHECKJNI = 1 << 1; - /** enable Java programming language "assert" statements */ - public static final int DEBUG_ENABLE_ASSERT = 1 << 2; - - private Zygote() {} - - /** - * Forks a new Zygote instance, but does not leave the zygote mode. - * The current VM must have been started with the -Xzygote flag. The - * new child is expected to eventually call forkAndSpecialize() - * - * @return 0 if this is the child, pid of the child - * if this is the parent, or -1 on error - */ - native public static int fork(); - - /** - * Forks a new VM instance. The current VM must have been started - * with the -Xzygote flag. NOTE: new instance keeps all - * root capabilities. The new process is expected to call capset(). - * - * @param uid the UNIX uid that the new process should setuid() to after - * fork()ing and and before spawning any threads. - * @param gid the UNIX gid that the new process should setgid() to after - * fork()ing and and before spawning any threads. - * @param gids null-ok; a list of UNIX gids that the new process should - * setgroups() to after fork and before spawning any threads. - * @param debugFlags bit flags that enable debugging features. - * @param rlimits null-ok an array of rlimit tuples, with the second - * dimension having a length of 3 and representing - * (resource, rlim_cur, rlim_max). These are set via the posix - * setrlimit(2) call. - * - * @return 0 if this is the child, pid of the child - * if this is the parent, or -1 on error. - */ - native public static int forkAndSpecialize(int uid, int gid, int[] gids, - int debugFlags, int[][] rlimits); - - /** - * Forks a new VM instance. - * @deprecated use {@link Zygote#forkAndSpecialize(int, int, int[], int, int[][])} - */ - @Deprecated - public static int forkAndSpecialize(int uid, int gid, int[] gids, - boolean enableDebugger, int[][] rlimits) { - int debugFlags = enableDebugger ? DEBUG_ENABLE_DEBUGGER : 0; - return forkAndSpecialize(uid, gid, gids, debugFlags, rlimits); - } - - /** - * Special method to start the system server process. In addition to the - * common actions performed in forkAndSpecialize, the pid of the child - * process is recorded such that the death of the child process will cause - * zygote to exit. - * - * @param uid the UNIX uid that the new process should setuid() to after - * fork()ing and and before spawning any threads. - * @param gid the UNIX gid that the new process should setgid() to after - * fork()ing and and before spawning any threads. - * @param gids null-ok; a list of UNIX gids that the new process should - * setgroups() to after fork and before spawning any threads. - * @param debugFlags bit flags that enable debugging features. - * @param rlimits null-ok an array of rlimit tuples, with the second - * dimension having a length of 3 and representing - * (resource, rlim_cur, rlim_max). These are set via the posix - * setrlimit(2) call. - * - * @return 0 if this is the child, pid of the child - * if this is the parent, or -1 on error. - */ - native public static int forkSystemServer(int uid, int gid, - int[] gids, int debugFlags, int[][] rlimits); - - /** - * Special method to start the system server process. - * @deprecated use {@link Zygote#forkSystemServer(int, int, int[], int, int[][])} - */ - @Deprecated - public static int forkSystemServer(int uid, int gid, int[] gids, - boolean enableDebugger, int[][] rlimits) { - int debugFlags = enableDebugger ? DEBUG_ENABLE_DEBUGGER : 0; - return forkAndSpecialize(uid, gid, gids, debugFlags, rlimits); - } -} - diff --git a/libcore/dalvik/src/main/java/dalvik/system/package.html b/libcore/dalvik/src/main/java/dalvik/system/package.html deleted file mode 100644 index 215671c78..000000000 --- a/libcore/dalvik/src/main/java/dalvik/system/package.html +++ /dev/null @@ -1,8 +0,0 @@ - - -

- Provides utility and system information classes specific to the Dalvik VM. -

- @since Android 1.0 - - diff --git a/libcore/dalvik/src/main/java/org/apache/harmony/dalvik/NativeTestTarget.java b/libcore/dalvik/src/main/java/org/apache/harmony/dalvik/NativeTestTarget.java deleted file mode 100644 index 7b46d2e69..000000000 --- a/libcore/dalvik/src/main/java/org/apache/harmony/dalvik/NativeTestTarget.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.dalvik; - -/** - * Methods used to test calling into native code. The methods in this - * class are all effectively no-ops and may be used to test the mechanisms - * and performance of calling native methods. - */ -public final class NativeTestTarget { - /** - * This class is uninstantiable. - */ - private NativeTestTarget() { - // This space intentionally left blank. - } - - /** - * This is an empty native static method with no args, hooked up using - * JNI. - */ - public static native void emptyJniStaticMethod0(); - - /** - * This is an empty native static method with six args, hooked up using - * JNI. - */ - public static native void emptyJniStaticMethod6(int a, int b, int c, - int d, int e, int f); - - /** - * This is an empty native static method with six args, hooked up - * using JNI. These have more complex args to show the cost of - * parsing the signature. All six values should be null - * references. - */ - public static native void emptyJniStaticMethod6L(String a, String[] b, - int[][] c, Object d, Object[] e, Object[][][][] f); - - /** - * This method is intended to be "inlined" by the virtual machine - * (e.g., given special treatment as an intrinsic). - */ - public static void emptyInlineMethod() { - // This space intentionally left blank. - } - - /** - * This method is intended to be defined in native code and hooked - * up using the virtual machine's special fast-path native linkage - * (as opposed to being hooked up using JNI). - */ - public static native void emptyInternalStaticMethod(); -} diff --git a/libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/Chunk.java b/libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/Chunk.java deleted file mode 100644 index 9b98893fe..000000000 --- a/libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/Chunk.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.dalvik.ddmc; - -import java.nio.ByteBuffer; - -/** - * A chunk of DDM data. This is really just meant to hold a few pieces - * of data together. - * - * The "offset" and "length" fields are present so handlers can over-allocate - * or share byte buffers. - */ -public class Chunk { - - /* - * Public members. Do not rename without updating the VM. - */ - public int type; // chunk type - public byte[] data; // chunk data - public int offset, length; // position within "data" - - /** - * Blank constructor. Fill in your own fields. - */ - public Chunk() {} - - /** - * Constructor with all fields. - */ - public Chunk(int type, byte[] data, int offset, int length) { - this.type = type; - this.data = data; - this.offset = offset; - this.length = length; - } - - /** - * Construct from a ByteBuffer. The chunk is assumed to start at - * offset 0 and continue to the current position. - */ - public Chunk(int type, ByteBuffer buf) { - this.type = type; - - this.data = buf.array(); - this.offset = buf.arrayOffset(); - this.length = buf.position(); - } -} - diff --git a/libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/ChunkHandler.java b/libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/ChunkHandler.java deleted file mode 100644 index 59a7cad72..000000000 --- a/libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/ChunkHandler.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.dalvik.ddmc; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -/** - * Handle a chunk of data sent from a DDM server. - * - * To handle a chunk type, sub-class ChunkHandler and register your class - * with DdmServer. - */ -public abstract class ChunkHandler { - - public static final ByteOrder CHUNK_ORDER = ByteOrder.BIG_ENDIAN; - - public static final int CHUNK_FAIL = type("FAIL"); - - - public ChunkHandler() {} - - /** - * Called when the DDM server connects. The handler is allowed to - * send messages to the server. - */ - public abstract void connected(); - - /** - * Called when the DDM server disconnects. Can be used to disable - * periodic transmissions or clean up saved state. - */ - public abstract void disconnected(); - - /** - * Handle a single chunk of data. "request" includes the type and - * the chunk payload. - * - * Returns a response in a Chunk. - */ - public abstract Chunk handleChunk(Chunk request); - - /** - * Create a FAIL chunk. The "handleChunk" methods can use this to - * return an error message when they are not able to process a chunk. - */ - public static Chunk createFailChunk(int errorCode, String msg) { - if (msg == null) - msg = ""; - - ByteBuffer out = ByteBuffer.allocate(8 + msg.length() * 2); - out.order(ChunkHandler.CHUNK_ORDER); - out.putInt(errorCode); - out.putInt(msg.length()); - putString(out, msg); - - return new Chunk(CHUNK_FAIL, out); - } - - /** - * Utility function to wrap a ByteBuffer around a Chunk. - */ - public static ByteBuffer wrapChunk(Chunk request) { - ByteBuffer in; - - in = ByteBuffer.wrap(request.data, request.offset, request.length); - in.order(CHUNK_ORDER); - return in; - } - - - /** - * Utility function to copy a String out of a ByteBuffer. - * - * This is here because multiple chunk handlers can make use of it, - * and there's nowhere better to put it. - */ - public static String getString(ByteBuffer buf, int len) { - char[] data = new char[len]; - for (int i = 0; i < len; i++) - data[i] = buf.getChar(); - return new String(data); - } - - /** - * Utility function to copy a String into a ByteBuffer. - */ - public static void putString(ByteBuffer buf, String str) { - int len = str.length(); - for (int i = 0; i < len; i++) - buf.putChar(str.charAt(i)); - } - - /** - * Convert a 4-character string to a 32-bit type. - */ - public static int type(String typeName) - { - int val = 0; - - if (typeName.length() != 4) - throw new RuntimeException(); - - for (int i = 0; i < 4; i++) { - val <<= 8; - val |= (byte) typeName.charAt(i); - } - - return val; - } - - /** - * Convert an integer type to a 4-character string. - */ - public static String name(int type) - { - char[] ascii = new char[4]; - - ascii[0] = (char) ((type >> 24) & 0xff); - ascii[1] = (char) ((type >> 16) & 0xff); - ascii[2] = (char) ((type >> 8) & 0xff); - ascii[3] = (char) (type & 0xff); - - return new String(ascii); - } - -} - diff --git a/libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/DdmServer.java b/libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/DdmServer.java deleted file mode 100644 index a7d429a51..000000000 --- a/libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/DdmServer.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.dalvik.ddmc; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; - - -/** - * This represents our connection to the DDM Server. - */ -public class DdmServer { - - public static final int CLIENT_PROTOCOL_VERSION = 1; - - private static HashMap mHandlerMap = - new HashMap(); - - private static final int CONNECTED = 1; - private static final int DISCONNECTED = 2; - - private static volatile boolean mRegistrationComplete = false; - private static boolean mRegistrationTimedOut = false; - - - /** - * Don't instantiate; all members and methods are static. - */ - private DdmServer() {} - - /** - * Register an instance of the ChunkHandler class to handle a specific - * chunk type. - * - * Throws an exception if the type already has a handler registered. - */ - public static void registerHandler(int type, ChunkHandler handler) { - if (handler == null) - throw new NullPointerException(); - - synchronized (mHandlerMap) { - if (mHandlerMap.get(type) != null) - throw new RuntimeException("type " + Integer.toHexString(type) - + " already registered"); - - mHandlerMap.put(type, handler); - } - } - - /** - * Unregister the existing handler for the specified type. - * - * Returns the old handler. - */ - public static ChunkHandler unregisterHandler(int type) { - synchronized (mHandlerMap) { - return mHandlerMap.remove(type); - } - } - - /** - * The application must call here after it finishes registering - * handlers. - */ - public static void registrationComplete() { - // sync on mHandlerMap because it's convenient and makes a kind of - // sense - synchronized (mHandlerMap) { - mRegistrationComplete = true; - mHandlerMap.notifyAll(); - } - } - - /** - * Send a chunk of data to the DDM server. This takes the form of a - * JDWP "event", which does not elicit a response from the server. - * - * Use this for "unsolicited" chunks. - */ - public static void sendChunk(Chunk chunk) { - nativeSendChunk(chunk.type, chunk.data, chunk.offset, chunk.length); - } - - /* send a chunk to the DDM server */ - native private static void nativeSendChunk(int type, byte[] data, - int offset, int length); - - /* - * Called by the VM when the DDM server connects or disconnects. - */ - private static void broadcast(int event) - { - synchronized (mHandlerMap) { - Collection values = mHandlerMap.values(); - Iterator iter = values.iterator(); - - while (iter.hasNext()) { - ChunkHandler handler = (ChunkHandler) iter.next(); - switch (event) { - case CONNECTED: - handler.connected(); - break; - case DISCONNECTED: - handler.disconnected(); - break; - default: - throw new UnsupportedOperationException(); - } - } - } - } - - /* - * This is called by the VM when a chunk arrives. - * - * For a DDM-aware application, we want to wait until the app has had - * a chance to register all of its chunk handlers. Otherwise, we'll - * end up dropping early-arriving packets on the floor. - * - * For a non-DDM-aware application, we'll end up waiting here forever - * if DDMS happens to connect. It's hard to know for sure that - * registration isn't going to happen, so we settle for a timeout. - */ - private static Chunk dispatch(int type, byte[] data, int offset, int length) - { - ChunkHandler handler; - - synchronized (mHandlerMap) { - /* - * If registration hasn't completed, and we haven't timed out - * waiting for it, wait a bit. - */ - while (!mRegistrationComplete && !mRegistrationTimedOut) { - //System.out.println("dispatch() waiting for reg"); - try { - mHandlerMap.wait(1000); // 1.0 sec - } catch (InterruptedException ie) { - continue; - } - - if (!mRegistrationComplete) { - /* timed out, don't wait again */ - System.out.println("DDM dispatch reg wait timeout"); - mRegistrationTimedOut = true; - } - } - - handler = mHandlerMap.get(type); - } - //System.out.println(" dispatch cont"); - - if (handler == null) { - System.err.println("Can't dispatch DDM chunk " - + Integer.toHexString(type) + ": no handler defined"); - return null; - } - - Chunk chunk = new Chunk(type, data, offset, length); - return handler.handleChunk(chunk); - } -} - diff --git a/libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/DdmVmInternal.java b/libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/DdmVmInternal.java deleted file mode 100644 index 01293b057..000000000 --- a/libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/DdmVmInternal.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.dalvik.ddmc; - -/** - * Declarations for some VM-internal DDM stuff. - */ -public class DdmVmInternal { - - /* do not instantiate */ - private DdmVmInternal() {} - - /** - * Enable thread notification. - * - * This is built into the VM, since that's where threads get managed. - */ - native public static void threadNotify(boolean enable); - - /** - * Enable heap info updates. - * - * This is built into the VM, since that's where the heap is managed. - * - * @param when when to send the next HPIF chunk - * @return true on success. false if 'when' is bad or if there was - * an internal error. - */ - native public static boolean heapInfoNotify(int when); - - /** - * Enable heap segment updates for the java (isNative == false) or - * native (isNative == true) heap. - * - * This is built into the VM, since that's where the heap is managed. - */ - native public static boolean heapSegmentNotify(int when, int what, - boolean isNative); - - /** - * Get status info for all threads. This is for the THST chunk. - * - * Returns a byte array with the THST data, or null if something - * went wrong. - */ - native public static byte[] getThreadStats(); - - /** - * Get a stack trace for the specified thread ID. The ID can be found - * in the data from getThreadStats. - */ - native public static StackTraceElement[] getStackTraceById(int threadId); - - /** - * Enable or disable "recent allocation" tracking. - */ - native public static void enableRecentAllocations(boolean enable); - - /* - * Return a boolean indicating whether or not the "recent allocation" - * feature is currently enabled. - */ - native public static boolean getRecentAllocationStatus(); - - /** - * Fill a buffer with data on recent heap allocations. - */ - native public static byte[] getRecentAllocations(); -} - diff --git a/libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/README.txt b/libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/README.txt deleted file mode 100644 index 99def80b2..000000000 --- a/libcore/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/README.txt +++ /dev/null @@ -1 +0,0 @@ -These classes are tied to the VM, e.g. the VM may invoke some of the methods. diff --git a/libcore/dalvik/src/main/native/dalvik_system_TouchDex.cpp b/libcore/dalvik/src/main/native/dalvik_system_TouchDex.cpp deleted file mode 100644 index e8b834b9f..000000000 --- a/libcore/dalvik/src/main/native/dalvik_system_TouchDex.cpp +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Bit of code to wrap DEX force-updating with a fork() call. - */ - -#define LOG_TAG "TouchDex" -#include "JNIHelp.h" - -#include "cutils/properties.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define JAVA_PACKAGE "dalvik/system" - -#ifndef HAVE_ANDROID_OS -# define BASE_DIR "/work/device/out/linux-x86-debug-sim" -#else -# define BASE_DIR "" -#endif - -namespace android { - -// fwd -static void logProcStatus(pid_t pid); - - -/* - * private static int trampoline(String dexFiles, String bcp) - */ -static jint dalvik_system_TouchDex_trampoline(JNIEnv* env, - jclass clazz, jstring dexFilesStr, jstring bcpStr) -{ -#ifndef HAVE_ANDROID_OS - /* don't do this on simulator -- gdb goes "funny" in goobuntu */ - return 0; -#endif - - const int kMinTimeout = 900; // 90 seconds - const char* bcp; - const char* dexFiles; - static const char* kExecFile = BASE_DIR "/system/bin/dalvikvm"; - //static const char* kDebugArg = - // "-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"; - static const char* kBcpArgName = "-Xbootclasspath:"; - static const char* kClassName = "dalvik.system.TouchDex"; - static const char* kExecMode = "-Xint"; - static const int argc = 7; - char* bcpArg; - const char* argv[argc+1]; - const char* kVerifyArg; - const char* kDexOptArg; - int timeoutMult; - pid_t pid; - struct timeval startWhen, endWhen; - char propBuf[PROPERTY_VALUE_MAX]; - char execModeBuf[PROPERTY_VALUE_MAX + sizeof("-X")]; - bool verifyJava = true; - - property_get("dalvik.vm.verify-bytecode", propBuf, ""); - if (strcmp(propBuf, "true") == 0) { - verifyJava = true; - } else if (strcmp(propBuf, "false") == 0) { - verifyJava = false; - } else { - /* bad value or not defined; use default */ - } - - if (verifyJava) { - kVerifyArg = "-Xverify:all"; - kDexOptArg = "-Xdexopt:verified"; - timeoutMult = 11; - } else { - kVerifyArg = "-Xverify:none"; - //kDexOptArg = "-Xdexopt:all"; - kDexOptArg = "-Xdexopt:verified"; - timeoutMult = 7; - } - - property_get("dalvik.vm.execution-mode", propBuf, ""); - if (strncmp(propBuf, "int:", 4) == 0) { - strcpy(execModeBuf, "-X"); - strcat(execModeBuf, propBuf); - kExecMode = execModeBuf; - } - - LOGV("TouchDex trampoline forking\n"); - gettimeofday(&startWhen, NULL); - - /* - * Retrieve strings. Note we want to do this *before* the fork() -- bad - * idea to perform Java operations in the child process (not all threads - * get carried over to the new process). - */ - bcp = env->GetStringUTFChars(bcpStr, NULL); - dexFiles = env->GetStringUTFChars(dexFilesStr, NULL); - if (bcp == NULL || dexFiles == NULL) { - LOGE("Bad values for bcp=%p dexFiles=%p\n", bcp, dexFiles); - abort(); - } - - pid = fork(); - if (pid < 0) { - LOGE("fork failed: %s", strerror(errno)); - return -1; - } - - if (pid == 0) { - /* child */ - char* bcpArg; - - LOGV("TouchDex trampoline in child\n"); - - bcpArg = (char*) malloc(strlen(bcp) + strlen(kBcpArgName) +1); - strcpy(bcpArg, kBcpArgName); - strcat(bcpArg, bcp); - - argv[0] = kExecFile; - argv[1] = bcpArg; - argv[2] = kVerifyArg; - argv[3] = kDexOptArg; - argv[4] = kExecMode; - argv[5] = kClassName; - argv[6] = dexFiles; - argv[7] = NULL; - - //LOGI("Calling execv with args:\n"); - //for (int i = 0; i < argc; i++) - // LOGI(" %d: '%s'\n", i, argv[i]); - - execv(kExecFile, (char* const*) argv); - free(bcpArg); - - LOGE("execv '%s' failed: %s\n", kExecFile, strerror(errno)); - exit(1); - } else { - int cc, count, dexCount, timeout; - int result = -1; - const char* cp; - - /* - * Adjust the timeout based on how many DEX files we have to - * process. Larger DEX files take longer, so this is a crude - * approximation at best. - * - * We need this for http://b/issue?id=836771, which can leave us - * stuck waiting for a long time even if there is no work to be done. - * - * This is currently being (ab)used to convert single files, which - * sort of spoils the timeout calculation. We establish a minimum - * timeout for single apps. - * - * The timeout calculation doesn't work at all right when a - * directory is specified. So the minimum is now a minute. At - * this point it's probably safe to just remove the timeout. - * - * The timeout is in 1/10ths of a second. - */ - dexCount = 1; - cp = dexFiles; - while (*++cp != '\0') { - if (*cp == ':') - dexCount++; - } - timeout = timeoutMult * dexCount; - if (timeout < kMinTimeout) - timeout = kMinTimeout; - - env->ReleaseStringUTFChars(bcpStr, bcp); - env->ReleaseStringUTFChars(dexFilesStr, dexFiles); - - - LOGD("TouchDex parent waiting for pid=%d (timeout=%.1fs)\n", - (int) pid, timeout / 10.0); - for (count = 0; count < timeout; count++) { - /* waitpid doesn't take a timeout, so poll and sleep */ - cc = waitpid(pid, &result, WNOHANG); - if (cc < 0) { - LOGE("waitpid(%d) failed: %s", (int) pid, strerror(errno)); - return -1; - } else if (cc == 0) { - usleep(100000); /* 0.1 sec */ - } else { - /* success! */ - break; - } - } - - if (count == timeout) { - /* note kill(0) returns 0 if the pid is a zombie */ - LOGE("timed out waiting for %d; kill(0) returns %d\n", - (int) pid, kill(pid, 0)); - logProcStatus(pid); - } else { - LOGV("TouchDex done after %d iterations (kill(0) returns %d)\n", - count, kill(pid, 0)); - } - - gettimeofday(&endWhen, NULL); - long long start = startWhen.tv_sec * 1000000 + startWhen.tv_usec; - long long end = endWhen.tv_sec * 1000000 + endWhen.tv_usec; - - LOGI("Dalvik-cache prep: status=0x%04x, finished in %dms\n", - result, (int) ((end - start) / 1000)); - - if (WIFEXITED(result)) - return WEXITSTATUS(result); - else - return result; - } -} - -/* - * Dump the contents of /proc//status to the log file. - */ -static void logProcStatus(pid_t pid) -{ - char localBuf[256]; - FILE* fp; - - sprintf(localBuf, "/proc/%d/status", (int) pid); - fp = fopen(localBuf, "r"); - if (fp == NULL) { - LOGI("Unable to open '%s'\n", localBuf); - return; - } - - LOGI("Contents of %s:\n", localBuf); - while (true) { - fgets(localBuf, sizeof(localBuf), fp); - if (ferror(fp) || feof(fp)) - break; - LOGI(" %s", localBuf); - } - - fclose(fp); -} - -/* - * JNI registration. - */ -static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ - { "trampoline", "(Ljava/lang/String;Ljava/lang/String;)I", - (void*) dalvik_system_TouchDex_trampoline }, -}; - -extern "C" int register_dalvik_system_TouchDex(JNIEnv* env) -{ - return jniRegisterNativeMethods(env, JAVA_PACKAGE "/TouchDex", - gMethods, NELEM(gMethods)); -} - -}; // namespace android - diff --git a/libcore/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.c b/libcore/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.c deleted file mode 100644 index 25235dc36..000000000 --- a/libcore/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "JNIHelp.h" - -/* - * public static void emptyJniStaticMethod0() - * - * For benchmarks, a do-nothing JNI method with no arguments. - */ -static void emptyJniStaticMethod0(JNIEnv* env, jclass clazz) -{ - // This space intentionally left blank. -} - -/* - * public static void emptyJniStaticMethod6(int a, int b, int c, - * int d, int e, int f) - * - * For benchmarks, a do-nothing JNI method with six arguments. - */ -static void emptyJniStaticMethod6(JNIEnv* env, jclass clazz, - int a, int b, int c, int d, int e, int f) -{ - // This space intentionally left blank. -} - -/* - * public static void emptyJniStaticMethod6L(String a, String[] b, - * int[][] c, Object d, Object[] e, Object[][][][] f) - * - * For benchmarks, a do-nothing JNI method with six arguments. - */ -static void emptyJniStaticMethod6L(JNIEnv* env, jclass clazz, - jobject a, jarray b, jarray c, jobject d, jarray e, jarray f) -{ - // This space intentionally left blank. -} - -/* - * JNI registration - */ -static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ - { "emptyJniStaticMethod0", "()V", emptyJniStaticMethod0 }, - { "emptyJniStaticMethod6", "(IIIIII)V", emptyJniStaticMethod6 }, - { "emptyJniStaticMethod6L", - "(Ljava/lang/String;[Ljava/lang/String;[[I" - "Ljava/lang/Object;[Ljava/lang/Object;[[[[Ljava/lang/Object;)V", - emptyJniStaticMethod6L }, -}; - -int register_org_apache_harmony_dalvik_NativeTestTarget(JNIEnv* env) -{ - int result = jniRegisterNativeMethods(env, - "org/apache/harmony/dalvik/NativeTestTarget", - gMethods, NELEM(gMethods)); - if (result != 0) { - /* print warning, but allow to continue */ - LOGW("WARNING: NativeTestTarget not registered\n"); - (*env)->ExceptionClear(env); - } - return 0; -} - diff --git a/libcore/dalvik/src/main/native/sub.mk b/libcore/dalvik/src/main/native/sub.mk deleted file mode 100644 index 67cca39fb..000000000 --- a/libcore/dalvik/src/main/native/sub.mk +++ /dev/null @@ -1,18 +0,0 @@ -# This file is included by the top-level libcore Android.mk. -# It's not a normal makefile, so we don't include CLEAR_VARS -# or BUILD_*_LIBRARY. - -LOCAL_SRC_FILES := \ - dalvik_system_TouchDex.cpp \ - org_apache_harmony_dalvik_NativeTestTarget.c - -#LOCAL_C_INCLUDES += - -# Any shared/static libs that are listed here must also -# be listed in libs/nativehelper/Android.mk. -# TODO: fix this requirement - -#LOCAL_SHARED_LIBRARIES += - -#LOCAL_STATIC_LIBRARIES += - diff --git a/libcore/dom/src/test/java/README b/libcore/dom/src/test/java/README deleted file mode 100644 index 0b9d9d414..000000000 --- a/libcore/dom/src/test/java/README +++ /dev/null @@ -1,10 +0,0 @@ -all classes under org.w3c.domts are from the official w3c test suite. -Level 1 Core tests and Level 2 Core tests from -http://www.w3.org/DOM/Test/ - -additions made: -all additions under org.w3c.dom.* and org.w3c.dom.events.* - - -removals: -org/w3c/domts/JUnitRunner.java diff --git a/libcore/dom/src/test/java/org/w3c/dom/DOMError.java b/libcore/dom/src/test/java/org/w3c/dom/DOMError.java deleted file mode 100644 index e70ec6bae..000000000 --- a/libcore/dom/src/test/java/org/w3c/dom/DOMError.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.w3c.dom; -public interface DOMError { - // ErrorSeverity - /** - * The severity of the error described by the DOMError is - * warning. A SEVERITY_WARNING will not cause the - * processing to stop, unless DOMErrorHandler.handleError() - * returns false. - */ - public static final short SEVERITY_WARNING = 1; - /** - * The severity of the error described by the DOMError is - * error. A SEVERITY_ERROR may not cause the processing to - * stop if the error can be recovered, unless - * DOMErrorHandler.handleError() returns false. - */ - public static final short SEVERITY_ERROR = 2; - /** - * The severity of the error described by the DOMError is - * fatal error. A SEVERITY_FATAL_ERROR will cause the - * normal processing to stop. The return value of - * DOMErrorHandler.handleError() is ignored unless the - * implementation chooses to continue, in which case the behavior - * becomes undefined. - */ - public static final short SEVERITY_FATAL_ERROR = 3; - - /** - * The severity of the error, either SEVERITY_WARNING, - * SEVERITY_ERROR, or SEVERITY_FATAL_ERROR. - */ - public short getSeverity(); - - /** - * An implementation specific string describing the error that occurred. - */ - public String getMessage(); - - /** - * A DOMString indicating which related data is expected in - * relatedData. Users should refer to the specification of - * the error in order to find its DOMString type and - * relatedData definitions if any. - *

Note: As an example, - * Document.normalizeDocument() does generate warnings when - * the "split-cdata-sections" parameter is in use. Therefore, the method - * generates a SEVERITY_WARNING with type - * "cdata-sections-splitted" and the first - * CDATASection node in document order resulting from the - * split is returned by the relatedData attribute. - */ - public String getType(); - - /** - * The related platform dependent exception if any. - */ - public Object getRelatedException(); - - /** - * The related DOMError.type dependent data if any. - */ - public Object getRelatedData(); - - /** - * The location of the error. - */ - public DOMLocator getLocation(); - -} \ No newline at end of file diff --git a/libcore/dom/src/test/java/org/w3c/dom/DOMErrorHandler.java b/libcore/dom/src/test/java/org/w3c/dom/DOMErrorHandler.java deleted file mode 100644 index 7b1366a69..000000000 --- a/libcore/dom/src/test/java/org/w3c/dom/DOMErrorHandler.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.w3c.dom; -public interface DOMErrorHandler { - /** - * This method is called on the error handler when an error occurs. - *
If an exception is thrown from this method, it is considered to be - * equivalent of returning true. - * @param error The error object that describes the error. This object - * may be reused by the DOM implementation across multiple calls to - * the handleError method. - * @return If the handleError method returns - * false, the DOM implementation should stop the current - * processing when possible. If the method returns true, - * the processing may continue depending on - * DOMError.severity. - */ - public boolean handleError(DOMError error); - -} \ No newline at end of file diff --git a/libcore/dom/src/test/java/org/w3c/dom/DOMLocator.java b/libcore/dom/src/test/java/org/w3c/dom/DOMLocator.java deleted file mode 100644 index 876636f23..000000000 --- a/libcore/dom/src/test/java/org/w3c/dom/DOMLocator.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.w3c.dom; - -/** - * DOMLocator is an interface that describes a location (e.g. - * where an error occurred). - *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 - */ -public interface DOMLocator { - /** - * The line number this locator is pointing to, or -1 if - * there is no column number available. - */ - public int getLineNumber(); - - /** - * The column number this locator is pointing to, or -1 if - * there is no column number available. - */ - public int getColumnNumber(); - - /** - * The byte offset into the input source this locator is pointing to or - * -1 if there is no byte offset available. - */ - public int getByteOffset(); - - /** - * The UTF-16, as defined in [Unicode] and Amendment 1 of [ISO/IEC 10646], offset into the input source this locator is pointing to or - * -1 if there is no UTF-16 offset available. - */ - public int getUtf16Offset(); - - /** - * The node this locator is pointing to, or null if no node - * is available. - */ - public Node getRelatedNode(); - - /** - * The URI this locator is pointing to, or null if no URI is - * available. - */ - public String getUri(); - -} diff --git a/libcore/dom/src/test/java/org/w3c/dom/UserDataHandler.java b/libcore/dom/src/test/java/org/w3c/dom/UserDataHandler.java deleted file mode 100644 index 0901f4aca..000000000 --- a/libcore/dom/src/test/java/org/w3c/dom/UserDataHandler.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.w3c.dom; -public interface UserDataHandler { - // OperationType - /** - * The node is cloned, using Node.cloneNode(). - */ - public static final short NODE_CLONED = 1; - /** - * The node is imported, using Document.importNode(). - */ - public static final short NODE_IMPORTED = 2; - /** - * The node is deleted. - *

Note: This may not be supported or may not be reliable in - * certain environments, such as Java, where the implementation has no - * real control over when objects are actually deleted. - */ - public static final short NODE_DELETED = 3; - /** - * The node is renamed, using Document.renameNode(). - */ - public static final short NODE_RENAMED = 4; - /** - * The node is adopted, using Document.adoptNode(). - */ - public static final short NODE_ADOPTED = 5; - - /** - * This method is called whenever the node for which this handler is - * registered is imported or cloned. - *
DOM applications must not raise exceptions in a - * UserDataHandler. The effect of throwing exceptions from - * the handler is DOM implementation dependent. - * @param operation Specifies the type of operation that is being - * performed on the node. - * @param key Specifies the key for which this handler is being called. - * @param data Specifies the data for which this handler is being called. - * @param src Specifies the node being cloned, adopted, imported, or - * renamed. This is null when the node is being deleted. - * @param dst Specifies the node newly created if any, or - * null. - */ - public void handle(short operation, - String key, - Object data, - Node src, - Node dst); - -} diff --git a/libcore/dom/src/test/java/org/w3c/dom/events/Event.java b/libcore/dom/src/test/java/org/w3c/dom/events/Event.java deleted file mode 100644 index f2baad61c..000000000 --- a/libcore/dom/src/test/java/org/w3c/dom/events/Event.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.dom.events; - -/** - * The Event interface is used to provide contextual information - * about an event to the handler processing the event. An object which - * implements the Event interface is generally passed as the - * first parameter to an event handler. More specific context information is - * passed to event handlers by deriving additional interfaces from - * Event which contain information directly relating to the - * type of event they accompany. These derived interfaces are also - * implemented by the object passed to the event listener. - *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 - */ -public interface Event { - // PhaseType - /** - * The current event phase is the capturing phase. - */ - public static final short CAPTURING_PHASE = 1; - /** - * The event is currently being evaluated at the target - * EventTarget. - */ - public static final short AT_TARGET = 2; - /** - * The current event phase is the bubbling phase. - */ - public static final short BUBBLING_PHASE = 3; - - /** - * The name of the event (case-insensitive). The name must be an XML name. - */ - public String getType(); - - /** - * Used to indicate the EventTarget to which the event was - * originally dispatched. - */ - public EventTarget getTarget(); - - /** - * Used to indicate the EventTarget whose - * EventListeners are currently being processed. This is - * particularly useful during capturing and bubbling. - */ - public EventTarget getCurrentTarget(); - - /** - * Used to indicate which phase of event flow is currently being - * evaluated. - */ - public short getEventPhase(); - - /** - * Used to indicate whether or not an event is a bubbling event. If the - * event can bubble the value is true, else the value is false. - */ - public boolean getBubbles(); - - /** - * Used to indicate whether or not an event can have its default action - * prevented. If the default action can be prevented the value is true, - * else the value is false. - */ - public boolean getCancelable(); - - /** - * Used to specify the time (in milliseconds relative to the epoch) at - * which the event was created. Due to the fact that some systems may - * not provide this information the value of timeStamp may - * be not available for all events. When not available, a value of 0 - * will be returned. Examples of epoch time are the time of the system - * start or 0:0:0 UTC 1st January 1970. - */ - public long getTimeStamp(); - - /** - * The stopPropagation method is used prevent further - * propagation of an event during event flow. If this method is called - * by any EventListener the event will cease propagating - * through the tree. The event will complete dispatch to all listeners - * on the current EventTarget before event flow stops. This - * method may be used during any stage of event flow. - */ - public void stopPropagation(); - - /** - * If an event is cancelable, the preventDefault method is - * used to signify that the event is to be canceled, meaning any default - * action normally taken by the implementation as a result of the event - * will not occur. If, during any stage of event flow, the - * preventDefault method is called the event is canceled. - * Any default action associated with the event will not occur. Calling - * this method for a non-cancelable event has no effect. Once - * preventDefault has been called it will remain in effect - * throughout the remainder of the event's propagation. This method may - * be used during any stage of event flow. - */ - public void preventDefault(); - - /** - * The initEvent method is used to initialize the value of an - * Event created through the DocumentEvent - * interface. This method may only be called before the - * Event has been dispatched via the - * dispatchEvent method, though it may be called multiple - * times during that phase if necessary. If called multiple times the - * final invocation takes precedence. If called from a subclass of - * Event interface only the values specified in the - * initEvent method are modified, all other attributes are - * left unchanged. - * @param eventTypeArgSpecifies the event type. This type may be any - * event type currently defined in this specification or a new event - * type.. The string must be an XML name. Any new event type must not - * begin with any upper, lower, or mixed case version of the string - * "DOM". This prefix is reserved for future DOM event sets. It is - * also strongly recommended that third parties adding their own - * events use their own prefix to avoid confusion and lessen the - * probability of conflicts with other new events. - * @param canBubbleArgSpecifies whether or not the event can bubble. - * @param cancelableArgSpecifies whether or not the event's default - * action can be prevented. - */ - public void initEvent(String eventTypeArg, - boolean canBubbleArg, - boolean cancelableArg); - -} diff --git a/libcore/dom/src/test/java/org/w3c/dom/events/EventException.java b/libcore/dom/src/test/java/org/w3c/dom/events/EventException.java deleted file mode 100644 index 7a6ff2620..000000000 --- a/libcore/dom/src/test/java/org/w3c/dom/events/EventException.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.dom.events; - -/** - * Event operations may throw an EventException as specified in - * their method descriptions. - *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 - */ -public class EventException extends RuntimeException { - public EventException(short code, String message) { - super(message); - this.code = code; - } - public short code; - // EventExceptionCode - /** - * If the Event's type was not specified by initializing the - * event before the method was called. Specification of the Event's type - * as null or an empty string will also trigger this - * exception. - */ - public static final short UNSPECIFIED_EVENT_TYPE_ERR = 0; - -} diff --git a/libcore/dom/src/test/java/org/w3c/dom/events/EventListener.java b/libcore/dom/src/test/java/org/w3c/dom/events/EventListener.java deleted file mode 100644 index 52e60cb21..000000000 --- a/libcore/dom/src/test/java/org/w3c/dom/events/EventListener.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.dom.events; - -/** - * The EventListener interface is the primary method for - * handling events. Users implement the EventListener interface - * and register their listener on an EventTarget using the - * AddEventListener method. The users should also remove their - * EventListener from its EventTarget after they - * have completed using the listener. - *

When a Node is copied using the cloneNode - * method the EventListeners attached to the source - * Node are not attached to the copied Node. If - * the user wishes the same EventListeners to be added to the - * newly created copy the user must add them manually. - *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 - */ -public interface EventListener { - /** - * This method is called whenever an event occurs of the type for which - * the EventListener interface was registered. - * @param evt The Event contains contextual information - * about the event. It also contains the stopPropagation - * and preventDefault methods which are used in - * determining the event's flow and default action. - */ - public void handleEvent(Event evt); - -} diff --git a/libcore/dom/src/test/java/org/w3c/dom/events/EventTarget.java b/libcore/dom/src/test/java/org/w3c/dom/events/EventTarget.java deleted file mode 100644 index 65e62869f..000000000 --- a/libcore/dom/src/test/java/org/w3c/dom/events/EventTarget.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.dom.events; - -/** - * The EventTarget interface is implemented by all - * Nodes in an implementation which supports the DOM Event - * Model. Therefore, this interface can be obtained by using - * binding-specific casting methods on an instance of the Node - * interface. The interface allows registration and removal of - * EventListeners on an EventTarget and dispatch - * of events to that EventTarget. - *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 - */ -public interface EventTarget { - /** - * This method allows the registration of event listeners on the event - * target. If an EventListener is added to an - * EventTarget while it is processing an event, it will not - * be triggered by the current actions but may be triggered during a - * later stage of event flow, such as the bubbling phase. - *
If multiple identical EventListeners are registered - * on the same EventTarget with the same parameters the - * duplicate instances are discarded. They do not cause the - * EventListener to be called twice and since they are - * discarded they do not need to be removed with the - * removeEventListener method. - * @param typeThe event type for which the user is registering - * @param listenerThe listener parameter takes an interface - * implemented by the user which contains the methods to be called - * when the event occurs. - * @param useCaptureIf true, useCapture indicates that the - * user wishes to initiate capture. After initiating capture, all - * events of the specified type will be dispatched to the registered - * EventListener before being dispatched to any - * EventTargets beneath them in the tree. Events which - * are bubbling upward through the tree will not trigger an - * EventListener designated to use capture. - */ - public void addEventListener(String type, - EventListener listener, - boolean useCapture); - - /** - * This method allows the removal of event listeners from the event - * target. If an EventListener is removed from an - * EventTarget while it is processing an event, it will not - * be triggered by the current actions. EventListeners can - * never be invoked after being removed. - *
Calling removeEventListener with arguments which do - * not identify any currently registered EventListener on - * the EventTarget has no effect. - * @param typeSpecifies the event type of the EventListener - * being removed. - * @param listenerThe EventListener parameter indicates the - * EventListener to be removed. - * @param useCaptureSpecifies whether the EventListener - * being removed was registered as a capturing listener or not. If a - * listener was registered twice, one with capture and one without, - * each must be removed separately. Removal of a capturing listener - * does not affect a non-capturing version of the same listener, and - * vice versa. - */ - public void removeEventListener(String type, - EventListener listener, - boolean useCapture); - - /** - * This method allows the dispatch of events into the implementations - * event model. Events dispatched in this manner will have the same - * capturing and bubbling behavior as events dispatched directly by the - * implementation. The target of the event is the - * EventTarget on which dispatchEvent is - * called. - * @param evtSpecifies the event type, behavior, and contextual - * information to be used in processing the event. - * @return The return value of dispatchEvent indicates - * whether any of the listeners which handled the event called - * preventDefault. If preventDefault was - * called the value is false, else the value is true. - * @exception EventException - * UNSPECIFIED_EVENT_TYPE_ERR: Raised if the Event's type - * was not specified by initializing the event before - * dispatchEvent was called. Specification of the - * Event's type as null or an empty string - * will also trigger this exception. - */ - public boolean dispatchEvent(Event evt) - throws EventException; - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/BatikTestDocumentBuilderFactory.java b/libcore/dom/src/test/java/org/w3c/domts/BatikTestDocumentBuilderFactory.java deleted file mode 100644 index 8e5c68290..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/BatikTestDocumentBuilderFactory.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; - -/** - * This class implements the generic parser and configuation - * abstract class for the DOM implementation of Batik. - * - * @author Curt Arnold - */ -public class BatikTestDocumentBuilderFactory - extends DOMTestDocumentBuilderFactory { - - /** dom factory. */ - private Object domFactory; - - /** xml reader. */ - private org.xml.sax.XMLReader xmlReader; - - /** reflective method to create document in Batik. **/ - private Method createDocument; - - /** dom implementation from Batik. **/ - private DOMImplementation domImpl; - - /** - * Creates a Batik implementation of DOMTestDocumentBuilderFactory. - * @param settings array of settings, may be null. - * @throws DOMTestIncompatibleException - * If implementation does not support the specified settings - */ - public BatikTestDocumentBuilderFactory( - DocumentBuilderSetting[] settings) throws DOMTestIncompatibleException { - super(settings); - domImpl = null; - - // - // get the JAXP specified SAX parser's class name - // - SAXParserFactory saxFactory = SAXParserFactory.newInstance(); - try { - SAXParser saxParser = saxFactory.newSAXParser(); - xmlReader = saxParser.getXMLReader(); - } catch (Exception ex) { - throw new DOMTestIncompatibleException(ex, null); - } - String xmlReaderClassName = xmlReader.getClass().getName(); - - // - // can't change settings, so if not the same as - // the default SAX parser then throw an exception - // - // for(int i = 0; i < settings.length; i++) { - // if(!settings[i].hasSetting(this)) { - // TODO - // throw new DOMTestIncompatibleException(null,settings[i]); - // } - // } - // - // try loading Batik reflectively - // - try { - ClassLoader classLoader = ClassLoader.getSystemClassLoader(); - Class domFactoryClass = - classLoader.loadClass( - "org.apache.batik.dom.svg.SAXSVGDocumentFactory"); - - Constructor domFactoryConstructor = - domFactoryClass.getConstructor(new Class[] {String.class}); - domFactory = - domFactoryConstructor.newInstance( - new Object[] {xmlReaderClassName}); - createDocument = - domFactoryClass.getMethod( - "createDocument", - new Class[] {String.class, java.io.InputStream.class}); - } catch (InvocationTargetException ex) { - throw new DOMTestIncompatibleException( - ex.getTargetException(), - null); - } catch (Exception ex) { - throw new DOMTestIncompatibleException(ex, null); - } - } - - /** - * Create new instance of document builder factory - * reflecting specified settings. - * @param newSettings new settings - * @return New instance - * @throws DOMTestIncompatibleException - * if settings are not supported by implementation - */ - public DOMTestDocumentBuilderFactory newInstance( - DocumentBuilderSetting[] newSettings) - throws DOMTestIncompatibleException { - if (newSettings == null) { - return this; - } - DocumentBuilderSetting[] mergedSettings = mergeSettings(newSettings); - return new BatikTestDocumentBuilderFactory(mergedSettings); - } - - /** - * Loads specified URL. - * @param url url to load - * @return DOM document - * @throws DOMTestLoadException if unable to load document - */ - public Document load(java.net.URL url) throws DOMTestLoadException { - try { - java.io.InputStream stream = url.openStream(); - return (org.w3c.dom.Document) createDocument.invoke( - domFactory, - new Object[] {url.toString(), stream}); - } catch (InvocationTargetException ex) { - ex.printStackTrace(); - throw new DOMTestLoadException(ex.getTargetException()); - } catch (Exception ex) { - ex.printStackTrace(); - throw new DOMTestLoadException(ex); - } - } - - /** - * Gets DOMImplementation. - * @return DOM implementation, may be null - */ - public DOMImplementation getDOMImplementation() { - // - // get DOM implementation - // - if (domImpl == null) { - try { - Class svgDomImplClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.apache.batik.dom.svg.SVGDOMImplementation"); - Method getImpl = - svgDomImplClass.getMethod( - "getDOMImplementation", - new Class[0]); - domImpl = - (DOMImplementation) getImpl.invoke(null, new Object[0]); - } catch (Exception ex) { - return null; - } - } - return domImpl; - } - - /** - * Determines if the implementation supports the specified feature. - * @param feature Feature - * @param version Version - * @return true if implementation supports the feature - */ - public boolean hasFeature(String feature, String version) { - return getDOMImplementation().hasFeature(feature, version); - } - - /** - * Adds any specialized extension required by the implementation. - * @param testFileName file name from test - * @return possibly modified file name - */ - public String addExtension(String testFileName) { - return testFileName + ".svg"; - } - - /** - * Indicates whether the implementation combines text and cdata nodes. - * @return true if coalescing - */ - public boolean isCoalescing() { - return false; - } - - /** - * Indicates whether the implementation expands entity references. - * @return true if expanding entity references - */ - public boolean isExpandEntityReferences() { - return false; - } - - /** - * Indicates whether the implementation ignores - * element content whitespace. - * @return true if ignoring element content whitespace - */ - public boolean isIgnoringElementContentWhitespace() { - return false; - } - - /** - * Indicates whether the implementation is namespace aware. - * @return true if namespace aware - */ - public boolean isNamespaceAware() { - return true; - } - - /** - * Indicates whether the implementation is validating. - * @return true if validating - */ - public boolean isValidating() { - return false; - } - - /** - * Gets content type. - * @return content type, "image/svg+xml" - */ - public String getContentType() { - return "image/svg+xml"; - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/DOM4JTestDocumentBuilderFactory.java b/libcore/dom/src/test/java/org/w3c/domts/DOM4JTestDocumentBuilderFactory.java deleted file mode 100644 index 8d6acdd67..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/DOM4JTestDocumentBuilderFactory.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -/* - $Log: DOM4JTestDocumentBuilderFactory.java,v $ - Revision 1.2 2004/03/11 01:44:21 dom-ts-4 - Checkstyle fixes (bug 592) - - Revision 1.1 2002/02/03 07:47:51 dom-ts-4 - More missing files - - */ - -package org.w3c.domts; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; -import org.xml.sax.XMLReader; - -/** - * This class implements the generic parser and configuation - * abstract class for JAXP supporting parsers. - */ -public class DOM4JTestDocumentBuilderFactory - extends DOMTestDocumentBuilderFactory { - - private final Object domFactory; - private final Object saxReader; - private final org.xml.sax.XMLReader xmlReader; - private org.w3c.dom.DOMImplementation domImpl; - private final Method readMethod; - - /** - * Creates a JAXP implementation of DOMTestDocumentBuilderFactory. - * @param factory null for default JAXP provider. If not null, - * factory will be mutated in constructor and should be released - * by calling code upon return. - * @param XMLReader if null use default XMLReader. If provided, - * it may be mutated and should be released by the caller immediately - * after the constructor. - * @param settings array of settings, may be null. - */ - public DOM4JTestDocumentBuilderFactory(DocumentBuilderSetting[] settings) throws - DOMTestIncompatibleException { - super(settings); - try { - // - // The following reflection code is trying to accomplish - // - //domFactory = org.dom4j.dom.DOMDocumentFactory.getInstance(); - //domImpl = (DOMImplementation) domFactory; - //saxReader = new org.dom4j.io.SAXReader(domFactory); - //xmlReader = saxReader.getXMLReader(); - - ClassLoader classLoader = ClassLoader.getSystemClassLoader(); - Class domFactoryClass = classLoader.loadClass( - "org.dom4j.dom.DOMDocumentFactory"); - Method getInstance = domFactoryClass.getMethod("getInstance", new Class[] {}); - domFactory = getInstance.invoke(null, new Object[] {}); - domImpl = (DOMImplementation) domFactory; - Class saxReaderClass = classLoader.loadClass("org.dom4j.io.SAXReader"); - Constructor saxReaderConstructor = saxReaderClass.getConstructor( - new Class[] {classLoader.loadClass("org.dom4j.DocumentFactory")}); - saxReader = saxReaderConstructor.newInstance(new Object[] {domFactory}); - - Method getReaderMethod = saxReaderClass.getMethod("getXMLReader", - new Class[] {}); - xmlReader = (XMLReader) getReaderMethod.invoke(saxReader, new Object[0]); - - readMethod = saxReaderClass.getMethod("read", new Class[] {java.net.URL.class}); - } - catch (InvocationTargetException ex) { - throw new DOMTestIncompatibleException(ex.getTargetException(), null); - } - catch (Exception ex) { - throw new DOMTestIncompatibleException(ex, null); - } - // - // TODO: Process settings - // - } - - public DOMTestDocumentBuilderFactory newInstance(DocumentBuilderSetting[] - newSettings) throws DOMTestIncompatibleException { - if (newSettings == null) { - return this; - } - DocumentBuilderSetting[] mergedSettings = mergeSettings(newSettings); - return new DOM4JTestDocumentBuilderFactory(mergedSettings); - } - - public Document load(java.net.URL url) throws DOMTestLoadException { - if (url == null) { - throw new NullPointerException("url"); - } - if (saxReader == null) { - throw new NullPointerException("saxReader"); - } - try { - return (org.w3c.dom.Document) readMethod.invoke(saxReader, - new Object[] {url}); - } - catch (InvocationTargetException ex) { - ex.getTargetException().printStackTrace(); - throw new DOMTestLoadException(ex.getTargetException()); - } - catch (Exception ex) { - ex.printStackTrace(); - throw new DOMTestLoadException(ex); - } - } - - public DOMImplementation getDOMImplementation() { - return domImpl; - } - - public boolean hasFeature(String feature, String version) { - return domImpl.hasFeature(feature, version); - } - - public boolean isCoalescing() { - return false; - } - - public boolean isExpandEntityReferences() { - return false; - } - - public boolean isIgnoringElementContentWhitespace() { - return false; - } - - public boolean isNamespaceAware() { - return true; - } - - public boolean isValidating() { - return false; - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/DOMErrorImpl.java b/libcore/dom/src/test/java/org/w3c/domts/DOMErrorImpl.java deleted file mode 100644 index 8cc211582..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/DOMErrorImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - -import org.w3c.dom.DOMError; -import org.w3c.dom.DOMLocator; - -/** - * This is a utility implementation of EventListener - * that captures all events and provides access - * to lists of all events by mode - */ -public class DOMErrorImpl - implements DOMError { - private final short severity; - private final String message; - private final String type; - private final Object relatedException; - private final Object relatedData; - private final DOMLocator location; - - /** - * Public constructor - * - */ - public DOMErrorImpl(DOMError src) { - this.severity = src.getSeverity(); - this.message = src.getMessage(); - this.type = src.getType(); - this.relatedException = src.getRelatedException(); - this.relatedData = src.getRelatedData(); - this.location = new DOMLocatorImpl(src.getLocation()); - } - - public final short getSeverity() { - return severity; - } - - public final String getMessage() { - return message; - } - - public final String getType() { - return type; - } - - public final Object getRelatedException() { - return relatedException; - } - - public final Object getRelatedData() { - return relatedData; - } - - public final DOMLocator getLocation() { - return location; - } -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/DOMErrorMonitor.java b/libcore/dom/src/test/java/org/w3c/domts/DOMErrorMonitor.java deleted file mode 100644 index 134dd03c7..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/DOMErrorMonitor.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - -import java.util.ArrayList; -import java.util.List; -import java.util.Iterator; - -import org.w3c.dom.DOMError; -import org.w3c.dom.DOMErrorHandler; - -/** - * This is a utility implementation of EventListener - * that captures all events and provides access - * to lists of all events by mode - */ -public class DOMErrorMonitor - implements DOMErrorHandler { - private final List errors = new ArrayList(); - - /** - * Public constructor - * - */ - public DOMErrorMonitor() { - } - - /** - * Implementation of DOMErrorHandler.handleError that - * adds copy of error to list for later retrieval. - * - */ - public boolean handleError(DOMError error) { - errors.add(new DOMErrorImpl(error)); - return true; - } - - /** - * Gets list of errors - * - * @return return errors - */ - public List getAllErrors() { - return new ArrayList(errors); - } - - public void assertLowerSeverity(DOMTestCase testCase, String id, int severity) { - Iterator iter = errors.iterator(); - while (iter.hasNext()) { - DOMError error = (DOMError) iter.next(); - if (error.getSeverity() >= severity) { - testCase.fail(id + error.getMessage()); - } - } - } -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/DOMLocatorImpl.java b/libcore/dom/src/test/java/org/w3c/domts/DOMLocatorImpl.java deleted file mode 100644 index 89a0c585e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/DOMLocatorImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ -package org.w3c.domts; - -import org.w3c.dom.DOMLocator; -import org.w3c.dom.Node; - -/** - * Implementation of DOMLocator - * - */ -public class DOMLocatorImpl - implements DOMLocator { - private final int lineNumber; - private final int columnNumber; - private final int byteOffset; - private final int utf16Offset; - private final Node relatedNode; - private final String uri; - - public DOMLocatorImpl(DOMLocator src) { - this.lineNumber = src.getLineNumber(); - this.columnNumber = src.getColumnNumber(); - this.byteOffset = src.getByteOffset(); - this.utf16Offset = src.getUtf16Offset(); - this.relatedNode = src.getRelatedNode(); - this.uri = src.getUri(); - } - - /* - * Line number - * @see org.w3c.dom.DOMLocator#getLineNumber() - */ - public int getLineNumber() { - return lineNumber; - } - - /* - * Column number - * @see org.w3c.dom.DOMLocator#getColumnNumber() - */ - public int getColumnNumber() { - return columnNumber; - } - - /* - * Byte offset - * @see org.w3c.dom.DOMLocator#getByteOffset() - */ - public int getByteOffset() { - return byteOffset; - } - - /* UTF-16 offset - * @see org.w3c.dom.DOMLocator#getUtf16Offset() - */ - public int getUtf16Offset() { - return utf16Offset; - } - - /* Related node - * @see org.w3c.dom.DOMLocator#getRelatedNode() - */ - public Node getRelatedNode() { - return relatedNode; - } - - /* URI - * @see org.w3c.dom.DOMLocator#getUri() - */ - public String getUri() { - return uri; - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/DOMTest.java b/libcore/dom/src/test/java/org/w3c/domts/DOMTest.java deleted file mode 100644 index b39ea6736..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/DOMTest.java +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright (c) 2001-2003 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Method; -import java.net.MalformedURLException; -import java.net.URL; - -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; - -/** - * This is an abstract base class for generated DOM tests - * - */ -public abstract class DOMTest /* wBM: implements EventListener */ { - private DOMTestDocumentBuilderFactory factory; - private int mutationCount = 0; - - /** - * This is the appropriate constructor for tests that make no requirements - * on the parser configuration. - * - * @param factory - * must not be null - */ - public DOMTest(DOMTestDocumentBuilderFactory factory) { - if (factory == null) { - throw new NullPointerException("factory"); - } - this.factory = factory; - } - - /** - * This constructor is used by tests that must create a modified document - * factory to meet requirements on the parser configuration. setFactory - * should be called within the test's constructor. - */ - public DOMTest() { - factory = null; - } - - /** - * Should only be called in the constructor of a derived type. - */ - protected void setFactory(DOMTestDocumentBuilderFactory factory) { - this.factory = factory; - } - - public boolean hasFeature(String feature, String version) { - return factory.hasFeature(feature, version); - } - - public boolean hasSetting(DocumentBuilderSetting setting) { - return setting.hasSetting(factory); - } - - protected DOMTestDocumentBuilderFactory getFactory() { - return factory; - } - - public DOMImplementation getImplementation() { - return factory.getDOMImplementation(); - } - - private URL resolveURI(String baseURI) throws DOMTestLoadException { - String docURI = factory.addExtension(baseURI); - - URL resolvedURI = null; - try { - resolvedURI = new URL(docURI); - if (resolvedURI.getProtocol() != null) { - return resolvedURI; - } - } - catch (MalformedURLException ex) { - // throw new DOMTestLoadException(ex); - } - // - // build a URL for a test file in the JAR - // - resolvedURI = getClass().getResource("/" + docURI); - if (resolvedURI == null) { - // - // see if it is an absolute URI - // - int firstSlash = docURI.indexOf('/'); - try { - if (firstSlash == 0 - || (firstSlash >= 1 - && docURI.charAt(firstSlash - 1) == ':')) { - resolvedURI = new URL(docURI); - } - else { - // - // try the files/level?/spec directory - // - String filename = getClass().getPackage().getName(); - filename = - "tests/" - + filename.substring(14).replace('.', '/') - + "/files/" - + docURI; - resolvedURI = new java.io.File(filename).toURL(); - } - } - catch (MalformedURLException ex) { - throw new DOMTestLoadException(ex); - } - } - - if (resolvedURI == null) { - throw new DOMTestLoadException( - new java.io.FileNotFoundException(docURI)); - } - return resolvedURI; - } - - public String getResourceURI(String href, String scheme, String contentType) throws - DOMTestLoadException { - if (scheme == null) { - throw new NullPointerException("scheme"); - } - if ("file".equals(scheme)) { - return resolveURI(href).toString(); - } - if ("http".equals(scheme)) { - StringBuffer httpURL = new StringBuffer( - System.getProperty("org.w3c.domts.httpbase", - "http://localhost:8080/webdav/")); - httpURL.append(href); - if ("application/pdf".equals(contentType)) { - httpURL.append(".pdf"); - } - else { - httpURL.append(".xml"); - } - return httpURL.toString(); - } - throw new DOMTestLoadException(new Exception("Unrecognized URI scheme " + - scheme)); - } - - public String createTempURI(String scheme) throws DOMTestLoadException { - if (scheme == null) { - throw new NullPointerException("scheme"); - } - if ("file".equals(scheme)) { - try { - File tempFile = File.createTempFile("domts", ".xml"); - try { - // - // if available use JDK 1.4's File.toURI().toString() - // - Method method = File.class.getMethod("toURI", null); - Object uri = method.invoke(tempFile, null); - return uri.toString(); - } - catch (NoSuchMethodException ex) { - // - // File.toURL is not as robust - // - URL url = tempFile.toURL(); - return url.toString(); - } - } - catch (Exception ex) { - throw new DOMTestLoadException(ex); - } - } - if ("http".equals(scheme)) { - String httpBase = System.getProperty("org.w3c.domts.httpbase", - "http://localhost:8080/webdav/"); - java.lang.StringBuffer buf = new StringBuffer(httpBase); - if (!httpBase.endsWith("/")) { - buf.append("/"); - } - buf.append("tmp"); - buf.append( (new java.util.Random()).nextInt(Integer.MAX_VALUE)); - buf.append(".xml"); - return buf.toString(); - } - throw new DOMTestLoadException(new Exception("Unrecognized URI scheme " + - scheme)); - } - - public Document load(String docURI, boolean willBeModified) throws - DOMTestLoadException { - Document doc = factory.load(resolveURI(docURI)); - // - // if will be modified is false and doc is an EventTarget - // - /* - * wBM: if (!willBeModified && doc instanceof EventTarget) { - * ((EventTarget) doc).addEventListener("DOMSubtreeModified", this, - * false); } - */ - return doc; - } - - public void preload(String contentType, String docURI, boolean willBeModified) throws - DOMTestIncompatibleException { - if ("text/html".equals(contentType) || - "application/xhtml+xml".equals(contentType)) { - if (docURI.startsWith("staff") || docURI.equals("datatype_normalization")) { - throw DOMTestIncompatibleException.incompatibleLoad(docURI, contentType); - } - } - } - - public Object createXPathEvaluator(Document doc) { - return factory.createXPathEvaluator(doc); - } - - public InputStream createStream(String bytes) throws DOMTestLoadException, - IOException { - int byteCount = bytes.length() / 2; - byte[] array = new byte[byteCount]; - for (int i = 0; i < byteCount; i++) { - array[i] = Byte.parseByte(bytes.substring(i * 2, i * 2 + 2), 16); - } - return new java.io.ByteArrayInputStream(array); - } - - abstract public String getTargetURI(); - - public final boolean isCoalescing() { - return factory.isCoalescing(); - } - - public final boolean isExpandEntityReferences() { - return factory.isExpandEntityReferences(); - } - - public final boolean isIgnoringElementContentWhitespace() { - return factory.isIgnoringElementContentWhitespace(); - } - - public final boolean isNamespaceAware() { - return factory.isNamespaceAware(); - } - - public final boolean isValidating() { - return factory.isValidating(); - } - - public final boolean isSigned() { - return true; - } - - public final boolean isHasNullString() { - return true; - } - - public final String getContentType() { - return factory.getContentType(); - } - - /** - * Implementation of EventListener.handleEvent - * - * This method is called when a mutation is reported for a document that - * was declared to not be modified during testing - * - * @param evt - * mutation event - */ - /* - * wBM: public final void handleEvent(Event evt) { mutationCount++; } - */ - - public final int getMutationCount() { - return mutationCount; - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/DOMTestCase.java b/libcore/dom/src/test/java/org/w3c/domts/DOMTestCase.java deleted file mode 100644 index 150877252..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/DOMTestCase.java +++ /dev/null @@ -1,983 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Iterator; - -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.NodeList; - -/** - * This is an abstract base class for generated DOM tests - */ -public abstract class DOMTestCase - extends DOMTest { - private DOMTestFramework framework; - - /** - * This constructor is for DOMTestCase's that make specific demands for - * parser configuration. setFactory should be called before the end of the - * tests constructor to set the factory. - */ - public DOMTestCase() { - framework = null; - } - - /** - * This constructor is for DOMTestCase's that do not add any requirements - * for parser configuration. - * - * @param factory - * document factory to be used by test, may not be null. - */ - public DOMTestCase(DOMTestDocumentBuilderFactory factory) { - super(factory); - framework = null; - } - - /** - * This method is called by the main() for each test and locates the - * appropriate test framework and runs the specified test - * - * @param testClass - * test class - * @param args - * arguments to test class - */ - public static void doMain(Class testClass, String[] args) { - // - // Attempt to load JUnitRunner - // - ClassLoader loader = ClassLoader.getSystemClassLoader(); - try { - Class runnerClass = loader.loadClass("org.w3c.domts.JUnitRunner"); - Constructor runnerFactory = - runnerClass.getConstructor(new Class[] {Class.class}); - // - // create the JUnitRunner - // - Object junitRun = - runnerFactory.newInstance(new Object[] {testClass}); - // - // find and call its execute method method - // - Class argsClass = loader.loadClass("[Ljava.lang.String;"); - Method execMethod = - runnerClass.getMethod("execute", new Class[] {argsClass}); - execMethod.invoke(junitRun, new Object[] {args}); - } - catch (InvocationTargetException ex) { - ex.getTargetException().printStackTrace(); - } - catch (Exception ex) { - System.out.println( - "junit-run.jar and junit.jar \n must be in same directory or on classpath."); - ex.printStackTrace(); - } - } - - /** - * Body of test - * - * @throws Throwable - */ - abstract public void runTest() throws Throwable; - - /** - * Sets test framework to be used by test. - * - * @param framework - */ - public void setFramework(DOMTestFramework framework) { - this.framework = framework; - } - - /** - * Wait - * - * @param millisecond - * milliseconds to wait - */ - public void wait(int millisecond) { - framework.wait(millisecond); - } - - /** - * Fail test - * - * @param assertID - * identifier of assertion - */ - public void fail(String assertID) { - framework.fail(this, assertID); - } - - /** - * Asserts that actual==true - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - */ - public void assertTrue(String assertID, boolean actual) { - framework.assertTrue(this, assertID, actual); - } - - /** - * Asserts that actual==true - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - */ - public void assertTrue(String assertID, Object actual) { - framework.assertTrue(this, assertID, ( (Boolean) actual).booleanValue()); - } - - /** - * Asserts that actual==false - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - */ - public void assertFalse(String assertID, boolean actual) { - framework.assertFalse(this, assertID, actual); - } - - /** - * Asserts that actual==false - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - */ - public void assertFalse(String assertID, Object actual) { - framework.assertFalse( - this, - assertID, - ( (Boolean) actual).booleanValue()); - } - - /** - * Asserts that actual == null - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - */ - public void assertNull(String assertID, Object actual) { - framework.assertNull(this, assertID, actual); - } - - /** - * Asserts that actual != null - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - */ - public void assertNotNull(String assertID, Object actual) { - framework.assertNotNull(this, assertID, actual); - } - - /** - * Asserts that actual and expected are the same object - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - */ - public void assertSame(String assertID, Object expected, Object actual) { - framework.assertSame(this, assertID, expected, actual); - } - - /** - * Asserts that obj is an instance of cls - * - * @param assertID - * identifier of assertion - * @param obj - * object - * @param cls - * class, may not be null. - */ - public void assertInstanceOf(String assertID, Class cls, Object obj) { - framework.assertInstanceOf(this, assertID, obj, cls); - } - - /** - * Asserts that the length of the collection is the expected size. - * - * @param assertID - * identifier of assertion - * @param expectedSize - * expected size - * @param collection - * collection - */ - public void assertSize( - String assertID, - int expectedSize, - NodeList collection) { - framework.assertSize(this, assertID, expectedSize, collection); - } - - /** - * Asserts that the length of the collection is the expected size. - * - * @param assertID - * identifier of assertion - * @param expectedSize - * expected size - * @param collection - * collection - */ - public void assertSize( - String assertID, - int expectedSize, - NamedNodeMap collection) { - framework.assertSize(this, assertID, expectedSize, collection); - } - - /** - * Asserts that the length of the collection is the expected size. - * - * @param assertID - * identifier of assertion - * @param expectedSize - * expected size - * @param collection - * collection - */ - public void assertSize( - String assertID, - int expectedSize, - Collection collection) { - framework.assertSize(this, assertID, expectedSize, collection); - } - - /** - * Asserts that expected.equalsIgnoreCase(actual) is true - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - * @param expected - * Expected value, may not be null. - */ - public void assertEqualsIgnoreCase( - String assertID, - String expected, - String actual) { - framework.assertEqualsIgnoreCase(this, assertID, expected, actual); - } - - /** - * Asserts that each entry in actual is matched with an entry in expected - * that only differs by case. Order is not significant. - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - * @param expected - * Expected value, may not be null. - */ - public void assertEqualsIgnoreCase( - String assertID, - Collection expected, - Collection actual) { - framework.assertEqualsIgnoreCase(this, assertID, expected, actual); - } - - /** - * Asserts that each entry in actual is matched with an entry in expected - * that only differs by case. Order is significant. - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - * @param expected - * Expected value, may not be null. - */ - public void assertEqualsIgnoreCase( - String assertID, - List expected, - List actual) { - framework.assertEqualsIgnoreCase(this, assertID, expected, actual); - } - - /** - * Asserts that expected.equalsIgnoreCase(actual) is true - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - * @param expected - * Expected value, may not be null. - */ - public void assertEqualsAutoCase( - String context, - String assertID, - String expected, - String actual) { - String contentType = getContentType(); - // - // if the content type is HTML (not XHTML) - // - if ("text/html".equals(contentType)) { - // - // if the context is attribute, then use case-insentive comparison - // - if ("attribute".equals(context)) { - framework.assertEqualsIgnoreCase(this, assertID, expected, actual); - } - else { - // - // otherwise should be compared against uppercased expectation - framework.assertEquals(this, assertID, expected.toUpperCase(), actual); - } - } - else { - framework.assertEquals(this, assertID, expected, actual); - } - } - - /** - * Creates an equivalent list where every member has - * been uppercased - * - */ - private List toUpperCase(Collection expected) { - List upperd = new ArrayList(expected.size()); - Iterator iter = expected.iterator(); - while (iter.hasNext()) { - upperd.add(iter.next().toString().toUpperCase()); - } - return upperd; - } - - /** - * Asserts that each entry in actual is matched with an entry in expected - * that only differs by case. Order is not significant. - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - * @param expected - * Expected value, may not be null. - */ - public void assertEqualAutoCase( - String context, - String assertID, - Collection expected, - Collection actual) { - String contentType = getContentType(); - if ("text/html".equals(contentType)) { - if ("attribute".equals(context)) { - assertEqualsIgnoreCase(assertID, expected, actual); - } - else { - framework.assertEquals(this, assertID, toUpperCase(expected), actual); - } - - } - else { - framework.assertEquals(this, assertID, expected, actual); - } - } - - /** - * Asserts that each entry in actual is matched with an entry in expected - * that only differs by case. Order is significant. - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - * @param expected - * Expected value, may not be null. - */ - public void assertEqualsAutoCase( - String context, - String assertID, - List expected, - List actual) { - String contentType = getContentType(); - if ("text/html".equals(contentType)) { - if ("attribute".equals(context)) { - assertEqualsIgnoreCase(assertID, expected, actual); - } - else { - framework.assertEquals(this, assertID, toUpperCase(expected), actual); - } - - } - else { - framework.assertEquals(this, assertID, expected, actual); - } - } - - /** - * Asserts that expected.equals(actual) is true - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - * @param expected - * Expected value, may not be null. - */ - public void assertEquals(String assertID, String expected, String actual) { - framework.assertEquals(this, assertID, expected, actual); - } - - /** - * Asserts that values of expected and actual are equal. - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - * @param expected - * Expected value, may not be null. - */ - public void assertEquals(String assertID, int expected, int actual) { - framework.assertEquals(this, assertID, expected, actual); - } - - /** - * Asserts that values of expected and actual are equal. - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - * @param expected - * Expected value, may not be null. - */ - public void assertEquals(String assertID, double expected, double actual) { - framework.assertEquals(this, assertID, expected, actual); - } - - /** - * Asserts that values of expected and actual are equal. - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - * @param expected - * Expected value, may not be null. - */ - public void assertEquals( - String assertID, - boolean expected, - boolean actual) { - framework.assertEquals(this, assertID, expected, actual); - } - - /** - * Asserts that each entry in actual exactly matches with an entry in - * expected. Order is not significant. - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - * @param expected - * Expected value, may not be null. - */ - public void assertEquals( - String assertID, - Collection expected, - NodeList actual) { - Collection actualList = new ArrayList(); - int actualLen = actual.getLength(); - for (int i = 0; i < actualLen; i++) { - actualList.add(actual.item(i)); - } - framework.assertEquals(this, assertID, expected, actualList); - } - - /** - * Asserts that each entry in actual exactly matches with an entry in - * expected. Order is not significant. - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - * @param expected - * Expected value, may not be null. - */ - public void assertEquals( - String assertID, - Collection expected, - Collection actual) { - framework.assertEquals(this, assertID, expected, actual); - } - - /** - * Asserts that expected.equalsIgnoreCase(actual) is false - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - * @param expected - * Expected value, may not be null. - */ - public void assertNotEqualsIgnoreCase( - String assertID, - String expected, - String actual) { - framework.assertNotEqualsIgnoreCase(this, assertID, expected, actual); - } - - /** - * Asserts that expected.equalsIgnoreCase(actual) is false - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - * @param expected - * Expected value, may not be null. - */ - public void assertNotEqualsAutoCase( - String context, - String assertID, - String expected, - String actual) { - String contentType = getContentType(); - if ("text/html".equals(contentType)) { - if ("attribute".equals(context)) { - framework.assertNotEqualsIgnoreCase(this, assertID, expected, actual); - } - else { - framework.assertNotEquals(this, assertID, expected.toUpperCase(), - actual); - } - } - framework.assertNotEquals(this, assertID, expected, actual); - } - - /** - * Asserts that values of expected and actual are not equal. - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - * @param expected - * Expected value, may not be null. - */ - public void assertNotEquals( - String assertID, - String expected, - String actual) { - framework.assertNotEquals(this, assertID, expected, actual); - } - - /** - * Asserts that values of expected and actual are not equal. - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - * @param expected - * Expected value, may not be null. - */ - public void assertNotEquals(String assertID, int expected, int actual) { - framework.assertNotEquals(this, assertID, expected, actual); - } - - /** - * Asserts that values of expected and actual are not equal. - * - * @param assertID - * identifier of assertion - * @param actual - * actual value - * @param expected - * Expected value, may not be null. - */ - public void assertNotEquals( - String assertID, - double expected, - double actual) { - framework.assertNotEquals(this, assertID, expected, actual); - } - - /** - * Asserts aspects of a URI - * - * @param assertID - * identifier of assertion - * @param scheme - * Expected scheme, for example, "file". If null, scheme is - * ignored. - * @param path - * Expected path, for example, "/DOM/Test". If null, path is - * ignored. - * @param host - * Expected host, for example, "www.w3.org". If null, host is - * ignored. - * @param file - * Expected file, for example, "staff.xml". If null, file is - * ignored. - * @param name - * Expected name, for example, "staff". If null, name is - * ignored. - * @param name - * Expected name, for example, "staff". If null, name is - * ignored. - * @param isAbsolute - * if Boolean.TRUE, URI must be absolute. Null indicates no - * assertion. - * @param actual - * URI to be tested. - */ - public void assertURIEquals( - String assertID, - String scheme, - String path, - String host, - String file, - String name, - String query, - String fragment, - Boolean isAbsolute, - String actual) { - // - // URI must be non-null - assertNotNull(assertID, actual); - - String uri = actual; - - int lastPound = actual.lastIndexOf("#"); - String actualFragment = ""; - if (lastPound != -1) { - // - // substring before pound - // - uri = actual.substring(0, lastPound); - actualFragment = actual.substring(lastPound + 1); - } - if (fragment != null) { - assertEquals(assertID, fragment, actualFragment); - - } - int lastQuestion = uri.lastIndexOf("?"); - String actualQuery = ""; - if (lastQuestion != -1) { - // - // substring before pound - // - uri = actual.substring(0, lastQuestion); - actualQuery = actual.substring(lastQuestion + 1); - } - if (query != null) { - assertEquals(assertID, query, actualQuery); - - } - int firstColon = uri.indexOf(":"); - int firstSlash = uri.indexOf("/"); - String actualPath = uri; - String actualScheme = ""; - if (firstColon != -1 && firstColon < firstSlash) { - actualScheme = uri.substring(0, firstColon); - actualPath = uri.substring(firstColon + 1); - } - - if (scheme != null) { - assertEquals(assertID, scheme, actualScheme); - } - - if (path != null) { - assertEquals(assertID, path, actualPath); - } - - if (host != null) { - String actualHost = ""; - if (actualPath.startsWith("//")) { - int termSlash = actualPath.indexOf("/", 2); - actualHost = actualPath.substring(0, termSlash); - } - assertEquals(assertID, host, actualHost); - } - - String actualFile = actualPath; - if (file != null || name != null) { - int finalSlash = actualPath.lastIndexOf("/"); - if (finalSlash != -1) { - actualFile = actualPath.substring(finalSlash + 1); - } - if (file != null) { - assertEquals(assertID, file, actualFile); - } - } - - if (name != null) { - String actualName = actualFile; - int finalPeriod = actualFile.lastIndexOf("."); - if (finalPeriod != -1) { - actualName = actualFile.substring(0, finalPeriod); - } - assertEquals(assertID, name, actualName); - } - - if (isAbsolute != null) { - // - // Jar URL's will have any actual path like file:/c:/somedrive... - assertEquals( - assertID, - isAbsolute.booleanValue(), - actualPath.startsWith("/") || actualPath.startsWith("file:/")); - } - } - - /** - * Compares the identity of actual and expected. - * - * @param expected - * expected - * @param actual - * actual - * @return true if actual and expected are the same object. - */ - public boolean same(Object expected, Object actual) { - return framework.same(expected, actual); - } - - /** - * Compares the value of actual and expected ignoring case. - * - * @param expected - * expected - * @param actual - * actual - * @return true if actual and expected are equal ignoring case. - */ - public boolean equalsIgnoreCase(String expected, String actual) { - return framework.equalsIgnoreCase(expected, actual); - } - - /** - * Compares the values in actual and expected ignoring case and order. - * - * @param expected - * expected - * @param actual - * actual - * @return true if actual and expected are equal ignoring case. - */ - public boolean equalsIgnoreCase(Collection expected, Collection actual) { - return framework.equalsIgnoreCase(expected, actual); - } - - /** - * Compares the values in actual and expected ignoring case. - * - * @param expected - * expected - * @param actual - * actual - * @return true if actual and expected are equal ignoring case. - */ - public boolean equalsIgnoreCase(List expected, List actual) { - return framework.equalsIgnoreCase(expected, actual); - } - - /** - * Compares the value of actual and expected ignoring case. - * - * @param expected - * expected - * @param actual - * actual - * @return true if actual and expected are equal ignoring case. - */ - public boolean equalsAutoCase(String context, String expected, String actual) { - if ("text/html".equals(getContentType())) { - if ("attribute".equals(context)) { - return framework.equalsIgnoreCase(expected, actual); - } - else { - return framework.equals(expected.toUpperCase(), actual); - } - } - return framework.equals(expected, actual); - } - - /** - * Compares the values in actual and expected ignoring case and order. - * - * @param expected - * expected - * @param actual - * actual - * @return true if actual and expected are equal ignoring case. - */ - public boolean equalsAutoCase(String context, Collection expected, - Collection actual) { - if ("text/html".equals(getContentType())) { - if ("attribute".equals(context)) { - return framework.equalsIgnoreCase(expected, actual); - } - else { - return framework.equals(toUpperCase(expected), actual); - } - } - return framework.equals(expected, actual); - } - - /** - * Compares the values in actual and expected ignoring case. - * - * @param expected - * expected - * @param actual - * actual - * @return true if actual and expected are equal ignoring case. - */ - public boolean equalsAutoCase(String context, List expected, List actual) { - if ("text/html".equals(getContentType())) { - if ("attribute".equals(context)) { - return framework.equalsIgnoreCase(expected, actual); - } - else { - return framework.equals(toUpperCase(expected), actual); - } - } - return framework.equals(expected, actual); - } - - /** - * Compares the values of actual and expected. - * - * @param expected - * expected - * @param actual - * actual - * @return true if actual and expected are equal. - */ - public boolean equals(String expected, String actual) { - return framework.equals(expected, actual); - } - - /** - * Compares the values of actual and expected. - * - * @param expected - * expected - * @param actual - * actual - * @return true if actual and expected are equal. - */ - public boolean equals(int expected, int actual) { - return framework.equals(expected, actual); - } - - /** - * Compares the values of actual and expected. - * - * @param expected - * expected - * @param actual - * actual - * @return true if actual and expected are equal. - */ - public boolean equals(double expected, double actual) { - return framework.equals(expected, actual); - } - - /** - * Compares the values in actual and expected ignoring order. - * - * @param expected - * expected - * @param actual - * actual - * @return true if actual and expected are equal. - */ - public boolean equals(Collection expected, Collection actual) { - return framework.equals(expected, actual); - } - - /** - * Compares the values in actual and expected. - * - * @param expected - * expected - * @param actual - * actual - * @return true if actual and expected are equal. - */ - public boolean equals(List expected, List actual) { - return framework.equals(expected, actual); - } - - /** - * Gets the size of the collection - * - * @param collection - * collection, may not be null. - * @return size of collection - */ - public int size(Collection collection) { - return framework.size(collection); - } - - /** - * Gets the size of the collection - * - * @param collection - * collection, may not be null. - * @return size of collection - */ - public int size(NamedNodeMap collection) { - return framework.size(collection); - } - - /** - * Gets the size of the collection - * - * @param collection - * collection, may not be null. - * @return size of collection - */ - public int size(NodeList collection) { - return framework.size(collection); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/DOMTestDocumentBuilderFactory.java b/libcore/dom/src/test/java/org/w3c/domts/DOMTestDocumentBuilderFactory.java deleted file mode 100644 index b24e70e89..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/DOMTestDocumentBuilderFactory.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; - -/** - * This class represents a particular parser and configuration - * (such as entity-expanding, non-validating, whitespace ignoring) - * for a test session. Individual tests or suites within a - * session can override the session properties on a call to - * createBuilderFactory. - * - * @author Curt Arnold - */ -public abstract class DOMTestDocumentBuilderFactory { - /** - * Parser configuration - */ - private final DocumentBuilderSetting[] settings; - - /** - * Constructor - * @param properties Array of parser settings, may be null. - */ - public DOMTestDocumentBuilderFactory(DocumentBuilderSetting[] settings) throws - DOMTestIncompatibleException { - if (settings == null) { - this.settings = new DocumentBuilderSetting[0]; - } - else { - this.settings = (DocumentBuilderSetting[]) settings.clone(); - } - } - - /** - * Returns an instance of DOMTestDocumentBuilderFactory - * with the settings from the argument list - * and any non-revoked settings from the current object. - * @param settings array of settings, may be null. - */ - public abstract DOMTestDocumentBuilderFactory newInstance( - DocumentBuilderSetting[] settings) throws DOMTestIncompatibleException; - - public abstract DOMImplementation getDOMImplementation(); - - public abstract boolean hasFeature(String feature, String version); - - public abstract Document load(java.net.URL url) throws DOMTestLoadException; - - /** - * Creates XPath evaluator - * @param doc DOM document, may not be null - */ - public Object createXPathEvaluator(Document doc) { - try { - Method getFeatureMethod = doc.getClass().getMethod("getFeature", - new Class[] {String.class, String.class}); - if (getFeatureMethod != null) { - return getFeatureMethod.invoke(doc, new Object[] {"XPath", null}); - } - } - catch (Exception ex) { - } - return doc; - } - - /** - * Merges the settings from the specific test case or suite - * with the existing (typically session) settings. - * @param settings new settings, may be null which will - * return clone of existing settings. - */ - protected DocumentBuilderSetting[] mergeSettings(DocumentBuilderSetting[] - newSettings) { - if (newSettings == null) { - return (DocumentBuilderSetting[]) settings.clone(); - } - List mergedSettings = new ArrayList(settings.length + newSettings.length); - // - // all new settings are respected - // - for (int i = 0; i < newSettings.length; i++) { - mergedSettings.add(newSettings[i]); - } - // - // for all previous settings, take only those that - // do not conflict with existing settings - for (int i = 0; i < settings.length; i++) { - DocumentBuilderSetting setting = settings[i]; - boolean hasConflict = false; - for (int j = 0; j < newSettings.length; j++) { - DocumentBuilderSetting newSetting = newSettings[j]; - if (newSetting.hasConflict(setting) || setting.hasConflict(newSetting)) { - hasConflict = true; - break; - } - } - if (!hasConflict) { - mergedSettings.add(setting); - } - } - - DocumentBuilderSetting[] mergedArray = - new DocumentBuilderSetting[mergedSettings.size()]; - for (int i = 0; i < mergedSettings.size(); i++) { - mergedArray[i] = (DocumentBuilderSetting) mergedSettings.get(i); - } - return mergedArray; - } - - public String addExtension(String testFileName) { - String contentType = getContentType(); - if ("text/html".equals(contentType)) { - return testFileName + ".html"; - } - if ("image/svg+xml".equals(contentType)) { - return testFileName + ".svg"; - } - if ("application/xhtml+xml".equals(contentType)) { - return testFileName + ".xhtml"; - } - return testFileName + ".xml"; - } - - public abstract boolean isCoalescing(); - - public abstract boolean isExpandEntityReferences(); - - public abstract boolean isIgnoringElementContentWhitespace(); - - public abstract boolean isNamespaceAware(); - - public abstract boolean isValidating(); - - public String getContentType() { - return System.getProperty("org.w3c.domts.contentType", "text/xml"); - } - - /** - * Creates an array of all determinable settings for the DocumentBuilder - * including those at implementation defaults. - * @param builder must not be null - */ - public final DocumentBuilderSetting[] getActualSettings() { - - DocumentBuilderSetting[] allSettings = new DocumentBuilderSetting[] { - DocumentBuilderSetting.coalescing, - DocumentBuilderSetting.expandEntityReferences, - DocumentBuilderSetting.hasNullString, - DocumentBuilderSetting.ignoringElementContentWhitespace, - DocumentBuilderSetting.namespaceAware, - DocumentBuilderSetting.signed, - DocumentBuilderSetting.validating, - DocumentBuilderSetting.notCoalescing, - DocumentBuilderSetting.notExpandEntityReferences, - DocumentBuilderSetting.notHasNullString, - DocumentBuilderSetting.notIgnoringElementContentWhitespace, - DocumentBuilderSetting.notNamespaceAware, - DocumentBuilderSetting.notSigned, - DocumentBuilderSetting.notValidating - }; - - List list = new ArrayList(allSettings.length / 2); - for (int i = 0; i < allSettings.length; i++) { - if (allSettings[i].hasSetting(this)) { - list.add(allSettings[i]); - } - } - DocumentBuilderSetting[] settings = new DocumentBuilderSetting[list.size()]; - for (int i = 0; i < settings.length; i++) { - settings[i] = (DocumentBuilderSetting) list.get(i); - } - return settings; - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/DOMTestFramework.java b/libcore/dom/src/test/java/org/w3c/domts/DOMTestFramework.java deleted file mode 100644 index c836f4b5e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/DOMTestFramework.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - -import java.util.Collection; -import java.util.List; - -import javax.xml.parsers.DocumentBuilder; - -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.NodeList; - -/** - * This interface provides services typically provided by a test framework - */ -public interface DOMTestFramework { - boolean hasFeature( - DocumentBuilder docBuilder, - String feature, - String version); - - void wait(int millisecond); - - void fail(DOMTestCase test, String assertID); - - void assertTrue(DOMTestCase test, String assertID, boolean actual); - - void assertFalse(DOMTestCase test, String assertID, boolean actual); - - void assertNull(DOMTestCase test, String assertID, Object actual); - - void assertNotNull(DOMTestCase test, String assertID, Object actual); - - void assertSame( - DOMTestCase test, - String assertID, - Object expected, - Object actual); - - void assertInstanceOf( - DOMTestCase test, - String assertID, - Object obj, - Class cls); - - void assertSize( - DOMTestCase test, - String assertID, - int expectedSize, - NodeList collection); - - void assertSize( - DOMTestCase test, - String assertID, - int expectedSize, - NamedNodeMap collection); - - void assertSize( - DOMTestCase test, - String assertID, - int expectedSize, - Collection collection); - - void assertEqualsIgnoreCase( - DOMTestCase test, - String assertID, - String expected, - String actual); - - void assertEqualsIgnoreCase( - DOMTestCase test, - String assertID, - Collection expected, - Collection actual); - - void assertEqualsIgnoreCase( - DOMTestCase test, - String assertID, - List expected, - List actual); - - void assertEquals( - DOMTestCase test, - String assertID, - String expected, - String actual); - - void assertEquals( - DOMTestCase test, - String assertID, - int expected, - int actual); - - void assertEquals( - DOMTestCase test, - String assertID, - boolean expected, - boolean actual); - - void assertEquals( - DOMTestCase test, - String assertID, - double expected, - double actual); - - void assertEquals( - DOMTestCase test, - String assertID, - Collection expected, - Collection actual); - - void assertNotEqualsIgnoreCase( - DOMTestCase test, - String assertID, - String expected, - String actual); - - void assertNotEquals( - DOMTestCase test, - String assertID, - String expected, - String actual); - - void assertNotEquals( - DOMTestCase test, - String assertID, - int expected, - int actual); - - void assertNotEquals( - DOMTestCase test, - String assertID, - boolean expected, - boolean actual); - - void assertNotEquals( - DOMTestCase test, - String assertID, - double expected, - double actual); - - boolean same(Object expected, Object actual); - - boolean equalsIgnoreCase(String expected, String actual); - - boolean equalsIgnoreCase(Collection expected, Collection actual); - - boolean equalsIgnoreCase(List expected, List actual); - - boolean equals(String expected, String actual); - - boolean equals(int expected, int actual); - - boolean equals(boolean expected, boolean actual); - - boolean equals(double expected, double actual); - - boolean equals(Collection expected, Collection actual); - - boolean equals(List expected, List actual); - - int size(Collection collection); - - int size(NamedNodeMap collection); - - int size(NodeList collection); -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/DOMTestIncompatibleException.java b/libcore/dom/src/test/java/org/w3c/domts/DOMTestIncompatibleException.java deleted file mode 100644 index 2a1c0e023..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/DOMTestIncompatibleException.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts; - - -/** - * This exception represents a mismatch between the - * requirements of the test (for example, entity preserving) - * and the capabilities of the parser under test. - * @author Curt Arnold - */ -public class DOMTestIncompatibleException - extends Exception { - private final String msg; - - private DOMTestIncompatibleException(String msg) { - this.msg = msg; - } - - /** - * Constructor from a ParserConfigurationException - * or reflection exception - */ - public DOMTestIncompatibleException(Throwable ex, - DocumentBuilderSetting setting) { - if (ex != null) { - msg = ex.toString(); - } - else { - if (setting != null) { - msg = setting.toString(); - } - else { - msg = super.toString(); - } - } - } - - public static DOMTestIncompatibleException incompatibleFeature(String feature, - String version) { - StringBuffer buf = new StringBuffer( - "Implementation does not support feature \""); - buf.append(feature); - buf.append("\" version=\""); - buf.append(version); - buf.append("\"."); - return new DOMTestIncompatibleException(buf.toString()); - } - - public static DOMTestIncompatibleException incompatibleLoad(String href, - String contentType) { - StringBuffer buf = new StringBuffer( - "Document is incompatible with content type, \""); - buf.append(href); - buf.append("\" not available for =\""); - buf.append(contentType); - buf.append("\"."); - return new DOMTestIncompatibleException(buf.toString()); - } - - public String toString() { - return msg; - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/DOMTestInnerClass.java b/libcore/dom/src/test/java/org/w3c/domts/DOMTestInnerClass.java deleted file mode 100644 index 2c9d9ba0d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/DOMTestInnerClass.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - -import java.util.Collection; -import java.util.List; - -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.NodeList; - -/** - * This class provides access to DOMTestCase methods (like - * assertEquals) for inner classes - */ -public class DOMTestInnerClass { - private final DOMTestCase test; - - public DOMTestInnerClass(DOMTestCase test) { - this.test = test; - } - - public void wait(int millisecond) { - test.wait(millisecond); - } - - public void assertTrue(String assertID, boolean actual) { - test.assertTrue(assertID, actual); - } - - public void assertFalse(String assertID, boolean actual) { - test.assertFalse(assertID, actual); - } - - public void assertNull(String assertID, Object actual) { - test.assertNull(assertID, actual); - } - - public void assertNotNull(String assertID, Object actual) { - test.assertNotNull(assertID, actual); - } - - public void assertSame(String assertID, Object expected, Object actual) { - test.assertSame(assertID, expected, actual); - } - - public void assertInstanceOf(String assertID, Class cls, Object obj) { - test.assertInstanceOf(assertID, cls, obj); - } - - public void assertSize(String assertID, int expectedSize, NodeList collection) { - test.assertSize(assertID, expectedSize, collection); - } - - public void assertSize(String assertID, int expectedSize, - NamedNodeMap collection) { - test.assertSize(assertID, expectedSize, collection); - } - - public void assertSize(String assertID, int expectedSize, - Collection collection) { - test.assertSize(assertID, expectedSize, collection); - } - - public void assertEqualsIgnoreCase(String assertID, String expected, - String actual) { - test.assertEqualsIgnoreCase(assertID, expected, actual); - } - - public void assertEqualsIgnoreCase(String assertID, Collection expected, - Collection actual) { - test.assertEqualsIgnoreCase(assertID, expected, actual); - } - - public void assertEqualsIgnoreCase(String assertID, List expected, - List actual) { - test.assertEqualsIgnoreCase(assertID, expected, actual); - } - - public void assertEquals(String assertID, String expected, String actual) { - test.assertEquals(assertID, expected, actual); - } - - public void assertEquals(String assertID, int expected, int actual) { - test.assertEquals(assertID, expected, actual); - } - - public void assertEquals(String assertID, double expected, double actual) { - test.assertEquals(assertID, expected, actual); - } - - public void assertEquals(String assertID, boolean expected, boolean actual) { - test.assertEquals(assertID, expected, actual); - } - - public void assertEquals(String assertID, Collection expected, - NodeList actual) { - test.assertEquals(assertID, expected, actual); - } - - public void assertEquals(String assertID, Collection expected, - Collection actual) { - test.assertEquals(assertID, expected, actual); - } - - public void assertNotEqualsIgnoreCase(String assertID, String expected, - String actual) { - test.assertNotEqualsIgnoreCase(assertID, expected, actual); - } - - public void assertNotEquals(String assertID, String expected, String actual) { - test.assertNotEquals(assertID, expected, actual); - } - - public void assertNotEquals(String assertID, int expected, int actual) { - test.assertNotEquals(assertID, expected, actual); - } - - public void assertNotEquals(String assertID, double expected, double actual) { - test.assertNotEquals(assertID, expected, actual); - } - - public void assertURIEquals(String assertID, String scheme, String path, - String host, String file, String name, - String query, String fragment, Boolean isAbsolute, - String actual) { - test.assertURIEquals(assertID, scheme, path, host, file, name, query, - fragment, isAbsolute, actual); - } - - public boolean same(Object expected, Object actual) { - return test.same(expected, actual); - } - - public boolean equalsIgnoreCase(String expected, String actual) { - return test.equalsIgnoreCase(expected, actual); - } - - public boolean equalsIgnoreCase(Collection expected, Collection actual) { - return test.equalsIgnoreCase(expected, actual); - } - - public boolean equalsIgnoreCase(List expected, List actual) { - return test.equalsIgnoreCase(expected, actual); - } - - public boolean equals(String expected, String actual) { - return test.equals(expected, actual); - } - - public boolean equals(int expected, int actual) { - return test.equals(expected, actual); - } - - public boolean equals(double expected, double actual) { - return test.equals(expected, actual); - } - - public boolean equals(Collection expected, Collection actual) { - return test.equals(expected, actual); - } - - public boolean equals(List expected, List actual) { - return test.equals(expected, actual); - } - - public int size(Collection collection) { - return test.size(collection); - } - - public int size(NamedNodeMap collection) { - return test.size(collection); - } - - public int size(NodeList collection) { - return test.size(collection); - } - - public DOMImplementation getImplementation() { - return test.getImplementation(); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/DOMTestLoadException.java b/libcore/dom/src/test/java/org/w3c/domts/DOMTestLoadException.java deleted file mode 100644 index 7d320baa2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/DOMTestLoadException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - - -/** - * Encapsulates a concrete load exception such as - * a SAX exception - * @author Curt Arnold - * @date 2 Feb 2002 - */ -public class DOMTestLoadException - extends Exception { - private final Throwable innerException; - - /** - * Constructor - * @param innerException should not be null - */ - public DOMTestLoadException(Throwable innerException) { - this.innerException = innerException; - } - - public String toString() { - if (innerException != null) { - return innerException.toString(); - } - return super.toString(); - } -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/DOMTestSink.java b/libcore/dom/src/test/java/org/w3c/domts/DOMTestSink.java deleted file mode 100644 index 9c641a709..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/DOMTestSink.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -/* - $Log: DOMTestSink.java,v $ - Revision 1.2 2004/03/11 01:44:21 dom-ts-4 - Checkstyle fixes (bug 592) - - Revision 1.1 2001/07/23 04:52:20 dom-ts-4 - Initial test running using JUnit. - - */ - -package org.w3c.domts; - -public interface DOMTestSink { - public void addTest(Class test); -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/DOMTestSuite.java b/libcore/dom/src/test/java/org/w3c/domts/DOMTestSuite.java deleted file mode 100644 index 94a76b863..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/DOMTestSuite.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -/* - $Log: DOMTestSuite.java,v $ - Revision 1.4 2004/03/11 01:44:21 dom-ts-4 - Checkstyle fixes (bug 592) - - Revision 1.3 2002/02/03 04:22:35 dom-ts-4 - DOM4J and Batik support added. - Rework of parser settings - - Revision 1.2 2001/07/23 04:52:20 dom-ts-4 - Initial test running using JUnit. - - */ - -package org.w3c.domts; - -/** - * Abstract base class for all test suites - * (that is any collection of DOMTest's) - * - * @author Curt Arnold - */ -public abstract class DOMTestSuite - extends DOMTest { - /** - * This constructor is used for suites that - * assert one or more implementation attributes or - * features. setLibrary should be called before - * the completion of the constructor in the derived class. - */ - protected DOMTestSuite() { - } - - /** - * This constructor is used for suites that make no - * additional requirements on the parser configuration. - * @param factory may not be null - */ - protected DOMTestSuite(DOMTestDocumentBuilderFactory factory) { - super(factory); - } - - /** - * Adds a test to the test suite. This method can - * only be run after the test suite has been attached - * to a test framework since each framework implements - * test suites in different manners. - */ - abstract public void build(DOMTestSink sink); -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/DocumentBuilderSetting.java b/libcore/dom/src/test/java/org/w3c/domts/DocumentBuilderSetting.java deleted file mode 100644 index 7aaf652ef..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/DocumentBuilderSetting.java +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - -import javax.xml.parsers.DocumentBuilderFactory; - -/** - * This class is an parser setting, such as non-validating or entity-expanding. - * - * @author Curt Arnold @date 2 Feb 2002 - */ -public final class DocumentBuilderSetting { - /** - * property name. - */ - private final String property; - - /** - * property value. - */ - private final boolean value; - - /** - * strategy used to set or get property value. - */ - private final DocumentBuilderSettingStrategy strategy; - - /** - * coalescing = true. - */ - public static final DocumentBuilderSetting coalescing = - new DocumentBuilderSetting( - "coalescing", - true, - DocumentBuilderSettingStrategy.coalescing); - - /** - * coalescing = false. - */ - public static final DocumentBuilderSetting notCoalescing = - new DocumentBuilderSetting( - "coalescing", - false, - DocumentBuilderSettingStrategy.coalescing); - - /** - * expandEntityReferences = false. - */ - public static final DocumentBuilderSetting expandEntityReferences = - new DocumentBuilderSetting( - "expandEntityReferences", - true, - DocumentBuilderSettingStrategy.expandEntityReferences); - - /** - * expandEntityReferences = true. - */ - public static final DocumentBuilderSetting notExpandEntityReferences = - new DocumentBuilderSetting( - "expandEntityReferences", - false, - DocumentBuilderSettingStrategy.expandEntityReferences); - - /** - * ignoringElementContentWhitespace = true. - */ - public static final DocumentBuilderSetting ignoringElementContentWhitespace = - new DocumentBuilderSetting( - "ignoringElementContentWhitespace", - true, - DocumentBuilderSettingStrategy.ignoringElementContentWhitespace); - - /** - * ignoringElementContentWhitespace = false. - */ - public static final DocumentBuilderSetting - notIgnoringElementContentWhitespace = - new DocumentBuilderSetting( - "ignoringElementContentWhitespace", - false, - DocumentBuilderSettingStrategy.ignoringElementContentWhitespace); - - /** - * namespaceAware = true. - */ - public static final DocumentBuilderSetting namespaceAware = - new DocumentBuilderSetting( - "namespaceAware", - true, - DocumentBuilderSettingStrategy.namespaceAware); - - /** - * namespaceAware = false. - */ - public static final DocumentBuilderSetting notNamespaceAware = - new DocumentBuilderSetting( - "namespaceAware", - false, - DocumentBuilderSettingStrategy.namespaceAware); - - /** - * validating = true. - */ - public static final DocumentBuilderSetting validating = - new DocumentBuilderSetting( - "validating", - true, - DocumentBuilderSettingStrategy.validating); - - /** - * validating = false. - */ - public static final DocumentBuilderSetting notValidating = - new DocumentBuilderSetting( - "validating", - false, - DocumentBuilderSettingStrategy.validating); - - /** - * signed = true. - */ - public static final DocumentBuilderSetting signed = - new DocumentBuilderSetting( - "signed", - true, - DocumentBuilderSettingStrategy.signed); - - /** - * signed = false. - */ - public static final DocumentBuilderSetting notSigned = - new DocumentBuilderSetting( - "signed", - false, - DocumentBuilderSettingStrategy.signed); - - /** - * hasNullString = true. - */ - public static final DocumentBuilderSetting hasNullString = - new DocumentBuilderSetting( - "hasNullString", - true, - DocumentBuilderSettingStrategy.hasNullString); - - /** - * hasNullString = false. - */ - public static final DocumentBuilderSetting notHasNullString = - new DocumentBuilderSetting( - "hasNullString", - false, - DocumentBuilderSettingStrategy.hasNullString); - - /** - * Schema validating enabled. - */ - public static final DocumentBuilderSetting schemaValidating = - new DocumentBuilderSetting( - "schemaValidating", - true, - DocumentBuilderSettingStrategy.schemaValidating); - - /** - * Schema validating disabled. - */ - public static final DocumentBuilderSetting notSchemaValidating = - new DocumentBuilderSetting( - "schemaValidating", - false, - DocumentBuilderSettingStrategy.schemaValidating); - - /** - * Comments ignored. - */ - public static final DocumentBuilderSetting ignoringComments = - new DocumentBuilderSetting( - "ignoringComments", - true, - DocumentBuilderSettingStrategy.ignoringComments); - - /** - * Comments preserved. - */ - public static final DocumentBuilderSetting notIgnoringComments = - new DocumentBuilderSetting( - "ignoringComments", - false, - DocumentBuilderSettingStrategy.ignoringComments); - - /** - * Protected constructor, use static members for supported settings. - * @param property property name, follows JAXP. - * @param value property value - * @param strategy strategy, may not be null - */ - protected DocumentBuilderSetting( - String property, - boolean value, - DocumentBuilderSettingStrategy strategy) { - if (property == null) { - throw new NullPointerException("property"); - } - this.property = property; - this.value = value; - this.strategy = strategy; - } - - /** - * Returns true if the settings have a conflict or are identical. - * - * @param other - * other setting, may not be null. - * @return true if this setting and the specified setting conflict - */ - public final boolean hasConflict(DocumentBuilderSetting other) { - if (other == null) { - throw new NullPointerException("other"); - } - if (other == this) { - return true; - } - return strategy.hasConflict(other.strategy); - } - - /** - * Determines current value of setting. - * @param factory DOMTestDocumentBuilderFactory factory - * @return boolean true if property enabled. - */ - public final boolean hasSetting(DOMTestDocumentBuilderFactory factory) { - return strategy.hasSetting(factory) == value; - } - - /** - * Attempts to change builder to have this setting. - * @param factory DocumentBuilderFactory Factory for DOM builders - * @throws DOMTestIncompatibleException - * if factory does not support the setting - */ - public final void applySetting(DocumentBuilderFactory factory) throws - DOMTestIncompatibleException { - strategy.applySetting(factory, value); - } - - /** - * Gets the property name. - * @return property name - */ - public final String getProperty() { - return property; - } - - /** - * Gets the property value. - * @return property value - */ - public final boolean getValue() { - return value; - } - - /** - * Gets a string representation of the setting. - * @return string representation - */ - public final String toString() { - StringBuffer builder = new StringBuffer(property); - builder.append('='); - builder.append(String.valueOf(value)); - return builder.toString(); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/DocumentBuilderSettingStrategy.java b/libcore/dom/src/test/java/org/w3c/domts/DocumentBuilderSettingStrategy.java deleted file mode 100644 index 6df1a92c3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/DocumentBuilderSettingStrategy.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute of - * Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - -import java.lang.reflect.Method; - -import javax.xml.parsers.DocumentBuilderFactory; - -/** - * This class is a strategy that provides the mapping from an abstract setting - * (such as DocumentBuilderSetting.validating) to a specific DOM implementation - * - * @author Curt Arnold @date 2 Feb 2002 - */ -public abstract class DocumentBuilderSettingStrategy { - protected DocumentBuilderSettingStrategy() { - } - - private static final String JAXP_SCHEMA_LANGUAGE = - "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; - private static final String W3C_XML_SCHEMA = - "http://www.w3.org/2001/XMLSchema"; - - public boolean hasConflict(DocumentBuilderSettingStrategy other) { - return (other == this); - } - - public abstract void applySetting( - DocumentBuilderFactory factory, - boolean value) throws DOMTestIncompatibleException; - - public abstract boolean hasSetting(DOMTestDocumentBuilderFactory factory); - - public static final DocumentBuilderSettingStrategy coalescing = - new DocumentBuilderSettingStrategy() { - public void applySetting(DocumentBuilderFactory factory, boolean value) - throws DOMTestIncompatibleException { - factory.setCoalescing(value); - } - - public boolean hasSetting(DOMTestDocumentBuilderFactory factory) { - return factory.isCoalescing(); - } - - }; - - public static final DocumentBuilderSettingStrategy - expandEntityReferences = - new DocumentBuilderSettingStrategy() { - public void applySetting(DocumentBuilderFactory factory, boolean value) - throws DOMTestIncompatibleException { - factory.setExpandEntityReferences(value); - } - - public boolean hasSetting(DOMTestDocumentBuilderFactory factory) { - return factory.isExpandEntityReferences(); - } - }; - - public static final DocumentBuilderSettingStrategy - ignoringElementContentWhitespace = - new DocumentBuilderSettingStrategy() { - public void applySetting(DocumentBuilderFactory factory, boolean value) - throws DOMTestIncompatibleException { - factory.setIgnoringElementContentWhitespace(value); - } - - public boolean hasSetting(DOMTestDocumentBuilderFactory factory) { - return factory.isIgnoringElementContentWhitespace(); - } - }; - - public static final DocumentBuilderSettingStrategy ignoringComments = - new DocumentBuilderSettingStrategy() { - public void applySetting(DocumentBuilderFactory factory, boolean value) - throws DOMTestIncompatibleException { - if (value) { - throw new DOMTestIncompatibleException( - new Exception("ignoreComments=true not supported"), - DocumentBuilderSetting.ignoringComments); - } - } - - public boolean hasSetting(DOMTestDocumentBuilderFactory factory) { - return false; - } - }; - - public static final DocumentBuilderSettingStrategy namespaceAware = - new DocumentBuilderSettingStrategy() { - public void applySetting(DocumentBuilderFactory factory, boolean value) throws - DOMTestIncompatibleException { - factory.setNamespaceAware(value); - } - - public boolean hasSetting(DOMTestDocumentBuilderFactory factory) { - return factory.isNamespaceAware(); - } - }; - - public static final DocumentBuilderSettingStrategy validating = - new DocumentBuilderSettingStrategy() { - public void applySetting(DocumentBuilderFactory factory, boolean value) throws - DOMTestIncompatibleException { - factory.setValidating(value); - } - - public boolean hasSetting(DOMTestDocumentBuilderFactory factory) { - return factory.isValidating(); - } - }; - - public static final DocumentBuilderSettingStrategy signed = - new DocumentBuilderSettingStrategy() { - public void applySetting(DocumentBuilderFactory factory, boolean value) throws - DOMTestIncompatibleException { - if (!value) { - throw new DOMTestIncompatibleException( - null, - DocumentBuilderSetting.notSigned); - } - } - - public boolean hasSetting(DOMTestDocumentBuilderFactory factory) { - return true; - } - }; - - public static final DocumentBuilderSettingStrategy hasNullString = - new DocumentBuilderSettingStrategy() { - public void applySetting(DocumentBuilderFactory factory, boolean value) throws - DOMTestIncompatibleException { - if (!value) { - throw new DOMTestIncompatibleException( - null, - DocumentBuilderSetting.notHasNullString); - } - } - - public boolean hasSetting(DOMTestDocumentBuilderFactory factory) { - return true; - } - }; - - public static final DocumentBuilderSettingStrategy schemaValidating = - new DocumentBuilderSettingStrategy() { - public void applySetting(DocumentBuilderFactory factory, boolean value) throws - DOMTestIncompatibleException { - if (value) { - factory.setNamespaceAware(true); - factory.setValidating(true); - factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); - } - else { - factory.setAttribute(JAXP_SCHEMA_LANGUAGE, - "http://www.w3.org/TR/REC-xml"); - } - } - - public boolean hasSetting(DOMTestDocumentBuilderFactory factory) { - try { - if (factory.isValidating()) { - Method getAttrMethod = factory.getClass().getMethod("getAttribute", - new Class[] {String.class}); - String val = (String) getAttrMethod.invoke(factory, - new Object[] {JAXP_SCHEMA_LANGUAGE}); - return W3C_XML_SCHEMA.equals(val); - } - } - catch (Exception ex) { - } - return false; - } - - // - // schema validating conflicts with namespaceAware - // and validating - // - public boolean hasConflict(DocumentBuilderSettingStrategy other) { - if (other == this || - other == DocumentBuilderSettingStrategy.namespaceAware || - other == DocumentBuilderSettingStrategy.validating) { - return true; - } - return false; - } - - }; - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/EventMonitor.java b/libcore/dom/src/test/java/org/w3c/domts/EventMonitor.java deleted file mode 100644 index 909ca4eb6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/EventMonitor.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - -import java.util.ArrayList; -import java.util.List; - -import org.w3c.dom.events.Event; -import org.w3c.dom.events.EventListener; - -/** - * This is a utility implementation of EventListener - * that captures all events and provides access - * to lists of all events by mode - */ -public class EventMonitor - implements EventListener { - private final List atEvents = new ArrayList(); - private final List bubbledEvents = new ArrayList(); - private final List capturedEvents = new ArrayList(); - private final List allEvents = new ArrayList(); - - public EventMonitor() { - } - - public void handleEvent(Event evt) { - switch (evt.getEventPhase()) { - case Event.CAPTURING_PHASE: - capturedEvents.add(evt); - break; - - case Event.BUBBLING_PHASE: - bubbledEvents.add(evt); - break; - - case Event.AT_TARGET: - atEvents.add(evt); - break; - } - allEvents.add(evt); - } - - public List getAllEvents() { - return new ArrayList(allEvents); - } - - public List getBubbledEvents() { - return new ArrayList(bubbledEvents); - } - - public List getAtEvents() { - return new ArrayList(atEvents); - } - - public List getCapturedEvents() { - return new ArrayList(capturedEvents); - } -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/JAXPDOMTestDocumentBuilderFactory.java b/libcore/dom/src/test/java/org/w3c/domts/JAXPDOMTestDocumentBuilderFactory.java deleted file mode 100644 index c2d105e82..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/JAXPDOMTestDocumentBuilderFactory.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - -/** - * This class implements the generic parser and configuation - * abstract class for JAXP supporting parsers. - */ -public class JAXPDOMTestDocumentBuilderFactory - extends DOMTestDocumentBuilderFactory { - - private DocumentBuilderFactory factory; - private DocumentBuilder builder; - - /** - * Creates a JAXP implementation of DOMTestDocumentBuilderFactory. - * @param factory null for default JAXP provider. If not null, - * factory will be mutated in constructor and should be released - * by calling code upon return. - * @param settings array of settings, may be null. - */ - public JAXPDOMTestDocumentBuilderFactory( - DocumentBuilderFactory baseFactory, - DocumentBuilderSetting[] settings) throws DOMTestIncompatibleException { - super(settings); - if (baseFactory == null) { - factory = DocumentBuilderFactory.newInstance(); - } - else { - factory = baseFactory; - } - // - // apply settings to selected document builder - // may throw exception if incompatible - if (settings != null) { - for (int i = 0; i < settings.length; i++) { - settings[i].applySetting(factory); - } - } - try { - this.builder = factory.newDocumentBuilder(); - } - catch (ParserConfigurationException ex) { - throw new DOMTestIncompatibleException(ex, null); - } - } - - protected DOMTestDocumentBuilderFactory createInstance(DocumentBuilderFactory - newFactory, - DocumentBuilderSetting[] mergedSettings) throws - DOMTestIncompatibleException { - return new JAXPDOMTestDocumentBuilderFactory(newFactory, mergedSettings); - } - - public DOMTestDocumentBuilderFactory newInstance(DocumentBuilderSetting[] - newSettings) throws DOMTestIncompatibleException { - if (newSettings == null) { - return this; - } - DocumentBuilderSetting[] mergedSettings = mergeSettings(newSettings); - DocumentBuilderFactory newFactory = factory.newInstance(); - return createInstance(newFactory, mergedSettings); - } - - private class LoadErrorHandler - implements org.xml.sax.ErrorHandler { - private SAXException parseException; - private int errorCount; - private int warningCount; - public LoadErrorHandler() { - parseException = null; - errorCount = 0; - warningCount = 0; - } - - public void error(SAXParseException ex) { - errorCount++; - if (parseException == null) { - parseException = ex; - } - } - - public void warning(SAXParseException ex) { - warningCount++; - } - - public void fatalError(SAXParseException ex) { - if (parseException == null) { - parseException = ex; - } - } - - public SAXException getFirstException() { - return parseException; - } - } - - public Document load(java.net.URL url) throws DOMTestLoadException { - Document doc = null; - Exception parseException = null; - try { - LoadErrorHandler errorHandler = new LoadErrorHandler(); - builder.setErrorHandler(errorHandler); - doc = builder.parse(url.openStream(), url.toString()); - parseException = errorHandler.getFirstException(); - } - catch (Exception ex) { - parseException = ex; - } - builder.setErrorHandler(null); - if (parseException != null) { - throw new DOMTestLoadException(parseException); - } - return doc; - } - - public DOMImplementation getDOMImplementation() { - return builder.getDOMImplementation(); - } - - public boolean hasFeature(String feature, String version) { - return builder.getDOMImplementation().hasFeature(feature, version); - } - - public boolean isCoalescing() { - return factory.isCoalescing(); - } - - public boolean isExpandEntityReferences() { - return factory.isExpandEntityReferences(); - } - - public boolean isIgnoringElementContentWhitespace() { - return factory.isIgnoringElementContentWhitespace(); - } - - public boolean isNamespaceAware() { - return factory.isNamespaceAware(); - } - - public boolean isValidating() { - return factory.isValidating(); - } - - public static DocumentBuilderSetting[] getConfiguration1() { - return new DocumentBuilderSetting[] { - DocumentBuilderSetting.notCoalescing, - DocumentBuilderSetting.notExpandEntityReferences, - DocumentBuilderSetting.notIgnoringElementContentWhitespace, - DocumentBuilderSetting.notNamespaceAware, - DocumentBuilderSetting.notValidating}; - } - - public static DocumentBuilderSetting[] getConfiguration2() { - return new DocumentBuilderSetting[] { - DocumentBuilderSetting.notCoalescing, - DocumentBuilderSetting.expandEntityReferences, - DocumentBuilderSetting.ignoringElementContentWhitespace, - DocumentBuilderSetting.namespaceAware, - DocumentBuilderSetting.validating}; - - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/JTidyDOMImplementation.java b/libcore/dom/src/test/java/org/w3c/domts/JTidyDOMImplementation.java deleted file mode 100644 index 60a6c8a27..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/JTidyDOMImplementation.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2002 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - -import org.w3c.dom.DOMException; -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; -import org.w3c.dom.DocumentType; - -/** - * JTidy does not implement DOMImplementation - * we do it here to keep the test exclusion logic - * from falling apart. - */ -public class JTidyDOMImplementation - implements DOMImplementation { - - /** - * Test if the DOM implementation implements a specific feature. - * @param feature The name of the feature to test (case-insensitive). The - * values used by DOM features are defined throughout the DOM Level 2 - * specifications and listed in the section. The name must be an XML - * name. To avoid possible conflicts, as a convention, names referring - * to features defined outside the DOM specification should be made - * unique. - * @param version This is the version number of the feature to test. In - * Level 2, the string can be either "2.0" or "1.0". If the version is - * not specified, supporting any version of the feature causes the - * method to return true. - * @return true if the feature is implemented in the - * specified version, false otherwise. - */ - public boolean hasFeature(String feature, - String version) { - if (feature.equals("Core")) { - return version == null || version.equals("1.0") || version.equals("2.0"); - } - return false; - } - - /** - * Creates an empty DocumentType node. Entity declarations - * and notations are not made available. Entity reference expansions and - * default attribute additions do not occur. It is expected that a - * future version of the DOM will provide a way for populating a - * DocumentType. - * @param qualifiedName The qualified name of the document type to be - * created. - * @param publicId The external subset public identifier. - * @param systemId The external subset system identifier. - * @return A new DocumentType node with - * Node.ownerDocument set to null. - * @exception DOMException - * INVALID_CHARACTER_ERR: Raised if the specified qualified name - * contains an illegal character. - *
NAMESPACE_ERR: Raised if the qualifiedName is - * malformed. - *
NOT_SUPPORTED_ERR: May be raised by DOM implementations which do - * not support the "XML" feature, if they choose not to - * support this method. Other features introduced in the future, by - * the DOM WG or in extensions defined by other groups, may also - * demand support for this method; please consult the definition of - * the feature to see if it requires this method. - * @since DOM Level 2 - */ - public DocumentType createDocumentType(String qualifiedName, - String publicId, - String systemId) throws DOMException { - throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not Implemented"); - } - - /** - * Creates a DOM Document object of the specified type with its document - * element. - * @param namespaceURI The namespace URI of the document element to - * create. - * @param qualifiedName The qualified name of the document element to be - * created. - * @param doctype The type of document to be created or null. - * When doctype is not null, its - * Node.ownerDocument attribute is set to the document - * being created. - * @return A new Document object. - * @exception DOMException - * INVALID_CHARACTER_ERR: Raised if the specified qualified name - * contains an illegal character. - *
NAMESPACE_ERR: Raised if the qualifiedName is - * malformed, if the qualifiedName has a prefix and the - * namespaceURI is null, or if the - * qualifiedName has a prefix that is "xml" and the - * namespaceURI is different from " - * http://www.w3.org/XML/1998/namespace" , or if the DOM - * implementation does not support the "XML" feature but - * a non-null namespace URI was provided, since namespaces were - * defined by XML. - *
WRONG_DOCUMENT_ERR: Raised if doctype has already - * been used with a different document or was created from a different - * implementation. - *
NOT_SUPPORTED_ERR: May be raised by DOM implementations which do - * not support the "XML" feature, if they choose not to support this - * method. Other features introduced in the future, by the DOM WG or - * in extensions defined by other groups, may also demand support for - * this method; please consult the definition of the feature to see if - * it requires this method. - * @since DOM Level 2 - */ - public Document createDocument(String namespaceURI, - String qualifiedName, - DocumentType doctype) throws DOMException { - throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not Implemented"); - } - - public DOMImplementation getInterface(String feature) { - return this; - } - - public Object getFeature(String feature, String version) { - return null; - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/JTidyDocumentBuilderFactory.java b/libcore/dom/src/test/java/org/w3c/domts/JTidyDocumentBuilderFactory.java deleted file mode 100644 index 7b8f45476..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/JTidyDocumentBuilderFactory.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2002-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; - -/** - * This class implements the generic parser builder - * for JTidy (http://sf.net/projects/JTidy) which reads HTML - * and supports the fundamental DOM interfaces but not either HTML L1 DOM - * or HTML L2 DOM - */ -public class JTidyDocumentBuilderFactory - extends DOMTestDocumentBuilderFactory { - - private final Constructor tidyConstructor; - private final Method parseDOMMethod; - private final DOMImplementation domImpl; - private static final Class[] NO_CLASSES = new Class[0]; - private static final Object[] NO_OBJECTS = new Object[0]; - - /** - * Creates a implementation of DOMTestDocumentBuilderFactory - * using JTidy's HTML parser and DOM implementation - * @param settings array of settings, may be null. - */ - public JTidyDocumentBuilderFactory( - DocumentBuilderSetting[] settings) throws DOMTestIncompatibleException { - super(settings); - - try { - ClassLoader classLoader = ClassLoader.getSystemClassLoader(); - Class tidyClass = classLoader.loadClass("org.w3c.tidy.Tidy"); - - tidyConstructor = - tidyClass.getConstructor(NO_CLASSES); - - parseDOMMethod = - tidyClass.getMethod("parseDOM", - new Class[] {java.io.InputStream.class, - java.io.OutputStream.class}); - - // - // JTidy doesn't implement DOMImplementation so - // we will do it here - domImpl = new JTidyDOMImplementation(); - - } - catch (Exception ex) { - throw new DOMTestIncompatibleException(ex, null); - } - - // - // apply settings to selected document builder - // may throw exception if incompatible - if (settings != null) { - for (int i = 0; i < settings.length; i++) { -// settings[i].applySetting(factory); - } - } - } - - public DOMTestDocumentBuilderFactory newInstance(DocumentBuilderSetting[] - newSettings) throws DOMTestIncompatibleException { - if (newSettings == null) { - return this; - } - DocumentBuilderSetting[] mergedSettings = mergeSettings(newSettings); - return new JTidyDocumentBuilderFactory(mergedSettings); - } - - public Document load(java.net.URL url) throws DOMTestLoadException { - Document doc = null; - try { - java.io.InputStream stream = url.openStream(); - Object tidyObj = tidyConstructor.newInstance(new Object[0]); - doc = (Document) parseDOMMethod.invoke(tidyObj, - new Object[] {stream, null}); - } - catch (InvocationTargetException ex) { - throw new DOMTestLoadException(ex.getTargetException()); - } - catch (Exception ex) { - throw new DOMTestLoadException(ex); - } - return doc; - } - - public DOMImplementation getDOMImplementation() { - return domImpl; - } - - public boolean hasFeature(String feature, String version) { - return domImpl.hasFeature(feature, version); - } - - public String getContentType() { - return "text/html"; - } - - public boolean isCoalescing() { - return false; - } - - public boolean isExpandEntityReferences() { - return false; - } - - public boolean isIgnoringElementContentWhitespace() { - return false; - } - - public boolean isNamespaceAware() { - return false; - } - - public boolean isValidating() { - return false; - } -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/JUnitTestCaseAdapter.java b/libcore/dom/src/test/java/org/w3c/domts/JUnitTestCaseAdapter.java deleted file mode 100644 index 711079236..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/JUnitTestCaseAdapter.java +++ /dev/null @@ -1,491 +0,0 @@ -/* - * Copyright (c) 2001-2003 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.logging.Logger; - -import javax.xml.parsers.DocumentBuilder; - -import junit.framework.TestCase; - -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - - -public class JUnitTestCaseAdapter extends TestCase implements DOMTestFramework { - - private DOMTestCase test; - - - private static DOMTestDocumentBuilderFactory defaultFactory = null; - - public JUnitTestCaseAdapter(DOMTestCase test) { - super(test.getTargetURI()); - test.setFramework(this); - this.test = test; - } -//BEGIN android-added - public JUnitTestCaseAdapter() { - - } - - private String errorMessage = null; - private boolean failed = false; - - @Override - public void setName(String name) { - super.setName(name); - if (test == null) { - try { - URI uri = new URI(name); - String path = uri.getPath(); - path = path.replaceAll("/", "."); - Class clazz = null; - int pos = path.indexOf('.'); - while (pos != -1) { - try { - clazz = Class.forName("org.w3c.domts." + path); - break; - } catch (ClassNotFoundException e) { - // do nothing - } - path = path.substring(pos + 1); - } - if (clazz == null) { - errorMessage = "class not found for test: " + name; - failed = true; - return; - } - - if (defaultFactory == null) { - defaultFactory = new JAXPDOMTestDocumentBuilderFactory(null, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - } - - Constructor constructor = clazz.getConstructor(new Class[] { - DOMTestDocumentBuilderFactory.class - }); - - test = (DOMTestCase)constructor.newInstance(new Object[] { - defaultFactory - }); - test.setFramework(this); - - } catch (URISyntaxException e) { - failed = true; - errorMessage = e.getMessage(); - if (errorMessage == null) { - errorMessage = "" + e.toString(); - } - } catch (IllegalAccessException e) { - failed = true; - errorMessage = e.getMessage(); - if (errorMessage == null) { - errorMessage = "" + e.toString(); - } - } catch (InstantiationException e) { - failed = true; - errorMessage = e.getMessage(); - if (errorMessage == null) { - errorMessage = "" + e.toString(); - } - } catch (DOMTestIncompatibleException e) { - failed = true; - errorMessage = e.getMessage(); - if (errorMessage == null) { - errorMessage = "" + e.toString(); - } - } catch (SecurityException e) { - failed = true; - errorMessage = e.getMessage(); - if (errorMessage == null) { - errorMessage = "" + e.toString(); - } - } catch (NoSuchMethodException e) { - failed = true; - errorMessage = e.getMessage(); - if (errorMessage == null) { - errorMessage = "" + e.toString(); - } - } catch (IllegalArgumentException e) { - failed = true; - errorMessage = e.getMessage(); - if (errorMessage == null) { - errorMessage = "" + e.toString(); - } - } catch (InvocationTargetException e) { - failed = true; - Throwable t = e.getCause(); - if (t != null) { - errorMessage = t.getMessage(); - if (errorMessage == null) { - errorMessage = "" + t.toString(); - } - } else { - errorMessage = e.getMessage(); - if (errorMessage == null) { - errorMessage = "" + e.toString(); - } - } - } - } - } -//END android-added - protected void runTest() throws Throwable { - //BEGIN android-added - if (failed) { - if (errorMessage != null) { - fail(errorMessage); - } else { - fail("init failed"); - } - } - //END android-added - test.runTest(); - int mutationCount = test.getMutationCount(); - if (mutationCount != 0) { - fail("Document loaded with willBeModified='false' was modified in course of test."); - } - } - - public boolean hasFeature(DocumentBuilder docBuilder, - String feature, - String version) { - return docBuilder.getDOMImplementation().hasFeature(feature,version); - } - - public void wait(int millisecond) { - } - - public void fail(DOMTestCase test, String assertID) { - fail(assertID); - } - - public void assertTrue(DOMTestCase test, String assertID, boolean actual) { - assertTrue(assertID,actual); - } - - public void assertFalse(DOMTestCase test, String assertID, boolean actual) { - if(actual) { - assertEquals(assertID,String.valueOf(false), String.valueOf(actual)); - } - } - - public void assertNull(DOMTestCase test, String assertID, Object actual) { - assertNull(assertID,actual); - } - - public void assertNotNull(DOMTestCase test, String assertID, Object actual) { - assertNotNull(assertID,actual); - } - - public void assertSame(DOMTestCase test, String assertID, Object expected, Object actual) { - boolean same = (expected == actual); - // - // if the not the same but both are not null - // might still really be the same - // - if(!same) { - if(expected == null || actual == null || - !(expected instanceof Node) || !(actual instanceof Node)) { - assertEquals(assertID,expected,actual); - } - else { - // - // could do something with isSame - // - assertEquals(assertID,expected,actual); - } - } - } - - public void assertInstanceOf(DOMTestCase test, String assertID, Object obj, Class cls) { - assertTrue(assertID,cls.isInstance(obj)); - } - - public void assertSize(DOMTestCase test, String assertID, int expectedSize, NodeList collection) { - assertEquals(assertID,expectedSize, collection.getLength()); - } - - public void assertSize(DOMTestCase test, String assertID, int expectedSize, NamedNodeMap collection) { - assertEquals(assertID, expectedSize, collection.getLength()); - } - - public void assertSize(DOMTestCase test, String assertID, int expectedSize, Collection collection) { - assertEquals(assertID, expectedSize, collection.size()); - } - - public void assertEqualsIgnoreCase(DOMTestCase test, String assertID, String expected, String actual) { - if (!expected.equalsIgnoreCase(actual)) { - assertEquals(assertID,expected, actual); - } - } - - public void assertEqualsIgnoreCase(DOMTestCase test, String assertID, Collection expected, Collection actual) { - int size = expected.size(); - assertNotNull(assertID,expected); - assertNotNull(assertID,actual); - assertEquals(assertID,size, actual.size()); - boolean equals = (expected != null && actual != null && size == actual.size()); - if(equals) { - List expectedArray = new ArrayList(expected); - String expectedString; - String actualString; - Iterator actualIter = actual.iterator(); - Iterator expectedIter; - while(actualIter.hasNext() && equals) { - actualString = (String) actualIter.next(); - expectedIter = expectedArray.iterator(); - equals = false; - while(expectedIter.hasNext() && !equals) { - expectedString = (String) expectedIter.next(); - if(actualString.equalsIgnoreCase(expectedString)) { - equals = true; - expectedArray.remove(expectedString); - } - } - } - } - assertTrue(assertID,equals); - } - - public void assertEqualsIgnoreCase(DOMTestCase test, String assertID, List expected, List actual) { - int size = expected.size(); - assertNotNull(assertID,expected); - assertNotNull(assertID,actual); - assertEquals(assertID,size, actual.size()); - boolean equals = (expected != null && actual != null && size == actual.size()); - if(equals) { - String expectedString; - String actualString; - for(int i = 0; i < size; i++) { - expectedString = (String) expected.get(i); - actualString = (String) actual.get(i); - if(!expectedString.equalsIgnoreCase(actualString)) { - assertEquals(assertID,expectedString,actualString); - break; - } - } - } - } - - public void assertEquals(DOMTestCase test, String assertID, String expected, String actual) { - assertEquals(assertID,expected,actual); - } - - public void assertEquals(DOMTestCase test, String assertID, int expected, int actual) { - assertEquals(assertID,expected,actual); - } - - public void assertEquals(DOMTestCase test, String assertID, boolean expected, boolean actual) { - assertEquals(assertID,expected,actual); - } - - public void assertEquals(DOMTestCase test, String assertID, double expected, double actual) { - assertEquals(assertID, expected, actual, 0.0); - } - - public void assertEquals(DOMTestCase test, String assertID, Collection expected, Collection actual) { - int size = expected.size(); - assertNotNull(assertID,expected); - assertNotNull(assertID,actual); - assertEquals(assertID,size, actual.size()); - boolean equals = (expected != null && actual != null && size == actual.size()); - if(equals) { - List expectedArray = new ArrayList(expected); - Object expectedObj; - Object actualObj; - Iterator actualIter = actual.iterator(); - Iterator expectedIter; - while(actualIter.hasNext() && equals) { - actualObj = actualIter.next(); - expectedIter = expectedArray.iterator(); - equals = false; - while(expectedIter.hasNext() && !equals) { - expectedObj = expectedIter.next(); - if(expectedObj == actualObj || expectedObj.equals(actualObj)) { - equals = true; - expectedArray.remove(expectedObj); - } - } - } - } - assertTrue(assertID,equals); - } - - public void assertNotEqualsIgnoreCase(DOMTestCase test, String assertID, String expected, String actual) { - if(expected.equalsIgnoreCase(actual)) { - assertTrue(assertID, !expected.equalsIgnoreCase(actual)); - } - } - - public void assertNotEquals(DOMTestCase test, String assertID, String expected, String actual) { - assertTrue(assertID, !expected.equals(actual)); - } - - public void assertNotEquals(DOMTestCase test, String assertID, int expected, int actual) { - assertTrue(assertID,expected !=actual); - } - - public void assertNotEquals(DOMTestCase test, String assertID, boolean expected, boolean actual) { - assertTrue(assertID,expected !=actual); - } - - - public void assertNotEquals(DOMTestCase test, String assertID, double expected, double actual) { - if(expected == actual) { - assertTrue(assertID,expected != actual); - } - } - - - public boolean same(Object expected, Object actual) { - boolean equals = (expected == actual); - if(!equals && expected != null && expected instanceof Node && - actual != null && actual instanceof Node) { - // - // can use Node.isSame eventually - } - return equals; - } - - public boolean equalsIgnoreCase(String expected, String actual) { - return expected.equalsIgnoreCase(actual); - } - - public boolean equalsIgnoreCase(Collection expected, Collection actual) { - int size = expected.size(); - boolean equals = (expected != null && actual != null && size == actual.size()); - if(equals) { - List expectedArray = new ArrayList(expected); - String expectedString; - String actualString; - Iterator actualIter = actual.iterator(); - Iterator expectedIter; - while(actualIter.hasNext() && equals) { - actualString = (String) actualIter.next(); - expectedIter = expectedArray.iterator(); - equals = false; - while(expectedIter.hasNext() && !equals) { - expectedString = (String) expectedIter.next(); - if(actualString.equalsIgnoreCase(expectedString)) { - equals = true; - expectedArray.remove(expectedString); - } - } - } - } - return equals; - } - - public boolean equalsIgnoreCase(List expected, List actual) { - int size = expected.size(); - boolean equals = (expected != null && actual != null && size == actual.size()); - if(equals) { - String expectedString; - String actualString; - for(int i = 0; i < size; i++) { - expectedString = (String) expected.get(i); - actualString = (String) actual.get(i); - if(!expectedString.equalsIgnoreCase(actualString)) { - equals = false; - break; - } - } - } - return equals; - } - - public boolean equals(String expected, String actual) { - return expected.equals(actual); - } - - public boolean equals(int expected, int actual) { - return expected == actual; - } - - public boolean equals(boolean expected, boolean actual) { - return expected == actual; - } - - public boolean equals(double expected, double actual) { - return expected == actual; - } - - public boolean equals(Collection expected, Collection actual) { - int size = expected.size(); - boolean equals = (expected != null && actual != null && size == actual.size()); - if(equals) { - List expectedArray = new ArrayList(expected); - Object expectedObj; - Object actualObj; - Iterator actualIter = actual.iterator(); - Iterator expectedIter; - while(actualIter.hasNext() && equals) { - actualObj = actualIter.next(); - expectedIter = expectedArray.iterator(); - equals = false; - while(expectedIter.hasNext() && !equals) { - expectedObj = expectedIter.next(); - if(expectedObj != actualObj && expectedObj.equals(actualObj)) { - equals = true; - expectedArray.remove(expectedObj); - } - } - } - } - return equals; - } - - public boolean equals(List expected, List actual) { - int size = expected.size(); - boolean equals = (expected != null && actual != null && size == actual.size()); - if(equals) { - Object expectedObj; - Object actualObj; - for(int i = 0; i < size; i++) { - expectedObj = expected.get(i); - actualObj = actual.get(i); - if(!expectedObj.equals(actualObj)) { - equals = false; - break; - } - } - } - return equals; - } - - public int size(Collection collection) { - return collection.size(); - } - - public int size(NamedNodeMap collection) { - return collection.getLength(); - } - - public int size(NodeList collection) { - return collection.getLength(); - } - - -} \ No newline at end of file diff --git a/libcore/dom/src/test/java/org/w3c/domts/JUnitTestSuiteAdapter.java b/libcore/dom/src/test/java/org/w3c/domts/JUnitTestSuiteAdapter.java deleted file mode 100644 index 62fcad364..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/JUnitTestSuiteAdapter.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - -import junit.framework.TestCase; -import junit.framework.TestSuite; - -public class JUnitTestSuiteAdapter extends TestSuite implements DOMTestSink { - - private DOMTestSuite test; - - public JUnitTestSuiteAdapter(DOMTestSuite test) { - super(test.getTargetURI()); - this.test = test; - test.build(this); - } - - public void addTest(Class testclass) { - DOMTestDocumentBuilderFactory factory = test.getFactory(); - try { - Constructor testConstructor = testclass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class } ); - // - // since this is done with reflection - // any exception on construction is wrapped with - // an InvocationTargetException and must be unwrapped - Object domtest; - try { - domtest = testConstructor.newInstance(new Object[] { factory }); - } catch(InvocationTargetException ex) { - throw ex.getTargetException(); - } - - if(domtest instanceof DOMTestCase) { - TestCase test = new JUnitTestCaseAdapter((DOMTestCase) domtest); - addTest(test); - } - else { - if(domtest instanceof DOMTestSuite) { - TestSuite test = new JUnitTestSuiteAdapter((DOMTestSuite) domtest); - addTest(test); - } - } - } - catch(Throwable ex) { - if(!(ex instanceof DOMTestIncompatibleException)) { - ex.printStackTrace(); - } - } - } -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/JunitTestCases.java b/libcore/dom/src/test/java/org/w3c/domts/JunitTestCases.java deleted file mode 100644 index 8a1b6ab0b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/JunitTestCases.java +++ /dev/null @@ -1,2189 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.w3c.domts; - -import junit.framework.TestCase; - -/** - * Wrapper class to make the W3C DOM test work as JUnit test cases. Note this - * file has been generated, so the method names may be cryptic and also be - * longer than 80 characters per line. - */ -public class JunitTestCases extends TestCase { - - private void runDomTest(String name) throws Throwable { - JUnitTestCaseAdapter adapter = new JUnitTestCaseAdapter(); - adapter.setName(name); - adapter.runTest(); - } - - public void test_level1_core_attrcreatedocumentfragment() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrcreatedocumentfragment"); - } - - public void test_level1_core_attrcreatetextnode() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrcreatetextnode"); - } - - public void test_level1_core_attrcreatetextnode2() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrcreatetextnode2"); - } - - public void test_level1_core_attreffectivevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/attreffectivevalue"); - } - - public void test_level1_core_attrname() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrname"); - } - - public void test_level1_core_attrnextsiblingnull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrnextsiblingnull"); - } - - public void test_level1_core_attrparentnodenull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrparentnodenull"); - } - - public void test_level1_core_attrprevioussiblingnull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrprevioussiblingnull"); - } - - public void test_level1_core_attrspecifiedvalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrspecifiedvalue"); - } - - public void test_level1_core_attrspecifiedvaluechanged() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrspecifiedvaluechanged"); - } - - public void test_level1_core_cdatasectiongetdata() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/cdatasectiongetdata"); - } - - public void test_level1_core_characterdataappenddata() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataappenddata"); - } - - public void test_level1_core_characterdataappenddatagetdata() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataappenddatagetdata"); - } - - public void test_level1_core_characterdatadeletedatabegining() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatadeletedatabegining"); - } - - public void test_level1_core_characterdatadeletedataend() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatadeletedataend"); - } - - public void test_level1_core_characterdatadeletedataexceedslength() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatadeletedataexceedslength"); - } - - public void test_level1_core_characterdatadeletedatagetlengthanddata() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatadeletedatagetlengthanddata"); - } - - public void test_level1_core_characterdatadeletedatamiddle() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatadeletedatamiddle"); - } - - public void test_level1_core_characterdatagetdata() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatagetdata"); - } - - public void test_level1_core_characterdatagetlength() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatagetlength"); - } - - public void test_level1_core_characterdatainsertdatabeginning() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatainsertdatabeginning"); - } - - public void test_level1_core_characterdatainsertdataend() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatainsertdataend"); - } - - public void test_level1_core_characterdatainsertdatamiddle() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatainsertdatamiddle"); - } - - public void test_level1_core_characterdatareplacedatabegining() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatareplacedatabegining"); - } - - public void test_level1_core_characterdatareplacedataend() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatareplacedataend"); - } - - public void test_level1_core_characterdatareplacedataexceedslengthofarg() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatareplacedataexceedslengthofarg"); - } - - public void test_level1_core_characterdatareplacedataexceedslengthofdata() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatareplacedataexceedslengthofdata"); - } - - public void test_level1_core_characterdatareplacedatamiddle() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatareplacedatamiddle"); - } - - public void test_level1_core_characterdatasubstringvalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatasubstringvalue"); - } - - public void test_level1_core_commentgetcomment() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/commentgetcomment"); - } - - public void test_level1_core_documentcreatecdatasection() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentcreatecdatasection"); - } - - public void test_level1_core_documentcreatecomment() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentcreatecomment"); - } - - public void test_level1_core_documentcreatedocumentfragment() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentcreatedocumentfragment"); - } - - public void test_level1_core_documentcreateelement() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentcreateelement"); - } - - public void test_level1_core_documentcreateelementcasesensitive() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentcreateelementcasesensitive"); - } - - public void test_level1_core_documentcreateentityreference() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentcreateentityreference"); - } - - public void test_level1_core_documentcreateprocessinginstruction() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentcreateprocessinginstruction"); - } - - public void test_level1_core_documentcreatetextnode() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentcreatetextnode"); - } - - public void test_level1_core_documentgetdoctype() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentgetdoctype"); - } - - public void test_level1_core_documentgetdoctypenodtd() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentgetdoctypenodtd"); - } - - public void test_level1_core_documentgetelementsbytagnamelength() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentgetelementsbytagnamelength"); - } - - public void test_level1_core_documentgetelementsbytagnamevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentgetelementsbytagnamevalue"); - } - - public void test_level1_core_documentgetimplementation() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentgetimplementation"); - } - - public void test_level1_core_documentgetrootnode() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentgetrootnode"); - } - - public void test_level1_core_documentinvalidcharacterexceptioncreateattribute() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentinvalidcharacterexceptioncreateattribute"); - } - - public void test_level1_core_documentinvalidcharacterexceptioncreateelement() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentinvalidcharacterexceptioncreateelement"); - } - - public void test_level1_core_documenttypegetdoctype() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/documenttypegetdoctype"); - } - - public void test_level1_core_domimplementationfeaturenoversion() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/domimplementationfeaturenoversion"); - } - - public void test_level1_core_domimplementationfeaturenull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/domimplementationfeaturenull"); - } - - public void test_level1_core_domimplementationfeaturexml() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/domimplementationfeaturexml"); - } - - public void test_level1_core_elementaddnewattribute() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementaddnewattribute"); - } - - public void test_level1_core_elementassociatedattribute() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementassociatedattribute"); - } - - public void test_level1_core_elementchangeattributevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementchangeattributevalue"); - } - - public void test_level1_core_elementgetattributenode() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementgetattributenode"); - } - - public void test_level1_core_elementgetattributenodenull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementgetattributenodenull"); - } - - public void test_level1_core_elementgetelementsbytagname() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementgetelementsbytagname"); - } - - public void test_level1_core_elementgetelementsbytagnameaccessnodelist() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementgetelementsbytagnameaccessnodelist"); - } - - public void test_level1_core_elementgetelementsbytagnamenomatch() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementgetelementsbytagnamenomatch"); - } - - public void test_level1_core_elementgettagname() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementgettagname"); - } - - public void test_level1_core_elementinuseattributeerr() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementinuseattributeerr"); - } - - public void test_level1_core_elementinvalidcharacterexception() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementinvalidcharacterexception"); - } - - public void test_level1_core_elementnormalize() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementnormalize"); - } - - public void test_level1_core_elementnotfounderr() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementnotfounderr"); - } - - public void test_level1_core_elementremoveattributeaftercreate() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementremoveattributeaftercreate"); - } - - public void test_level1_core_elementremoveattributenode() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementremoveattributenode"); - } - - public void test_level1_core_elementreplaceexistingattributegevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementreplaceexistingattributegevalue"); - } - - public void test_level1_core_elementretrieveattrvalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementretrieveattrvalue"); - } - - public void test_level1_core_elementretrievetagname() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementretrievetagname"); - } - - public void test_level1_core_elementsetattributenodenull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementsetattributenodenull"); - } - - public void test_level1_core_elementwrongdocumenterr() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementwrongdocumenterr"); - } - - public void test_level1_core_namednodemapchildnoderange() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapchildnoderange"); - } - - public void test_level1_core_namednodemapgetnameditem() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapgetnameditem"); - } - - public void test_level1_core_namednodemapinuseattributeerr() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapinuseattributeerr"); - } - - public void test_level1_core_namednodemapnotfounderr() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapnotfounderr"); - } - - public void test_level1_core_namednodemapnumberofnodes() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapnumberofnodes"); - } - - public void test_level1_core_namednodemapremovenameditemreturnnodevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapremovenameditemreturnnodevalue"); - } - - public void test_level1_core_namednodemapreturnattrnode() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapreturnattrnode"); - } - - public void test_level1_core_namednodemapreturnfirstitem() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapreturnfirstitem"); - } - - public void test_level1_core_namednodemapreturnlastitem() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapreturnlastitem"); - } - - public void test_level1_core_namednodemapreturnnull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapreturnnull"); - } - - public void test_level1_core_namednodemapsetnameditem() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapsetnameditem"); - } - - public void test_level1_core_namednodemapsetnameditemreturnvalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapsetnameditemreturnvalue"); - } - - public void test_level1_core_namednodemapsetnameditemwithnewvalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapsetnameditemwithnewvalue"); - } - - public void test_level1_core_namednodemapwrongdocumenterr() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapwrongdocumenterr"); - } - - public void test_level1_core_nodeappendchild() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchild"); - } - - public void test_level1_core_nodeappendchildgetnodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchildgetnodename"); - } - - public void test_level1_core_nodeappendchildnewchilddiffdocument() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchildnewchilddiffdocument"); - } - - public void test_level1_core_nodeappendchildnodeancestor() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchildnodeancestor"); - } - - public void test_level1_core_nodeattributenodeattribute() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeattributenodeattribute"); - } - - public void test_level1_core_nodeattributenodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeattributenodename"); - } - - public void test_level1_core_nodeattributenodetype() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeattributenodetype"); - } - - public void test_level1_core_nodeattributenodevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeattributenodevalue"); - } - - public void test_level1_core_nodecdatasectionnodeattribute() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodecdatasectionnodeattribute"); - } - - public void test_level1_core_nodecdatasectionnodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodecdatasectionnodename"); - } - - public void test_level1_core_nodecdatasectionnodetype() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodecdatasectionnodetype"); - } - - public void test_level1_core_nodecdatasectionnodevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodecdatasectionnodevalue"); - } - - public void test_level1_core_nodechildnodes() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodechildnodes"); - } - - public void test_level1_core_nodechildnodesempty() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodechildnodesempty"); - } - - public void test_level1_core_nodecommentnodeattributes() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodecommentnodeattributes"); - } - - public void test_level1_core_nodecommentnodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodecommentnodename"); - } - - public void test_level1_core_nodecommentnodetype() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodecommentnodetype"); - } - - public void test_level1_core_nodecommentnodevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodecommentnodevalue"); - } - - public void test_level1_core_nodedocumentfragmentnodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumentfragmentnodename"); - } - - public void test_level1_core_nodedocumentfragmentnodetype() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumentfragmentnodetype"); - } - - public void test_level1_core_nodedocumentfragmentnodevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumentfragmentnodevalue"); - } - - public void test_level1_core_nodedocumentnodeattribute() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumentnodeattribute"); - } - - public void test_level1_core_nodedocumentnodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumentnodename"); - } - - public void test_level1_core_nodedocumentnodetype() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumentnodetype"); - } - - public void test_level1_core_nodedocumentnodevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumentnodevalue"); - } - - public void test_level1_core_nodedocumenttypenodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumenttypenodename"); - } - - public void test_level1_core_nodedocumenttypenodetype() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumenttypenodetype"); - } - - public void test_level1_core_nodedocumenttypenodevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumenttypenodevalue"); - } - - public void test_level1_core_nodeelementnodeattributes() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeelementnodeattributes"); - } - - public void test_level1_core_nodeelementnodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeelementnodename"); - } - - public void test_level1_core_nodeelementnodetype() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeelementnodetype"); - } - - public void test_level1_core_nodeelementnodevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeelementnodevalue"); - } - - public void test_level1_core_nodeentityreferencenodeattributes() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeentityreferencenodeattributes"); - } - - public void test_level1_core_nodeentityreferencenodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeentityreferencenodename"); - } - - public void test_level1_core_nodeentityreferencenodetype() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeentityreferencenodetype"); - } - - public void test_level1_core_nodeentityreferencenodevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeentityreferencenodevalue"); - } - - public void test_level1_core_nodegetfirstchild() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetfirstchild"); - } - - public void test_level1_core_nodegetfirstchildnull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetfirstchildnull"); - } - - public void test_level1_core_nodegetlastchild() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetlastchild"); - } - - public void test_level1_core_nodegetlastchildnull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetlastchildnull"); - } - - public void test_level1_core_nodegetnextsibling() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetnextsibling"); - } - - public void test_level1_core_nodegetnextsiblingnull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetnextsiblingnull"); - } - - public void test_level1_core_nodegetownerdocument() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetownerdocument"); - } - - public void test_level1_core_nodegetownerdocumentnull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetownerdocumentnull"); - } - - public void test_level1_core_nodegetprevioussibling() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetprevioussibling"); - } - - public void test_level1_core_nodegetprevioussiblingnull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetprevioussiblingnull"); - } - - public void test_level1_core_nodehaschildnodes() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodehaschildnodes"); - } - - public void test_level1_core_nodehaschildnodesfalse() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodehaschildnodesfalse"); - } - - public void test_level1_core_nodeinsertbeforenewchilddiffdocument() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbeforenewchilddiffdocument"); - } - - public void test_level1_core_nodeinsertbeforenewchildexists() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbeforenewchildexists"); - } - - public void test_level1_core_nodeinsertbeforenodeancestor() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbeforenodeancestor"); - } - - public void test_level1_core_nodeinsertbeforenodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbeforenodename"); - } - - public void test_level1_core_nodelistindexequalzero() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodelistindexequalzero"); - } - - public void test_level1_core_nodelistindexgetlength() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodelistindexgetlength"); - } - - public void test_level1_core_nodelistindexgetlengthofemptylist() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodelistindexgetlengthofemptylist"); - } - - public void test_level1_core_nodelistindexnotzero() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodelistindexnotzero"); - } - - public void test_level1_core_nodelistreturnfirstitem() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodelistreturnfirstitem"); - } - - public void test_level1_core_nodelistreturnlastitem() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodelistreturnlastitem"); - } - - public void test_level1_core_nodelisttraverselist() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodelisttraverselist"); - } - - public void test_level1_core_nodeparentnode() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeparentnode"); - } - - public void test_level1_core_nodeparentnodenull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeparentnodenull"); - } - - public void test_level1_core_nodeprocessinginstructionnodeattributes() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeprocessinginstructionnodeattributes"); - } - - public void test_level1_core_nodeprocessinginstructionnodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeprocessinginstructionnodename"); - } - - public void test_level1_core_nodeprocessinginstructionnodetype() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeprocessinginstructionnodetype"); - } - - public void test_level1_core_nodeprocessinginstructionnodevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeprocessinginstructionnodevalue"); - } - - public void test_level1_core_noderemovechild() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/noderemovechild"); - } - - public void test_level1_core_noderemovechildgetnodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/noderemovechildgetnodename"); - } - - public void test_level1_core_nodereplacechildnewchilddiffdocument() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodereplacechildnewchilddiffdocument"); - } - - public void test_level1_core_nodereplacechildnodeancestor() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodereplacechildnodeancestor"); - } - - public void test_level1_core_nodereplacechildnodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodereplacechildnodename"); - } - - public void test_level1_core_nodetextnodeattribute() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodetextnodeattribute"); - } - - public void test_level1_core_nodetextnodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodetextnodename"); - } - - public void test_level1_core_nodetextnodetype() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodetextnodetype"); - } - - public void test_level1_core_nodetextnodevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodetextnodevalue"); - } - - public void test_level1_core_processinginstructiongetdata() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/processinginstructiongetdata"); - } - - public void test_level1_core_processinginstructiongettarget() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/processinginstructiongettarget"); - } - - public void test_level1_core_textsplittextfour() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/textsplittextfour"); - } - - public void test_level1_core_textsplittextone() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/textsplittextone"); - } - - public void test_level1_core_textsplittextthree() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/textsplittextthree"); - } - - public void test_level1_core_textwithnomarkup() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/textwithnomarkup"); - } - - public void test_level1_core_nodevalue01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodevalue01"); - } - - public void test_level1_core_nodevalue03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodevalue03"); - } - - public void test_level1_core_nodevalue04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodevalue04"); - } - - public void test_level1_core_nodevalue05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodevalue05"); - } - - public void test_level1_core_nodevalue06() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodevalue06"); - } - - public void test_level1_core_hc_attrcreatedocumentfragment() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrcreatedocumentfragment"); - } - - public void test_level1_core_hc_attrcreatetextnode() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrcreatetextnode"); - } - - public void test_level1_core_hc_attrcreatetextnode2() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrcreatetextnode2"); - } - - public void test_level1_core_hc_attreffectivevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attreffectivevalue"); - } - - public void test_level1_core_hc_attrname() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrname"); - } - - public void test_level1_core_hc_attrnextsiblingnull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrnextsiblingnull"); - } - - public void test_level1_core_hc_attrparentnodenull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrparentnodenull"); - } - - public void test_level1_core_hc_attrprevioussiblingnull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrprevioussiblingnull"); - } - - public void test_level1_core_hc_attrspecifiedvalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrspecifiedvalue"); - } - - public void test_level1_core_hc_attrspecifiedvaluechanged() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrspecifiedvaluechanged"); - } - - public void test_level1_core_hc_characterdataappenddata() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdataappenddata"); - } - - public void test_level1_core_hc_characterdataappenddatagetdata() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdataappenddatagetdata"); - } - - public void test_level1_core_hc_characterdatadeletedatabegining() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatadeletedatabegining"); - } - - public void test_level1_core_hc_characterdatadeletedataend() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatadeletedataend"); - } - - public void test_level1_core_hc_characterdatadeletedataexceedslength() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatadeletedataexceedslength"); - } - - public void test_level1_core_hc_characterdatadeletedatagetlengthanddata() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatadeletedatagetlengthanddata"); - } - - public void test_level1_core_hc_characterdatadeletedatamiddle() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatadeletedatamiddle"); - } - - public void test_level1_core_hc_characterdatagetdata() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatagetdata"); - } - - public void test_level1_core_hc_characterdatagetlength() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatagetlength"); - } - - public void test_level1_core_hc_characterdatainsertdatabeginning() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatainsertdatabeginning"); - } - - public void test_level1_core_hc_characterdatainsertdataend() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatainsertdataend"); - } - - public void test_level1_core_hc_characterdatainsertdatamiddle() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatainsertdatamiddle"); - } - - public void test_level1_core_hc_characterdatareplacedatabegining() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatareplacedatabegining"); - } - - public void test_level1_core_hc_characterdatareplacedataend() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatareplacedataend"); - } - - public void test_level1_core_hc_characterdatareplacedataexceedslengthofarg() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatareplacedataexceedslengthofarg"); - } - - public void test_level1_core_hc_characterdatareplacedataexceedslengthofdata() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatareplacedataexceedslengthofdata"); - } - - public void test_level1_core_hc_characterdatareplacedatamiddle() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatareplacedatamiddle"); - } - - public void test_level1_core_hc_characterdatasubstringvalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatasubstringvalue"); - } - - public void test_level1_core_hc_commentgetcomment() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_commentgetcomment"); - } - - public void test_level1_core_hc_documentcreatecomment() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentcreatecomment"); - } - - public void test_level1_core_hc_documentcreatedocumentfragment() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentcreatedocumentfragment"); - } - - public void test_level1_core_hc_documentcreateelement() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentcreateelement"); - } - - public void test_level1_core_hc_documentcreateelementcasesensitive() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentcreateelementcasesensitive"); - } - - public void test_level1_core_hc_documentcreatetextnode() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentcreatetextnode"); - } - - public void test_level1_core_hc_documentgetdoctype() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentgetdoctype"); - } - - public void test_level1_core_hc_documentgetelementsbytagnamelength() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentgetelementsbytagnamelength"); - } - - public void test_level1_core_hc_documentgetelementsbytagnametotallength() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentgetelementsbytagnametotallength"); - } - - public void test_level1_core_hc_documentgetelementsbytagnamevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentgetelementsbytagnamevalue"); - } - - public void test_level1_core_hc_documentgetimplementation() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentgetimplementation"); - } - - public void test_level1_core_hc_documentgetrootnode() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentgetrootnode"); - } - - public void test_level1_core_hc_documentinvalidcharacterexceptioncreateattribute() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentinvalidcharacterexceptioncreateattribute"); - } - - public void test_level1_core_hc_documentinvalidcharacterexceptioncreateattribute1() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentinvalidcharacterexceptioncreateattribute1"); - } - - public void test_level1_core_hc_documentinvalidcharacterexceptioncreateelement() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentinvalidcharacterexceptioncreateelement"); - } - - public void test_level1_core_hc_documentinvalidcharacterexceptioncreateelement1() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentinvalidcharacterexceptioncreateelement1"); - } - - public void test_level1_core_hc_domimplementationfeaturenoversion() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_domimplementationfeaturenoversion"); - } - - public void test_level1_core_hc_domimplementationfeaturenull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_domimplementationfeaturenull"); - } - - public void test_level1_core_hc_domimplementationfeaturexml() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_domimplementationfeaturexml"); - } - - public void test_level1_core_hc_elementaddnewattribute() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementaddnewattribute"); - } - - public void test_level1_core_hc_elementassociatedattribute() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementassociatedattribute"); - } - - public void test_level1_core_hc_elementchangeattributevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementchangeattributevalue"); - } - - public void test_level1_core_hc_elementgetattributenode() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementgetattributenode"); - } - - public void test_level1_core_hc_elementgetattributenodenull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementgetattributenodenull"); - } - - public void test_level1_core_hc_elementgetelementsbytagname() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementgetelementsbytagname"); - } - - public void test_level1_core_hc_elementgetelementsbytagnameaccessnodelist() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementgetelementsbytagnameaccessnodelist"); - } - - public void test_level1_core_hc_elementgetelementsbytagnamenomatch() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementgetelementsbytagnamenomatch"); - } - - public void test_level1_core_hc_elementgettagname() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementgettagname"); - } - - public void test_level1_core_hc_elementinuseattributeerr() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementinuseattributeerr"); - } - - public void test_level1_core_hc_elementinvalidcharacterexception() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementinvalidcharacterexception"); - } - - public void test_level1_core_hc_elementinvalidcharacterexception1() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementinvalidcharacterexception1"); - } - - public void test_level1_core_hc_elementnormalize() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementnormalize"); - } - - public void test_level1_core_hc_elementnotfounderr() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementnotfounderr"); - } - - public void test_level1_core_hc_elementremoveattribute() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementremoveattribute"); - } - - public void test_level1_core_hc_elementremoveattributeaftercreate() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementremoveattributeaftercreate"); - } - - public void test_level1_core_hc_elementremoveattributenode() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementremoveattributenode"); - } - - public void test_level1_core_hc_elementreplaceexistingattributegevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementreplaceexistingattributegevalue"); - } - - public void test_level1_core_hc_elementretrieveattrvalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementretrieveattrvalue"); - } - - public void test_level1_core_hc_elementretrievetagname() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementretrievetagname"); - } - - public void test_level1_core_hc_elementsetattributenodenull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementsetattributenodenull"); - } - - public void test_level1_core_hc_elementwrongdocumenterr() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementwrongdocumenterr"); - } - - public void test_level1_core_hc_namednodemapgetnameditem() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapgetnameditem"); - } - - public void test_level1_core_hc_namednodemapinuseattributeerr() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapinuseattributeerr"); - } - - public void test_level1_core_hc_namednodemapnotfounderr() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapnotfounderr"); - } - - public void test_level1_core_hc_namednodemapremovenameditem() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapremovenameditem"); - } - - public void test_level1_core_hc_namednodemapreturnattrnode() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapreturnattrnode"); - } - - public void test_level1_core_hc_namednodemapreturnnull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapreturnnull"); - } - - public void test_level1_core_hc_namednodemapsetnameditem() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapsetnameditem"); - } - - public void test_level1_core_hc_namednodemapsetnameditemreturnvalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapsetnameditemreturnvalue"); - } - - public void test_level1_core_hc_namednodemapsetnameditemwithnewvalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapsetnameditemwithnewvalue"); - } - - public void test_level1_core_hc_namednodemapwrongdocumenterr() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapwrongdocumenterr"); - } - - public void test_level1_core_hc_nodeappendchild() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeappendchild"); - } - - public void test_level1_core_hc_nodeappendchildgetnodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeappendchildgetnodename"); - } - - public void test_level1_core_hc_nodeappendchildnewchilddiffdocument() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeappendchildnewchilddiffdocument"); - } - - public void test_level1_core_hc_nodeappendchildnodeancestor() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeappendchildnodeancestor"); - } - - public void test_level1_core_hc_nodeattributenodeattribute() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeattributenodeattribute"); - } - - public void test_level1_core_hc_nodeattributenodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeattributenodename"); - } - - public void test_level1_core_hc_nodeattributenodetype() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeattributenodetype"); - } - - public void test_level1_core_hc_nodeattributenodevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeattributenodevalue"); - } - - public void test_level1_core_hc_nodechildnodes() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodechildnodes"); - } - - public void test_level1_core_hc_nodechildnodesempty() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodechildnodesempty"); - } - - public void test_level1_core_hc_nodecommentnodeattributes() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodecommentnodeattributes"); - } - - public void test_level1_core_hc_nodecommentnodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodecommentnodename"); - } - - public void test_level1_core_hc_nodecommentnodetype() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodecommentnodetype"); - } - - public void test_level1_core_hc_nodecommentnodevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodecommentnodevalue"); - } - - public void test_level1_core_hc_nodedocumentfragmentnodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodedocumentfragmentnodename"); - } - - public void test_level1_core_hc_nodedocumentfragmentnodetype() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodedocumentfragmentnodetype"); - } - - public void test_level1_core_hc_nodedocumentfragmentnodevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodedocumentfragmentnodevalue"); - } - - public void test_level1_core_hc_nodedocumentnodeattribute() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodedocumentnodeattribute"); - } - - public void test_level1_core_hc_nodedocumentnodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodedocumentnodename"); - } - - public void test_level1_core_hc_nodedocumentnodetype() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodedocumentnodetype"); - } - - public void test_level1_core_hc_nodedocumentnodevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodedocumentnodevalue"); - } - - public void test_level1_core_hc_nodeelementnodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeelementnodename"); - } - - public void test_level1_core_hc_nodeelementnodetype() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeelementnodetype"); - } - - public void test_level1_core_hc_nodeelementnodevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeelementnodevalue"); - } - - public void test_level1_core_hc_nodegetfirstchild() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetfirstchild"); - } - - public void test_level1_core_hc_nodegetfirstchildnull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetfirstchildnull"); - } - - public void test_level1_core_hc_nodegetlastchild() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetlastchild"); - } - - public void test_level1_core_hc_nodegetlastchildnull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetlastchildnull"); - } - - public void test_level1_core_hc_nodegetnextsibling() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetnextsibling"); - } - - public void test_level1_core_hc_nodegetnextsiblingnull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetnextsiblingnull"); - } - - public void test_level1_core_hc_nodegetownerdocument() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetownerdocument"); - } - - public void test_level1_core_hc_nodegetownerdocumentnull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetownerdocumentnull"); - } - - public void test_level1_core_hc_nodegetprevioussibling() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetprevioussibling"); - } - - public void test_level1_core_hc_nodegetprevioussiblingnull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetprevioussiblingnull"); - } - - public void test_level1_core_hc_nodehaschildnodes() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodehaschildnodes"); - } - - public void test_level1_core_hc_nodehaschildnodesfalse() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodehaschildnodesfalse"); - } - - public void test_level1_core_hc_nodeinsertbeforenewchilddiffdocument() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeinsertbeforenewchilddiffdocument"); - } - - public void test_level1_core_hc_nodeinsertbeforenodeancestor() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeinsertbeforenodeancestor"); - } - - public void test_level1_core_hc_nodeinsertbeforenodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeinsertbeforenodename"); - } - - public void test_level1_core_hc_nodelistindexequalzero() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodelistindexequalzero"); - } - - public void test_level1_core_hc_nodelistindexgetlength() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodelistindexgetlength"); - } - - public void test_level1_core_hc_nodelistindexgetlengthofemptylist() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodelistindexgetlengthofemptylist"); - } - - public void test_level1_core_hc_nodelistindexnotzero() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodelistindexnotzero"); - } - - public void test_level1_core_hc_nodelistreturnfirstitem() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodelistreturnfirstitem"); - } - - public void test_level1_core_hc_nodelistreturnlastitem() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodelistreturnlastitem"); - } - - public void test_level1_core_hc_nodelisttraverselist() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodelisttraverselist"); - } - - public void test_level1_core_hc_nodeparentnode() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeparentnode"); - } - - public void test_level1_core_hc_nodeparentnodenull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeparentnodenull"); - } - - public void test_level1_core_hc_noderemovechild() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_noderemovechild"); - } - - public void test_level1_core_hc_noderemovechildgetnodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_noderemovechildgetnodename"); - } - - public void test_level1_core_hc_nodereplacechildnewchilddiffdocument() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodereplacechildnewchilddiffdocument"); - } - - public void test_level1_core_hc_nodereplacechildnodeancestor() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodereplacechildnodeancestor"); - } - - public void test_level1_core_hc_nodereplacechildnodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodereplacechildnodename"); - } - - public void test_level1_core_hc_nodetextnodeattribute() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodetextnodeattribute"); - } - - public void test_level1_core_hc_nodetextnodename() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodetextnodename"); - } - - public void test_level1_core_hc_nodetextnodetype() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodetextnodetype"); - } - - public void test_level1_core_hc_nodetextnodevalue() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodetextnodevalue"); - } - - public void test_level1_core_hc_nodevalue01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodevalue01"); - } - - public void test_level1_core_hc_nodevalue03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodevalue03"); - } - - public void test_level1_core_hc_nodevalue04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodevalue04"); - } - - public void test_level1_core_hc_nodevalue05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodevalue05"); - } - - public void test_level1_core_hc_nodevalue06() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodevalue06"); - } - - public void test_level1_core_hc_textsplittextfour() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_textsplittextfour"); - } - - public void test_level1_core_hc_textsplittextone() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_textsplittextone"); - } - - public void test_level1_core_hc_textsplittextthree() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_textsplittextthree"); - } - - public void test_level1_core_hc_textwithnomarkup() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_textwithnomarkup"); - } - - public void test_level1_core_hc_attrappendchild2() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrappendchild2"); - } - - public void test_level1_core_hc_attrappendchild4() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrappendchild4"); - } - - public void test_level1_core_hc_attrinsertbefore5() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrinsertbefore5"); - } - - public void test_level1_core_hc_attrinsertbefore7() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrinsertbefore7"); - } - - public void test_level2_core_attrgetownerelement02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/attrgetownerelement02"); - } - - public void test_level2_core_attrgetownerelement03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/attrgetownerelement03"); - } - - public void test_level2_core_attrgetownerelement04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/attrgetownerelement04"); - } - - public void test_level2_core_attrgetownerelement05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/attrgetownerelement05"); - } - - public void test_level2_core_createAttributeNS01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/createAttributeNS01"); - } - - public void test_level2_core_createAttributeNS02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/createAttributeNS02"); - } - - public void test_level2_core_createAttributeNS03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/createAttributeNS03"); - } - - public void test_level2_core_createAttributeNS04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/createAttributeNS04"); - } - - public void test_level2_core_createAttributeNS05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/createAttributeNS05"); - } - - public void test_level2_core_createDocument01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocument01"); - } - - public void test_level2_core_createDocument02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocument02"); - } - - public void test_level2_core_createDocument05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocument05"); - } - - public void test_level2_core_createDocument06() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocument06"); - } - - public void test_level2_core_createDocument07() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocument07"); - } - - public void test_level2_core_createDocumentType01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocumentType01"); - } - - public void test_level2_core_createDocumentType02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocumentType02"); - } - - public void test_level2_core_createDocumentType03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocumentType03"); - } - - public void test_level2_core_createElementNS01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/createElementNS01"); - } - - public void test_level2_core_createElementNS02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/createElementNS02"); - } - - public void test_level2_core_createElementNS03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/createElementNS03"); - } - - public void test_level2_core_createElementNS04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/createElementNS04"); - } - - public void test_level2_core_createElementNS05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/createElementNS05"); - } - - public void test_level2_core_documentcreateattributeNS01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateattributeNS01"); - } - - public void test_level2_core_documentcreateattributeNS02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateattributeNS02"); - } - - public void test_level2_core_documentcreateattributeNS03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateattributeNS03"); - } - - public void test_level2_core_documentcreateattributeNS04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateattributeNS04"); - } - - public void test_level2_core_documentcreateattributeNS05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateattributeNS05"); - } - - public void test_level2_core_documentcreateattributeNS06() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateattributeNS06"); - } - - public void test_level2_core_documentcreateattributeNS07() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateattributeNS07"); - } - - public void test_level2_core_documentcreateelementNS01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateelementNS01"); - } - - public void test_level2_core_documentcreateelementNS02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateelementNS02"); - } - - public void test_level2_core_documentcreateelementNS05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateelementNS05"); - } - - public void test_level2_core_documentcreateelementNS06() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateelementNS06"); - } - - public void test_level2_core_documentgetelementbyid01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentgetelementbyid01"); - } - - public void test_level2_core_documentgetelementsbytagnameNS01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentgetelementsbytagnameNS01"); - } - - public void test_level2_core_documentgetelementsbytagnameNS02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentgetelementsbytagnameNS02"); - } - - public void test_level2_core_documentgetelementsbytagnameNS03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentgetelementsbytagnameNS03"); - } - - public void test_level2_core_documentgetelementsbytagnameNS04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentgetelementsbytagnameNS04"); - } - - public void test_level2_core_documentgetelementsbytagnameNS05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentgetelementsbytagnameNS05"); - } - - public void test_level2_core_documentimportnode02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode02"); - } - - public void test_level2_core_documentimportnode05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode05"); - } - - public void test_level2_core_documentimportnode06() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode06"); - } - - public void test_level2_core_documentimportnode07() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode07"); - } - - public void test_level2_core_documentimportnode08() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode08"); - } - - public void test_level2_core_documentimportnode09() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode09"); - } - - public void test_level2_core_documentimportnode10() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode10"); - } - - public void test_level2_core_documentimportnode11() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode11"); - } - - public void test_level2_core_documentimportnode12() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode12"); - } - - public void test_level2_core_documentimportnode13() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode13"); - } - - public void test_level2_core_documentimportnode15() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode15"); - } - - public void test_level2_core_documentimportnode17() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode17"); - } - - public void test_level2_core_documentimportnode18() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode18"); - } - - public void test_level2_core_documenttypeinternalSubset01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documenttypeinternalSubset01"); - } - - public void test_level2_core_documenttypepublicid01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documenttypepublicid01"); - } - - public void test_level2_core_documenttypesystemid01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/documenttypesystemid01"); - } - - public void test_level2_core_domimplementationcreatedocument03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationcreatedocument03"); - } - - public void test_level2_core_domimplementationcreatedocument04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationcreatedocument04"); - } - - public void test_level2_core_domimplementationcreatedocument05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationcreatedocument05"); - } - - public void test_level2_core_domimplementationcreatedocument07() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationcreatedocument07"); - } - - public void test_level2_core_domimplementationcreatedocumenttype01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationcreatedocumenttype01"); - } - - public void test_level2_core_domimplementationcreatedocumenttype02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationcreatedocumenttype02"); - } - - public void test_level2_core_domimplementationcreatedocumenttype04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationcreatedocumenttype04"); - } - - public void test_level2_core_domimplementationfeaturecore() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationfeaturecore"); - } - - public void test_level2_core_domimplementationfeaturexmlversion2() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationfeaturexmlversion2"); - } - - public void test_level2_core_domimplementationhasfeature01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationhasfeature01"); - } - - public void test_level2_core_domimplementationhasfeature02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationhasfeature02"); - } - - public void test_level2_core_elementgetattributenodens01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementgetattributenodens01"); - } - - public void test_level2_core_elementgetattributenodens02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementgetattributenodens02"); - } - - public void test_level2_core_elementgetelementsbytagnamens02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementgetelementsbytagnamens02"); - } - - public void test_level2_core_elementgetelementsbytagnamens04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementgetelementsbytagnamens04"); - } - - public void test_level2_core_elementgetelementsbytagnamens05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementgetelementsbytagnamens05"); - } - - public void test_level2_core_elementhasattribute01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementhasattribute01"); - } - - public void test_level2_core_elementhasattribute03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementhasattribute03"); - } - - public void test_level2_core_elementhasattribute04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementhasattribute04"); - } - - public void test_level2_core_elementhasattributens02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementhasattributens02"); - } - - public void test_level2_core_elementhasattributens03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementhasattributens03"); - } - - public void test_level2_core_elementremoveattributens01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementremoveattributens01"); - } - - public void test_level2_core_elementsetattributenodens01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributenodens01"); - } - - public void test_level2_core_elementsetattributenodens02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributenodens02"); - } - - public void test_level2_core_elementsetattributenodens03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributenodens03"); - } - - public void test_level2_core_elementsetattributenodens04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributenodens04"); - } - - public void test_level2_core_elementsetattributenodens05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributenodens05"); - } - - public void test_level2_core_elementsetattributens01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributens01"); - } - - public void test_level2_core_elementsetattributens02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributens02"); - } - - public void test_level2_core_elementsetattributens03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributens03"); - } - - public void test_level2_core_elementsetattributens04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributens04"); - } - - public void test_level2_core_elementsetattributens05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributens05"); - } - - public void test_level2_core_elementsetattributens08() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributens08"); - } - - public void test_level2_core_elementsetattributensurinull() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributensurinull"); - } - - public void test_level2_core_getAttributeNS02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getAttributeNS02"); - } - - public void test_level2_core_getAttributeNS03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getAttributeNS03"); - } - - public void test_level2_core_getAttributeNS04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getAttributeNS04"); - } - - public void test_level2_core_getAttributeNS05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getAttributeNS05"); - } - - public void test_level2_core_getAttributeNodeNS01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getAttributeNodeNS01"); - } - - public void test_level2_core_getAttributeNodeNS02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getAttributeNodeNS02"); - } - - public void test_level2_core_getElementById02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementById02"); - } - - public void test_level2_core_getElementsByTagNameNS02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS02"); - } - - public void test_level2_core_getElementsByTagNameNS03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS03"); - } - - public void test_level2_core_getElementsByTagNameNS04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS04"); - } - - public void test_level2_core_getElementsByTagNameNS05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS05"); - } - - public void test_level2_core_getElementsByTagNameNS06() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS06"); - } - - public void test_level2_core_getElementsByTagNameNS07() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS07"); - } - - public void test_level2_core_getElementsByTagNameNS08() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS08"); - } - - public void test_level2_core_getElementsByTagNameNS09() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS09"); - } - - public void test_level2_core_getElementsByTagNameNS10() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS10"); - } - - public void test_level2_core_getElementsByTagNameNS11() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS11"); - } - - public void test_level2_core_getElementsByTagNameNS12() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS12"); - } - - public void test_level2_core_getElementsByTagNameNS13() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS13"); - } - - public void test_level2_core_getElementsByTagNameNS14() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS14"); - } - - public void test_level2_core_getNamedItemNS01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getNamedItemNS01"); - } - - public void test_level2_core_getNamedItemNS02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/getNamedItemNS02"); - } - - public void test_level2_core_hasAttribute01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttribute01"); - } - - public void test_level2_core_hasAttribute03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttribute03"); - } - - public void test_level2_core_hasAttributeNS01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttributeNS01"); - } - - public void test_level2_core_hasAttributeNS02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttributeNS02"); - } - - public void test_level2_core_hasAttributeNS03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttributeNS03"); - } - - public void test_level2_core_hasAttributeNS05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttributeNS05"); - } - - public void test_level2_core_hasAttributes01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttributes01"); - } - - public void test_level2_core_hasAttributes02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttributes02"); - } - - public void test_level2_core_hc_namednodemapinvalidtype1() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/hc_namednodemapinvalidtype1"); - } - - public void test_level2_core_hc_nodedocumentfragmentnormalize1() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/hc_nodedocumentfragmentnormalize1"); - } - - public void test_level2_core_hc_nodedocumentfragmentnormalize2() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/hc_nodedocumentfragmentnormalize2"); - } - - public void test_level2_core_importNode02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode02"); - } - - public void test_level2_core_importNode03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode03"); - } - - public void test_level2_core_importNode04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode04"); - } - - public void test_level2_core_importNode08() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode08"); - } - - public void test_level2_core_importNode10() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode10"); - } - - public void test_level2_core_importNode14() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode14"); - } - - public void test_level2_core_importNode15() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode15"); - } - - public void test_level2_core_importNode16() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode16"); - } - - public void test_level2_core_importNode17() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode17"); - } - - public void test_level2_core_internalSubset01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/internalSubset01"); - } - - public void test_level2_core_isSupported01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported01"); - } - - public void test_level2_core_isSupported02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported02"); - } - - public void test_level2_core_isSupported04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported04"); - } - - public void test_level2_core_isSupported05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported05"); - } - - public void test_level2_core_isSupported06() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported06"); - } - - public void test_level2_core_isSupported07() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported07"); - } - - public void test_level2_core_isSupported09() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported09"); - } - - public void test_level2_core_isSupported10() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported10"); - } - - public void test_level2_core_isSupported11() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported11"); - } - - public void test_level2_core_isSupported12() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported12"); - } - - public void test_level2_core_isSupported13() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported13"); - } - - public void test_level2_core_isSupported14() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported14"); - } - - public void test_level2_core_localName01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/localName01"); - } - - public void test_level2_core_localName02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/localName02"); - } - - public void test_level2_core_localName03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/localName03"); - } - - public void test_level2_core_localName04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/localName04"); - } - - public void test_level2_core_namednodemapgetnameditemns02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapgetnameditemns02"); - } - - public void test_level2_core_namednodemapgetnameditemns03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapgetnameditemns03"); - } - - public void test_level2_core_namednodemapgetnameditemns04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapgetnameditemns04"); - } - - public void test_level2_core_namednodemapgetnameditemns05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapgetnameditemns05"); - } - - public void test_level2_core_namednodemapgetnameditemns06() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapgetnameditemns06"); - } - - public void test_level2_core_namednodemapremovenameditemns01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapremovenameditemns01"); - } - - public void test_level2_core_namednodemapremovenameditemns03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapremovenameditemns03"); - } - - public void test_level2_core_namednodemapremovenameditemns06() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapremovenameditemns06"); - } - - public void test_level2_core_namednodemapremovenameditemns07() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapremovenameditemns07"); - } - - public void test_level2_core_namednodemapremovenameditemns08() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapremovenameditemns08"); - } - - public void test_level2_core_namednodemapremovenameditemns09() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapremovenameditemns09"); - } - - public void test_level2_core_namednodemapsetnameditemns01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns01"); - } - - public void test_level2_core_namednodemapsetnameditemns02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns02"); - } - - public void test_level2_core_namednodemapsetnameditemns03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns03"); - } - - public void test_level2_core_namednodemapsetnameditemns04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns04"); - } - - public void test_level2_core_namednodemapsetnameditemns06() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns06"); - } - - public void test_level2_core_namednodemapsetnameditemns07() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns07"); - } - - public void test_level2_core_namednodemapsetnameditemns08() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns08"); - } - - public void test_level2_core_namespaceURI02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namespaceURI02"); - } - - public void test_level2_core_namespaceURI03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namespaceURI03"); - } - - public void test_level2_core_namespaceURI04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/namespaceURI04"); - } - - public void test_level2_core_nodegetlocalname03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodegetlocalname03"); - } - - public void test_level2_core_nodegetnamespaceuri03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodegetnamespaceuri03"); - } - - public void test_level2_core_nodegetownerdocument01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodegetownerdocument01"); - } - - public void test_level2_core_nodegetownerdocument02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodegetownerdocument02"); - } - - public void test_level2_core_nodegetprefix03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodegetprefix03"); - } - - public void test_level2_core_nodehasattributes01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodehasattributes01"); - } - - public void test_level2_core_nodehasattributes02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodehasattributes02"); - } - - public void test_level2_core_nodehasattributes03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodehasattributes03"); - } - - public void test_level2_core_nodehasattributes04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodehasattributes04"); - } - - public void test_level2_core_nodeissupported01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodeissupported01"); - } - - public void test_level2_core_nodeissupported02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodeissupported02"); - } - - public void test_level2_core_nodeissupported03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodeissupported03"); - } - - public void test_level2_core_nodeissupported04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodeissupported04"); - } - - public void test_level2_core_nodeissupported05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodeissupported05"); - } - - public void test_level2_core_nodenormalize01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodenormalize01"); - } - - public void test_level2_core_nodesetprefix01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodesetprefix01"); - } - - public void test_level2_core_nodesetprefix02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodesetprefix02"); - } - - public void test_level2_core_nodesetprefix03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodesetprefix03"); - } - - public void test_level2_core_nodesetprefix05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodesetprefix05"); - } - - public void test_level2_core_nodesetprefix06() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodesetprefix06"); - } - - public void test_level2_core_nodesetprefix07() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodesetprefix07"); - } - - public void test_level2_core_nodesetprefix08() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodesetprefix08"); - } - - public void test_level2_core_normalize01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/normalize01"); - } - - public void test_level2_core_ownerDocument01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/ownerDocument01"); - } - - public void test_level2_core_ownerElement01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/ownerElement01"); - } - - public void test_level2_core_ownerElement02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/ownerElement02"); - } - - public void test_level2_core_prefix01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix01"); - } - - public void test_level2_core_prefix02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix02"); - } - - public void test_level2_core_prefix03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix03"); - } - - public void test_level2_core_prefix04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix04"); - } - - public void test_level2_core_prefix05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix05"); - } - - public void test_level2_core_prefix07() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix07"); - } - - public void test_level2_core_prefix10() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix10"); - } - - public void test_level2_core_prefix11() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix11"); - } - - public void test_level2_core_publicId01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/publicId01"); - } - - public void test_level2_core_removeNamedItemNS01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/removeNamedItemNS01"); - } - - public void test_level2_core_removeNamedItemNS02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/removeNamedItemNS02"); - } - - public void test_level2_core_setAttributeNS01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNS01"); - } - - public void test_level2_core_setAttributeNS02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNS02"); - } - - public void test_level2_core_setAttributeNS04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNS04"); - } - - public void test_level2_core_setAttributeNS05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNS05"); - } - - public void test_level2_core_setAttributeNS06() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNS06"); - } - - public void test_level2_core_setAttributeNS07() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNS07"); - } - - public void test_level2_core_setAttributeNS09() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNS09"); - } - - public void test_level2_core_setAttributeNodeNS01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNodeNS01"); - } - - public void test_level2_core_setAttributeNodeNS03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNodeNS03"); - } - - public void test_level2_core_setAttributeNodeNS04() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNodeNS04"); - } - - public void test_level2_core_setAttributeNodeNS05() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNodeNS05"); - } - - public void test_level2_core_setNamedItemNS01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/setNamedItemNS01"); - } - - public void test_level2_core_setNamedItemNS02() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/setNamedItemNS02"); - } - - public void test_level2_core_setNamedItemNS03() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/setNamedItemNS03"); - } - - public void test_level2_core_systemId01() throws Throwable { - runDomTest("http://www.w3.org/2001/DOM-Test-Suite/level2/core/systemId01"); - } - -} \ No newline at end of file diff --git a/libcore/dom/src/test/java/org/w3c/domts/LSDocumentBuilderFactory.java b/libcore/dom/src/test/java/org/w3c/domts/LSDocumentBuilderFactory.java deleted file mode 100644 index 7ed0f542c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/LSDocumentBuilderFactory.java +++ /dev/null @@ -1,414 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; - -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; - -/** - * This class implements the generic parser and configuation - * abstract class for the DOM L3 implementations - * - * @author Curt Arnold - */ -public class LSDocumentBuilderFactory - extends DOMTestDocumentBuilderFactory { - - private final Object parser; - private final Method parseURIMethod; - private final DOMImplementation impl; - - /** - * - * Abstract class for a strategy to map a DocumentBuilderSetting - * to an action on LSParser. - */ - private static abstract class LSStrategy { - - /** - * Constructor. - */ - protected LSStrategy() { - } - - /** - * Applies setting to LSParser - * - * @param setting setting - * @param parser parser - * @throws DOMTestIncompatibleException if parser does not support setting - */ - public abstract void applySetting(DocumentBuilderSetting setting, - Object parser) throws - DOMTestIncompatibleException; - - /** - * Gets state of setting for parser - * - * @param parser parser - * @return state of setting - */ - public abstract boolean hasSetting(Object parser); - - } - - /** - * Represents a fixed setting, for example, all Java implementations - * supported signed values. - * - */ - private static class LSFixedStrategy - extends LSStrategy { - private final boolean fixedValue; - - /** - * Constructor - * - * @param settingName setting name - * @param fixedValue fixed value - */ - public LSFixedStrategy(boolean fixedValue) { - this.fixedValue = fixedValue; - } - - /** - * Apply setting. Throws exception if requested setting - * does not match fixed value. - */ - public void applySetting(DocumentBuilderSetting setting, Object parser) throws - DOMTestIncompatibleException { - if (setting.getValue() != fixedValue) { - throw new DOMTestIncompatibleException(null, setting); - } - } - - /** - * Gets fixed value for setting - */ - public boolean hasSetting(Object parser) { - return fixedValue; - } - } - - /** - * A strategy for a setting that can be applied by setting a DOMConfiguration - * parameter. - * - */ - private static class LSParameterStrategy - extends LSStrategy { - private final String lsParameter; - private final boolean inverse; - - /** - * Constructor - * - * @param lsParameter corresponding DOMConfiguration parameter - * @param inverse if true, DOMConfiguration value is the inverse - * of the setting value - */ - public LSParameterStrategy(String lsParameter, boolean inverse) { - this.lsParameter = lsParameter; - this.inverse = inverse; - } - - protected static void setParameter(DocumentBuilderSetting setting, - Object parser, - String parameter, - Object value) throws - DOMTestIncompatibleException { - try { - Method domConfigMethod = parser.getClass().getMethod("getDomConfig", - new Class[0]); - Object domConfig = domConfigMethod.invoke(parser, new Object[0]); - Method setParameterMethod = domConfig.getClass().getMethod( - "setParameter", new Class[] {String.class, Object.class}); - setParameterMethod.invoke(domConfig, new Object[] {parameter, value}); - - } - catch (InvocationTargetException ex) { - throw new DOMTestIncompatibleException(ex.getTargetException(), setting); - } - catch (Exception ex) { - throw new DOMTestIncompatibleException(ex, setting); - } - } - - protected static Object getParameter(Object parser, - String parameter) throws Exception { - Method domConfigMethod = parser.getClass().getMethod("getDomConfig", - new Class[0]); - Object domConfig = domConfigMethod.invoke(parser, new Object[0]); - Method getParameterMethod = domConfig.getClass().getMethod("getParameter", - new Class[] {String.class}); - return getParameterMethod.invoke(domConfig, new Object[] {parameter}); - } - - /** - * Apply setting - */ - public void applySetting(DocumentBuilderSetting setting, Object parser) throws - DOMTestIncompatibleException { - if (inverse) { - setParameter(setting, parser, lsParameter, - new Boolean(!setting.getValue())); - } - else { - setParameter(setting, parser, lsParameter, new Boolean(setting.getValue())); - } - } - - /** - * Get value of setting - */ - public boolean hasSetting(Object parser) { - try { - if (inverse) { - return! ( (Boolean) getParameter(parser, lsParameter)).booleanValue(); - } - else { - return ( (Boolean) getParameter(parser, lsParameter)).booleanValue(); - } - } - catch (Exception ex) { - return false; - } - } - } - - /** - * A strategy for the validation settings which require - * two DOMConfigurure parameters being set, 'validate' and 'schema-type' - * - */ - private static class LSValidateStrategy - extends LSParameterStrategy { - private final String schemaType; - - /** - * Constructor - * @param schemaType schema type - */ - public LSValidateStrategy(String schemaType) { - super("validate", false); - this.schemaType = schemaType; - } - - /** - * Apply setting - */ - public void applySetting(DocumentBuilderSetting setting, Object parser) throws - DOMTestIncompatibleException { - super.applySetting(setting, parser); - setParameter(null, parser, "schema-type", schemaType); - } - - /** - * Get setting value - */ - public boolean hasSetting(Object parser) { - if (super.hasSetting(parser)) { - try { - String parserSchemaType = (String) getParameter(parser, "schema-type"); - if (schemaType == null || schemaType.equals(parserSchemaType)) { - return true; - } - } - catch (Exception ex) { - } - } - return false; - } - - } - - /** - * Strategies for mapping DocumentBuilderSettings to - * actions on LSParser - */ - private static final Map strategies; - - static { - strategies = new HashMap(); - strategies.put("coalescing", new LSParameterStrategy("cdata-sections", true)); - strategies.put("expandEntityReferences", new LSParameterStrategy("entities", true)); - strategies.put("ignoringElementContentWhitespace", - new LSParameterStrategy("element-content-whitespace", true)); - strategies.put("namespaceAware", new LSParameterStrategy("namespaces", false)); - strategies.put("validating", - new LSValidateStrategy("http://www.w3.org/TR/REC-xml")); - strategies.put("schemaValidating", - new LSValidateStrategy("http://www.w3.org/2001/XMLSchema")); - strategies.put("ignoringComments", new LSParameterStrategy("comments", true)); - strategies.put("signed", new LSFixedStrategy(true)); - strategies.put("hasNullString", new LSFixedStrategy(true)); - } - - /** - * Creates a LS implementation of DOMTestDocumentBuilderFactory. - * @param settings array of settings, may be null. - * @throws DOMTestIncompatibleException - * Thrown if implementation does not support the specified settings - */ - public LSDocumentBuilderFactory(DocumentBuilderSetting[] settings) throws - DOMTestIncompatibleException { - super(settings); - - try { - Class domImplRegistryClass = Class.forName( - "org.w3c.dom.bootstrap.DOMImplementationRegistry"); - Method newInstanceMethod = domImplRegistryClass.getMethod("newInstance", null); - Object domRegistry = newInstanceMethod.invoke(null, null); - Method getDOMImplementationMethod = domImplRegistryClass.getMethod( - "getDOMImplementation", new Class[] {String.class}); - impl = (DOMImplementation) getDOMImplementationMethod.invoke(domRegistry, - new Object[] {"LS"}); - Method createLSParserMethod = impl.getClass().getMethod("createLSParser", - new Class[] {short.class, String.class}); - parser = createLSParserMethod.invoke(impl, - new Object[] {new Short( (short) 1), null}); - parseURIMethod = parser.getClass().getMethod("parseURI", - new Class[] {String.class}); - } - catch (InvocationTargetException ex) { - throw new DOMTestIncompatibleException(ex.getTargetException(), null); - } - catch (Exception ex) { - throw new DOMTestIncompatibleException(ex, null); - } - - if (settings != null) { - for (int i = 0; i < settings.length; i++) { - Object strategy = strategies.get(settings[i].getProperty()); - if (strategy == null) { - throw new DOMTestIncompatibleException(null, settings[i]); - } - else { - ( (LSStrategy) strategy).applySetting(settings[i], parser); - } - } - } - } - - /** - * Create new instance of document builder factory - * reflecting specified settings - * @param newSettings new settings - * @return New instance - * @throws DOMTestIncompatibleException - * if settings are not supported by implementation - */ - public DOMTestDocumentBuilderFactory newInstance( - DocumentBuilderSetting[] newSettings) throws DOMTestIncompatibleException { - if (newSettings == null) { - return this; - } - DocumentBuilderSetting[] mergedSettings = mergeSettings(newSettings); - return new LSDocumentBuilderFactory(mergedSettings); - } - - /** - * Loads specified URL - * @param url url to load - * @return DOM document - * @throws DOMTestLoadException if unable to load document - */ - public Document load(java.net.URL url) throws DOMTestLoadException { - try { - return (Document) parseURIMethod.invoke(parser, - new Object[] {url.toString()}); - } - catch (InvocationTargetException ex) { - throw new DOMTestLoadException(ex.getTargetException()); - } - catch (Exception ex) { - throw new DOMTestLoadException(ex); - } - } - - /** - * Gets DOMImplementation - * @return DOM implementation, may be null - */ - public DOMImplementation getDOMImplementation() { - return impl; - } - - /** - * Determines if the implementation supports the specified feature - * @param feature Feature - * @param version Version - * @return true if implementation supports the feature - */ - public boolean hasFeature(String feature, String version) { - return getDOMImplementation().hasFeature(feature, version); - } - - private boolean hasProperty(String parameter) { - try { - return ( (Boolean) LSParameterStrategy.getParameter(parser, parameter)). - booleanValue(); - } - catch (Exception ex) { - return true; - } - - } - - /** - * Indicates whether the implementation combines text and cdata nodes. - * @return true if coalescing - */ - public boolean isCoalescing() { - return!hasProperty("cdata-sections"); - } - - /** - * Indicates whether the implementation expands entity references. - * @return true if expanding entity references - */ - public boolean isExpandEntityReferences() { - return!hasProperty("entities"); - } - - /** - * Indicates whether the implementation ignores - * element content whitespace. - * @return true if ignoring element content whitespace - */ - public boolean isIgnoringElementContentWhitespace() { - return!hasProperty("element-content-whitespace"); - } - - /** - * Indicates whether the implementation is namespace aware. - * @return true if namespace aware - */ - public boolean isNamespaceAware() { - return hasProperty("namespaces"); - } - - /** - * Indicates whether the implementation is validating. - * @return true if validating - */ - public boolean isValidating() { - return hasProperty("validate"); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/UserDataMonitor.java b/libcore/dom/src/test/java/org/w3c/domts/UserDataMonitor.java deleted file mode 100644 index d7e35bb52..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/UserDataMonitor.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2004 World Wide Web Consortium, (Massachusetts Institute of - * Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - -import java.util.ArrayList; -import java.util.List; - -import org.w3c.dom.Node; -import org.w3c.dom.UserDataHandler; - -/** - * This is a utility implementation of UserDataHandler that captures all - * notifications - */ -public class UserDataMonitor - implements UserDataHandler { - private final List notifications = new ArrayList(); - - /** - * Public constructor - * - */ - public UserDataMonitor() { - } - - /** - * Implementation of UserDataHandler.handle. Creates a UserDataNotification - * for later testing - * - * @param operation - * See org.w3c.dom.UserDataHandler - * @param key - * See org.w3c.dom.UserDataHandler - * @param data - * See org.w3c.dom.UserDataHandler - * @param src - * See org.w3c.dom.UserDataHandler - * @param dst - * See org.w3c.dom.UserDataHandler - */ - public void handle( - short operation, - String key, - Object data, - Node src, - Node dst) { - notifications.add( - new UserDataNotification(operation, key, data, src, dst)); - } - - /** - * Gets list of notifications - * - * @return List of notifications, may not be null. - */ - public final List getAllNotifications() { - return new ArrayList(notifications); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/UserDataNotification.java b/libcore/dom/src/test/java/org/w3c/domts/UserDataNotification.java deleted file mode 100644 index d422901b3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/UserDataNotification.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2004 World Wide Web Consortium, (Massachusetts Institute of - * Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - -import org.w3c.dom.Node; - -/** - * This class captures the parameters to one invocation of - * UserDataHandler.handle. - * - */ -public class UserDataNotification { - private final short operation; - private final String key; - private final Object data; - private final Node src; - private final Node dst; - - /** - * Public constructor - * - */ - public UserDataNotification(short operation, - String key, - Object data, - Node src, - Node dst) { - this.operation = operation; - this.key = key; - this.data = data; - this.src = src; - this.dst = dst; - } - - /** - * Get value of operation parameter - * - * @return value of operation parameter - */ - public final short getOperation() { - return operation; - } - - /** - * Gets value of key parameter - * - * @return value of key parameter - */ - public final String getKey() { - return key; - } - - /** - * Gets value of data parameter - * - * @return value of data parameter - */ - public final Object getData() { - return data; - } - - /** - * Gets value of src parameter - * - * @return value of src parameter - */ - public final Node getSrc() { - return src; - } - - /** - * Gets value of dst parameter - * - * @return value of dst parameter - */ - public final Node getDst() { - return dst; - } -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/XalanDOMTestDocumentBuilderFactory.java b/libcore/dom/src/test/java/org/w3c/domts/XalanDOMTestDocumentBuilderFactory.java deleted file mode 100644 index cb60658a2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/XalanDOMTestDocumentBuilderFactory.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2001-2003 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -/* - $Log: XalanDOMTestDocumentBuilderFactory.java,v $ - Revision 1.2 2004/03/11 01:44:21 dom-ts-4 - Checkstyle fixes (bug 592) - - Revision 1.1 2003/04/24 05:02:05 dom-ts-4 - Xalan-J support for L3 XPath - http://www.w3.org/Bugs/Public/show_bug.cgi?id=191 - - Revision 1.1 2002/02/03 07:47:51 dom-ts-4 - More missing files - - */ - -package org.w3c.domts; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import org.w3c.dom.Document; - -/** - * - * This class uses Xalan-J to add XPath support - * to the current JAXP DOM implementation - */ -public class XalanDOMTestDocumentBuilderFactory - extends JAXPDOMTestDocumentBuilderFactory { - - /** - * Creates a JAXP implementation of DOMTestDocumentBuilderFactory. - * @param factory null for default JAXP provider. If not null, - * factory will be mutated in constructor and should be released - * by calling code upon return. - * @param settings array of settings, may be null. - */ - public XalanDOMTestDocumentBuilderFactory( - DocumentBuilderFactory baseFactory, - DocumentBuilderSetting[] settings) throws DOMTestIncompatibleException { - super(baseFactory, settings); - } - - protected DOMTestDocumentBuilderFactory createInstance(DocumentBuilderFactory - newFactory, - DocumentBuilderSetting[] mergedSettings) throws - DOMTestIncompatibleException { - return new XalanDOMTestDocumentBuilderFactory(newFactory, mergedSettings); - } - - /** - * Creates XPath evaluator - * @param doc DOM document, may not be null - */ - public Object createXPathEvaluator(Document doc) { - try { - Class xpathClass = Class.forName( - "org.apache.xpath.domapi.XPathEvaluatorImpl"); - Constructor constructor = xpathClass.getConstructor(new Class[] {Document.class}); - return constructor.newInstance(new Object[] {doc}); - } - catch (Exception ex) { - } - return doc; - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/XercesHTML2DocumentBuilderFactory.java b/libcore/dom/src/test/java/org/w3c/domts/XercesHTML2DocumentBuilderFactory.java deleted file mode 100644 index bf657237d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/XercesHTML2DocumentBuilderFactory.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (c) 2002 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; -import org.xml.sax.AttributeList; -import org.xml.sax.Attributes; -import org.xml.sax.DocumentHandler; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -/** - * This class implements the generic parser and configuation - * class for the HTML DOM L2 implementation in Xerces-J - */ -public class XercesHTML2DocumentBuilderFactory - extends DOMTestDocumentBuilderFactory { - - private SAXParserFactory factory; - private Constructor htmlBuilderConstructor; - private Method getHTMLDocumentMethod; - private DOMImplementation domImpl; - private static final Class[] NO_CLASSES = new Class[0]; - private static final Object[] NO_OBJECTS = new Object[0]; - - /** - * Creates a implementation of DOMTestDocumentBuilderFactory - * using org.apache.html.dom.HTMLBuilder - * @param settings array of settings, may be null. - */ - public XercesHTML2DocumentBuilderFactory(DocumentBuilderSetting[] settings) throws - DOMTestIncompatibleException { - super(settings); - - try { - ClassLoader classLoader = ClassLoader.getSystemClassLoader(); - Class htmlBuilderClass = - classLoader.loadClass("org.apache.html2.dom.HTMLBuilder"); - - htmlBuilderConstructor = - htmlBuilderClass.getConstructor(NO_CLASSES); - - getHTMLDocumentMethod = - htmlBuilderClass.getMethod("getHTMLDocument", NO_CLASSES); - - Class htmlDOMImpl = - classLoader.loadClass( - "org.apache.html2.dom.HTMLDOMImplementationImpl"); - Method method = - htmlDOMImpl.getMethod("getHTMLDOMImplementation", NO_CLASSES); - domImpl = (DOMImplementation) method.invoke(null, NO_OBJECTS); - - Class saxFactoryClass = - classLoader.loadClass( - "org.apache.xerces.jaxp.SAXParserFactoryImpl"); - factory = (SAXParserFactory) saxFactoryClass.newInstance(); - } - catch (InvocationTargetException ex) { - throw new DOMTestIncompatibleException( - ex.getTargetException(), - null); - } - catch (Exception ex) { - throw new DOMTestIncompatibleException(ex, null); - } - - // - // apply settings to selected document builder - // may throw exception if incompatible - if (settings != null) { - for (int i = 0; i < settings.length; i++) { - // settings[i].applySetting(factory); - } - } - try { - factory.newSAXParser(); - } - catch (ParserConfigurationException ex) { - throw new DOMTestIncompatibleException(ex, null); - } - catch (SAXException ex) { - throw new DOMTestIncompatibleException(ex, null); - } - } - - public DOMTestDocumentBuilderFactory newInstance(DocumentBuilderSetting[] - newSettings) throws DOMTestIncompatibleException { - if (newSettings == null) { - return this; - } - DocumentBuilderSetting[] mergedSettings = mergeSettings(newSettings); - return new XercesHTML2DocumentBuilderFactory(mergedSettings); - } - - private class HTMLHandler - extends DefaultHandler - implements AttributeList { - private final DocumentHandler htmlBuilder; - private final Method getHTMLDocumentMethod; - private Attributes currentAttributes; - - public HTMLHandler( - Constructor htmlBuilderConstructor, - Method getHTMLDocumentMethod) throws Exception { - htmlBuilder = - (DocumentHandler) htmlBuilderConstructor.newInstance( - new Object[0]); - this.getHTMLDocumentMethod = getHTMLDocumentMethod; - } - - public void startDocument() throws SAXException { - htmlBuilder.startDocument(); - } - - public void endDocument() throws SAXException { - htmlBuilder.endDocument(); - } - - public void startElement( - String uri, - String localName, - String qName, - Attributes attributes) throws SAXException { - currentAttributes = attributes; - htmlBuilder.startElement(qName, this); - } - - public void endElement(String uri, String localName, String qName) throws - SAXException { - htmlBuilder.endElement(qName); - } - - public void characters(char ch[], int start, int length) throws - SAXException { - htmlBuilder.characters(ch, start, length); - } - - public void ignorableWhitespace(char ch[], int start, int length) throws - SAXException { - htmlBuilder.ignorableWhitespace(ch, start, length); - } - - public void processingInstruction(String target, String data) throws - SAXException { - htmlBuilder.processingInstruction(target, data); - } - - public Document getHTMLDocument() throws Exception { - return (Document) getHTMLDocumentMethod.invoke( - htmlBuilder, - NO_OBJECTS); - } - - public int getLength() { - return currentAttributes.getLength(); - } - - public String getName(int i) { - return currentAttributes.getQName(i); - } - - public String getType(int i) { - return currentAttributes.getType(i); - } - - public String getValue(int i) { - return currentAttributes.getValue(i); - } - - public String getType(String name) { - return currentAttributes.getType(name); - } - - public String getValue(String name) { - return currentAttributes.getValue(name); - } - - } - - public Document load(java.net.URL url) throws DOMTestLoadException { - Document doc = null; - try { - SAXParser parser = factory.newSAXParser(); - HTMLHandler handler = - new HTMLHandler(htmlBuilderConstructor, getHTMLDocumentMethod); - parser.parse(url.toString(), handler); - doc = handler.getHTMLDocument(); - } - catch (Exception ex) { - throw new DOMTestLoadException(ex); - } - return doc; - } - - public DOMImplementation getDOMImplementation() { - return domImpl; - } - - public boolean hasFeature(String feature, String version) { - return domImpl.hasFeature(feature, version); - } - - public boolean isCoalescing() { - return false; - } - - public boolean isExpandEntityReferences() { - return false; - } - - public boolean isIgnoringElementContentWhitespace() { - return false; - } - - public boolean isNamespaceAware() { - return factory.isNamespaceAware(); - } - - public boolean isValidating() { - return factory.isValidating(); - } - - public static DocumentBuilderSetting[] getConfiguration1() { - return new DocumentBuilderSetting[] { - DocumentBuilderSetting.notCoalescing, - DocumentBuilderSetting.notExpandEntityReferences, - DocumentBuilderSetting.notIgnoringElementContentWhitespace, - DocumentBuilderSetting.notNamespaceAware, - DocumentBuilderSetting.notValidating}; - } - - public static DocumentBuilderSetting[] getConfiguration2() { - return new DocumentBuilderSetting[] { - DocumentBuilderSetting.notCoalescing, - DocumentBuilderSetting.expandEntityReferences, - DocumentBuilderSetting.ignoringElementContentWhitespace, - DocumentBuilderSetting.namespaceAware, - DocumentBuilderSetting.validating}; - - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/XercesHTMLDocumentBuilderFactory.java b/libcore/dom/src/test/java/org/w3c/domts/XercesHTMLDocumentBuilderFactory.java deleted file mode 100644 index b6b537bbc..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/XercesHTMLDocumentBuilderFactory.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (c) 2002 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; -import org.xml.sax.AttributeList; -import org.xml.sax.Attributes; -import org.xml.sax.DocumentHandler; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -/** - * This class implements the generic parser and configuation - * abstract class the HTML DOM implementation in Xerces-J - */ -public class XercesHTMLDocumentBuilderFactory - extends DOMTestDocumentBuilderFactory { - - private SAXParserFactory factory; - private Constructor htmlBuilderConstructor; - private Method getHTMLDocumentMethod; - private DOMImplementation domImpl; - private static final Class[] NO_CLASSES = new Class[0]; - private static final Object[] NO_OBJECTS = new Object[0]; - - /** - * Creates a implementation of DOMTestDocumentBuilderFactory - * using org.apache.html.dom.HTMLBuilder - * @param settings array of settings, may be null. - */ - public XercesHTMLDocumentBuilderFactory(DocumentBuilderSetting[] settings) throws - DOMTestIncompatibleException { - super(settings); - - try { - ClassLoader classLoader = ClassLoader.getSystemClassLoader(); - Class htmlBuilderClass = - classLoader.loadClass("org.apache.html.dom.HTMLBuilder"); - - htmlBuilderConstructor = - htmlBuilderClass.getConstructor(NO_CLASSES); - - getHTMLDocumentMethod = - htmlBuilderClass.getMethod("getHTMLDocument", NO_CLASSES); - - Class htmlDOMImpl = - classLoader.loadClass( - "org.apache.html.dom.HTMLDOMImplementationImpl"); - Method method = - htmlDOMImpl.getMethod("getHTMLDOMImplementation", NO_CLASSES); - domImpl = (DOMImplementation) method.invoke(null, NO_OBJECTS); - - Class saxFactoryClass = - classLoader.loadClass( - "org.apache.xerces.jaxp.SAXParserFactoryImpl"); - factory = (SAXParserFactory) saxFactoryClass.newInstance(); - } - catch (InvocationTargetException ex) { - throw new DOMTestIncompatibleException( - ex.getTargetException(), - null); - } - catch (Exception ex) { - throw new DOMTestIncompatibleException(ex, null); - } - - // - // apply settings to selected document builder - // may throw exception if incompatible - if (settings != null) { - for (int i = 0; i < settings.length; i++) { - // settings[i].applySetting(factory); - } - } - try { - factory.newSAXParser(); - } - catch (ParserConfigurationException ex) { - throw new DOMTestIncompatibleException(ex, null); - } - catch (SAXException ex) { - throw new DOMTestIncompatibleException(ex, null); - } - } - - public DOMTestDocumentBuilderFactory newInstance(DocumentBuilderSetting[] - newSettings) throws DOMTestIncompatibleException { - if (newSettings == null) { - return this; - } - DocumentBuilderSetting[] mergedSettings = mergeSettings(newSettings); - return new XercesHTMLDocumentBuilderFactory(mergedSettings); - } - - private class HTMLHandler - extends DefaultHandler - implements AttributeList { - private final DocumentHandler htmlBuilder; - private final Method getHTMLDocumentMethod; - private Attributes currentAttributes; - - public HTMLHandler( - Constructor htmlBuilderConstructor, - Method getHTMLDocumentMethod) throws Exception { - htmlBuilder = - (DocumentHandler) htmlBuilderConstructor.newInstance( - new Object[0]); - this.getHTMLDocumentMethod = getHTMLDocumentMethod; - } - - public void startDocument() throws SAXException { - htmlBuilder.startDocument(); - } - - public void endDocument() throws SAXException { - htmlBuilder.endDocument(); - } - - public void startElement( - String uri, - String localName, - String qName, - Attributes attributes) throws SAXException { - currentAttributes = attributes; - htmlBuilder.startElement(qName, this); - } - - public void endElement(String uri, String localName, String qName) throws - SAXException { - htmlBuilder.endElement(qName); - } - - public void characters(char ch[], int start, int length) throws - SAXException { - htmlBuilder.characters(ch, start, length); - } - - public void ignorableWhitespace(char ch[], int start, int length) throws - SAXException { - htmlBuilder.ignorableWhitespace(ch, start, length); - } - - public void processingInstruction(String target, String data) throws - SAXException { - htmlBuilder.processingInstruction(target, data); - } - - public Document getHTMLDocument() throws Exception { - return (Document) getHTMLDocumentMethod.invoke( - htmlBuilder, - NO_OBJECTS); - } - - public int getLength() { - return currentAttributes.getLength(); - } - - public String getName(int i) { - return currentAttributes.getQName(i); - } - - public String getType(int i) { - return currentAttributes.getType(i); - } - - public String getValue(int i) { - return currentAttributes.getValue(i); - } - - public String getType(String name) { - return currentAttributes.getType(name); - } - - public String getValue(String name) { - return currentAttributes.getValue(name); - } - - } - - public Document load(java.net.URL url) throws DOMTestLoadException { - Document doc = null; - try { - SAXParser parser = factory.newSAXParser(); - HTMLHandler handler = - new HTMLHandler(htmlBuilderConstructor, getHTMLDocumentMethod); - parser.parse(url.toString(), handler); - doc = handler.getHTMLDocument(); - } - catch (Exception ex) { - throw new DOMTestLoadException(ex); - } - return doc; - } - - public DOMImplementation getDOMImplementation() { - return domImpl; - } - - public boolean hasFeature(String feature, String version) { - return domImpl.hasFeature(feature, version); - } - - public boolean isCoalescing() { - return false; - } - - public boolean isExpandEntityReferences() { - return false; - } - - public boolean isIgnoringElementContentWhitespace() { - return false; - } - - public boolean isNamespaceAware() { - return factory.isNamespaceAware(); - } - - public boolean isValidating() { - return factory.isValidating(); - } - - public static DocumentBuilderSetting[] getConfiguration1() { - return new DocumentBuilderSetting[] { - DocumentBuilderSetting.notCoalescing, - DocumentBuilderSetting.notExpandEntityReferences, - DocumentBuilderSetting.notIgnoringElementContentWhitespace, - DocumentBuilderSetting.notNamespaceAware, - DocumentBuilderSetting.notValidating}; - } - - public static DocumentBuilderSetting[] getConfiguration2() { - return new DocumentBuilderSetting[] { - DocumentBuilderSetting.notCoalescing, - DocumentBuilderSetting.expandEntityReferences, - DocumentBuilderSetting.ignoringElementContentWhitespace, - DocumentBuilderSetting.namespaceAware, - DocumentBuilderSetting.validating}; - - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestBatik.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestBatik.java deleted file mode 100644 index 581b3441b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestBatik.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level1.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.BatikTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.DocumentBuilderSetting; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestBatik extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level1.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new BatikTestDocumentBuilderFactory(new DocumentBuilderSetting[0]); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestCrimson.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestCrimson.java deleted file mode 100644 index 4963b646d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestCrimson.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level1.core; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestCrimson extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level1.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory crimsonFactory = (DocumentBuilderFactory) - ClassLoader.getSystemClassLoader().loadClass("org.apache.crimson.jaxp.DocumentBuilderFactoryImpl").newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(crimsonFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestCrimsonAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestCrimsonAltConfig.java deleted file mode 100644 index 124d8cec4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestCrimsonAltConfig.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level1.core; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestCrimsonAltConfig extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level1.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory crimsonFactory = (DocumentBuilderFactory) - ClassLoader.getSystemClassLoader().loadClass("org.apache.crimson.jaxp.DocumentBuilderFactoryImpl").newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(crimsonFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDOM4J.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDOM4J.java deleted file mode 100644 index c368d44af..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDOM4J.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level1.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOM4JTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.DocumentBuilderSetting; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestDOM4J extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level1.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new DOM4JTestDocumentBuilderFactory(new DocumentBuilderSetting[0]); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDefaultLS.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDefaultLS.java deleted file mode 100644 index 6890a72db..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDefaultLS.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level1.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.LSDocumentBuilderFactory; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L1 Core tests using the - * Default LS parser in default configuration. - * - * @author Curt Arnold - * - */ -public class TestDefaultLS extends TestSuite { - - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level1.core.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new LSDocumentBuilderFactory( - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDefaultLSAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDefaultLSAltConfig.java deleted file mode 100644 index 1e8e2647d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDefaultLSAltConfig.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level1.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.LSDocumentBuilderFactory; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L1 Core tests using the - * Default LS parser in an alternate configuration. - * - * @author Curt Arnold - * - */ -public class TestDefaultLSAltConfig extends TestSuite { - - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level1.core.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new LSDocumentBuilderFactory( - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDefaultParser.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDefaultParser.java deleted file mode 100644 index fb43dfb05..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDefaultParser.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level1.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestDefaultParser extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level1.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(null, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDefaultParserAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDefaultParserAltConfig.java deleted file mode 100644 index 3c19b101d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestDefaultParserAltConfig.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level1.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestDefaultParserAltConfig extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level1.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(null, - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestGNUJAXP.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestGNUJAXP.java deleted file mode 100644 index dcebe885d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestGNUJAXP.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level1.core; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestGNUJAXP extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level1.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - - DocumentBuilderFactory gnujaxpFactory = (DocumentBuilderFactory) - ClassLoader.getSystemClassLoader(). - loadClass("gnu.xml.dom.JAXPFactory").newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(gnujaxpFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestGNUJAXPAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestGNUJAXPAltConfig.java deleted file mode 100644 index 5900db1af..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestGNUJAXPAltConfig.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level1.core; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestGNUJAXPAltConfig extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level1.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory gnujaxpFactory = (DocumentBuilderFactory) - ClassLoader.getSystemClassLoader(). - loadClass("gnu.xml.dom.JAXPFactory").newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(gnujaxpFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestJTidy.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestJTidy.java deleted file mode 100644 index 12ecf3f42..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestJTidy.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level1.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.DocumentBuilderSetting; -import org.w3c.domts.JTidyDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestJTidy extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level1.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new JTidyDocumentBuilderFactory(new DocumentBuilderSetting[0]); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestOracle.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestOracle.java deleted file mode 100644 index 96c9f3623..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestOracle.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level1.core; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestOracle extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level1.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory oracleFactory = (DocumentBuilderFactory) - ClassLoader.getSystemClassLoader(). - loadClass("oracle.xml.jaxp.JXDocumentBuilderFactory").newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(oracleFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestOracleAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestOracleAltConfig.java deleted file mode 100644 index 968abd0a6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestOracleAltConfig.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level1.core; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestOracleAltConfig extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level1.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory oracleFactory = (DocumentBuilderFactory) - ClassLoader.getSystemClassLoader(). - loadClass("oracle.xml.jaxp.JXDocumentBuilderFactory").newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(oracleFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestXerces.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestXerces.java deleted file mode 100644 index 268bad044..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestXerces.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level1.core; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestXerces extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level1.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory xercesFactory = (DocumentBuilderFactory) - ClassLoader.getSystemClassLoader().loadClass("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl").newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(xercesFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestXercesAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestXercesAltConfig.java deleted file mode 100644 index 74b3c4c43..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/TestXercesAltConfig.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level1.core; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestXercesAltConfig extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level1.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory xercesFactory = (DocumentBuilderFactory) - ClassLoader.getSystemClassLoader().loadClass("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl").newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(xercesFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/alltests.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/alltests.java deleted file mode 100644 index 2c907f228..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/alltests.java +++ /dev/null @@ -1,595 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.DOMTestSink; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - -/** - * -* @author DOM Test Suite Project -*/ -public class alltests extends DOMTestSuite { - - /** - * Constructor - * @param factory document factory, may not be null - * @throws Exception Thrown if test is not compatible with settings - */ - public alltests(DOMTestDocumentBuilderFactory factory) throws Exception { - super(factory); - - setFactory(factory); - } - - /** - * Build test suite by adding each test to the test sink - * @param sink test sink - */ - public void build(DOMTestSink sink) { - sink.addTest(attrcreatedocumentfragment.class); - sink.addTest(attrcreatetextnode.class); - sink.addTest(attrcreatetextnode2.class); -// sink.addTest(attrdefaultvalue.class); //javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(attreffectivevalue.class); -// sink.addTest(attrentityreplacement.class); - sink.addTest(attrname.class); - sink.addTest(attrnextsiblingnull.class); -// sink.addTest(attrnotspecifiedvalue.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(attrparentnodenull.class); - sink.addTest(attrprevioussiblingnull.class); -// sink.addTest(attrsetvaluenomodificationallowederr.class); -// sink.addTest(attrsetvaluenomodificationallowederrEE.class); - sink.addTest(attrspecifiedvalue.class); - sink.addTest(attrspecifiedvaluechanged.class); -// sink.addTest(attrspecifiedvalueremove.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(cdatasectiongetdata.class); -// sink.addTest(cdatasectionnormalize.class); - sink.addTest(characterdataappenddata.class); - sink.addTest(characterdataappenddatagetdata.class); -// sink.addTest(characterdataappenddatanomodificationallowederr.class); -// sink.addTest(characterdataappenddatanomodificationallowederrEE.class); - sink.addTest(characterdatadeletedatabegining.class); - sink.addTest(characterdatadeletedataend.class); - sink.addTest(characterdatadeletedataexceedslength.class); - sink.addTest(characterdatadeletedatagetlengthanddata.class); - sink.addTest(characterdatadeletedatamiddle.class); -// sink.addTest(characterdatadeletedatanomodificationallowederr.class); -// sink.addTest(characterdatadeletedatanomodificationallowederrEE.class); - sink.addTest(characterdatagetdata.class); - sink.addTest(characterdatagetlength.class); -// sink.addTest(characterdataindexsizeerrdeletedatacountnegative.class); -// sink.addTest(characterdataindexsizeerrdeletedataoffsetgreater.class); -// sink.addTest(characterdataindexsizeerrdeletedataoffsetnegative.class); -// sink.addTest(characterdataindexsizeerrinsertdataoffsetgreater.class); -// sink.addTest(characterdataindexsizeerrinsertdataoffsetnegative.class); -// sink.addTest(characterdataindexsizeerrreplacedatacountnegative.class); -// sink.addTest(characterdataindexsizeerrreplacedataoffsetgreater.class); -// sink.addTest(characterdataindexsizeerrreplacedataoffsetnegative.class); -// sink.addTest(characterdataindexsizeerrsubstringcountnegative.class); -// sink.addTest(characterdataindexsizeerrsubstringnegativeoffset.class); -// sink.addTest(characterdataindexsizeerrsubstringoffsetgreater.class); - sink.addTest(characterdatainsertdatabeginning.class); - sink.addTest(characterdatainsertdataend.class); - sink.addTest(characterdatainsertdatamiddle.class); -// sink.addTest(characterdatainsertdatanomodificationallowederr.class); -// sink.addTest(characterdatainsertdatanomodificationallowederrEE.class); - sink.addTest(characterdatareplacedatabegining.class); - sink.addTest(characterdatareplacedataend.class); - sink.addTest(characterdatareplacedataexceedslengthofarg.class); - sink.addTest(characterdatareplacedataexceedslengthofdata.class); - sink.addTest(characterdatareplacedatamiddle.class); -// sink.addTest(characterdatareplacedatanomodificationallowederr.class); -// sink.addTest(characterdatareplacedatanomodificationallowederrEE.class); -// sink.addTest(characterdatasetdatanomodificationallowederr.class); -// sink.addTest(characterdatasetdatanomodificationallowederrEE.class); -// sink.addTest(characterdatasetnodevalue.class); -// sink.addTest(characterdatasubstringexceedsvalue.class); - sink.addTest(characterdatasubstringvalue.class); - sink.addTest(commentgetcomment.class); -// sink.addTest(documentcreateattribute.class); - sink.addTest(documentcreatecdatasection.class); - sink.addTest(documentcreatecomment.class); - sink.addTest(documentcreatedocumentfragment.class); - sink.addTest(documentcreateelement.class); - sink.addTest(documentcreateelementcasesensitive.class); -// sink.addTest(documentcreateelementdefaultattr.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(documentcreateentityreference.class); -// sink.addTest(documentcreateentityreferenceknown.class); - sink.addTest(documentcreateprocessinginstruction.class); - sink.addTest(documentcreatetextnode.class); - sink.addTest(documentgetdoctype.class); - sink.addTest(documentgetdoctypenodtd.class); - sink.addTest(documentgetelementsbytagnamelength.class); -// sink.addTest(documentgetelementsbytagnametotallength.class); - sink.addTest(documentgetelementsbytagnamevalue.class); - sink.addTest(documentgetimplementation.class); - sink.addTest(documentgetrootnode.class); - sink.addTest(documentinvalidcharacterexceptioncreateattribute.class); - sink.addTest(documentinvalidcharacterexceptioncreateelement.class); -// sink.addTest(documentinvalidcharacterexceptioncreateentref.class); -// sink.addTest(documentinvalidcharacterexceptioncreateentref1.class); -// sink.addTest(documentinvalidcharacterexceptioncreatepi.class); -// sink.addTest(documentinvalidcharacterexceptioncreatepi1.class); - sink.addTest(documenttypegetdoctype.class); -// sink.addTest(documenttypegetentities.class); -// sink.addTest(documenttypegetentitieslength.class); -// sink.addTest(documenttypegetentitiestype.class); -// sink.addTest(documenttypegetnotations.class); -// sink.addTest(documenttypegetnotationstype.class); - sink.addTest(domimplementationfeaturenoversion.class); - sink.addTest(domimplementationfeaturenull.class); - sink.addTest(domimplementationfeaturexml.class); - sink.addTest(elementaddnewattribute.class); - sink.addTest(elementassociatedattribute.class); - sink.addTest(elementchangeattributevalue.class); -// sink.addTest(elementcreatenewattribute.class); - sink.addTest(elementgetattributenode.class); - sink.addTest(elementgetattributenodenull.class); -// sink.addTest(elementgetelementempty.class); - sink.addTest(elementgetelementsbytagname.class); - sink.addTest(elementgetelementsbytagnameaccessnodelist.class); - sink.addTest(elementgetelementsbytagnamenomatch.class); -// sink.addTest(elementgetelementsbytagnamespecialvalue.class); - sink.addTest(elementgettagname.class); - sink.addTest(elementinuseattributeerr.class); - sink.addTest(elementinvalidcharacterexception.class); - sink.addTest(elementnormalize.class); - sink.addTest(elementnotfounderr.class); -// sink.addTest(elementremoveattribute.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(elementremoveattributeaftercreate.class); - sink.addTest(elementremoveattributenode.class); -// sink.addTest(elementremoveattributenodenomodificationallowederr.class); -// sink.addTest(elementremoveattributenodenomodificationallowederrEE.class); -// sink.addTest(elementremoveattributenomodificationallowederr.class); -// sink.addTest(elementremoveattributenomodificationallowederrEE.class); -// sink.addTest(elementremoveattributerestoredefaultvalue.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available -// sink.addTest(elementreplaceattributewithself.class); -// sink.addTest(elementreplaceexistingattribute.class); - sink.addTest(elementreplaceexistingattributegevalue.class); -// sink.addTest(elementretrieveallattributes.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(elementretrieveattrvalue.class); - sink.addTest(elementretrievetagname.class); -// sink.addTest(elementsetattributenodenomodificationallowederr.class); -// sink.addTest(elementsetattributenodenomodificationallowederrEE.class); - sink.addTest(elementsetattributenodenull.class); -// sink.addTest(elementsetattributenomodificationallowederr.class); -// sink.addTest(elementsetattributenomodificationallowederrEE.class); - sink.addTest(elementwrongdocumenterr.class); -// sink.addTest(entitygetentityname.class); -// sink.addTest(entitygetpublicid.class); -// sink.addTest(entitygetpublicidnull.class); - sink.addTest(namednodemapchildnoderange.class); - sink.addTest(namednodemapgetnameditem.class); - sink.addTest(namednodemapinuseattributeerr.class); - sink.addTest(namednodemapnotfounderr.class); - sink.addTest(namednodemapnumberofnodes.class); -// sink.addTest(namednodemapremovenameditem.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available -// sink.addTest(namednodemapremovenameditemgetvalue.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(namednodemapremovenameditemreturnnodevalue.class); - sink.addTest(namednodemapreturnattrnode.class); - sink.addTest(namednodemapreturnfirstitem.class); - sink.addTest(namednodemapreturnlastitem.class); - sink.addTest(namednodemapreturnnull.class); - sink.addTest(namednodemapsetnameditem.class); - sink.addTest(namednodemapsetnameditemreturnvalue.class); -// sink.addTest(namednodemapsetnameditemthatexists.class); - sink.addTest(namednodemapsetnameditemwithnewvalue.class); - sink.addTest(namednodemapwrongdocumenterr.class); - sink.addTest(nodeappendchild.class); -// sink.addTest(nodeappendchildchildexists.class); -// sink.addTest(nodeappendchilddocfragment.class); - sink.addTest(nodeappendchildgetnodename.class); -// sink.addTest(nodeappendchildinvalidnodetype.class); - sink.addTest(nodeappendchildnewchilddiffdocument.class); - sink.addTest(nodeappendchildnodeancestor.class); -// sink.addTest(nodeappendchildnomodificationallowederr.class); -// sink.addTest(nodeappendchildnomodificationallowederrEE.class); - sink.addTest(nodeattributenodeattribute.class); - sink.addTest(nodeattributenodename.class); - sink.addTest(nodeattributenodetype.class); - sink.addTest(nodeattributenodevalue.class); - sink.addTest(nodecdatasectionnodeattribute.class); - sink.addTest(nodecdatasectionnodename.class); - sink.addTest(nodecdatasectionnodetype.class); - sink.addTest(nodecdatasectionnodevalue.class); - sink.addTest(nodechildnodes.class); -// sink.addTest(nodechildnodesappendchild.class); - sink.addTest(nodechildnodesempty.class); -// sink.addTest(nodecloneattributescopied.class); -// sink.addTest(nodeclonefalsenocopytext.class); -// sink.addTest(nodeclonegetparentnull.class); -// sink.addTest(nodeclonenodefalse.class); -// sink.addTest(nodeclonenodetrue.class); -// sink.addTest(nodeclonetruecopytext.class); - sink.addTest(nodecommentnodeattributes.class); - sink.addTest(nodecommentnodename.class); - sink.addTest(nodecommentnodetype.class); - sink.addTest(nodecommentnodevalue.class); - sink.addTest(nodedocumentfragmentnodename.class); - sink.addTest(nodedocumentfragmentnodetype.class); - sink.addTest(nodedocumentfragmentnodevalue.class); - sink.addTest(nodedocumentnodeattribute.class); - sink.addTest(nodedocumentnodename.class); - sink.addTest(nodedocumentnodetype.class); - sink.addTest(nodedocumentnodevalue.class); - sink.addTest(nodedocumenttypenodename.class); - sink.addTest(nodedocumenttypenodetype.class); - sink.addTest(nodedocumenttypenodevalue.class); - sink.addTest(nodeelementnodeattributes.class); - sink.addTest(nodeelementnodename.class); - sink.addTest(nodeelementnodetype.class); - sink.addTest(nodeelementnodevalue.class); -// sink.addTest(nodeentitynodeattributes.class); -// sink.addTest(nodeentitynodename.class); -// sink.addTest(nodeentitynodetype.class); -// sink.addTest(nodeentitynodevalue.class); -// sink.addTest(nodeentitysetnodevalue.class); - sink.addTest(nodeentityreferencenodeattributes.class); - sink.addTest(nodeentityreferencenodename.class); - sink.addTest(nodeentityreferencenodetype.class); - sink.addTest(nodeentityreferencenodevalue.class); - sink.addTest(nodegetfirstchild.class); - sink.addTest(nodegetfirstchildnull.class); - sink.addTest(nodegetlastchild.class); - sink.addTest(nodegetlastchildnull.class); - sink.addTest(nodegetnextsibling.class); - sink.addTest(nodegetnextsiblingnull.class); - sink.addTest(nodegetownerdocument.class); - sink.addTest(nodegetownerdocumentnull.class); - sink.addTest(nodegetprevioussibling.class); - sink.addTest(nodegetprevioussiblingnull.class); - sink.addTest(nodehaschildnodes.class); - sink.addTest(nodehaschildnodesfalse.class); -// sink.addTest(nodeinsertbefore.class); -// sink.addTest(nodeinsertbeforedocfragment.class); -// sink.addTest(nodeinsertbeforeinvalidnodetype.class); - sink.addTest(nodeinsertbeforenewchilddiffdocument.class); - sink.addTest(nodeinsertbeforenewchildexists.class); - sink.addTest(nodeinsertbeforenodeancestor.class); - sink.addTest(nodeinsertbeforenodename.class); -// sink.addTest(nodeinsertbeforenomodificationallowederr.class); -// sink.addTest(nodeinsertbeforenomodificationallowederrEE.class); -// sink.addTest(nodeinsertbeforerefchildnonexistent.class); -// sink.addTest(nodeinsertbeforerefchildnull.class); - sink.addTest(nodelistindexequalzero.class); - sink.addTest(nodelistindexgetlength.class); - sink.addTest(nodelistindexgetlengthofemptylist.class); - sink.addTest(nodelistindexnotzero.class); - sink.addTest(nodelistreturnfirstitem.class); - sink.addTest(nodelistreturnlastitem.class); - sink.addTest(nodelisttraverselist.class); -// sink.addTest(nodenotationnodeattributes.class); -// sink.addTest(nodenotationnodename.class); -// sink.addTest(nodenotationnodetype.class); -// sink.addTest(nodenotationnodevalue.class); - sink.addTest(nodeparentnode.class); - sink.addTest(nodeparentnodenull.class); - sink.addTest(nodeprocessinginstructionnodeattributes.class); - sink.addTest(nodeprocessinginstructionnodename.class); - sink.addTest(nodeprocessinginstructionnodetype.class); - sink.addTest(nodeprocessinginstructionnodevalue.class); -// sink.addTest(nodeprocessinginstructionsetnodevalue.class); - sink.addTest(noderemovechild.class); - sink.addTest(noderemovechildgetnodename.class); -// sink.addTest(noderemovechildnode.class); -// sink.addTest(noderemovechildnomodificationallowederr.class); -// sink.addTest(noderemovechildnomodificationallowederrEE.class); -// sink.addTest(noderemovechildoldchildnonexistent.class); -// sink.addTest(nodereplacechild.class); -// sink.addTest(nodereplacechildinvalidnodetype.class); - sink.addTest(nodereplacechildnewchilddiffdocument.class); -// sink.addTest(nodereplacechildnewchildexists.class); - sink.addTest(nodereplacechildnodeancestor.class); - sink.addTest(nodereplacechildnodename.class); -// sink.addTest(nodereplacechildnomodificationallowederr.class); -// sink.addTest(nodereplacechildnomodificationallowederrEE.class); -// sink.addTest(nodereplacechildoldchildnonexistent.class); -// sink.addTest(nodesetnodevaluenomodificationallowederr.class); -// sink.addTest(nodesetnodevaluenomodificationallowederrEE.class); - sink.addTest(nodetextnodeattribute.class); - sink.addTest(nodetextnodename.class); - sink.addTest(nodetextnodetype.class); - sink.addTest(nodetextnodevalue.class); -// sink.addTest(notationgetnotationname.class); -// sink.addTest(notationgetpublicid.class); -// sink.addTest(notationgetpublicidnull.class); -// sink.addTest(notationgetsystemid.class); -// sink.addTest(notationgetsystemidnull.class); - sink.addTest(processinginstructiongetdata.class); - sink.addTest(processinginstructiongettarget.class); -// sink.addTest(processinginstructionsetdatanomodificationallowederr.class); -// sink.addTest(processinginstructionsetdatanomodificationallowederrEE.class); -// sink.addTest(textindexsizeerrnegativeoffset.class); -// sink.addTest(textindexsizeerroffsetoutofbounds.class); -// sink.addTest(textparseintolistofelements.class); - sink.addTest(textsplittextfour.class); -// sink.addTest(textsplittextnomodificationallowederr.class); -// sink.addTest(textsplittextnomodificationallowederrEE.class); - sink.addTest(textsplittextone.class); - sink.addTest(textsplittextthree.class); -// sink.addTest(textsplittexttwo.class); - sink.addTest(textwithnomarkup.class); - sink.addTest(nodevalue01.class); -// sink.addTest(nodevalue02.class); - sink.addTest(nodevalue03.class); - sink.addTest(nodevalue04.class); - sink.addTest(nodevalue05.class); - sink.addTest(nodevalue06.class); -// sink.addTest(nodevalue07.class); -// sink.addTest(nodevalue08.class); -// sink.addTest(nodevalue09.class); - sink.addTest(hc_attrcreatedocumentfragment.class); - sink.addTest(hc_attrcreatetextnode.class); - sink.addTest(hc_attrcreatetextnode2.class); - sink.addTest(hc_attreffectivevalue.class); - sink.addTest(hc_attrname.class); - sink.addTest(hc_attrnextsiblingnull.class); - sink.addTest(hc_attrparentnodenull.class); - sink.addTest(hc_attrprevioussiblingnull.class); - sink.addTest(hc_attrspecifiedvalue.class); - sink.addTest(hc_attrspecifiedvaluechanged.class); - sink.addTest(hc_characterdataappenddata.class); - sink.addTest(hc_characterdataappenddatagetdata.class); - sink.addTest(hc_characterdatadeletedatabegining.class); - sink.addTest(hc_characterdatadeletedataend.class); - sink.addTest(hc_characterdatadeletedataexceedslength.class); - sink.addTest(hc_characterdatadeletedatagetlengthanddata.class); - sink.addTest(hc_characterdatadeletedatamiddle.class); - sink.addTest(hc_characterdatagetdata.class); - sink.addTest(hc_characterdatagetlength.class); -// sink.addTest(hc_characterdataindexsizeerrdeletedatacountnegative.class); -// sink.addTest(hc_characterdataindexsizeerrdeletedataoffsetgreater.class); -// sink.addTest(hc_characterdataindexsizeerrdeletedataoffsetnegative.class); -// sink.addTest(hc_characterdataindexsizeerrinsertdataoffsetgreater.class); -// sink.addTest(hc_characterdataindexsizeerrinsertdataoffsetnegative.class); -// sink.addTest(hc_characterdataindexsizeerrreplacedatacountnegative.class); -// sink.addTest(hc_characterdataindexsizeerrreplacedataoffsetgreater.class); -// sink.addTest(hc_characterdataindexsizeerrreplacedataoffsetnegative.class); -// sink.addTest(hc_characterdataindexsizeerrsubstringcountnegative.class); -// sink.addTest(hc_characterdataindexsizeerrsubstringnegativeoffset.class); -// sink.addTest(hc_characterdataindexsizeerrsubstringoffsetgreater.class); - sink.addTest(hc_characterdatainsertdatabeginning.class); - sink.addTest(hc_characterdatainsertdataend.class); - sink.addTest(hc_characterdatainsertdatamiddle.class); - sink.addTest(hc_characterdatareplacedatabegining.class); - sink.addTest(hc_characterdatareplacedataend.class); - sink.addTest(hc_characterdatareplacedataexceedslengthofarg.class); - sink.addTest(hc_characterdatareplacedataexceedslengthofdata.class); - sink.addTest(hc_characterdatareplacedatamiddle.class); -// sink.addTest(hc_characterdatasetnodevalue.class); -// sink.addTest(hc_characterdatasubstringexceedsvalue.class); - sink.addTest(hc_characterdatasubstringvalue.class); - sink.addTest(hc_commentgetcomment.class); -// sink.addTest(hc_documentcreateattribute.class); - sink.addTest(hc_documentcreatecomment.class); - sink.addTest(hc_documentcreatedocumentfragment.class); - sink.addTest(hc_documentcreateelement.class); - sink.addTest(hc_documentcreateelementcasesensitive.class); - sink.addTest(hc_documentcreatetextnode.class); - sink.addTest(hc_documentgetdoctype.class); - sink.addTest(hc_documentgetelementsbytagnamelength.class); - sink.addTest(hc_documentgetelementsbytagnametotallength.class); - sink.addTest(hc_documentgetelementsbytagnamevalue.class); - sink.addTest(hc_documentgetimplementation.class); - sink.addTest(hc_documentgetrootnode.class); - sink.addTest(hc_documentinvalidcharacterexceptioncreateattribute.class); - sink.addTest(hc_documentinvalidcharacterexceptioncreateattribute1.class); - sink.addTest(hc_documentinvalidcharacterexceptioncreateelement.class); - sink.addTest(hc_documentinvalidcharacterexceptioncreateelement1.class); - sink.addTest(hc_domimplementationfeaturenoversion.class); - sink.addTest(hc_domimplementationfeaturenull.class); - sink.addTest(hc_domimplementationfeaturexml.class); - sink.addTest(hc_elementaddnewattribute.class); - sink.addTest(hc_elementassociatedattribute.class); - sink.addTest(hc_elementchangeattributevalue.class); -// sink.addTest(hc_elementcreatenewattribute.class); - sink.addTest(hc_elementgetattributenode.class); - sink.addTest(hc_elementgetattributenodenull.class); -// sink.addTest(hc_elementgetelementempty.class); - sink.addTest(hc_elementgetelementsbytagname.class); - sink.addTest(hc_elementgetelementsbytagnameaccessnodelist.class); - sink.addTest(hc_elementgetelementsbytagnamenomatch.class); -// sink.addTest(hc_elementgetelementsbytagnamespecialvalue.class); - sink.addTest(hc_elementgettagname.class); - sink.addTest(hc_elementinuseattributeerr.class); - sink.addTest(hc_elementinvalidcharacterexception.class); - sink.addTest(hc_elementinvalidcharacterexception1.class); - sink.addTest(hc_elementnormalize.class); -// sink.addTest(hc_elementnormalize2.class); - sink.addTest(hc_elementnotfounderr.class); - sink.addTest(hc_elementremoveattribute.class); - sink.addTest(hc_elementremoveattributeaftercreate.class); - sink.addTest(hc_elementremoveattributenode.class); -// sink.addTest(hc_elementreplaceattributewithself.class); -// sink.addTest(hc_elementreplaceexistingattribute.class); - sink.addTest(hc_elementreplaceexistingattributegevalue.class); -// sink.addTest(hc_elementretrieveallattributes.class); - sink.addTest(hc_elementretrieveattrvalue.class); - sink.addTest(hc_elementretrievetagname.class); - sink.addTest(hc_elementsetattributenodenull.class); - sink.addTest(hc_elementwrongdocumenterr.class); -// sink.addTest(hc_entitiesremovenameditem1.class); -// sink.addTest(hc_entitiessetnameditem1.class); -// sink.addTest(hc_namednodemapchildnoderange.class); - sink.addTest(hc_namednodemapgetnameditem.class); - sink.addTest(hc_namednodemapinuseattributeerr.class); - sink.addTest(hc_namednodemapnotfounderr.class); -// sink.addTest(hc_namednodemapnumberofnodes.class); - sink.addTest(hc_namednodemapremovenameditem.class); - sink.addTest(hc_namednodemapreturnattrnode.class); -// sink.addTest(hc_namednodemapreturnfirstitem.class); -// sink.addTest(hc_namednodemapreturnlastitem.class); - sink.addTest(hc_namednodemapreturnnull.class); - sink.addTest(hc_namednodemapsetnameditem.class); - sink.addTest(hc_namednodemapsetnameditemreturnvalue.class); -// sink.addTest(hc_namednodemapsetnameditemthatexists.class); - sink.addTest(hc_namednodemapsetnameditemwithnewvalue.class); - sink.addTest(hc_namednodemapwrongdocumenterr.class); - sink.addTest(hc_nodeappendchild.class); -// sink.addTest(hc_nodeappendchildchildexists.class); -// sink.addTest(hc_nodeappendchilddocfragment.class); - sink.addTest(hc_nodeappendchildgetnodename.class); -// sink.addTest(hc_nodeappendchildinvalidnodetype.class); - sink.addTest(hc_nodeappendchildnewchilddiffdocument.class); - sink.addTest(hc_nodeappendchildnodeancestor.class); - sink.addTest(hc_nodeattributenodeattribute.class); - sink.addTest(hc_nodeattributenodename.class); - sink.addTest(hc_nodeattributenodetype.class); - sink.addTest(hc_nodeattributenodevalue.class); - sink.addTest(hc_nodechildnodes.class); -// sink.addTest(hc_nodechildnodesappendchild.class); - sink.addTest(hc_nodechildnodesempty.class); -// sink.addTest(hc_nodecloneattributescopied.class); -// sink.addTest(hc_nodeclonefalsenocopytext.class); -// sink.addTest(hc_nodeclonegetparentnull.class); -// sink.addTest(hc_nodeclonenodefalse.class); -// sink.addTest(hc_nodeclonenodetrue.class); -// sink.addTest(hc_nodeclonetruecopytext.class); - sink.addTest(hc_nodecommentnodeattributes.class); - sink.addTest(hc_nodecommentnodename.class); - sink.addTest(hc_nodecommentnodetype.class); - sink.addTest(hc_nodecommentnodevalue.class); - sink.addTest(hc_nodedocumentfragmentnodename.class); - sink.addTest(hc_nodedocumentfragmentnodetype.class); - sink.addTest(hc_nodedocumentfragmentnodevalue.class); - sink.addTest(hc_nodedocumentnodeattribute.class); - sink.addTest(hc_nodedocumentnodename.class); - sink.addTest(hc_nodedocumentnodetype.class); - sink.addTest(hc_nodedocumentnodevalue.class); -// sink.addTest(hc_nodeelementnodeattributes.class); - sink.addTest(hc_nodeelementnodename.class); - sink.addTest(hc_nodeelementnodetype.class); - sink.addTest(hc_nodeelementnodevalue.class); - sink.addTest(hc_nodegetfirstchild.class); - sink.addTest(hc_nodegetfirstchildnull.class); - sink.addTest(hc_nodegetlastchild.class); - sink.addTest(hc_nodegetlastchildnull.class); - sink.addTest(hc_nodegetnextsibling.class); - sink.addTest(hc_nodegetnextsiblingnull.class); - sink.addTest(hc_nodegetownerdocument.class); - sink.addTest(hc_nodegetownerdocumentnull.class); - sink.addTest(hc_nodegetprevioussibling.class); - sink.addTest(hc_nodegetprevioussiblingnull.class); - sink.addTest(hc_nodehaschildnodes.class); - sink.addTest(hc_nodehaschildnodesfalse.class); -// sink.addTest(hc_nodeinsertbefore.class); -// sink.addTest(hc_nodeinsertbeforedocfragment.class); -// sink.addTest(hc_nodeinsertbeforeinvalidnodetype.class); - sink.addTest(hc_nodeinsertbeforenewchilddiffdocument.class); -// sink.addTest(hc_nodeinsertbeforenewchildexists.class); - sink.addTest(hc_nodeinsertbeforenodeancestor.class); - sink.addTest(hc_nodeinsertbeforenodename.class); -// sink.addTest(hc_nodeinsertbeforerefchildnonexistent.class); -// sink.addTest(hc_nodeinsertbeforerefchildnull.class); - sink.addTest(hc_nodelistindexequalzero.class); - sink.addTest(hc_nodelistindexgetlength.class); - sink.addTest(hc_nodelistindexgetlengthofemptylist.class); - sink.addTest(hc_nodelistindexnotzero.class); - sink.addTest(hc_nodelistreturnfirstitem.class); - sink.addTest(hc_nodelistreturnlastitem.class); - sink.addTest(hc_nodelisttraverselist.class); - sink.addTest(hc_nodeparentnode.class); - sink.addTest(hc_nodeparentnodenull.class); - sink.addTest(hc_noderemovechild.class); - sink.addTest(hc_noderemovechildgetnodename.class); -// sink.addTest(hc_noderemovechildnode.class); -// sink.addTest(hc_noderemovechildoldchildnonexistent.class); -// sink.addTest(hc_nodereplacechild.class); -// sink.addTest(hc_nodereplacechildinvalidnodetype.class); - sink.addTest(hc_nodereplacechildnewchilddiffdocument.class); -// sink.addTest(hc_nodereplacechildnewchildexists.class); - sink.addTest(hc_nodereplacechildnodeancestor.class); - sink.addTest(hc_nodereplacechildnodename.class); -// sink.addTest(hc_nodereplacechildoldchildnonexistent.class); - sink.addTest(hc_nodetextnodeattribute.class); - sink.addTest(hc_nodetextnodename.class); - sink.addTest(hc_nodetextnodetype.class); - sink.addTest(hc_nodetextnodevalue.class); - sink.addTest(hc_nodevalue01.class); -// sink.addTest(hc_nodevalue02.class); - sink.addTest(hc_nodevalue03.class); - sink.addTest(hc_nodevalue04.class); - sink.addTest(hc_nodevalue05.class); - sink.addTest(hc_nodevalue06.class); -// sink.addTest(hc_nodevalue07.class); -// sink.addTest(hc_nodevalue08.class); -// sink.addTest(hc_notationsremovenameditem1.class); -// sink.addTest(hc_notationssetnameditem1.class); -// sink.addTest(hc_textindexsizeerrnegativeoffset.class); -// sink.addTest(hc_textindexsizeerroffsetoutofbounds.class); -// sink.addTest(hc_textparseintolistofelements.class); - sink.addTest(hc_textsplittextfour.class); - sink.addTest(hc_textsplittextone.class); - sink.addTest(hc_textsplittextthree.class); -// sink.addTest(hc_textsplittexttwo.class); - sink.addTest(hc_textwithnomarkup.class); -// sink.addTest(hc_attrappendchild1.class); - sink.addTest(hc_attrappendchild2.class); -// sink.addTest(hc_attrappendchild3.class); - sink.addTest(hc_attrappendchild4.class); -// sink.addTest(hc_attrappendchild5.class); -// sink.addTest(hc_attrappendchild6.class); -// sink.addTest(hc_attrchildnodes1.class); -// sink.addTest(hc_attrchildnodes2.class); -// sink.addTest(hc_attrclonenode1.class); -// sink.addTest(hc_attrfirstchild.class); -// sink.addTest(hc_attrgetvalue1.class); -// sink.addTest(hc_attrgetvalue2.class); -// sink.addTest(hc_attrhaschildnodes.class); -// sink.addTest(hc_attrinsertbefore1.class); -// sink.addTest(hc_attrinsertbefore2.class); -// sink.addTest(hc_attrinsertbefore3.class); -// sink.addTest(hc_attrinsertbefore4.class); - sink.addTest(hc_attrinsertbefore5.class); -// sink.addTest(hc_attrinsertbefore6.class); - sink.addTest(hc_attrinsertbefore7.class); -// sink.addTest(hc_attrlastchild.class); -// sink.addTest(hc_attrnormalize.class); -// sink.addTest(hc_attrremovechild1.class); -// sink.addTest(hc_attrremovechild2.class); -// sink.addTest(hc_attrreplacechild1.class); -// sink.addTest(hc_attrreplacechild2.class); -// sink.addTest(hc_attrsetvalue1.class); -// sink.addTest(hc_attrsetvalue2.class); -// sink.addTest(attrremovechild1.class); -// sink.addTest(attrreplacechild1.class); - - } - /** - * Gets URI that identifies the test suite - * @return uri identifier of test suite - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/alltests"; - } - - /** - * Runs individual test - * @param args command line arguments - */ - public static void main(String[] args) { - DOMTestCase.doMain(alltests.class, args); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrcreatedocumentfragment.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrcreatedocumentfragment.java deleted file mode 100644 index e1c6b1e47..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrcreatedocumentfragment.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Attr nodes may be associated with Element nodes contained within a DocumentFragment. - * Create a new DocumentFragment and add a newly created Element node(with one attribute). - * Once the element is added, its attribute should be available as an attribute associated - * with an Element within a DocumentFragment. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-35CB04B5 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3 -*/ -public final class attrcreatedocumentfragment extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrcreatedocumentfragment(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentFragment docFragment; - Element newOne; - Node domesticNode; - NamedNodeMap domesticAttr; - Attr attrs; - String attrName; - Node appendedChild; - doc = (Document) load("staff", true); - docFragment = doc.createDocumentFragment(); - newOne = doc.createElement("newElement"); - newOne.setAttribute("newdomestic", "Yes"); - appendedChild = docFragment.appendChild(newOne); - domesticNode = docFragment.getFirstChild(); - domesticAttr = domesticNode.getAttributes(); - attrs = (Attr) domesticAttr.item(0); - attrName = attrs.getName(); - assertEquals("attrCreateDocumentFragmentAssert", "newdomestic", attrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrcreatedocumentfragment"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrcreatedocumentfragment.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrcreatetextnode.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrcreatetextnode.java deleted file mode 100644 index 1ff80ffd8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrcreatetextnode.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setValue()" method for an attribute creates a - * Text node with the unparsed content of the string. - * Retrieve the attribute named "street" from the last - * child of of the fourth employee and assign the "Y&ent1;" - * string to its value attribute. This value is not yet - * parsed and therefore should still be the same upon - * retrieval. This test uses the "getNamedItem(name)" method - * from the NamedNodeMap interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Apr/0057.html -*/ -public final class attrcreatetextnode extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrcreatetextnode(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr streetAttr; - String value; - doc = (Document) load("staff", true); - addressList = doc.getElementsByTagName("address"); - testNode = addressList.item(3); - attributes = testNode.getAttributes(); - streetAttr = (Attr) attributes.getNamedItem("street"); - streetAttr.setValue("Y&ent1;"); - value = streetAttr.getValue(); - assertEquals("value", "Y&ent1;", value); - value = streetAttr.getNodeValue(); - assertEquals("nodeValue", "Y&ent1;", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrcreatetextnode"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrcreatetextnode.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrcreatetextnode2.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrcreatetextnode2.java deleted file mode 100644 index 2733c4313..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrcreatetextnode2.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setNodeValue()" method for an attribute creates a - * Text node with the unparsed content of the string. - * Retrieve the attribute named "street" from the last - * child of of the fourth employee and assign the "Y&ent1;" - * string to its value attribute. This value is not yet - * parsed and therefore should still be the same upon - * retrieval. This test uses the "getNamedItem(name)" method - * from the NamedNodeMap interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Apr/0057.html -*/ -public final class attrcreatetextnode2 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrcreatetextnode2(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr streetAttr; - String value; - doc = (Document) load("staff", true); - addressList = doc.getElementsByTagName("address"); - testNode = addressList.item(3); - attributes = testNode.getAttributes(); - streetAttr = (Attr) attributes.getNamedItem("street"); - streetAttr.setNodeValue("Y&ent1;"); - value = streetAttr.getValue(); - assertEquals("value", "Y&ent1;", value); - value = streetAttr.getNodeValue(); - assertEquals("nodeValue", "Y&ent1;", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrcreatetextnode2"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrcreatetextnode2.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrdefaultvalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrdefaultvalue.java deleted file mode 100644 index 151c5840e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrdefaultvalue.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If there is not an explicit value assigned to an attribute - * and there is a declaration for this attribute and that - * declaration includes a default value, then that default - * value is the attributes default value. - * Retrieve the attribute named "street" from the last - * child of of the first employee and examine its - * value. That value should be the value given the - * attribute in the DTD file. The test uses the - * "getNamedItem(name)" method from the NamedNodeMap - * interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html -*/ -public final class attrdefaultvalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrdefaultvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr streetAttr; - String value; - doc = (Document) load("staff", false); - addressList = doc.getElementsByTagName("address"); - testNode = addressList.item(0); - attributes = testNode.getAttributes(); - streetAttr = (Attr) attributes.getNamedItem("street"); - value = streetAttr.getNodeValue(); - assertEquals("attrDefaultValueAssert", "Yes", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrdefaultvalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrdefaultvalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attreffectivevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/attreffectivevalue.java deleted file mode 100644 index 0efe4f087..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attreffectivevalue.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If an Attr is explicitly assigned any value, then that value is the attributes effective value. - * Retrieve the attribute named "domestic" from the last child of of the first employee - * and examine its nodeValue attribute. This test uses the "getNamedItem(name)" method - * from the NamedNodeMap interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549 -*/ -public final class attreffectivevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attreffectivevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr domesticAttr; - String value; - doc = (Document) load("staff", false); - addressList = doc.getElementsByTagName("address"); - testNode = addressList.item(0); - attributes = testNode.getAttributes(); - domesticAttr = (Attr) attributes.getNamedItem("domestic"); - value = domesticAttr.getNodeValue(); - assertEquals("attrEffectiveValueAssert", "Yes", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attreffectivevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attreffectivevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrentityreplacement.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrentityreplacement.java deleted file mode 100644 index b25881189..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrentityreplacement.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getValue()" method will return the value of the - * attribute as a string. The general entity references - * are replaced with their values. - * Retrieve the attribute named "street" from the last - * child of of the fourth employee and examine the string - * returned by the "getValue()" method. The value should - * be set to "Yes" after the EntityReference is - * replaced with its value. This test uses the - * "getNamedItem(name)" method from the NamedNodeMap - * interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474 -*/ -public final class attrentityreplacement extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrentityreplacement(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr streetAttr; - String value; - doc = (Document) load("staff", true); - addressList = doc.getElementsByTagName("address"); - testNode = addressList.item(3); - attributes = testNode.getAttributes(); - streetAttr = (Attr) attributes.getNamedItem("street"); - value = streetAttr.getValue(); - assertEquals("streetYes", "Yes", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrentityreplacement"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrentityreplacement.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrname.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrname.java deleted file mode 100644 index 06a78cc5c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrname.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The getNodeName() method of an Attribute node. - * Retrieve the attribute named street from the last - * child of of the second employee and examine its - * NodeName. This test uses the getNamedItem(name) method from the NamedNodeMap - * interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1112119403 -*/ -public final class attrname extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrname(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr streetAttr; - String name; - doc = (Document) load("staff", false); - addressList = doc.getElementsByTagName("address"); - testNode = addressList.item(1); - attributes = testNode.getAttributes(); - streetAttr = (Attr) attributes.getNamedItem("street"); - name = streetAttr.getNodeName(); - assertEquals("nodeName", "street", name); - name = streetAttr.getName(); - assertEquals("name", "street", name); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrname"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrname.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrnextsiblingnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrnextsiblingnull.java deleted file mode 100644 index 853a91256..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrnextsiblingnull.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNextSibling()" method for an Attr node should return null. - * Retrieve the attribute named "domestic" from the last child of of the - * first employee and examine its NextSibling node. This test uses the - * "getNamedItem(name)" method from the NamedNodeMap interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6AC54C2F -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -*/ -public final class attrnextsiblingnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrnextsiblingnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr domesticAttr; - Node s; - doc = (Document) load("staff", false); - addressList = doc.getElementsByTagName("address"); - testNode = addressList.item(0); - attributes = testNode.getAttributes(); - domesticAttr = (Attr) attributes.getNamedItem("domestic"); - s = domesticAttr.getNextSibling(); - assertNull("attrNextSiblingNullAssert", s); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrnextsiblingnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrnextsiblingnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrnotspecifiedvalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrnotspecifiedvalue.java deleted file mode 100644 index 5adff5042..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrnotspecifiedvalue.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getSpecified()" method for an Attr node should - * be set to false if the attribute was not explicitly given - * a value. - * Retrieve the attribute named "street" from the last - * child of of the first employee and examine the value - * returned by the "getSpecified()" method. This test uses - * the "getNamedItem(name)" method from the NamedNodeMap - * interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-862529273 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html -*/ -public final class attrnotspecifiedvalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrnotspecifiedvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr streetAttr; - boolean state; - doc = (Document) load("staff", false); - addressList = doc.getElementsByTagName("address"); - testNode = addressList.item(0); - attributes = testNode.getAttributes(); - streetAttr = (Attr) attributes.getNamedItem("street"); - state = streetAttr.getSpecified(); - assertFalse("streetNotSpecified", state); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrnotspecifiedvalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrnotspecifiedvalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrparentnodenull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrparentnodenull.java deleted file mode 100644 index 8757a7284..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrparentnodenull.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getParentNode()" method for an Attr node should return null. Retrieve - * the attribute named "domestic" from the last child of the first employee - * and examine its parentNode attribute. This test also uses the "getNamedItem(name)" - * method from the NamedNodeMap interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1060184317 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -*/ -public final class attrparentnodenull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrparentnodenull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr domesticAttr; - Node s; - doc = (Document) load("staff", false); - addressList = doc.getElementsByTagName("address"); - testNode = addressList.item(0); - attributes = testNode.getAttributes(); - domesticAttr = (Attr) attributes.getNamedItem("domestic"); - s = domesticAttr.getParentNode(); - assertNull("attrParentNodeNullAssert", s); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrparentnodenull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrparentnodenull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrprevioussiblingnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrprevioussiblingnull.java deleted file mode 100644 index bdce56929..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrprevioussiblingnull.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getPreviousSibling()" method for an Attr node should return null. - * Retrieve the attribute named "domestic" from the last child of of the - * first employee and examine its PreviousSibling node. This test uses the - * "getNamedItem(name)" method from the NamedNodeMap interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-640FB3C8 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -*/ -public final class attrprevioussiblingnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrprevioussiblingnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr domesticAttr; - Node s; - doc = (Document) load("staff", false); - addressList = doc.getElementsByTagName("address"); - testNode = addressList.item(0); - attributes = testNode.getAttributes(); - domesticAttr = (Attr) attributes.getNamedItem("domestic"); - s = domesticAttr.getPreviousSibling(); - assertNull("attrPreviousSiblingNullAssert", s); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrprevioussiblingnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrprevioussiblingnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrremovechild1.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrremovechild1.java deleted file mode 100644 index 8de15cb9c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrremovechild1.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Removing a child node from an attribute in an entity reference - * should result in an NO_MODIFICATION_ALLOWED_ERR DOMException. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1734834066')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -*/ -public final class attrremovechild1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrremovechild1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - EntityReference entRef; - Element entElement; - Node attrNode; - Text textNode; - Node removedNode; - doc = (Document) load("staff", true); - entRef = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entRef); - entElement = (Element) entRef.getFirstChild(); - assertNotNull("entElementNotNull", entElement); - attrNode = entElement.getAttributeNode("domestic"); - textNode = (Text) attrNode.getFirstChild(); - assertNotNull("attrChildNotNull", textNode); - - { - boolean success = false; - try { - removedNode = attrNode.removeChild(textNode); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("setValue_throws_NO_MODIFICATION_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrremovechild1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrremovechild1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrreplacechild1.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrreplacechild1.java deleted file mode 100644 index c84586c63..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrreplacechild1.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Replacing a child node from an attribute in an entity reference - * should result in an NO_MODIFICATION_ALLOWED_ERR DOMException. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-785887307')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -*/ -public final class attrreplacechild1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrreplacechild1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - EntityReference entRef; - Element entElement; - Node attrNode; - Text textNode; - Node removedNode; - Node newChild; - doc = (Document) load("staff", true); - entRef = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entRef); - entElement = (Element) entRef.getFirstChild(); - assertNotNull("entElementNotNull", entElement); - attrNode = entElement.getAttributeNode("domestic"); - textNode = (Text) attrNode.getFirstChild(); - assertNotNull("attrChildNotNull", textNode); - newChild = doc.createTextNode("Yesterday"); - - { - boolean success = false; - try { - removedNode = attrNode.replaceChild(newChild, textNode); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("setValue_throws_NO_MODIFICATION_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrreplacechild1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrreplacechild1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrsetvaluenomodificationallowederr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrsetvaluenomodificationallowederr.java deleted file mode 100644 index 98c5e2858..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrsetvaluenomodificationallowederr.java +++ /dev/null @@ -1,133 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setValue()" method for an attribute causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Get the "domestic" attribute - * from the entity reference and execute the "setValue()" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#ID-221662474 -* @see http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#xpointer(id('ID-221662474')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/DOM/updates/REC-DOM-Level-1-19981001-errata.html -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474 -*/ -public final class attrsetvaluenomodificationallowederr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrsetvaluenomodificationallowederr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.notExpandEntityReferences - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node gender; - NodeList genList; - Node gen; - NodeList gList; - Node g; - NamedNodeMap attrList; - Attr attrNode; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - gender = genderList.item(2); - assertNotNull("genderNotNull", gender); - genList = gender.getChildNodes(); - gen = genList.item(0); - assertNotNull("genderFirstChildNotNull", gen); - gList = gen.getChildNodes(); - g = gList.item(0); - assertNotNull("genderFirstGrandchildNotNull", g); - attrList = g.getAttributes(); - assertNotNull("attributesNotNull", attrList); - attrNode = (Attr) attrList.getNamedItem("domestic"); - assertNotNull("attrNotNull", attrNode); - - { - boolean success = false; - try { - attrNode.setValue("newvalue"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("setValue_throws_NO_MODIFICATION", success); - } - - { - boolean success = false; - try { - attrNode.setNodeValue("newvalue2"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("setNodeValue_throws_NO_MODIFICATION", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrsetvaluenomodificationallowederr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrsetvaluenomodificationallowederr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrsetvaluenomodificationallowederrEE.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrsetvaluenomodificationallowederrEE.java deleted file mode 100644 index 5455fee6e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrsetvaluenomodificationallowederrEE.java +++ /dev/null @@ -1,123 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setValue()" method for an attribute causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * Create an entity reference using document.createEntityReference() - * Get the "domestic" attribute from the entity - * reference and execute the "setValue()" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author Curt Arnold -* @see http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#ID-221662474 -* @see http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#xpointer(id('ID-221662474')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/DOM/updates/REC-DOM-Level-1-19981001-errata.html -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474 -* @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrsetvaluenomodificationallowederr.xml -*/ -public final class attrsetvaluenomodificationallowederrEE extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrsetvaluenomodificationallowederrEE(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - EntityReference entRef; - Element entElement; - NamedNodeMap attrList; - Node attrNode; - Node gender; - NodeList genderList; - Node appendedChild; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - gender = genderList.item(2); - assertNotNull("genderNotNull", gender); - entRef = doc.createEntityReference("ent4"); - assertNotNull("entRefNotNull", entRef); - appendedChild = gender.appendChild(entRef); - entElement = (Element) entRef.getFirstChild(); - assertNotNull("entElementNotNull", entElement); - attrList = entElement.getAttributes(); - attrNode = attrList.getNamedItem("domestic"); - - { - boolean success = false; - try { - ((Attr) /*Node */attrNode).setValue("newvalue"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("setValue_throws_NO_MODIFICATION", success); - } - - { - boolean success = false; - try { - attrNode.setNodeValue("newvalue2"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("setNodeValue_throws_NO_MODIFICATION", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrsetvaluenomodificationallowederrEE"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrsetvaluenomodificationallowederrEE.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrspecifiedvalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrspecifiedvalue.java deleted file mode 100644 index 10087ffc4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrspecifiedvalue.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getSpecified()" method for an Attr node should - * be set to true if the attribute was explicitly given - * a value. - * Retrieve the attribute named "domestic" from the last - * child of of the first employee and examine the value - * returned by the "getSpecified()" method. This test uses - * the "getNamedItem(name)" method from the NamedNodeMap - * interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-862529273 -*/ -public final class attrspecifiedvalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrspecifiedvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr domesticAttr; - boolean state; - doc = (Document) load("staff", false); - addressList = doc.getElementsByTagName("address"); - testNode = addressList.item(0); - attributes = testNode.getAttributes(); - domesticAttr = (Attr) attributes.getNamedItem("domestic"); - state = domesticAttr.getSpecified(); - assertTrue("domesticSpecified", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrspecifiedvalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrspecifiedvalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrspecifiedvaluechanged.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrspecifiedvaluechanged.java deleted file mode 100644 index dacc8aec6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrspecifiedvaluechanged.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getSpecified()" method for an Attr node should return true if the - * value of the attribute is changed. - * Retrieve the attribute named "street" from the last - * child of of the THIRD employee and change its - * value to "Yes"(which is the default DTD value). This - * should cause the "getSpecified()" method to be true. - * This test uses the "setAttribute(name,value)" method - * from the Element interface and the "getNamedItem(name)" - * method from the NamedNodeMap interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-862529273 -*/ -public final class attrspecifiedvaluechanged extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrspecifiedvaluechanged(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr streetAttr; - boolean state; - doc = (Document) load("staff", true); - addressList = doc.getElementsByTagName("address"); - testNode = addressList.item(2); - ((Element) /*Node */testNode).setAttribute("street", "Yes"); - attributes = testNode.getAttributes(); - streetAttr = (Attr) attributes.getNamedItem("street"); - state = streetAttr.getSpecified(); - assertTrue("streetSpecified", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrspecifiedvaluechanged"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrspecifiedvaluechanged.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrspecifiedvalueremove.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrspecifiedvalueremove.java deleted file mode 100644 index bd72827fd..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/attrspecifiedvalueremove.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * To respecify the attribute to its default value from - * the DTD, the attribute must be deleted. This will then - * make a new attribute available with the "getSpecified()" - * method value set to false. - * Retrieve the attribute named "street" from the last - * child of of the THIRD employee and delete it. This - * should then create a new attribute with its default - * value and also cause the "getSpecified()" method to - * return false. - * This test uses the "removeAttribute(name)" method - * from the Element interface and the "getNamedItem(name)" - * method from the NamedNodeMap interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html -*/ -public final class attrspecifiedvalueremove extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrspecifiedvalueremove(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr streetAttr; - boolean state; - doc = (Document) load("staff", true); - addressList = doc.getElementsByTagName("address"); - testNode = addressList.item(2); - ((Element) /*Node */testNode).removeAttribute("street"); - attributes = testNode.getAttributes(); - streetAttr = (Attr) attributes.getNamedItem("street"); - assertNotNull("streetAttrNotNull", streetAttr); - state = streetAttr.getSpecified(); - assertFalse("attrSpecifiedValueRemoveAssert", state); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrspecifiedvalueremove"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrspecifiedvalueremove.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/cdatasectiongetdata.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/cdatasectiongetdata.java deleted file mode 100644 index f3ef7a8c9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/cdatasectiongetdata.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the last CDATASection node located inside the - * second child of the second employee and examine its - * content. Since the CDATASection interface inherits - * from the CharacterData interface(via the Text node), - * the "getData()" method can be used to access the - * CDATA content. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -*/ -public final class cdatasectiongetdata extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public cdatasectiongetdata(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.notCoalescing - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList nameList; - Node child; - Node lastChild; - String data; - int nodeType; - doc = (Document) load("staff", false); - nameList = doc.getElementsByTagName("name"); - child = nameList.item(1); - lastChild = child.getLastChild(); - nodeType = (int) lastChild.getNodeType(); - assertEquals("isCDATA", 4, nodeType); - data = ((CharacterData) /*Node */lastChild).getData(); - assertEquals("data", "This is an adjacent CDATASection with a reference to a tab &tab;", data); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/cdatasectiongetdata"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(cdatasectiongetdata.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/cdatasectionnormalize.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/cdatasectionnormalize.java deleted file mode 100644 index 7235b31cc..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/cdatasectionnormalize.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Adjacent CDATASection nodes cannot be merged together by - * use of the "normalize()" method from the Element interface. - * Retrieve second child of the second employee and invoke - * the "normalize()" method. The Element under contains - * two CDATASection nodes that should not be merged together - * by the "normalize()" method. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-162CF083 -*/ -public final class cdatasectionnormalize extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public cdatasectionnormalize(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList nameList; - Element lChild; - NodeList childNodes; - CDATASection cdataN; - String data; - doc = (Document) load("staff", true); - nameList = doc.getElementsByTagName("name"); - lChild = (Element) nameList.item(1); - lChild.normalize(); - childNodes = lChild.getChildNodes(); - cdataN = (CDATASection) childNodes.item(1); - assertNotNull("firstCDATASection", cdataN); - data = cdataN.getData(); - assertEquals("data1", "This is a CDATASection with EntityReference number 2 &ent2;", data); - cdataN = (CDATASection) childNodes.item(3); - assertNotNull("secondCDATASection", cdataN); - data = cdataN.getData(); - assertEquals("data3", "This is an adjacent CDATASection with a reference to a tab &tab;", data); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/cdatasectionnormalize"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(cdatasectionnormalize.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataappenddata.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataappenddata.java deleted file mode 100644 index 0ca7b0ca9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataappenddata.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "appendData(arg)" method appends a string to the end - * of the character data of the node. - * - * Retrieve the character data from the second child - * of the first employee. The appendData(arg) method is - * called with arg=", Esquire". The method should append - * the specified data to the already existing character - * data. The new value return by the "getLength()" method - * should be 24. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F -*/ -public final class characterdataappenddata extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdataappenddata(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childValue; - int childLength; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("name"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.appendData(", Esquire"); - childValue = child.getData(); - childLength = childValue.length(); - assertEquals("characterdataAppendDataAssert", 24, childLength); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataappenddata"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdataappenddata.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataappenddatagetdata.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataappenddatagetdata.java deleted file mode 100644 index e3c352eb9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataappenddatagetdata.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * On successful invocation of the "appendData(arg)" - * method the "getData()" method provides access to the - * concatentation of data and the specified string. - * - * Retrieve the character data from the second child - * of the first employee. The appendData(arg) method is - * called with arg=", Esquire". The method should append - * the specified data to the already existing character - * data. The new value return by the "getData()" method - * should be "Margaret Martin, Esquire". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F -*/ -public final class characterdataappenddatagetdata extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdataappenddatagetdata(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("name"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.appendData(", Esquire"); - childData = child.getData(); - assertEquals("characterdataAppendDataGetDataAssert", "Margaret Martin, Esquire", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataappenddatagetdata"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdataappenddatagetdata.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataappenddatanomodificationallowederr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataappenddatanomodificationallowederr.java deleted file mode 100644 index 5c1fd9a85..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataappenddatanomodificationallowederr.java +++ /dev/null @@ -1,114 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "appendData(arg)" method raises a NO_MODIFICATION_ALLOWED_ERR - * DOMException if the node is readonly. - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Get the FIRST item - * from the entity reference and execute the "appendData(arg)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-32791A2F')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F -*/ -public final class characterdataappenddatanomodificationallowederr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdataappenddatanomodificationallowederr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node genderNode; - Node entElement; - Node entElementContent; - Node entReference; - int nodeType; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - genderNode = genderList.item(2); - entReference = genderNode.getFirstChild(); - assertNotNull("entReferenceNotNull", entReference); - nodeType = (int) entReference.getNodeType(); - - if (equals(1, nodeType)) { - entReference = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entReference); - } - entElement = entReference.getFirstChild(); - assertNotNull("entElementNotNull", entElement); - entElementContent = entElement.getFirstChild(); - assertNotNull("entElementContentNotNull", entElementContent); - - { - boolean success = false; - try { - ((CharacterData) /*Node */entElementContent).appendData("newString"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataappenddatanomodificationallowederr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdataappenddatanomodificationallowederr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataappenddatanomodificationallowederrEE.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataappenddatanomodificationallowederrEE.java deleted file mode 100644 index 725a35fa4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataappenddatanomodificationallowederrEE.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Create an ent3 entity reference and call appendData on a text child, should thrown a NO_MODIFICATION_ALLOWED_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-32791A2F')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F -* @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataappenddatanomodificationallowederr.xml -*/ -public final class characterdataappenddatanomodificationallowederrEE extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdataappenddatanomodificationallowederrEE(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node genderNode; - Node entText; - EntityReference entReference; - Node appendedChild; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - genderNode = genderList.item(2); - entReference = doc.createEntityReference("ent3"); - assertNotNull("createdEntRefNotNull", entReference); - appendedChild = genderNode.appendChild(entReference); - entText = entReference.getFirstChild(); - assertNotNull("entTextNotNull", entText); - - { - boolean success = false; - try { - ((CharacterData) /*Node */entText).appendData("newString"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataappenddatanomodificationallowederrEE"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdataappenddatanomodificationallowederrEE.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatabegining.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatabegining.java deleted file mode 100644 index 2a0a4bc05..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatabegining.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "deleteData(offset,count)" method removes a range of - * characters from the node. Delete data at the beginning - * of the character data. - * Retrieve the character data from the last child of the - * first employee. The "deleteData(offset,count)" - * method is then called with offset=0 and count=16. - * The method should delete the characters from position - * 0 thru position 16. The new value of the character data - * should be "Dallas, Texas 98551". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -*/ -public final class characterdatadeletedatabegining extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatadeletedatabegining(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.deleteData(0, 16); - childData = child.getData(); - assertEquals("characterdataDeleteDataBeginingAssert", "Dallas, Texas 98551", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatadeletedatabegining"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatadeletedatabegining.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedataend.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedataend.java deleted file mode 100644 index fbe195ae9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedataend.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "deleteData(offset,count)" method removes a range of - * characters from the node. Delete data at the end - * of the character data. - * - * Retrieve the character data from the last child of the - * first employee. The "deleteData(offset,count)" - * method is then called with offset=30 and count=5. - * The method should delete the characters from position - * 30 thru position 35. The new value of the character data - * should be "1230 North Ave. Dallas, Texas". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -*/ -public final class characterdatadeletedataend extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatadeletedataend(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.deleteData(30, 5); - childData = child.getData(); - assertEquals("characterdataDeleteDataEndAssert", "1230 North Ave. Dallas, Texas ", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatadeletedataend"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatadeletedataend.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedataexceedslength.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedataexceedslength.java deleted file mode 100644 index b1e254e64..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedataexceedslength.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the sum of the offset and count used in the - * "deleteData(offset,count) method is greater than the - * length of the character data then all the characters - * from the offset to the end of the data are deleted. - * - * Retrieve the character data from the last child of the - * first employee. The "deleteData(offset,count)" - * method is then called with offset=4 and count=50. - * The method should delete the characters from position 4 - * to the end of the data since the offset+count(50+4) - * is greater than the length of the character data(35). - * The new value of the character data should be "1230". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -*/ -public final class characterdatadeletedataexceedslength extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatadeletedataexceedslength(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.deleteData(4, 50); - childData = child.getData(); - assertEquals("characterdataDeleteDataExceedsLengthAssert", "1230", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatadeletedataexceedslength"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatadeletedataexceedslength.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatagetlengthanddata.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatagetlengthanddata.java deleted file mode 100644 index 7e3cf1341..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatagetlengthanddata.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * On successful invocation of the "deleteData(offset,count)" - * method, the "getData()" and "getLength()" methods reflect - * the changes. - * - * Retrieve the character data from the last child of the - * first employee. The "deleteData(offset,count)" - * method is then called with offset=30 and count=5. - * The method should delete the characters from position - * 30 thru position 35. The new value of the character data - * should be "1230 North Ave. Dallas, Texas" which is - * returned by the "getData()" method and "getLength()" - * method should return 30". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7D61178C -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -*/ -public final class characterdatadeletedatagetlengthanddata extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatadeletedatagetlengthanddata(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - int childLength; - java.util.List result = new java.util.ArrayList(); - - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.deleteData(30, 5); - childData = child.getData(); - assertEquals("data", "1230 North Ave. Dallas, Texas ", childData); - childLength = (int) child.getLength(); - assertEquals("length", 30, childLength); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatadeletedatagetlengthanddata"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatadeletedatagetlengthanddata.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatamiddle.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatamiddle.java deleted file mode 100644 index 35f2ff3a4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatamiddle.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "deleteData(offset,count)" method removes a range of - * characters from the node. Delete data in the middle - * of the character data. - * - * Retrieve the character data from the last child of the - * first employee. The "deleteData(offset,count)" - * method is then called with offset=16 and count=8. - * The method should delete the characters from position - * 16 thru position 24. The new value of the character data - * should be "1230 North Ave. Texas 98551". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -*/ -public final class characterdatadeletedatamiddle extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatadeletedatamiddle(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.deleteData(16, 8); - childData = child.getData(); - assertEquals("characterdataDeleteDataMiddleAssert", "1230 North Ave. Texas 98551", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatadeletedatamiddle"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatadeletedatamiddle.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatanomodificationallowederr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatanomodificationallowederr.java deleted file mode 100644 index d902b774c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatanomodificationallowederr.java +++ /dev/null @@ -1,114 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "deleteData(offset,count)" method raises a NO_MODIFICATION_ALLOWED_ERR - * DOMException if the node is readonly. - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Get the FIRST item - * from the entity reference and execute the "deleteData(offset,count)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -*/ -public final class characterdatadeletedatanomodificationallowederr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatadeletedatanomodificationallowederr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node genderNode; - Node entElement; - Node entElementContent; - int nodeType; - Node entReference; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - genderNode = genderList.item(2); - entReference = genderNode.getFirstChild(); - assertNotNull("entReferenceNotNull", entReference); - nodeType = (int) entReference.getNodeType(); - - if (equals(3, nodeType)) { - entReference = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entReference); - } - entElement = entReference.getFirstChild(); - assertNotNull("entElementNotNull", entElement); - entElementContent = entElement.getFirstChild(); - assertNotNull("entElementContentNotNull", entElementContent); - - { - boolean success = false; - try { - ((CharacterData) /*Node */entElementContent).deleteData(1, 3); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatadeletedatanomodificationallowederr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatadeletedatanomodificationallowederr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatanomodificationallowederrEE.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatanomodificationallowederrEE.java deleted file mode 100644 index 2122c3d9c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatadeletedatanomodificationallowederrEE.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Create an ent3 entity reference and call deleteData on a text child, should thrown a NO_MODIFICATION_ALLOWED_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -* @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatadeletedatanomodificationallowederr.xml -*/ -public final class characterdatadeletedatanomodificationallowederrEE extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatadeletedatanomodificationallowederrEE(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node genderNode; - Node entText; - EntityReference entReference; - Node appendedChild; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - genderNode = genderList.item(2); - entReference = doc.createEntityReference("ent3"); - assertNotNull("createdEntRefNotNull", entReference); - appendedChild = genderNode.appendChild(entReference); - entText = entReference.getFirstChild(); - assertNotNull("entTextNotNull", entText); - - { - boolean success = false; - try { - ((CharacterData) /*Node */entText).deleteData(1, 3); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatadeletedatanomodificationallowederrEE"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatadeletedatanomodificationallowederrEE.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatagetdata.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatagetdata.java deleted file mode 100644 index 895f9d510..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatagetdata.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getData()" method retrieves the character data - * currently stored in the node. - * Retrieve the character data from the second child - * of the first employee and invoke the "getData()" - * method. The method returns the character data - * string. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -*/ -public final class characterdatagetdata extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatagetdata(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("name"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - childData = child.getData(); - assertEquals("characterdataGetDataAssert", "Margaret Martin", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatagetdata"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatagetdata.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatagetlength.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatagetlength.java deleted file mode 100644 index 7458d7a05..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatagetlength.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getLength()" method returns the number of characters - * stored in this nodes data. - * Retrieve the character data from the second - * child of the first employee and examine the - * value returned by the getLength() method. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7D61178C -*/ -public final class characterdatagetlength extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatagetlength(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childValue; - int childLength; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("name"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - childValue = child.getData(); - childLength = childValue.length(); - assertEquals("characterdataGetLengthAssert", 15, childLength); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatagetlength"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatagetlength.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrdeletedatacountnegative.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrdeletedatacountnegative.java deleted file mode 100644 index d902d7334..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrdeletedatacountnegative.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "deleteData(offset,count)" method raises an - * INDEX_SIZE_ERR DOMException if the specified count - * is negative. - * - * Retrieve the character data of the last child of the - * first employee and invoke its "deleteData(offset,count)" - * method with offset=10 and count=-3. It should raise the - * desired exception since the count is negative. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -*/ -public final class characterdataindexsizeerrdeletedatacountnegative extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdataindexsizeerrdeletedatacountnegative(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.signed - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - child.deleteData(10, -3); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throws_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataindexsizeerrdeletedatacountnegative"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdataindexsizeerrdeletedatacountnegative.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrdeletedataoffsetgreater.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrdeletedataoffsetgreater.java deleted file mode 100644 index dd8c7e8bd..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrdeletedataoffsetgreater.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "deleteData(offset,count)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset - * is greater that the number of characters in the string. - * - * Retrieve the character data of the last child of the - * first employee and invoke its "deleteData(offset,count)" - * method with offset=40 and count=3. It should raise the - * desired exception since the offset is greater than the - * number of characters in the string. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class characterdataindexsizeerrdeletedataoffsetgreater extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdataindexsizeerrdeletedataoffsetgreater(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - child.deleteData(40, 3); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throw_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataindexsizeerrdeletedataoffsetgreater"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdataindexsizeerrdeletedataoffsetgreater.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrdeletedataoffsetnegative.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrdeletedataoffsetnegative.java deleted file mode 100644 index 96dd368f8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrdeletedataoffsetnegative.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "deleteData(offset,count)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset - * is negative. - * - * Retrieve the character data of the last child of the - * first employee and invoke its "deleteData(offset,count)" - * method with offset=-5 and count=3. It should raise the - * desired exception since the offset is negative. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -*/ -public final class characterdataindexsizeerrdeletedataoffsetnegative extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdataindexsizeerrdeletedataoffsetnegative(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.signed - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - child.deleteData(-5, 3); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throws_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataindexsizeerrdeletedataoffsetnegative"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdataindexsizeerrdeletedataoffsetnegative.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrinsertdataoffsetgreater.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrinsertdataoffsetgreater.java deleted file mode 100644 index 3163162c7..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrinsertdataoffsetgreater.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertData(offset,arg)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset - * is greater than the number of characters in the string. - * - * Retrieve the character data of the last child of the - * first employee and invoke its insertData"(offset,arg)" - * method with offset=40 and arg="ABC". It should raise - * the desired exception since the offset is greater than - * the number of characters in the string. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class characterdataindexsizeerrinsertdataoffsetgreater extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdataindexsizeerrinsertdataoffsetgreater(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - child.insertData(40, "ABC"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throw_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataindexsizeerrinsertdataoffsetgreater"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdataindexsizeerrinsertdataoffsetgreater.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrinsertdataoffsetnegative.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrinsertdataoffsetnegative.java deleted file mode 100644 index e578d9c3b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrinsertdataoffsetnegative.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertData(offset,arg)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset - * is negative. - * - * Retrieve the character data of the last child of the - * first employee and invoke its insertData"(offset,arg)" - * method with offset=-5 and arg="ABC". It should raise - * the desired exception since the offset is negative. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-E5CBA7FB')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -*/ -public final class characterdataindexsizeerrinsertdataoffsetnegative extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdataindexsizeerrinsertdataoffsetnegative(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.signed - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - child.insertData(-5, "ABC"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throws_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataindexsizeerrinsertdataoffsetnegative"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdataindexsizeerrinsertdataoffsetnegative.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrreplacedatacountnegative.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrreplacedatacountnegative.java deleted file mode 100644 index 01b5bccbf..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrreplacedatacountnegative.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceData(offset,count,arg)" method raises an - * INDEX_SIZE_ERR DOMException if the specified count - * is negative. - * - * Retrieve the character data of the last child of the - * first employee and invoke its - * "replaceData(offset,count,arg) method with offset=10 - * and count=-3 and arg="ABC". It should raise the - * desired exception since the count is negative. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -*/ -public final class characterdataindexsizeerrreplacedatacountnegative extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdataindexsizeerrreplacedatacountnegative(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.signed - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - child.replaceData(10, -3, "ABC"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throws_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataindexsizeerrreplacedatacountnegative"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdataindexsizeerrreplacedatacountnegative.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrreplacedataoffsetgreater.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrreplacedataoffsetgreater.java deleted file mode 100644 index feda16fab..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrreplacedataoffsetgreater.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceData(offset,count,arg)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset - * is greater than the length of the string. - * - * Retrieve the character data of the last child of the - * first employee and invoke its - * "replaceData(offset,count,arg) method with offset=40 - * and count=3 and arg="ABC". It should raise the - * desired exception since the offset is greater than the - * length of the string. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class characterdataindexsizeerrreplacedataoffsetgreater extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdataindexsizeerrreplacedataoffsetgreater(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - child.replaceData(40, 3, "ABC"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throw_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataindexsizeerrreplacedataoffsetgreater"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdataindexsizeerrreplacedataoffsetgreater.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrreplacedataoffsetnegative.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrreplacedataoffsetnegative.java deleted file mode 100644 index f8aae5c51..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrreplacedataoffsetnegative.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceData(offset,count,arg)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset - * is negative. - * - * Retrieve the character data of the last child of the - * first employee and invoke its - * "replaceData(offset,count,arg) method with offset=-5 - * and count=3 and arg="ABC". It should raise the - * desired exception since the offset is negative. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-E5CBA7FB')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -*/ -public final class characterdataindexsizeerrreplacedataoffsetnegative extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdataindexsizeerrreplacedataoffsetnegative(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.signed - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - child.replaceData(-5, 3, "ABC"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throws_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataindexsizeerrreplacedataoffsetnegative"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdataindexsizeerrreplacedataoffsetnegative.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrsubstringcountnegative.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrsubstringcountnegative.java deleted file mode 100644 index c14d44a8d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrsubstringcountnegative.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "substringData(offset,count)" method raises an - * INDEX_SIZE_ERR DOMException if the specified count - * is negative. - * - * Retrieve the character data of the last child of the - * first employee and invoke its "substringData(offset,count) - * method with offset=10 and count=-3. It should raise the - * desired exception since the count is negative. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -*/ -public final class characterdataindexsizeerrsubstringcountnegative extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdataindexsizeerrsubstringcountnegative(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.signed - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String badSubstring; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - badSubstring = child.substringData(10, -3); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throws_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataindexsizeerrsubstringcountnegative"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdataindexsizeerrsubstringcountnegative.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrsubstringnegativeoffset.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrsubstringnegativeoffset.java deleted file mode 100644 index 37fcea4aa..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrsubstringnegativeoffset.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "substringData(offset,count)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset - * is negative. - * - * Retrieve the character data of the last child of the - * first employee and invoke its "substringData(offset,count) - * method with offset=-5 and count=3. It should raise the - * desired exception since the offset is negative. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -*/ -public final class characterdataindexsizeerrsubstringnegativeoffset extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdataindexsizeerrsubstringnegativeoffset(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.signed - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String badString; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - badString = child.substringData(-5, 3); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throws_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataindexsizeerrsubstringnegativeoffset"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdataindexsizeerrsubstringnegativeoffset.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrsubstringoffsetgreater.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrsubstringoffsetgreater.java deleted file mode 100644 index 500c5eb20..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdataindexsizeerrsubstringoffsetgreater.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "substringData(offset,count)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset - * is greater than the number of characters in the string. - * - * Retrieve the character data of the last child of the - * first employee and invoke its "substringData(offset,count) - * method with offset=40 and count=3. It should raise the - * desired exception since the offsets value is greater - * than the length. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class characterdataindexsizeerrsubstringoffsetgreater extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdataindexsizeerrsubstringoffsetgreater(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String badString; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - badString = child.substringData(40, 3); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throw_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataindexsizeerrsubstringoffsetgreater"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdataindexsizeerrsubstringoffsetgreater.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdatabeginning.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdatabeginning.java deleted file mode 100644 index 9adb722b1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdatabeginning.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertData(offset,arg)" method will insert a string - * at the specified character offset. Insert the data at - * the beginning of the character data. - * Retrieve the character data from the second child of - * the first employee. The "insertData(offset,arg)" - * method is then called with offset=0 and arg="Mss.". - * The method should insert the string "Mss." at position 0. - * The new value of the character data should be - * "Mss. Margaret Martin". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F -*/ -public final class characterdatainsertdatabeginning extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatainsertdatabeginning(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("name"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.insertData(0, "Mss. "); - childData = child.getData(); - assertEquals("characterdataInsertDataBeginningAssert", "Mss. Margaret Martin", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatainsertdatabeginning"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatainsertdatabeginning.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdataend.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdataend.java deleted file mode 100644 index b3052c63b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdataend.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertData(offset,arg)" method will insert a string - * at the specified character offset. Insert the data at - * the end of the character data. - * - * Retrieve the character data from the second child of - * the first employee. The "insertData(offset,arg)" - * method is then called with offset=15 and arg=", Esquire". - * The method should insert the string ", Esquire" at - * position 15. The new value of the character data should - * be "Margaret Martin, Esquire". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F -*/ -public final class characterdatainsertdataend extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatainsertdataend(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("name"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.insertData(15, ", Esquire"); - childData = child.getData(); - assertEquals("characterdataInsertDataEndAssert", "Margaret Martin, Esquire", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatainsertdataend"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatainsertdataend.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdatamiddle.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdatamiddle.java deleted file mode 100644 index 9f6516834..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdatamiddle.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertData(offset,arg)" method will insert a string - * at the specified character offset. Insert the data in - * the middle of the character data. - * - * Retrieve the character data from the second child of - * the first employee. The "insertData(offset,arg)" - * method is then called with offset=9 and arg="Ann". - * The method should insert the string "Ann" at position 9. - * The new value of the character data should be - * "Margaret Ann Martin". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F -*/ -public final class characterdatainsertdatamiddle extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatainsertdatamiddle(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("name"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.insertData(9, "Ann "); - childData = child.getData(); - assertEquals("characterdataInsertDataMiddleAssert", "Margaret Ann Martin", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatainsertdatamiddle"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatainsertdatamiddle.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdatanomodificationallowederr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdatanomodificationallowederr.java deleted file mode 100644 index f2f23a6ae..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdatanomodificationallowederr.java +++ /dev/null @@ -1,114 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertData(offset,arg)" method raises a NO_MODIFICATION_ALLOWED_ERR - * DOMException if the node is readonly. - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Get the FIRST item - * from the entity reference and execute the "insertData(offset,arg)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-3EDB695F')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F -*/ -public final class characterdatainsertdatanomodificationallowederr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatainsertdatanomodificationallowederr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node genderNode; - Node entElement; - int nodeType; - Node entElementContent; - Node entReference; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - genderNode = genderList.item(2); - entReference = genderNode.getFirstChild(); - assertNotNull("entReferenceNotNull", entReference); - nodeType = (int) entReference.getNodeType(); - - if (equals(1, nodeType)) { - entReference = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entReference); - } - entElement = entReference.getFirstChild(); - assertNotNull("entElementNotNull", entElement); - entElementContent = entElement.getFirstChild(); - assertNotNull("entElementContentNotNull", entElementContent); - - { - boolean success = false; - try { - ((CharacterData) /*Node */entElementContent).insertData(1, "newArg"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatainsertdatanomodificationallowederr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatainsertdatanomodificationallowederr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdatanomodificationallowederrEE.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdatanomodificationallowederrEE.java deleted file mode 100644 index 82ca7ee52..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatainsertdatanomodificationallowederrEE.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Create an ent3 entity reference and call insertData on a text child, should thrown a NO_MODIFICATION_ALLOWED_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-3EDB695F')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F -* @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatainsertdatanomodificationallowederr.xml -*/ -public final class characterdatainsertdatanomodificationallowederrEE extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatainsertdatanomodificationallowederrEE(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node genderNode; - CharacterData entText; - EntityReference entReference; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - genderNode = genderList.item(2); - entReference = doc.createEntityReference("ent3"); - assertNotNull("createdEntRefNotNull", entReference); - entText = (CharacterData) entReference.getFirstChild(); - assertNotNull("entTextNotNull", entText); - - { - boolean success = false; - try { - entText.insertData(1, "newArg"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatainsertdatanomodificationallowederrEE"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatainsertdatanomodificationallowederrEE.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedatabegining.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedatabegining.java deleted file mode 100644 index 33fa98823..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedatabegining.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceData(offset,count,arg)" method replaces the - * characters starting at the specified offset with the - * specified string. Test for replacement in the - * middle of the data. - * Retrieve the character data from the last child of the - * first employee. The "replaceData(offset,count,arg)" - * method is then called with offset=5 and count=5 and - * arg="South". The method should replace characters five - * thru 9 of the character data with "South". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -*/ -public final class characterdatareplacedatabegining extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatareplacedatabegining(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.replaceData(0, 4, "2500"); - childData = child.getData(); - assertEquals("characterdataReplaceDataBeginingAssert", "2500 North Ave. Dallas, Texas 98551", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatareplacedatabegining"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatareplacedatabegining.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedataend.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedataend.java deleted file mode 100644 index 59e2f8788..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedataend.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceData(offset,count,arg)" method replaces the - * characters starting at the specified offset with the - * specified string. Test for replacement at the - * end of the data. - * - * Retrieve the character data from the last child of the - * first employee. The "replaceData(offset,count,arg)" - * method is then called with offset=30 and count=5 and - * arg="98665". The method should replace characters 30 - * thru 34 of the character data with "98665". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -*/ -public final class characterdatareplacedataend extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatareplacedataend(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.replaceData(30, 5, "98665"); - childData = child.getData(); - assertEquals("characterdataReplaceDataEndAssert", "1230 North Ave. Dallas, Texas 98665", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatareplacedataend"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatareplacedataend.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedataexceedslengthofarg.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedataexceedslengthofarg.java deleted file mode 100644 index 2025be4f6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedataexceedslengthofarg.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceData(offset,count,arg)" method replaces the - * characters starting at the specified offset with the - * specified string. Test the situation where the length - * of the arg string is greater than the specified offset. - * - * Retrieve the character data from the last child of the - * first employee. The "replaceData(offset,count,arg)" - * method is then called with offset=0 and count=4 and - * arg="260030". The method should replace characters one - * thru four with "260030". Note that the length of the - * specified string is greater that the specified offset. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -*/ -public final class characterdatareplacedataexceedslengthofarg extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatareplacedataexceedslengthofarg(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.replaceData(0, 4, "260030"); - childData = child.getData(); - assertEquals("characterdataReplaceDataExceedsLengthOfArgAssert", "260030 North Ave. Dallas, Texas 98551", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatareplacedataexceedslengthofarg"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatareplacedataexceedslengthofarg.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedataexceedslengthofdata.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedataexceedslengthofdata.java deleted file mode 100644 index 5794f11e9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedataexceedslengthofdata.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the sum of the offset and count exceeds the length then - * all the characters to the end of the data are replaced. - * - * Retrieve the character data from the last child of the - * first employee. The "replaceData(offset,count,arg)" - * method is then called with offset=0 and count=50 and - * arg="2600". The method should replace all the characters - * with "2600". This is because the sum of the offset and - * count exceeds the length of the character data. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -*/ -public final class characterdatareplacedataexceedslengthofdata extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatareplacedataexceedslengthofdata(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.replaceData(0, 50, "2600"); - childData = child.getData(); - assertEquals("characterdataReplaceDataExceedsLengthOfDataAssert", "2600", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatareplacedataexceedslengthofdata"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatareplacedataexceedslengthofdata.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedatamiddle.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedatamiddle.java deleted file mode 100644 index 0a168e61d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedatamiddle.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceData(offset,count,arg)" method replaces the - * characters starting at the specified offset with the - * specified string. Test for replacement in the - * middle of the data. - * - * Retrieve the character data from the last child of the - * first employee. The "replaceData(offset,count,arg)" - * method is then called with offset=5 and count=5 and - * arg="South". The method should replace characters five - * thru 9 of the character data with "South". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -*/ -public final class characterdatareplacedatamiddle extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatareplacedatamiddle(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.replaceData(5, 5, "South"); - childData = child.getData(); - assertEquals("characterdataReplaceDataMiddleAssert", "1230 South Ave. Dallas, Texas 98551", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatareplacedatamiddle"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatareplacedatamiddle.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedatanomodificationallowederr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedatanomodificationallowederr.java deleted file mode 100644 index 6176d3b54..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedatanomodificationallowederr.java +++ /dev/null @@ -1,115 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceData(offset,count,arg)" method raises a NO_MODIFICATION_ALLOWED_ERR - * DOMException if the node is readonly. - * - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Get the FIRST item - * from the entity reference and execute the "replaceData(offset,count,arg)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-E5CBA7FB')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -*/ -public final class characterdatareplacedatanomodificationallowederr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatareplacedatanomodificationallowederr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node genderNode; - Node entElement; - Node entElementContent; - Node entReference; - int nodeType; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - genderNode = genderList.item(2); - entReference = genderNode.getFirstChild(); - assertNotNull("entReferenceNotNull", entReference); - nodeType = (int) entReference.getNodeType(); - - if (equals(1, nodeType)) { - entReference = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entReference); - } - entElement = entReference.getFirstChild(); - assertNotNull("entElementNotNull", entElement); - entElementContent = entElement.getFirstChild(); - assertNotNull("entElementContentNotNull", entElementContent); - - { - boolean success = false; - try { - ((CharacterData) /*Node */entElementContent).replaceData(1, 3, "newArg"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatareplacedatanomodificationallowederr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatareplacedatanomodificationallowederr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedatanomodificationallowederrEE.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedatanomodificationallowederrEE.java deleted file mode 100644 index 30d7efda2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatareplacedatanomodificationallowederrEE.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Create an ent3 entity reference and call replaceData on a text child, should thrown a NO_MODIFICATION_ALLOWED_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-E5CBA7FB')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -* @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatareplacedatanomodificationallowederr.xml -*/ -public final class characterdatareplacedatanomodificationallowederrEE extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatareplacedatanomodificationallowederrEE(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node genderNode; - CharacterData entText; - EntityReference entReference; - Node appendedNode; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - genderNode = genderList.item(2); - entReference = doc.createEntityReference("ent3"); - assertNotNull("createdEntRefNotNull", entReference); - appendedNode = genderNode.appendChild(entReference); - entText = (CharacterData) entReference.getFirstChild(); - assertNotNull("entTextNotNull", entText); - - { - boolean success = false; - try { - entText.replaceData(1, 3, "newArg"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatareplacedatanomodificationallowederrEE"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatareplacedatanomodificationallowederrEE.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasetdatanomodificationallowederr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasetdatanomodificationallowederr.java deleted file mode 100644 index ce7898c51..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasetdatanomodificationallowederr.java +++ /dev/null @@ -1,114 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setData(data)" method raises a NO_MODIFICATION_ALLOWED_ERR - * DOMException if the node is readonly. - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Get the FIRST item - * from the entity reference and execute the "setData(data)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-72AB8359')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -*/ -public final class characterdatasetdatanomodificationallowederr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatasetdatanomodificationallowederr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node genderNode; - Node entElement; - Node entElementContent; - Node entReference; - int nodeType; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - genderNode = genderList.item(2); - entReference = genderNode.getFirstChild(); - assertNotNull("entReferenceNotNull", entReference); - nodeType = (int) entReference.getNodeType(); - - if (equals(1, nodeType)) { - entReference = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entReference); - } - entElement = entReference.getFirstChild(); - assertNotNull("entElementNotNull", entElement); - entElementContent = entElement.getFirstChild(); - assertNotNull("entElementContentNotNull", entElementContent); - - { - boolean success = false; - try { - ((CharacterData) /*Node */entElementContent).setData("newData"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatasetdatanomodificationallowederr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatasetdatanomodificationallowederr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasetdatanomodificationallowederrEE.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasetdatanomodificationallowederrEE.java deleted file mode 100644 index 2db63a9c1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasetdatanomodificationallowederrEE.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Create an ent3 entity reference and call setData on a text child, should thrown a NO_MODIFICATION_ALLOWED_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-72AB8359')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatasetdatanomodificationallowederr.xml -*/ -public final class characterdatasetdatanomodificationallowederrEE extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatasetdatanomodificationallowederrEE(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node genderNode; - Node entText; - EntityReference entReference; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - genderNode = genderList.item(4); - entReference = doc.createEntityReference("ent3"); - assertNotNull("createdEntRefNotNull", entReference); - entText = entReference.getFirstChild(); - assertNotNull("entTextNotNull", entText); - - { - boolean success = false; - try { - ((CharacterData) /*Node */entText).setData("newData"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatasetdatanomodificationallowederrEE"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatasetdatanomodificationallowederrEE.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasetnodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasetnodevalue.java deleted file mode 100644 index bb5dfeb1d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasetnodevalue.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setNodeValue()" method changes the character data - * currently stored in the node. - * Retrieve the character data from the second child - * of the first employee and invoke the "setNodeValue()" - * method, call "getData()" and compare. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -*/ -public final class characterdatasetnodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatasetnodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - String childValue; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("name"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.setNodeValue("Marilyn Martin"); - childData = child.getData(); - assertEquals("data", "Marilyn Martin", childData); - childValue = child.getNodeValue(); - assertEquals("value", "Marilyn Martin", childValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatasetnodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatasetnodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasubstringexceedsvalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasubstringexceedsvalue.java deleted file mode 100644 index 7ee0b8f42..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasubstringexceedsvalue.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the sum of the "offset" and "count" exceeds the - * "length" then the "substringData(offset,count)" method - * returns all the characters to the end of the data. - * - * Retrieve the character data from the second child - * of the first employee and access part of the data - * by using the substringData(offset,count) method - * with offset=9 and count=10. The method should return - * the substring "Martin" since offset+count > length - * (19 > 15). -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF -*/ -public final class characterdatasubstringexceedsvalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatasubstringexceedsvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String substring; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("name"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - substring = child.substringData(9, 10); - assertEquals("characterdataSubStringExceedsValueAssert", "Martin", substring); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatasubstringexceedsvalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatasubstringexceedsvalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasubstringvalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasubstringvalue.java deleted file mode 100644 index 46e712cfa..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/characterdatasubstringvalue.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "substringData(offset,count)" method returns the - * specified string. - * - * Retrieve the character data from the second child - * of the first employee and access part of the data - * by using the substringData(offset,count) method. The - * method should return the specified substring starting - * at position "offset" and extract "count" characters. - * The method should return the string "Margaret". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF -*/ -public final class characterdatasubstringvalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public characterdatasubstringvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String substring; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("name"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - substring = child.substringData(0, 8); - assertEquals("characterdataSubStringValueAssert", "Margaret", substring); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatasubstringvalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(characterdatasubstringvalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/commentgetcomment.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/commentgetcomment.java deleted file mode 100644 index 66eb212ed..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/commentgetcomment.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * A comment is all the characters between the starting - * '' - * Retrieve the nodes of the DOM document. Search for a - * comment node and the content is its value. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1334481328 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -*/ -public final class commentgetcomment extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public commentgetcomment(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node child; - String childName; - String childValue; - int commentCount = 0; - int childType; - doc = (Document) load("staff", false); - elementList = doc.getChildNodes(); - for (int indexN10057 = 0; indexN10057 < elementList.getLength(); indexN10057++) { - child = (Node) elementList.item(indexN10057); - childType = (int) child.getNodeType(); - - if (equals(8, childType)) { - childName = child.getNodeName(); - assertEquals("nodeName", "#comment", childName); - childValue = child.getNodeValue(); - assertEquals("nodeValue", " This is comment number 1.", childValue); - commentCount = commentCount + 1; - } - } - assertEquals("commentCount", 1, commentCount); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/commentgetcomment"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(commentgetcomment.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateattribute.java deleted file mode 100644 index 5b7f528ce..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateattribute.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createAttribute(name)" method creates an Attribute - * node of the given name. - * - * Retrieve the entire DOM document and invoke its - * "createAttribute(name)" method. It should create a - * new Attribute node with the given name. The name, value - * and type of the newly created object are retrieved and - * output. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198 -*/ -public final class documentcreateattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreateattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr newAttrNode; - String attrValue; - String attrName; - int attrType; - doc = (Document) load("staff", true); - newAttrNode = doc.createAttribute("district"); - attrValue = newAttrNode.getNodeValue(); - assertEquals("value", "", attrValue); - attrName = newAttrNode.getNodeName(); - assertEquals("name", "district", attrName); - attrType = (int) newAttrNode.getNodeType(); - assertEquals("type", 2, attrType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentcreateattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreateattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreatecdatasection.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreatecdatasection.java deleted file mode 100644 index 412341e1e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreatecdatasection.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createCDATASection(data)" method creates a new - * CDATASection node whose value is the specified string. - * Retrieve the entire DOM document and invoke its - * "createCDATASection(data)" method. It should create a - * new CDATASection node whose "data" is the specified - * string. The content, name and type are retrieved and - * output. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D26C0AF8 -*/ -public final class documentcreatecdatasection extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreatecdatasection(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - CDATASection newCDATASectionNode; - String newCDATASectionValue; - String newCDATASectionName; - int newCDATASectionType; - doc = (Document) load("staff", true); - newCDATASectionNode = doc.createCDATASection("This is a new CDATASection node"); - newCDATASectionValue = newCDATASectionNode.getNodeValue(); - assertEquals("nodeValue", "This is a new CDATASection node", newCDATASectionValue); - newCDATASectionName = newCDATASectionNode.getNodeName(); - assertEquals("nodeName", "#cdata-section", newCDATASectionName); - newCDATASectionType = (int) newCDATASectionNode.getNodeType(); - assertEquals("nodeType", 4, newCDATASectionType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentcreatecdatasection"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreatecdatasection.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreatecomment.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreatecomment.java deleted file mode 100644 index 91583904a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreatecomment.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createComment(data)" method creates a new Comment - * node given the specified string. - * Retrieve the entire DOM document and invoke its - * "createComment(data)" method. It should create a new - * Comment node whose "data" is the specified string. - * The content, name and type are retrieved and output. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1334481328 -*/ -public final class documentcreatecomment extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreatecomment(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Comment newCommentNode; - String newCommentValue; - String newCommentName; - int newCommentType; - doc = (Document) load("staff", true); - newCommentNode = doc.createComment("This is a new Comment node"); - newCommentValue = newCommentNode.getNodeValue(); - assertEquals("value", "This is a new Comment node", newCommentValue); - newCommentName = newCommentNode.getNodeName(); - assertEquals("name", "#comment", newCommentName); - newCommentType = (int) newCommentNode.getNodeType(); - assertEquals("type", 8, newCommentType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentcreatecomment"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreatecomment.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreatedocumentfragment.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreatedocumentfragment.java deleted file mode 100644 index 2942abb52..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreatedocumentfragment.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createDocumentFragment()" method creates an empty - * DocumentFragment object. - * Retrieve the entire DOM document and invoke its - * "createDocumentFragment()" method. The content, name, - * type and value of the newly created object are output. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-35CB04B5 -*/ -public final class documentcreatedocumentfragment extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreatedocumentfragment(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentFragment newDocFragment; - NodeList children; - int length; - String newDocFragmentName; - int newDocFragmentType; - String newDocFragmentValue; - doc = (Document) load("staff", true); - newDocFragment = doc.createDocumentFragment(); - children = newDocFragment.getChildNodes(); - length = (int) children.getLength(); - assertEquals("length", 0, length); - newDocFragmentName = newDocFragment.getNodeName(); - assertEquals("name", "#document-fragment", newDocFragmentName); - newDocFragmentType = (int) newDocFragment.getNodeType(); - assertEquals("type", 11, newDocFragmentType); - newDocFragmentValue = newDocFragment.getNodeValue(); - assertNull("value", newDocFragmentValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentcreatedocumentfragment"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreatedocumentfragment.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateelement.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateelement.java deleted file mode 100644 index 69a339bb9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateelement.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createElement(tagName)" method creates an Element - * of the type specified. - * Retrieve the entire DOM document and invoke its - * "createElement(tagName)" method with tagName="address". - * The method should create an instance of an Element node - * whose tagName is "address". The NodeName, NodeType - * and NodeValue are returned. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547 -*/ -public final class documentcreateelement extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreateelement(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element newElement; - String newElementName; - int newElementType; - String newElementValue; - doc = (Document) load("staff", true); - newElement = doc.createElement("address"); - newElementName = newElement.getNodeName(); - assertEquals("name", "address", newElementName); - newElementType = (int) newElement.getNodeType(); - assertEquals("type", 1, newElementType); - newElementValue = newElement.getNodeValue(); - assertNull("valueInitiallyNull", newElementValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentcreateelement"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreateelement.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateelementcasesensitive.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateelementcasesensitive.java deleted file mode 100644 index 908e4586a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateelementcasesensitive.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The tagName parameter in the "createElement(tagName)" - * method is case-sensitive for XML documents. - * Retrieve the entire DOM document and invoke its - * "createElement(tagName)" method twice. Once for tagName - * equal to "address" and once for tagName equal to "ADDRESS" - * Each call should create a distinct Element node. The - * newly created Elements are then assigned attributes - * that are retrieved. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547 -*/ -public final class documentcreateelementcasesensitive extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreateelementcasesensitive(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element newElement1; - Element newElement2; - String attribute1; - String attribute2; - doc = (Document) load("staff", true); - newElement1 = doc.createElement("ADDRESS"); - newElement2 = doc.createElement("address"); - newElement1.setAttribute("district", "Fort Worth"); - newElement2.setAttribute("county", "Dallas"); - attribute1 = newElement1.getAttribute("district"); - attribute2 = newElement2.getAttribute("county"); - assertEquals("attrib1", "Fort Worth", attribute1); - assertEquals("attrib2", "Dallas", attribute2); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentcreateelementcasesensitive"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreateelementcasesensitive.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateelementdefaultattr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateelementdefaultattr.java deleted file mode 100644 index 7d7a97afb..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateelementdefaultattr.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createElement(tagName)" method creates an Element - * of the type specified. In addition, if there are known attributes - * with default values, Attr nodes representing them are automatically - * created and attached to the element. - * Retrieve the entire DOM document and invoke its - * "createElement(tagName)" method with tagName="address". - * The method should create an instance of an Element node - * whose tagName is "address". The tagName "address" has an - * attribute with default values, therefore the newly created element - * will have them. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html -*/ -public final class documentcreateelementdefaultattr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreateelementdefaultattr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element newElement; - NamedNodeMap defaultAttr; - Node child; - String name; - String value; - doc = (Document) load("staff", true); - newElement = doc.createElement("address"); - defaultAttr = newElement.getAttributes(); - child = defaultAttr.item(0); - assertNotNull("defaultAttrNotNull", child); - name = child.getNodeName(); - assertEquals("attrName", "street", name); - value = child.getNodeValue(); - assertEquals("attrValue", "Yes", value); - assertSize("attrCount", 1, defaultAttr); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentcreateelementdefaultattr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreateelementdefaultattr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateentityreference.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateentityreference.java deleted file mode 100644 index e6726afed..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateentityreference.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createEntityReference(name)" method creates an - * EntityReferrence node. - * - * Retrieve the entire DOM document and invoke its - * "createEntityReference(name)" method. It should create - * a new EntityReference node for the Entity with the - * given name. The name, value and type are retrieved and - * output. -* @author NIST -* @author Mary Brady -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-392B75AE -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -*/ -public final class documentcreateentityreference extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreateentityreference(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - EntityReference newEntRefNode; - String entRefValue; - String entRefName; - int entRefType; - doc = (Document) load("staff", true); - newEntRefNode = doc.createEntityReference("ent1"); - assertNotNull("createdEntRefNotNull", newEntRefNode); - entRefValue = newEntRefNode.getNodeValue(); - assertNull("value", entRefValue); - entRefName = newEntRefNode.getNodeName(); - assertEquals("name", "ent1", entRefName); - entRefType = (int) newEntRefNode.getNodeType(); - assertEquals("type", 5, entRefType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentcreateentityreference"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreateentityreference.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateentityreferenceknown.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateentityreferenceknown.java deleted file mode 100644 index 02f167ee3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateentityreferenceknown.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createEntityReference(name)" method creates an - * EntityReference node. In addition, if the referenced entity - * is known, the child list of the "EntityReference" node - * is the same as the corresponding "Entity" node. - * - * Retrieve the entire DOM document and invoke its - * "createEntityReference(name)" method. It should create - * a new EntityReference node for the Entity with the - * given name. The referenced entity is known, therefore the child - * list of the "EntityReference" node is the same as the corresponding - * "Entity" node. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-392B75AE -*/ -public final class documentcreateentityreferenceknown extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreateentityreferenceknown(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - EntityReference newEntRefNode; - NodeList newEntRefList; - Node child; - String name; - String value; - doc = (Document) load("staff", true); - newEntRefNode = doc.createEntityReference("ent3"); - assertNotNull("createdEntRefNotNull", newEntRefNode); - newEntRefList = newEntRefNode.getChildNodes(); - assertSize("size", 1, newEntRefList); - child = newEntRefNode.getFirstChild(); - name = child.getNodeName(); - assertEquals("name", "#text", name); - value = child.getNodeValue(); - assertEquals("value", "Texas", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentcreateentityreferenceknown"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreateentityreferenceknown.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateprocessinginstruction.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateprocessinginstruction.java deleted file mode 100644 index ad1d7b958..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreateprocessinginstruction.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createProcessingInstruction(target,data)" method - * creates a new ProcessingInstruction node with the - * specified name and data string. - * - * Retrieve the entire DOM document and invoke its - * "createProcessingInstruction(target,data)" method. - * It should create a new PI node with the specified target - * and data. The target, data and type are retrieved and - * output. -* @author NIST -* @author Mary Brady -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core# -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2001Apr/0020.html -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-135944439 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class documentcreateprocessinginstruction extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreateprocessinginstruction(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - ProcessingInstruction newPINode; - String piValue; - String piName; - int piType; - doc = (Document) load("staff", true); - newPINode = doc.createProcessingInstruction("TESTPI", "This is a new PI node"); - assertNotNull("createdPINotNull", newPINode); - piName = newPINode.getNodeName(); - assertEquals("name", "TESTPI", piName); - piValue = newPINode.getNodeValue(); - assertEquals("value", "This is a new PI node", piValue); - piType = (int) newPINode.getNodeType(); - assertEquals("type", 7, piType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentcreateprocessinginstruction"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreateprocessinginstruction.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreatetextnode.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreatetextnode.java deleted file mode 100644 index c5d9a6bc2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentcreatetextnode.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createTextNode(data)" method creates a Text node - * given the specfied string. - * Retrieve the entire DOM document and invoke its - * "createTextNode(data)" method. It should create a - * new Text node whose "data" is the specified string. - * The NodeName and NodeType are also checked. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1975348127 -*/ -public final class documentcreatetextnode extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreatetextnode(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Text newTextNode; - String newTextName; - String newTextValue; - int newTextType; - doc = (Document) load("staff", true); - newTextNode = doc.createTextNode("This is a new Text node"); - newTextValue = newTextNode.getNodeValue(); - assertEquals("value", "This is a new Text node", newTextValue); - newTextName = newTextNode.getNodeName(); - assertEquals("name", "#text", newTextName); - newTextType = (int) newTextNode.getNodeType(); - assertEquals("type", 3, newTextType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentcreatetextnode"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreatetextnode.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetdoctype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetdoctype.java deleted file mode 100644 index 40e237681..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetdoctype.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getDoctype()" method returns the Document - * Type Declaration associated with this document. - * Retrieve the entire DOM document and invoke its - * "getDoctype()" method. The name of the document - * type should be returned. The "getName()" method - * should be equal to "staff" or "svg". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class documentgetdoctype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentgetdoctype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - String docTypeName; - String nodeValue; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - docTypeName = docType.getName(); - - if (("image/svg+xml".equals(getContentType()))) { - assertEquals("doctypeNameSVG", "svg", docTypeName); - } else { - assertEquals("doctypeName", "staff", docTypeName); - } - - nodeValue = docType.getNodeValue(); - assertNull("initiallyNull", nodeValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentgetdoctype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentgetdoctype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetdoctypenodtd.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetdoctypenodtd.java deleted file mode 100644 index 554a78eeb..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetdoctypenodtd.java +++ /dev/null @@ -1,88 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getDoctype()" method returns null for XML documents - * without a document type declaration. - * Retrieve the XML document without a DTD and invoke the - * "getDoctype()" method. It should return null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31 -*/ -public final class documentgetdoctypenodtd extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentgetdoctypenodtd(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.notValidating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_nodtdstaff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - doc = (Document) load("hc_nodtdstaff", false); - docType = doc.getDoctype(); - assertNull("documentGetDocTypeNoDTDAssert", docType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentgetdoctypenodtd"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentgetdoctypenodtd.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetelementsbytagnamelength.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetelementsbytagnamelength.java deleted file mode 100644 index e06a2ff59..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetelementsbytagnamelength.java +++ /dev/null @@ -1,85 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagName(tagName)" method returns a - * NodeList of all the Elements with a given tagName. - * - * Retrieve the entire DOM document and invoke its - * "getElementsByTagName(tagName)" method with tagName - * equal to "name". The method should return a NodeList - * that contains 5 elements. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094 -*/ -public final class documentgetelementsbytagnamelength extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentgetelementsbytagnamelength(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList nameList; - doc = (Document) load("staff", false); - nameList = doc.getElementsByTagName("name"); - assertSize("documentGetElementsByTagNameLengthAssert", 5, nameList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentgetelementsbytagnamelength"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentgetelementsbytagnamelength.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetelementsbytagnametotallength.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetelementsbytagnametotallength.java deleted file mode 100644 index ecb029de8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetelementsbytagnametotallength.java +++ /dev/null @@ -1,86 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the entire DOM document, invoke - * getElementsByTagName("*") and check the length of the NodeList. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094 -*/ -public final class documentgetelementsbytagnametotallength extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentgetelementsbytagnametotallength(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList nameList; - doc = (Document) load("staff", false); - nameList = doc.getElementsByTagName("*"); - - if (("image/svg+xml".equals(getContentType()))) { - assertSize("elementCountSVG", 39, nameList); - } else { - assertSize("documentGetElementsByTagNameTotalLengthAssert", 37, nameList); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentgetelementsbytagnametotallength"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentgetelementsbytagnametotallength.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetelementsbytagnamevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetelementsbytagnamevalue.java deleted file mode 100644 index 05d154f4d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetelementsbytagnamevalue.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagName(tagName)" method returns a - * NodeList of all the Elements with a given tagName - * in a pre-order traversal of the tree. - * - * Retrieve the entire DOM document and invoke its - * "getElementsByTagName(tagName)" method with tagName - * equal to "name". The method should return a NodeList - * that contains 5 elements. The FOURTH item in the - * list is retrieved and output. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094 -*/ -public final class documentgetelementsbytagnamevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentgetelementsbytagnamevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList nameList; - Node nameNode; - Node firstChild; - String childValue; - doc = (Document) load("staff", false); - nameList = doc.getElementsByTagName("name"); - nameNode = nameList.item(3); - firstChild = nameNode.getFirstChild(); - childValue = firstChild.getNodeValue(); - assertEquals("documentGetElementsByTagNameValueAssert", "Jeny Oconnor", childValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentgetelementsbytagnamevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentgetelementsbytagnamevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetimplementation.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetimplementation.java deleted file mode 100644 index ada7c3039..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetimplementation.java +++ /dev/null @@ -1,86 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getImplementation()" method returns the - * DOMImplementation object that handles this document. - * Retrieve the entire DOM document and invoke its - * "getImplementation()" method. It should return a - * DOMImplementation whose "hasFeature("XML","1.0") - * method returns the boolean value "true". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1B793EBA -*/ -public final class documentgetimplementation extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentgetimplementation(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation docImpl; - boolean state; - doc = (Document) load("staff", false); - docImpl = doc.getImplementation(); - state = docImpl.hasFeature("XML", "1.0"); -assertTrue("documentGetImplementationAssert", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentgetimplementation"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentgetimplementation.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetrootnode.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetrootnode.java deleted file mode 100644 index e0711ed85..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentgetrootnode.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getDocumentElement()" method provides direct access - * to the child node that is the root element of the document. - * Retrieve the entire DOM document and invoke its - * "getDocumentElement()" method. It should return an - * Element node whose NodeName is "staff" (or "svg"). -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-87CD092 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251 -*/ -public final class documentgetrootnode extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentgetrootnode(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element root; - String rootName; - doc = (Document) load("staff", false); - root = doc.getDocumentElement(); - rootName = root.getNodeName(); - - if (("image/svg+xml".equals(getContentType()))) { - assertEquals("svgRootNode", "svg", rootName); - } else { - assertEquals("documentGetRootNodeAssert", "staff", rootName); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentgetrootnode"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentgetrootnode.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreateattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreateattribute.java deleted file mode 100644 index c8d9f0a8e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreateattribute.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createAttribute(tagName)" method raises an - * INVALID_CHARACTER_ERR DOMException if the specified - * tagName contains an invalid character. - * - * Retrieve the entire DOM document and invoke its - * "createAttribute(tagName)" method with the tagName equal - * to the string "invalid^Name". Due to the invalid - * character the desired EXCEPTION should be raised. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1084891198')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class documentinvalidcharacterexceptioncreateattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentinvalidcharacterexceptioncreateattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr createdAttr; - doc = (Document) load("staff", true); - - { - boolean success = false; - try { - createdAttr = doc.createAttribute("invalid^Name"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentinvalidcharacterexceptioncreateattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentinvalidcharacterexceptioncreateattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreateelement.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreateelement.java deleted file mode 100644 index 46459ea11..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreateelement.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createElement(tagName)" method raises an - * INVALID_CHARACTER_ERR DOMException if the specified - * tagName contains an invalid character. - * - * Retrieve the entire DOM document and invoke its - * "createElement(tagName)" method with the tagName equal - * to the string "invalid^Name". Due to the invalid - * character the desired EXCEPTION should be raised. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-2141741547')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class documentinvalidcharacterexceptioncreateelement extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentinvalidcharacterexceptioncreateelement(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element badElement; - doc = (Document) load("staff", true); - - { - boolean success = false; - try { - badElement = doc.createElement("invalid^Name"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentinvalidcharacterexceptioncreateelement"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentinvalidcharacterexceptioncreateelement.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreateentref.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreateentref.java deleted file mode 100644 index 1ebfb35d3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreateentref.java +++ /dev/null @@ -1,110 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createEntityReference(tagName)" method raises an - * INVALID_CHARACTER_ERR DOMException if the specified - * tagName contains an invalid character. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-392B75AE -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-392B75AE')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class documentinvalidcharacterexceptioncreateentref extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentinvalidcharacterexceptioncreateentref(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - if (factory.hasFeature("XML", null) != true) { - throw org.w3c.domts.DOMTestIncompatibleException.incompatibleFeature("XML", null); - } - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - EntityReference badEntityRef; - doc = (Document) load("hc_staff", true); - - if (("text/html".equals(getContentType()))) { - - { - boolean success = false; - try { - badEntityRef = doc.createEntityReference("foo"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_SUPPORTED_ERR); - } - assertTrue("throw_NOT_SUPPORTED_ERR", success); - } -} else { - - { - boolean success = false; - try { - badEntityRef = doc.createEntityReference("invalid^Name"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentinvalidcharacterexceptioncreateentref"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentinvalidcharacterexceptioncreateentref.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreateentref1.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreateentref1.java deleted file mode 100644 index 7185680e7..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreateentref1.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Creating an entity reference with an empty name should cause an INVALID_CHARACTER_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-392B75AE -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-392B75AE')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525 -*/ -public final class documentinvalidcharacterexceptioncreateentref1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentinvalidcharacterexceptioncreateentref1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - if (factory.hasFeature("XML", null) != true) { - throw org.w3c.domts.DOMTestIncompatibleException.incompatibleFeature("XML", null); - } - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - EntityReference badEntityRef; - doc = (Document) load("hc_staff", true); - - if (("text/html".equals(getContentType()))) { - - { - boolean success = false; - try { - badEntityRef = doc.createEntityReference("foo"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_SUPPORTED_ERR); - } - assertTrue("throw_NOT_SUPPORTED_ERR", success); - } -} else { - - { - boolean success = false; - try { - badEntityRef = doc.createEntityReference(""); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentinvalidcharacterexceptioncreateentref1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentinvalidcharacterexceptioncreateentref1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreatepi.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreatepi.java deleted file mode 100644 index ca4899649..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreatepi.java +++ /dev/null @@ -1,110 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createProcessingInstruction(target,data) method - * raises an INVALID_CHARACTER_ERR DOMException if the - * specified tagName contains an invalid character. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-135944439 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-135944439')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class documentinvalidcharacterexceptioncreatepi extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentinvalidcharacterexceptioncreatepi(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - if (factory.hasFeature("XML", null) != true) { - throw org.w3c.domts.DOMTestIncompatibleException.incompatibleFeature("XML", null); - } - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - ProcessingInstruction badPI; - doc = (Document) load("hc_staff", true); - - if (("text/html".equals(getContentType()))) { - - { - boolean success = false; - try { - badPI = doc.createProcessingInstruction("foo", "data"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_SUPPORTED_ERR); - } - assertTrue("throw_NOT_SUPPORTED_ERR", success); - } -} else { - - { - boolean success = false; - try { - badPI = doc.createProcessingInstruction("invalid^Name", "data"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentinvalidcharacterexceptioncreatepi"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentinvalidcharacterexceptioncreatepi.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreatepi1.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreatepi1.java deleted file mode 100644 index 7b97807b9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documentinvalidcharacterexceptioncreatepi1.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Creating a processing instruction with an empty target should cause an INVALID_CHARACTER_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-135944439 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-135944439')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525 -*/ -public final class documentinvalidcharacterexceptioncreatepi1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentinvalidcharacterexceptioncreatepi1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - if (factory.hasFeature("XML", null) != true) { - throw org.w3c.domts.DOMTestIncompatibleException.incompatibleFeature("XML", null); - } - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - ProcessingInstruction badPI; - doc = (Document) load("hc_staff", true); - - if (("text/html".equals(getContentType()))) { - - { - boolean success = false; - try { - badPI = doc.createProcessingInstruction("foo", "data"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_SUPPORTED_ERR); - } - assertTrue("throw_NOT_SUPPORTED_ERR", success); - } -} else { - - { - boolean success = false; - try { - badPI = doc.createProcessingInstruction("", "data"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentinvalidcharacterexceptioncreatepi1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentinvalidcharacterexceptioncreatepi1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetdoctype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetdoctype.java deleted file mode 100644 index 881d27b5c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetdoctype.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getName()" method contains the name of the DTD. - * - * Retrieve the Document Type for this document and examine - * the string returned by the "getName()" method. - * It should be set to "staff". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1844763134 -*/ -public final class documenttypegetdoctype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documenttypegetdoctype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - String name; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - name = docType.getName(); - - if (("image/svg+xml".equals(getContentType()))) { - assertEquals("doctypeName", "svg", name); - } else { - assertEquals("documenttypeGetDocTypeAssert", "staff", name); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documenttypegetdoctype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documenttypegetdoctype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetentities.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetentities.java deleted file mode 100644 index c34c66ed9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetentities.java +++ /dev/null @@ -1,120 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getEntities()" method is a NamedNodeMap that contains - * the general entities for this document. - * - * Retrieve the Document Type for this document and create - * a NamedNodeMap of all its entities. The entire map is - * traversed and the names of the entities are retrieved. - * There should be 5 entities. Duplicates should be ignored. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1788794630 -*/ -public final class documenttypegetentities extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documenttypegetentities(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap entityList; - String name; - java.util.Collection expectedResult = new java.util.ArrayList(); - expectedResult.add("ent1"); - expectedResult.add("ent2"); - expectedResult.add("ent3"); - expectedResult.add("ent4"); - expectedResult.add("ent5"); - - java.util.Collection expectedResultSVG = new java.util.ArrayList(); - expectedResultSVG.add("ent1"); - expectedResultSVG.add("ent2"); - expectedResultSVG.add("ent3"); - expectedResultSVG.add("ent4"); - expectedResultSVG.add("ent5"); - expectedResultSVG.add("svgunit"); - expectedResultSVG.add("svgtest"); - - java.util.Collection nameList = new java.util.ArrayList(); - - Node entity; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - entityList = docType.getEntities(); - assertNotNull("entitiesNotNull", entityList); - for (int indexN1007B = 0; indexN1007B < entityList.getLength(); indexN1007B++) { - entity = (Node) entityList.item(indexN1007B); - name = entity.getNodeName(); - nameList.add(name); - } - - if (("image/svg+xml".equals(getContentType()))) { - assertEquals("entityNamesSVG", expectedResultSVG, nameList); - } else { - assertEquals("entityNames", expectedResult, nameList); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documenttypegetentities"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documenttypegetentities.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetentitieslength.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetentitieslength.java deleted file mode 100644 index 3a4653408..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetentitieslength.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Duplicate entities are to be discarded. - * Retrieve the Document Type for this document and create - * a NamedNodeMap of all its entities. The entity named - * "ent1" is defined twice and therefore that last - * occurrance should be discarded. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1788794630 -*/ -public final class documenttypegetentitieslength extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documenttypegetentitieslength(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap entityList; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - entityList = docType.getEntities(); - assertNotNull("entitiesNotNull", entityList); - - if (("image/svg+xml".equals(getContentType()))) { - assertSize("entitySizeSVG", 7, entityList); - } else { - assertSize("entitySize", 5, entityList); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documenttypegetentitieslength"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documenttypegetentitieslength.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetentitiestype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetentitiestype.java deleted file mode 100644 index 347c9941c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetentitiestype.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Every node in the map returned by the "getEntities()" - * method implements the Entity interface. - * - * Retrieve the Document Type for this document and create - * a NamedNodeMap of all its entities. Traverse the - * entire list and examine the NodeType of each node - * in the list. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1788794630 -*/ -public final class documenttypegetentitiestype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documenttypegetentitiestype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap entityList; - Node entity; - int entityType; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - entityList = docType.getEntities(); - assertNotNull("entitiesNotNull", entityList); - for (int indexN10049 = 0; indexN10049 < entityList.getLength(); indexN10049++) { - entity = (Node) entityList.item(indexN10049); - entityType = (int) entity.getNodeType(); - assertEquals("documenttypeGetEntitiesTypeAssert", 6, entityType); - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documenttypegetentitiestype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documenttypegetentitiestype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetnotations.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetnotations.java deleted file mode 100644 index 579d656c2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetnotations.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNotations()" method creates a NamedNodeMap that - * contains all the notations declared in the DTD. - * - * Retrieve the Document Type for this document and create - * a NamedNodeMap object of all the notations. There - * should be two items in the list (notation1 and notation2). -* @author NIST -* @author Mary Brady -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D46829EF -*/ -public final class documenttypegetnotations extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documenttypegetnotations(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap notationList; - Node notation; - String notationName; - java.util.Collection actual = new java.util.ArrayList(); - - java.util.Collection expected = new java.util.ArrayList(); - expected.add("notation1"); - expected.add("notation2"); - - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - notationList = docType.getNotations(); - assertNotNull("notationsNotNull", notationList); - for (int indexN1005B = 0; indexN1005B < notationList.getLength(); indexN1005B++) { - notation = (Node) notationList.item(indexN1005B); - notationName = notation.getNodeName(); - actual.add(notationName); - } - assertEquals("names", expected, actual); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documenttypegetnotations"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documenttypegetnotations.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetnotationstype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetnotationstype.java deleted file mode 100644 index 251c84faa..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/documenttypegetnotationstype.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Every node in the map returned by the "getNotations()" - * method implements the Notation interface. - * - * Retrieve the Document Type for this document and create - * a NamedNodeMap object of all the notations. Traverse - * the entire list and examine the NodeType of each node. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D46829EF -*/ -public final class documenttypegetnotationstype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documenttypegetnotationstype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap notationList; - Node notation; - int notationType; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - notationList = docType.getNotations(); - assertNotNull("notationsNotNull", notationList); - for (int indexN10049 = 0; indexN10049 < notationList.getLength(); indexN10049++) { - notation = (Node) notationList.item(indexN10049); - notationType = (int) notation.getNodeType(); - assertEquals("documenttypeGetNotationsTypeAssert", 12, notationType); - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documenttypegetnotationstype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documenttypegetnotationstype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/domimplementationfeaturenoversion.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/domimplementationfeaturenoversion.java deleted file mode 100644 index 232b89487..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/domimplementationfeaturenoversion.java +++ /dev/null @@ -1,82 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * hasFeature("XML", "") should return true for implementations that can read staff files. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7 -* @see http://www.w3.org/2000/11/DOM-Level-2-errata#core-14 -*/ -public final class domimplementationfeaturenoversion extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public domimplementationfeaturenoversion(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation domImpl; - boolean state; - doc = (Document) load("staff", false); - domImpl = doc.getImplementation(); - state = domImpl.hasFeature("XML", ""); -assertTrue("hasXMLEmpty", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/domimplementationfeaturenoversion"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(domimplementationfeaturenoversion.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/domimplementationfeaturenull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/domimplementationfeaturenull.java deleted file mode 100644 index 88ed136e1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/domimplementationfeaturenull.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * hasFeature("XML", null) should return true for implementations that can read staff documents. -* @author NIST -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7 -* @see http://www.w3.org/2000/11/DOM-Level-2-errata#core-14 -*/ -public final class domimplementationfeaturenull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public domimplementationfeaturenull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.hasNullString - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation domImpl; - boolean state; - String nullVersion = null; - - doc = (Document) load("staff", false); - domImpl = doc.getImplementation(); - state = domImpl.hasFeature("XML", nullVersion); -assertTrue("hasXMLnull", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/domimplementationfeaturenull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(domimplementationfeaturenull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/domimplementationfeaturexml.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/domimplementationfeaturexml.java deleted file mode 100644 index c1cf63351..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/domimplementationfeaturexml.java +++ /dev/null @@ -1,81 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * hasFeature("xml", "1.0") should return true for implementations that can read staff documents. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7 -*/ -public final class domimplementationfeaturexml extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public domimplementationfeaturexml(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation domImpl; - boolean state; - doc = (Document) load("staff", false); - domImpl = doc.getImplementation(); - state = domImpl.hasFeature("xml", "1.0"); -assertTrue("hasXML1", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/domimplementationfeaturexml"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(domimplementationfeaturexml.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementaddnewattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementaddnewattribute.java deleted file mode 100644 index 7be482ba2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementaddnewattribute.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttribute(name,value)" method adds a new attribute - * to the Element - * - * Retrieve the last child of the last employee, then - * add an attribute to it by invoking the - * "setAttribute(name,value)" method. It should create - * a "name" attribute with an assigned value equal to - * "value". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082 -*/ -public final class elementaddnewattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementaddnewattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - String attrValue; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testEmployee = (Element) elementList.item(4); - testEmployee.setAttribute("district", "dallas"); - attrValue = testEmployee.getAttribute("district"); - assertEquals("elementAddNewAttributeAssert", "dallas", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementaddnewattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementaddnewattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementassociatedattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementassociatedattribute.java deleted file mode 100644 index b717e2ac9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementassociatedattribute.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Elements may have attributes associated with them. - * - * Retrieve the first attribute from the last child of - * the first employee and invoke the "getSpecified()" - * method. This test is only intended to show that - * Elements can actually have attributes. This test uses - * the "getNamedItem(name)" method from the NamedNodeMap - * interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -*/ -public final class elementassociatedattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementassociatedattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - NamedNodeMap attributes; - Attr domesticAttr; - boolean specified; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - testEmployee = elementList.item(0); - attributes = testEmployee.getAttributes(); - domesticAttr = (Attr) attributes.getNamedItem("domestic"); - specified = domesticAttr.getSpecified(); - assertTrue("domesticSpecified", specified); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementassociatedattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementassociatedattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementchangeattributevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementchangeattributevalue.java deleted file mode 100644 index ed487708a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementchangeattributevalue.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttribute(name,value)" method adds a new attribute - * to the Element. If the "name" is already present, then - * its value should be changed to the new one that is in - * the "value" parameter. - * - * Retrieve the last child of the fourth employee, then add - * an attribute to it by invoking the - * "setAttribute(name,value)" method. Since the name of the - * used attribute("street") is already present in this - * element, then its value should be changed to the new one - * of the "value" parameter. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082 -*/ -public final class elementchangeattributevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementchangeattributevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - String attrValue; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testEmployee = (Element) elementList.item(3); - testEmployee.setAttribute("street", "Neither"); - attrValue = testEmployee.getAttribute("street"); - assertEquals("elementChangeAttributeValueAssert", "Neither", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementchangeattributevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementchangeattributevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementcreatenewattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementcreatenewattribute.java deleted file mode 100644 index 2cb836493..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementcreatenewattribute.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNode(newAttr)" method adds a new - * attribute to the Element. - * - * Retrieve first address element and add - * a new attribute node to it by invoking its - * "setAttributeNode(newAttr)" method. This test makes use - * of the "createAttribute(name)" method from the Document - * interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 -*/ -public final class elementcreatenewattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementcreatenewattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddress; - Attr newAttribute; - Attr oldAttr; - Attr districtAttr; - String attrVal; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testAddress = (Element) elementList.item(0); - newAttribute = doc.createAttribute("district"); - oldAttr = testAddress.setAttributeNode(newAttribute); - assertNull("old_attr_doesnt_exist", oldAttr); - districtAttr = testAddress.getAttributeNode("district"); - assertNotNull("new_district_accessible", districtAttr); - attrVal = testAddress.getAttribute("district"); - assertEquals("attr_value", "", attrVal); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementcreatenewattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementcreatenewattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetattributenode.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetattributenode.java deleted file mode 100644 index 28c9f305f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetattributenode.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributeNode(name)" method retrieves an - * attribute node by name. - * - * Retrieve the attribute "domestic" from the last child - * of the first employee. Since the method returns an - * Attr object, the "name" can be examined to ensure the - * proper attribute was retrieved. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-217A91B8 -*/ -public final class elementgetattributenode extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementgetattributenode(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - Attr domesticAttr; - String name; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testEmployee = (Element) elementList.item(0); - domesticAttr = testEmployee.getAttributeNode("domestic"); - name = domesticAttr.getNodeName(); - assertEquals("elementGetAttributeNodeAssert", "domestic", name); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementgetattributenode"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementgetattributenode.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetattributenodenull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetattributenodenull.java deleted file mode 100644 index e5449f6c4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetattributenodenull.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributeNode(name)" method retrieves an - * attribute node by name. It should return null if the - * "name" attribute does not exist. - * - * Retrieve the last child of the first employee and attempt - * to retrieve a non-existing attribute. The method should - * return "null". The non-existing attribute to be used - * is "invalidAttribute". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-217A91B8 -*/ -public final class elementgetattributenodenull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementgetattributenodenull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - Attr domesticAttr; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testEmployee = (Element) elementList.item(0); - domesticAttr = testEmployee.getAttributeNode("invalidAttribute"); - assertNull("elementGetAttributeNodeNullAssert", domesticAttr); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementgetattributenodenull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementgetattributenodenull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementempty.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementempty.java deleted file mode 100644 index 79bb924ef..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementempty.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttribute(name)" method returns an empty - * string if no value was assigned to an attribute and - * no default value was given in the DTD file. - * - * Retrieve the last child of the last employee, then - * invoke "getAttribute(name)" method, where "name" is an - * attribute without a specified or DTD default value. - * The "getAttribute(name)" method should return the empty - * string. This method makes use of the - * "createAttribute(newAttr)" method from the Document - * interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-666EE0F9 -*/ -public final class elementgetelementempty extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementgetelementempty(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr newAttribute; - NodeList elementList; - Element testEmployee; - Attr domesticAttr; - String attrValue; - doc = (Document) load("staff", true); - newAttribute = doc.createAttribute("district"); - elementList = doc.getElementsByTagName("address"); - testEmployee = (Element) elementList.item(3); - domesticAttr = testEmployee.setAttributeNode(newAttribute); - attrValue = testEmployee.getAttribute("district"); - assertEquals("elementGetElementEmptyAssert", "", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementgetelementempty"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementgetelementempty.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementsbytagname.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementsbytagname.java deleted file mode 100644 index af8badacc..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementsbytagname.java +++ /dev/null @@ -1,86 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagName(name)" method returns a list - * of all descendant Elements with the given tag name. - * Test for an empty list. - * Create a NodeList of all the descendant elements - * using the string "noMatch" as the tagName. - * The method should return a NodeList whose length is - * "0" since there are not any descendant elements - * that match the given tag name. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D -*/ -public final class elementgetelementsbytagname extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementgetelementsbytagname(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - assertSize("elementGetElementsByTagNameAssert", 5, elementList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementgetelementsbytagname"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementgetelementsbytagname.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementsbytagnameaccessnodelist.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementsbytagnameaccessnodelist.java deleted file mode 100644 index 76721b007..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementsbytagnameaccessnodelist.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Element.getElementsByTagName("employee") should return a NodeList whose length is - * "5" in the order the children were encountered. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D -*/ -public final class elementgetelementsbytagnameaccessnodelist extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementgetelementsbytagnameaccessnodelist(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - Node child; - String childName; - String childValue; - int childType; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - testEmployee = (Element) elementList.item(3); - child = testEmployee.getFirstChild(); - childType = (int) child.getNodeType(); - - if (equals(3, childType)) { - child = child.getNextSibling(); - } - childName = child.getNodeName(); - assertEquals("nodename", "employeeId", childName); - child = child.getFirstChild(); - childValue = child.getNodeValue(); - assertEquals("emp0004", "EMP0004", childValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementgetelementsbytagnameaccessnodelist"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementgetelementsbytagnameaccessnodelist.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementsbytagnamenomatch.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementsbytagnamenomatch.java deleted file mode 100644 index a89d4dcd5..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementsbytagnamenomatch.java +++ /dev/null @@ -1,84 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagName(name)" method returns a list - * of all descendant Elements with the given tag name. - * Create a NodeList of all the descendant elements - * using the string "employee" as the tagName. - * The method should return a NodeList whose length is - * "5". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D -*/ -public final class elementgetelementsbytagnamenomatch extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementgetelementsbytagnamenomatch(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("noMatch"); - assertSize("elementGetElementsByTagNameNoMatchNoMatchAssert", 0, elementList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementgetelementsbytagnamenomatch"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementgetelementsbytagnamenomatch.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementsbytagnamespecialvalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementsbytagnamespecialvalue.java deleted file mode 100644 index 2a1b92755..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgetelementsbytagnamespecialvalue.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagName(name)" method may use the - * special value "*" to match all tags in the element - * tree. - * Create a NodeList of all the descendant elements - * of the last employee by using the special value "*". - * The method should return all the descendant children(6) - * in the order the children were encountered. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D -*/ -public final class elementgetelementsbytagnamespecialvalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementgetelementsbytagnamespecialvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element lastEmployee; - NodeList lastempList; - Node child; - String childName; - java.util.List result = new java.util.ArrayList(); - - java.util.List expectedResult = new java.util.ArrayList(); - expectedResult.add("employeeId"); - expectedResult.add("name"); - expectedResult.add("position"); - expectedResult.add("salary"); - expectedResult.add("gender"); - expectedResult.add("address"); - - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - lastEmployee = (Element) elementList.item(4); - lastempList = lastEmployee.getElementsByTagName("*"); - for (int indexN1006A = 0; indexN1006A < lastempList.getLength(); indexN1006A++) { - child = (Node) lastempList.item(indexN1006A); - childName = child.getNodeName(); - result.add(childName); - } - assertEquals("tagNames", expectedResult, result); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementgetelementsbytagnamespecialvalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementgetelementsbytagnamespecialvalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgettagname.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgettagname.java deleted file mode 100644 index 8fef87ff7..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementgettagname.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getTagName()" method returns the - * tagName of an element. - * - * Invoke the "getTagName()" method one the - * root node. The value returned should be "staff". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-104682815 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251 -*/ -public final class elementgettagname extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementgettagname(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element root; - String tagname; - doc = (Document) load("staff", false); - root = doc.getDocumentElement(); - tagname = root.getTagName(); - - if (("image/svg+xml".equals(getContentType()))) { - assertEquals("svgTagName", "svg", tagname); - } else { - assertEquals("elementGetTagNameAssert", "staff", tagname); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementgettagname"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementgettagname.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementinuseattributeerr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementinuseattributeerr.java deleted file mode 100644 index da60c7029..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementinuseattributeerr.java +++ /dev/null @@ -1,112 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNode(newAttr)" method raises an - * "INUSE_ATTRIBUTE_ERR DOMException if the "newAttr" - * is already an attribute of another element. - * - * Retrieve the last child of the second employee and append - * a newly created element. The "createAttribute(name)" - * and "setAttributeNode(newAttr)" methods are invoked - * to create and add a new attribute to the newly created - * Element. The "setAttributeNode(newAttr)" method is - * once again called to add the new attribute causing an - * exception to be raised since the attribute is already - * an attribute of another element. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-887236154')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR']) -*/ -public final class elementinuseattributeerr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementinuseattributeerr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr newAttribute; - NodeList addressElementList; - Element testAddress; - Element newElement; - Node appendedChild; - Attr setAttr1; - Attr setAttr2; - doc = (Document) load("staff", true); - addressElementList = doc.getElementsByTagName("address"); - testAddress = (Element) addressElementList.item(1); - newElement = doc.createElement("newElement"); - appendedChild = testAddress.appendChild(newElement); - newAttribute = doc.createAttribute("newAttribute"); - setAttr1 = newElement.setAttributeNode(newAttribute); - - { - boolean success = false; - try { - setAttr2 = testAddress.setAttributeNode(newAttribute); - } catch (DOMException ex) { - success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR); - } - assertTrue("throw_INUSE_ATTRIBUTE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementinuseattributeerr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementinuseattributeerr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementinvalidcharacterexception.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementinvalidcharacterexception.java deleted file mode 100644 index 651b48470..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementinvalidcharacterexception.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttribute(name,value)" method raises an - * "INVALID_CHARACTER_ERR DOMException if the specified - * name contains an invalid character. - * - * Retrieve the last child of the first employee and - * call its "setAttribute(name,value)" method with - * "name" containing an invalid character. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-F68F082')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class elementinvalidcharacterexception extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementinvalidcharacterexception(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddress; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testAddress = (Element) elementList.item(0); - - { - boolean success = false; - try { - testAddress.setAttribute("invalid^Name", "value"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementinvalidcharacterexception"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementinvalidcharacterexception.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementnormalize.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementnormalize.java deleted file mode 100644 index c73e7cdb1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementnormalize.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "normalize()" method puts all the nodes in the full - * depth of the sub-tree underneath this element into a - * "normal" form. - * - * Retrieve the third employee and access its second child. - * This child contains a block of text that is spread - * across multiple lines. The content of the "name" child - * should be parsed and treated as a single Text node. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-162CF083 -*/ -public final class elementnormalize extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementnormalize(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element root; - NodeList elementList; - Element testName; - Node firstChild; - String childValue; - doc = (Document) load("staff", true); - root = doc.getDocumentElement(); - root.normalize(); - elementList = root.getElementsByTagName("name"); - testName = (Element) elementList.item(2); - firstChild = testName.getFirstChild(); - childValue = firstChild.getNodeValue(); - assertEquals("elementNormalizeAssert", "Roger\n Jones", childValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementnormalize"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementnormalize.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementnotfounderr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementnotfounderr.java deleted file mode 100644 index 8413f6b97..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementnotfounderr.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeAttributeNode(oldAttr)" method raises a - * NOT_FOUND_ERR DOMException if the "oldAttr" attribute - * is not an attribute of the element. - * - * Retrieve the last employee and attempt to remove - * a non existing attribute node. This should cause the - * intended exception to be raised. This test makes use - * of the "createAttribute(name)" method from the Document - * interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-D589198')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class elementnotfounderr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementnotfounderr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr oldAttribute; - NodeList addressElementList; - Element testAddress; - Attr attrAddress; - doc = (Document) load("staff", true); - addressElementList = doc.getElementsByTagName("address"); - testAddress = (Element) addressElementList.item(4); - oldAttribute = doc.createAttribute("oldAttribute"); - - { - boolean success = false; - try { - attrAddress = testAddress.removeAttributeNode(oldAttribute); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_FOUND_ERR); - } - assertTrue("throw_NOT_FOUND_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementnotfounderr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementnotfounderr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattribute.java deleted file mode 100644 index da5411ba1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattribute.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeAttribute(name)" removes an attribute by name. - * If the attribute has a default value, it is immediately - * replaced. - * - * Retrieve the attribute named "street" from the last child - * of the fourth employee, then remove the "street" - * attribute by invoking the "removeAttribute(name)" method. - * The "street" attribute has a default value defined in the - * DTD file, that value should immediately replace the old - * value. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html -*/ -public final class elementremoveattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementremoveattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - String attrValue; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testEmployee = (Element) elementList.item(3); - testEmployee.removeAttribute("street"); - attrValue = testEmployee.getAttribute("street"); - assertEquals("streetYes", "Yes", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementremoveattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementremoveattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributeaftercreate.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributeaftercreate.java deleted file mode 100644 index e153f154d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributeaftercreate.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeAttributeNode(oldAttr)" method removes the - * specified attribute. - * - * Retrieve the last child of the third employee, add a - * new "district" node to it and then try to remove it. - * To verify that the node was removed use the - * "getNamedItem(name)" method from the NamedNodeMap - * interface. It also uses the "getAttributes()" method - * from the Node interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198 -*/ -public final class elementremoveattributeaftercreate extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementremoveattributeaftercreate(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - Attr newAttribute; - NamedNodeMap attributes; - Attr districtAttr; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testEmployee = (Element) elementList.item(2); - newAttribute = doc.createAttribute("district"); - districtAttr = testEmployee.setAttributeNode(newAttribute); - districtAttr = testEmployee.removeAttributeNode(newAttribute); - attributes = testEmployee.getAttributes(); - districtAttr = (Attr) attributes.getNamedItem("district"); - assertNull("elementRemoveAttributeAfterCreateAssert", districtAttr); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementremoveattributeaftercreate"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementremoveattributeaftercreate.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenode.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenode.java deleted file mode 100644 index 5b378bf43..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenode.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeAttributeNode(oldAttr)" method returns the - * node that was removed. - * - * Retrieve the last child of the third employee and - * remove its "street" Attr node. The method should - * return the old attribute node. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198 -*/ -public final class elementremoveattributenode extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementremoveattributenode(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - Attr streetAttr; - Attr removedAttr; - String removedValue; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testEmployee = (Element) elementList.item(2); - streetAttr = testEmployee.getAttributeNode("street"); - removedAttr = testEmployee.removeAttributeNode(streetAttr); - removedValue = removedAttr.getValue(); - assertEquals("elementRemoveAttributeNodeAssert", "No", removedValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementremoveattributenode"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementremoveattributenode.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenodenomodificationallowederr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenodenomodificationallowederr.java deleted file mode 100644 index 2d5b755d9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenodenomodificationallowederr.java +++ /dev/null @@ -1,122 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeAttributeNode(oldAttr)" method for an attribute causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Try to remove the "domestic" attribute - * from the entity reference by executing the "removeAttributeNode(oldAttr)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-D589198')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198 -*/ -public final class elementremoveattributenodenomodificationallowederr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementremoveattributenodenomodificationallowederr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node gender; - NodeList genList; - Node gen; - int nodeType; - NodeList gList; - Element genElement; - NamedNodeMap attrList; - Attr attrNode; - Attr removedAttr; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - gender = genderList.item(2); - genList = gender.getChildNodes(); - gen = genList.item(0); - assertNotNull("genNotNull", gen); - nodeType = (int) gen.getNodeType(); - - if (equals(1, nodeType)) { - gen = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", gen); - } - gList = gen.getChildNodes(); - genElement = (Element) gList.item(0); - assertNotNull("genElementNotNull", genElement); - attrList = genElement.getAttributes(); - attrNode = (Attr) attrList.getNamedItem("domestic"); - - { - boolean success = false; - try { - removedAttr = genElement.removeAttributeNode(attrNode); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementremoveattributenodenomodificationallowederr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementremoveattributenodenomodificationallowederr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenodenomodificationallowederrEE.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenodenomodificationallowederrEE.java deleted file mode 100644 index dc7d56321..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenodenomodificationallowederrEE.java +++ /dev/null @@ -1,115 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeAttributeNode(oldAttr)" method for an attribute causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Create an entity reference and add it to the children of the THIRD "gender" element. - * Try to remove the "domestic" attribute from the entity - * reference by executing the "removeAttributeNode(oldAttr)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-D589198')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198 -* @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementremoveattributenodenomodificationallowederr.xml -*/ -public final class elementremoveattributenodenomodificationallowederrEE extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementremoveattributenodenomodificationallowederrEE(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node gender; - EntityReference entRef; - Element entElement; - NamedNodeMap attrList; - Attr attrNode; - int nodeType; - Attr removedAttr; - Node appendedChild; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - gender = genderList.item(2); - entRef = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entRef); - appendedChild = gender.appendChild(entRef); - entElement = (Element) entRef.getFirstChild(); - assertNotNull("entElementNotNull", entElement); - attrList = entElement.getAttributes(); - attrNode = (Attr) attrList.getNamedItem("domestic"); - assertNotNull("attrNodeNotNull", attrNode); - - { - boolean success = false; - try { - removedAttr = entElement.removeAttributeNode(attrNode); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementremoveattributenodenomodificationallowederrEE"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementremoveattributenodenomodificationallowederrEE.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenomodificationallowederr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenomodificationallowederr.java deleted file mode 100644 index e4b93c4f1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenomodificationallowederr.java +++ /dev/null @@ -1,117 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeAttribute(name)" method for an attribute causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Try to remove the "domestic" attribute - * from the entity reference by executing the "removeAttribute(name)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6D6AC0F9')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9 -*/ -public final class elementremoveattributenomodificationallowederr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementremoveattributenomodificationallowederr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node gender; - NodeList genList; - Node gen; - NodeList gList; - int nodeType; - Element genElement; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - gender = genderList.item(2); - genList = gender.getChildNodes(); - gen = genList.item(0); - assertNotNull("genNotNull", gen); - nodeType = (int) gen.getNodeType(); - - if (equals(1, nodeType)) { - gen = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", gen); - } - gList = gen.getChildNodes(); - genElement = (Element) gList.item(0); - assertNotNull("genElementNotNull", genElement); - - { - boolean success = false; - try { - genElement.removeAttribute("domestic"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementremoveattributenomodificationallowederr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementremoveattributenomodificationallowederr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenomodificationallowederrEE.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenomodificationallowederrEE.java deleted file mode 100644 index 4bfb1a8b5..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributenomodificationallowederrEE.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeAttribute(name)" method for an attribute causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Create an reference the entity ent4 and add it to the THIRD "gender" element. - * Try to remove the "domestic" attribute from the entity reference by executing the "removeAttribute(name)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6D6AC0F9')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9 -* @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementremoveattributenomodificationallowederr.xml -*/ -public final class elementremoveattributenomodificationallowederrEE extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementremoveattributenomodificationallowederrEE(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node gender; - EntityReference entRef; - Element entElement; - Node appendedChild; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - gender = genderList.item(2); - entRef = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entRef); - appendedChild = gender.appendChild(entRef); - entElement = (Element) entRef.getFirstChild(); - assertNotNull("entElementNotNull", entElement); - - { - boolean success = false; - try { - entElement.removeAttribute("domestic"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementremoveattributenomodificationallowederrEE"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementremoveattributenomodificationallowederrEE.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributerestoredefaultvalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributerestoredefaultvalue.java deleted file mode 100644 index bbe52beed..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementremoveattributerestoredefaultvalue.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeAttributeNode(oldAttr)" method removes the - * specified attribute node and restores any default values. - * - * Retrieve the last child of the third employeed and - * remove its "street" Attr node. Since this node has a - * default value defined in the DTD file, that default - * should immediately be the new value. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html -*/ -public final class elementremoveattributerestoredefaultvalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementremoveattributerestoredefaultvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - Attr streetAttr; - String attribute; - Attr removedAttr; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testEmployee = (Element) elementList.item(2); - streetAttr = testEmployee.getAttributeNode("street"); - removedAttr = testEmployee.removeAttributeNode(streetAttr); - attribute = testEmployee.getAttribute("street"); - assertEquals("streetYes", "Yes", attribute); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementremoveattributerestoredefaultvalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementremoveattributerestoredefaultvalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementreplaceattributewithself.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementreplaceattributewithself.java deleted file mode 100644 index 0d029b5bd..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementreplaceattributewithself.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * This test calls setAttributeNode to replace an attribute with itself. - * Since the node is not an attribute of another Element, it would - * be inappropriate to throw an INUSE_ATTRIBUTE_ERR. - * This test was derived from elementinuserattributeerr which - * inadvertanly made this test. -* @author Curt Arnold -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 -*/ -public final class elementreplaceattributewithself extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementreplaceattributewithself(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - Attr streetAttr; - Attr replacedAttr; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testEmployee = (Element) elementList.item(2); - streetAttr = testEmployee.getAttributeNode("street"); - replacedAttr = testEmployee.setAttributeNode(streetAttr); - assertSame("replacedAttr", streetAttr, replacedAttr); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementreplaceattributewithself"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementreplaceattributewithself.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementreplaceexistingattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementreplaceexistingattribute.java deleted file mode 100644 index 99fbcdfac..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementreplaceexistingattribute.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNode(newAttr)" method adds a new - * attribute to the Element. If the "newAttr" Attr node is - * already present in this element, it should replace the - * existing one. - * - * Retrieve the last child of the third employee and add a - * new attribute node by invoking the "setAttributeNode(new - * Attr)" method. The new attribute node to be added is - * "street", which is already present in this element. The - * method should replace the existing Attr node with the - * new one. This test uses the "createAttribute(name)" - * method from the Document interface. -* @author NIST -* @author Mary Brady -*/ -public final class elementreplaceexistingattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementreplaceexistingattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - Attr newAttribute; - String name; - Attr setAttr; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testEmployee = (Element) elementList.item(2); - newAttribute = doc.createAttribute("street"); - setAttr = testEmployee.setAttributeNode(newAttribute); - name = testEmployee.getAttribute("street"); - assertEquals("elementReplaceExistingAttributeAssert", "", name); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementreplaceexistingattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementreplaceexistingattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementreplaceexistingattributegevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementreplaceexistingattributegevalue.java deleted file mode 100644 index 47b4ff294..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementreplaceexistingattributegevalue.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the "setAttributeNode(newAttr)" method replaces an - * existing Attr node with the same name, then it should - * return the previously existing Attr node. - * Retrieve the last child of the third employee and add a - * new attribute node. The new attribute node is "street", - * which is already present in this Element. The method - * should return the existing Attr node(old "street" Attr). - * This test uses the "createAttribute(name)" method - * from the Document interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 -*/ -public final class elementreplaceexistingattributegevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementreplaceexistingattributegevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - Attr newAttribute; - Attr streetAttr; - String value; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testEmployee = (Element) elementList.item(2); - newAttribute = doc.createAttribute("street"); - streetAttr = testEmployee.setAttributeNode(newAttribute); - value = streetAttr.getValue(); - assertEquals("streetNo", "No", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementreplaceexistingattributegevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementreplaceexistingattributegevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementretrieveallattributes.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementretrieveallattributes.java deleted file mode 100644 index b654c01ce..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementretrieveallattributes.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributes()" method(Node Interface) may - * be used to retrieve the set of all attributes of an - * element. - * - * Create a list of all the attributes of the last child - * of the first employee by using the "getAttributes()" - * method. Examine the length of the attribute list. - * This test uses the "getLength()" method from the - * NameNodeMap interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html -*/ -public final class elementretrieveallattributes extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementretrieveallattributes(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testAddress; - NamedNodeMap attributes; - doc = (Document) load("staff", false); - addressList = doc.getElementsByTagName("address"); - testAddress = addressList.item(0); - attributes = testAddress.getAttributes(); - assertSize("elementRetrieveAllAttributesAssert", 2, attributes); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementretrieveallattributes"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementretrieveallattributes.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementretrieveattrvalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementretrieveattrvalue.java deleted file mode 100644 index ca465ded7..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementretrieveattrvalue.java +++ /dev/null @@ -1,88 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttribute(name)" method returns an attribute - * value by name. - * - * Retrieve the second address element, then - * invoke the 'getAttribute("street")' method. This should - * return the value of the attribute("No"). -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-666EE0F9 -*/ -public final class elementretrieveattrvalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementretrieveattrvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddress; - String attrValue; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - testAddress = (Element) elementList.item(2); - attrValue = testAddress.getAttribute("street"); - assertEquals("attrValue", "No", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementretrieveattrvalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementretrieveattrvalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementretrievetagname.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementretrievetagname.java deleted file mode 100644 index 05739192c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementretrievetagname.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagName()" method returns a NodeList - * of all descendant elements with a given tagName. - * - * Invoke the "getElementsByTagName()" method and create - * a NodeList of "position" elements. Retrieve the second - * "position" element in the list and return the NodeName. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-104682815 -*/ -public final class elementretrievetagname extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementretrievetagname(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - String name; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("position"); - testEmployee = elementList.item(1); - name = testEmployee.getNodeName(); - assertEquals("nodename", "position", name); - name = ((Element) /*Node */testEmployee).getTagName(); - assertEquals("tagname", "position", name); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementretrievetagname"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementretrievetagname.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenodenomodificationallowederr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenodenomodificationallowederr.java deleted file mode 100644 index f9c9304bf..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenodenomodificationallowederr.java +++ /dev/null @@ -1,116 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNode(newAttr)" method for an attribute causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Try to remove the "domestic" attribute - * from the entity reference by executing the "setAttributeNode(newAttr)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-887236154')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 -*/ -public final class elementsetattributenodenomodificationallowederr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementsetattributenodenomodificationallowederr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node gender; - Node entRef; - Element entElement; - Attr newAttr; - int nodeType; - Attr badAttr; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - gender = genderList.item(2); - entRef = gender.getFirstChild(); - assertNotNull("entRefNotNull", entRef); - nodeType = (int) entRef.getNodeType(); - - if (equals(1, nodeType)) { - entRef = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entRef); - } - entElement = (Element) entRef.getFirstChild(); - assertNotNull("entElementNotNull", entElement); - newAttr = doc.createAttribute("newAttr"); - - { - boolean success = false; - try { - badAttr = entElement.setAttributeNode(newAttr); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementsetattributenodenomodificationallowederr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementsetattributenodenomodificationallowederr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenodenomodificationallowederrEE.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenodenomodificationallowederrEE.java deleted file mode 100644 index e6970f29e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenodenomodificationallowederrEE.java +++ /dev/null @@ -1,117 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNode(newAttr)" method for an attribute causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Create an entity reference and add to the THIRD "gender" element. The elements - * content is an entity reference. Try to remove the "domestic" attribute - * from the entity reference by executing the "setAttributeNode(newAttr)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-887236154')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 -* @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementsetattributenodenomodificationallowederr.xml -*/ -public final class elementsetattributenodenomodificationallowederrEE extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementsetattributenodenomodificationallowederrEE(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.notExpandEntityReferences - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node gender; - EntityReference entRef; - Element entElement; - Attr newAttr; - Attr badAttr; - Node appendedChild; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - gender = genderList.item(2); - entRef = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entRef); - appendedChild = gender.appendChild(entRef); - entElement = (Element) entRef.getFirstChild(); - assertNotNull("entElementNotNull", entElement); - newAttr = doc.createAttribute("newAttr"); - - { - boolean success = false; - try { - badAttr = entElement.setAttributeNode(newAttr); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementsetattributenodenomodificationallowederrEE"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementsetattributenodenomodificationallowederrEE.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenodenull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenodenull.java deleted file mode 100644 index 55f5bcdf5..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenodenull.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNode(newAttr)" method returns the - * null value if no previously existing Attr node with the - * same name was replaced. - * - * Retrieve the last child of the third employee and add a - * new attribute to it. The new attribute node added is - * "district", which is not part of this Element. The - * method should return the null value. - * This test uses the "createAttribute(name)" - * method from the Document interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 -*/ -public final class elementsetattributenodenull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementsetattributenodenull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - Attr newAttribute; - Attr districtAttr; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testEmployee = (Element) elementList.item(2); - newAttribute = doc.createAttribute("district"); - districtAttr = testEmployee.setAttributeNode(newAttribute); - assertNull("elementSetAttributeNodeNullAssert", districtAttr); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementsetattributenodenull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementsetattributenodenull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenomodificationallowederr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenomodificationallowederr.java deleted file mode 100644 index ce01fe2bf..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenomodificationallowederr.java +++ /dev/null @@ -1,112 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttribute(name,value)" method for an attribute causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Try to remove the "domestic" attribute - * from the entity reference by executing the "setAttribute(name,value)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-F68F082')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082 -*/ -public final class elementsetattributenomodificationallowederr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementsetattributenomodificationallowederr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.notExpandEntityReferences - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node gender; - EntityReference entRef; - Element entElement; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - gender = genderList.item(2); - entRef = (EntityReference) gender.getFirstChild(); - assertNotNull("entRefNotNull", entRef); - entElement = (Element) entRef.getFirstChild(); - assertNotNull("entElementNotNull", entElement); - - { - boolean success = false; - try { - entElement.setAttribute("newAttr", "newValue"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementsetattributenomodificationallowederr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementsetattributenomodificationallowederr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenomodificationallowederrEE.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenomodificationallowederrEE.java deleted file mode 100644 index e2bccb1a2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementsetattributenomodificationallowederrEE.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttribute(name,value)" method for an attribute causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Add an ent4 reference to the children of the THIRD "gender" element. - * Try to remove the "domestic" attribute - * from the entity reference by executing the "setAttribute(name,value)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-F68F082')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082 -* @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementsetattributenomodificationallowederr.xml -*/ -public final class elementsetattributenomodificationallowederrEE extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementsetattributenomodificationallowederrEE(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node gender; - EntityReference entRef; - Element entElement; - Node appendedChild; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - gender = genderList.item(2); - entRef = doc.createEntityReference("ent4"); - appendedChild = gender.appendChild(entRef); - entElement = (Element) entRef.getFirstChild(); - assertNotNull("entElementNotNull", entElement); - - { - boolean success = false; - try { - entElement.setAttribute("newAttr", "newValue"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementsetattributenomodificationallowederrEE"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementsetattributenomodificationallowederrEE.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementwrongdocumenterr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementwrongdocumenterr.java deleted file mode 100644 index ec1a50b86..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/elementwrongdocumenterr.java +++ /dev/null @@ -1,110 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNode(newAttr)" method raises an - * "WRONG_DOCUMENT_ERR DOMException if the "newAttr" - * was created from a different document than the one that - * created this document. - * - * Retrieve the last employee and attempt to set a new - * attribute node for its "employee" element. The new - * attribute was created from a document other than the - * one that created this element, therefore a - * WRONG_DOCUMENT_ERR DOMException should be raised. - * This test uses the "createAttribute(newAttr)" method - * from the Document interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-887236154')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class elementwrongdocumenterr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementwrongdocumenterr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc1; - Document doc2; - Attr newAttribute; - NodeList addressElementList; - Element testAddress; - Attr attrAddress; - doc1 = (Document) load("staff", true); - doc2 = (Document) load("staff", false); - newAttribute = doc2.createAttribute("newAttribute"); - addressElementList = doc1.getElementsByTagName("address"); - testAddress = (Element) addressElementList.item(4); - - { - boolean success = false; - try { - attrAddress = testAddress.setAttributeNode(newAttribute); - } catch (DOMException ex) { - success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); - } - assertTrue("throw_WRONG_DOCUMENT_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementwrongdocumenterr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementwrongdocumenterr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/entitygetentityname.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/entitygetentityname.java deleted file mode 100644 index fe06dc493..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/entitygetentityname.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The nodeName attribute that is inherited from Node - * contains the name of the entity. - * - * Retrieve the entity named "ent1" and access its name by - * invoking the "getNodeName()" method inherited from - * the Node interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-527DCFF2 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -*/ -public final class entitygetentityname extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public entitygetentityname(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap entityList; - Entity entityNode; - String entityName; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - entityList = docType.getEntities(); - assertNotNull("entitiesNotNull", entityList); - entityNode = (Entity) entityList.getNamedItem("ent1"); - entityName = entityNode.getNodeName(); - assertEquals("entityGetEntityNameAssert", "ent1", entityName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/entitygetentityname"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(entitygetentityname.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/entitygetpublicid.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/entitygetpublicid.java deleted file mode 100644 index 5e1e87c0f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/entitygetpublicid.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getPublicId()" method of an Entity node contains - * the public identifier associated with the entity, if - * one was specified. - * - * Retrieve the entity named "ent5" and access its - * public identifier. The string "entityURI" should be - * returned. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D7303025 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6ABAEB38 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D7C29F3E -*/ -public final class entitygetpublicid extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public entitygetpublicid(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap entityList; - Entity entityNode; - String publicId; - String systemId; - String notation; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - entityList = docType.getEntities(); - assertNotNull("entitiesNotNull", entityList); - entityNode = (Entity) entityList.getNamedItem("ent5"); - publicId = entityNode.getPublicId(); - assertEquals("publicId", "entityURI", publicId); - systemId = entityNode.getSystemId(); - assertURIEquals("systemId", null, null, null, "entityFile", null, null, null, null, systemId); -notation = entityNode.getNotationName(); - assertEquals("notation", "notation1", notation); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/entitygetpublicid"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(entitygetpublicid.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/entitygetpublicidnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/entitygetpublicidnull.java deleted file mode 100644 index f50d54f0b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/entitygetpublicidnull.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getPublicId()" method of an Entity node contains - * the public identifier associated with the entity, if - * one was not specified a null value should be returned. - * - * Retrieve the entity named "ent1" and access its - * public identifier. Since a public identifier was not - * specified for this entity, the "getPublicId()" method - * should return null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D7303025 -*/ -public final class entitygetpublicidnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public entitygetpublicidnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap entityList; - Entity entityNode; - String publicId; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - entityList = docType.getEntities(); - assertNotNull("entitiesNotNull", entityList); - entityNode = (Entity) entityList.getNamedItem("ent1"); - publicId = entityNode.getPublicId(); - assertNull("entityGetPublicIdNullAssert", publicId); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/entitygetpublicidnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(entitygetpublicidnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild1.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild1.java deleted file mode 100644 index 7d3e69640..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild1.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Appends a text node to an attribute and checks if the value of - * the attribute is changed. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -*/ -public final class hc_attrappendchild1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrappendchild1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text textNode; - Node retval; - Node lastChild; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - textNode = doc.createTextNode("terday"); - retval = titleAttr.appendChild(textNode); - value = titleAttr.getValue(); - assertEquals("attrValue", "Yesterday", value); - value = titleAttr.getNodeValue(); - assertEquals("attrNodeValue", "Yesterday", value); - value = retval.getNodeValue(); - assertEquals("retvalValue", "terday", value); - lastChild = titleAttr.getLastChild(); - value = lastChild.getNodeValue(); - assertEquals("lastChildValue", "terday", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrappendchild1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrappendchild1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild2.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild2.java deleted file mode 100644 index c619ed83d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild2.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Attempts to append an element to the child nodes of an attribute. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -*/ -public final class hc_attrappendchild2 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrappendchild2(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Node newChild; - Node retval; - Node lastChild; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - newChild = doc.createElement("terday"); - - { - boolean success = false; - try { - retval = titleAttr.appendChild(newChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR); - } - assertTrue("throw_HIERARCHY_REQUEST_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrappendchild2"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrappendchild2.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild3.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild3.java deleted file mode 100644 index 3fa01ca5a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild3.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Appends a document fragment to an attribute and checks if the value of - * the attribute is changed. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -*/ -public final class hc_attrappendchild3 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrappendchild3(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text terNode; - Text dayNode; - Node retval; - Node lastChild; - DocumentFragment docFrag; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - terNode = doc.createTextNode("ter"); - dayNode = doc.createTextNode("day"); - docFrag = doc.createDocumentFragment(); - retval = docFrag.appendChild(terNode); - retval = docFrag.appendChild(dayNode); - retval = titleAttr.appendChild(docFrag); - value = titleAttr.getValue(); - assertEquals("attrValue", "Yesterday", value); - value = titleAttr.getNodeValue(); - assertEquals("attrNodeValue", "Yesterday", value); - value = retval.getNodeValue(); - assertNull("retvalValue", value); - lastChild = titleAttr.getLastChild(); - value = lastChild.getNodeValue(); - assertEquals("lastChildValue", "day", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrappendchild3"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrappendchild3.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild4.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild4.java deleted file mode 100644 index 6b74ebfe8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild4.java +++ /dev/null @@ -1,118 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Attempt to append a CDATASection to an attribute which should result - * in a HIERARCHY_REQUEST_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -*/ -public final class hc_attrappendchild4 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrappendchild4(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - if (factory.hasFeature("XML", null) != true) { - throw org.w3c.domts.DOMTestIncompatibleException.incompatibleFeature("XML", null); - } - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Node textNode; - Node retval; - Node lastChild; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - - if (("text/html".equals(getContentType()))) { - - { - boolean success = false; - try { - textNode = doc.createCDATASection("terday"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_SUPPORTED_ERR); - } - assertTrue("throw_NOT_SUPPORTED_ERR", success); - } -} else { - textNode = doc.createCDATASection("terday"); - - { - boolean success = false; - try { - retval = titleAttr.appendChild(textNode); - } catch (DOMException ex) { - success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR); - } - assertTrue("throw_HIERARCHY_REQUEST_ERR", success); - } -} - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrappendchild4"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrappendchild4.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild5.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild5.java deleted file mode 100644 index 26846e132..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild5.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Attempt to append a node from another document to an attribute which should result - * in a WRONG_DOCUMENT_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -*/ -public final class hc_attrappendchild5 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrappendchild5(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Node textNode; - Node retval; - Node lastChild; - Document otherDoc; - doc = (Document) load("hc_staff", true); - otherDoc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - textNode = otherDoc.createTextNode("terday"); - - { - boolean success = false; - try { - retval = titleAttr.appendChild(textNode); - } catch (DOMException ex) { - success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); - } - assertTrue("throw_WRONG_DOCUMENT_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrappendchild5"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrappendchild5.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild6.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild6.java deleted file mode 100644 index 754ba2b0b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrappendchild6.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Creates an new attribute node and appends a text node. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -*/ -public final class hc_attrappendchild6 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrappendchild6(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text textNode; - Node retval; - Node lastChild; - doc = (Document) load("hc_staff", true); - titleAttr = doc.createAttribute("title"); - textNode = doc.createTextNode("Yesterday"); - retval = titleAttr.appendChild(textNode); - value = titleAttr.getValue(); - assertEquals("attrValue", "Yesterday", value); - value = titleAttr.getNodeValue(); - assertEquals("attrNodeValue", "Yesterday", value); - value = retval.getNodeValue(); - assertEquals("retvalValue", "Yesterday", value); - lastChild = titleAttr.getLastChild(); - value = lastChild.getNodeValue(); - assertEquals("lastChildValue", "Yesterday", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrappendchild6"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrappendchild6.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrchildnodes1.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrchildnodes1.java deleted file mode 100644 index ab38fbb69..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrchildnodes1.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Checks that Node.childNodes for an attribute node contains - * the expected text node. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987 -*/ -public final class hc_attrchildnodes1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrchildnodes1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text textNode; - NodeList childNodes; - doc = (Document) load("hc_staff", false); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - childNodes = titleAttr.getChildNodes(); - assertSize("childNodesSize", 1, childNodes); - textNode = (Text) childNodes.item(0); - value = textNode.getNodeValue(); - assertEquals("child1IsYes", "Yes", value); - textNode = (Text) childNodes.item(1); - assertNull("secondItemIsNull", textNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrchildnodes1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrchildnodes1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrchildnodes2.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrchildnodes2.java deleted file mode 100644 index 425177a09..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrchildnodes2.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Checks Node.childNodes for an attribute with multiple child nodes. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987 -*/ -public final class hc_attrchildnodes2 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrchildnodes2(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text textNode; - NodeList childNodes; - Node retval; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - childNodes = titleAttr.getChildNodes(); - textNode = doc.createTextNode("terday"); - retval = titleAttr.appendChild(textNode); - assertSize("childNodesSize", 2, childNodes); - textNode = (Text) childNodes.item(0); - value = textNode.getNodeValue(); - assertEquals("child1IsYes", "Yes", value); - textNode = (Text) childNodes.item(1); - value = textNode.getNodeValue(); - assertEquals("child2IsTerday", "terday", value); - textNode = (Text) childNodes.item(2); - assertNull("thirdItemIsNull", textNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrchildnodes2"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrchildnodes2.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrclonenode1.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrclonenode1.java deleted file mode 100644 index c38a6739b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrclonenode1.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Appends a text node to an attribute and clones the node. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4 -*/ -public final class hc_attrclonenode1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrclonenode1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text textNode; - Node retval; - Node lastChild; - Attr clonedTitle; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - textNode = doc.createTextNode("terday"); - retval = titleAttr.appendChild(textNode); - clonedTitle = (Attr) titleAttr.cloneNode(false); - textNode.setNodeValue("text_node_not_cloned"); - value = clonedTitle.getValue(); - assertEquals("attrValue", "Yesterday", value); - value = clonedTitle.getNodeValue(); - assertEquals("attrNodeValue", "Yesterday", value); - lastChild = clonedTitle.getLastChild(); - value = lastChild.getNodeValue(); - assertEquals("lastChildValue", "terday", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrclonenode1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrclonenode1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrcreatedocumentfragment.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrcreatedocumentfragment.java deleted file mode 100644 index be44465a4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrcreatedocumentfragment.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Create a new DocumentFragment and add a newly created Element node(with one attribute). - * Once the element is added, its attribute should be available as an attribute associated - * with an Element within a DocumentFragment. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-35CB04B5 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184 -*/ -public final class hc_attrcreatedocumentfragment extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrcreatedocumentfragment(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentFragment docFragment; - Element newOne; - Node domesticNode; - NamedNodeMap attributes; - Attr attribute; - String attrName; - Node appendedChild; - int langAttrCount = 0; - doc = (Document) load("hc_staff", true); - docFragment = doc.createDocumentFragment(); - newOne = doc.createElement("html"); - newOne.setAttribute("lang", "EN"); - appendedChild = docFragment.appendChild(newOne); - domesticNode = docFragment.getFirstChild(); - attributes = domesticNode.getAttributes(); - for (int indexN10078 = 0; indexN10078 < attributes.getLength(); indexN10078++) { - attribute = (Attr) attributes.item(indexN10078); - attrName = attribute.getNodeName(); - - if (equalsAutoCase("attribute", "lang", attrName)) { - langAttrCount += 1; - } - } - assertEquals("hasLangAttr", 1, langAttrCount); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrcreatedocumentfragment"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrcreatedocumentfragment.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrcreatetextnode.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrcreatetextnode.java deleted file mode 100644 index 20eb5da35..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrcreatetextnode.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setValue()" method for an attribute creates a - * Text node with the unparsed content of the string. - * Retrieve the attribute named "class" from the last - * child of of the fourth employee and assign the "Y&ent1;" - * string to its value attribute. This value is not yet - * parsed and therefore should still be the same upon - * retrieval. This test uses the "getNamedItem(name)" method - * from the NamedNodeMap interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Apr/0057.html -*/ -public final class hc_attrcreatetextnode extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrcreatetextnode(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr streetAttr; - String value; - doc = (Document) load("hc_staff", true); - addressList = doc.getElementsByTagName("acronym"); - testNode = addressList.item(3); - attributes = testNode.getAttributes(); - streetAttr = (Attr) attributes.getNamedItem("class"); - streetAttr.setValue("Y&ent1;"); - value = streetAttr.getValue(); - assertEquals("value", "Y&ent1;", value); - value = streetAttr.getNodeValue(); - assertEquals("nodeValue", "Y&ent1;", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrcreatetextnode"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrcreatetextnode.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrcreatetextnode2.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrcreatetextnode2.java deleted file mode 100644 index f487d69df..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrcreatetextnode2.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setNodeValue()" method for an attribute creates a - * Text node with the unparsed content of the string. - * Retrieve the attribute named "class" from the last - * child of of the fourth employee and assign the "Y&ent1;" - * string to its value attribute. This value is not yet - * parsed and therefore should still be the same upon - * retrieval. This test uses the "getNamedItem(name)" method - * from the NamedNodeMap interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Apr/0057.html -*/ -public final class hc_attrcreatetextnode2 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrcreatetextnode2(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr streetAttr; - String value; - doc = (Document) load("hc_staff", true); - addressList = doc.getElementsByTagName("acronym"); - testNode = addressList.item(3); - attributes = testNode.getAttributes(); - streetAttr = (Attr) attributes.getNamedItem("class"); - streetAttr.setNodeValue("Y&ent1;"); - value = streetAttr.getValue(); - assertEquals("value", "Y&ent1;", value); - value = streetAttr.getNodeValue(); - assertEquals("nodeValue", "Y&ent1;", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrcreatetextnode2"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrcreatetextnode2.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attreffectivevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attreffectivevalue.java deleted file mode 100644 index d90944b40..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attreffectivevalue.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If an Attr is explicitly assigned any value, then that value is the attributes effective value. - * Retrieve the attribute named "domestic" from the last child of of the first employee - * and examine its nodeValue attribute. This test uses the "getNamedItem(name)" method - * from the NamedNodeMap interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549 -*/ -public final class hc_attreffectivevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attreffectivevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr domesticAttr; - String value; - doc = (Document) load("hc_staff", false); - addressList = doc.getElementsByTagName("acronym"); - testNode = addressList.item(0); - attributes = testNode.getAttributes(); - domesticAttr = (Attr) attributes.getNamedItem("title"); - value = domesticAttr.getNodeValue(); - assertEquals("attrEffectiveValueAssert", "Yes", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attreffectivevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attreffectivevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrfirstchild.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrfirstchild.java deleted file mode 100644 index e7da3b8a8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrfirstchild.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Checks that Node.firstChild for an attribute node contains - * the expected text node. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-169727388 -*/ -public final class hc_attrfirstchild extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrfirstchild(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text textNode; - Node otherChild; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - textNode = (Text) titleAttr.getFirstChild(); - assertNotNull("textNodeNotNull", textNode); - value = textNode.getNodeValue(); - assertEquals("child1IsYes", "Yes", value); - otherChild = textNode.getNextSibling(); - assertNull("nextSiblingIsNull", otherChild); - otherChild = textNode.getPreviousSibling(); - assertNull("previousSiblingIsNull", otherChild); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrfirstchild"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrfirstchild.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrgetvalue1.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrgetvalue1.java deleted file mode 100644 index d2e38caa5..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrgetvalue1.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Checks the value of an attribute that contains entity references. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474 -*/ -public final class hc_attrgetvalue1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrgetvalue1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text textNode; - Node retval; - Node lastChild; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("class"); - value = titleAttr.getValue(); - assertEquals("attrValue1", "Yα", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrgetvalue1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrgetvalue1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrgetvalue2.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrgetvalue2.java deleted file mode 100644 index fd5b2114a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrgetvalue2.java +++ /dev/null @@ -1,111 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Checks the value of an attribute that contains entity references. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474 -*/ -public final class hc_attrgetvalue2 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrgetvalue2(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - if (factory.hasFeature("XML", null) != true) { - throw org.w3c.domts.DOMTestIncompatibleException.incompatibleFeature("XML", null); - } - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text textNode; - Node retval; - Node firstChild; - EntityReference alphaRef; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("class"); - - if (("text/html".equals(getContentType()))) { - - { - boolean success = false; - try { - alphaRef = doc.createEntityReference("alpha"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_SUPPORTED_ERR); - } - assertTrue("throw_NOT_SUPPORTED_ERR", success); - } -} else { - alphaRef = doc.createEntityReference("alpha"); - firstChild = titleAttr.getFirstChild(); - retval = titleAttr.insertBefore(alphaRef, firstChild); - value = titleAttr.getValue(); - assertEquals("attrValue1", "αYα", value); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrgetvalue2"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrgetvalue2.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrhaschildnodes.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrhaschildnodes.java deleted file mode 100644 index 04c65f647..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrhaschildnodes.java +++ /dev/null @@ -1,87 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Checks that Node.hasChildNodes() is true for an attribute with content. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-810594187 -*/ -public final class hc_attrhaschildnodes extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrhaschildnodes(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - boolean hasChildNodes; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - hasChildNodes = titleAttr.hasChildNodes(); - assertTrue("hasChildrenIsTrue", hasChildNodes); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrhaschildnodes"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrhaschildnodes.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore1.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore1.java deleted file mode 100644 index c6711486f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore1.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Appends a text node to an attribute and checks if the value of - * the attribute is changed. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -*/ -public final class hc_attrinsertbefore1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrinsertbefore1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text textNode; - Node retval; - Node firstChild; - Node lastChild; - Node refChild = null; - - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - textNode = doc.createTextNode("terday"); - retval = titleAttr.insertBefore(textNode, refChild); - value = titleAttr.getValue(); - assertEquals("attrValue", "Yesterday", value); - value = titleAttr.getNodeValue(); - assertEquals("attrNodeValue", "Yesterday", value); - value = retval.getNodeValue(); - assertEquals("retvalValue", "terday", value); - firstChild = titleAttr.getFirstChild(); - value = firstChild.getNodeValue(); - assertEquals("firstChildValue", "Yes", value); - lastChild = titleAttr.getLastChild(); - value = lastChild.getNodeValue(); - assertEquals("lastChildValue", "terday", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrinsertbefore1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrinsertbefore1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore2.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore2.java deleted file mode 100644 index 954233000..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore2.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Prepends a text node to an attribute and checks if the value of - * the attribute is changed. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -*/ -public final class hc_attrinsertbefore2 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrinsertbefore2(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text textNode; - Node retval; - Node lastChild; - Node firstChild; - Node refChild; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - textNode = doc.createTextNode("terday"); - refChild = titleAttr.getFirstChild(); - retval = titleAttr.insertBefore(textNode, refChild); - value = titleAttr.getValue(); - assertEquals("attrValue", "terdayYes", value); - value = titleAttr.getNodeValue(); - assertEquals("attrNodeValue", "terdayYes", value); - value = retval.getNodeValue(); - assertEquals("retvalValue", "terday", value); - firstChild = titleAttr.getFirstChild(); - value = firstChild.getNodeValue(); - assertEquals("firstChildValue", "terday", value); - lastChild = titleAttr.getLastChild(); - value = lastChild.getNodeValue(); - assertEquals("lastChildValue", "Yes", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrinsertbefore2"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrinsertbefore2.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore3.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore3.java deleted file mode 100644 index 7ac6e6b17..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore3.java +++ /dev/null @@ -1,112 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Appends a document fragment to an attribute and checks if the value of - * the attribute is changed. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -*/ -public final class hc_attrinsertbefore3 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrinsertbefore3(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text terNode; - Text dayNode; - DocumentFragment docFrag; - Node retval; - Node firstChild; - Node lastChild; - Node refChild = null; - - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - terNode = doc.createTextNode("ter"); - dayNode = doc.createTextNode("day"); - docFrag = doc.createDocumentFragment(); - retval = docFrag.appendChild(terNode); - retval = docFrag.appendChild(dayNode); - retval = titleAttr.insertBefore(docFrag, refChild); - value = titleAttr.getValue(); - assertEquals("attrValue", "Yesterday", value); - value = titleAttr.getNodeValue(); - assertEquals("attrNodeValue", "Yesterday", value); - value = retval.getNodeValue(); - assertNull("retvalValue", value); - firstChild = titleAttr.getFirstChild(); - value = firstChild.getNodeValue(); - assertEquals("firstChildValue", "Yes", value); - lastChild = titleAttr.getLastChild(); - value = lastChild.getNodeValue(); - assertEquals("lastChildValue", "day", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrinsertbefore3"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrinsertbefore3.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore4.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore4.java deleted file mode 100644 index 39cec5be7..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore4.java +++ /dev/null @@ -1,112 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Prepends a document fragment to an attribute and checks if the value of - * the attribute is changed. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -*/ -public final class hc_attrinsertbefore4 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrinsertbefore4(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text terNode; - Text dayNode; - DocumentFragment docFrag; - Node retval; - Node firstChild; - Node lastChild; - Node refChild; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - terNode = doc.createTextNode("ter"); - dayNode = doc.createTextNode("day"); - docFrag = doc.createDocumentFragment(); - retval = docFrag.appendChild(terNode); - retval = docFrag.appendChild(dayNode); - refChild = titleAttr.getFirstChild(); - retval = titleAttr.insertBefore(docFrag, refChild); - value = titleAttr.getValue(); - assertEquals("attrValue", "terdayYes", value); - value = titleAttr.getNodeValue(); - assertEquals("attrNodeValue", "terdayYes", value); - value = retval.getNodeValue(); - assertNull("retvalValue", value); - firstChild = titleAttr.getFirstChild(); - value = firstChild.getNodeValue(); - assertEquals("firstChildValue", "ter", value); - lastChild = titleAttr.getLastChild(); - value = lastChild.getNodeValue(); - assertEquals("lastChildValue", "Yes", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrinsertbefore4"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrinsertbefore4.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore5.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore5.java deleted file mode 100644 index 3a3e47ec0..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore5.java +++ /dev/null @@ -1,119 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Attempt to append a CDATASection to an attribute which should result - * in a HIERARCHY_REQUEST_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -*/ -public final class hc_attrinsertbefore5 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrinsertbefore5(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - if (factory.hasFeature("XML", null) != true) { - throw org.w3c.domts.DOMTestIncompatibleException.incompatibleFeature("XML", null); - } - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Node textNode; - Node retval; - Node refChild = null; - - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - - if (("text/html".equals(getContentType()))) { - - { - boolean success = false; - try { - textNode = doc.createCDATASection("terday"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_SUPPORTED_ERR); - } - assertTrue("throw_NOT_SUPPORTED_ERR", success); - } -} else { - textNode = doc.createCDATASection("terday"); - - { - boolean success = false; - try { - retval = titleAttr.insertBefore(textNode, refChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR); - } - assertTrue("throw_HIERARCHY_REQUEST_ERR", success); - } -} - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrinsertbefore5"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrinsertbefore5.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore6.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore6.java deleted file mode 100644 index 6cb66b52e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore6.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Attempt to append a text node from another document to an attribute which should result - * in a WRONG_DOCUMENT_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -*/ -public final class hc_attrinsertbefore6 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrinsertbefore6(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Node textNode; - Node retval; - Node refChild = null; - - Document otherDoc; - doc = (Document) load("hc_staff", true); - otherDoc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - textNode = otherDoc.createTextNode("terday"); - - { - boolean success = false; - try { - retval = titleAttr.insertBefore(textNode, refChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); - } - assertTrue("throw_WRONG_DOCUMENT_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrinsertbefore6"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrinsertbefore6.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore7.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore7.java deleted file mode 100644 index 122a27f6e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrinsertbefore7.java +++ /dev/null @@ -1,126 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Appends a document fragment containing a CDATASection to an attribute. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -*/ -public final class hc_attrinsertbefore7 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrinsertbefore7(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - if (factory.hasFeature("XML", null) != true) { - throw org.w3c.domts.DOMTestIncompatibleException.incompatibleFeature("XML", null); - } - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text terNode; - Node dayNode; - DocumentFragment docFrag; - Node retval; - Node firstChild; - Node lastChild; - Node refChild = null; - - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - terNode = doc.createTextNode("ter"); - - if (("text/html".equals(getContentType()))) { - - { - boolean success = false; - try { - dayNode = doc.createCDATASection("day"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_SUPPORTED_ERR); - } - assertTrue("throw_NOT_SUPPORTED_ERR", success); - } -} else { - dayNode = doc.createCDATASection("day"); - docFrag = doc.createDocumentFragment(); - retval = docFrag.appendChild(terNode); - retval = docFrag.appendChild(dayNode); - - { - boolean success = false; - try { - retval = titleAttr.insertBefore(docFrag, refChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR); - } - assertTrue("throw_HIERARCHY_REQUEST_ERR", success); - } -} - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrinsertbefore7"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrinsertbefore7.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrlastchild.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrlastchild.java deleted file mode 100644 index 0467b5b12..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrlastchild.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Checks that Node.lastChild for an attribute node contains - * the expected text node. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-61AD09FB -*/ -public final class hc_attrlastchild extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrlastchild(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text textNode; - Node otherChild; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - textNode = (Text) titleAttr.getFirstChild(); - assertNotNull("textNodeNotNull", textNode); - value = textNode.getNodeValue(); - assertEquals("child1IsYes", "Yes", value); - otherChild = textNode.getNextSibling(); - assertNull("nextSiblingIsNull", otherChild); - otherChild = textNode.getPreviousSibling(); - assertNull("previousSiblingIsNull", otherChild); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrlastchild"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrlastchild.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrname.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrname.java deleted file mode 100644 index 3f3b276ab..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrname.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the attribute named class from the last - * child of of the second "p" element and examine its - * NodeName. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1112119403 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html -*/ -public final class hc_attrname extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrname(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr streetAttr; - String strong1; - String strong2; - doc = (Document) load("hc_staff", false); - addressList = doc.getElementsByTagName("acronym"); - testNode = addressList.item(1); - attributes = testNode.getAttributes(); - streetAttr = (Attr) attributes.getNamedItem("class"); - strong1 = streetAttr.getNodeName(); - strong2 = streetAttr.getName(); - assertEqualsAutoCase("attribute", "nodeName", "class", strong1); - assertEqualsAutoCase("attribute", "name", "class", strong2); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrname"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrname.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrnextsiblingnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrnextsiblingnull.java deleted file mode 100644 index 57efb39f2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrnextsiblingnull.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNextSibling()" method for an Attr node should return null. - * Retrieve the attribute named "domestic" from the last child of of the - * first employee and examine its NextSibling node. This test uses the - * "getNamedItem(name)" method from the NamedNodeMap interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6AC54C2F -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -*/ -public final class hc_attrnextsiblingnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrnextsiblingnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr domesticAttr; - Node s; - doc = (Document) load("hc_staff", false); - addressList = doc.getElementsByTagName("acronym"); - testNode = addressList.item(0); - attributes = testNode.getAttributes(); - domesticAttr = (Attr) attributes.getNamedItem("title"); - s = domesticAttr.getNextSibling(); - assertNull("attrNextSiblingNullAssert", s); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrnextsiblingnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrnextsiblingnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrnormalize.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrnormalize.java deleted file mode 100644 index 017e71aba..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrnormalize.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Appends a text node to an attribute, normalizes the attribute - * and checks for a single child node. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-162CF083 -*/ -public final class hc_attrnormalize extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrnormalize(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text textNode; - Node retval; - Node firstChild; - Node secondChild; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - textNode = doc.createTextNode("terday"); - retval = titleAttr.appendChild(textNode); - textNode = doc.createTextNode(""); - retval = titleAttr.appendChild(textNode); - ((Element) /*Node */testNode).normalize(); - value = titleAttr.getNodeValue(); - assertEquals("attrNodeValue", "Yesterday", value); - firstChild = titleAttr.getFirstChild(); - value = firstChild.getNodeValue(); - assertEquals("firstChildValue", "Yesterday", value); - secondChild = firstChild.getNextSibling(); - assertNull("secondChildIsNull", secondChild); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrnormalize"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrnormalize.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrparentnodenull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrparentnodenull.java deleted file mode 100644 index 17f42833f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrparentnodenull.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getParentNode()" method for an Attr node should return null. Retrieve - * the attribute named "domestic" from the last child of the first employee - * and examine its parentNode attribute. This test also uses the "getNamedItem(name)" - * method from the NamedNodeMap interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1060184317 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -*/ -public final class hc_attrparentnodenull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrparentnodenull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr domesticAttr; - Node s; - doc = (Document) load("hc_staff", false); - addressList = doc.getElementsByTagName("acronym"); - testNode = addressList.item(0); - attributes = testNode.getAttributes(); - domesticAttr = (Attr) attributes.getNamedItem("title"); - s = domesticAttr.getParentNode(); - assertNull("attrParentNodeNullAssert", s); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrparentnodenull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrparentnodenull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrprevioussiblingnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrprevioussiblingnull.java deleted file mode 100644 index f63bf7636..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrprevioussiblingnull.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getPreviousSibling()" method for an Attr node should return null. - * Retrieve the attribute named "domestic" from the last child of of the - * first employee and examine its PreviousSibling node. This test uses the - * "getNamedItem(name)" method from the NamedNodeMap interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-640FB3C8 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -*/ -public final class hc_attrprevioussiblingnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrprevioussiblingnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr domesticAttr; - Node s; - doc = (Document) load("hc_staff", false); - addressList = doc.getElementsByTagName("acronym"); - testNode = addressList.item(0); - attributes = testNode.getAttributes(); - domesticAttr = (Attr) attributes.getNamedItem("title"); - s = domesticAttr.getPreviousSibling(); - assertNull("attrPreviousSiblingNullAssert", s); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrprevioussiblingnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrprevioussiblingnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrremovechild1.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrremovechild1.java deleted file mode 100644 index dd883347b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrremovechild1.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Removes the child node of an attribute and checks that the value is empty. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066 -*/ -public final class hc_attrremovechild1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrremovechild1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text textNode; - Node retval; - Node firstChild; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - textNode = (Text) titleAttr.getFirstChild(); - assertNotNull("attrChildNotNull", textNode); - retval = titleAttr.removeChild(textNode); - value = titleAttr.getValue(); - assertEquals("attrValue", "", value); - value = titleAttr.getNodeValue(); - assertEquals("attrNodeValue", "", value); - value = retval.getNodeValue(); - assertEquals("retvalValue", "Yes", value); - firstChild = titleAttr.getFirstChild(); - assertNull("firstChildNull", firstChild); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrremovechild1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrremovechild1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrremovechild2.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrremovechild2.java deleted file mode 100644 index 3ece6aff8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrremovechild2.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Attempts to remove a freshly created text node which should result in a NOT_FOUND_ERR exception. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066 -*/ -public final class hc_attrremovechild2 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrremovechild2(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text textNode; - Node retval; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - textNode = doc.createTextNode("Yesterday"); - - { - boolean success = false; - try { - retval = titleAttr.removeChild(textNode); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_FOUND_ERR); - } - assertTrue("throw_NOT_FOUND_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrremovechild2"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrremovechild2.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrreplacechild1.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrreplacechild1.java deleted file mode 100644 index 59e80f9d7..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrreplacechild1.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Replaces a text node of an attribute and checks if the value of - * the attribute is changed. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -*/ -public final class hc_attrreplacechild1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrreplacechild1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text textNode; - Node retval; - Node firstChild; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - textNode = doc.createTextNode("terday"); - firstChild = titleAttr.getFirstChild(); - assertNotNull("attrChildNotNull", firstChild); - retval = titleAttr.replaceChild(textNode, firstChild); - value = titleAttr.getValue(); - assertEquals("attrValue", "terday", value); - value = titleAttr.getNodeValue(); - assertEquals("attrNodeValue", "terday", value); - value = retval.getNodeValue(); - assertEquals("retvalValue", "Yes", value); - firstChild = titleAttr.getFirstChild(); - value = firstChild.getNodeValue(); - assertEquals("firstChildValue", "terday", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrreplacechild1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrreplacechild1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrreplacechild2.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrreplacechild2.java deleted file mode 100644 index c26840d8f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrreplacechild2.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Replaces a text node of an attribute with a document fragment and checks if the value of - * the attribute is changed. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -*/ -public final class hc_attrreplacechild2 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrreplacechild2(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text terNode; - Text dayNode; - DocumentFragment docFrag; - Node retval; - Node firstChild; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - terNode = doc.createTextNode("ter"); - dayNode = doc.createTextNode("day"); - docFrag = doc.createDocumentFragment(); - retval = docFrag.appendChild(terNode); - retval = docFrag.appendChild(dayNode); - firstChild = titleAttr.getFirstChild(); - assertNotNull("attrChildNotNull", firstChild); - retval = titleAttr.replaceChild(docFrag, firstChild); - value = titleAttr.getValue(); - assertEquals("attrValue", "terday", value); - value = titleAttr.getNodeValue(); - assertEquals("attrNodeValue", "terday", value); - value = retval.getNodeValue(); - assertEquals("retvalValue", "Yes", value); - firstChild = titleAttr.getFirstChild(); - value = firstChild.getNodeValue(); - assertEquals("firstChildValue", "ter", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrreplacechild2"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrreplacechild2.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrsetvalue1.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrsetvalue1.java deleted file mode 100644 index da4535bb9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrsetvalue1.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Sets Attr.value on an attribute that only has a simple value. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474 -*/ -public final class hc_attrsetvalue1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrsetvalue1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Node retval; - Node firstChild; - Node otherChild; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - firstChild = titleAttr.getFirstChild(); - assertNotNull("attrChildNotNull", firstChild); - titleAttr.setValue("Tomorrow"); - firstChild.setNodeValue("impl reused node"); - value = titleAttr.getValue(); - assertEquals("attrValue", "Tomorrow", value); - value = titleAttr.getNodeValue(); - assertEquals("attrNodeValue", "Tomorrow", value); - firstChild = titleAttr.getLastChild(); - value = firstChild.getNodeValue(); - assertEquals("firstChildValue", "Tomorrow", value); - otherChild = firstChild.getNextSibling(); - assertNull("nextSiblingIsNull", otherChild); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrsetvalue1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrsetvalue1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrsetvalue2.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrsetvalue2.java deleted file mode 100644 index e92eaa1a4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrsetvalue2.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Sets Attr.value on an attribute that should contain multiple child nodes. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474 -*/ -public final class hc_attrsetvalue2 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrsetvalue2(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList acronymList; - Node testNode; - NamedNodeMap attributes; - Attr titleAttr; - String value; - Text textNode; - Node retval; - Node firstChild; - Node otherChild; - doc = (Document) load("hc_staff", true); - acronymList = doc.getElementsByTagName("acronym"); - testNode = acronymList.item(3); - attributes = testNode.getAttributes(); - titleAttr = (Attr) attributes.getNamedItem("title"); - textNode = doc.createTextNode("terday"); - retval = titleAttr.appendChild(textNode); - firstChild = titleAttr.getFirstChild(); - assertNotNull("attrChildNotNull", firstChild); - titleAttr.setValue("Tomorrow"); - firstChild.setNodeValue("impl reused node"); - value = titleAttr.getValue(); - assertEquals("attrValue", "Tomorrow", value); - value = titleAttr.getNodeValue(); - assertEquals("attrNodeValue", "Tomorrow", value); - firstChild = titleAttr.getLastChild(); - value = firstChild.getNodeValue(); - assertEquals("firstChildValue", "Tomorrow", value); - otherChild = firstChild.getNextSibling(); - assertNull("nextSiblingIsNull", otherChild); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrsetvalue2"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrsetvalue2.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrspecifiedvalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrspecifiedvalue.java deleted file mode 100644 index 949823829..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrspecifiedvalue.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getSpecified()" method for an Attr node should - * be set to true if the attribute was explicitly given - * a value. - * Retrieve the attribute named "domestic" from the last - * child of of the first employee and examine the value - * returned by the "getSpecified()" method. This test uses - * the "getNamedItem(name)" method from the NamedNodeMap - * interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-862529273 -*/ -public final class hc_attrspecifiedvalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrspecifiedvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr domesticAttr; - boolean state; - doc = (Document) load("hc_staff", false); - addressList = doc.getElementsByTagName("acronym"); - testNode = addressList.item(0); - attributes = testNode.getAttributes(); - domesticAttr = (Attr) attributes.getNamedItem("title"); - state = domesticAttr.getSpecified(); - assertTrue("acronymTitleSpecified", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrspecifiedvalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrspecifiedvalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrspecifiedvaluechanged.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrspecifiedvaluechanged.java deleted file mode 100644 index c9a2e625c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_attrspecifiedvaluechanged.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getSpecified()" method for an Attr node should return true if the - * value of the attribute is changed. - * Retrieve the attribute named "class" from the last - * child of of the THIRD employee and change its - * value to "Yes"(which is the default DTD value). This - * should cause the "getSpecified()" method to be true. - * This test uses the "setAttribute(name,value)" method - * from the Element interface and the "getNamedItem(name)" - * method from the NamedNodeMap interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-862529273 -*/ -public final class hc_attrspecifiedvaluechanged extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_attrspecifiedvaluechanged(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr streetAttr; - boolean state; - doc = (Document) load("hc_staff", true); - addressList = doc.getElementsByTagName("acronym"); - testNode = addressList.item(2); - ((Element) /*Node */testNode).setAttribute("class", "Yα"); - attributes = testNode.getAttributes(); - streetAttr = (Attr) attributes.getNamedItem("class"); - state = streetAttr.getSpecified(); - assertTrue("acronymClassSpecified", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrspecifiedvaluechanged"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_attrspecifiedvaluechanged.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataappenddata.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataappenddata.java deleted file mode 100644 index c07e69638..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataappenddata.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "appendData(arg)" method appends a string to the end - * of the character data of the node. - * - * Retrieve the character data from the second child - * of the first employee. The appendData(arg) method is - * called with arg=", Esquire". The method should append - * the specified data to the already existing character - * data. The new value return by the "getLength()" method - * should be 24. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F -*/ -public final class hc_characterdataappenddata extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdataappenddata(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childValue; - int childLength; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("strong"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.appendData(", Esquire"); - childValue = child.getData(); - childLength = childValue.length(); - assertEquals("characterdataAppendDataAssert", 24, childLength); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdataappenddata"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdataappenddata.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataappenddatagetdata.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataappenddatagetdata.java deleted file mode 100644 index 02cbf3278..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataappenddatagetdata.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * On successful invocation of the "appendData(arg)" - * method the "getData()" method provides access to the - * concatentation of data and the specified string. - * - * Retrieve the character data from the second child - * of the first employee. The appendData(arg) method is - * called with arg=", Esquire". The method should append - * the specified data to the already existing character - * data. The new value return by the "getData()" method - * should be "Margaret Martin, Esquire". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F -*/ -public final class hc_characterdataappenddatagetdata extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdataappenddatagetdata(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("strong"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.appendData(", Esquire"); - childData = child.getData(); - assertEquals("characterdataAppendDataGetDataAssert", "Margaret Martin, Esquire", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdataappenddatagetdata"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdataappenddatagetdata.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedatabegining.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedatabegining.java deleted file mode 100644 index 179fe6c6d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedatabegining.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "deleteData(offset,count)" method removes a range of - * characters from the node. Delete data at the beginning - * of the character data. - * Retrieve the character data from the last child of the - * first employee. The "deleteData(offset,count)" - * method is then called with offset=0 and count=16. - * The method should delete the characters from position - * 0 thru position 16. The new value of the character data - * should be "Dallas, Texas 98551". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -*/ -public final class hc_characterdatadeletedatabegining extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdatadeletedatabegining(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.deleteData(0, 16); - childData = child.getData(); - assertEquals("data", "Dallas, Texas 98551", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatadeletedatabegining"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdatadeletedatabegining.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedataend.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedataend.java deleted file mode 100644 index 6401b8f62..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedataend.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "deleteData(offset,count)" method removes a range of - * characters from the node. Delete data at the end - * of the character data. - * - * Retrieve the character data from the last child of the - * first employee. The "deleteData(offset,count)" - * method is then called with offset=30 and count=5. - * The method should delete the characters from position - * 30 thru position 35. The new value of the character data - * should be "1230 North Ave. Dallas, Texas". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -*/ -public final class hc_characterdatadeletedataend extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdatadeletedataend(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.deleteData(30, 5); - childData = child.getData(); - assertEquals("characterdataDeleteDataEndAssert", "1230 North Ave. Dallas, Texas ", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatadeletedataend"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdatadeletedataend.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedataexceedslength.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedataexceedslength.java deleted file mode 100644 index ec60bfc23..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedataexceedslength.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the sum of the offset and count used in the - * "deleteData(offset,count) method is greater than the - * length of the character data then all the characters - * from the offset to the end of the data are deleted. - * - * Retrieve the character data from the last child of the - * first employee. The "deleteData(offset,count)" - * method is then called with offset=4 and count=50. - * The method should delete the characters from position 4 - * to the end of the data since the offset+count(50+4) - * is greater than the length of the character data(35). - * The new value of the character data should be "1230". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -*/ -public final class hc_characterdatadeletedataexceedslength extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdatadeletedataexceedslength(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.deleteData(4, 50); - childData = child.getData(); - assertEquals("characterdataDeleteDataExceedsLengthAssert", "1230", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatadeletedataexceedslength"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdatadeletedataexceedslength.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedatagetlengthanddata.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedatagetlengthanddata.java deleted file mode 100644 index 1a7fe3283..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedatagetlengthanddata.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * On successful invocation of the "deleteData(offset,count)" - * method, the "getData()" and "getLength()" methods reflect - * the changes. - * - * Retrieve the character data from the last child of the - * first employee. The "deleteData(offset,count)" - * method is then called with offset=30 and count=5. - * The method should delete the characters from position - * 30 thru position 35. The new value of the character data - * should be "1230 North Ave. Dallas, Texas" which is - * returned by the "getData()" method and "getLength()" - * method should return 30". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7D61178C -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -*/ -public final class hc_characterdatadeletedatagetlengthanddata extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdatadeletedatagetlengthanddata(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - int childLength; - java.util.List result = new java.util.ArrayList(); - - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.deleteData(30, 5); - childData = child.getData(); - assertEquals("data", "1230 North Ave. Dallas, Texas ", childData); - childLength = (int) child.getLength(); - assertEquals("length", 30, childLength); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatadeletedatagetlengthanddata"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdatadeletedatagetlengthanddata.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedatamiddle.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedatamiddle.java deleted file mode 100644 index 672e1362f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatadeletedatamiddle.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "deleteData(offset,count)" method removes a range of - * characters from the node. Delete data in the middle - * of the character data. - * - * Retrieve the character data from the last child of the - * first employee. The "deleteData(offset,count)" - * method is then called with offset=16 and count=8. - * The method should delete the characters from position - * 16 thru position 24. The new value of the character data - * should be "1230 North Ave. Texas 98551". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -*/ -public final class hc_characterdatadeletedatamiddle extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdatadeletedatamiddle(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.deleteData(16, 8); - childData = child.getData(); - assertEquals("characterdataDeleteDataMiddleAssert", "1230 North Ave. Texas 98551", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatadeletedatamiddle"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdatadeletedatamiddle.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatagetdata.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatagetdata.java deleted file mode 100644 index 63582a961..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatagetdata.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getData()" method retrieves the character data - * currently stored in the node. - * Retrieve the character data from the second child - * of the first employee and invoke the "getData()" - * method. The method returns the character data - * string. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -*/ -public final class hc_characterdatagetdata extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdatagetdata(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("strong"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - childData = child.getData(); - assertEquals("characterdataGetDataAssert", "Margaret Martin", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatagetdata"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdatagetdata.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatagetlength.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatagetlength.java deleted file mode 100644 index 981ca4289..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatagetlength.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getLength()" method returns the number of characters - * stored in this nodes data. - * Retrieve the character data from the second - * child of the first employee and examine the - * value returned by the getLength() method. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7D61178C -*/ -public final class hc_characterdatagetlength extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdatagetlength(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childValue; - int childLength; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("strong"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - childValue = child.getData(); - childLength = childValue.length(); - assertEquals("characterdataGetLengthAssert", 15, childLength); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatagetlength"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdatagetlength.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrdeletedatacountnegative.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrdeletedatacountnegative.java deleted file mode 100644 index f41b51597..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrdeletedatacountnegative.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "deleteData(offset,count)" method raises an - * INDEX_SIZE_ERR DOMException if the specified count - * is negative. - * - * Retrieve the character data of the last child of the - * first employee and invoke its "deleteData(offset,count)" - * method with offset=10 and count=-3. It should raise the - * desired exception since the count is negative. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -*/ -public final class hc_characterdataindexsizeerrdeletedatacountnegative extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdataindexsizeerrdeletedatacountnegative(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.signed - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childSubstring; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - childSubstring = child.substringData(10, -3); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throws_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdataindexsizeerrdeletedatacountnegative"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdataindexsizeerrdeletedatacountnegative.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrdeletedataoffsetgreater.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrdeletedataoffsetgreater.java deleted file mode 100644 index bf3f8cb82..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrdeletedataoffsetgreater.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "deleteData(offset,count)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset - * is greater that the number of characters in the string. - * - * Retrieve the character data of the last child of the - * first employee and invoke its "deleteData(offset,count)" - * method with offset=40 and count=3. It should raise the - * desired exception since the offset is greater than the - * number of characters in the string. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class hc_characterdataindexsizeerrdeletedataoffsetgreater extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdataindexsizeerrdeletedataoffsetgreater(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - child.deleteData(40, 3); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throw_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdataindexsizeerrdeletedataoffsetgreater"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdataindexsizeerrdeletedataoffsetgreater.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrdeletedataoffsetnegative.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrdeletedataoffsetnegative.java deleted file mode 100644 index 73f73a771..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrdeletedataoffsetnegative.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "deleteData(offset,count)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset - * is negative. - * - * Retrieve the character data of the last child of the - * first employee and invoke its "deleteData(offset,count)" - * method with offset=-5 and count=3. It should raise the - * desired exception since the offset is negative. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -*/ -public final class hc_characterdataindexsizeerrdeletedataoffsetnegative extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdataindexsizeerrdeletedataoffsetnegative(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.signed - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - child.deleteData(-5, 3); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throws_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdataindexsizeerrdeletedataoffsetnegative"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdataindexsizeerrdeletedataoffsetnegative.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrinsertdataoffsetgreater.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrinsertdataoffsetgreater.java deleted file mode 100644 index 4d174631d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrinsertdataoffsetgreater.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertData(offset,arg)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset - * is greater than the number of characters in the string. - * - * Retrieve the character data of the last child of the - * first employee and invoke its insertData"(offset,arg)" - * method with offset=40 and arg="ABC". It should raise - * the desired exception since the offset is greater than - * the number of characters in the string. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class hc_characterdataindexsizeerrinsertdataoffsetgreater extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdataindexsizeerrinsertdataoffsetgreater(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - child.deleteData(40, 3); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throw_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdataindexsizeerrinsertdataoffsetgreater"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdataindexsizeerrinsertdataoffsetgreater.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrinsertdataoffsetnegative.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrinsertdataoffsetnegative.java deleted file mode 100644 index 7aea106fa..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrinsertdataoffsetnegative.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertData(offset,arg)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset - * is negative. - * - * Retrieve the character data of the last child of the - * first employee and invoke its insertData"(offset,arg)" - * method with offset=-5 and arg="ABC". It should raise - * the desired exception since the offset is negative. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-E5CBA7FB')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -*/ -public final class hc_characterdataindexsizeerrinsertdataoffsetnegative extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdataindexsizeerrinsertdataoffsetnegative(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.signed - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - child.replaceData(-5, 3, "ABC"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throws_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdataindexsizeerrinsertdataoffsetnegative"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdataindexsizeerrinsertdataoffsetnegative.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedatacountnegative.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedatacountnegative.java deleted file mode 100644 index d5eabc7f0..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedatacountnegative.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceData(offset,count,arg)" method raises an - * INDEX_SIZE_ERR DOMException if the specified count - * is negative. - * - * Retrieve the character data of the last child of the - * first employee and invoke its - * "replaceData(offset,count,arg) method with offset=10 - * and count=-3 and arg="ABC". It should raise the - * desired exception since the count is negative. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -*/ -public final class hc_characterdataindexsizeerrreplacedatacountnegative extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdataindexsizeerrreplacedatacountnegative(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.signed - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String badString; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - badString = child.substringData(10, -3); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throws_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdataindexsizeerrreplacedatacountnegative"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdataindexsizeerrreplacedatacountnegative.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedataoffsetgreater.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedataoffsetgreater.java deleted file mode 100644 index 3af507ef9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedataoffsetgreater.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceData(offset,count,arg)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset - * is greater than the length of the string. - * - * Retrieve the character data of the last child of the - * first employee and invoke its - * "replaceData(offset,count,arg) method with offset=40 - * and count=3 and arg="ABC". It should raise the - * desired exception since the offset is greater than the - * length of the string. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=242 -*/ -public final class hc_characterdataindexsizeerrreplacedataoffsetgreater extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdataindexsizeerrreplacedataoffsetgreater(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - child.deleteData(40, 3); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throw_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdataindexsizeerrreplacedataoffsetgreater"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdataindexsizeerrreplacedataoffsetgreater.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedataoffsetnegative.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedataoffsetnegative.java deleted file mode 100644 index 2b93ee9f2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrreplacedataoffsetnegative.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceData(offset,count,arg)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset - * is negative. - * - * Retrieve the character data of the last child of the - * first employee and invoke its - * "replaceData(offset,count,arg) method with offset=-5 - * and count=3 and arg="ABC". It should raise the - * desired exception since the offset is negative. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-E5CBA7FB')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -*/ -public final class hc_characterdataindexsizeerrreplacedataoffsetnegative extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdataindexsizeerrreplacedataoffsetnegative(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.signed - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - child.replaceData(-5, 3, "ABC"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throws_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdataindexsizeerrreplacedataoffsetnegative"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdataindexsizeerrreplacedataoffsetnegative.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrsubstringcountnegative.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrsubstringcountnegative.java deleted file mode 100644 index 1d3bc530f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrsubstringcountnegative.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "substringData(offset,count)" method raises an - * INDEX_SIZE_ERR DOMException if the specified count - * is negative. - * - * Retrieve the character data of the last child of the - * first employee and invoke its "substringData(offset,count) - * method with offset=10 and count=-3. It should raise the - * desired exception since the count is negative. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -*/ -public final class hc_characterdataindexsizeerrsubstringcountnegative extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdataindexsizeerrsubstringcountnegative(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.signed - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String badSubstring; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - badSubstring = child.substringData(10, -3); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throws_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdataindexsizeerrsubstringcountnegative"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdataindexsizeerrsubstringcountnegative.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrsubstringnegativeoffset.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrsubstringnegativeoffset.java deleted file mode 100644 index a7ccd2dfa..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrsubstringnegativeoffset.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "substringData(offset,count)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset - * is negative. - * - * Retrieve the character data of the last child of the - * first employee and invoke its "substringData(offset,count) - * method with offset=-5 and count=3. It should raise the - * desired exception since the offset is negative. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -*/ -public final class hc_characterdataindexsizeerrsubstringnegativeoffset extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdataindexsizeerrsubstringnegativeoffset(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.signed - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String badString; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - badString = child.substringData(-5, 3); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throws_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdataindexsizeerrsubstringnegativeoffset"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdataindexsizeerrsubstringnegativeoffset.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrsubstringoffsetgreater.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrsubstringoffsetgreater.java deleted file mode 100644 index d3d2b2fbf..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdataindexsizeerrsubstringoffsetgreater.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "substringData(offset,count)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset - * is greater than the number of characters in the string. - * - * Retrieve the character data of the last child of the - * first employee and invoke its "substringData(offset,count) - * method with offset=40 and count=3. It should raise the - * desired exception since the offsets value is greater - * than the length. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class hc_characterdataindexsizeerrsubstringoffsetgreater extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdataindexsizeerrsubstringoffsetgreater(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String badString; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - - { - boolean success = false; - try { - badString = child.substringData(40, 3); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throw_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdataindexsizeerrsubstringoffsetgreater"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdataindexsizeerrsubstringoffsetgreater.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatainsertdatabeginning.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatainsertdatabeginning.java deleted file mode 100644 index 7142e9e9c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatainsertdatabeginning.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertData(offset,arg)" method will insert a string - * at the specified character offset. Insert the data at - * the beginning of the character data. - * Retrieve the character data from the second child of - * the first employee. The "insertData(offset,arg)" - * method is then called with offset=0 and arg="Mss.". - * The method should insert the string "Mss." at position 0. - * The new value of the character data should be - * "Mss. Margaret Martin". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F -*/ -public final class hc_characterdatainsertdatabeginning extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdatainsertdatabeginning(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("strong"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.insertData(0, "Mss. "); - childData = child.getData(); - assertEquals("characterdataInsertDataBeginningAssert", "Mss. Margaret Martin", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatainsertdatabeginning"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdatainsertdatabeginning.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatainsertdataend.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatainsertdataend.java deleted file mode 100644 index 0c7218f6d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatainsertdataend.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertData(offset,arg)" method will insert a string - * at the specified character offset. Insert the data at - * the end of the character data. - * - * Retrieve the character data from the second child of - * the first employee. The "insertData(offset,arg)" - * method is then called with offset=15 and arg=", Esquire". - * The method should insert the string ", Esquire" at - * position 15. The new value of the character data should - * be "Margaret Martin, Esquire". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F -*/ -public final class hc_characterdatainsertdataend extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdatainsertdataend(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("strong"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.insertData(15, ", Esquire"); - childData = child.getData(); - assertEquals("characterdataInsertDataEndAssert", "Margaret Martin, Esquire", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatainsertdataend"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdatainsertdataend.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatainsertdatamiddle.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatainsertdatamiddle.java deleted file mode 100644 index 160fe4d2f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatainsertdatamiddle.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertData(offset,arg)" method will insert a string - * at the specified character offset. Insert the data in - * the middle of the character data. - * - * Retrieve the character data from the second child of - * the first employee. The "insertData(offset,arg)" - * method is then called with offset=9 and arg="Ann". - * The method should insert the string "Ann" at position 9. - * The new value of the character data should be - * "Margaret Ann Martin". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F -*/ -public final class hc_characterdatainsertdatamiddle extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdatainsertdatamiddle(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("strong"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.insertData(9, "Ann "); - childData = child.getData(); - assertEquals("characterdataInsertDataMiddleAssert", "Margaret Ann Martin", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatainsertdatamiddle"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdatainsertdatamiddle.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedatabegining.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedatabegining.java deleted file mode 100644 index 562c1dd06..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedatabegining.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceData(offset,count,arg)" method replaces the - * characters starting at the specified offset with the - * specified string. Test for replacement in the - * middle of the data. - * Retrieve the character data from the last child of the - * first employee. The "replaceData(offset,count,arg)" - * method is then called with offset=5 and count=5 and - * arg="South". The method should replace characters five - * thru 9 of the character data with "South". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -*/ -public final class hc_characterdatareplacedatabegining extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdatareplacedatabegining(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.replaceData(0, 4, "2500"); - childData = child.getData(); - assertEquals("characterdataReplaceDataBeginingAssert", "2500 North Ave. Dallas, Texas 98551", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatareplacedatabegining"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdatareplacedatabegining.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedataend.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedataend.java deleted file mode 100644 index 3c8679456..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedataend.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceData(offset,count,arg)" method replaces the - * characters starting at the specified offset with the - * specified string. Test for replacement at the - * end of the data. - * - * Retrieve the character data from the last child of the - * first employee. The "replaceData(offset,count,arg)" - * method is then called with offset=30 and count=5 and - * arg="98665". The method should replace characters 30 - * thru 34 of the character data with "98665". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -*/ -public final class hc_characterdatareplacedataend extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdatareplacedataend(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.replaceData(30, 5, "98665"); - childData = child.getData(); - assertEquals("characterdataReplaceDataEndAssert", "1230 North Ave. Dallas, Texas 98665", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatareplacedataend"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdatareplacedataend.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedataexceedslengthofarg.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedataexceedslengthofarg.java deleted file mode 100644 index f45c49a04..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedataexceedslengthofarg.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceData(offset,count,arg)" method replaces the - * characters starting at the specified offset with the - * specified string. Test the situation where the length - * of the arg string is greater than the specified offset. - * - * Retrieve the character data from the last child of the - * first employee. The "replaceData(offset,count,arg)" - * method is then called with offset=0 and count=4 and - * arg="260030". The method should replace characters one - * thru four with "260030". Note that the length of the - * specified string is greater that the specified offset. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -*/ -public final class hc_characterdatareplacedataexceedslengthofarg extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdatareplacedataexceedslengthofarg(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.replaceData(0, 4, "260030"); - childData = child.getData(); - assertEquals("characterdataReplaceDataExceedsLengthOfArgAssert", "260030 North Ave. Dallas, Texas 98551", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatareplacedataexceedslengthofarg"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdatareplacedataexceedslengthofarg.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedataexceedslengthofdata.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedataexceedslengthofdata.java deleted file mode 100644 index efe88cc7e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedataexceedslengthofdata.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the sum of the offset and count exceeds the length then - * all the characters to the end of the data are replaced. - * - * Retrieve the character data from the last child of the - * first employee. The "replaceData(offset,count,arg)" - * method is then called with offset=0 and count=50 and - * arg="2600". The method should replace all the characters - * with "2600". This is because the sum of the offset and - * count exceeds the length of the character data. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -*/ -public final class hc_characterdatareplacedataexceedslengthofdata extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdatareplacedataexceedslengthofdata(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.replaceData(0, 50, "2600"); - childData = child.getData(); - assertEquals("characterdataReplaceDataExceedsLengthOfDataAssert", "2600", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatareplacedataexceedslengthofdata"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdatareplacedataexceedslengthofdata.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedatamiddle.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedatamiddle.java deleted file mode 100644 index 87b10811c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatareplacedatamiddle.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceData(offset,count,arg)" method replaces the - * characters starting at the specified offset with the - * specified string. Test for replacement in the - * middle of the data. - * - * Retrieve the character data from the last child of the - * first employee. The "replaceData(offset,count,arg)" - * method is then called with offset=5 and count=5 and - * arg="South". The method should replace characters five - * thru 9 of the character data with "South". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB -*/ -public final class hc_characterdatareplacedatamiddle extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdatareplacedatamiddle(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.replaceData(5, 5, "South"); - childData = child.getData(); - assertEquals("characterdataReplaceDataMiddleAssert", "1230 South Ave. Dallas, Texas 98551", childData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatareplacedatamiddle"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdatareplacedatamiddle.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatasetnodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatasetnodevalue.java deleted file mode 100644 index 71d93fcd2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatasetnodevalue.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setNodeValue()" method changes the character data - * currently stored in the node. - * Retrieve the character data from the second child - * of the first employee and invoke the "setNodeValue()" - * method, call "getData()" and compare. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 -*/ -public final class hc_characterdatasetnodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdatasetnodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String childData; - String childValue; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("strong"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - child.setNodeValue("Marilyn Martin"); - childData = child.getData(); - assertEquals("data", "Marilyn Martin", childData); - childValue = child.getNodeValue(); - assertEquals("value", "Marilyn Martin", childValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatasetnodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdatasetnodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatasubstringexceedsvalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatasubstringexceedsvalue.java deleted file mode 100644 index fc64688e5..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatasubstringexceedsvalue.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the sum of the "offset" and "count" exceeds the - * "length" then the "substringData(offset,count)" method - * returns all the characters to the end of the data. - * - * Retrieve the character data from the second child - * of the first employee and access part of the data - * by using the substringData(offset,count) method - * with offset=9 and count=10. The method should return - * the substring "Martin" since offset+count > length - * (19 > 15). -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF -*/ -public final class hc_characterdatasubstringexceedsvalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdatasubstringexceedsvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String substring; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("strong"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - substring = child.substringData(9, 10); - assertEquals("characterdataSubStringExceedsValueAssert", "Martin", substring); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatasubstringexceedsvalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdatasubstringexceedsvalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatasubstringvalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatasubstringvalue.java deleted file mode 100644 index 5050fbae6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_characterdatasubstringvalue.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "substringData(offset,count)" method returns the - * specified string. - * - * Retrieve the character data from the second child - * of the first employee and access part of the data - * by using the substringData(offset,count) method. The - * method should return the specified substring starting - * at position "offset" and extract "count" characters. - * The method should return the string "Margaret". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF -*/ -public final class hc_characterdatasubstringvalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_characterdatasubstringvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - CharacterData child; - String substring; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("strong"); - nameNode = elementList.item(0); - child = (CharacterData) nameNode.getFirstChild(); - substring = child.substringData(0, 8); - assertEquals("characterdataSubStringValueAssert", "Margaret", substring); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatasubstringvalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_characterdatasubstringvalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_commentgetcomment.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_commentgetcomment.java deleted file mode 100644 index 946f97578..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_commentgetcomment.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * A comment is all the characters between the starting - * '' - * Retrieve the nodes of the DOM document. Search for a - * comment node and the content is its value. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1334481328 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=509 -*/ -public final class hc_commentgetcomment extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_commentgetcomment(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node child; - String childName; - String childValue; - int commentCount = 0; - int childType; - NamedNodeMap attributes; - doc = (Document) load("hc_staff", false); - elementList = doc.getChildNodes(); - for (int indexN1005E = 0; indexN1005E < elementList.getLength(); indexN1005E++) { - child = (Node) elementList.item(indexN1005E); - childType = (int) child.getNodeType(); - - if (equals(8, childType)) { - childName = child.getNodeName(); - assertEquals("nodeName", "#comment", childName); - childValue = child.getNodeValue(); - assertEquals("nodeValue", " This is comment number 1.", childValue); - attributes = child.getAttributes(); - assertNull("attributes", attributes); - commentCount += 1; - } - } - assertTrue("atMostOneComment", (commentCount < 2)); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_commentgetcomment"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_commentgetcomment.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreateattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreateattribute.java deleted file mode 100644 index 983dabd7c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreateattribute.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the entire DOM document and invoke its - * "createAttribute(name)" method. It should create a - * new Attribute node with the given name. The name, value - * and type of the newly created object are retrieved and - * output. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243 -*/ -public final class hc_documentcreateattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_documentcreateattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr newAttrNode; - String attrValue; - String attrName; - int attrType; - doc = (Document) load("hc_staff", true); - newAttrNode = doc.createAttribute("title"); - attrValue = newAttrNode.getNodeValue(); - assertEquals("value", "", attrValue); - attrName = newAttrNode.getNodeName(); - assertEqualsAutoCase("attribute", "name", "title", attrName); - attrType = (int) newAttrNode.getNodeType(); - assertEquals("type", 2, attrType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentcreateattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_documentcreateattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreatecomment.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreatecomment.java deleted file mode 100644 index b5c02267a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreatecomment.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createComment(data)" method creates a new Comment - * node given the specified string. - * Retrieve the entire DOM document and invoke its - * "createComment(data)" method. It should create a new - * Comment node whose "data" is the specified string. - * The content, name and type are retrieved and output. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1334481328 -*/ -public final class hc_documentcreatecomment extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_documentcreatecomment(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Comment newCommentNode; - String newCommentValue; - String newCommentName; - int newCommentType; - doc = (Document) load("hc_staff", true); - newCommentNode = doc.createComment("This is a new Comment node"); - newCommentValue = newCommentNode.getNodeValue(); - assertEquals("value", "This is a new Comment node", newCommentValue); - newCommentName = newCommentNode.getNodeName(); - assertEquals("strong", "#comment", newCommentName); - newCommentType = (int) newCommentNode.getNodeType(); - assertEquals("type", 8, newCommentType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentcreatecomment"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_documentcreatecomment.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreatedocumentfragment.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreatedocumentfragment.java deleted file mode 100644 index 7c96f4821..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreatedocumentfragment.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createDocumentFragment()" method creates an empty - * DocumentFragment object. - * Retrieve the entire DOM document and invoke its - * "createDocumentFragment()" method. The content, name, - * type and value of the newly created object are output. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-35CB04B5 -*/ -public final class hc_documentcreatedocumentfragment extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_documentcreatedocumentfragment(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentFragment newDocFragment; - NodeList children; - int length; - String newDocFragmentName; - int newDocFragmentType; - String newDocFragmentValue; - doc = (Document) load("hc_staff", true); - newDocFragment = doc.createDocumentFragment(); - children = newDocFragment.getChildNodes(); - length = (int) children.getLength(); - assertEquals("length", 0, length); - newDocFragmentName = newDocFragment.getNodeName(); - assertEquals("strong", "#document-fragment", newDocFragmentName); - newDocFragmentType = (int) newDocFragment.getNodeType(); - assertEquals("type", 11, newDocFragmentType); - newDocFragmentValue = newDocFragment.getNodeValue(); - assertNull("value", newDocFragmentValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentcreatedocumentfragment"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_documentcreatedocumentfragment.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreateelement.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreateelement.java deleted file mode 100644 index d266ef50d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreateelement.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createElement(tagName)" method creates an Element - * of the type specified. - * Retrieve the entire DOM document and invoke its - * "createElement(tagName)" method with tagName="acronym". - * The method should create an instance of an Element node - * whose tagName is "acronym". The NodeName, NodeType - * and NodeValue are returned. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547 -*/ -public final class hc_documentcreateelement extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_documentcreateelement(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element newElement; - String newElementName; - int newElementType; - String newElementValue; - doc = (Document) load("hc_staff", true); - newElement = doc.createElement("acronym"); - newElementName = newElement.getNodeName(); - assertEqualsAutoCase("element", "strong", "acronym", newElementName); - newElementType = (int) newElement.getNodeType(); - assertEquals("type", 1, newElementType); - newElementValue = newElement.getNodeValue(); - assertNull("valueInitiallyNull", newElementValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentcreateelement"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_documentcreateelement.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreateelementcasesensitive.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreateelementcasesensitive.java deleted file mode 100644 index 224d67569..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreateelementcasesensitive.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The tagName parameter in the "createElement(tagName)" - * method is case-sensitive for XML documents. - * Retrieve the entire DOM document and invoke its - * "createElement(tagName)" method twice. Once for tagName - * equal to "acronym" and once for tagName equal to "ACRONYM" - * Each call should create a distinct Element node. The - * newly created Elements are then assigned attributes - * that are retrieved. - * Modified on 27 June 2003 to avoid setting an invalid style - * values and checked the node names to see if they matched expectations. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243 -*/ -public final class hc_documentcreateelementcasesensitive extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_documentcreateelementcasesensitive(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element newElement1; - Element newElement2; - String attribute1; - String attribute2; - String nodeName1; - String nodeName2; - doc = (Document) load("hc_staff", true); - newElement1 = doc.createElement("ACRONYM"); - newElement2 = doc.createElement("acronym"); - newElement1.setAttribute("lang", "EN"); - newElement2.setAttribute("title", "Dallas"); - attribute1 = newElement1.getAttribute("lang"); - attribute2 = newElement2.getAttribute("title"); - assertEquals("attrib1", "EN", attribute1); - assertEquals("attrib2", "Dallas", attribute2); - nodeName1 = newElement1.getNodeName(); - nodeName2 = newElement2.getNodeName(); - assertEqualsAutoCase("element", "nodeName1", "ACRONYM", nodeName1); - assertEqualsAutoCase("element", "nodeName2", "acronym", nodeName2); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentcreateelementcasesensitive"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_documentcreateelementcasesensitive.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreatetextnode.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreatetextnode.java deleted file mode 100644 index 47faab188..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentcreatetextnode.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createTextNode(data)" method creates a Text node - * given the specfied string. - * Retrieve the entire DOM document and invoke its - * "createTextNode(data)" method. It should create a - * new Text node whose "data" is the specified string. - * The NodeName and NodeType are also checked. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1975348127 -*/ -public final class hc_documentcreatetextnode extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_documentcreatetextnode(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Text newTextNode; - String newTextName; - String newTextValue; - int newTextType; - doc = (Document) load("hc_staff", true); - newTextNode = doc.createTextNode("This is a new Text node"); - newTextValue = newTextNode.getNodeValue(); - assertEquals("value", "This is a new Text node", newTextValue); - newTextName = newTextNode.getNodeName(); - assertEquals("strong", "#text", newTextName); - newTextType = (int) newTextNode.getNodeType(); - assertEquals("type", 3, newTextType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentcreatetextnode"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_documentcreatetextnode.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetdoctype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetdoctype.java deleted file mode 100644 index 69acccc02..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetdoctype.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Access Document.doctype for hc_staff, if not text/html should return DocumentType node. - * HTML implementations may return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31 -*/ -public final class hc_documentgetdoctype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_documentgetdoctype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - String docTypeName; - String nodeValue; - NamedNodeMap attributes; - doc = (Document) load("hc_staff", false); - docType = doc.getDoctype(); - - if ( - !(("text/html".equals(getContentType()))) -) { - assertNotNull("docTypeNotNull", docType); - } - - if ((docType != null)) { - docTypeName = docType.getName(); - - if (("image/svg+xml".equals(getContentType()))) { - assertEquals("nodeNameSVG", "svg", docTypeName); - } else { - assertEquals("nodeName", "html", docTypeName); - } - - nodeValue = docType.getNodeValue(); - assertNull("nodeValue", nodeValue); - attributes = docType.getAttributes(); - assertNull("attributes", attributes); - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentgetdoctype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_documentgetdoctype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetelementsbytagnamelength.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetelementsbytagnamelength.java deleted file mode 100644 index c824751fd..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetelementsbytagnamelength.java +++ /dev/null @@ -1,84 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagName(tagName)" method returns a - * NodeList of all the Elements with a given tagName. - * - * Retrieve the entire DOM document and invoke its - * "getElementsByTagName(tagName)" method with tagName - * equal to "strong". The method should return a NodeList - * that contains 5 elements. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094 -*/ -public final class hc_documentgetelementsbytagnamelength extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_documentgetelementsbytagnamelength(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList nameList; - doc = (Document) load("hc_staff", false); - nameList = doc.getElementsByTagName("strong"); - assertSize("documentGetElementsByTagNameLengthAssert", 5, nameList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentgetelementsbytagnamelength"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_documentgetelementsbytagnamelength.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetelementsbytagnametotallength.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetelementsbytagnametotallength.java deleted file mode 100644 index 34660dd8e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetelementsbytagnametotallength.java +++ /dev/null @@ -1,186 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the entire DOM document and invoke its - * "getElementsByTagName(tagName)" method with tagName - * equal to "*". The method should return a NodeList - * that contains all the elements of the document. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251 -*/ -public final class hc_documentgetelementsbytagnametotallength extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_documentgetelementsbytagnametotallength(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList nameList; - java.util.List expectedNames = new java.util.ArrayList(); - expectedNames.add("html"); - expectedNames.add("head"); - expectedNames.add("meta"); - expectedNames.add("title"); - expectedNames.add("script"); - expectedNames.add("script"); - expectedNames.add("script"); - expectedNames.add("body"); - expectedNames.add("p"); - expectedNames.add("em"); - expectedNames.add("strong"); - expectedNames.add("code"); - expectedNames.add("sup"); - expectedNames.add("var"); - expectedNames.add("acronym"); - expectedNames.add("p"); - expectedNames.add("em"); - expectedNames.add("strong"); - expectedNames.add("code"); - expectedNames.add("sup"); - expectedNames.add("var"); - expectedNames.add("acronym"); - expectedNames.add("p"); - expectedNames.add("em"); - expectedNames.add("strong"); - expectedNames.add("code"); - expectedNames.add("sup"); - expectedNames.add("var"); - expectedNames.add("acronym"); - expectedNames.add("p"); - expectedNames.add("em"); - expectedNames.add("strong"); - expectedNames.add("code"); - expectedNames.add("sup"); - expectedNames.add("var"); - expectedNames.add("acronym"); - expectedNames.add("p"); - expectedNames.add("em"); - expectedNames.add("strong"); - expectedNames.add("code"); - expectedNames.add("sup"); - expectedNames.add("var"); - expectedNames.add("acronym"); - - java.util.List svgExpectedNames = new java.util.ArrayList(); - svgExpectedNames.add("svg"); - svgExpectedNames.add("rect"); - svgExpectedNames.add("script"); - svgExpectedNames.add("head"); - svgExpectedNames.add("meta"); - svgExpectedNames.add("title"); - svgExpectedNames.add("body"); - svgExpectedNames.add("p"); - svgExpectedNames.add("em"); - svgExpectedNames.add("strong"); - svgExpectedNames.add("code"); - svgExpectedNames.add("sup"); - svgExpectedNames.add("var"); - svgExpectedNames.add("acronym"); - svgExpectedNames.add("p"); - svgExpectedNames.add("em"); - svgExpectedNames.add("strong"); - svgExpectedNames.add("code"); - svgExpectedNames.add("sup"); - svgExpectedNames.add("var"); - svgExpectedNames.add("acronym"); - svgExpectedNames.add("p"); - svgExpectedNames.add("em"); - svgExpectedNames.add("strong"); - svgExpectedNames.add("code"); - svgExpectedNames.add("sup"); - svgExpectedNames.add("var"); - svgExpectedNames.add("acronym"); - svgExpectedNames.add("p"); - svgExpectedNames.add("em"); - svgExpectedNames.add("strong"); - svgExpectedNames.add("code"); - svgExpectedNames.add("sup"); - svgExpectedNames.add("var"); - svgExpectedNames.add("acronym"); - svgExpectedNames.add("p"); - svgExpectedNames.add("em"); - svgExpectedNames.add("strong"); - svgExpectedNames.add("code"); - svgExpectedNames.add("sup"); - svgExpectedNames.add("var"); - svgExpectedNames.add("acronym"); - - java.util.List actualNames = new java.util.ArrayList(); - - Element thisElement; - String thisTag; - doc = (Document) load("hc_staff", false); - nameList = doc.getElementsByTagName("*"); - for (int indexN10148 = 0; indexN10148 < nameList.getLength(); indexN10148++) { - thisElement = (Element) nameList.item(indexN10148); - thisTag = thisElement.getTagName(); - actualNames.add(thisTag); - } - - if (("image/svg+xml".equals(getContentType()))) { - assertEqualsAutoCase("element", "svgTagNames", svgExpectedNames, actualNames); - } else { - assertEqualsAutoCase("element", "tagNames", expectedNames, actualNames); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentgetelementsbytagnametotallength"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_documentgetelementsbytagnametotallength.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetelementsbytagnamevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetelementsbytagnamevalue.java deleted file mode 100644 index 7bf67037e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetelementsbytagnamevalue.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagName(tagName)" method returns a - * NodeList of all the Elements with a given tagName - * in a pre-order traversal of the tree. - * - * Retrieve the entire DOM document and invoke its - * "getElementsByTagName(tagName)" method with tagName - * equal to "strong". The method should return a NodeList - * that contains 5 elements. The FOURTH item in the - * list is retrieved and output. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094 -*/ -public final class hc_documentgetelementsbytagnamevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_documentgetelementsbytagnamevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList nameList; - Node nameNode; - Node firstChild; - String childValue; - doc = (Document) load("hc_staff", false); - nameList = doc.getElementsByTagName("strong"); - nameNode = nameList.item(3); - firstChild = nameNode.getFirstChild(); - childValue = firstChild.getNodeValue(); - assertEquals("documentGetElementsByTagNameValueAssert", "Jeny Oconnor", childValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentgetelementsbytagnamevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_documentgetelementsbytagnamevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetimplementation.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetimplementation.java deleted file mode 100644 index d63627501..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetimplementation.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the entire DOM document and invoke its - * "getImplementation()" method. If contentType="text/html", - * DOMImplementation.hasFeature("HTML","1.0") should be true. - * Otherwise, DOMImplementation.hasFeature("XML", "1.0") - * should be true. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1B793EBA -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=245 -*/ -public final class hc_documentgetimplementation extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_documentgetimplementation(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation docImpl; - boolean xmlstate; - boolean htmlstate; - doc = (Document) load("hc_staff", false); - docImpl = doc.getImplementation(); - xmlstate = docImpl.hasFeature("XML", "1.0"); -htmlstate = docImpl.hasFeature("HTML", "1.0"); - - if (("text/html".equals(getContentType()))) { - assertTrue("supports_HTML_1.0", htmlstate); - } else { - assertTrue("supports_XML_1.0", xmlstate); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentgetimplementation"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_documentgetimplementation.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetrootnode.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetrootnode.java deleted file mode 100644 index 17b54fb2e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentgetrootnode.java +++ /dev/null @@ -1,88 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Load a document and invoke its - * "getDocumentElement()" method. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-87CD092 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251 -*/ -public final class hc_documentgetrootnode extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_documentgetrootnode(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element root; - String rootName; - doc = (Document) load("hc_staff", false); - root = doc.getDocumentElement(); - rootName = root.getNodeName(); - - if (("image/svg+xml".equals(getContentType()))) { - assertEquals("svgTagName", "svg", rootName); - } else { - assertEqualsAutoCase("element", "docElemName", "html", rootName); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentgetrootnode"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_documentgetrootnode.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentinvalidcharacterexceptioncreateattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentinvalidcharacterexceptioncreateattribute.java deleted file mode 100644 index 1f474693d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentinvalidcharacterexceptioncreateattribute.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createAttribute(tagName)" method raises an - * INVALID_CHARACTER_ERR DOMException if the specified - * tagName contains an invalid character. - * - * Retrieve the entire DOM document and invoke its - * "createAttribute(tagName)" method with the tagName equal - * to the string "invalid^Name". Due to the invalid - * character the desired EXCEPTION should be raised. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1084891198')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class hc_documentinvalidcharacterexceptioncreateattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_documentinvalidcharacterexceptioncreateattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr createdAttr; - doc = (Document) load("hc_staff", true); - - { - boolean success = false; - try { - createdAttr = doc.createAttribute("invalid^Name"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentinvalidcharacterexceptioncreateattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_documentinvalidcharacterexceptioncreateattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentinvalidcharacterexceptioncreateattribute1.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentinvalidcharacterexceptioncreateattribute1.java deleted file mode 100644 index 3b2995333..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentinvalidcharacterexceptioncreateattribute1.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Creating an attribute with an empty name should cause an INVALID_CHARACTER_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1084891198')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525 -*/ -public final class hc_documentinvalidcharacterexceptioncreateattribute1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_documentinvalidcharacterexceptioncreateattribute1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr createdAttr; - doc = (Document) load("hc_staff", true); - - { - boolean success = false; - try { - createdAttr = doc.createAttribute(""); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentinvalidcharacterexceptioncreateattribute1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_documentinvalidcharacterexceptioncreateattribute1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentinvalidcharacterexceptioncreateelement.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentinvalidcharacterexceptioncreateelement.java deleted file mode 100644 index 8e9029af6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentinvalidcharacterexceptioncreateelement.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createElement(tagName)" method raises an - * INVALID_CHARACTER_ERR DOMException if the specified - * tagName contains an invalid character. - * - * Retrieve the entire DOM document and invoke its - * "createElement(tagName)" method with the tagName equal - * to the string "invalid^Name". Due to the invalid - * character the desired EXCEPTION should be raised. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-2141741547')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class hc_documentinvalidcharacterexceptioncreateelement extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_documentinvalidcharacterexceptioncreateelement(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element badElement; - doc = (Document) load("hc_staff", true); - - { - boolean success = false; - try { - badElement = doc.createElement("invalid^Name"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentinvalidcharacterexceptioncreateelement"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_documentinvalidcharacterexceptioncreateelement.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentinvalidcharacterexceptioncreateelement1.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentinvalidcharacterexceptioncreateelement1.java deleted file mode 100644 index bf59e22e0..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_documentinvalidcharacterexceptioncreateelement1.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Creating an element with an empty name should cause an INVALID_CHARACTER_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-2141741547')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525 -*/ -public final class hc_documentinvalidcharacterexceptioncreateelement1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_documentinvalidcharacterexceptioncreateelement1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element badElement; - doc = (Document) load("hc_staff", true); - - { - boolean success = false; - try { - badElement = doc.createElement(""); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentinvalidcharacterexceptioncreateelement1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_documentinvalidcharacterexceptioncreateelement1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_domimplementationfeaturenoversion.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_domimplementationfeaturenoversion.java deleted file mode 100644 index e4ad27c73..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_domimplementationfeaturenoversion.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Load a document and invoke its - * "getImplementation()" method. This should create a - * DOMImplementation object whose "hasFeature(feature, - * version)" method is invoked with version equal to "". - * If the version is not specified, supporting any version - * feature will cause the method to return "true". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7 -* @see http://www.w3.org/2000/11/DOM-Level-2-errata#core-14 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=245 -*/ -public final class hc_domimplementationfeaturenoversion extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_domimplementationfeaturenoversion(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation domImpl; - boolean state; - doc = (Document) load("hc_staff", false); - domImpl = doc.getImplementation(); - - if (("text/html".equals(getContentType()))) { - state = domImpl.hasFeature("HTML", ""); -} else { - state = domImpl.hasFeature("XML", ""); -} - - assertTrue("hasFeatureBlank", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_domimplementationfeaturenoversion"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_domimplementationfeaturenoversion.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_domimplementationfeaturenull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_domimplementationfeaturenull.java deleted file mode 100644 index 1eb79105e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_domimplementationfeaturenull.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Load a document and invoke its - * "getImplementation()" method. This should create a - * DOMImplementation object whose "hasFeature(feature, - * version)" method is invoked with version equal to null. - * If the version is not specified, supporting any version - * feature will cause the method to return "true". -* @author Curt Arnold -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7 -* @see http://www.w3.org/2000/11/DOM-Level-2-errata#core-14 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=245 -*/ -public final class hc_domimplementationfeaturenull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_domimplementationfeaturenull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.hasNullString - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation domImpl; - boolean state; - doc = (Document) load("hc_staff", false); - domImpl = doc.getImplementation(); - - if (("text/html".equals(getContentType()))) { - state = domImpl.hasFeature("HTML", null); -assertTrue("supports_HTML_null", state); - } else { - state = domImpl.hasFeature("XML", null); -assertTrue("supports_XML_null", state); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_domimplementationfeaturenull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_domimplementationfeaturenull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_domimplementationfeaturexml.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_domimplementationfeaturexml.java deleted file mode 100644 index f66622d6e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_domimplementationfeaturexml.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the entire DOM document and invoke its - * "getImplementation()" method. This should create a - * DOMImplementation object whose "hasFeature(feature, - * version)" method is invoked with "feature" equal to "html" or "xml". - * The method should return a boolean "true". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=245 -*/ -public final class hc_domimplementationfeaturexml extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_domimplementationfeaturexml(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation domImpl; - boolean state; - doc = (Document) load("hc_staff", false); - domImpl = doc.getImplementation(); - - if (("text/html".equals(getContentType()))) { - state = domImpl.hasFeature("html", "1.0"); -assertTrue("supports_html_1.0", state); - } else { - state = domImpl.hasFeature("xml", "1.0"); -assertTrue("supports_xml_1.0", state); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_domimplementationfeaturexml"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_domimplementationfeaturexml.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementaddnewattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementaddnewattribute.java deleted file mode 100644 index 759b5791e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementaddnewattribute.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttribute(name,value)" method adds a new attribute - * to the Element - * - * Retrieve the last child of the last employee, then - * add an attribute to it by invoking the - * "setAttribute(name,value)" method. It should create - * a "strong" attribute with an assigned value equal to - * "value". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243 -*/ -public final class hc_elementaddnewattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementaddnewattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - String attrValue; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = (Element) elementList.item(4); - testEmployee.setAttribute("lang", "EN-us"); - attrValue = testEmployee.getAttribute("lang"); - assertEquals("attrValue", "EN-us", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementaddnewattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementaddnewattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementassociatedattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementassociatedattribute.java deleted file mode 100644 index 706bfcbb5..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementassociatedattribute.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the first attribute from the last child of - * the first employee and invoke the "getSpecified()" - * method. This test is only intended to show that - * Elements can actually have attributes. This test uses - * the "getNamedItem(name)" method from the NamedNodeMap - * interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -*/ -public final class hc_elementassociatedattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementassociatedattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - NamedNodeMap attributes; - Attr domesticAttr; - boolean specified; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = elementList.item(0); - attributes = testEmployee.getAttributes(); - domesticAttr = (Attr) attributes.getNamedItem("title"); - specified = domesticAttr.getSpecified(); - assertTrue("acronymTitleSpecified", specified); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementassociatedattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementassociatedattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementchangeattributevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementchangeattributevalue.java deleted file mode 100644 index 35b2e51ec..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementchangeattributevalue.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttribute(name,value)" method adds a new attribute - * to the Element. If the "strong" is already present, then - * its value should be changed to the new one that is in - * the "value" parameter. - * - * Retrieve the last child of the fourth employee, then add - * an attribute to it by invoking the - * "setAttribute(name,value)" method. Since the name of the - * used attribute("class") is already present in this - * element, then its value should be changed to the new one - * of the "value" parameter. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082 -*/ -public final class hc_elementchangeattributevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementchangeattributevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - String attrValue; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = (Element) elementList.item(3); - testEmployee.setAttribute("class", "Neither"); - attrValue = testEmployee.getAttribute("class"); - assertEquals("elementChangeAttributeValueAssert", "Neither", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementchangeattributevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementchangeattributevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementcreatenewattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementcreatenewattribute.java deleted file mode 100644 index ddd5b6a2d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementcreatenewattribute.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNode(newAttr)" method adds a new - * attribute to the Element. - * - * Retrieve first address element and add - * a new attribute node to it by invoking its - * "setAttributeNode(newAttr)" method. This test makes use - * of the "createAttribute(name)" method from the Document - * interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243 -*/ -public final class hc_elementcreatenewattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementcreatenewattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddress; - Attr newAttribute; - Attr oldAttr; - Attr districtAttr; - String attrVal; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testAddress = (Element) elementList.item(0); - newAttribute = doc.createAttribute("lang"); - oldAttr = testAddress.setAttributeNode(newAttribute); - assertNull("old_attr_doesnt_exist", oldAttr); - districtAttr = testAddress.getAttributeNode("lang"); - assertNotNull("new_district_accessible", districtAttr); - attrVal = testAddress.getAttribute("lang"); - assertEquals("attr_value", "", attrVal); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementcreatenewattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementcreatenewattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetattributenode.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetattributenode.java deleted file mode 100644 index 90bc7f4e3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetattributenode.java +++ /dev/null @@ -1,87 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the attribute "title" from the last child - * of the first "p" element and check its node name. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-217A91B8 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html -*/ -public final class hc_elementgetattributenode extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementgetattributenode(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - Attr domesticAttr; - String nodeName; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = (Element) elementList.item(0); - domesticAttr = testEmployee.getAttributeNode("title"); - nodeName = domesticAttr.getNodeName(); - assertEqualsAutoCase("attribute", "nodeName", "title", nodeName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementgetattributenode"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementgetattributenode.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetattributenodenull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetattributenodenull.java deleted file mode 100644 index 29416936d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetattributenodenull.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributeNode(name)" method retrieves an - * attribute node by name. It should return null if the - * "strong" attribute does not exist. - * - * Retrieve the last child of the first employee and attempt - * to retrieve a non-existing attribute. The method should - * return "null". The non-existing attribute to be used - * is "invalidAttribute". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-217A91B8 -*/ -public final class hc_elementgetattributenodenull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementgetattributenodenull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - Attr domesticAttr; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = (Element) elementList.item(0); - domesticAttr = testEmployee.getAttributeNode("invalidAttribute"); - assertNull("elementGetAttributeNodeNullAssert", domesticAttr); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementgetattributenodenull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementgetattributenodenull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementempty.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementempty.java deleted file mode 100644 index 69241875c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementempty.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttribute(name)" method returns an empty - * string if no value was assigned to an attribute and - * no default value was given in the DTD file. - * - * Retrieve the last child of the last employee, then - * invoke "getAttribute(name)" method, where "strong" is an - * attribute without a specified or DTD default value. - * The "getAttribute(name)" method should return the empty - * string. This method makes use of the - * "createAttribute(newAttr)" method from the Document - * interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-666EE0F9 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243 -*/ -public final class hc_elementgetelementempty extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementgetelementempty(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr newAttribute; - NodeList elementList; - Element testEmployee; - Attr domesticAttr; - String attrValue; - doc = (Document) load("hc_staff", true); - newAttribute = doc.createAttribute("lang"); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = (Element) elementList.item(3); - domesticAttr = testEmployee.setAttributeNode(newAttribute); - attrValue = testEmployee.getAttribute("lang"); - assertEquals("elementGetElementEmptyAssert", "", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementgetelementempty"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementgetelementempty.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementsbytagname.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementsbytagname.java deleted file mode 100644 index 37d1e22c3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementsbytagname.java +++ /dev/null @@ -1,85 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagName(name)" method returns a list - * of all descendant Elements with the given tag name. - * Test for an empty list. - * Create a NodeList of all the descendant elements - * using the string "noMatch" as the tagName. - * The method should return a NodeList whose length is - * "0" since there are not any descendant elements - * that match the given tag name. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D -*/ -public final class hc_elementgetelementsbytagname extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementgetelementsbytagname(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("p"); - assertSize("elementGetElementsByTagNameAssert", 5, elementList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementgetelementsbytagname"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementgetelementsbytagname.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementsbytagnameaccessnodelist.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementsbytagnameaccessnodelist.java deleted file mode 100644 index 557071b40..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementsbytagnameaccessnodelist.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagName(name)" method returns a list - * of all descendant Elements in the order the children - * were encountered in a pre order traversal of the element - * tree. - * Create a NodeList of all the descendant elements - * using the string "p" as the tagName. - * The method should return a NodeList whose length is - * "5" in the order the children were encountered. - * Access the FOURTH element in the NodeList. The FOURTH - * element, the first or second should be an "em" node with - * the content "EMP0004". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_elementgetelementsbytagnameaccessnodelist extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementgetelementsbytagnameaccessnodelist(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - Node firstC; - String childName; - int nodeType; - CharacterData employeeIDNode; - String employeeID; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("p"); - testEmployee = (Element) elementList.item(3); - firstC = testEmployee.getFirstChild(); - nodeType = (int) firstC.getNodeType(); - - while (equals(3, nodeType)) { - firstC = firstC.getNextSibling(); - nodeType = (int) firstC.getNodeType(); - - } -childName = firstC.getNodeName(); - assertEqualsAutoCase("element", "childName", "em", childName); - employeeIDNode = (CharacterData) firstC.getFirstChild(); - employeeID = employeeIDNode.getNodeValue(); - assertEquals("employeeID", "EMP0004", employeeID); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementgetelementsbytagnameaccessnodelist"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementgetelementsbytagnameaccessnodelist.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementsbytagnamenomatch.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementsbytagnamenomatch.java deleted file mode 100644 index f5dc79e4d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementsbytagnamenomatch.java +++ /dev/null @@ -1,83 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagName(name)" method returns a list - * of all descendant Elements with the given tag name. - * Create a NodeList of all the descendant elements - * using the string "employee" as the tagName. - * The method should return a NodeList whose length is - * "5". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D -*/ -public final class hc_elementgetelementsbytagnamenomatch extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementgetelementsbytagnamenomatch(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("noMatch"); - assertSize("elementGetElementsByTagNameNoMatchNoMatchAssert", 0, elementList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementgetelementsbytagnamenomatch"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementgetelementsbytagnamenomatch.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementsbytagnamespecialvalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementsbytagnamespecialvalue.java deleted file mode 100644 index 30abebb18..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgetelementsbytagnamespecialvalue.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagName(name)" method may use the - * special value "*" to match all tags in the element - * tree. - * Create a NodeList of all the descendant elements - * of the last employee by using the special value "*". - * The method should return all the descendant children(6) - * in the order the children were encountered. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D -*/ -public final class hc_elementgetelementsbytagnamespecialvalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementgetelementsbytagnamespecialvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element lastEmployee; - NodeList lastempList; - Node child; - String childName; - java.util.List result = new java.util.ArrayList(); - - java.util.List expectedResult = new java.util.ArrayList(); - expectedResult.add("em"); - expectedResult.add("strong"); - expectedResult.add("code"); - expectedResult.add("sup"); - expectedResult.add("var"); - expectedResult.add("acronym"); - - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("p"); - lastEmployee = (Element) elementList.item(4); - lastempList = lastEmployee.getElementsByTagName("*"); - for (int indexN10067 = 0; indexN10067 < lastempList.getLength(); indexN10067++) { - child = (Node) lastempList.item(indexN10067); - childName = child.getNodeName(); - result.add(childName); - } - assertEqualsAutoCase("element", "tagNames", expectedResult, result); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementgetelementsbytagnamespecialvalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementgetelementsbytagnamespecialvalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgettagname.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgettagname.java deleted file mode 100644 index a382e0e34..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementgettagname.java +++ /dev/null @@ -1,88 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Invoke the "getTagName()" method one the - * root node. The value returned should be "html" or "svg". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-104682815 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251 -*/ -public final class hc_elementgettagname extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementgettagname(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element root; - String tagname; - doc = (Document) load("hc_staff", false); - root = doc.getDocumentElement(); - tagname = root.getTagName(); - - if (("image/svg+xml".equals(getContentType()))) { - assertEquals("svgTagname", "svg", tagname); - } else { - assertEqualsAutoCase("element", "tagname", "html", tagname); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementgettagname"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementgettagname.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementinuseattributeerr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementinuseattributeerr.java deleted file mode 100644 index 168a00edf..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementinuseattributeerr.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNode(newAttr)" method raises an - * "INUSE_ATTRIBUTE_ERR DOMException if the "newAttr" - * is already an attribute of another element. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-887236154')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=244 -*/ -public final class hc_elementinuseattributeerr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementinuseattributeerr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr newAttribute; - NodeList addressElementList; - Element testAddress; - Element newElement; - Attr attrAddress; - Node appendedChild; - Attr setAttr1; - Attr setAttr2; - doc = (Document) load("hc_staff", true); - addressElementList = doc.getElementsByTagName("body"); - testAddress = (Element) addressElementList.item(0); - newElement = doc.createElement("p"); - appendedChild = testAddress.appendChild(newElement); - newAttribute = doc.createAttribute("title"); - setAttr1 = newElement.setAttributeNode(newAttribute); - - { - boolean success = false; - try { - setAttr2 = testAddress.setAttributeNode(newAttribute); - } catch (DOMException ex) { - success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR); - } - assertTrue("throw_INUSE_ATTRIBUTE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementinuseattributeerr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementinuseattributeerr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementinvalidcharacterexception.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementinvalidcharacterexception.java deleted file mode 100644 index d7bfff536..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementinvalidcharacterexception.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttribute(name,value)" method raises an - * "INVALID_CHARACTER_ERR DOMException if the specified - * name contains an invalid character. - * Retrieve the last child of the first employee and - * call its "setAttribute(name,value)" method with - * "strong" containing an invalid character. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-F68F082')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class hc_elementinvalidcharacterexception extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementinvalidcharacterexception(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddress; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testAddress = (Element) elementList.item(0); - - { - boolean success = false; - try { - testAddress.setAttribute("invalid^Name", "value"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementinvalidcharacterexception"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementinvalidcharacterexception.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementinvalidcharacterexception1.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementinvalidcharacterexception1.java deleted file mode 100644 index c2886aedc..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementinvalidcharacterexception1.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Calling Element.setAttribute with an empty name will cause an INVALID_CHARACTER_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-F68F082')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525 -*/ -public final class hc_elementinvalidcharacterexception1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementinvalidcharacterexception1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddress; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testAddress = (Element) elementList.item(0); - - { - boolean success = false; - try { - testAddress.setAttribute("", "value"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementinvalidcharacterexception1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementinvalidcharacterexception1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementnormalize.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementnormalize.java deleted file mode 100644 index fb1714db3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementnormalize.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Append a couple of text nodes to the first sup element, normalize the - * document element and check that the element has been normalized. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-162CF083 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=546 -*/ -public final class hc_elementnormalize extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementnormalize(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element root; - NodeList elementList; - Element testName; - Node firstChild; - String childValue; - Text textNode; - Node retNode; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("sup"); - testName = (Element) elementList.item(0); - textNode = doc.createTextNode(""); - retNode = testName.appendChild(textNode); - textNode = doc.createTextNode(",000"); - retNode = testName.appendChild(textNode); - root = doc.getDocumentElement(); - root.normalize(); - elementList = doc.getElementsByTagName("sup"); - testName = (Element) elementList.item(0); - firstChild = testName.getFirstChild(); - childValue = firstChild.getNodeValue(); - assertEquals("elementNormalizeAssert", "56,000,000", childValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementnormalize"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementnormalize.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementnormalize2.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementnormalize2.java deleted file mode 100644 index 0f64fa537..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementnormalize2.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Add an empty text node to an existing attribute node, normalize the containing element - * and check that the attribute node has eliminated the empty text. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-162CF083 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=482 -*/ -public final class hc_elementnormalize2 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementnormalize2(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element root; - NodeList elementList; - Element element; - Node firstChild; - Node secondChild; - String childValue; - Text emptyText; - Attr attrNode; - Node retval; - doc = (Document) load("hc_staff", true); - root = doc.getDocumentElement(); - emptyText = doc.createTextNode(""); - elementList = root.getElementsByTagName("acronym"); - element = (Element) elementList.item(0); - attrNode = element.getAttributeNode("title"); - retval = attrNode.appendChild(emptyText); - element.normalize(); - attrNode = element.getAttributeNode("title"); - firstChild = attrNode.getFirstChild(); - childValue = firstChild.getNodeValue(); - assertEquals("firstChild", "Yes", childValue); - secondChild = firstChild.getNextSibling(); - assertNull("secondChildNull", secondChild); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementnormalize2"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementnormalize2.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementnotfounderr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementnotfounderr.java deleted file mode 100644 index e88545af1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementnotfounderr.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeAttributeNode(oldAttr)" method raises a - * NOT_FOUND_ERR DOMException if the "oldAttr" attribute - * is not an attribute of the element. - * - * Retrieve the last employee and attempt to remove - * a non existing attribute node. This should cause the - * intended exception to be raised. This test makes use - * of the "createAttribute(name)" method from the Document - * interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-D589198')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class hc_elementnotfounderr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementnotfounderr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr oldAttribute; - NodeList addressElementList; - Element testAddress; - Attr attrAddress; - doc = (Document) load("hc_staff", true); - addressElementList = doc.getElementsByTagName("acronym"); - testAddress = (Element) addressElementList.item(4); - oldAttribute = doc.createAttribute("title"); - - { - boolean success = false; - try { - attrAddress = testAddress.removeAttributeNode(oldAttribute); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_FOUND_ERR); - } - assertTrue("throw_NOT_FOUND_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementnotfounderr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementnotfounderr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementremoveattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementremoveattribute.java deleted file mode 100644 index acf6dc362..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementremoveattribute.java +++ /dev/null @@ -1,87 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeAttribute(name)" removes an attribute by name. - * If the attribute has a default value, it is immediately - * replaced. However, there is no default values in the HTML - * compatible tests, so its value is "". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html -*/ -public final class hc_elementremoveattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementremoveattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - String attrValue; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = (Element) elementList.item(3); - testEmployee.removeAttribute("class"); - attrValue = testEmployee.getAttribute("class"); - assertEquals("attrValue", "", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementremoveattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementremoveattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementremoveattributeaftercreate.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementremoveattributeaftercreate.java deleted file mode 100644 index 0ec73a943..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementremoveattributeaftercreate.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeAttributeNode(oldAttr)" method removes the - * specified attribute. - * - * Retrieve the last child of the third employee, add a - * new "lang" attribute to it and then try to remove it. - * To verify that the node was removed use the - * "getNamedItem(name)" method from the NamedNodeMap - * interface. It also uses the "getAttributes()" method - * from the Node interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243 -*/ -public final class hc_elementremoveattributeaftercreate extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementremoveattributeaftercreate(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - Attr newAttribute; - NamedNodeMap attributes; - Attr districtAttr; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = (Element) elementList.item(2); - newAttribute = doc.createAttribute("lang"); - districtAttr = testEmployee.setAttributeNode(newAttribute); - districtAttr = testEmployee.removeAttributeNode(newAttribute); - attributes = testEmployee.getAttributes(); - districtAttr = (Attr) attributes.getNamedItem("lang"); - assertNull("removed_item_null", districtAttr); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementremoveattributeaftercreate"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementremoveattributeaftercreate.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementremoveattributenode.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementremoveattributenode.java deleted file mode 100644 index 509611441..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementremoveattributenode.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeAttributeNode(oldAttr)" method returns the - * node that was removed. - * - * Retrieve the last child of the third employee and - * remove its "class" Attr node. The method should - * return the old attribute node. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198 -*/ -public final class hc_elementremoveattributenode extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementremoveattributenode(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - Attr streetAttr; - Attr removedAttr; - String removedValue; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = (Element) elementList.item(2); - streetAttr = testEmployee.getAttributeNode("class"); - removedAttr = testEmployee.removeAttributeNode(streetAttr); - assertNotNull("removedAttrNotNull", removedAttr); - removedValue = removedAttr.getValue(); - assertEquals("elementRemoveAttributeNodeAssert", "No", removedValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementremoveattributenode"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementremoveattributenode.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementreplaceattributewithself.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementreplaceattributewithself.java deleted file mode 100644 index bb8661c06..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementreplaceattributewithself.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * This test calls setAttributeNode to replace an attribute with itself. - * Since the node is not an attribute of another Element, it would - * be inappropriate to throw an INUSE_ATTRIBUTE_ERR. - * This test was derived from elementinuserattributeerr which - * inadvertanly made this test. -* @author Curt Arnold -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 -*/ -public final class hc_elementreplaceattributewithself extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementreplaceattributewithself(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - Attr streetAttr; - Attr replacedAttr; - String value; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = (Element) elementList.item(2); - streetAttr = testEmployee.getAttributeNode("class"); - replacedAttr = testEmployee.setAttributeNode(streetAttr); - assertSame("replacedAttr", streetAttr, replacedAttr); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementreplaceattributewithself"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementreplaceattributewithself.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementreplaceexistingattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementreplaceexistingattribute.java deleted file mode 100644 index b21e265d9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementreplaceexistingattribute.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNode(newAttr)" method adds a new - * attribute to the Element. If the "newAttr" Attr node is - * already present in this element, it should replace the - * existing one. - * - * Retrieve the last child of the third employee and add a - * new attribute node by invoking the "setAttributeNode(new - * Attr)" method. The new attribute node to be added is - * "class", which is already present in this element. The - * method should replace the existing Attr node with the - * new one. This test uses the "createAttribute(name)" - * method from the Document interface. -* @author Curt Arnold -*/ -public final class hc_elementreplaceexistingattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementreplaceexistingattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - Attr newAttribute; - String strong; - Attr setAttr; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = (Element) elementList.item(2); - newAttribute = doc.createAttribute("class"); - setAttr = testEmployee.setAttributeNode(newAttribute); - strong = testEmployee.getAttribute("class"); - assertEquals("replacedValue", "", strong); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementreplaceexistingattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementreplaceexistingattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementreplaceexistingattributegevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementreplaceexistingattributegevalue.java deleted file mode 100644 index 69c37b983..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementreplaceexistingattributegevalue.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the "setAttributeNode(newAttr)" method replaces an - * existing Attr node with the same name, then it should - * return the previously existing Attr node. - * Retrieve the last child of the third employee and add a - * new attribute node. The new attribute node is "class", - * which is already present in this Element. The method - * should return the existing Attr node(old "class" Attr). - * This test uses the "createAttribute(name)" method - * from the Document interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 -*/ -public final class hc_elementreplaceexistingattributegevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementreplaceexistingattributegevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - Attr newAttribute; - Attr streetAttr; - String value; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = (Element) elementList.item(2); - newAttribute = doc.createAttribute("class"); - streetAttr = testEmployee.setAttributeNode(newAttribute); - assertNotNull("previousAttrNotNull", streetAttr); - value = streetAttr.getValue(); - assertEquals("previousAttrValue", "No", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementreplaceexistingattributegevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementreplaceexistingattributegevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementretrieveallattributes.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementretrieveallattributes.java deleted file mode 100644 index e12fb822e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementretrieveallattributes.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Create a list of all the attributes of the last child - * of the first "p" element by using the "getAttributes()" - * method. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184 -*/ -public final class hc_elementretrieveallattributes extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementretrieveallattributes(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testAddress; - NamedNodeMap attributes; - Attr attribute; - String attributeName; - java.util.Collection actual = new java.util.ArrayList(); - - java.util.Collection htmlExpected = new java.util.ArrayList(); - htmlExpected.add("title"); - - java.util.Collection expected = new java.util.ArrayList(); - expected.add("title"); - expected.add("dir"); - - doc = (Document) load("hc_staff", false); - addressList = doc.getElementsByTagName("acronym"); - testAddress = addressList.item(0); - attributes = testAddress.getAttributes(); - for (int indexN1006B = 0; indexN1006B < attributes.getLength(); indexN1006B++) { - attribute = (Attr) attributes.item(indexN1006B); - attributeName = attribute.getNodeName(); - actual.add(attributeName); - } - - if (("text/html".equals(getContentType()))) { - assertEqualsIgnoreCase("htmlAttributeNames", htmlExpected, actual); -} else { - assertEqualsIgnoreCase("attributeNames", expected, actual); -} - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementretrieveallattributes"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementretrieveallattributes.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementretrieveattrvalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementretrieveattrvalue.java deleted file mode 100644 index fac3d2a56..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementretrieveattrvalue.java +++ /dev/null @@ -1,87 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttribute(name)" method returns an attribute - * value by name. - * - * Retrieve the second address element, then - * invoke the 'getAttribute("class")' method. This should - * return the value of the attribute("No"). -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-666EE0F9 -*/ -public final class hc_elementretrieveattrvalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementretrieveattrvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddress; - String attrValue; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - testAddress = (Element) elementList.item(2); - attrValue = testAddress.getAttribute("class"); - assertEquals("attrValue", "No", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementretrieveattrvalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementretrieveattrvalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementretrievetagname.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementretrievetagname.java deleted file mode 100644 index aaa4d7af1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementretrievetagname.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagName()" method returns a NodeList - * of all descendant elements with a given tagName. - * - * Invoke the "getElementsByTagName()" method and create - * a NodeList of "code" elements. Retrieve the second - * "code" element in the list and return the NodeName. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-104682815 -*/ -public final class hc_elementretrievetagname extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementretrievetagname(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - String strong; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("code"); - testEmployee = elementList.item(1); - strong = testEmployee.getNodeName(); - assertEqualsAutoCase("element", "nodename", "code", strong); - strong = ((Element) /*Node */testEmployee).getTagName(); - assertEqualsAutoCase("element", "tagname", "code", strong); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementretrievetagname"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementretrievetagname.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementsetattributenodenull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementsetattributenodenull.java deleted file mode 100644 index 709142fa7..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementsetattributenodenull.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNode(newAttr)" method returns the - * null value if no previously existing Attr node with the - * same name was replaced. - * - * Retrieve the last child of the third employee and add a - * new attribute to it. The new attribute node added is - * "lang", which is not part of this Element. The - * method should return the null value. - * This test uses the "createAttribute(name)" - * method from the Document interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243 -*/ -public final class hc_elementsetattributenodenull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementsetattributenodenull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - Attr newAttribute; - Attr districtAttr; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = (Element) elementList.item(2); - newAttribute = doc.createAttribute("lang"); - districtAttr = testEmployee.setAttributeNode(newAttribute); - assertNull("elementSetAttributeNodeNullAssert", districtAttr); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementsetattributenodenull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementsetattributenodenull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementwrongdocumenterr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementwrongdocumenterr.java deleted file mode 100644 index e8e176a16..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_elementwrongdocumenterr.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNode(newAttr)" method raises an - * "WRONG_DOCUMENT_ERR DOMException if the "newAttr" - * was created from a different document than the one that - * created this document. - * Retrieve the last employee and attempt to set a new - * attribute node for its "employee" element. The new - * attribute was created from a document other than the - * one that created this element, therefore a - * WRONG_DOCUMENT_ERR DOMException should be raised. - * This test uses the "createAttribute(newAttr)" method - * from the Document interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-887236154')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class hc_elementwrongdocumenterr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_elementwrongdocumenterr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc1; - Document doc2; - Attr newAttribute; - NodeList addressElementList; - Element testAddress; - Attr attrAddress; - doc1 = (Document) load("hc_staff", true); - doc2 = (Document) load("hc_staff", false); - newAttribute = doc2.createAttribute("newAttribute"); - addressElementList = doc1.getElementsByTagName("acronym"); - testAddress = (Element) addressElementList.item(4); - - { - boolean success = false; - try { - attrAddress = testAddress.setAttributeNode(newAttribute); - } catch (DOMException ex) { - success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); - } - assertTrue("throw_WRONG_DOCUMENT_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementwrongdocumenterr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_elementwrongdocumenterr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_entitiesremovenameditem1.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_entitiesremovenameditem1.java deleted file mode 100644 index be6b5ea56..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_entitiesremovenameditem1.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An attempt to add remove an entity should result in a NO_MODIFICATION_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1788794630 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193 -*/ -public final class hc_entitiesremovenameditem1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_entitiesremovenameditem1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - if (factory.hasFeature("XML", null) != true) { - throw org.w3c.domts.DOMTestIncompatibleException.incompatibleFeature("XML", null); - } - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap entities; - DocumentType docType; - Node retval; - doc = (Document) load("hc_staff", true); - docType = doc.getDoctype(); - - if ( - !(("text/html".equals(getContentType()))) -) { - assertNotNull("docTypeNotNull", docType); - entities = docType.getEntities(); - assertNotNull("entitiesNotNull", entities); - - { - boolean success = false; - try { - retval = entities.removeNamedItem("alpha"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_entitiesremovenameditem1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_entitiesremovenameditem1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_entitiessetnameditem1.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_entitiessetnameditem1.java deleted file mode 100644 index 890f35a9c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_entitiessetnameditem1.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An attempt to add an element to the named node map returned by entities should - * result in a NO_MODIFICATION_ERR or HIERARCHY_REQUEST_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1788794630 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788 -*/ -public final class hc_entitiessetnameditem1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_entitiessetnameditem1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - if (factory.hasFeature("XML", null) != true) { - throw org.w3c.domts.DOMTestIncompatibleException.incompatibleFeature("XML", null); - } - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap entities; - DocumentType docType; - Node retval; - Element elem; - doc = (Document) load("hc_staff", true); - docType = doc.getDoctype(); - - if ( - !(("text/html".equals(getContentType()))) -) { - assertNotNull("docTypeNotNull", docType); - entities = docType.getEntities(); - assertNotNull("entitiesNotNull", entities); - elem = doc.createElement("br"); - - try { - retval = entities.setNamedItem(elem); - fail("throw_HIER_OR_NO_MOD_ERR"); - - } catch (DOMException ex) { - switch (ex.code) { - case 3 : - break; - case 7 : - break; - default: - throw ex; - } - } -} - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_entitiessetnameditem1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_entitiessetnameditem1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapchildnoderange.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapchildnoderange.java deleted file mode 100644 index 1283a6175..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapchildnoderange.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Create a NamedNodeMap object from the attributes of the - * last child of the third "p" element and traverse the - * list from index 0 thru length -1. All indices should - * be valid. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D0FB19E -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=250 -*/ -public final class hc_namednodemapchildnoderange extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_namednodemapchildnoderange(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - NamedNodeMap attributes; - Node child; - String strong; - int length; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = elementList.item(2); - attributes = testEmployee.getAttributes(); - length = (int) attributes.getLength(); - - if (("text/html".equals(getContentType()))) { - assertEquals("htmlLength", 2, length); - } else { - assertEquals("length", 3, length); - child = attributes.item(2); - assertNotNull("attr2", child); - } - - child = attributes.item(0); - assertNotNull("attr0", child); - child = attributes.item(1); - assertNotNull("attr1", child); - child = attributes.item(3); - assertNull("attr3", child); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapchildnoderange"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_namednodemapchildnoderange.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapgetnameditem.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapgetnameditem.java deleted file mode 100644 index fe9e79343..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapgetnameditem.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the second "p" element and create a NamedNodeMap - * listing of the attributes of the last child. Once the - * list is created an invocation of the "getNamedItem(name)" - * method is done with name="title". This should result - * in the title Attr node being returned. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html -*/ -public final class hc_namednodemapgetnameditem extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_namednodemapgetnameditem(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - NamedNodeMap attributes; - Attr domesticAttr; - String attrName; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = elementList.item(1); - attributes = testEmployee.getAttributes(); - domesticAttr = (Attr) attributes.getNamedItem("title"); - attrName = domesticAttr.getNodeName(); - assertEqualsAutoCase("attribute", "nodeName", "title", attrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapgetnameditem"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_namednodemapgetnameditem.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapinuseattributeerr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapinuseattributeerr.java deleted file mode 100644 index e8d326855..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapinuseattributeerr.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setNamedItem(arg)" method raises a - * INUSE_ATTRIBUTE_ERR DOMException if "arg" is an - * Attr that is already in an attribute of another Element. - * Create a NamedNodeMap object from the attributes of the - * last child of the third employee and attempt to add - * an attribute that is already being used by the first - * employee. This should raise the desired exception. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1025163788')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class hc_namednodemapinuseattributeerr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_namednodemapinuseattributeerr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element firstNode; - Node testNode; - NamedNodeMap attributes; - Attr domesticAttr; - Attr setAttr; - Node setNode; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - firstNode = (Element) elementList.item(0); - domesticAttr = doc.createAttribute("title"); - domesticAttr.setValue("Yα"); - setAttr = firstNode.setAttributeNode(domesticAttr); - elementList = doc.getElementsByTagName("acronym"); - testNode = elementList.item(2); - attributes = testNode.getAttributes(); - - { - boolean success = false; - try { - setNode = attributes.setNamedItem(domesticAttr); - } catch (DOMException ex) { - success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR); - } - assertTrue("throw_INUSE_ATTRIBUTE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapinuseattributeerr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_namednodemapinuseattributeerr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapnotfounderr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapnotfounderr.java deleted file mode 100644 index ed6b86f4d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapnotfounderr.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeNamedItem(name)" method raises a - * NOT_FOUND_ERR DOMException if there is not a node - * named "strong" in the map. - * - * Create a NamedNodeMap object from the attributes of the - * last child of the third employee and attempt to remove - * the "lang" attribute. There is not a node named - * "lang" in the list and therefore the desired - * exception should be raised. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-D58B193')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243 -*/ -public final class hc_namednodemapnotfounderr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_namednodemapnotfounderr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - NamedNodeMap attributes; - Node removedNode; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = (Element) elementList.item(2); - attributes = testEmployee.getAttributes(); - - { - boolean success = false; - try { - removedNode = attributes.removeNamedItem("lang"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_FOUND_ERR); - } - assertTrue("throw_NOT_FOUND_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapnotfounderr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_namednodemapnotfounderr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapnumberofnodes.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapnumberofnodes.java deleted file mode 100644 index e4a4965da..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapnumberofnodes.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the second "p" element and evaluate Node.attributes.length. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D0FB19E -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=250 -*/ -public final class hc_namednodemapnumberofnodes extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_namednodemapnumberofnodes(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - NamedNodeMap attributes; - int length; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = elementList.item(2); - attributes = testEmployee.getAttributes(); - length = (int) attributes.getLength(); - - if (("text/html".equals(getContentType()))) { - assertEquals("htmlLength", 2, length); - } else { - assertEquals("length", 3, length); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapnumberofnodes"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_namednodemapnumberofnodes.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapremovenameditem.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapremovenameditem.java deleted file mode 100644 index 02b7a60da..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapremovenameditem.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeNamedItem(name)" method removes a node - * specified by name. - * - * Retrieve the third employee and create a NamedNodeMap - * object of the attributes of the last child. Once the - * list is created invoke the "removeNamedItem(name)" - * method with name="class". This should result - * in the removal of the specified attribute. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html -*/ -public final class hc_namednodemapremovenameditem extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_namednodemapremovenameditem(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Attr newAttribute; - Node testAddress; - NamedNodeMap attributes; - Attr streetAttr; - boolean specified; - Node removedNode; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testAddress = elementList.item(2); - attributes = testAddress.getAttributes(); - removedNode = attributes.removeNamedItem("class"); - streetAttr = (Attr) attributes.getNamedItem("class"); - assertNull("isnull", streetAttr); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapremovenameditem"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_namednodemapremovenameditem.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapreturnattrnode.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapreturnattrnode.java deleted file mode 100644 index fd4793a2f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapreturnattrnode.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the second p element and create a NamedNodeMap - * listing of the attributes of the last child. Once the - * list is created an invocation of the "getNamedItem(name)" - * method is done with name="class". This should result - * in the method returning an Attr node. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1112119403 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236 -*/ -public final class hc_namednodemapreturnattrnode extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_namednodemapreturnattrnode(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - NamedNodeMap attributes; - Node streetAttr; - String attrName; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = elementList.item(1); - attributes = testEmployee.getAttributes(); - streetAttr = attributes.getNamedItem("class"); - assertInstanceOf("typeAssert", Attr.class, streetAttr); -attrName = streetAttr.getNodeName(); - assertEqualsAutoCase("attribute", "nodeName", "class", attrName); - attrName = ((Attr) /*Node */streetAttr).getName(); - assertEqualsAutoCase("attribute", "name", "class", attrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapreturnattrnode"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_namednodemapreturnattrnode.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapreturnfirstitem.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapreturnfirstitem.java deleted file mode 100644 index 20fd55def..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapreturnfirstitem.java +++ /dev/null @@ -1,114 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "item(index)" method returns the indexth item in - * the map(test for first item). - * - * Retrieve the second "acronym" get the NamedNodeMap of the attributes. Since the - * DOM does not specify an order of these nodes the contents - * of the FIRST node can contain either "title", "class" or "dir". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184 -*/ -public final class hc_namednodemapreturnfirstitem extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_namednodemapreturnfirstitem(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testAddress; - NamedNodeMap attributes; - Node child; - String nodeName; - java.util.Collection htmlExpected = new java.util.ArrayList(); - htmlExpected.add("title"); - htmlExpected.add("class"); - - java.util.Collection expected = new java.util.ArrayList(); - expected.add("title"); - expected.add("class"); - expected.add("dir"); - - java.util.Collection actual = new java.util.ArrayList(); - - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testAddress = elementList.item(1); - attributes = testAddress.getAttributes(); - for (int indexN10070 = 0; indexN10070 < attributes.getLength(); indexN10070++) { - child = (Node) attributes.item(indexN10070); - nodeName = child.getNodeName(); - actual.add(nodeName); - } - - if (("text/html".equals(getContentType()))) { - assertEqualsIgnoreCase("attrName_html", htmlExpected, actual); -} else { - assertEquals("attrName", expected, actual); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapreturnfirstitem"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_namednodemapreturnfirstitem.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapreturnlastitem.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapreturnlastitem.java deleted file mode 100644 index 32b783bf5..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapreturnlastitem.java +++ /dev/null @@ -1,116 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "item(index)" method returns the indexth item in - * the map(test for last item). - * - * Retrieve the second "acronym" and get the attribute name. Since the - * DOM does not specify an order of these nodes the contents - * of the LAST node can contain either "title" or "class". - * The test should return "true" if the LAST node is either - * of these values. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184 -*/ -public final class hc_namednodemapreturnlastitem extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_namednodemapreturnlastitem(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - NamedNodeMap attributes; - Node child; - String nodeName; - java.util.Collection htmlExpected = new java.util.ArrayList(); - htmlExpected.add("title"); - htmlExpected.add("class"); - - java.util.Collection expected = new java.util.ArrayList(); - expected.add("title"); - expected.add("class"); - expected.add("dir"); - - java.util.Collection actual = new java.util.ArrayList(); - - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = elementList.item(1); - attributes = testEmployee.getAttributes(); - for (int indexN10070 = 0; indexN10070 < attributes.getLength(); indexN10070++) { - child = (Node) attributes.item(indexN10070); - nodeName = child.getNodeName(); - actual.add(nodeName); - } - - if (("text/html".equals(getContentType()))) { - assertEqualsIgnoreCase("attrName_html", htmlExpected, actual); -} else { - assertEquals("attrName", expected, actual); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapreturnlastitem"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_namednodemapreturnlastitem.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapreturnnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapreturnnull.java deleted file mode 100644 index 0d5ab3b37..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapreturnnull.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNamedItem(name)" method returns null of the - * specified name did not identify any node in the map. - * - * Retrieve the second employee and create a NamedNodeMap - * listing of the attributes of the last child. Once the - * list is created an invocation of the "getNamedItem(name)" - * method is done with name="lang". This name does not - * match any names in the list therefore the method should - * return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class hc_namednodemapreturnnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_namednodemapreturnnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - NamedNodeMap attributes; - Attr districtNode; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - testEmployee = elementList.item(1); - attributes = testEmployee.getAttributes(); - districtNode = (Attr) attributes.getNamedItem("lang"); - assertNull("langAttrNull", districtNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapreturnnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_namednodemapreturnnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapsetnameditem.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapsetnameditem.java deleted file mode 100644 index 609009a8b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapsetnameditem.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the second "p" element and create a NamedNodeMap - * object from the attributes of the last child by - * invoking the "getAttributes()" method. Once the - * list is created an invocation of the "setNamedItem(arg)" - * method is done with arg=newAttr, where newAttr is a - * new Attr Node previously created. The "setNamedItem(arg)" - * method should add then new node to the NamedNodeItem - * object by using its "nodeName" attribute("lang'). - * This node is then retrieved using the "getNamedItem(name)" - * method. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243 -*/ -public final class hc_namednodemapsetnameditem extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_namednodemapsetnameditem(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Attr newAttribute; - Node testAddress; - NamedNodeMap attributes; - Attr districtNode; - String attrName; - Node setNode; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testAddress = elementList.item(1); - newAttribute = doc.createAttribute("lang"); - attributes = testAddress.getAttributes(); - setNode = attributes.setNamedItem(newAttribute); - districtNode = (Attr) attributes.getNamedItem("lang"); - attrName = districtNode.getNodeName(); - assertEqualsAutoCase("attribute", "nodeName", "lang", attrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapsetnameditem"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_namednodemapsetnameditem.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapsetnameditemreturnvalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapsetnameditemreturnvalue.java deleted file mode 100644 index e9d796fbb..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapsetnameditemreturnvalue.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the "setNamedItem(arg)" method replaces an already - * existing node with the same name then the already - * existing node is returned. - * - * Retrieve the third employee and create a NamedNodeMap - * object from the attributes of the last child by - * invoking the "getAttributes()" method. Once the - * list is created an invocation of the "setNamedItem(arg)" - * method is done with arg=newAttr, where newAttr is a - * new Attr Node previously created and whose node name - * already exists in the map. The "setNamedItem(arg)" - * method should replace the already existing node with - * the new one and return the existing node. - * This test uses the "createAttribute(name)" method from - * the document interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -*/ -public final class hc_namednodemapsetnameditemreturnvalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_namednodemapsetnameditemreturnvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Attr newAttribute; - Node testAddress; - NamedNodeMap attributes; - Node newNode; - String attrValue; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testAddress = elementList.item(2); - newAttribute = doc.createAttribute("class"); - attributes = testAddress.getAttributes(); - newNode = attributes.setNamedItem(newAttribute); - assertNotNull("previousAttrNotNull", newNode); - attrValue = newNode.getNodeValue(); - assertEquals("previousAttrValue", "No", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapsetnameditemreturnvalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_namednodemapsetnameditemreturnvalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapsetnameditemthatexists.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapsetnameditemthatexists.java deleted file mode 100644 index 90f88e448..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapsetnameditemthatexists.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the node to be added by the "setNamedItem(arg)" method - * already exists in the NamedNodeMap, it is replaced by - * the new one. - * - * Retrieve the second employee and create a NamedNodeMap - * object from the attributes of the last child by - * invoking the "getAttributes()" method. Once the - * list is created an invocation of the "setNamedItem(arg)" - * method is done with arg=newAttr, where newAttr is a - * new Attr Node previously created and whose node name - * already exists in the map. The "setNamedItem(arg)" - * method should replace the already existing node with - * the new one. - * This node is then retrieved using the "getNamedItem(name)" - * method. This test uses the "createAttribute(name)" - * method from the document interface -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -*/ -public final class hc_namednodemapsetnameditemthatexists extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_namednodemapsetnameditemthatexists(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Attr newAttribute; - Node testAddress; - NamedNodeMap attributes; - Attr districtNode; - String attrValue; - Node setNode; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testAddress = elementList.item(1); - newAttribute = doc.createAttribute("class"); - attributes = testAddress.getAttributes(); - setNode = attributes.setNamedItem(newAttribute); - districtNode = (Attr) attributes.getNamedItem("class"); - attrValue = districtNode.getNodeValue(); - assertEquals("namednodemapSetNamedItemThatExistsAssert", "", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapsetnameditemthatexists"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_namednodemapsetnameditemthatexists.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapsetnameditemwithnewvalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapsetnameditemwithnewvalue.java deleted file mode 100644 index 28f25fdc4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapsetnameditemwithnewvalue.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the "setNamedItem(arg)" method does not replace an - * existing node with the same name then it returns null. - * - * Retrieve the third employee and create a NamedNodeMap - * object from the attributes of the last child. - * Once the list is created the "setNamedItem(arg)" method - * is invoked with arg=newAttr, where newAttr is a - * newly created Attr Node and whose node name - * already exists in the map. The "setNamedItem(arg)" - * method should add the new node and return null. - * This test uses the "createAttribute(name)" method from - * the document interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243 -*/ -public final class hc_namednodemapsetnameditemwithnewvalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_namednodemapsetnameditemwithnewvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Attr newAttribute; - Node testAddress; - NamedNodeMap attributes; - Node newNode; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - testAddress = elementList.item(2); - newAttribute = doc.createAttribute("lang"); - attributes = testAddress.getAttributes(); - newNode = attributes.setNamedItem(newAttribute); - assertNull("prevValueNull", newNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapsetnameditemwithnewvalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_namednodemapsetnameditemwithnewvalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapwrongdocumenterr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapwrongdocumenterr.java deleted file mode 100644 index cc4649dd2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_namednodemapwrongdocumenterr.java +++ /dev/null @@ -1,111 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setNamedItem(arg)" method raises a - * WRONG_DOCUMENT_ERR DOMException if "arg" was created - * from a different document than the one that created - * the NamedNodeMap. - * - * Create a NamedNodeMap object from the attributes of the - * last child of the third employee and attempt to add - * another Attr node to it that was created from a - * different DOM document. This should raise the desired - * exception. This method uses the "createAttribute(name)" - * method from the Document interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1025163788')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class hc_namednodemapwrongdocumenterr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_namednodemapwrongdocumenterr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc1; - Document doc2; - NodeList elementList; - Node testAddress; - NamedNodeMap attributes; - Node newAttribute; - String strong; - Node setNode; - doc1 = (Document) load("hc_staff", true); - doc2 = (Document) load("hc_staff", true); - elementList = doc1.getElementsByTagName("acronym"); - testAddress = elementList.item(2); - newAttribute = doc2.createAttribute("newAttribute"); - attributes = testAddress.getAttributes(); - - { - boolean success = false; - try { - setNode = attributes.setNamedItem(newAttribute); - } catch (DOMException ex) { - success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); - } - assertTrue("throw_WRONG_DOCUMENT_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapwrongdocumenterr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_namednodemapwrongdocumenterr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchild.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchild.java deleted file mode 100644 index 621f87133..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchild.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the second "p" and append a "br" Element - * node to the list of children. The last node in the list - * is then retrieved and its NodeName examined. The - * "getNodeName()" method should return "br". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247 -*/ -public final class hc_nodeappendchild extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeappendchild(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node createdNode; - Node lchild; - String childName; - Node appendedChild; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - createdNode = doc.createElement("br"); - appendedChild = employeeNode.appendChild(createdNode); - lchild = employeeNode.getLastChild(); - childName = lchild.getNodeName(); - assertEqualsAutoCase("element", "nodeName", "br", childName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeappendchild"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeappendchild.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildchildexists.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildchildexists.java deleted file mode 100644 index f83797160..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildchildexists.java +++ /dev/null @@ -1,125 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the "newChild" is already in the tree, it is first - * removed before the new one is appended. - * - * Retrieve the "em" second employee and - * append the first child to the end of the list. After - * the "appendChild(newChild)" method is invoked the first - * child should be the one that was second and the last - * child should be the one that was first. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_nodeappendchildchildexists extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeappendchildchildexists(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - NodeList childList; - Node childNode; - Node newChild; - Node memberNode; - String memberName; - java.util.List refreshedActual = new java.util.ArrayList(); - - java.util.List actual = new java.util.ArrayList(); - - int nodeType; - java.util.List expected = new java.util.ArrayList(); - expected.add("strong"); - expected.add("code"); - expected.add("sup"); - expected.add("var"); - expected.add("acronym"); - expected.add("em"); - - Node appendedChild; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("p"); - childNode = elementList.item(1); - childList = ((Element) /*Node */childNode).getElementsByTagName("*"); - newChild = childList.item(0); - appendedChild = childNode.appendChild(newChild); - for (int indexN10085 = 0; indexN10085 < childList.getLength(); indexN10085++) { - memberNode = (Node) childList.item(indexN10085); - memberName = memberNode.getNodeName(); - actual.add(memberName); - } - assertEqualsAutoCase("element", "liveByTagName", expected, actual); - childList = childNode.getChildNodes(); - for (int indexN1009C = 0; indexN1009C < childList.getLength(); indexN1009C++) { - memberNode = (Node) childList.item(indexN1009C); - nodeType = (int) memberNode.getNodeType(); - - if (equals(1, nodeType)) { - memberName = memberNode.getNodeName(); - refreshedActual.add(memberName); - } - } - assertEqualsAutoCase("element", "refreshedChildNodes", expected, refreshedActual); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeappendchildchildexists"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeappendchildchildexists.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchilddocfragment.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchilddocfragment.java deleted file mode 100644 index 690c1f0ed..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchilddocfragment.java +++ /dev/null @@ -1,125 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the "newChild" is a DocumentFragment object then - * all its content is added to the child list of this node. - * - * Create and populate a new DocumentFragment object and - * append it to the second employee. After the - * "appendChild(newChild)" method is invoked retrieve the - * new nodes at the end of the list, they should be the - * two Element nodes from the DocumentFragment. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247 -*/ -public final class hc_nodeappendchilddocfragment extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeappendchilddocfragment(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - DocumentFragment newdocFragment; - Node newChild1; - Node newChild2; - Node child; - String childName; - java.util.List result = new java.util.ArrayList(); - - Node appendedChild; - int nodeType; - java.util.List expected = new java.util.ArrayList(); - expected.add("em"); - expected.add("strong"); - expected.add("code"); - expected.add("sup"); - expected.add("var"); - expected.add("acronym"); - expected.add("br"); - expected.add("b"); - - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - newdocFragment = doc.createDocumentFragment(); - newChild1 = doc.createElement("br"); - newChild2 = doc.createElement("b"); - appendedChild = newdocFragment.appendChild(newChild1); - appendedChild = newdocFragment.appendChild(newChild2); - appendedChild = employeeNode.appendChild(newdocFragment); - for (int indexN100A2 = 0; indexN100A2 < childList.getLength(); indexN100A2++) { - child = (Node) childList.item(indexN100A2); - nodeType = (int) child.getNodeType(); - - if (equals(1, nodeType)) { - childName = child.getNodeName(); - result.add(childName); - } - } - assertEqualsAutoCase("element", "nodeNames", expected, result); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeappendchilddocfragment"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeappendchilddocfragment.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildgetnodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildgetnodename.java deleted file mode 100644 index 86cd3a3a0..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildgetnodename.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "appendChild(newChild)" method returns the node - * added. - * - * Append a newly created node to the child list of the - * second employee and check the NodeName returned. The - * "getNodeName()" method should return "br". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247 -*/ -public final class hc_nodeappendchildgetnodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeappendchildgetnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node newChild; - Node appendNode; - String childName; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - newChild = doc.createElement("br"); - appendNode = employeeNode.appendChild(newChild); - childName = appendNode.getNodeName(); - assertEqualsAutoCase("element", "nodeName", "br", childName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeappendchildgetnodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeappendchildgetnodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildinvalidnodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildinvalidnodetype.java deleted file mode 100644 index 12c804f78..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildinvalidnodetype.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "appendChild(newChild)" method raises a - * HIERARCHY_REQUEST_ERR DOMException if this node is of - * a type that does not allow children of the type "newChild" - * to be inserted. - * - * Retrieve the root node and attempt to append a newly - * created Attr node. An Element node cannot have children - * of the "Attr" type, therefore the desired exception - * should be raised. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-184E7107')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class hc_nodeappendchildinvalidnodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeappendchildinvalidnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element rootNode; - Node newChild; - Node appendedChild; - doc = (Document) load("hc_staff", true); - rootNode = doc.getDocumentElement(); - newChild = doc.createAttribute("newAttribute"); - - { - boolean success = false; - try { - appendedChild = rootNode.appendChild(newChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR); - } - assertTrue("throw_HIERARCHY_REQUEST_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeappendchildinvalidnodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeappendchildinvalidnodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildnewchilddiffdocument.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildnewchilddiffdocument.java deleted file mode 100644 index cb9c36399..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildnewchilddiffdocument.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "appendChild(newChild)" method raises a - * WRONG_DOCUMENT_ERR DOMException if the "newChild" was - * created from a different document than the one that - * created this node. - * - * Retrieve the second employee and attempt to append - * a node created from a different document. An attempt - * to make such a replacement should raise the desired - * exception. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-184E7107')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247 -*/ -public final class hc_nodeappendchildnewchilddiffdocument extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeappendchildnewchilddiffdocument(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc1; - Document doc2; - Node newChild; - NodeList elementList; - Node elementNode; - Node appendedChild; - doc1 = (Document) load("hc_staff", false); - doc2 = (Document) load("hc_staff", true); - newChild = doc1.createElement("br"); - elementList = doc2.getElementsByTagName("p"); - elementNode = elementList.item(1); - - { - boolean success = false; - try { - appendedChild = elementNode.appendChild(newChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); - } - assertTrue("throw_WRONG_DOCUMENT_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeappendchildnewchilddiffdocument"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeappendchildnewchilddiffdocument.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildnodeancestor.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildnodeancestor.java deleted file mode 100644 index b884bf99c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeappendchildnodeancestor.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "appendChild(newChild)" method raises a - * HIERARCHY_REQUEST_ERR DOMException if the node to - * append is one of this node's ancestors. - * - * Retrieve the second employee and attempt to append - * an ancestor node(root node) to it. - * An attempt to make such an addition should raise the - * desired exception. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-184E7107')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -*/ -public final class hc_nodeappendchildnodeancestor extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeappendchildnodeancestor(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node newChild; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node oldChild; - Node appendedChild; - doc = (Document) load("hc_staff", true); - newChild = doc.getDocumentElement(); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - - { - boolean success = false; - try { - appendedChild = employeeNode.appendChild(newChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR); - } - assertTrue("throw_HIERARCHY_REQUEST_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeappendchildnodeancestor"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeappendchildnodeancestor.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeattributenodeattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeattributenodeattribute.java deleted file mode 100644 index 12430b7c1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeattributenodeattribute.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributes()" method invoked on an Attribute - * Node returns null. - * Retrieve the first attribute from the last child of the - * first employee and invoke the "getAttributes()" method - * on the Attribute Node. It should return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -*/ -public final class hc_nodeattributenodeattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeattributenodeattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - NamedNodeMap addrAttr; - Node attrNode; - NamedNodeMap attrList; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - testAddr = (Element) elementList.item(0); - addrAttr = testAddr.getAttributes(); - attrNode = addrAttr.item(0); - attrList = attrNode.getAttributes(); - assertNull("nodeAttributeNodeAttributeAssert1", attrList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeattributenodeattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeattributenodeattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeattributenodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeattributenodename.java deleted file mode 100644 index 23ea3fdba..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeattributenodename.java +++ /dev/null @@ -1,88 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the Attribute named "title" from the last - * child of the first p element and check the string returned - * by the "getNodeName()" method. It should be equal to - * "title". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236 -*/ -public final class hc_nodeattributenodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeattributenodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - Attr addrAttr; - String attrName; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - testAddr = (Element) elementList.item(0); - addrAttr = testAddr.getAttributeNode("title"); - attrName = addrAttr.getNodeName(); - assertEqualsAutoCase("attribute", "nodeName", "title", attrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeattributenodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeattributenodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeattributenodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeattributenodetype.java deleted file mode 100644 index c3e53a7ce..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeattributenodetype.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNodeType()" method for an Attribute Node - * returns the constant value 2. - * - * Retrieve the first attribute from the last child of - * the first employee and invoke the "getNodeType()" - * method. The method should return 2. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -*/ -public final class hc_nodeattributenodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeattributenodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - Attr addrAttr; - int nodeType; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - testAddr = (Element) elementList.item(0); - addrAttr = testAddr.getAttributeNode("title"); - nodeType = (int) addrAttr.getNodeType(); - assertEquals("nodeAttrNodeTypeAssert1", 2, nodeType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeattributenodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeattributenodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeattributenodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeattributenodevalue.java deleted file mode 100644 index 8f7876297..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeattributenodevalue.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeValue()" method for an - * Attribute Node is the value of the Attribute. - * - * Retrieve the Attribute named "title" from the last - * child of the first "p" and check the string returned - * by the "getNodeValue()" method. It should be equal to - * "Yes". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -*/ -public final class hc_nodeattributenodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeattributenodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - Attr addrAttr; - String attrValue; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - testAddr = (Element) elementList.item(0); - addrAttr = testAddr.getAttributeNode("title"); - attrValue = addrAttr.getNodeValue(); - assertEquals("nodeValue", "Yes", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeattributenodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeattributenodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodechildnodes.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodechildnodes.java deleted file mode 100644 index 9b35bc95c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodechildnodes.java +++ /dev/null @@ -1,114 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * - * The "getChildNodes()" method returns a NodeList - * that contains all children of this node. - * - * Retrieve the second employee and check the NodeList - * returned by the "getChildNodes()" method. The - * length of the list should be 13. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_nodechildnodes extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodechildnodes(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - Node childNode; - NodeList childNodes; - int nodeType; - String childName; - java.util.List actual = new java.util.ArrayList(); - - java.util.List expected = new java.util.ArrayList(); - expected.add("em"); - expected.add("strong"); - expected.add("code"); - expected.add("sup"); - expected.add("var"); - expected.add("acronym"); - - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - childNodes = employeeNode.getChildNodes(); - for (int indexN1006C = 0; indexN1006C < childNodes.getLength(); indexN1006C++) { - childNode = (Node) childNodes.item(indexN1006C); - nodeType = (int) childNode.getNodeType(); - childName = childNode.getNodeName(); - - if (equals(1, nodeType)) { - actual.add(childName); - } else { - assertEquals("textNodeType", 3, nodeType); - } - - } - assertEqualsAutoCase("element", "elementNames", expected, actual); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodechildnodes"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodechildnodes.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodechildnodesappendchild.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodechildnodesappendchild.java deleted file mode 100644 index 40f1139a8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodechildnodesappendchild.java +++ /dev/null @@ -1,124 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The NodeList returned by the "getChildNodes()" method - * is live. Changes on the node's children are immediately - * reflected on the nodes returned in the NodeList. - * - * Create a NodeList of the children of the second employee - * and then add a newly created element that was created - * by the "createElement()" method(Document Interface) to - * the second employee by using the "appendChild()" method. - * The length of the NodeList should reflect this new - * addition to the child list. It should return the value 14. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247 -*/ -public final class hc_nodechildnodesappendchild extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodechildnodesappendchild(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node createdNode; - Node childNode; - String childName; - int childType; - Node textNode; - java.util.List actual = new java.util.ArrayList(); - - java.util.List expected = new java.util.ArrayList(); - expected.add("em"); - expected.add("strong"); - expected.add("code"); - expected.add("sup"); - expected.add("var"); - expected.add("acronym"); - expected.add("br"); - - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - createdNode = doc.createElement("br"); - employeeNode = employeeNode.appendChild(createdNode); - for (int indexN10087 = 0; indexN10087 < childList.getLength(); indexN10087++) { - childNode = (Node) childList.item(indexN10087); - childName = childNode.getNodeName(); - childType = (int) childNode.getNodeType(); - - if (equals(1, childType)) { - actual.add(childName); - } else { - assertEquals("textNodeType", 3, childType); - } - - } - assertEqualsAutoCase("element", "childElements", expected, actual); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodechildnodesappendchild"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodechildnodesappendchild.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodechildnodesempty.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodechildnodesempty.java deleted file mode 100644 index 2533e25d9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodechildnodesempty.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getChildNodes()" method returns a NodeList - * that contains all children of this node. If there - * are not any children, this is a NodeList that does not - * contain any nodes. - * Retrieve the character data of the second "em" node and - * invoke the "getChildNodes()" method. The - * NodeList returned should not have any nodes. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_nodechildnodesempty extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodechildnodesempty(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - NodeList childList; - Node employeeNode; - Node textNode; - int length; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("em"); - employeeNode = elementList.item(1); - textNode = employeeNode.getFirstChild(); - childList = textNode.getChildNodes(); - length = (int) childList.getLength(); - assertEquals("length_zero", 0, length); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodechildnodesempty"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodechildnodesempty.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecloneattributescopied.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecloneattributescopied.java deleted file mode 100644 index a101d2d0c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecloneattributescopied.java +++ /dev/null @@ -1,113 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the second acronym element and invoke - * the cloneNode method. The - * duplicate node returned by the method should copy the - * attributes associated with this node. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184 -*/ -public final class hc_nodecloneattributescopied extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodecloneattributescopied(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node addressNode; - Node clonedNode; - NamedNodeMap attributes; - Node attributeNode; - String attributeName; - java.util.Collection result = new java.util.ArrayList(); - - java.util.Collection htmlExpected = new java.util.ArrayList(); - htmlExpected.add("class"); - htmlExpected.add("title"); - - java.util.Collection expected = new java.util.ArrayList(); - expected.add("class"); - expected.add("title"); - expected.add("dir"); - - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - addressNode = elementList.item(1); - clonedNode = addressNode.cloneNode(false); - attributes = clonedNode.getAttributes(); - for (int indexN10076 = 0; indexN10076 < attributes.getLength(); indexN10076++) { - attributeNode = (Node) attributes.item(indexN10076); - attributeName = attributeNode.getNodeName(); - result.add(attributeName); - } - - if (("text/html".equals(getContentType()))) { - assertEqualsIgnoreCase("nodeNames_html", htmlExpected, result); -} else { - assertEquals("nodeNames", expected, result); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodecloneattributescopied"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodecloneattributescopied.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonefalsenocopytext.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonefalsenocopytext.java deleted file mode 100644 index 25da6aa3e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonefalsenocopytext.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "cloneNode(deep)" method does not copy text unless it - * is deep cloned.(Test for deep=false) - * - * Retrieve the fourth child of the second employee and - * the "cloneNode(deep)" method with deep=false. The - * duplicate node returned by the method should not copy - * any text data contained in this node. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4 -*/ -public final class hc_nodeclonefalsenocopytext extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeclonefalsenocopytext(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node childNode; - Node clonedNode; - Node lastChildNode; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - childNode = childList.item(3); - clonedNode = childNode.cloneNode(false); - lastChildNode = clonedNode.getLastChild(); - assertNull("nodeCloneFalseNoCopyTextAssert1", lastChildNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeclonefalsenocopytext"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeclonefalsenocopytext.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonegetparentnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonegetparentnull.java deleted file mode 100644 index ee1b2980c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonegetparentnull.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The duplicate node returned by the "cloneNode(deep)" - * method does not have a ParentNode. - * - * Retrieve the second employee and invoke the - * "cloneNode(deep)" method with deep=false. The - * duplicate node returned should return null when the - * "getParentNode()" is invoked. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4 -*/ -public final class hc_nodeclonegetparentnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeclonegetparentnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - Node clonedNode; - Node parentNode; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - clonedNode = employeeNode.cloneNode(false); - parentNode = clonedNode.getParentNode(); - assertNull("nodeCloneGetParentNullAssert1", parentNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeclonegetparentnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeclonegetparentnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonenodefalse.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonenodefalse.java deleted file mode 100644 index 51e20b23f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonenodefalse.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "cloneNode(deep)" method returns a copy of the node - * only if deep=false. - * - * Retrieve the second employee and invoke the - * "cloneNode(deep)" method with deep=false. The - * method should only clone this node. The NodeName and - * length of the NodeList are checked. The "getNodeName()" - * method should return "employee" and the "getLength()" - * method should return 0. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4 -*/ -public final class hc_nodeclonenodefalse extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeclonenodefalse(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - Node clonedNode; - String cloneName; - NodeList cloneChildren; - int length; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - clonedNode = employeeNode.cloneNode(false); - cloneName = clonedNode.getNodeName(); - assertEqualsAutoCase("element", "strong", "p", cloneName); - cloneChildren = clonedNode.getChildNodes(); - length = (int) cloneChildren.getLength(); - assertEquals("length", 0, length); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeclonenodefalse"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeclonenodefalse.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonenodetrue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonenodetrue.java deleted file mode 100644 index 69c045567..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonenodetrue.java +++ /dev/null @@ -1,113 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "cloneNode(deep)" method returns a copy of the node - * and the subtree under it if deep=true. - * - * Retrieve the second employee and invoke the - * "cloneNode(deep)" method with deep=true. The - * method should clone this node and the subtree under it. - * The NodeName of each child in the returned node is - * checked to insure the entire subtree under the second - * employee was cloned. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_nodeclonenodetrue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeclonenodetrue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - Node clonedNode; - NodeList clonedList; - Node clonedChild; - String clonedChildName; - NodeList origList; - Node origChild; - String origChildName; - java.util.List result = new java.util.ArrayList(); - - java.util.List expected = new java.util.ArrayList(); - - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - origList = employeeNode.getChildNodes(); - for (int indexN10065 = 0; indexN10065 < origList.getLength(); indexN10065++) { - origChild = (Node) origList.item(indexN10065); - origChildName = origChild.getNodeName(); - expected.add(origChildName); - } - clonedNode = employeeNode.cloneNode(true); - clonedList = clonedNode.getChildNodes(); - for (int indexN1007B = 0; indexN1007B < clonedList.getLength(); indexN1007B++) { - clonedChild = (Node) clonedList.item(indexN1007B); - clonedChildName = clonedChild.getNodeName(); - result.add(clonedChildName); - } - assertEquals("clone", expected, result); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeclonenodetrue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeclonenodetrue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonetruecopytext.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonetruecopytext.java deleted file mode 100644 index a79f82c2d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeclonetruecopytext.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "cloneNode(deep)" method does not copy text unless it - * is deep cloned.(Test for deep=true) - * - * Retrieve the eighth child of the second employee and - * the "cloneNode(deep)" method with deep=true. The - * duplicate node returned by the method should copy - * any text data contained in this node. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_nodeclonetruecopytext extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeclonetruecopytext(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node childNode; - Node clonedNode; - Node lastChildNode; - String childValue; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("sup"); - childNode = elementList.item(1); - clonedNode = childNode.cloneNode(true); - lastChildNode = clonedNode.getLastChild(); - childValue = lastChildNode.getNodeValue(); - assertEquals("cloneContainsText", "35,000", childValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeclonetruecopytext"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeclonetruecopytext.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecommentnodeattributes.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecommentnodeattributes.java deleted file mode 100644 index 0db3b834d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecommentnodeattributes.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributes()" method invoked on a Comment - * Node returns null. - * Find any comment that is an immediate child of the root - * and assert that Node.attributes is null. Then create - * a new comment node (in case they had been omitted) and - * make the assertion. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=248 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=263 -*/ -public final class hc_nodecommentnodeattributes extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodecommentnodeattributes(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node commentNode; - NodeList nodeList; - NamedNodeMap attrList; - int nodeType; - doc = (Document) load("hc_staff", false); - nodeList = doc.getChildNodes(); - for (int indexN10043 = 0; indexN10043 < nodeList.getLength(); indexN10043++) { - commentNode = (Node) nodeList.item(indexN10043); - nodeType = (int) commentNode.getNodeType(); - - if (equals(8, nodeType)) { - attrList = commentNode.getAttributes(); - assertNull("existingCommentAttributesNull", attrList); - } - } - commentNode = doc.createComment("This is a comment"); - attrList = commentNode.getAttributes(); - assertNull("createdCommentAttributesNull", attrList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodecommentnodeattributes"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodecommentnodeattributes.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecommentnodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecommentnodename.java deleted file mode 100644 index b2a7de158..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecommentnodename.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeName()" method for a - * Comment Node is "#comment". - * - * Retrieve the Comment node in the XML file - * and check the string returned by the "getNodeName()" - * method. It should be equal to "#comment". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=248 -*/ -public final class hc_nodecommentnodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodecommentnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node commentNode; - int nodeType; - String commentName; - String commentNodeName; - doc = (Document) load("hc_staff", false); - elementList = doc.getChildNodes(); - for (int indexN10044 = 0; indexN10044 < elementList.getLength(); indexN10044++) { - commentNode = (Node) elementList.item(indexN10044); - nodeType = (int) commentNode.getNodeType(); - - if (equals(8, nodeType)) { - commentNodeName = commentNode.getNodeName(); - assertEquals("existingNodeName", "#comment", commentNodeName); - } - } - commentNode = doc.createComment("This is a comment"); - commentNodeName = commentNode.getNodeName(); - assertEquals("createdNodeName", "#comment", commentNodeName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodecommentnodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodecommentnodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecommentnodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecommentnodetype.java deleted file mode 100644 index bfae3e29e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecommentnodetype.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNodeType()" method for a Comment Node - * returns the constant value 8. - * - * Retrieve the nodes from the document and check for - * a comment node and invoke the "getNodeType()" method. This should - * return 8. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=248 -*/ -public final class hc_nodecommentnodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodecommentnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList testList; - Node commentNode; - String commentNodeName; - int nodeType; - doc = (Document) load("hc_staff", false); - testList = doc.getChildNodes(); - for (int indexN10040 = 0; indexN10040 < testList.getLength(); indexN10040++) { - commentNode = (Node) testList.item(indexN10040); - commentNodeName = commentNode.getNodeName(); - - if (equals("#comment", commentNodeName)) { - nodeType = (int) commentNode.getNodeType(); - assertEquals("existingCommentNodeType", 8, nodeType); - } - } - commentNode = doc.createComment("This is a comment"); - nodeType = (int) commentNode.getNodeType(); - assertEquals("createdCommentNodeType", 8, nodeType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodecommentnodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodecommentnodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecommentnodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecommentnodevalue.java deleted file mode 100644 index a42fae853..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodecommentnodevalue.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeValue()" method for a - * Comment Node is the content of the comment. - * - * Retrieve the comment in the XML file and - * check the string returned by the "getNodeValue()" method. - * It should be equal to "This is comment number 1". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=248 -*/ -public final class hc_nodecommentnodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodecommentnodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node commentNode; - String commentName; - String commentValue; - doc = (Document) load("hc_staff", false); - elementList = doc.getChildNodes(); - for (int indexN10040 = 0; indexN10040 < elementList.getLength(); indexN10040++) { - commentNode = (Node) elementList.item(indexN10040); - commentName = commentNode.getNodeName(); - - if (equals("#comment", commentName)) { - commentValue = commentNode.getNodeValue(); - assertEquals("value", " This is comment number 1.", commentValue); - } - } - commentNode = doc.createComment(" This is a comment"); - commentValue = commentNode.getNodeValue(); - assertEquals("createdCommentNodeValue", " This is a comment", commentValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodecommentnodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodecommentnodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentfragmentnodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentfragmentnodename.java deleted file mode 100644 index cbbc83ebd..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentfragmentnodename.java +++ /dev/null @@ -1,86 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeName()" method for a - * DocumentFragment Node is "#document-frament". - * Retrieve the DOM document and invoke the - * "createDocumentFragment()" method and check the string - * returned by the "getNodeName()" method. It should be - * equal to "#document-fragment". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3 -*/ -public final class hc_nodedocumentfragmentnodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodedocumentfragmentnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentFragment docFragment; - String documentFragmentName; - doc = (Document) load("hc_staff", true); - docFragment = doc.createDocumentFragment(); - documentFragmentName = docFragment.getNodeName(); - assertEquals("nodeDocumentFragmentNodeNameAssert1", "#document-fragment", documentFragmentName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodedocumentfragmentnodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodedocumentfragmentnodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentfragmentnodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentfragmentnodetype.java deleted file mode 100644 index e2afd657c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentfragmentnodetype.java +++ /dev/null @@ -1,86 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNodeType()" method for a DocumentFragment Node - * returns the constant value 11. - * Invoke the "createDocumentFragment()" method and - * examine the NodeType of the document fragment - * returned by the "getNodeType()" method. The method - * should return 11. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3 -*/ -public final class hc_nodedocumentfragmentnodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodedocumentfragmentnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentFragment documentFragmentNode; - int nodeType; - doc = (Document) load("hc_staff", true); - documentFragmentNode = doc.createDocumentFragment(); - nodeType = (int) documentFragmentNode.getNodeType(); - assertEquals("nodeDocumentFragmentNodeTypeAssert1", 11, nodeType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodedocumentfragmentnodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodedocumentfragmentnodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentfragmentnodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentfragmentnodevalue.java deleted file mode 100644 index 1eb42bcf3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentfragmentnodevalue.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeValue()" method for a - * DocumentFragment Node is null. - * - * Retrieve the DOM document and invoke the - * "createDocumentFragment()" method and check the string - * returned by the "getNodeValue()" method. It should be - * equal to null. -* @author Curt Arnold -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -*/ -public final class hc_nodedocumentfragmentnodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodedocumentfragmentnodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentFragment docFragment; - NamedNodeMap attrList; - String value; - doc = (Document) load("hc_staff", true); - docFragment = doc.createDocumentFragment(); - attrList = docFragment.getAttributes(); - assertNull("attributesNull", attrList); - value = docFragment.getNodeValue(); - assertNull("initiallyNull", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodedocumentfragmentnodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodedocumentfragmentnodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentnodeattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentnodeattribute.java deleted file mode 100644 index 1c09dcb6a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentnodeattribute.java +++ /dev/null @@ -1,83 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributes()" method invoked on a Document - * Node returns null. - * Retrieve the DOM Document and invoke the - * "getAttributes()" method on the Document Node. - * It should return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document -*/ -public final class hc_nodedocumentnodeattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodedocumentnodeattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attrList; - doc = (Document) load("hc_staff", false); - attrList = doc.getAttributes(); - assertNull("doc_attributes_is_null", attrList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodedocumentnodeattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodedocumentnodeattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentnodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentnodename.java deleted file mode 100644 index 6fb18c685..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentnodename.java +++ /dev/null @@ -1,83 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeName()" method for a - * Document Node is "#document". - * Retrieve the DOM document and check the string returned - * by the "getNodeName()" method. It should be equal to - * "#document". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -*/ -public final class hc_nodedocumentnodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodedocumentnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - String documentName; - doc = (Document) load("hc_staff", false); - documentName = doc.getNodeName(); - assertEquals("documentNodeName", "#document", documentName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodedocumentnodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodedocumentnodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentnodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentnodetype.java deleted file mode 100644 index 6bc4d4248..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentnodetype.java +++ /dev/null @@ -1,82 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNodeType()" method for a Document Node - * returns the constant value 9. - * Retrieve the document and invoke the "getNodeType()" - * method. The method should return 9. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -*/ -public final class hc_nodedocumentnodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodedocumentnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - int nodeType; - doc = (Document) load("hc_staff", false); - nodeType = (int) doc.getNodeType(); - assertEquals("nodeDocumentNodeTypeAssert1", 9, nodeType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodedocumentnodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodedocumentnodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentnodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentnodevalue.java deleted file mode 100644 index 4f70dd217..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodedocumentnodevalue.java +++ /dev/null @@ -1,83 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeValue()" method for a - * Document Node is null. - * Retrieve the DOM Document and check the string returned - * by the "getNodeValue()" method. It should be equal to - * null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -*/ -public final class hc_nodedocumentnodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodedocumentnodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - String documentValue; - doc = (Document) load("hc_staff", false); - documentValue = doc.getNodeValue(); - assertNull("documentNodeValue", documentValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodedocumentnodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodedocumentnodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeelementnodeattributes.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeelementnodeattributes.java deleted file mode 100644 index 634a78035..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeelementnodeattributes.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the third "acronym" element and evaluate Node.attributes. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184 -*/ -public final class hc_nodeelementnodeattributes extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeelementnodeattributes(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - NamedNodeMap addrAttr; - Node attrNode; - String attrName; - java.util.Collection attrList = new java.util.ArrayList(); - - java.util.Collection htmlExpected = new java.util.ArrayList(); - htmlExpected.add("title"); - htmlExpected.add("class"); - - java.util.Collection expected = new java.util.ArrayList(); - expected.add("title"); - expected.add("class"); - expected.add("dir"); - - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - testAddr = (Element) elementList.item(2); - addrAttr = testAddr.getAttributes(); - for (int indexN10070 = 0; indexN10070 < addrAttr.getLength(); indexN10070++) { - attrNode = (Node) addrAttr.item(indexN10070); - attrName = attrNode.getNodeName(); - attrList.add(attrName); - } - - if (("text/html".equals(getContentType()))) { - assertEqualsIgnoreCase("attrNames_html", htmlExpected, attrList); -} else { - assertEquals("attrNames", expected, attrList); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeelementnodeattributes"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeelementnodeattributes.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeelementnodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeelementnodename.java deleted file mode 100644 index f66808a08..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeelementnodename.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the first Element Node(Root Node) of the - * DOM object and check the string returned by the - * "getNodeName()" method. It should be equal to its - * tagName. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251 -*/ -public final class hc_nodeelementnodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeelementnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element elementNode; - String elementName; - doc = (Document) load("hc_staff", false); - elementNode = doc.getDocumentElement(); - elementName = elementNode.getNodeName(); - - if (("image/svg+xml".equals(getContentType()))) { - assertEquals("svgNodeName", "svg", elementName); - } else { - assertEqualsAutoCase("element", "nodeName", "html", elementName); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeelementnodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeelementnodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeelementnodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeelementnodetype.java deleted file mode 100644 index cbefdca1c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeelementnodetype.java +++ /dev/null @@ -1,84 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNodeType()" method for an Element Node - * returns the constant value 1. - * - * Retrieve the root node and invoke the "getNodeType()" - * method. The method should return 1. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -*/ -public final class hc_nodeelementnodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeelementnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element rootNode; - int nodeType; - doc = (Document) load("hc_staff", false); - rootNode = doc.getDocumentElement(); - nodeType = (int) rootNode.getNodeType(); - assertEquals("nodeElementNodeTypeAssert1", 1, nodeType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeelementnodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeelementnodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeelementnodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeelementnodevalue.java deleted file mode 100644 index b4cd51537..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeelementnodevalue.java +++ /dev/null @@ -1,81 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeValue()" method for an - * Element Node is null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -*/ -public final class hc_nodeelementnodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeelementnodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element elementNode; - String elementValue; - doc = (Document) load("hc_staff", false); - elementNode = doc.getDocumentElement(); - elementValue = elementNode.getNodeValue(); - assertNull("elementNodeValue", elementValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeelementnodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeelementnodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetfirstchild.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetfirstchild.java deleted file mode 100644 index 29e641921..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetfirstchild.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getFirstChild()" method returns the first child - * of this node. - * - * Retrieve the second employee and invoke the - * "getFirstChild()" method. The NodeName returned - * should be "#text" or "EM". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-169727388 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_nodegetfirstchild extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodegetfirstchild(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - Node fchildNode; - String childName; - int nodeType; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - fchildNode = employeeNode.getFirstChild(); - childName = fchildNode.getNodeName(); - - if (equals("#text", childName)) { - assertEquals("firstChild_w_whitespace", "#text", childName); - } else { - assertEqualsAutoCase("element", "firstChild_wo_whitespace", "em", childName); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetfirstchild"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodegetfirstchild.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetfirstchildnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetfirstchildnull.java deleted file mode 100644 index 1b6b5b1de..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetfirstchildnull.java +++ /dev/null @@ -1,88 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If there is not a first child then the "getFirstChild()" - * method returns null. - * Retrieve the text of the first "em" element and invoke the "getFirstChild()" method. It - * should return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-169727388 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_nodegetfirstchildnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodegetfirstchildnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList emList; - Node emNode; - CharacterData emText; - Node nullChild; - doc = (Document) load("hc_staff", false); - emList = doc.getElementsByTagName("em"); - emNode = emList.item(0); - emText = (CharacterData) emNode.getFirstChild(); - nullChild = emText.getFirstChild(); - assertNull("nullChild", nullChild); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetfirstchildnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodegetfirstchildnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetlastchild.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetlastchild.java deleted file mode 100644 index ea5dcd3ac..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetlastchild.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getLastChild()" method returns the last child - * of this node. - * - * Retrieve the second employee and invoke the - * "getLastChild()" method. The NodeName returned - * should be "#text". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-61AD09FB -*/ -public final class hc_nodegetlastchild extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodegetlastchild(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - Node lchildNode; - String childName; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - lchildNode = employeeNode.getLastChild(); - childName = lchildNode.getNodeName(); - assertEquals("whitespace", "#text", childName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetlastchild"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodegetlastchild.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetlastchildnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetlastchildnull.java deleted file mode 100644 index 02a6b0a76..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetlastchildnull.java +++ /dev/null @@ -1,88 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If there is not a last child then the "getLastChild()" - * method returns null. - * Retrieve the text of the first "em" element and invoke the "getFirstChild()" method. It - * should return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-61AD09FB -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_nodegetlastchildnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodegetlastchildnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList emList; - Node emNode; - CharacterData emText; - Node nullChild; - doc = (Document) load("hc_staff", false); - emList = doc.getElementsByTagName("em"); - emNode = emList.item(0); - emText = (CharacterData) emNode.getFirstChild(); - nullChild = emText.getLastChild(); - assertNull("nullChild", nullChild); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetlastchildnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodegetlastchildnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetnextsibling.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetnextsibling.java deleted file mode 100644 index 45b87f28a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetnextsibling.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNextSibling()" method returns the node immediately - * following this node. - * - * Retrieve the first child of the second employee and - * invoke the "getNextSibling()" method. It should return - * a node with the NodeName of "#text". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6AC54C2F -*/ -public final class hc_nodegetnextsibling extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodegetnextsibling(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node emNode; - Node nsNode; - String nsName; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("em"); - emNode = elementList.item(1); - nsNode = emNode.getNextSibling(); - nsName = nsNode.getNodeName(); - assertEquals("whitespace", "#text", nsName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetnextsibling"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodegetnextsibling.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetnextsiblingnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetnextsiblingnull.java deleted file mode 100644 index 94701f298..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetnextsiblingnull.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If there is not a node immediately following this node the - * "getNextSibling()" method returns null. - * - * Retrieve the first child of the second employee and - * invoke the "getNextSibling()" method. It should - * be set to null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6AC54C2F -*/ -public final class hc_nodegetnextsiblingnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodegetnextsiblingnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - Node lcNode; - Node nsNode; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - lcNode = employeeNode.getLastChild(); - nsNode = lcNode.getNextSibling(); - assertNull("nodeGetNextSiblingNullAssert1", nsNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetnextsiblingnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodegetnextsiblingnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetownerdocument.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetownerdocument.java deleted file mode 100644 index 309cfd908..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetownerdocument.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Evaluate Node.ownerDocument on the second "p" element. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#node-ownerDoc -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251 -*/ -public final class hc_nodegetownerdocument extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodegetownerdocument(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node docNode; - Document ownerDocument; - Element docElement; - String elementName; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("p"); - docNode = elementList.item(1); - ownerDocument = docNode.getOwnerDocument(); - docElement = ownerDocument.getDocumentElement(); - elementName = docElement.getNodeName(); - - if (("image/svg+xml".equals(getContentType()))) { - assertEquals("svgNodeName", "svg", elementName); - } else { - assertEqualsAutoCase("element", "ownerDocElemTagName", "html", elementName); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetownerdocument"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodegetownerdocument.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetownerdocumentnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetownerdocumentnull.java deleted file mode 100644 index df1f508f0..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetownerdocumentnull.java +++ /dev/null @@ -1,82 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getOwnerDocument()" method returns null if the target - * node itself is a document. - * - * Invoke the "getOwnerDocument()" method on the master - * document. The Document returned should be null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#node-ownerDoc -*/ -public final class hc_nodegetownerdocumentnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodegetownerdocumentnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document ownerDocument; - doc = (Document) load("hc_staff", false); - ownerDocument = doc.getOwnerDocument(); - assertNull("nodeGetOwnerDocumentNullAssert1", ownerDocument); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetownerdocumentnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodegetownerdocumentnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetprevioussibling.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetprevioussibling.java deleted file mode 100644 index a0adc5fd9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetprevioussibling.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getPreviousSibling()" method returns the node - * immediately preceding this node. - * - * Retrieve the second child of the second employee and - * invoke the "getPreviousSibling()" method. It should - * return a node with a NodeName of "#text". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-640FB3C8 -*/ -public final class hc_nodegetprevioussibling extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodegetprevioussibling(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - Node psNode; - String psName; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("strong"); - nameNode = elementList.item(1); - psNode = nameNode.getPreviousSibling(); - psName = psNode.getNodeName(); - assertEquals("whitespace", "#text", psName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetprevioussibling"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodegetprevioussibling.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetprevioussiblingnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetprevioussiblingnull.java deleted file mode 100644 index 565d41e7e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodegetprevioussiblingnull.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If there is not a node immediately preceding this node the - * "getPreviousSibling()" method returns null. - * - * Retrieve the first child of the second employee and - * invoke the "getPreviousSibling()" method. It should - * be set to null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-640FB3C8 -*/ -public final class hc_nodegetprevioussiblingnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodegetprevioussiblingnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - Node fcNode; - Node psNode; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(2); - fcNode = employeeNode.getFirstChild(); - psNode = fcNode.getPreviousSibling(); - assertNull("nodeGetPreviousSiblingNullAssert1", psNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodegetprevioussiblingnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodegetprevioussiblingnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodehaschildnodes.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodehaschildnodes.java deleted file mode 100644 index 1d8bcf8f2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodehaschildnodes.java +++ /dev/null @@ -1,87 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "hasChildNodes()" method returns true if the node - * has children. - * - * Retrieve the root node("staff") and invoke the - * "hasChildNodes()" method. It should return the boolean - * value "true". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-810594187 -*/ -public final class hc_nodehaschildnodes extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodehaschildnodes(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - boolean state; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - state = employeeNode.hasChildNodes(); - assertTrue("nodeHasChildAssert1", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodehaschildnodes"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodehaschildnodes.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodehaschildnodesfalse.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodehaschildnodesfalse.java deleted file mode 100644 index fc19f6bb1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodehaschildnodesfalse.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "hasChildNodes()" method returns false if the node - * does not have any children. - * - * Retrieve the text of the first "em" element and invoke the "hasChildNodes()" method. It - * should return false. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-810594187 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_nodehaschildnodesfalse extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodehaschildnodesfalse(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList emList; - Node emNode; - CharacterData emText; - boolean hasChild; - doc = (Document) load("hc_staff", false); - emList = doc.getElementsByTagName("em"); - emNode = emList.item(0); - emText = (CharacterData) emNode.getFirstChild(); - hasChild = emText.hasChildNodes(); - assertFalse("hasChild", hasChild); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodehaschildnodesfalse"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodehaschildnodesfalse.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbefore.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbefore.java deleted file mode 100644 index 5962f7bcc..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbefore.java +++ /dev/null @@ -1,119 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertBefore(newChild,refChild)" method inserts the - * node "newChild" before the node "refChild". - * - * Insert a newly created Element node before the second - * sup element in the document and check the "newChild" - * and "refChild" after insertion for correct placement. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=261 -*/ -public final class hc_nodeinsertbefore extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeinsertbefore(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node refChild; - Node newChild; - Node child; - String childName; - Node insertedNode; - java.util.List actual = new java.util.ArrayList(); - - java.util.List expected = new java.util.ArrayList(); - expected.add("em"); - expected.add("strong"); - expected.add("code"); - expected.add("br"); - expected.add("sup"); - expected.add("var"); - expected.add("acronym"); - - int nodeType; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("sup"); - refChild = elementList.item(2); - employeeNode = refChild.getParentNode(); - childList = employeeNode.getChildNodes(); - newChild = doc.createElement("br"); - insertedNode = employeeNode.insertBefore(newChild, refChild); - for (int indexN10091 = 0; indexN10091 < childList.getLength(); indexN10091++) { - child = (Node) childList.item(indexN10091); - nodeType = (int) child.getNodeType(); - - if (equals(1, nodeType)) { - childName = child.getNodeName(); - actual.add(childName); - } - } - assertEqualsAutoCase("element", "nodeNames", expected, actual); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeinsertbefore"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeinsertbefore.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforedocfragment.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforedocfragment.java deleted file mode 100644 index a5fb10268..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforedocfragment.java +++ /dev/null @@ -1,112 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the "newChild" is a DocumentFragment object then all - * its children are inserted in the same order before the - * the "refChild". - * - * Create a DocumentFragment object and populate it with - * two Element nodes. Retrieve the second employee and - * insert the newly created DocumentFragment before its - * fourth child. The second employee should now have two - * extra children("newChild1" and "newChild2") at - * positions fourth and fifth respectively. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247 -*/ -public final class hc_nodeinsertbeforedocfragment extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeinsertbeforedocfragment(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node refChild; - DocumentFragment newdocFragment; - Node newChild1; - Node newChild2; - Node child; - String childName; - Node appendedChild; - Node insertedNode; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - refChild = childList.item(3); - newdocFragment = doc.createDocumentFragment(); - newChild1 = doc.createElement("br"); - newChild2 = doc.createElement("b"); - appendedChild = newdocFragment.appendChild(newChild1); - appendedChild = newdocFragment.appendChild(newChild2); - insertedNode = employeeNode.insertBefore(newdocFragment, refChild); - child = childList.item(3); - childName = child.getNodeName(); - assertEqualsAutoCase("element", "childName3", "br", childName); - child = childList.item(4); - childName = child.getNodeName(); - assertEqualsAutoCase("element", "childName4", "b", childName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeinsertbeforedocfragment"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeinsertbeforedocfragment.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforeinvalidnodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforeinvalidnodetype.java deleted file mode 100644 index 4b954a4f2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforeinvalidnodetype.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertBefore(newChild,refChild)" method raises a - * HIERARCHY_REQUEST_ERR DOMException if this node is of - * a type that does not allow children of the type "newChild" - * to be inserted. - * - * Retrieve the root node and attempt to insert a newly - * created Attr node. An Element node cannot have children - * of the "Attr" type, therefore the desired exception - * should be raised. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-952280727')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=406 -*/ -public final class hc_nodeinsertbeforeinvalidnodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeinsertbeforeinvalidnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element rootNode; - Node newChild; - NodeList elementList; - Node refChild; - Node insertedNode; - doc = (Document) load("hc_staff", true); - newChild = doc.createAttribute("title"); - elementList = doc.getElementsByTagName("p"); - refChild = elementList.item(1); - rootNode = (Element) refChild.getParentNode(); - - { - boolean success = false; - try { - insertedNode = rootNode.insertBefore(newChild, refChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR); - } - assertTrue("throw_HIERARCHY_REQUEST_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeinsertbeforeinvalidnodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeinsertbeforeinvalidnodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforenewchilddiffdocument.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforenewchilddiffdocument.java deleted file mode 100644 index a9713a353..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforenewchilddiffdocument.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertBefore(newChild,refChild)" method raises a - * WRONG_DOCUMENT_ERR DOMException if the "newChild" was - * created from a different document than the one that - * created this node. - * - * Retrieve the second employee and attempt to insert a new - * child that was created from a different document than the - * one that created the second employee. An attempt to - * insert such a child should raise the desired exception. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-952280727')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247 -*/ -public final class hc_nodeinsertbeforenewchilddiffdocument extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeinsertbeforenewchilddiffdocument(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc1; - Document doc2; - Node refChild; - Node newChild; - NodeList elementList; - Node elementNode; - Node insertedNode; - doc1 = (Document) load("hc_staff", false); - doc2 = (Document) load("hc_staff", true); - newChild = doc1.createElement("br"); - elementList = doc2.getElementsByTagName("p"); - elementNode = elementList.item(1); - refChild = elementNode.getFirstChild(); - - { - boolean success = false; - try { - insertedNode = elementNode.insertBefore(newChild, refChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); - } - assertTrue("throw_WRONG_DOCUMENT_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeinsertbeforenewchilddiffdocument"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeinsertbeforenewchilddiffdocument.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforenewchildexists.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforenewchildexists.java deleted file mode 100644 index dad71d0d5..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforenewchildexists.java +++ /dev/null @@ -1,119 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the "newChild" is already in the tree, the - * "insertBefore(newChild,refChild)" method must first - * remove it before the insertion takes place. - * - * Insert a node Element ("em") that is already - * present in the tree. The existing node should be - * removed first and the new one inserted. The node is - * inserted at a different position in the tree to assure - * that it was indeed inserted. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_nodeinsertbeforenewchildexists extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeinsertbeforenewchildexists(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node refChild; - Node newChild; - Node child; - String childName; - Node insertedNode; - java.util.List expected = new java.util.ArrayList(); - expected.add("strong"); - expected.add("code"); - expected.add("sup"); - expected.add("var"); - expected.add("em"); - expected.add("acronym"); - - java.util.List result = new java.util.ArrayList(); - - int nodeType; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - childList = ((Element) /*Node */employeeNode).getElementsByTagName("*"); - refChild = childList.item(5); - newChild = childList.item(0); - insertedNode = employeeNode.insertBefore(newChild, refChild); - for (int indexN1008C = 0; indexN1008C < childList.getLength(); indexN1008C++) { - child = (Node) childList.item(indexN1008C); - nodeType = (int) child.getNodeType(); - - if (equals(1, nodeType)) { - childName = child.getNodeName(); - result.add(childName); - } - } - assertEqualsAutoCase("element", "childNames", expected, result); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeinsertbeforenewchildexists"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeinsertbeforenewchildexists.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforenodeancestor.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforenodeancestor.java deleted file mode 100644 index 0d69bd866..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforenodeancestor.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertBefore(newChild,refChild)" method raises a - * HIERARCHY_REQUEST_ERR DOMException if the node to be - * inserted is one of this nodes ancestors. - * - * Retrieve the second employee and attempt to insert a - * node that is one of its ancestors(root node). An - * attempt to insert such a node should raise the - * desired exception. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-952280727')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -*/ -public final class hc_nodeinsertbeforenodeancestor extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeinsertbeforenodeancestor(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node newChild; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node refChild; - Node insertedNode; - doc = (Document) load("hc_staff", true); - newChild = doc.getDocumentElement(); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - refChild = childList.item(0); - - { - boolean success = false; - try { - insertedNode = employeeNode.insertBefore(newChild, refChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR); - } - assertTrue("throw_HIERARCHY_REQUEST_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeinsertbeforenodeancestor"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeinsertbeforenodeancestor.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforenodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforenodename.java deleted file mode 100644 index 1ada950bd..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforenodename.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertBefore(newChild,refchild)" method returns - * the node being inserted. - * - * Insert an Element node before the fourth - * child of the second employee and check the node - * returned from the "insertBefore(newChild,refChild)" - * method. The node returned should be "newChild". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247 -*/ -public final class hc_nodeinsertbeforenodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeinsertbeforenodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node refChild; - Node newChild; - Node insertedNode; - String childName; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - refChild = childList.item(3); - newChild = doc.createElement("br"); - insertedNode = employeeNode.insertBefore(newChild, refChild); - childName = insertedNode.getNodeName(); - assertEqualsAutoCase("element", "nodeName", "br", childName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeinsertbeforenodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeinsertbeforenodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforerefchildnonexistent.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforerefchildnonexistent.java deleted file mode 100644 index f9225954b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforerefchildnonexistent.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertBefore(newChild,refChild)" method raises a - * NOT_FOUND_ERR DOMException if the reference child is - * not a child of this node. - * - * Retrieve the second employee and attempt to insert a - * new node before a reference node that is not a child - * of this node. An attempt to insert before a non child - * node should raise the desired exception. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-952280727')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class hc_nodeinsertbeforerefchildnonexistent extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeinsertbeforerefchildnonexistent(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node refChild; - Node newChild; - NodeList elementList; - Node elementNode; - Node insertedNode; - doc = (Document) load("hc_staff", true); - newChild = doc.createElement("br"); - refChild = doc.createElement("b"); - elementList = doc.getElementsByTagName("p"); - elementNode = elementList.item(1); - - { - boolean success = false; - try { - insertedNode = elementNode.insertBefore(newChild, refChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_FOUND_ERR); - } - assertTrue("throw_NOT_FOUND_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeinsertbeforerefchildnonexistent"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeinsertbeforerefchildnonexistent.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforerefchildnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforerefchildnull.java deleted file mode 100644 index d39684b19..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeinsertbeforerefchildnull.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the "refChild" is null then the - * "insertBefore(newChild,refChild)" method inserts the - * node "newChild" at the end of the list of children. - * - * Retrieve the second employee and invoke the - * "insertBefore(newChild,refChild)" method with - * refChild=null. Since "refChild" is null the "newChild" - * should be added to the end of the list. The last item - * in the list is checked after insertion. The last Element - * node of the list should be "newChild". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247 -*/ -public final class hc_nodeinsertbeforerefchildnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeinsertbeforerefchildnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node refChild = null; - - Node newChild; - Node child; - String childName; - Node insertedNode; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - newChild = doc.createElement("br"); - insertedNode = employeeNode.insertBefore(newChild, refChild); - child = employeeNode.getLastChild(); - childName = child.getNodeName(); - assertEqualsAutoCase("element", "nodeName", "br", childName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeinsertbeforerefchildnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeinsertbeforerefchildnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistindexequalzero.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistindexequalzero.java deleted file mode 100644 index 5556d46f9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistindexequalzero.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Create a list of all the children elements of the third - * employee and access its first child by using an index - * of 0. This should result in the whitspace before "em" being - * selected (em when ignoring whitespace). - * Further we evaluate its content(by using - * the "getNodeName()" method) to ensure the proper - * element was accessed. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_nodelistindexequalzero extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodelistindexequalzero(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList employeeList; - Node child; - String childName; - int length; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(2); - employeeList = employeeNode.getChildNodes(); - length = (int) employeeList.getLength(); - child = employeeList.item(0); - childName = child.getNodeName(); - - if (equals(13, length)) { - assertEquals("childName_w_whitespace", "#text", childName); - } else { - assertEqualsAutoCase("element", "childName_wo_whitespace", "em", childName); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodelistindexequalzero"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodelistindexequalzero.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistindexgetlength.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistindexgetlength.java deleted file mode 100644 index d965d9ee5..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistindexgetlength.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getLength()" method returns the number of nodes - * in the list. - * - * Create a list of all the children elements of the third - * employee and invoke the "getLength()" method. - * It should contain the value 13. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_nodelistindexgetlength extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodelistindexgetlength(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList employeeList; - int length; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(2); - employeeList = employeeNode.getChildNodes(); - length = (int) employeeList.getLength(); - - if (equals(6, length)) { - assertEquals("length_wo_space", 6, length); - } else { - assertEquals("length_w_space", 13, length); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodelistindexgetlength"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodelistindexgetlength.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistindexgetlengthofemptylist.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistindexgetlengthofemptylist.java deleted file mode 100644 index 45b908854..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistindexgetlengthofemptylist.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getLength()" method returns the number of nodes - * in the list.(Test for EMPTY list) - * - * Create a list of all the children of the Text node - * inside the first child of the third employee and - * invoke the "getLength()" method. It should contain - * the value 0. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_nodelistindexgetlengthofemptylist extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodelistindexgetlengthofemptylist(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList emList; - Node emNode; - Node textNode; - NodeList textList; - int length; - doc = (Document) load("hc_staff", false); - emList = doc.getElementsByTagName("em"); - emNode = emList.item(2); - textNode = emNode.getFirstChild(); - textList = textNode.getChildNodes(); - length = (int) textList.getLength(); - assertEquals("length", 0, length); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodelistindexgetlengthofemptylist"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodelistindexgetlengthofemptylist.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistindexnotzero.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistindexnotzero.java deleted file mode 100644 index 84c9c8210..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistindexnotzero.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The items in the list are accessible via an integral - * index starting from zero. - * (Index not equal 0) - * - * Create a list of all the children elements of the third - * employee and access its fourth child by using an index - * of 3 and calling getNodeName() which should return - * "strong" (no whitespace) or "#text" (with whitespace). -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_nodelistindexnotzero extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodelistindexnotzero(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList employeeList; - Node child; - String childName; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(2); - employeeList = employeeNode.getChildNodes(); - child = employeeList.item(3); - childName = child.getNodeName(); - - if (equals("#text", childName)) { - assertEquals("childName_space", "#text", childName); - } else { - assertEqualsAutoCase("element", "childName_strong", "strong", childName); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodelistindexnotzero"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodelistindexnotzero.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistreturnfirstitem.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistreturnfirstitem.java deleted file mode 100644 index 363320460..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistreturnfirstitem.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Create a list of all the children elements of the third - * employee and access its first child by invoking the - * "item(index)" method with an index=0. This should - * result in node with a nodeName of "#text" or "em". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_nodelistreturnfirstitem extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodelistreturnfirstitem(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList employeeList; - Node child; - String childName; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(2); - employeeList = employeeNode.getChildNodes(); - child = employeeList.item(0); - childName = child.getNodeName(); - - if (equals("#text", childName)) { - assertEquals("nodeName_w_space", "#text", childName); - } else { - assertEqualsAutoCase("element", "nodeName_wo_space", "em", childName); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodelistreturnfirstitem"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodelistreturnfirstitem.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistreturnlastitem.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistreturnlastitem.java deleted file mode 100644 index eeb03dcd2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelistreturnlastitem.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Create a list of all the children elements of the third - * employee and access its last child by invoking the - * "item(index)" method with an index=length-1. This should - * result in node with nodeName="#text" or acronym. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_nodelistreturnlastitem extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodelistreturnlastitem(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList employeeList; - Node child; - String childName; - int index; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(2); - employeeList = employeeNode.getChildNodes(); - index = (int) employeeList.getLength(); - index -= 1; - child = employeeList.item(((int) /*int */index)); - childName = child.getNodeName(); - - if (equals(12, index)) { - assertEquals("lastNodeName_w_whitespace", "#text", childName); - } else { - assertEqualsAutoCase("element", "lastNodeName", "acronym", childName); - assertEquals("index", 5, index); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodelistreturnlastitem"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodelistreturnlastitem.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelisttraverselist.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelisttraverselist.java deleted file mode 100644 index 29b17628e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodelisttraverselist.java +++ /dev/null @@ -1,114 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The range of valid child node indices is 0 thru length -1 - * - * Create a list of all the children elements of the third - * employee and traverse the list from index=0 thru - * length -1. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_nodelisttraverselist extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodelisttraverselist(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList employeeList; - Node child; - String childName; - int nodeType; - java.util.List result = new java.util.ArrayList(); - - java.util.List expected = new java.util.ArrayList(); - expected.add("em"); - expected.add("strong"); - expected.add("code"); - expected.add("sup"); - expected.add("var"); - expected.add("acronym"); - - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(2); - employeeList = employeeNode.getChildNodes(); - for (int indexN10073 = 0; indexN10073 < employeeList.getLength(); indexN10073++) { - child = (Node) employeeList.item(indexN10073); - nodeType = (int) child.getNodeType(); - childName = child.getNodeName(); - - if (equals(1, nodeType)) { - result.add(childName); - } else { - assertEquals("textNodeType", 3, nodeType); - assertEquals("textNodeName", "#text", childName); - } - - } - assertEqualsAutoCase("element", "nodeNames", expected, result); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodelisttraverselist"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodelisttraverselist.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeparentnode.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeparentnode.java deleted file mode 100644 index 87070f51f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeparentnode.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getParentNode()" method returns the parent - * of this node. - * - * Retrieve the second employee and invoke the - * "getParentNode()" method on this node. It should - * be set to "body". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1060184317 -*/ -public final class hc_nodeparentnode extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeparentnode(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - Node parentNode; - String parentName; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - parentNode = employeeNode.getParentNode(); - parentName = parentNode.getNodeName(); - assertEqualsAutoCase("element", "parentNodeName", "body", parentName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeparentnode"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeparentnode.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeparentnodenull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeparentnodenull.java deleted file mode 100644 index 0896b8136..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodeparentnodenull.java +++ /dev/null @@ -1,86 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getParentNode()" method invoked on a node that has - * just been created and not yet added to the tree is null. - * Create a new "employee" Element node using the - * "createElement(name)" method from the Document interface. - * Since this new node has not yet been added to the tree, - * the "getParentNode()" method will return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1060184317 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247 -*/ -public final class hc_nodeparentnodenull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodeparentnodenull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element createdNode; - Node parentNode; - doc = (Document) load("hc_staff", false); - createdNode = doc.createElement("br"); - parentNode = createdNode.getParentNode(); - assertNull("parentNode", parentNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeparentnodenull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodeparentnodenull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_noderemovechild.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_noderemovechild.java deleted file mode 100644 index a905f465e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_noderemovechild.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeChild(oldChild)" method removes the child node - * indicated by "oldChild" from the list of children and - * returns it. - * - * Remove the first employee by invoking the - * "removeChild(oldChild)" method an checking the - * node returned by the "getParentNode()" method. It - * should be set to null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class hc_noderemovechild extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_noderemovechild(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element rootNode; - NodeList childList; - Node childToRemove; - Node removedChild; - Node parentNode; - doc = (Document) load("hc_staff", true); - rootNode = doc.getDocumentElement(); - childList = rootNode.getChildNodes(); - childToRemove = childList.item(1); - removedChild = rootNode.removeChild(childToRemove); - parentNode = removedChild.getParentNode(); - assertNull("parentNodeNull", parentNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_noderemovechild"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_noderemovechild.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_noderemovechildgetnodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_noderemovechildgetnodename.java deleted file mode 100644 index b8e904130..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_noderemovechildgetnodename.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeChild(oldChild)" method returns - * the node being removed. - * - * Remove the first child of the second employee - * and check the NodeName returned by the - * "removeChild(oldChild)" method. The returned node - * should have a NodeName equal to "#text". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_noderemovechildgetnodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_noderemovechildgetnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node oldChild; - Node removedChild; - String childName; - String oldName; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - oldChild = childList.item(0); - oldName = oldChild.getNodeName(); - removedChild = employeeNode.removeChild(oldChild); - assertNotNull("notnull", removedChild); - childName = removedChild.getNodeName(); - assertEquals("nodeName", oldName, childName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_noderemovechildgetnodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_noderemovechildgetnodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_noderemovechildnode.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_noderemovechildnode.java deleted file mode 100644 index 132886c82..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_noderemovechildnode.java +++ /dev/null @@ -1,124 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeChild(oldChild)" method removes the node - * indicated by "oldChild". - * - * Retrieve the second p element and remove its first child. - * After the removal, the second p element should have 5 element - * children and the first child should now be the child - * that used to be at the second position in the list. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_noderemovechildnode extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_noderemovechildnode(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - NodeList emList; - Node employeeNode; - NodeList childList; - Node oldChild; - Node child; - String childName; - int length; - Node removedChild; - String removedName; - int nodeType; - java.util.List expected = new java.util.ArrayList(); - expected.add("strong"); - expected.add("code"); - expected.add("sup"); - expected.add("var"); - expected.add("acronym"); - - java.util.List actual = new java.util.ArrayList(); - - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - emList = ((Element) /*Node */employeeNode).getElementsByTagName("em"); - oldChild = emList.item(0); - removedChild = employeeNode.removeChild(oldChild); - removedName = removedChild.getNodeName(); - assertEqualsAutoCase("element", "removedName", "em", removedName); - for (int indexN10098 = 0; indexN10098 < childList.getLength(); indexN10098++) { - child = (Node) childList.item(indexN10098); - nodeType = (int) child.getNodeType(); - childName = child.getNodeName(); - - if (equals(1, nodeType)) { - actual.add(childName); - } else { - assertEquals("textNodeType", 3, nodeType); - assertEquals("textNodeName", "#text", childName); - } - - } - assertEqualsAutoCase("element", "childNames", expected, actual); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_noderemovechildnode"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_noderemovechildnode.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_noderemovechildoldchildnonexistent.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_noderemovechildoldchildnonexistent.java deleted file mode 100644 index b2422b2d6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_noderemovechildoldchildnonexistent.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeChild(oldChild)" method raises a - * NOT_FOUND_ERR DOMException if the old child is - * not a child of this node. - * - * Retrieve the second employee and attempt to remove a - * node that is not one of its children. An attempt to - * remove such a node should raise the desired exception. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1734834066')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247 -*/ -public final class hc_noderemovechildoldchildnonexistent extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_noderemovechildoldchildnonexistent(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node oldChild; - NodeList elementList; - Node elementNode; - Node removedChild; - doc = (Document) load("hc_staff", true); - oldChild = doc.createElement("br"); - elementList = doc.getElementsByTagName("p"); - elementNode = elementList.item(1); - - { - boolean success = false; - try { - removedChild = elementNode.removeChild(oldChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_FOUND_ERR); - } - assertTrue("throw_NOT_FOUND_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_noderemovechildoldchildnonexistent"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_noderemovechildoldchildnonexistent.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechild.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechild.java deleted file mode 100644 index 49156c5b4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechild.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceChild(newChild,oldChild)" method replaces - * the node "oldChild" with the node "newChild". - * - * Replace the first element of the second employee with - * a newly created Element node. Check the first position - * after the replacement operation is completed. The new - * Element should be "newChild". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247 -*/ -public final class hc_nodereplacechild extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodereplacechild(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node oldChild; - Node newChild; - Node child; - String childName; - Node replacedNode; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - oldChild = childList.item(0); - newChild = doc.createElement("br"); - replacedNode = employeeNode.replaceChild(newChild, oldChild); - child = childList.item(0); - childName = child.getNodeName(); - assertEqualsAutoCase("element", "nodeName", "br", childName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodereplacechild"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodereplacechild.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildinvalidnodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildinvalidnodetype.java deleted file mode 100644 index 95c6371bf..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildinvalidnodetype.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceChild(newChild,oldChild)" method raises a - * HIERARCHY_REQUEST_ERR DOMException if this node is of - * a type that does not allow children of the type "newChild" - * to be inserted. - * - * Retrieve the root node and attempt to replace - * one of its children with a newly created Attr node. - * An Element node cannot have children of the "Attr" - * type, therefore the desired exception should be raised. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-785887307')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=406 -*/ -public final class hc_nodereplacechildinvalidnodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodereplacechildinvalidnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element rootNode; - Node newChild; - NodeList elementList; - Node oldChild; - Node replacedChild; - doc = (Document) load("hc_staff", true); - newChild = doc.createAttribute("lang"); - elementList = doc.getElementsByTagName("p"); - oldChild = elementList.item(1); - rootNode = (Element) oldChild.getParentNode(); - - { - boolean success = false; - try { - replacedChild = rootNode.replaceChild(newChild, oldChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR); - } - assertTrue("throw_HIERARCHY_REQUEST_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodereplacechildinvalidnodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodereplacechildinvalidnodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildnewchilddiffdocument.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildnewchilddiffdocument.java deleted file mode 100644 index ddcdeee9c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildnewchilddiffdocument.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceChild(newChild,oldChild)" method raises a - * WRONG_DOCUMENT_ERR DOMException if the "newChild" was - * created from a different document than the one that - * created this node. - * - * Retrieve the second employee and attempt to replace one - * of its children with a node created from a different - * document. An attempt to make such a replacement - * should raise the desired exception. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-785887307')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247 -*/ -public final class hc_nodereplacechildnewchilddiffdocument extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodereplacechildnewchilddiffdocument(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc1; - Document doc2; - Node oldChild; - Node newChild; - NodeList elementList; - Node elementNode; - Node replacedChild; - doc1 = (Document) load("hc_staff", false); - doc2 = (Document) load("hc_staff", true); - newChild = doc1.createElement("br"); - elementList = doc2.getElementsByTagName("p"); - elementNode = elementList.item(1); - oldChild = elementNode.getFirstChild(); - - { - boolean success = false; - try { - replacedChild = elementNode.replaceChild(newChild, oldChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); - } - assertTrue("throw_WRONG_DOCUMENT_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodereplacechildnewchilddiffdocument"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodereplacechildnewchilddiffdocument.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildnewchildexists.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildnewchildexists.java deleted file mode 100644 index 89bd3eb95..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildnewchildexists.java +++ /dev/null @@ -1,121 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the "newChild" is already in the tree, it is first - * removed before the new one is added. - * - * Retrieve the second "p" and replace "acronym" with its "em". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246 -*/ -public final class hc_nodereplacechildnewchildexists extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodereplacechildnewchildexists(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node oldChild = null; - - Node newChild = null; - - Node child; - String childName; - Node childNode; - java.util.List actual = new java.util.ArrayList(); - - java.util.List expected = new java.util.ArrayList(); - expected.add("strong"); - expected.add("code"); - expected.add("sup"); - expected.add("var"); - expected.add("em"); - - Node replacedChild; - int nodeType; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - childList = ((Element) /*Node */employeeNode).getElementsByTagName("*"); - newChild = childList.item(0); - oldChild = childList.item(5); - replacedChild = employeeNode.replaceChild(newChild, oldChild); - assertSame("return_value_same", oldChild, replacedChild); -for (int indexN10094 = 0; indexN10094 < childList.getLength(); indexN10094++) { - childNode = (Node) childList.item(indexN10094); - childName = childNode.getNodeName(); - nodeType = (int) childNode.getNodeType(); - - if (equals(1, nodeType)) { - actual.add(childName); - } else { - assertEquals("textNodeType", 3, nodeType); - assertEquals("textNodeName", "#text", childName); - } - - } - assertEqualsAutoCase("element", "childNames", expected, actual); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodereplacechildnewchildexists"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodereplacechildnewchildexists.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildnodeancestor.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildnodeancestor.java deleted file mode 100644 index eda76061f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildnodeancestor.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceChild(newChild,oldChild)" method raises a - * HIERARCHY_REQUEST_ERR DOMException if the node to put - * in is one of this node's ancestors. - * - * Retrieve the second employee and attempt to replace - * one of its children with an ancestor node(root node). - * An attempt to make such a replacement should raise the - * desired exception. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-785887307')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -*/ -public final class hc_nodereplacechildnodeancestor extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodereplacechildnodeancestor(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node newChild; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node oldChild; - Node replacedNode; - doc = (Document) load("hc_staff", true); - newChild = doc.getDocumentElement(); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - oldChild = childList.item(0); - - { - boolean success = false; - try { - replacedNode = employeeNode.replaceChild(newChild, oldChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR); - } - assertTrue("throw_HIERARCHY_REQUEST_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodereplacechildnodeancestor"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodereplacechildnodeancestor.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildnodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildnodename.java deleted file mode 100644 index 6947d398e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildnodename.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceChild(newChild,oldChild)" method returns - * the node being replaced. - * - * Replace the second Element of the second employee with - * a newly created node Element and check the NodeName - * returned by the "replaceChild(newChild,oldChild)" - * method. The returned node should have a NodeName equal - * to "em". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247 -*/ -public final class hc_nodereplacechildnodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodereplacechildnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node oldChild; - Node newChild; - Node replacedNode; - String childName; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("p"); - employeeNode = elementList.item(1); - childList = ((Element) /*Node */employeeNode).getElementsByTagName("em"); - oldChild = childList.item(0); - newChild = doc.createElement("br"); - replacedNode = employeeNode.replaceChild(newChild, oldChild); - childName = replacedNode.getNodeName(); - assertEqualsAutoCase("element", "replacedNodeName", "em", childName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodereplacechildnodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodereplacechildnodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildoldchildnonexistent.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildoldchildnonexistent.java deleted file mode 100644 index bbbda27c1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodereplacechildoldchildnonexistent.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceChild(newChild,oldChild)" method raises a - * NOT_FOUND_ERR DOMException if the old child is - * not a child of this node. - * - * Retrieve the second employee and attempt to replace a - * node that is not one of its children. An attempt to - * replace such a node should raise the desired exception. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-785887307')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247 -*/ -public final class hc_nodereplacechildoldchildnonexistent extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodereplacechildoldchildnonexistent(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node oldChild; - Node newChild; - NodeList elementList; - Node elementNode; - Node replacedNode; - doc = (Document) load("hc_staff", true); - newChild = doc.createElement("br"); - oldChild = doc.createElement("b"); - elementList = doc.getElementsByTagName("p"); - elementNode = elementList.item(1); - - { - boolean success = false; - try { - replacedNode = elementNode.replaceChild(newChild, oldChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_FOUND_ERR); - } - assertTrue("throw_NOT_FOUND_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodereplacechildoldchildnonexistent"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodereplacechildoldchildnonexistent.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodetextnodeattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodetextnodeattribute.java deleted file mode 100644 index 07442048c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodetextnodeattribute.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributes()" method invoked on a Text - * Node returns null. - * Retrieve the Text node from the last child of the - * first employee and invoke the "getAttributes()" method - * on the Text Node. It should return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1312295772 -*/ -public final class hc_nodetextnodeattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodetextnodeattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testAddr; - Node textNode; - NamedNodeMap attrList; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - testAddr = elementList.item(0); - textNode = testAddr.getFirstChild(); - attrList = textNode.getAttributes(); - assertNull("text_attributes_is_null", attrList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodetextnodeattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodetextnodeattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodetextnodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodetextnodename.java deleted file mode 100644 index 830d0866b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodetextnodename.java +++ /dev/null @@ -1,85 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeName()" method for a - * Text Node is "#text". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -*/ -public final class hc_nodetextnodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodetextnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - Node textNode; - String textName; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - testAddr = (Element) elementList.item(0); - textNode = testAddr.getFirstChild(); - textName = textNode.getNodeName(); - assertEquals("textNodeName", "#text", textName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodetextnodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodetextnodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodetextnodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodetextnodetype.java deleted file mode 100644 index f9c0862ab..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodetextnodetype.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNodeType()" method for a Text Node - * returns the constant value 3. - * - * Retrieve the Text node from the last child of - * the first employee and invoke the "getNodeType()" - * method. The method should return 3. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -*/ -public final class hc_nodetextnodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodetextnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - Node textNode; - int nodeType; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - testAddr = (Element) elementList.item(0); - textNode = testAddr.getFirstChild(); - nodeType = (int) textNode.getNodeType(); - assertEquals("nodeTextNodeTypeAssert1", 3, nodeType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodetextnodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodetextnodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodetextnodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodetextnodevalue.java deleted file mode 100644 index b647ebb3d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodetextnodevalue.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeValue()" method for a - * Text Node is the content of the Text node. - * - * Retrieve the Text node from the last child of the first - * employee and check the string returned by the - * "getNodeValue()" method. It should be equal to - * "1230 North Ave. Dallas, Texas 98551". -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -*/ -public final class hc_nodetextnodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodetextnodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - Node textNode; - String textValue; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - testAddr = (Element) elementList.item(0); - textNode = testAddr.getFirstChild(); - textValue = textNode.getNodeValue(); - assertEquals("textNodeValue", "1230 North Ave. Dallas, Texas 98551", textValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodetextnodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodetextnodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue01.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue01.java deleted file mode 100644 index 1ef97f560..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue01.java +++ /dev/null @@ -1,85 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An element is created, setNodeValue is called with a non-null argument, but getNodeValue - * should still return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document -*/ -public final class hc_nodevalue01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodevalue01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element newNode; - String newValue; - doc = (Document) load("hc_staff", true); - newNode = doc.createElement("acronym"); - newValue = newNode.getNodeValue(); - assertNull("initiallyNull", newValue); - newNode.setNodeValue("This should have no effect"); - newValue = newNode.getNodeValue(); - assertNull("nullAfterAttemptedChange", newValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodevalue01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodevalue01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue02.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue02.java deleted file mode 100644 index 89fb85e40..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue02.java +++ /dev/null @@ -1,85 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An comment is created, setNodeValue is called with a non-null argument, but getNodeValue - * should still return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322 -*/ -public final class hc_nodevalue02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodevalue02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node newNode; - String newValue; - doc = (Document) load("hc_staff", true); - newNode = doc.createComment("This is a new Comment node"); - newValue = newNode.getNodeValue(); - assertEquals("initial", "This is a new Comment node", newValue); - newNode.setNodeValue("This should have an effect"); - newValue = newNode.getNodeValue(); - assertEquals("afterChange", "This should have an effect", newValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodevalue02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodevalue02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue03.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue03.java deleted file mode 100644 index 336b8e75a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue03.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An entity reference is created, setNodeValue is called with a non-null argument, but getNodeValue - * should still return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-11C98490 -*/ -public final class hc_nodevalue03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodevalue03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node newNode; - String newValue; - doc = (Document) load("hc_staff", true); - - if (("text/html".equals(getContentType()))) { - - { - boolean success = false; - try { - newNode = doc.createEntityReference("ent1"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_SUPPORTED_ERR); - } - assertTrue("throw_NOT_SUPPORTED_ERR", success); - } -} else { - newNode = doc.createEntityReference("ent1"); - assertNotNull("createdEntRefNotNull", newNode); - newValue = newNode.getNodeValue(); - assertNull("initiallyNull", newValue); - newNode.setNodeValue("This should have no effect"); - newValue = newNode.getNodeValue(); - assertNull("nullAfterAttemptedChange", newValue); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodevalue03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodevalue03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue04.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue04.java deleted file mode 100644 index c86fd471d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue04.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An document type accessed, setNodeValue is called with a non-null argument, but getNodeValue - * should still return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31 -*/ -public final class hc_nodevalue04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodevalue04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node newNode; - String newValue; - doc = (Document) load("hc_staff", true); - newNode = doc.getDoctype(); - assertTrue("docTypeNotNullOrDocIsHTML", - ((newNode != null) | ("text/html".equals(getContentType()))) -); - - if ((newNode != null)) { - assertNotNull("docTypeNotNull", newNode); - newValue = newNode.getNodeValue(); - assertNull("initiallyNull", newValue); - newNode.setNodeValue("This should have no effect"); - newValue = newNode.getNodeValue(); - assertNull("nullAfterAttemptedChange", newValue); - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodevalue04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodevalue04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue05.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue05.java deleted file mode 100644 index bb71bc47a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue05.java +++ /dev/null @@ -1,85 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * A document fragment is created, setNodeValue is called with a non-null argument, but getNodeValue - * should still return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3 -*/ -public final class hc_nodevalue05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodevalue05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node newNode; - String newValue; - doc = (Document) load("hc_staff", true); - newNode = doc.createDocumentFragment(); - newValue = newNode.getNodeValue(); - assertNull("initiallyNull", newValue); - newNode.setNodeValue("This should have no effect"); - newValue = newNode.getNodeValue(); - assertNull("nullAfterAttemptedChange", newValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodevalue05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodevalue05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue06.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue06.java deleted file mode 100644 index 79bafb30e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue06.java +++ /dev/null @@ -1,83 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An document is accessed, setNodeValue is called with a non-null argument, but getNodeValue - * should still return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document -*/ -public final class hc_nodevalue06 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodevalue06(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document newNode; - String newValue; - newNode = (Document) load("hc_staff", true); - newValue = newNode.getNodeValue(); - assertNull("initiallyNull", newValue); - newNode.setNodeValue("This should have no effect"); - newValue = newNode.getNodeValue(); - assertNull("nullAfterAttemptedChange", newValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodevalue06"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodevalue06.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue07.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue07.java deleted file mode 100644 index b0a8217dc..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue07.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An Entity is accessed, setNodeValue is called with a non-null argument, but getNodeValue - * should still return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-527DCFF2 -*/ -public final class hc_nodevalue07 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodevalue07(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - if (factory.hasFeature("XML", null) != true) { - throw org.w3c.domts.DOMTestIncompatibleException.incompatibleFeature("XML", null); - } - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node newNode; - String newValue; - NamedNodeMap nodeMap; - DocumentType docType; - doc = (Document) load("hc_staff", true); - docType = doc.getDoctype(); - - if ( - !(("text/html".equals(getContentType()))) -) { - assertNotNull("docTypeNotNull", docType); - nodeMap = docType.getEntities(); - assertNotNull("entitiesNotNull", nodeMap); - newNode = nodeMap.getNamedItem("alpha"); - assertNotNull("entityNotNull", newNode); - newValue = newNode.getNodeValue(); - assertNull("initiallyNull", newValue); - newNode.setNodeValue("This should have no effect"); - newValue = newNode.getNodeValue(); - assertNull("nullAfterAttemptedChange", newValue); - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodevalue07"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodevalue07.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue08.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue08.java deleted file mode 100644 index 05bdf5bea..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_nodevalue08.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An notation is accessed, setNodeValue is called with a non-null argument, but getNodeValue - * should still return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5431D1B9 -*/ -public final class hc_nodevalue08 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodevalue08(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - if (factory.hasFeature("XML", null) != true) { - throw org.w3c.domts.DOMTestIncompatibleException.incompatibleFeature("XML", null); - } - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - Node newNode; - String newValue; - NamedNodeMap nodeMap; - doc = (Document) load("hc_staff", true); - docType = doc.getDoctype(); - - if ( - !(("text/html".equals(getContentType()))) -) { - assertNotNull("docTypeNotNull", docType); - nodeMap = docType.getNotations(); - assertNotNull("notationsNotNull", nodeMap); - newNode = nodeMap.getNamedItem("notation1"); - assertNotNull("notationNotNull", newNode); - newValue = newNode.getNodeValue(); - assertNull("initiallyNull", newValue); - newNode.setNodeValue("This should have no effect"); - newValue = newNode.getNodeValue(); - assertNull("nullAfterAttemptedChange", newValue); - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodevalue08"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodevalue08.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_notationsremovenameditem1.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_notationsremovenameditem1.java deleted file mode 100644 index d088d3f22..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_notationsremovenameditem1.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An attempt to add remove an notation should result in a NO_MODIFICATION_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D46829EF -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193 -*/ -public final class hc_notationsremovenameditem1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_notationsremovenameditem1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - if (factory.hasFeature("XML", null) != true) { - throw org.w3c.domts.DOMTestIncompatibleException.incompatibleFeature("XML", null); - } - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap notations; - DocumentType docType; - Node retval; - doc = (Document) load("hc_staff", true); - docType = doc.getDoctype(); - - if ( - !(("text/html".equals(getContentType()))) -) { - assertNotNull("docTypeNotNull", docType); - notations = docType.getNotations(); - assertNotNull("notationsNotNull", notations); - - { - boolean success = false; - try { - retval = notations.removeNamedItem("notation1"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_notationsremovenameditem1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_notationsremovenameditem1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_notationssetnameditem1.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_notationssetnameditem1.java deleted file mode 100644 index 1e220bc46..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_notationssetnameditem1.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An attempt to add an element to the named node map returned by notations should - * result in a NO_MODIFICATION_ERR or HIERARCHY_REQUEST_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D46829EF -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788 -*/ -public final class hc_notationssetnameditem1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_notationssetnameditem1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - if (factory.hasFeature("XML", null) != true) { - throw org.w3c.domts.DOMTestIncompatibleException.incompatibleFeature("XML", null); - } - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap notations; - DocumentType docType; - Node retval; - Element elem; - doc = (Document) load("hc_staff", true); - docType = doc.getDoctype(); - - if ( - !(("text/html".equals(getContentType()))) -) { - assertNotNull("docTypeNotNull", docType); - notations = docType.getNotations(); - assertNotNull("notationsNotNull", notations); - elem = doc.createElement("br"); - - try { - retval = notations.setNamedItem(elem); - fail("throw_HIER_OR_NO_MOD_ERR"); - - } catch (DOMException ex) { - switch (ex.code) { - case 3 : - break; - case 7 : - break; - default: - throw ex; - } - } -} - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_notationssetnameditem1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_notationssetnameditem1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textindexsizeerrnegativeoffset.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textindexsizeerrnegativeoffset.java deleted file mode 100644 index 5de7f34dd..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textindexsizeerrnegativeoffset.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "splitText(offset)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset is - * negative. - * - * Retrieve the textual data from the second child of the - * third employee and invoke the "splitText(offset)" method. - * The desired exception should be raised since the offset - * is a negative number. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-38853C1D')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -*/ -public final class hc_textindexsizeerrnegativeoffset extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_textindexsizeerrnegativeoffset(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.signed - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - Text textNode; - Text splitNode; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("strong"); - nameNode = elementList.item(2); - textNode = (Text) nameNode.getFirstChild(); - - { - boolean success = false; - try { - splitNode = textNode.splitText(-69); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throws_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_textindexsizeerrnegativeoffset"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_textindexsizeerrnegativeoffset.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textindexsizeerroffsetoutofbounds.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textindexsizeerroffsetoutofbounds.java deleted file mode 100644 index 1f5832237..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textindexsizeerroffsetoutofbounds.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "splitText(offset)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset is - * greater than the number of characters in the Text node. - * - * Retrieve the textual data from the second child of the - * third employee and invoke the "splitText(offset)" method. - * The desired exception should be raised since the offset - * is a greater than the number of characters in the Text - * node. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-38853C1D')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class hc_textindexsizeerroffsetoutofbounds extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_textindexsizeerroffsetoutofbounds(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - Text textNode; - Text splitNode; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("strong"); - nameNode = elementList.item(2); - textNode = (Text) nameNode.getFirstChild(); - - { - boolean success = false; - try { - splitNode = textNode.splitText(300); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throw_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_textindexsizeerroffsetoutofbounds"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_textindexsizeerroffsetoutofbounds.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textparseintolistofelements.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textparseintolistofelements.java deleted file mode 100644 index 5694a4ac8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textparseintolistofelements.java +++ /dev/null @@ -1,125 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the textual data from the last child of the - * second employee. That node is composed of two - * EntityReference nodes and two Text nodes. After - * the content node is parsed, the "acronym" Element - * should contain four children with each one of the - * EntityReferences containing one child. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-11C98490 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-745549614 -*/ -public final class hc_textparseintolistofelements extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_textparseintolistofelements(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node addressNode; - NodeList childList; - Node child; - String value; - Node grandChild; - int length; - java.util.List result = new java.util.ArrayList(); - - java.util.List expectedNormal = new java.util.ArrayList(); - expectedNormal.add("β"); - expectedNormal.add(" Dallas, "); - expectedNormal.add("γ"); - expectedNormal.add("\n 98554"); - - java.util.List expectedExpanded = new java.util.ArrayList(); - expectedExpanded.add("β Dallas, γ\n 98554"); - - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("acronym"); - addressNode = elementList.item(1); - childList = addressNode.getChildNodes(); - length = (int) childList.getLength(); - for (int indexN1007C = 0; indexN1007C < childList.getLength(); indexN1007C++) { - child = (Node) childList.item(indexN1007C); - value = child.getNodeValue(); - - if ((value == null)) { - grandChild = child.getFirstChild(); - assertNotNull("grandChildNotNull", grandChild); - value = grandChild.getNodeValue(); - result.add(value); - } else { - result.add(value); - } - - } - - if (equals(1, length)) { - assertEquals("assertEqCoalescing", expectedExpanded, result); - } else { - assertEquals("assertEqNormal", expectedNormal, result); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_textparseintolistofelements"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_textparseintolistofelements.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textsplittextfour.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textsplittextfour.java deleted file mode 100644 index beafa4268..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textsplittextfour.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "splitText(offset)" method returns the new Text node. - * - * Retrieve the textual data from the last child of the - * first employee and invoke the "splitText(offset)" method. - * The method should return the new Text node. The offset - * value used for this test is 30. The "getNodeValue()" - * method is called to check that the new node now contains - * the characters at and after position 30. - * (Starting count at 0) -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D -*/ -public final class hc_textsplittextfour extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_textsplittextfour(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node addressNode; - Text textNode; - Text splitNode; - String value; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("acronym"); - addressNode = elementList.item(0); - textNode = (Text) addressNode.getFirstChild(); - splitNode = textNode.splitText(30); - value = splitNode.getNodeValue(); - assertEquals("textSplitTextFourAssert", "98551", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_textsplittextfour"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_textsplittextfour.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textsplittextone.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textsplittextone.java deleted file mode 100644 index 24f8bd390..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textsplittextone.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "splitText(offset)" method breaks the Text node into - * two Text nodes at the specified offset keeping each node - * as siblings in the tree. - * - * Retrieve the textual data from the second child of the - * third employee and invoke the "splitText(offset)" method. - * The method splits the Text node into two new sibling - * Text nodes keeping both of them in the tree. This test - * checks the "nextSibling()" method of the original node - * to ensure that the two nodes are indeed siblings. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D -*/ -public final class hc_textsplittextone extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_textsplittextone(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - Text textNode; - Text splitNode; - Node secondPart; - String value; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("strong"); - nameNode = elementList.item(2); - textNode = (Text) nameNode.getFirstChild(); - splitNode = textNode.splitText(7); - secondPart = textNode.getNextSibling(); - value = secondPart.getNodeValue(); - assertEquals("textSplitTextOneAssert", "Jones", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_textsplittextone"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_textsplittextone.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textsplittextthree.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textsplittextthree.java deleted file mode 100644 index e607c7a8a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textsplittextthree.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * After the "splitText(offset)" method breaks the Text node - * into two Text nodes, the new Text node contains all the - * content at and after the offset point. - * - * Retrieve the textual data from the second child of the - * third employee and invoke the "splitText(offset)" method. - * The new Text node should contain all the content - * at and after the offset point. The "getNodeValue()" - * method is called to check that the new node now contains - * the characters at and after position seven. - * (Starting count at 0) -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D -*/ -public final class hc_textsplittextthree extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_textsplittextthree(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - Text textNode; - Text splitNode; - String value; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("strong"); - nameNode = elementList.item(2); - textNode = (Text) nameNode.getFirstChild(); - splitNode = textNode.splitText(6); - value = splitNode.getNodeValue(); - assertEquals("textSplitTextThreeAssert", " Jones", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_textsplittextthree"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_textsplittextthree.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textsplittexttwo.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textsplittexttwo.java deleted file mode 100644 index da925c7b9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textsplittexttwo.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * After the "splitText(offset)" method breaks the Text node - * into two Text nodes, the original node contains all the - * content up to the offset point. - * - * Retrieve the textual data from the second child of the - * third employee and invoke the "splitText(offset)" method. - * The original Text node should contain all the content - * up to the offset point. The "getNodeValue()" method - * is called to check that the original node now contains - * the first five characters. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D -*/ -public final class hc_textsplittexttwo extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_textsplittexttwo(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - Text textNode; - Text splitNode; - String value; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("strong"); - nameNode = elementList.item(2); - textNode = (Text) nameNode.getFirstChild(); - splitNode = textNode.splitText(5); - value = textNode.getNodeValue(); - assertEquals("textSplitTextTwoAssert", "Roger", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_textsplittexttwo"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_textsplittexttwo.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textwithnomarkup.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textwithnomarkup.java deleted file mode 100644 index 8ff96c2dc..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/hc_textwithnomarkup.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If there is not any markup inside an Element or Attr node - * content, then the text is contained in a single object - * implementing the Text interface that is the only child - * of the element. - * - * Retrieve the textual data from the second child of the - * third employee. That Text node contains a block of - * multiple text lines without markup, so they should be - * treated as a single Text node. The "getNodeValue()" - * method should contain the combination of the two lines. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1312295772 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -*/ -public final class hc_textwithnomarkup extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_textwithnomarkup(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - Node nodeV; - String value; - doc = (Document) load("hc_staff", false); - elementList = doc.getElementsByTagName("strong"); - nameNode = elementList.item(2); - nodeV = nameNode.getFirstChild(); - value = nodeV.getNodeValue(); - assertEquals("textWithNoMarkupAssert", "Roger\n Jones", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_textwithnomarkup"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_textwithnomarkup.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapchildnoderange.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapchildnoderange.java deleted file mode 100644 index 007ee0a07..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapchildnoderange.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The range of valid child node indices is 0 to Length -1. - * - * Create a NamedNodeMap object from the attributes of the - * last child of the third employee and traverse the - * list from index 0 thru length -1. All indices should - * be valid. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D0FB19E -*/ -public final class namednodemapchildnoderange extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapchildnoderange(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - NamedNodeMap attributes; - Node child; - int length; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testEmployee = elementList.item(2); - attributes = testEmployee.getAttributes(); - length = (int) attributes.getLength(); - assertEquals("length", 2, length); - child = attributes.item(0); - child = attributes.item(1); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapchildnoderange"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapchildnoderange.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapgetnameditem.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapgetnameditem.java deleted file mode 100644 index fea069132..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapgetnameditem.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNamedItem(name)" method retrieves a node - * specified by name. - * - * Retrieve the second employee and create a NamedNodeMap - * listing of the attributes of the last child. Once the - * list is created an invocation of the "getNamedItem(name)" - * method is done with name="domestic". This should result - * in the domestic Attr node being returned. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -*/ -public final class namednodemapgetnameditem extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapgetnameditem(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - NamedNodeMap attributes; - Attr domesticAttr; - String attrName; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - testEmployee = elementList.item(1); - attributes = testEmployee.getAttributes(); - domesticAttr = (Attr) attributes.getNamedItem("domestic"); - attrName = domesticAttr.getNodeName(); - assertEquals("namednodemapGetNamedItemAssert", "domestic", attrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapgetnameditem"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapgetnameditem.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapinuseattributeerr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapinuseattributeerr.java deleted file mode 100644 index ebe7a2ee1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapinuseattributeerr.java +++ /dev/null @@ -1,110 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setNamedItem(arg)" method raises a - * INUSE_ATTRIBUTE_ERR DOMException if "arg" is an - * Attr that is already in an attribute of another Element. - * Create a NamedNodeMap object from the attributes of the - * last child of the third employee and attempt to add - * an attribute that is already being used by the first - * employee. This should raise the desired exception. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1025163788')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class namednodemapinuseattributeerr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapinuseattributeerr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element firstNode; - Node testNode; - NamedNodeMap attributes; - Attr domesticAttr; - Attr setAttr; - Node setNode; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - firstNode = (Element) elementList.item(0); - domesticAttr = doc.createAttribute("domestic"); - domesticAttr.setValue("Yes"); - setAttr = firstNode.setAttributeNode(domesticAttr); - elementList = doc.getElementsByTagName("address"); - testNode = elementList.item(2); - attributes = testNode.getAttributes(); - - { - boolean success = false; - try { - setNode = attributes.setNamedItem(domesticAttr); - } catch (DOMException ex) { - success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR); - } - assertTrue("throw_INUSE_ATTRIBUTE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapinuseattributeerr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapinuseattributeerr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapnotfounderr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapnotfounderr.java deleted file mode 100644 index bfd93f4bd..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapnotfounderr.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeNamedItem(name)" method raises a - * NOT_FOUND_ERR DOMException if there is not a node - * named "name" in the map. - * - * Create a NamedNodeMap object from the attributes of the - * last child of the third employee and attempt to remove - * the "district" attribute. There is not a node named - * "district" in the list and therefore the desired - * exception should be raised. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-D58B193')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR']) -*/ -public final class namednodemapnotfounderr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapnotfounderr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testEmployee; - NamedNodeMap attributes; - Node removedNode; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testEmployee = (Element) elementList.item(2); - attributes = testEmployee.getAttributes(); - - { - boolean success = false; - try { - removedNode = attributes.removeNamedItem("district"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_FOUND_ERR); - } - assertTrue("throw_NOT_FOUND_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapnotfounderr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapnotfounderr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapnumberofnodes.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapnumberofnodes.java deleted file mode 100644 index 2209735ef..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapnumberofnodes.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getLength()" method returns the number of nodes - * in the map. - * - * Retrieve the second employee and create a NamedNodeMap - * listing of the attributes of the last child. Once the - * list is created an invocation of the "getLength()" - * method is executed. The number of nodes should be 2. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D0FB19E -*/ -public final class namednodemapnumberofnodes extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapnumberofnodes(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - NamedNodeMap attributes; - int length; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testEmployee = elementList.item(2); - attributes = testEmployee.getAttributes(); - length = (int) attributes.getLength(); - assertEquals("length", 2, length); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapnumberofnodes"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapnumberofnodes.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapremovenameditem.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapremovenameditem.java deleted file mode 100644 index 667c7f866..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapremovenameditem.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeNamedItem(name)" method removes a node - * specified by name. - * - * Retrieve the third employee and create a NamedNodeMap - * object of the attributes of the last child. Once the - * list is created invoke the "removeNamedItem(name)" - * method with name="street". This should result - * in the removal of the specified attribute and - * the "getSpecified()" method should return false. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html -*/ -public final class namednodemapremovenameditem extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapremovenameditem(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testAddress; - NamedNodeMap attributes; - Attr streetAttr; - boolean specified; - Node removedNode; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testAddress = elementList.item(2); - attributes = testAddress.getAttributes(); - assertNotNull("attributesNotNull", attributes); - removedNode = attributes.removeNamedItem("street"); - streetAttr = (Attr) attributes.getNamedItem("street"); - assertNotNull("streetAttrNotNull", streetAttr); - specified = streetAttr.getSpecified(); - assertFalse("attrNotSpecified", specified); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapremovenameditem"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapremovenameditem.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapremovenameditemgetvalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapremovenameditemgetvalue.java deleted file mode 100644 index bd431bb03..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapremovenameditemgetvalue.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the node removed by the "removeNamedItem(name)" method - * is an Attr node with a default value it is immediately - * replaced. - * - * Retrieve the third employee and create a NamedNodeMap - * object of the attributes of the last child. Once the - * list is created invoke the "removeNamedItem(name)" - * method with name="street". The "removeNamedItem(name)" - * method should remove the "street" attribute and since - * it has a default value of "Yes", that value should - * immediately be the attributes value. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html -*/ -public final class namednodemapremovenameditemgetvalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapremovenameditemgetvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - NamedNodeMap attributes; - Attr streetAttr; - String value; - Node removedNode; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testEmployee = elementList.item(2); - attributes = testEmployee.getAttributes(); - assertNotNull("attributesNotNull", attributes); - removedNode = attributes.removeNamedItem("street"); - streetAttr = (Attr) attributes.getNamedItem("street"); - assertNotNull("streetAttrNotNull", streetAttr); - value = streetAttr.getValue(); - assertEquals("namednodemapRemoveNamedItemGetValueAssert", "Yes", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapremovenameditemgetvalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapremovenameditemgetvalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapremovenameditemreturnnodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapremovenameditemreturnnodevalue.java deleted file mode 100644 index e05713202..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapremovenameditemreturnnodevalue.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeNamedItem(name)" method returns the node - * removed from the map. - * - * Retrieve the third employee and create a NamedNodeMap - * object of the attributes of the last child. Once the - * list is created invoke the "removeNamedItem(name)" - * method with name="street". The "removeNamedItem(name)" - * method should remove the existing "street" attribute - * and return it. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -*/ -public final class namednodemapremovenameditemreturnnodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapremovenameditemreturnnodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testAddress; - NamedNodeMap attributes; - Node removedNode; - String value; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testAddress = elementList.item(2); - attributes = testAddress.getAttributes(); - removedNode = attributes.removeNamedItem("street"); - value = removedNode.getNodeValue(); - assertEquals("namednodemapRemoveNamedItemReturnNodeValueAssert", "No", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapremovenameditemreturnnodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapremovenameditemreturnnodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapreturnattrnode.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapreturnattrnode.java deleted file mode 100644 index 92d7a409d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapreturnattrnode.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNamedItem(name)" method returns a node of any - * type specified by name. - * - * Retrieve the second employee and create a NamedNodeMap - * listing of the attributes of the last child. Once the - * list is created an invocation of the "getNamedItem(name)" - * method is done with name="street". This should result - * in the method returning an Attr node. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1112119403 -*/ -public final class namednodemapreturnattrnode extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapreturnattrnode(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - NamedNodeMap attributes; - Node streetAttr; - String attrName; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - testEmployee = elementList.item(1); - attributes = testEmployee.getAttributes(); - streetAttr = attributes.getNamedItem("street"); - assertInstanceOf("typeAssert", Attr.class, streetAttr); -attrName = streetAttr.getNodeName(); - assertEquals("nodeName", "street", attrName); - attrName = ((Attr) /*Node */streetAttr).getName(); - assertEquals("attrName", "street", attrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapreturnattrnode"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapreturnattrnode.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapreturnfirstitem.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapreturnfirstitem.java deleted file mode 100644 index 90711602f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapreturnfirstitem.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "item(index)" method returns the indexth item in - * the map(test for first item). - * - * Retrieve the second employee and create a NamedNodeMap - * listing of the attributes of the last child. Since the - * DOM does not specify an order of these nodes the contents - * of the FIRST node can contain either "domestic" or "street". - * The test should return "true" if the FIRST node is either - * of these values. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -*/ -public final class namednodemapreturnfirstitem extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapreturnfirstitem(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testAddress; - NamedNodeMap attributes; - Node child; - String name; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testAddress = elementList.item(1); - attributes = testAddress.getAttributes(); - child = attributes.item(0); - name = child.getNodeName(); - assertTrue("namednodemapReturnFirstItemAssert", - (equals("domestic", name) | equals("street", name)) -); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapreturnfirstitem"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapreturnfirstitem.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapreturnlastitem.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapreturnlastitem.java deleted file mode 100644 index e047363cc..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapreturnlastitem.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "item(index)" method returns the indexth item in - * the map(test for last item). - * - * Retrieve the second employee and create a NamedNodeMap - * listing of the attributes of the last child. Since the - * DOM does not specify an order of these nodes the contents - * of the LAST node can contain either "domestic" or "street". - * The test should return "true" if the LAST node is either - * of these values. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -*/ -public final class namednodemapreturnlastitem extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapreturnlastitem(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - NamedNodeMap attributes; - Node child; - String name; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testEmployee = elementList.item(1); - attributes = testEmployee.getAttributes(); - child = attributes.item(1); - name = child.getNodeName(); - assertTrue("namednodemapReturnLastItemAssert", - (equals("domestic", name) | equals("street", name)) -); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapreturnlastitem"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapreturnlastitem.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapreturnnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapreturnnull.java deleted file mode 100644 index 4537f52f6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapreturnnull.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNamedItem(name)" method returns null of the - * specified name did not identify any node in the map. - * - * Retrieve the second employee and create a NamedNodeMap - * listing of the attributes of the last child. Once the - * list is created an invocation of the "getNamedItem(name)" - * method is done with name="district". This name does not - * match any names in the list therefore the method should - * return null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549 -*/ -public final class namednodemapreturnnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapreturnnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - NamedNodeMap attributes; - Attr districtNode; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - testEmployee = elementList.item(1); - attributes = testEmployee.getAttributes(); - districtNode = (Attr) attributes.getNamedItem("district"); - assertNull("namednodemapReturnNullAssert", districtNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapreturnnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapreturnnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapsetnameditem.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapsetnameditem.java deleted file mode 100644 index bffaf29b6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapsetnameditem.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setNamedItem(arg)" method adds a node using its - * nodeName attribute. - * - * Retrieve the second employee and create a NamedNodeMap - * object from the attributes of the last child by - * invoking the "getAttributes()" method. Once the - * list is created an invocation of the "setNamedItem(arg)" - * method is done with arg=newAttr, where newAttr is a - * new Attr Node previously created. The "setNamedItem(arg)" - * method should add then new node to the NamedNodeItem - * object by using its "nodeName" attribute("district'). - * This node is then retrieved using the "getNamedItem(name)" - * method. This test uses the "createAttribute(name)" - * method from the document interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -*/ -public final class namednodemapsetnameditem extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapsetnameditem(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Attr newAttribute; - Node testAddress; - NamedNodeMap attributes; - Attr districtNode; - String attrName; - Node setNode; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testAddress = elementList.item(1); - newAttribute = doc.createAttribute("district"); - attributes = testAddress.getAttributes(); - setNode = attributes.setNamedItem(newAttribute); - districtNode = (Attr) attributes.getNamedItem("district"); - attrName = districtNode.getNodeName(); - assertEquals("namednodemapSetNamedItemAssert", "district", attrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapsetnameditem"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapsetnameditem.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapsetnameditemreturnvalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapsetnameditemreturnvalue.java deleted file mode 100644 index baa80d39e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapsetnameditemreturnvalue.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the "setNamedItem(arg)" method replaces an already - * existing node with the same name then the already - * existing node is returned. - * - * Retrieve the third employee and create a NamedNodeMap - * object from the attributes of the last child by - * invoking the "getAttributes()" method. Once the - * list is created an invocation of the "setNamedItem(arg)" - * method is done with arg=newAttr, where newAttr is a - * new Attr Node previously created and whose node name - * already exists in the map. The "setNamedItem(arg)" - * method should replace the already existing node with - * the new one and return the existing node. - * This test uses the "createAttribute(name)" method from - * the document interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -*/ -public final class namednodemapsetnameditemreturnvalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapsetnameditemreturnvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Attr newAttribute; - Node testAddress; - NamedNodeMap attributes; - Node newNode; - String attrValue; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testAddress = elementList.item(2); - newAttribute = doc.createAttribute("street"); - attributes = testAddress.getAttributes(); - newNode = attributes.setNamedItem(newAttribute); - attrValue = newNode.getNodeValue(); - assertEquals("returnedNodeValue", "No", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapsetnameditemreturnvalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapsetnameditemreturnvalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapsetnameditemthatexists.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapsetnameditemthatexists.java deleted file mode 100644 index cd88d92bb..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapsetnameditemthatexists.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the node to be added by the "setNamedItem(arg)" method - * already exists in the NamedNodeMap, it is replaced by - * the new one. - * - * Retrieve the second employee and create a NamedNodeMap - * object from the attributes of the last child by - * invoking the "getAttributes()" method. Once the - * list is created an invocation of the "setNamedItem(arg)" - * method is done with arg=newAttr, where newAttr is a - * new Attr Node previously created and whose node name - * already exists in the map. The "setNamedItem(arg)" - * method should replace the already existing node with - * the new one. - * This node is then retrieved using the "getNamedItem(name)" - * method. This test uses the "createAttribute(name)" - * method from the document interface -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -*/ -public final class namednodemapsetnameditemthatexists extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapsetnameditemthatexists(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Attr newAttribute; - Node testAddress; - NamedNodeMap attributes; - Attr districtNode; - String attrValue; - Node setNode; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testAddress = elementList.item(1); - newAttribute = doc.createAttribute("street"); - attributes = testAddress.getAttributes(); - setNode = attributes.setNamedItem(newAttribute); - districtNode = (Attr) attributes.getNamedItem("street"); - attrValue = districtNode.getNodeValue(); - assertEquals("streetValue", "", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapsetnameditemthatexists"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapsetnameditemthatexists.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapsetnameditemwithnewvalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapsetnameditemwithnewvalue.java deleted file mode 100644 index 91d7b2509..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapsetnameditemwithnewvalue.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the "setNamedItem(arg)" method does not replace an - * existing node with the same name then it returns null. - * - * Retrieve the third employee and create a NamedNodeMap - * object from the attributes of the last child. - * Once the list is created the "setNamedItem(arg)" method - * is invoked with arg=newAttr, where newAttr is a - * newly created Attr Node and whose node name - * already exists in the map. The "setNamedItem(arg)" - * method should add the new node and return null. - * This test uses the "createAttribute(name)" method from - * the document interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9 -*/ -public final class namednodemapsetnameditemwithnewvalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapsetnameditemwithnewvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Attr newAttribute; - Node testAddress; - NamedNodeMap attributes; - Node newNode; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - testAddress = elementList.item(2); - newAttribute = doc.createAttribute("district"); - attributes = testAddress.getAttributes(); - newNode = attributes.setNamedItem(newAttribute); - assertNull("returnedNodeNull", newNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapsetnameditemwithnewvalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapsetnameditemwithnewvalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapwrongdocumenterr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapwrongdocumenterr.java deleted file mode 100644 index 81393d47c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/namednodemapwrongdocumenterr.java +++ /dev/null @@ -1,111 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setNamedItem(arg)" method raises a - * WRONG_DOCUMENT_ERR DOMException if "arg" was created - * from a different document than the one that created - * the NamedNodeMap. - * - * Create a NamedNodeMap object from the attributes of the - * last child of the third employee and attempt to add - * another Attr node to it that was created from a - * different DOM document. This should raise the desired - * exception. This method uses the "createAttribute(name)" - * method from the Document interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1025163788')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class namednodemapwrongdocumenterr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapwrongdocumenterr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc1; - Document doc2; - NodeList elementList; - Node testAddress; - NamedNodeMap attributes; - Node newAttribute; - Node setNode; - doc1 = (Document) load("staff", true); - doc2 = (Document) load("staff", true); - elementList = doc1.getElementsByTagName("address"); - testAddress = elementList.item(2); - newAttribute = doc2.createAttribute("newAttribute"); - attributes = testAddress.getAttributes(); - - { - boolean success = false; - try { - setNode = attributes.setNamedItem(newAttribute); - } catch (DOMException ex) { - success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); - } - assertTrue("throw_WRONG_DOCUMENT_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapwrongdocumenterr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapwrongdocumenterr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchild.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchild.java deleted file mode 100644 index 20fe4f95d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchild.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "appendChild(newChild)" method adds the node - * "newChild" to the end of the list of children of the - * node. - * - * Retrieve the second employee and append a new Element - * node to the list of children. The last node in the list - * is then retrieved and its NodeName examined. The - * "getNodeName()" method should return "newChild". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -*/ -public final class nodeappendchild extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeappendchild(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node createdNode; - Node lchild; - String childName; - Node appendedChild; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - createdNode = doc.createElement("newChild"); - appendedChild = employeeNode.appendChild(createdNode); - lchild = employeeNode.getLastChild(); - childName = lchild.getNodeName(); - assertEquals("nodeAppendChildAssert1", "newChild", childName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchild"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeappendchild.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildchildexists.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildchildexists.java deleted file mode 100644 index 674ddac2c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildchildexists.java +++ /dev/null @@ -1,110 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the "newChild" is already in the tree, it is first - * removed before the new one is appended. - * - * Retrieve the first child of the second employee and - * append the first child to the end of the list. After - * the "appendChild(newChild)" method is invoked the first - * child should be the one that was second and the last - * child should be the one that was first. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -*/ -public final class nodeappendchildchildexists extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeappendchildchildexists(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node childNode; - Node newChild; - Node lchild; - Node fchild; - String lchildName; - String fchildName; - Node appendedChild; - String initialName; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - childNode = elementList.item(1); - newChild = childNode.getFirstChild(); - initialName = newChild.getNodeName(); - appendedChild = childNode.appendChild(newChild); - fchild = childNode.getFirstChild(); - fchildName = fchild.getNodeName(); - lchild = childNode.getLastChild(); - lchildName = lchild.getNodeName(); - - if (equals("employeeId", initialName)) { - assertEquals("assert1_nowhitespace", "name", fchildName); - assertEquals("assert2_nowhitespace", "employeeId", lchildName); - } else { - assertEquals("assert1", "employeeId", fchildName); - assertEquals("assert2", "#text", lchildName); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchildchildexists"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeappendchildchildexists.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchilddocfragment.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchilddocfragment.java deleted file mode 100644 index e059ef843..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchilddocfragment.java +++ /dev/null @@ -1,121 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Create and populate a new DocumentFragment object and - * append it to the second employee. After the - * "appendChild(newChild)" method is invoked retrieve the - * new nodes at the end of the list, they should be the - * two Element nodes from the DocumentFragment. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -*/ -public final class nodeappendchilddocfragment extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeappendchilddocfragment(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - DocumentFragment newdocFragment; - Node newChild1; - Node newChild2; - Node child; - String childName; - java.util.List result = new java.util.ArrayList(); - - int nodeType; - Node appendedChild; - java.util.List expected = new java.util.ArrayList(); - expected.add("employeeId"); - expected.add("name"); - expected.add("position"); - expected.add("salary"); - expected.add("gender"); - expected.add("address"); - expected.add("newChild1"); - expected.add("newChild2"); - - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - newdocFragment = doc.createDocumentFragment(); - newChild1 = doc.createElement("newChild1"); - newChild2 = doc.createElement("newChild2"); - appendedChild = newdocFragment.appendChild(newChild1); - appendedChild = newdocFragment.appendChild(newChild2); - appendedChild = employeeNode.appendChild(newdocFragment); - for (int indexN1009F = 0; indexN1009F < childList.getLength(); indexN1009F++) { - child = (Node) childList.item(indexN1009F); - nodeType = (int) child.getNodeType(); - - if (equals(1, nodeType)) { - childName = child.getNodeName(); - result.add(childName); - } - } - assertEquals("elementNames", expected, result); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchilddocfragment"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeappendchilddocfragment.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildgetnodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildgetnodename.java deleted file mode 100644 index c3c16b965..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildgetnodename.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "appendChild(newChild)" method returns the node - * added. - * - * Append a newly created node to the child list of the - * second employee and check the NodeName returned. The - * "getNodeName()" method should return "newChild". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -*/ -public final class nodeappendchildgetnodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeappendchildgetnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node newChild; - Node appendNode; - String childName; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - newChild = doc.createElement("newChild"); - appendNode = employeeNode.appendChild(newChild); - childName = appendNode.getNodeName(); - assertEquals("nodeAppendChildGetNodeNameAssert1", "newChild", childName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchildgetnodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeappendchildgetnodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildinvalidnodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildinvalidnodetype.java deleted file mode 100644 index 65a137feb..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildinvalidnodetype.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "appendChild(newChild)" method raises a - * HIERARCHY_REQUEST_ERR DOMException if this node is of - * a type that does not allow children of the type "newChild" - * to be inserted. - * - * Retrieve the root node and attempt to append a newly - * created Attr node. An Element node cannot have children - * of the "Attr" type, therefore the desired exception - * should be raised. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-184E7107')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class nodeappendchildinvalidnodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeappendchildinvalidnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element rootNode; - Node newChild; - Node appendedChild; - doc = (Document) load("staff", true); - rootNode = doc.getDocumentElement(); - newChild = doc.createAttribute("newAttribute"); - - { - boolean success = false; - try { - appendedChild = rootNode.appendChild(newChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR); - } - assertTrue("throw_HIERARCHY_REQUEST_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchildinvalidnodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeappendchildinvalidnodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildnewchilddiffdocument.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildnewchilddiffdocument.java deleted file mode 100644 index 13a61a596..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildnewchilddiffdocument.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "appendChild(newChild)" method raises a - * WRONG_DOCUMENT_ERR DOMException if the "newChild" was - * created from a different document than the one that - * created this node. - * - * Retrieve the second employee and attempt to append - * a node created from a different document. An attempt - * to make such a replacement should raise the desired - * exception. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-184E7107')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class nodeappendchildnewchilddiffdocument extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeappendchildnewchilddiffdocument(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc1; - Document doc2; - Node newChild; - NodeList elementList; - Node elementNode; - Node appendedChild; - doc1 = (Document) load("staff", false); - doc2 = (Document) load("staff", true); - newChild = doc1.createElement("newChild"); - elementList = doc2.getElementsByTagName("employee"); - elementNode = elementList.item(1); - - { - boolean success = false; - try { - appendedChild = elementNode.appendChild(newChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); - } - assertTrue("throw_WRONG_DOCUMENT_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchildnewchilddiffdocument"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeappendchildnewchilddiffdocument.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildnodeancestor.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildnodeancestor.java deleted file mode 100644 index 40b40e509..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildnodeancestor.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "appendChild(newChild)" method raises a - * HIERARCHY_REQUEST_ERR DOMException if the node to - * append is one of this node's ancestors. - * - * Retrieve the second employee and attempt to append - * an ancestor node(root node) to it. - * An attempt to make such an addition should raise the - * desired exception. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-184E7107')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class nodeappendchildnodeancestor extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeappendchildnodeancestor(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node newChild; - NodeList elementList; - Node employeeNode; - Node appendedChild; - doc = (Document) load("staff", true); - newChild = doc.getDocumentElement(); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - - { - boolean success = false; - try { - appendedChild = employeeNode.appendChild(newChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR); - } - assertTrue("throw_HIERARCHY_REQUEST_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchildnodeancestor"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeappendchildnodeancestor.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildnomodificationallowederr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildnomodificationallowederr.java deleted file mode 100644 index 53bef85ec..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildnomodificationallowederr.java +++ /dev/null @@ -1,116 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "appendChild(newChild)" method causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Get the FIRST item - * from the entity reference and execute the "appendChild(newChild)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-184E7107')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -*/ -public final class nodeappendchildnomodificationallowederr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeappendchildnomodificationallowederr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node genderNode; - Node entRef; - Node entElement; - Node createdNode; - Node appendedNode; - int nodeType; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - genderNode = genderList.item(2); - entRef = genderNode.getFirstChild(); - assertNotNull("entRefNotNull", entRef); - nodeType = (int) entRef.getNodeType(); - - if (equals(1, nodeType)) { - entRef = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entRef); - } - entElement = entRef.getFirstChild(); - assertNotNull("entElementNotNull", entElement); - createdNode = doc.createElement("text3"); - - { - boolean success = false; - try { - appendedNode = entElement.appendChild(createdNode); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchildnomodificationallowederr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeappendchildnomodificationallowederr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildnomodificationallowederrEE.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildnomodificationallowederrEE.java deleted file mode 100644 index 52a0b6dfe..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeappendchildnomodificationallowederrEE.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "appendChild(newChild)" method causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Create an ent4 entity reference and the "appendChild(newChild)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-184E7107')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -* @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchildnomodificationallowederr.xml -*/ -public final class nodeappendchildnomodificationallowederrEE extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeappendchildnomodificationallowederrEE(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node entRef; - Node createdNode; - Node appendedNode; - doc = (Document) load("staff", true); - entRef = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entRef); - createdNode = doc.createElement("text3"); - - { - boolean success = false; - try { - appendedNode = entRef.appendChild(createdNode); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchildnomodificationallowederrEE"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeappendchildnomodificationallowederrEE.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeattributenodeattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeattributenodeattribute.java deleted file mode 100644 index 7b3275545..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeattributenodeattribute.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributes()" method invoked on an Attribute - * Node returns null. - * Retrieve the first attribute from the last child of the - * first employee and invoke the "getAttributes()" method - * on the Attribute Node. It should return null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 -*/ -public final class nodeattributenodeattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeattributenodeattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - NamedNodeMap addrAttr; - Node attrNode; - NamedNodeMap attrList; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - testAddr = (Element) elementList.item(0); - addrAttr = testAddr.getAttributes(); - attrNode = addrAttr.item(0); - attrList = attrNode.getAttributes(); - assertNull("nodeAttributeNodeAttributeAssert1", attrList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeattributenodeattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeattributenodeattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeattributenodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeattributenodename.java deleted file mode 100644 index b41c160dc..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeattributenodename.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeName()" method for an - * Attribute Node is the name of the Attribute. - * - * Retrieve the Attribute named "domestic" from the last - * child of the first employee and check the string returned - * by the "getNodeName()" method. It should be equal to - * "domestic". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -*/ -public final class nodeattributenodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeattributenodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - Attr addrAttr; - String attrName; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - testAddr = (Element) elementList.item(0); - addrAttr = testAddr.getAttributeNode("domestic"); - attrName = addrAttr.getNodeName(); - assertEquals("nodeAttributeNodeNameAssert1", "domestic", attrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeattributenodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeattributenodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeattributenodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeattributenodetype.java deleted file mode 100644 index 4777617a5..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeattributenodetype.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNodeType()" method for an Attribute Node - * returns the constant value 2. - * - * Retrieve the first attribute from the last child of - * the first employee and invoke the "getNodeType()" - * method. The method should return 2. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -*/ -public final class nodeattributenodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeattributenodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - Attr addrAttr; - int nodeType; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - testAddr = (Element) elementList.item(0); - addrAttr = testAddr.getAttributeNode("domestic"); - nodeType = (int) addrAttr.getNodeType(); - assertEquals("nodeAttrNodeTypeAssert1", 2, nodeType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeattributenodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeattributenodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeattributenodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeattributenodevalue.java deleted file mode 100644 index f5afeab70..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeattributenodevalue.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeValue()" method for an - * Attribute Node is the value of the Attribute. - * - * Retrieve the Attribute named "domestic" from the last - * child of the first employee and check the string returned - * by the "getNodeValue()" method. It should be equal to - * "Yes". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -*/ -public final class nodeattributenodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeattributenodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - Attr addrAttr; - String attrValue; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - testAddr = (Element) elementList.item(0); - addrAttr = testAddr.getAttributeNode("domestic"); - attrValue = addrAttr.getNodeValue(); - assertEquals("nodeAttributeNodeValueAssert1", "Yes", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeattributenodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeattributenodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecdatasectionnodeattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecdatasectionnodeattribute.java deleted file mode 100644 index ae47004a2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecdatasectionnodeattribute.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributes()" method invoked on a CDATASection - * Node returns null. - * Retrieve the CDATASection node contained inside the - * second child of the second employee and invoke the - * "getAttributes()" method on the CDATASection node. - * It should return null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-667469212 -*/ -public final class nodecdatasectionnodeattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodecdatasectionnodeattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element cdataName; - Node cdataNode; - NamedNodeMap attrList; - int nodeType; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("name"); - cdataName = (Element) elementList.item(1); - cdataNode = cdataName.getLastChild(); - nodeType = (int) cdataNode.getNodeType(); - - if (!equals(4, nodeType)) { - cdataNode = doc.createCDATASection(""); - } - attrList = cdataNode.getAttributes(); - assertNull("cdataSection", attrList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodecdatasectionnodeattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodecdatasectionnodeattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecdatasectionnodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecdatasectionnodename.java deleted file mode 100644 index 7eda90aea..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecdatasectionnodename.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeName()" method for a - * CDATASection Node is #cdata-section". - * - * Retrieve the CDATASection node inside the second child - * of the second employee and check the string returned - * by the "getNodeName()" method. It should be equal to - * "#cdata-section". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-667469212 -*/ -public final class nodecdatasectionnodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodecdatasectionnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element cdataName; - Node cdataNode; - int nodeType; - String cdataNodeName; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("name"); - cdataName = (Element) elementList.item(1); - cdataNode = cdataName.getLastChild(); - nodeType = (int) cdataNode.getNodeType(); - - if (!equals(4, nodeType)) { - cdataNode = doc.createCDATASection(""); - } - cdataNodeName = cdataNode.getNodeName(); - assertEquals("cdataNodeName", "#cdata-section", cdataNodeName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodecdatasectionnodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodecdatasectionnodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecdatasectionnodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecdatasectionnodetype.java deleted file mode 100644 index 90f950664..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecdatasectionnodetype.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNodeType()" method for a CDATASection Node - * returns the constant value 4. - * - * Retrieve the CDATASection node contained inside the - * second child of the second employee and invoke the - * "getNodeType()" method. The method should return 4. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-667469212 -*/ -public final class nodecdatasectionnodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodecdatasectionnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.notCoalescing - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testName; - Node cdataNode; - int nodeType; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("name"); - testName = (Element) elementList.item(1); - cdataNode = testName.getLastChild(); - nodeType = (int) cdataNode.getNodeType(); - - if (equals(3, nodeType)) { - cdataNode = doc.createCDATASection(""); - nodeType = (int) cdataNode.getNodeType(); - } - assertEquals("nodeTypeCDATA", 4, nodeType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodecdatasectionnodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodecdatasectionnodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecdatasectionnodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecdatasectionnodevalue.java deleted file mode 100644 index 9883b2721..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecdatasectionnodevalue.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeValue()" method for a - * CDATASection Node is the content of the CDATASection. - * - * Retrieve the CDATASection node inside the second child - * of the second employee and check the string returned - * by the "getNodeValue()" method. It should be equal to - * "This is a CDATA Section with EntityReference number 2 - * &ent2;". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-667469212 -*/ -public final class nodecdatasectionnodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodecdatasectionnodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.notCoalescing - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element cdataName; - NodeList childList; - Node child; - String cdataNodeValue; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("name"); - cdataName = (Element) elementList.item(1); - childList = cdataName.getChildNodes(); - child = childList.item(1); - - if ((child == null)) { - child = doc.createCDATASection("This is a CDATASection with EntityReference number 2 &ent2;"); - } - cdataNodeValue = child.getNodeValue(); - assertEquals("value", "This is a CDATASection with EntityReference number 2 &ent2;", cdataNodeValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodecdatasectionnodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodecdatasectionnodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodechildnodes.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodechildnodes.java deleted file mode 100644 index 859d8e658..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodechildnodes.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Collect the element names from Node.childNodes and check against expectations. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987 -*/ -public final class nodechildnodes extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodechildnodes(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childNodes; - Node childNode; - int childType; - String childName; - java.util.List elementNames = new java.util.ArrayList(); - - java.util.List expectedElementNames = new java.util.ArrayList(); - expectedElementNames.add("employeeId"); - expectedElementNames.add("name"); - expectedElementNames.add("position"); - expectedElementNames.add("salary"); - expectedElementNames.add("gender"); - expectedElementNames.add("address"); - - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childNodes = employeeNode.getChildNodes(); - for (int indexN1006C = 0; indexN1006C < childNodes.getLength(); indexN1006C++) { - childNode = (Node) childNodes.item(indexN1006C); - childType = (int) childNode.getNodeType(); - - if (equals(1, childType)) { - childName = childNode.getNodeName(); - elementNames.add(childName); - } - } - assertEquals("elementNames", expectedElementNames, elementNames); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodechildnodes"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodechildnodes.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodechildnodesappendchild.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodechildnodesappendchild.java deleted file mode 100644 index 4fb86c88b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodechildnodesappendchild.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Add an element and check that the previously retrieved childNodes NodeList - * is live. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107 -*/ -public final class nodechildnodesappendchild extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodechildnodesappendchild(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node createdNode; - int expectedLength; - int length; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - expectedLength = (int) childList.getLength(); - expectedLength += 1; - createdNode = doc.createElement("text3"); - employeeNode = employeeNode.appendChild(createdNode); - length = (int) childList.getLength(); - assertEquals("childNodeLength", expectedLength, length); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodechildnodesappendchild"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodechildnodesappendchild.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodechildnodesempty.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodechildnodesempty.java deleted file mode 100644 index 8a26abf9b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodechildnodesempty.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getChildNodes()" method returns a NodeList - * that contains all children of this node. If there - * are not any children, this is a NodeList that does not - * contain any nodes. - * Retrieve the Text node from the second child of the second - * employee and invoke the "getChildNodes()" method. The - * NodeList returned should not have any nodes. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987 -*/ -public final class nodechildnodesempty extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodechildnodesempty(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node secondCNode; - Node textNode; - NodeList childNodesList; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - secondCNode = childList.item(1); - textNode = secondCNode.getFirstChild(); - childNodesList = textNode.getChildNodes(); - assertSize("nodeChildNodesEmptyAssert1", 0, childNodesList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodechildnodesempty"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodechildnodesempty.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecloneattributescopied.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecloneattributescopied.java deleted file mode 100644 index 981403b16..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecloneattributescopied.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the cloneNode method is used to clone an - * Element node, all the attributes of the Element are - * copied along with their values. - * - * Retrieve the last child of the second employee and invoke - * the cloneNode method. The - * duplicate node returned by the method should copy the - * attributes associated with this node. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -*/ -public final class nodecloneattributescopied extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodecloneattributescopied(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node addressNode; - Node clonedNode; - NamedNodeMap attributes; - Node attributeNode; - String attributeName; - java.util.Collection result = new java.util.ArrayList(); - - java.util.Collection expectedResult = new java.util.ArrayList(); - expectedResult.add("domestic"); - expectedResult.add("street"); - - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - addressNode = elementList.item(1); - clonedNode = addressNode.cloneNode(false); - attributes = clonedNode.getAttributes(); - for (int indexN10065 = 0; indexN10065 < attributes.getLength(); indexN10065++) { - attributeNode = (Node) attributes.item(indexN10065); - attributeName = attributeNode.getNodeName(); - result.add(attributeName); - } - assertEquals("nodeCloneAttributesCopiedAssert1", expectedResult, result); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodecloneattributescopied"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodecloneattributescopied.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonefalsenocopytext.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonefalsenocopytext.java deleted file mode 100644 index 858abab43..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonefalsenocopytext.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "cloneNode(deep)" method does not copy text unless it - * is deep cloned.(Test for deep=false) - * - * Retrieve the fourth child of the second employee and - * the "cloneNode(deep)" method with deep=false. The - * duplicate node returned by the method should not copy - * any text data contained in this node. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4 -*/ -public final class nodeclonefalsenocopytext extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeclonefalsenocopytext(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node childNode; - Node clonedNode; - Node lastChildNode; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - childNode = childList.item(3); - clonedNode = childNode.cloneNode(false); - lastChildNode = clonedNode.getLastChild(); - assertNull("noTextNodes", lastChildNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeclonefalsenocopytext"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeclonefalsenocopytext.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonegetparentnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonegetparentnull.java deleted file mode 100644 index 6ad1f8aa8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonegetparentnull.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The duplicate node returned by the "cloneNode(deep)" - * method does not have a ParentNode. - * - * Retrieve the second employee and invoke the - * "cloneNode(deep)" method with deep=false. The - * duplicate node returned should return null when the - * "getParentNode()" is invoked. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4 -*/ -public final class nodeclonegetparentnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeclonegetparentnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - Node clonedNode; - Node parentNode; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - clonedNode = employeeNode.cloneNode(false); - parentNode = clonedNode.getParentNode(); - assertNull("nodeCloneGetParentNullAssert1", parentNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeclonegetparentnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeclonegetparentnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonenodefalse.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonenodefalse.java deleted file mode 100644 index 7be253e38..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonenodefalse.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "cloneNode(deep)" method returns a copy of the node - * only if deep=false. - * - * Retrieve the second employee and invoke the - * "cloneNode(deep)" method with deep=false. The - * method should only clone this node. The NodeName and - * length of the NodeList are checked. The "getNodeName()" - * method should return "employee" and the "getLength()" - * method should return 0. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4 -*/ -public final class nodeclonenodefalse extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeclonenodefalse(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - Node clonedNode; - String cloneName; - NodeList cloneChildren; - int length; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - clonedNode = employeeNode.cloneNode(false); - cloneName = clonedNode.getNodeName(); - assertEquals("name", "employee", cloneName); - cloneChildren = clonedNode.getChildNodes(); - length = (int) cloneChildren.getLength(); - assertEquals("length", 0, length); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeclonenodefalse"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeclonenodefalse.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonenodetrue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonenodetrue.java deleted file mode 100644 index d952d296c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonenodetrue.java +++ /dev/null @@ -1,135 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "cloneNode(deep)" method returns a copy of the node - * and the subtree under it if deep=true. - * - * Retrieve the second employee and invoke the - * "cloneNode(deep)" method with deep=true. The - * method should clone this node and the subtree under it. - * The NodeName of each child in the returned node is - * checked to insure the entire subtree under the second - * employee was cloned. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4 -*/ -public final class nodeclonenodetrue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeclonenodetrue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node clonedNode; - NodeList clonedList; - Node clonedChild; - String clonedChildName; - int length; - java.util.List result = new java.util.ArrayList(); - - java.util.List expectedWhitespace = new java.util.ArrayList(); - expectedWhitespace.add("#text"); - expectedWhitespace.add("employeeId"); - expectedWhitespace.add("#text"); - expectedWhitespace.add("name"); - expectedWhitespace.add("#text"); - expectedWhitespace.add("position"); - expectedWhitespace.add("#text"); - expectedWhitespace.add("salary"); - expectedWhitespace.add("#text"); - expectedWhitespace.add("gender"); - expectedWhitespace.add("#text"); - expectedWhitespace.add("address"); - expectedWhitespace.add("#text"); - - java.util.List expectedNoWhitespace = new java.util.ArrayList(); - expectedNoWhitespace.add("employeeId"); - expectedNoWhitespace.add("name"); - expectedNoWhitespace.add("position"); - expectedNoWhitespace.add("salary"); - expectedNoWhitespace.add("gender"); - expectedNoWhitespace.add("address"); - - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - length = (int) childList.getLength(); - clonedNode = employeeNode.cloneNode(true); - clonedList = clonedNode.getChildNodes(); - for (int indexN100AE = 0; indexN100AE < clonedList.getLength(); indexN100AE++) { - clonedChild = (Node) clonedList.item(indexN100AE); - clonedChildName = clonedChild.getNodeName(); - result.add(clonedChildName); - } - - if (equals(6, length)) { - assertEquals("nowhitespace", expectedNoWhitespace, result); - } else { - assertEquals("whitespace", expectedWhitespace, result); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeclonenodetrue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeclonenodetrue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonetruecopytext.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonetruecopytext.java deleted file mode 100644 index 0676e39ed..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeclonetruecopytext.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the second salary and - * the "cloneNode(deep)" method with deep=true. The - * duplicate node returned by the method should copy - * any text data contained in this node. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4 -*/ -public final class nodeclonetruecopytext extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeclonetruecopytext(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - NodeList childList; - Node childNode; - Node clonedNode; - Node lastChildNode; - String childValue; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("salary"); - childNode = elementList.item(1); - clonedNode = childNode.cloneNode(true); - lastChildNode = clonedNode.getLastChild(); - childValue = lastChildNode.getNodeValue(); - assertEquals("nodeCloneTrueCopyTextAssert1", "35,000", childValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeclonetruecopytext"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeclonetruecopytext.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecommentnodeattributes.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecommentnodeattributes.java deleted file mode 100644 index 7fe33b88d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecommentnodeattributes.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributes()" method invoked on a Comment - * Node returns null. - * Find any comment that is an immediate child of the root - * and assert that Node.attributes is null. Then create - * a new comment node (in case they had been omitted) and - * make the assertion. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=248 -*/ -public final class nodecommentnodeattributes extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodecommentnodeattributes(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList childList; - Node childNode; - NamedNodeMap attrList; - int nodeType; - doc = (Document) load("staff", false); - childList = doc.getChildNodes(); - for (int indexN10043 = 0; indexN10043 < childList.getLength(); indexN10043++) { - childNode = (Node) childList.item(indexN10043); - nodeType = (int) childNode.getNodeType(); - - if (equals(8, nodeType)) { - attrList = childNode.getAttributes(); - assertNull("attributesNull", attrList); - } - } - childNode = doc.createComment("This is a comment"); - attrList = childNode.getAttributes(); - assertNull("createdAttributesNull", attrList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodecommentnodeattributes"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodecommentnodeattributes.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecommentnodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecommentnodename.java deleted file mode 100644 index fd49ac36c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecommentnodename.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeName()" method for a - * Comment Node is "#comment". - * - * Retrieve the Comment node in the XML file - * and check the string returned by the "getNodeName()" - * method. It should be equal to "#comment". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322 -*/ -public final class nodecommentnodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodecommentnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node commentNode; - int nodeType; - String commentNodeName; - doc = (Document) load("staff", false); - elementList = doc.getChildNodes(); - for (int indexN10040 = 0; indexN10040 < elementList.getLength(); indexN10040++) { - commentNode = (Node) elementList.item(indexN10040); - nodeType = (int) commentNode.getNodeType(); - - if (equals(8, nodeType)) { - commentNodeName = commentNode.getNodeName(); - assertEquals("commentNodeName", "#comment", commentNodeName); - } - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodecommentnodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodecommentnodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecommentnodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecommentnodetype.java deleted file mode 100644 index 33d206048..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecommentnodetype.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNodeType()" method for a Comment Node - * returns the constant value 8. - * - * Retrieve the nodes from the document and check for - * a comment node and invoke the "getNodeType()" method. This should - * return 8. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322 -*/ -public final class nodecommentnodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodecommentnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList testList; - Node commentNode; - String commentNodeName; - int nodeType; - doc = (Document) load("staff", false); - testList = doc.getChildNodes(); - for (int indexN10040 = 0; indexN10040 < testList.getLength(); indexN10040++) { - commentNode = (Node) testList.item(indexN10040); - commentNodeName = commentNode.getNodeName(); - - if (equals("#comment", commentNodeName)) { - nodeType = (int) commentNode.getNodeType(); - assertEquals("nodeCommentNodeTypeAssert1", 8, nodeType); - } - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodecommentnodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodecommentnodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecommentnodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecommentnodevalue.java deleted file mode 100644 index b10df5f53..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodecommentnodevalue.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeValue()" method for a - * Comment Node is the content of the comment. - * - * Retrieve the comment in the XML file and - * check the string returned by the "getNodeValue()" method. - * It should be equal to "This is comment number 1". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322 -*/ -public final class nodecommentnodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodecommentnodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node commentNode; - String commentName; - String commentValue; - doc = (Document) load("staff", false); - elementList = doc.getChildNodes(); - for (int indexN10040 = 0; indexN10040 < elementList.getLength(); indexN10040++) { - commentNode = (Node) elementList.item(indexN10040); - commentName = commentNode.getNodeName(); - - if (equals("#comment", commentName)) { - commentValue = commentNode.getNodeValue(); - assertEquals("value", " This is comment number 1.", commentValue); - } - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodecommentnodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodecommentnodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentfragmentnodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentfragmentnodename.java deleted file mode 100644 index a49cebd45..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentfragmentnodename.java +++ /dev/null @@ -1,87 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeName()" method for a - * DocumentFragment Node is "#document-frament". - * Retrieve the DOM document and invoke the - * "createDocumentFragment()" method and check the string - * returned by the "getNodeName()" method. It should be - * equal to "#document-fragment". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3 -*/ -public final class nodedocumentfragmentnodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodedocumentfragmentnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentFragment docFragment; - String documentFragmentName; - doc = (Document) load("staff", true); - docFragment = doc.createDocumentFragment(); - documentFragmentName = docFragment.getNodeName(); - assertEquals("nodeDocumentFragmentNodeNameAssert1", "#document-fragment", documentFragmentName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumentfragmentnodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodedocumentfragmentnodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentfragmentnodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentfragmentnodetype.java deleted file mode 100644 index 13778a700..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentfragmentnodetype.java +++ /dev/null @@ -1,87 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNodeType()" method for a DocumentFragment Node - * returns the constant value 11. - * Invoke the "createDocumentFragment()" method and - * examine the NodeType of the document fragment - * returned by the "getNodeType()" method. The method - * should return 11. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3 -*/ -public final class nodedocumentfragmentnodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodedocumentfragmentnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentFragment documentFragmentNode; - int nodeType; - doc = (Document) load("staff", true); - documentFragmentNode = doc.createDocumentFragment(); - nodeType = (int) documentFragmentNode.getNodeType(); - assertEquals("nodeDocumentFragmentNodeTypeAssert1", 11, nodeType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumentfragmentnodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodedocumentfragmentnodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentfragmentnodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentfragmentnodevalue.java deleted file mode 100644 index 6a3bd3ca8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentfragmentnodevalue.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeValue()" method for a - * DocumentFragment Node is null. - * - * Retrieve the DOM document and invoke the - * "createDocumentFragment()" method and check the string - * returned by the "getNodeValue()" method. It should be - * equal to null. -* @author NIST -* @author Mary Brady -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -*/ -public final class nodedocumentfragmentnodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodedocumentfragmentnodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentFragment docFragment; - NamedNodeMap attrList; - String value; - doc = (Document) load("staff", true); - docFragment = doc.createDocumentFragment(); - attrList = docFragment.getAttributes(); - assertNull("attributesNull", attrList); - value = docFragment.getNodeValue(); - assertNull("initiallyNull", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumentfragmentnodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodedocumentfragmentnodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentnodeattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentnodeattribute.java deleted file mode 100644 index 570d2fbd1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentnodeattribute.java +++ /dev/null @@ -1,81 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributes()" method invoked on a Document - * Node returns null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document -*/ -public final class nodedocumentnodeattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodedocumentnodeattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attrList; - doc = (Document) load("staff", false); - attrList = doc.getAttributes(); - assertNull("documentAttributesNull", attrList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumentnodeattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodedocumentnodeattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentnodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentnodename.java deleted file mode 100644 index e0da8cdf5..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentnodename.java +++ /dev/null @@ -1,84 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeName()" method for a - * Document Node is "#document". - * Retrieve the DOM document and check the string returned - * by the "getNodeName()" method. It should be equal to - * "#document". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -*/ -public final class nodedocumentnodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodedocumentnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - String documentName; - doc = (Document) load("staff", false); - documentName = doc.getNodeName(); - assertEquals("documentNodeName", "#document", documentName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumentnodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodedocumentnodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentnodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentnodetype.java deleted file mode 100644 index bb3d32b6e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentnodetype.java +++ /dev/null @@ -1,83 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNodeType()" method for a Document Node - * returns the constant value 9. - * Retrieve the document and invoke the "getNodeType()" - * method. The method should return 9. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -*/ -public final class nodedocumentnodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodedocumentnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - int nodeType; - doc = (Document) load("staff", false); - nodeType = (int) doc.getNodeType(); - assertEquals("nodeDocumentNodeTypeAssert1", 9, nodeType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumentnodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodedocumentnodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentnodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentnodevalue.java deleted file mode 100644 index 3caa1cbb4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumentnodevalue.java +++ /dev/null @@ -1,84 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeValue()" method for a - * Document Node is null. - * Retrieve the DOM Document and check the string returned - * by the "getNodeValue()" method. It should be equal to - * null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -*/ -public final class nodedocumentnodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodedocumentnodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - String documentValue; - doc = (Document) load("staff", false); - documentValue = doc.getNodeValue(); - assertNull("documentNodeValueNull", documentValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumentnodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodedocumentnodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumenttypenodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumenttypenodename.java deleted file mode 100644 index 7853a5a50..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumenttypenodename.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the DOCTYPE declaration from the XML file and - * check the string returned by the "getNodeName()" - * method. It should be equal to "staff" or "svg". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -*/ -public final class nodedocumenttypenodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodedocumenttypenodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - String documentTypeName; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - documentTypeName = docType.getNodeName(); - - if (("image/svg+xml".equals(getContentType()))) { - assertEquals("doctypeNameSVG", "svg", documentTypeName); - } else { - assertEquals("documentName", "staff", documentTypeName); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumenttypenodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodedocumenttypenodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumenttypenodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumenttypenodetype.java deleted file mode 100644 index d6d90f0a2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumenttypenodetype.java +++ /dev/null @@ -1,83 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNodeType()" method for a DocumentType Node - * returns the constant value 10. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -*/ -public final class nodedocumenttypenodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodedocumenttypenodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType documentTypeNode; - int nodeType; - doc = (Document) load("staff", false); - documentTypeNode = doc.getDoctype(); - assertNotNull("doctypeNotNull", documentTypeNode); - nodeType = (int) documentTypeNode.getNodeType(); - assertEquals("nodeType", 10, nodeType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumenttypenodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodedocumenttypenodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumenttypenodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumenttypenodevalue.java deleted file mode 100644 index 5b013d9c4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodedocumenttypenodevalue.java +++ /dev/null @@ -1,82 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeValue()" method for a - * DocumentType Node is null. -* @author NIST -* @author Mary Brady -*/ -public final class nodedocumenttypenodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodedocumenttypenodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap attrList; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - attrList = docType.getAttributes(); - assertNull("doctypeAttributesNull", attrList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumenttypenodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodedocumenttypenodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeelementnodeattributes.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeelementnodeattributes.java deleted file mode 100644 index c318c9d89..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeelementnodeattributes.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributes()" method invoked on an Element - * Node returns a NamedNodeMap containing the attributes - * of this node. - * - * Retrieve the last child of the third employee and - * invoke the "getAttributes()" method. It should return - * a NamedNodeMap containing the attributes of the Element - * node. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -*/ -public final class nodeelementnodeattributes extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeelementnodeattributes(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - NamedNodeMap addrAttr; - Node attrNode; - String attrName; - java.util.Collection attrList = new java.util.ArrayList(); - - java.util.Collection expected = new java.util.ArrayList(); - expected.add("domestic"); - expected.add("street"); - - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - testAddr = (Element) elementList.item(2); - addrAttr = testAddr.getAttributes(); - for (int indexN1005C = 0; indexN1005C < addrAttr.getLength(); indexN1005C++) { - attrNode = (Node) addrAttr.item(indexN1005C); - attrName = attrNode.getNodeName(); - attrList.add(attrName); - } - assertEquals("nodeElementNodeValueAssert1", expected, attrList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeelementnodeattributes"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeelementnodeattributes.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeelementnodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeelementnodename.java deleted file mode 100644 index 892f1aa4a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeelementnodename.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeName()" method for an - * Element Node is its tagName. - * - * Retrieve the first Element Node(Root Node) of the - * DOM object and check the string returned by the - * "getNodeName()" method. It should be equal to its - * tagName. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251 -*/ -public final class nodeelementnodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeelementnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element elementNode; - String elementName; - doc = (Document) load("staff", false); - elementNode = doc.getDocumentElement(); - elementName = elementNode.getNodeName(); - - if (("image/svg+xml".equals(getContentType()))) { - assertEquals("svgNodeName", "svg", elementName); - } else { - assertEquals("nodeElementNodeNameAssert1", "staff", elementName); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeelementnodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeelementnodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeelementnodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeelementnodetype.java deleted file mode 100644 index 576685913..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeelementnodetype.java +++ /dev/null @@ -1,85 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNodeType()" method for an Element Node - * returns the constant value 1. - * - * Retrieve the root node and invoke the "getNodeType()" - * method. The method should return 1. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -*/ -public final class nodeelementnodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeelementnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element rootNode; - int nodeType; - doc = (Document) load("staff", false); - rootNode = doc.getDocumentElement(); - nodeType = (int) rootNode.getNodeType(); - assertEquals("nodeElementNodeTypeAssert1", 1, nodeType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeelementnodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeelementnodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeelementnodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeelementnodevalue.java deleted file mode 100644 index 6fe3a9dfb..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeelementnodevalue.java +++ /dev/null @@ -1,82 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeValue()" method for an - * Element Node is null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -*/ -public final class nodeelementnodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeelementnodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element elementNode; - String elementValue; - doc = (Document) load("staff", false); - elementNode = doc.getDocumentElement(); - elementValue = elementNode.getNodeValue(); - assertNull("elementNodeValueNull", elementValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeelementnodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeelementnodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitynodeattributes.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitynodeattributes.java deleted file mode 100644 index 2d83fe14d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitynodeattributes.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributes()" method invoked on an Entity - * Node returns null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -*/ -public final class nodeentitynodeattributes extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeentitynodeattributes(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap entities; - Node entityNode; - NamedNodeMap attrList; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - entities = docType.getEntities(); - assertNotNull("entitiesNotNull", entities); - entityNode = entities.getNamedItem("ent1"); - assertNotNull("ent1NotNull", entityNode); - attrList = entityNode.getAttributes(); - assertNull("entityAttributesNull", attrList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeentitynodeattributes"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeentitynodeattributes.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitynodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitynodename.java deleted file mode 100644 index 279b5bdd5..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitynodename.java +++ /dev/null @@ -1,88 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Check the nodeName of the entity returned by DocumentType.entities.getNamedItem("ent1"). -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -*/ -public final class nodeentitynodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeentitynodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap entities; - Node entityNode; - String entityName; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - entities = docType.getEntities(); - assertNotNull("entitiesNotNull", entities); - entityNode = entities.getNamedItem("ent1"); - assertNotNull("entityNodeNotNull", entityNode); - entityName = entityNode.getNodeName(); - assertEquals("entityNodeName", "ent1", entityName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeentitynodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeentitynodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitynodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitynodetype.java deleted file mode 100644 index ad6dc691b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitynodetype.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNodeType()" method for an Entity Node - * returns the constant value 6. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -*/ -public final class nodeentitynodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeentitynodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap entities; - Node entityNode; - int nodeType; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - entities = docType.getEntities(); - assertNotNull("entitiesNotNull", entities); - entityNode = entities.getNamedItem("ent1"); - assertNotNull("ent1NotNull", entityNode); - nodeType = (int) entityNode.getNodeType(); - assertEquals("entityNodeType", 6, nodeType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeentitynodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeentitynodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitynodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitynodevalue.java deleted file mode 100644 index 5432d490a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitynodevalue.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeValue()" method for an - * Entity Node is null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -*/ -public final class nodeentitynodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeentitynodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap entities; - Node entityNode; - String entityValue; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - entities = docType.getEntities(); - assertNotNull("entitiesNotNull", entities); - entityNode = entities.getNamedItem("ent1"); - assertNotNull("ent1NotNull", entityNode); - entityValue = entityNode.getNodeValue(); - assertNull("entityNodeValue", entityValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeentitynodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeentitynodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentityreferencenodeattributes.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentityreferencenodeattributes.java deleted file mode 100644 index 36d8ea330..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentityreferencenodeattributes.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributes()" method invoked on an EntityReference - * Node returns null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -*/ -public final class nodeentityreferencenodeattributes extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeentityreferencenodeattributes(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element entRefAddr; - Node entRefNode; - NamedNodeMap attrList; - int nodeType; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - entRefAddr = (Element) elementList.item(1); - entRefNode = entRefAddr.getFirstChild(); - nodeType = (int) entRefNode.getNodeType(); - - if (!equals(5, nodeType)) { - entRefNode = doc.createEntityReference("ent2"); - assertNotNull("createdEntRefNotNull", entRefNode); - } - attrList = entRefNode.getAttributes(); - assertNull("attrList", attrList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeentityreferencenodeattributes"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeentityreferencenodeattributes.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentityreferencenodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentityreferencenodename.java deleted file mode 100644 index eef2b16c0..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentityreferencenodename.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeName()" method for an - * EntityReference Node is the name of the entity referenced. - * - * Retrieve the first Entity Reference node from the last - * child of the second employee and check the string - * returned by the "getNodeName()" method. It should be - * equal to "ent2". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -*/ -public final class nodeentityreferencenodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeentityreferencenodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element entRefAddr; - Node entRefNode; - String entRefName; - int nodeType; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - entRefAddr = (Element) elementList.item(1); - entRefNode = entRefAddr.getFirstChild(); - nodeType = (int) entRefNode.getNodeType(); - - if (!equals(5, nodeType)) { - entRefNode = doc.createEntityReference("ent2"); - assertNotNull("createdEntRefNotNull", entRefNode); - } - entRefName = entRefNode.getNodeName(); - assertEquals("nodeEntityReferenceNodeNameAssert1", "ent2", entRefName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeentityreferencenodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeentityreferencenodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentityreferencenodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentityreferencenodetype.java deleted file mode 100644 index c426caef0..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentityreferencenodetype.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNodeType()" method for an EntityReference Node - * returns the constant value 5. - * - * Retrieve the EntityReference node from the last child - * of the second employee and invoke the "getNodeType()" - * method. The method should return 5. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -*/ -public final class nodeentityreferencenodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeentityreferencenodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element entRefAddr; - Node entRefNode; - int nodeType; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - entRefAddr = (Element) elementList.item(1); - entRefNode = entRefAddr.getFirstChild(); - nodeType = (int) entRefNode.getNodeType(); - - if (equals(3, nodeType)) { - entRefNode = doc.createEntityReference("ent2"); - assertNotNull("createdEntRefNotNull", entRefNode); - nodeType = (int) entRefNode.getNodeType(); - } - assertEquals("entityNodeType", 5, nodeType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeentityreferencenodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeentityreferencenodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentityreferencenodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentityreferencenodevalue.java deleted file mode 100644 index 631b247af..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentityreferencenodevalue.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeValue()" method for an - * EntityReference Node is null. - * - * Retrieve the first Entity Reference node from the last - * child of the second employee and check the string - * returned by the "getNodeValue()" method. It should be - * equal to null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -*/ -public final class nodeentityreferencenodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeentityreferencenodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element entRefAddr; - Node entRefNode; - String entRefValue; - int nodeType; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - entRefAddr = (Element) elementList.item(1); - entRefNode = entRefAddr.getFirstChild(); - nodeType = (int) entRefNode.getNodeType(); - - if (equals(3, nodeType)) { - entRefNode = doc.createEntityReference("ent2"); - assertNotNull("createdEntRefNotNull", entRefNode); - } - entRefValue = entRefNode.getNodeValue(); - assertNull("entRefNodeValue", entRefValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeentityreferencenodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeentityreferencenodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitysetnodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitysetnodevalue.java deleted file mode 100644 index 2561790e8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeentitysetnodevalue.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeValue()" method for an - * Entity Node is always null and "setNodeValue" should have no effect. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-527DCFF2 -*/ -public final class nodeentitysetnodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeentitysetnodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap entities; - Node entityNode; - String entityValue; - doc = (Document) load("staff", true); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - entities = docType.getEntities(); - assertNotNull("entitiesNotNull", entities); - entityNode = entities.getNamedItem("ent1"); - assertNotNull("ent1NotNull", entityNode); - entityNode.setNodeValue("This should have no effect"); - entityValue = entityNode.getNodeValue(); - assertNull("nodeValueNull", entityValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeentitysetnodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeentitysetnodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetfirstchild.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetfirstchild.java deleted file mode 100644 index 1f5c273ec..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetfirstchild.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getFirstChild()" method returns the first child - * of this node. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-169727388 -*/ -public final class nodegetfirstchild extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodegetfirstchild(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - Node fchildNode; - String childName; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - fchildNode = employeeNode.getFirstChild(); - childName = fchildNode.getNodeName(); - - if (equals("#text", childName)) { - fchildNode = fchildNode.getNextSibling(); - childName = fchildNode.getNodeName(); - } - assertEquals("nodeName", "employeeId", childName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetfirstchild"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodegetfirstchild.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetfirstchildnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetfirstchildnull.java deleted file mode 100644 index 304173559..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetfirstchildnull.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If there is not a first child then the "getFirstChild()" - * method returns null. - * - * Retrieve the Text node form the second child of the first - * employee and invoke the "getFirstChild()" method. It - * should return null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-169727388 -*/ -public final class nodegetfirstchildnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodegetfirstchildnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList employeeList; - Node secondChildNode; - Node textNode; - Node noChildNode; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(0); - employeeList = employeeNode.getChildNodes(); - secondChildNode = employeeList.item(1); - textNode = secondChildNode.getFirstChild(); - noChildNode = textNode.getFirstChild(); - assertNull("nodeGetFirstChildNullAssert1", noChildNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetfirstchildnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodegetfirstchildnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetlastchild.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetlastchild.java deleted file mode 100644 index 5e335fc2a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetlastchild.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getLastChild()" method returns the last child - * of this node. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-61AD09FB -*/ -public final class nodegetlastchild extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodegetlastchild(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - Node lchildNode; - String childName; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - lchildNode = employeeNode.getLastChild(); - childName = lchildNode.getNodeName(); - - if (equals("#text", childName)) { - lchildNode = lchildNode.getPreviousSibling(); - childName = lchildNode.getNodeName(); - } - assertEquals("nodeName", "address", childName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetlastchild"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodegetlastchild.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetlastchildnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetlastchildnull.java deleted file mode 100644 index b64c7c77c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetlastchildnull.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If there is not a last child then the "getLastChild()" - * method returns null. - * - * Retrieve the Text node from the second child of the first - * employee and invoke the "getLastChild()" method. It - * should return null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-61AD09FB -*/ -public final class nodegetlastchildnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodegetlastchildnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList employeeList; - Node secondChildNode; - Node textNode; - Node noChildNode; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(0); - employeeList = employeeNode.getChildNodes(); - secondChildNode = employeeList.item(1); - textNode = secondChildNode.getFirstChild(); - noChildNode = textNode.getLastChild(); - assertNull("nodeGetLastChildNullAssert1", noChildNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetlastchildnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodegetlastchildnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetnextsibling.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetnextsibling.java deleted file mode 100644 index 591721238..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetnextsibling.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNextSibling()" method returns the node immediately - * following this node. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6AC54C2F -*/ -public final class nodegetnextsibling extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodegetnextsibling(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeIdNode; - Node nsNode; - String nsName; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employeeId"); - employeeIdNode = elementList.item(1); - nsNode = employeeIdNode.getNextSibling(); - nsName = nsNode.getNodeName(); - - if (equals("#text", nsName)) { - nsNode = nsNode.getNextSibling(); - nsName = nsNode.getNodeName(); - } - assertEquals("nodeName", "name", nsName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetnextsibling"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodegetnextsibling.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetnextsiblingnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetnextsiblingnull.java deleted file mode 100644 index 5e1bfbd11..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetnextsiblingnull.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If there is not a node immediately following this node the - * "getNextSibling()" method returns null. - * - * Retrieve the first child of the second employee and - * invoke the "getNextSibling()" method. It should - * be set to null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6AC54C2F -*/ -public final class nodegetnextsiblingnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodegetnextsiblingnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - Node lcNode; - Node nsNode; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - lcNode = employeeNode.getLastChild(); - nsNode = lcNode.getNextSibling(); - assertNull("nodeGetNextSiblingNullAssert1", nsNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetnextsiblingnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodegetnextsiblingnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetownerdocument.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetownerdocument.java deleted file mode 100644 index 757edd279..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetownerdocument.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getOwnerDocument()" method returns the Document - * object associated with this node. - * - * Retrieve the second employee and examine Document - * returned by the "getOwnerDocument()" method. Invoke - * the "getDocumentElement()" on the Document which will - * return an Element that is equal to "staff". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#node-ownerDoc -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251 -*/ -public final class nodegetownerdocument extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodegetownerdocument(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node docNode; - Document ownerDocument; - Element docElement; - String elementName; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - docNode = elementList.item(1); - ownerDocument = docNode.getOwnerDocument(); - docElement = ownerDocument.getDocumentElement(); - elementName = docElement.getNodeName(); - - if (("image/svg+xml".equals(getContentType()))) { - assertEquals("svgTagName", "svg", elementName); - } else { - assertEquals("nodeGetOwnerDocumentAssert1", "staff", elementName); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetownerdocument"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodegetownerdocument.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetownerdocumentnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetownerdocumentnull.java deleted file mode 100644 index b85352334..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetownerdocumentnull.java +++ /dev/null @@ -1,80 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getOwnerDocument()" method returns null if the target - * node itself is a document. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#node-ownerDoc -*/ -public final class nodegetownerdocumentnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodegetownerdocumentnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document ownerDocument; - doc = (Document) load("staff", false); - ownerDocument = doc.getOwnerDocument(); - assertNull("documentOwnerDocumentNull", ownerDocument); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetownerdocumentnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodegetownerdocumentnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetprevioussibling.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetprevioussibling.java deleted file mode 100644 index a89639480..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetprevioussibling.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getPreviousSibling()" method returns the node - * immediately preceding this node. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-640FB3C8 -*/ -public final class nodegetprevioussibling extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodegetprevioussibling(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - Node psNode; - String psName; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("name"); - nameNode = elementList.item(1); - psNode = nameNode.getPreviousSibling(); - psName = psNode.getNodeName(); - - if (equals("#text", psName)) { - psNode = psNode.getPreviousSibling(); - psName = psNode.getNodeName(); - } - assertEquals("nodeName", "employeeId", psName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetprevioussibling"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodegetprevioussibling.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetprevioussiblingnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetprevioussiblingnull.java deleted file mode 100644 index 7eba475d9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodegetprevioussiblingnull.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If there is not a node immediately preceding this node the - * "getPreviousSibling()" method returns null. - * - * Retrieve the first child of the second employee and - * invoke the "getPreviousSibling()" method. It should - * be set to null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-640FB3C8 -*/ -public final class nodegetprevioussiblingnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodegetprevioussiblingnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - Node fcNode; - Node psNode; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(2); - fcNode = employeeNode.getFirstChild(); - psNode = fcNode.getPreviousSibling(); - assertNull("nodeGetPreviousSiblingNullAssert1", psNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodegetprevioussiblingnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodegetprevioussiblingnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodehaschildnodes.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodehaschildnodes.java deleted file mode 100644 index e4b1bdb2c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodehaschildnodes.java +++ /dev/null @@ -1,88 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "hasChildNodes()" method returns true if the node - * has children. - * - * Retrieve the root node("staff") and invoke the - * "hasChildNodes()" method. It should return the boolean - * value "true". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-810594187 -*/ -public final class nodehaschildnodes extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodehaschildnodes(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - boolean state; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - state = employeeNode.hasChildNodes(); - assertTrue("nodeHasChildAssert1", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodehaschildnodes"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodehaschildnodes.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodehaschildnodesfalse.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodehaschildnodesfalse.java deleted file mode 100644 index afac51e6c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodehaschildnodesfalse.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "hasChildNodes()" method returns false if the node - * does not have any children. - * - * Retrieve the Text node inside the first child of the - * second employee and invoke the "hasChildNodes()" method. - * It should return the boolean value "false". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-810594187 -*/ -public final class nodehaschildnodesfalse extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodehaschildnodesfalse(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node child; - NodeList employeeIdList; - Node employeeNode; - Node textNode; - boolean state; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - child = elementList.item(1); - employeeIdList = child.getChildNodes(); - employeeNode = employeeIdList.item(1); - textNode = employeeNode.getFirstChild(); - state = textNode.hasChildNodes(); - assertFalse("nodeHasChildFalseAssert1", state); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodehaschildnodesfalse"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodehaschildnodesfalse.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbefore.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbefore.java deleted file mode 100644 index 985d1138d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbefore.java +++ /dev/null @@ -1,140 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertBefore(newChild,refChild)" method inserts the - * node "newChild" before the node "refChild". - * - * Insert a newly created Element node before the eigth - * child of the second employee and check the "newChild" - * and "refChild" after insertion for correct placement. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -*/ -public final class nodeinsertbefore extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeinsertbefore(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node refChild; - Node newChild; - Node child; - String childName; - int length; - Node insertedNode; - java.util.List actual = new java.util.ArrayList(); - - java.util.List expectedWithWhitespace = new java.util.ArrayList(); - expectedWithWhitespace.add("#text"); - expectedWithWhitespace.add("employeeId"); - expectedWithWhitespace.add("#text"); - expectedWithWhitespace.add("name"); - expectedWithWhitespace.add("#text"); - expectedWithWhitespace.add("position"); - expectedWithWhitespace.add("#text"); - expectedWithWhitespace.add("newChild"); - expectedWithWhitespace.add("salary"); - expectedWithWhitespace.add("#text"); - expectedWithWhitespace.add("gender"); - expectedWithWhitespace.add("#text"); - expectedWithWhitespace.add("address"); - expectedWithWhitespace.add("#text"); - - java.util.List expectedWithoutWhitespace = new java.util.ArrayList(); - expectedWithoutWhitespace.add("employeeId"); - expectedWithoutWhitespace.add("name"); - expectedWithoutWhitespace.add("position"); - expectedWithoutWhitespace.add("newChild"); - expectedWithoutWhitespace.add("salary"); - expectedWithoutWhitespace.add("gender"); - expectedWithoutWhitespace.add("address"); - - java.util.List expected = new java.util.ArrayList(); - - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - length = (int) childList.getLength(); - - if (equals(6, length)) { - refChild = childList.item(3); - expected = expectedWithoutWhitespace; - } else { - refChild = childList.item(7); - expected = expectedWithWhitespace; - } - - newChild = doc.createElement("newChild"); - insertedNode = employeeNode.insertBefore(newChild, refChild); - for (int indexN100DC = 0; indexN100DC < childList.getLength(); indexN100DC++) { - child = (Node) childList.item(indexN100DC); - childName = child.getNodeName(); - actual.add(childName); - } - assertEquals("nodeNames", expected, actual); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbefore"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeinsertbefore.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforedocfragment.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforedocfragment.java deleted file mode 100644 index 5f2ee1419..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforedocfragment.java +++ /dev/null @@ -1,112 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the "newChild" is a DocumentFragment object then all - * its children are inserted in the same order before the - * the "refChild". - * - * Create a DocumentFragment object and populate it with - * two Element nodes. Retrieve the second employee and - * insert the newly created DocumentFragment before its - * fourth child. The second employee should now have two - * extra children("newChild1" and "newChild2") at - * positions fourth and fifth respectively. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -*/ -public final class nodeinsertbeforedocfragment extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeinsertbeforedocfragment(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node refChild; - DocumentFragment newdocFragment; - Node newChild1; - Node newChild2; - Node child; - String childName; - Node appendedChild; - Node insertedNode; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - refChild = childList.item(3); - newdocFragment = doc.createDocumentFragment(); - newChild1 = doc.createElement("newChild1"); - newChild2 = doc.createElement("newChild2"); - appendedChild = newdocFragment.appendChild(newChild1); - appendedChild = newdocFragment.appendChild(newChild2); - insertedNode = employeeNode.insertBefore(newdocFragment, refChild); - child = childList.item(3); - childName = child.getNodeName(); - assertEquals("childName3", "newChild1", childName); - child = childList.item(4); - childName = child.getNodeName(); - assertEquals("childName4", "newChild2", childName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbeforedocfragment"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeinsertbeforedocfragment.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforeinvalidnodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforeinvalidnodetype.java deleted file mode 100644 index 2136d7d7e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforeinvalidnodetype.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertBefore(newChild,refChild)" method raises a - * HIERARCHY_REQUEST_ERR DOMException if this node is of - * a type that does not allow children of the type "newChild" - * to be inserted. - * - * Retrieve the root node and attempt to insert a newly - * created Attr node. An Element node cannot have children - * of the "Attr" type, therefore the desired exception - * should be raised. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-952280727')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class nodeinsertbeforeinvalidnodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeinsertbeforeinvalidnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element rootNode; - Node newChild; - NodeList elementList; - Node refChild; - Node insertedNode; - doc = (Document) load("staff", true); - rootNode = doc.getDocumentElement(); - newChild = doc.createAttribute("newAttribute"); - elementList = doc.getElementsByTagName("employee"); - refChild = elementList.item(1); - - { - boolean success = false; - try { - insertedNode = rootNode.insertBefore(newChild, refChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR); - } - assertTrue("throw_HIERARCHY_REQUEST_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbeforeinvalidnodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeinsertbeforeinvalidnodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenewchilddiffdocument.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenewchilddiffdocument.java deleted file mode 100644 index 4a8be1f43..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenewchilddiffdocument.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertBefore(newChild,refChild)" method raises a - * WRONG_DOCUMENT_ERR DOMException if the "newChild" was - * created from a different document than the one that - * created this node. - * - * Retrieve the second employee and attempt to insert a new - * child that was created from a different document than the - * one that created the second employee. An attempt to - * insert such a child should raise the desired exception. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-952280727')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -*/ -public final class nodeinsertbeforenewchilddiffdocument extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeinsertbeforenewchilddiffdocument(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc1; - Document doc2; - Node refChild; - Node newChild; - NodeList elementList; - Node elementNode; - Node insertedNode; - doc1 = (Document) load("staff", false); - doc2 = (Document) load("staff", true); - newChild = doc1.createElement("newChild"); - elementList = doc2.getElementsByTagName("employee"); - elementNode = elementList.item(1); - refChild = elementNode.getFirstChild(); - - { - boolean success = false; - try { - insertedNode = elementNode.insertBefore(newChild, refChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); - } - assertTrue("throw_WRONG_DOCUMENT_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbeforenewchilddiffdocument"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeinsertbeforenewchilddiffdocument.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenewchildexists.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenewchildexists.java deleted file mode 100644 index bdd1c73df..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenewchildexists.java +++ /dev/null @@ -1,142 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the "newChild" is already in the tree, the - * "insertBefore(newChild,refChild)" method must first - * remove it before the insertion takes place. - * - * Insert a node Element ("employeeId") that is already - * present in the tree. The existing node should be - * removed first and the new one inserted. The node is - * inserted at a different position in the tree to assure - * that it was indeed inserted. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -*/ -public final class nodeinsertbeforenewchildexists extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeinsertbeforenewchildexists(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node refChild; - Node newChild; - Node child; - int length; - String childName; - Node insertedNode; - java.util.List expectedWhitespace = new java.util.ArrayList(); - expectedWhitespace.add("#text"); - expectedWhitespace.add("#text"); - expectedWhitespace.add("name"); - expectedWhitespace.add("#text"); - expectedWhitespace.add("position"); - expectedWhitespace.add("#text"); - expectedWhitespace.add("salary"); - expectedWhitespace.add("#text"); - expectedWhitespace.add("gender"); - expectedWhitespace.add("#text"); - expectedWhitespace.add("employeeId"); - expectedWhitespace.add("address"); - expectedWhitespace.add("#text"); - - java.util.List expectedNoWhitespace = new java.util.ArrayList(); - expectedNoWhitespace.add("name"); - expectedNoWhitespace.add("position"); - expectedNoWhitespace.add("salary"); - expectedNoWhitespace.add("gender"); - expectedNoWhitespace.add("employeeId"); - expectedNoWhitespace.add("address"); - - java.util.List expected = new java.util.ArrayList(); - - java.util.List result = new java.util.ArrayList(); - - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - length = (int) childList.getLength(); - - if (equals(6, length)) { - expected = expectedNoWhitespace; - refChild = childList.item(5); - newChild = childList.item(0); - } else { - expected = expectedWhitespace; - refChild = childList.item(11); - newChild = childList.item(1); - } - - insertedNode = employeeNode.insertBefore(newChild, refChild); - for (int indexN100DD = 0; indexN100DD < childList.getLength(); indexN100DD++) { - child = (Node) childList.item(indexN100DD); - childName = child.getNodeName(); - result.add(childName); - } - assertEquals("childNames", expected, result); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbeforenewchildexists"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeinsertbeforenewchildexists.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenodeancestor.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenodeancestor.java deleted file mode 100644 index f02f7fcb2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenodeancestor.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertBefore(newChild,refChild)" method raises a - * HIERARCHY_REQUEST_ERR DOMException if the node to be - * inserted is one of this nodes ancestors. - * - * Retrieve the second employee and attempt to insert a - * node that is one of its ancestors(root node). An - * attempt to insert such a node should raise the - * desired exception. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-952280727')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class nodeinsertbeforenodeancestor extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeinsertbeforenodeancestor(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node newChild; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node refChild; - Node insertedNode; - doc = (Document) load("staff", true); - newChild = doc.getDocumentElement(); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - refChild = childList.item(0); - - { - boolean success = false; - try { - insertedNode = employeeNode.insertBefore(newChild, refChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR); - } - assertTrue("throw_HIERARCHY_REQUEST_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbeforenodeancestor"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeinsertbeforenodeancestor.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenodename.java deleted file mode 100644 index 449405387..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenodename.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertBefore(newChild,refchild)" method returns - * the node being inserted. - * - * Insert an Element node before the fourth - * child of the second employee and check the node - * returned from the "insertBefore(newChild,refChild)" - * method. The node returned should be "newChild". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -*/ -public final class nodeinsertbeforenodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeinsertbeforenodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node refChild; - Node newChild; - Node insertedNode; - String childName; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - refChild = childList.item(3); - newChild = doc.createElement("newChild"); - insertedNode = employeeNode.insertBefore(newChild, refChild); - childName = insertedNode.getNodeName(); - assertEquals("nodeInsertBeforeNodeNameAssert1", "newChild", childName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbeforenodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeinsertbeforenodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenomodificationallowederr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenomodificationallowederr.java deleted file mode 100644 index 6ccb2a019..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenomodificationallowederr.java +++ /dev/null @@ -1,118 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertBefore(newChild,refChild)" method causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Get the FIRST item - * from the entity reference and execute the "insertBefore(newChild,refChild)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-952280727')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -*/ -public final class nodeinsertbeforenomodificationallowederr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeinsertbeforenomodificationallowederr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node genderNode; - Node entRef; - Node entElement; - Node createdNode; - Node insertedNode; - Node refChild = null; - - int nodeType; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - genderNode = genderList.item(2); - entRef = genderNode.getFirstChild(); - assertNotNull("entRefNotNull", entRef); - nodeType = (int) entRef.getNodeType(); - - if (equals(1, nodeType)) { - entRef = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entRef); - } - entElement = entRef.getFirstChild(); - assertNotNull("entElementNotNull", entElement); - createdNode = doc.createElement("text3"); - - { - boolean success = false; - try { - insertedNode = entElement.insertBefore(createdNode, refChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NOT_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbeforenomodificationallowederr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeinsertbeforenomodificationallowederr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenomodificationallowederrEE.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenomodificationallowederrEE.java deleted file mode 100644 index de42fb408..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforenomodificationallowederrEE.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertBefore(newChild,refChild)" method causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Create an ent4 entity reference and and execute the "insertBefore(newChild,refChild)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-952280727')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbeforenomodificationallowederr.xml -*/ -public final class nodeinsertbeforenomodificationallowederrEE extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeinsertbeforenomodificationallowederrEE(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node entRef; - Node createdNode; - Node insertedNode; - Node refChild = null; - - doc = (Document) load("staff", true); - entRef = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entRef); - createdNode = doc.createElement("text3"); - - { - boolean success = false; - try { - insertedNode = entRef.insertBefore(createdNode, refChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbeforenomodificationallowederrEE"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeinsertbeforenomodificationallowederrEE.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforerefchildnonexistent.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforerefchildnonexistent.java deleted file mode 100644 index f58c6fd25..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforerefchildnonexistent.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "insertBefore(newChild,refChild)" method raises a - * NOT_FOUND_ERR DOMException if the reference child is - * not a child of this node. - * - * Retrieve the second employee and attempt to insert a - * new node before a reference node that is not a child - * of this node. An attempt to insert before a non child - * node should raise the desired exception. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-952280727')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class nodeinsertbeforerefchildnonexistent extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeinsertbeforerefchildnonexistent(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node refChild; - Node newChild; - NodeList elementList; - Node elementNode; - Node insertedNode; - doc = (Document) load("staff", true); - newChild = doc.createElement("newChild"); - refChild = doc.createElement("refChild"); - elementList = doc.getElementsByTagName("employee"); - elementNode = elementList.item(1); - - { - boolean success = false; - try { - insertedNode = elementNode.insertBefore(newChild, refChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_FOUND_ERR); - } - assertTrue("throw_NOT_FOUND_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbeforerefchildnonexistent"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeinsertbeforerefchildnonexistent.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforerefchildnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforerefchildnull.java deleted file mode 100644 index c1bd9fbc3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeinsertbeforerefchildnull.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If the "refChild" is null then the - * "insertBefore(newChild,refChild)" method inserts the - * node "newChild" at the end of the list of children. - * - * Retrieve the second employee and invoke the - * "insertBefore(newChild,refChild)" method with - * refChild=null. Since "refChild" is null the "newChild" - * should be added to the end of the list. The last item - * in the list is checked after insertion. The last Element - * node of the list should be "newChild". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727 -*/ -public final class nodeinsertbeforerefchildnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeinsertbeforerefchildnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node refChild = null; - - Node newChild; - Node child; - String childName; - Node insertedNode; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - newChild = doc.createElement("newChild"); - insertedNode = employeeNode.insertBefore(newChild, refChild); - child = employeeNode.getLastChild(); - childName = child.getNodeName(); - assertEquals("nodeInsertBeforeRefChildNullAssert1", "newChild", childName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbeforerefchildnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeinsertbeforerefchildnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistindexequalzero.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistindexequalzero.java deleted file mode 100644 index 67629b789..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistindexequalzero.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Create a list of all the children elements of the third - * employee and access its first child by using an index - * of 0. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136 -*/ -public final class nodelistindexequalzero extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodelistindexequalzero(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList employeeList; - Node child; - String childName; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(2); - employeeList = employeeNode.getChildNodes(); - child = employeeList.item(0); - childName = child.getNodeName(); - - if (!equals("#text", childName)) { - assertEquals("childName", "employeeId", childName); - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodelistindexequalzero"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodelistindexequalzero.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistindexgetlength.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistindexgetlength.java deleted file mode 100644 index c1d140970..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistindexgetlength.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getLength()" method returns the number of nodes - * in the list should be 6 (no whitespace) or 13. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337 -*/ -public final class nodelistindexgetlength extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodelistindexgetlength(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList employeeList; - int length; - int expectedCount = 0; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(2); - employeeList = employeeNode.getChildNodes(); - length = (int) employeeList.getLength(); - assertTrue("lengthIs6or13", - (equals(6, length) | equals(13, length)) -); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodelistindexgetlength"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodelistindexgetlength.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistindexgetlengthofemptylist.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistindexgetlengthofemptylist.java deleted file mode 100644 index 433771f68..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistindexgetlengthofemptylist.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getLength()" method returns the number of nodes - * in the list.(Test for EMPTY list) - * - * Create a list of all the children of the Text node - * inside the first child of the third employee and - * invoke the "getLength()" method. It should contain - * the value 0. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337 -*/ -public final class nodelistindexgetlengthofemptylist extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodelistindexgetlengthofemptylist(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList employeeList; - Node childNode; - Node textNode; - NodeList textList; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(2); - employeeList = employeeNode.getChildNodes(); - childNode = employeeList.item(1); - textNode = childNode.getFirstChild(); - textList = textNode.getChildNodes(); - assertSize("nodelistIndexGetLengthOfEmptyListAssert", 0, textList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodelistindexgetlengthofemptylist"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodelistindexgetlengthofemptylist.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistindexnotzero.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistindexnotzero.java deleted file mode 100644 index 63de8d818..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistindexnotzero.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Create a list of all the children elements of the third - * employee and access its fourth child by using an index - * of 3. This should result in "name" being - * selected. Further we evaluate its content(by using - * the "getNodeName()" method) to ensure the proper - * element was accessed. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136 -*/ -public final class nodelistindexnotzero extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodelistindexnotzero(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList employeeList; - Node child; - int length; - String childName; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(2); - employeeList = employeeNode.getChildNodes(); - length = (int) employeeList.getLength(); - - if (equals(6, length)) { - child = employeeList.item(1); - } else { - child = employeeList.item(3); - } - - childName = child.getNodeName(); - assertEquals("nodeName", "name", childName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodelistindexnotzero"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodelistindexnotzero.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistreturnfirstitem.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistreturnfirstitem.java deleted file mode 100644 index e3215882c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistreturnfirstitem.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Get the first child of the third employee using NodeList.item(0) - * which will either be a Text node (whitespace) or employeeId element. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136 -*/ -public final class nodelistreturnfirstitem extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodelistreturnfirstitem(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList employeeList; - Node child; - String childName; - int length; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(2); - employeeList = employeeNode.getChildNodes(); - child = employeeList.item(0); - childName = child.getNodeName(); - length = (int) employeeList.getLength(); - - if (equals(6, length)) { - assertEqualsIgnoreCase("firstChildNoWhitespace", "employeeId", childName); -} else { - assertEqualsIgnoreCase("firstChildWithWhitespace", "#text", childName); -} - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodelistreturnfirstitem"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodelistreturnfirstitem.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistreturnlastitem.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistreturnlastitem.java deleted file mode 100644 index de97ab0c6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelistreturnlastitem.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Get this last child of the third employee using NodeList.item(NodeList.length - 1) - * and check that it is either a Text element (with whitespace) or an address element. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136 -*/ -public final class nodelistreturnlastitem extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodelistreturnlastitem(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList employeeList; - Node child; - String childName; - int length; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(2); - employeeList = employeeNode.getChildNodes(); - length = (int) employeeList.getLength(); - - if (equals(6, length)) { - child = employeeList.item(5); - childName = child.getNodeName(); - assertEquals("nodeName1", "address", childName); - } else { - child = employeeList.item(12); - childName = child.getNodeName(); - assertEquals("nodeName2", "#text", childName); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodelistreturnlastitem"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodelistreturnlastitem.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelisttraverselist.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelisttraverselist.java deleted file mode 100644 index 85cbc4877..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodelisttraverselist.java +++ /dev/null @@ -1,128 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The range of valid child node indices is 0 thru length -1 - * - * Create a list of all the children elements of the third - * employee and traverse the list from index=0 thru - * length -1. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136 -*/ -public final class nodelisttraverselist extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodelisttraverselist(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList employeeList; - Node child; - String childName; - java.util.List result = new java.util.ArrayList(); - - int length; - java.util.List expectedWhitespace = new java.util.ArrayList(); - expectedWhitespace.add("#text"); - expectedWhitespace.add("employeeId"); - expectedWhitespace.add("#text"); - expectedWhitespace.add("name"); - expectedWhitespace.add("#text"); - expectedWhitespace.add("position"); - expectedWhitespace.add("#text"); - expectedWhitespace.add("salary"); - expectedWhitespace.add("#text"); - expectedWhitespace.add("gender"); - expectedWhitespace.add("#text"); - expectedWhitespace.add("address"); - expectedWhitespace.add("#text"); - - java.util.List expectedNoWhitespace = new java.util.ArrayList(); - expectedNoWhitespace.add("employeeId"); - expectedNoWhitespace.add("name"); - expectedNoWhitespace.add("position"); - expectedNoWhitespace.add("salary"); - expectedNoWhitespace.add("gender"); - expectedNoWhitespace.add("address"); - - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(2); - employeeList = employeeNode.getChildNodes(); - length = (int) employeeList.getLength(); - for (int indexN100A4 = 0; indexN100A4 < employeeList.getLength(); indexN100A4++) { - child = (Node) employeeList.item(indexN100A4); - childName = child.getNodeName(); - result.add(childName); - } - - if (equals(6, length)) { - assertEquals("nowhitespace", expectedNoWhitespace, result); - } else { - assertEquals("whitespace", expectedWhitespace, result); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodelisttraverselist"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodelisttraverselist.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodenotationnodeattributes.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodenotationnodeattributes.java deleted file mode 100644 index 5eaf42c29..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodenotationnodeattributes.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributes()" method invoked on a Notation - * Node returns null. - * Retrieve the Notation declaration inside the DocumentType - * node and invoke the "getAttributes()" method on the - * Notation Node. It should return null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -*/ -public final class nodenotationnodeattributes extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodenotationnodeattributes(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap notations; - Node notationNode; - NamedNodeMap attrList; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - notations = docType.getNotations(); - assertNotNull("notationsNotNull", notations); - notationNode = notations.getNamedItem("notation1"); - assertNotNull("notationNotNull", notationNode); - attrList = notationNode.getAttributes(); - assertNull("nodeNotationNodeAttributesAssert1", attrList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodenotationnodeattributes"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodenotationnodeattributes.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodenotationnodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodenotationnodename.java deleted file mode 100644 index 8b25e31a8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodenotationnodename.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeName()" method for a - * Notation Node is the name of the notation. - * Retrieve the Notation declaration inside the - * DocumentType node and check the string returned - * by the "getNodeName()" method. It should be equal to - * "notation1". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -*/ -public final class nodenotationnodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodenotationnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap notations; - Node notationNode; - String notationName; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - notations = docType.getNotations(); - assertNotNull("notationsNotNull", notations); - notationNode = notations.getNamedItem("notation1"); - assertNotNull("notationNotNull", notationNode); - notationName = notationNode.getNodeName(); - assertEquals("nodeName", "notation1", notationName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodenotationnodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodenotationnodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodenotationnodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodenotationnodetype.java deleted file mode 100644 index 93cbe23fc..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodenotationnodetype.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNodeType()" method for an Notation Node - * returns the constant value 12. - * Retrieve the Notation declaration in the DocumentType - * node and invoke the "getNodeType()" method. The method - * should return 12. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -*/ -public final class nodenotationnodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodenotationnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap notations; - Notation notationNode; - int nodeType; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - notations = docType.getNotations(); - assertNotNull("notationsNotNull", notations); - notationNode = (Notation) notations.getNamedItem("notation1"); - assertNotNull("notationNotNull", notationNode); - nodeType = (int) notationNode.getNodeType(); - assertEquals("nodeNotationNodeTypeAssert1", 12, nodeType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodenotationnodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodenotationnodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodenotationnodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodenotationnodevalue.java deleted file mode 100644 index d29127358..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodenotationnodevalue.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeValue()" method for a - * Notation Node is null. - * Retrieve the Notation declaration inside the - * DocumentType node and check the string returned - * by the "getNodeValue()" method. It should be equal to - * null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -*/ -public final class nodenotationnodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodenotationnodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap notations; - Node notationNode; - String notationValue; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - notations = docType.getNotations(); - assertNotNull("notationsNotNull", notations); - notationNode = notations.getNamedItem("notation1"); - assertNotNull("notationNotNull", notationNode); - notationValue = notationNode.getNodeValue(); - assertNull("nodeValue", notationValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodenotationnodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodenotationnodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeparentnode.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeparentnode.java deleted file mode 100644 index 527c53cd2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeparentnode.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getParentNode()" method returns the parent - * of this node. - * - * Retrieve the second employee and invoke the - * "getParentNode()" method on this node. It should - * be set to "staff". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1060184317 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251 -*/ -public final class nodeparentnode extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeparentnode(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - Node parentNode; - String parentName; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - parentNode = employeeNode.getParentNode(); - parentName = parentNode.getNodeName(); - - if (("image/svg+xml".equals(getContentType()))) { - assertEquals("svgTagName", "svg", parentName); - } else { - assertEquals("nodeParentNodeAssert1", "staff", parentName); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeparentnode"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeparentnode.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeparentnodenull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeparentnodenull.java deleted file mode 100644 index 6c1a9dc81..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeparentnodenull.java +++ /dev/null @@ -1,86 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getParentNode()" method invoked on a node that has - * just been created and not yet added to the tree is null. - * Create a new "employee" Element node using the - * "createElement(name)" method from the Document interface. - * Since this new node has not yet been added to the tree, - * the "getParentNode()" method will return null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1060184317 -*/ -public final class nodeparentnodenull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeparentnodenull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element createdNode; - Node parentNode; - doc = (Document) load("staff", false); - createdNode = doc.createElement("employee"); - parentNode = createdNode.getParentNode(); - assertNull("parentNode", parentNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeparentnodenull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeparentnodenull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionnodeattributes.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionnodeattributes.java deleted file mode 100644 index 5e245473a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionnodeattributes.java +++ /dev/null @@ -1,87 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributes()" method invoked on a Processing - * Instruction Node returns null. - * - * Retrieve the Processing Instruction node and invoke - * the "getAttributes()" method. It should return null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -*/ -public final class nodeprocessinginstructionnodeattributes extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeprocessinginstructionnodeattributes(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList testList; - Node piNode; - NamedNodeMap attrList; - doc = (Document) load("staff", false); - testList = doc.getChildNodes(); - piNode = testList.item(0); - attrList = piNode.getAttributes(); - assertNull("nodeProcessingInstructionNodeAttrAssert1", attrList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeprocessinginstructionnodeattributes"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeprocessinginstructionnodeattributes.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionnodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionnodename.java deleted file mode 100644 index c02f03151..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionnodename.java +++ /dev/null @@ -1,88 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeName()" method for a - * Processing Instruction Node is the target. - * - * Retrieve the Processing Instruction Node in the XML file - * and check the string returned by the "getNodeName()" - * method. It should be equal to "XML-STYLE". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -*/ -public final class nodeprocessinginstructionnodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeprocessinginstructionnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList testList; - Node piNode; - String piName; - doc = (Document) load("staff", false); - testList = doc.getChildNodes(); - piNode = testList.item(0); - piName = piNode.getNodeName(); - assertEquals("nodeProcessingInstructionNodeNameAssert1", "TEST-STYLE", piName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeprocessinginstructionnodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeprocessinginstructionnodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionnodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionnodetype.java deleted file mode 100644 index 8356bdc33..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionnodetype.java +++ /dev/null @@ -1,88 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNodeType()" method for a Processing Instruction - * node returns the constant value 7. - * - * Retrieve a NodeList of child elements from the document. - * Retrieve the first child and invoke the "getNodeType()" - * method. The method should return 7. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -*/ -public final class nodeprocessinginstructionnodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeprocessinginstructionnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList testList; - Node piNode; - int nodeType; - doc = (Document) load("staff", false); - testList = doc.getChildNodes(); - piNode = testList.item(0); - nodeType = (int) piNode.getNodeType(); - assertEquals("nodeProcessingInstructionNodeTypeAssert1", 7, nodeType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeprocessinginstructionnodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeprocessinginstructionnodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionnodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionnodevalue.java deleted file mode 100644 index f484caa61..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionnodevalue.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeValue()" method for a - * Processing Instruction Node is the content of the - * Processing Instruction(exclude the target). - * - * Retrieve the Processing Instruction node in the XML file - * and check the string returned by the "getNodeValue()" - * method. It should be equal to "PIDATA". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -*/ -public final class nodeprocessinginstructionnodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeprocessinginstructionnodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList testList; - Node piNode; - String piValue; - doc = (Document) load("staff", false); - testList = doc.getChildNodes(); - piNode = testList.item(0); - piValue = piNode.getNodeValue(); - assertEquals("value", "PIDATA", piValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeprocessinginstructionnodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeprocessinginstructionnodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionsetnodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionsetnodevalue.java deleted file mode 100644 index e4e8fdd0a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodeprocessinginstructionsetnodevalue.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Setting the nodeValue should change the value returned by - * nodeValue and ProcessingInstruction.getData. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1004215813 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-837822393 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=181 -*/ -public final class nodeprocessinginstructionsetnodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeprocessinginstructionsetnodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList testList; - Node piNode; - String piValue; - doc = (Document) load("staff", true); - testList = doc.getChildNodes(); - piNode = testList.item(0); - piNode.setNodeValue("Something different"); - piValue = piNode.getNodeValue(); - assertEquals("nodeValue", "Something different", piValue); - piValue = ((ProcessingInstruction) /*Node */piNode).getData(); - assertEquals("data", "Something different", piValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeprocessinginstructionsetnodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeprocessinginstructionsetnodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechild.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechild.java deleted file mode 100644 index 517ed7a53..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechild.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeChild(oldChild)" method removes the child node - * indicated by "oldChild" from the list of children and - * returns it. - * - * Remove the first employee by invoking the - * "removeChild(oldChild)" method an checking the - * node returned by the "getParentNode()" method. It - * should be set to null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066 -*/ -public final class noderemovechild extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public noderemovechild(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element rootNode; - NodeList childList; - Node childToRemove; - Node removedChild; - Node parentNode; - doc = (Document) load("staff", true); - rootNode = doc.getDocumentElement(); - childList = rootNode.getChildNodes(); - childToRemove = childList.item(1); - removedChild = rootNode.removeChild(childToRemove); - parentNode = removedChild.getParentNode(); - assertNull("nodeRemoveChildAssert1", parentNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/noderemovechild"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(noderemovechild.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildgetnodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildgetnodename.java deleted file mode 100644 index 3c2e61ca7..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildgetnodename.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Remove the first child of the second employee - * and check the NodeName returned by the - * "removeChild(oldChild)" method. The returned node - * should have a NodeName equal to "#text" or employeeId depending on whitespace. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066 -*/ -public final class noderemovechildgetnodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public noderemovechildgetnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node oldChild; - Node removedChild; - String childName; - int length; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - length = (int) childList.getLength(); - oldChild = childList.item(0); - removedChild = employeeNode.removeChild(oldChild); - childName = removedChild.getNodeName(); - - if (equals(6, length)) { - assertEquals("nowhitespace", "employeeId", childName); - } else { - assertEquals("whitespace", "#text", childName); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/noderemovechildgetnodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(noderemovechildgetnodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildnode.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildnode.java deleted file mode 100644 index ad21ade28..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildnode.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the second employee and remove its first child. - * After the removal, the second employee should have five or twelve - * children and the first child should now be the child - * that used to be at the second position in the list. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066 -*/ -public final class noderemovechildnode extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public noderemovechildnode(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node oldChild; - Node child; - String childName; - int length; - Node removedChild; - String removedName; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - oldChild = childList.item(0); - removedChild = employeeNode.removeChild(oldChild); - removedName = removedChild.getNodeName(); - child = childList.item(0); - childName = child.getNodeName(); - length = (int) childList.getLength(); - - if (equals(5, length)) { - assertEquals("removedNameNoWhitespace", "employeeId", removedName); - assertEquals("childNameNoWhitespace", "name", childName); - } else { - assertEquals("removedName", "#text", removedName); - assertEquals("childName", "employeeId", childName); - assertEquals("length", 12, length); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/noderemovechildnode"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(noderemovechildnode.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildnomodificationallowederr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildnomodificationallowederr.java deleted file mode 100644 index f760c6885..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildnomodificationallowederr.java +++ /dev/null @@ -1,114 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeChild(oldChild)" method causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Get the FIRST item - * from the entity reference and execute the "removeChild(oldChild)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1734834066')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066 -*/ -public final class noderemovechildnomodificationallowederr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public noderemovechildnomodificationallowederr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node genderNode; - Node entRef; - Node entElement; - Node removedNode; - int nodeType; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - genderNode = genderList.item(2); - entRef = genderNode.getFirstChild(); - assertNotNull("entRefNotNull", entRef); - nodeType = (int) entRef.getNodeType(); - - if (equals(1, nodeType)) { - entRef = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entRef); - } - entElement = entRef.getFirstChild(); - assertNotNull("entElementNotNull", entElement); - - { - boolean success = false; - try { - removedNode = entRef.removeChild(entElement); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/noderemovechildnomodificationallowederr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(noderemovechildnomodificationallowederr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildnomodificationallowederrEE.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildnomodificationallowederrEE.java deleted file mode 100644 index 2dbff2276..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildnomodificationallowederrEE.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeChild(oldChild)" method causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Create an entity reference and execute the "removeChild(oldChild)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1734834066')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066 -* @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/noderemovechildnomodificationallowederr.xml -*/ -public final class noderemovechildnomodificationallowederrEE extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public noderemovechildnomodificationallowederrEE(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node entRef; - Node entText; - Node removedNode; - doc = (Document) load("staff", true); - entRef = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entRef); - entText = entRef.getFirstChild(); - assertNotNull("entTextNotNull", entText); - - { - boolean success = false; - try { - removedNode = entRef.removeChild(entText); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/noderemovechildnomodificationallowederrEE"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(noderemovechildnomodificationallowederrEE.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildoldchildnonexistent.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildoldchildnonexistent.java deleted file mode 100644 index 5c634091c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/noderemovechildoldchildnonexistent.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeChild(oldChild)" method raises a - * NOT_FOUND_ERR DOMException if the old child is - * not a child of this node. - * - * Retrieve the second employee and attempt to remove a - * node that is not one of its children. An attempt to - * remove such a node should raise the desired exception. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1734834066')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class noderemovechildoldchildnonexistent extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public noderemovechildoldchildnonexistent(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node oldChild; - NodeList elementList; - Node elementNode; - Node removedChild; - doc = (Document) load("staff", true); - oldChild = doc.createElement("oldChild"); - elementList = doc.getElementsByTagName("employee"); - elementNode = elementList.item(1); - - { - boolean success = false; - try { - removedChild = elementNode.removeChild(oldChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_FOUND_ERR); - } - assertTrue("throw_NOT_FOUND_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/noderemovechildoldchildnonexistent"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(noderemovechildoldchildnonexistent.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechild.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechild.java deleted file mode 100644 index ebe0736db..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechild.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceChild(newChild,oldChild)" method replaces - * the node "oldChild" with the node "newChild". - * - * Replace the first element of the second employee with - * a newly created Element node. Check the first position - * after the replacement operation is completed. The new - * Element should be "newChild". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -*/ -public final class nodereplacechild extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodereplacechild(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node oldChild; - Node newChild; - Node child; - String childName; - Node replacedNode; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - oldChild = childList.item(0); - newChild = doc.createElement("newChild"); - replacedNode = employeeNode.replaceChild(newChild, oldChild); - child = childList.item(0); - childName = child.getNodeName(); - assertEquals("nodeReplaceChildAssert1", "newChild", childName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodereplacechild"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodereplacechild.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildinvalidnodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildinvalidnodetype.java deleted file mode 100644 index f7bc5a9f1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildinvalidnodetype.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceChild(newChild,oldChild)" method raises a - * HIERARCHY_REQUEST_ERR DOMException if this node is of - * a type that does not allow children of the type "newChild" - * to be inserted. - * - * Retrieve the root node and attempt to replace - * one of its children with a newly created Attr node. - * An Element node cannot have children of the "Attr" - * type, therefore the desired exception should be raised. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-785887307')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class nodereplacechildinvalidnodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodereplacechildinvalidnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element rootNode; - Node newChild; - NodeList elementList; - Node oldChild; - Node replacedChild; - doc = (Document) load("staff", true); - rootNode = doc.getDocumentElement(); - newChild = doc.createAttribute("newAttribute"); - elementList = doc.getElementsByTagName("employee"); - oldChild = elementList.item(1); - - { - boolean success = false; - try { - replacedChild = rootNode.replaceChild(newChild, oldChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR); - } - assertTrue("throw_HIERARCHY_REQUEST_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodereplacechildinvalidnodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodereplacechildinvalidnodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnewchilddiffdocument.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnewchilddiffdocument.java deleted file mode 100644 index 97a862af1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnewchilddiffdocument.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceChild(newChild,oldChild)" method raises a - * WRONG_DOCUMENT_ERR DOMException if the "newChild" was - * created from a different document than the one that - * created this node. - * - * Retrieve the second employee and attempt to replace one - * of its children with a node created from a different - * document. An attempt to make such a replacement - * should raise the desired exception. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-785887307')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -*/ -public final class nodereplacechildnewchilddiffdocument extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodereplacechildnewchilddiffdocument(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc1; - Document doc2; - Node oldChild; - Node newChild; - NodeList elementList; - Node elementNode; - Node replacedChild; - doc1 = (Document) load("staff", false); - doc2 = (Document) load("staff", true); - newChild = doc1.createElement("newChild"); - elementList = doc2.getElementsByTagName("employee"); - elementNode = elementList.item(1); - oldChild = elementNode.getFirstChild(); - - { - boolean success = false; - try { - replacedChild = elementNode.replaceChild(newChild, oldChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); - } - assertTrue("throw_WRONG_DOCUMENT_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodereplacechildnewchilddiffdocument"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodereplacechildnewchilddiffdocument.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnewchildexists.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnewchildexists.java deleted file mode 100644 index aab45b57c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnewchildexists.java +++ /dev/null @@ -1,139 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the second employee and replace its TWELFTH - * child(address) with its SECOND child(employeeId). After the - * replacement the second child should now be the one that used - * to be at the third position and the TWELFTH child should be the - * one that used to be at the SECOND position. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -*/ -public final class nodereplacechildnewchildexists extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodereplacechildnewchildexists(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node oldChild = null; - - Node newChild = null; - - String childName; - Node childNode; - int length; - java.util.List actual = new java.util.ArrayList(); - - java.util.List expected = new java.util.ArrayList(); - - java.util.List expectedWithoutWhitespace = new java.util.ArrayList(); - expectedWithoutWhitespace.add("name"); - expectedWithoutWhitespace.add("position"); - expectedWithoutWhitespace.add("salary"); - expectedWithoutWhitespace.add("gender"); - expectedWithoutWhitespace.add("employeeId"); - - java.util.List expectedWithWhitespace = new java.util.ArrayList(); - expectedWithWhitespace.add("#text"); - expectedWithWhitespace.add("#text"); - expectedWithWhitespace.add("name"); - expectedWithWhitespace.add("#text"); - expectedWithWhitespace.add("position"); - expectedWithWhitespace.add("#text"); - expectedWithWhitespace.add("salary"); - expectedWithWhitespace.add("#text"); - expectedWithWhitespace.add("gender"); - expectedWithWhitespace.add("#text"); - expectedWithWhitespace.add("employeeId"); - expectedWithWhitespace.add("#text"); - - Node replacedChild; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - length = (int) childList.getLength(); - - if (equals(13, length)) { - newChild = childList.item(1); - oldChild = childList.item(11); - expected = expectedWithWhitespace; - } else { - newChild = childList.item(0); - oldChild = childList.item(5); - expected = expectedWithoutWhitespace; - } - - replacedChild = employeeNode.replaceChild(newChild, oldChild); - assertSame("return_value_same", oldChild, replacedChild); -for (int indexN100DE = 0; indexN100DE < childList.getLength(); indexN100DE++) { - childNode = (Node) childList.item(indexN100DE); - childName = childNode.getNodeName(); - actual.add(childName); - } - assertEquals("childNames", expected, actual); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodereplacechildnewchildexists"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodereplacechildnewchildexists.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnodeancestor.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnodeancestor.java deleted file mode 100644 index 03b620ea2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnodeancestor.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceChild(newChild,oldChild)" method raises a - * HIERARCHY_REQUEST_ERR DOMException if the node to put - * in is one of this node's ancestors. - * - * Retrieve the second employee and attempt to replace - * one of its children with an ancestor node(root node). - * An attempt to make such a replacement should raise the - * desired exception. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-785887307')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class nodereplacechildnodeancestor extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodereplacechildnodeancestor(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node newChild; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node oldChild; - Node replacedNode; - doc = (Document) load("staff", true); - newChild = doc.getDocumentElement(); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - oldChild = childList.item(0); - - { - boolean success = false; - try { - replacedNode = employeeNode.replaceChild(newChild, oldChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR); - } - assertTrue("throw_HIERARCHY_REQUEST_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodereplacechildnodeancestor"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodereplacechildnodeancestor.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnodename.java deleted file mode 100644 index 7f2990732..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnodename.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Replace the second Element of the second employee with - * a newly created node Element and check the NodeName - * returned by the "replaceChild(newChild,oldChild)" - * method. The returned node should have a NodeName equal - * to "employeeId". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -*/ -public final class nodereplacechildnodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodereplacechildnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - NodeList childList; - Node oldChild; - Node newChild; - Node replacedNode; - int length; - String childName; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - childList = employeeNode.getChildNodes(); - length = (int) childList.getLength(); - oldChild = childList.item(1); - newChild = doc.createElement("newChild"); - replacedNode = employeeNode.replaceChild(newChild, oldChild); - childName = replacedNode.getNodeName(); - - if (equals(6, length)) { - assertEquals("nowhitespace", "name", childName); - } else { - assertEquals("whitespace", "employeeId", childName); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodereplacechildnodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodereplacechildnodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnomodificationallowederr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnomodificationallowederr.java deleted file mode 100644 index cb29e1974..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnomodificationallowederr.java +++ /dev/null @@ -1,115 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceChild(newChild,oldChild)" method causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Get the FIRST item - * from the entity reference and execute the "replaceChild(newChild,oldChild)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-785887307')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -*/ -public final class nodereplacechildnomodificationallowederr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodereplacechildnomodificationallowederr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node genderNode; - Node entRef; - Node entElement; - Node createdNode; - Node replacedChild; - int nodeType; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - genderNode = genderList.item(2); - entRef = genderNode.getFirstChild(); - nodeType = (int) entRef.getNodeType(); - - if (equals(1, nodeType)) { - entRef = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entRef); - } - entElement = entRef.getFirstChild(); - createdNode = doc.createElement("newChild"); - - { - boolean success = false; - try { - replacedChild = entRef.replaceChild(createdNode, entElement); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodereplacechildnomodificationallowederr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodereplacechildnomodificationallowederr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnomodificationallowederrEE.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnomodificationallowederrEE.java deleted file mode 100644 index a68fd783c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildnomodificationallowederrEE.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceChild(newChild,oldChild)" method causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Create an entity reference execute the "replaceChild(newChild,oldChild)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-785887307')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodereplacechildnomodificationallowederr.xml -*/ -public final class nodereplacechildnomodificationallowederrEE extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodereplacechildnomodificationallowederrEE(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node entRef; - Node entText; - Node createdNode; - Node replacedChild; - doc = (Document) load("staff", true); - entRef = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entRef); - entText = entRef.getFirstChild(); - createdNode = doc.createElement("newChild"); - - { - boolean success = false; - try { - replacedChild = entRef.replaceChild(createdNode, entText); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodereplacechildnomodificationallowederrEE"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodereplacechildnomodificationallowederrEE.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildoldchildnonexistent.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildoldchildnonexistent.java deleted file mode 100644 index fe19ea993..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodereplacechildoldchildnonexistent.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "replaceChild(newChild,oldChild)" method raises a - * NOT_FOUND_ERR DOMException if the old child is - * not a child of this node. - * - * Retrieve the second employee and attempt to replace a - * node that is not one of its children. An attempt to - * replace such a node should raise the desired exception. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-785887307')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class nodereplacechildoldchildnonexistent extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodereplacechildoldchildnonexistent(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node oldChild; - Node newChild; - NodeList elementList; - Node elementNode; - Node replacedNode; - doc = (Document) load("staff", true); - newChild = doc.createElement("newChild"); - oldChild = doc.createElement("oldChild"); - elementList = doc.getElementsByTagName("employee"); - elementNode = elementList.item(1); - - { - boolean success = false; - try { - replacedNode = elementNode.replaceChild(newChild, oldChild); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_FOUND_ERR); - } - assertTrue("throw_NOT_FOUND_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodereplacechildoldchildnonexistent"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodereplacechildoldchildnonexistent.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodesetnodevaluenomodificationallowederr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodesetnodevaluenomodificationallowederr.java deleted file mode 100644 index 5a08853c0..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodesetnodevaluenomodificationallowederr.java +++ /dev/null @@ -1,117 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setNodeValue(nodeValue)" method causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Get the SECOND item - * from the entity reference and execute the "setNodeValue(nodeValue)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-F68D080')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -*/ -public final class nodesetnodevaluenomodificationallowederr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodesetnodevaluenomodificationallowederr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node genderNode; - EntityReference entRef; - Element entElement; - CharacterData entElementText; - int nodeType; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - genderNode = genderList.item(2); - entRef = (EntityReference) genderNode.getFirstChild(); - assertNotNull("entRefNotNull", entRef); - nodeType = (int) entRef.getNodeType(); - - if (equals(1, nodeType)) { - entRef = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entRef); - } - entElement = (Element) entRef.getFirstChild(); - assertNotNull("entElementNotNull", entElement); - entElementText = (CharacterData) entElement.getFirstChild(); - assertNotNull("entElementTextNotNull", entElementText); - - { - boolean success = false; - try { - entElementText.setNodeValue("newValue"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodesetnodevaluenomodificationallowederr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodesetnodevaluenomodificationallowederr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodesetnodevaluenomodificationallowederrEE.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodesetnodevaluenomodificationallowederrEE.java deleted file mode 100644 index b72da4910..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodesetnodevaluenomodificationallowederrEE.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Create an entity reference and execute the "setNodeValue(nodeValue)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-F68D080')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodesetnodevaluenomodificationallowederr.xml -*/ -public final class nodesetnodevaluenomodificationallowederrEE extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodesetnodevaluenomodificationallowederrEE(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - EntityReference entRef; - CharacterData entText; - doc = (Document) load("staff", true); - entRef = doc.createEntityReference("ent3"); - assertNotNull("createdEntRefNotNull", entRef); - entText = (CharacterData) entRef.getFirstChild(); - assertNotNull("entTextNotNull", entText); - - { - boolean success = false; - try { - entText.setNodeValue("newValue"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodesetnodevaluenomodificationallowederrEE"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodesetnodevaluenomodificationallowederrEE.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodetextnodeattribute.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodetextnodeattribute.java deleted file mode 100644 index 1a4c5ded6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodetextnodeattribute.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributes()" method invoked on a Text - * Node returns null. - * Retrieve the Text node from the last child of the - * first employee and invoke the "getAttributes()" method - * on the Text Node. It should return null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1312295772 -*/ -public final class nodetextnodeattribute extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodetextnodeattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testAddr; - Node textNode; - NamedNodeMap attrList; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - testAddr = elementList.item(0); - textNode = testAddr.getFirstChild(); - attrList = textNode.getAttributes(); - assertNull("nodeTextNodeAttributesAssert1", attrList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodetextnodeattribute"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodetextnodeattribute.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodetextnodename.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodetextnodename.java deleted file mode 100644 index e88f03d2d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodetextnodename.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeName()" method for a - * Text Node is "#text". - * - * Retrieve the Text Node from the last child of the - * first employee and check the string returned - * by the "getNodeName()" method. It should be equal to - * "#text". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -*/ -public final class nodetextnodename extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodetextnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - Node textNode; - String textName; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - testAddr = (Element) elementList.item(0); - textNode = testAddr.getFirstChild(); - textName = textNode.getNodeName(); - assertEquals("nodeTextNodeNameAssert1", "#text", textName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodetextnodename"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodetextnodename.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodetextnodetype.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodetextnodetype.java deleted file mode 100644 index 978d9aed4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodetextnodetype.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNodeType()" method for a Text Node - * returns the constant value 3. - * - * Retrieve the Text node from the last child of - * the first employee and invoke the "getNodeType()" - * method. The method should return 3. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 -*/ -public final class nodetextnodetype extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodetextnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - Node textNode; - int nodeType; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - testAddr = (Element) elementList.item(0); - textNode = testAddr.getFirstChild(); - nodeType = (int) textNode.getNodeType(); - assertEquals("nodeTextNodeTypeAssert1", 3, nodeType); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodetextnodetype"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodetextnodetype.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodetextnodevalue.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodetextnodevalue.java deleted file mode 100644 index 61bcdd8e2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodetextnodevalue.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The string returned by the "getNodeValue()" method for a - * Text Node is the content of the Text node. - * - * Retrieve the Text node from the last child of the first - * employee and check the string returned by the - * "getNodeValue()" method. It should be equal to - * "1230 North Ave. Dallas, Texas 98551". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -*/ -public final class nodetextnodevalue extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodetextnodevalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - Node textNode; - String textValue; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - testAddr = (Element) elementList.item(0); - textNode = testAddr.getFirstChild(); - textValue = textNode.getNodeValue(); - assertEquals("nodeTextNodeValueAssert1", "1230 North Ave. Dallas, Texas 98551", textValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodetextnodevalue"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodetextnodevalue.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue01.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue01.java deleted file mode 100644 index fe4d8b287..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue01.java +++ /dev/null @@ -1,85 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An element is created, setNodeValue is called with a non-null argument, but getNodeValue - * should still return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document -*/ -public final class nodevalue01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodevalue01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element newNode; - String newValue; - doc = (Document) load("staff", true); - newNode = doc.createElement("address"); - newValue = newNode.getNodeValue(); - assertNull("initiallyNull", newValue); - newNode.setNodeValue("This should have no effect"); - newValue = newNode.getNodeValue(); - assertNull("nullAfterAttemptedChange", newValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodevalue01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodevalue01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue02.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue02.java deleted file mode 100644 index c541f6e59..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue02.java +++ /dev/null @@ -1,85 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An comment is created, setNodeValue is called with a non-null argument, but getNodeValue - * should still return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322 -*/ -public final class nodevalue02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodevalue02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node newNode; - String newValue; - doc = (Document) load("staff", true); - newNode = doc.createComment("This is a new Comment node"); - newValue = newNode.getNodeValue(); - assertEquals("initial", "This is a new Comment node", newValue); - newNode.setNodeValue("This should have an effect"); - newValue = newNode.getNodeValue(); - assertEquals("afterChange", "This should have an effect", newValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodevalue02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodevalue02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue03.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue03.java deleted file mode 100644 index b81d0ef52..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue03.java +++ /dev/null @@ -1,86 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An entity reference is created, setNodeValue is called with a non-null argument, but getNodeValue - * should still return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-11C98490 -*/ -public final class nodevalue03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodevalue03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node newNode; - String newValue; - doc = (Document) load("staff", true); - newNode = doc.createEntityReference("ent1"); - assertNotNull("createdEntRefNotNull", newNode); - newValue = newNode.getNodeValue(); - assertNull("initiallyNull", newValue); - newNode.setNodeValue("This should have no effect"); - newValue = newNode.getNodeValue(); - assertNull("nullAfterAttemptedChange", newValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodevalue03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodevalue03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue04.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue04.java deleted file mode 100644 index cc2cacfac..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue04.java +++ /dev/null @@ -1,86 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An document type accessed, setNodeValue is called with a non-null argument, but getNodeValue - * should still return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31 -*/ -public final class nodevalue04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodevalue04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node newNode; - String newValue; - doc = (Document) load("staff", true); - newNode = doc.getDoctype(); - assertNotNull("docTypeNotNull", newNode); - newValue = newNode.getNodeValue(); - assertNull("initiallyNull", newValue); - newNode.setNodeValue("This should have no effect"); - newValue = newNode.getNodeValue(); - assertNull("nullAfterAttemptedChange", newValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodevalue04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodevalue04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue05.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue05.java deleted file mode 100644 index 6594b4c69..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue05.java +++ /dev/null @@ -1,85 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * A document fragment is created, setNodeValue is called with a non-null argument, but getNodeValue - * should still return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3 -*/ -public final class nodevalue05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodevalue05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node newNode; - String newValue; - doc = (Document) load("staff", true); - newNode = doc.createDocumentFragment(); - newValue = newNode.getNodeValue(); - assertNull("initiallyNull", newValue); - newNode.setNodeValue("This should have no effect"); - newValue = newNode.getNodeValue(); - assertNull("nullAfterAttemptedChange", newValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodevalue05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodevalue05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue06.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue06.java deleted file mode 100644 index 824f8f471..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue06.java +++ /dev/null @@ -1,83 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An document is accessed, setNodeValue is called with a non-null argument, but getNodeValue - * should still return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document -*/ -public final class nodevalue06 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodevalue06(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document newNode; - String newValue; - newNode = (Document) load("staff", true); - newValue = newNode.getNodeValue(); - assertNull("initiallyNull", newValue); - newNode.setNodeValue("This should have no effect"); - newValue = newNode.getNodeValue(); - assertNull("nullAfterAttemptedChange", newValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodevalue06"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodevalue06.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue07.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue07.java deleted file mode 100644 index 607bd356f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue07.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An Entity is accessed, setNodeValue is called with a non-null argument, but getNodeValue - * should still return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-527DCFF2 -*/ -public final class nodevalue07 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodevalue07(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node newNode; - String newValue; - NamedNodeMap nodeMap; - DocumentType docType; - doc = (Document) load("staff", true); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - nodeMap = docType.getEntities(); - assertNotNull("entitiesNotNull", nodeMap); - newNode = nodeMap.getNamedItem("ent1"); - assertNotNull("entityNotNull", newNode); - newValue = newNode.getNodeValue(); - assertNull("initiallyNull", newValue); - newNode.setNodeValue("This should have no effect"); - newValue = newNode.getNodeValue(); - assertNull("nullAfterAttemptedChange", newValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodevalue07"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodevalue07.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue08.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue08.java deleted file mode 100644 index fdea9eebf..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue08.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An notation is accessed, setNodeValue is called with a non-null argument, but getNodeValue - * should still return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5431D1B9 -*/ -public final class nodevalue08 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodevalue08(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - Node newNode; - String newValue; - NamedNodeMap nodeMap; - doc = (Document) load("staff", true); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - nodeMap = docType.getNotations(); - assertNotNull("notationsNotNull", nodeMap); - newNode = nodeMap.getNamedItem("notation1"); - assertNotNull("notationNotNull", newNode); - newValue = newNode.getNodeValue(); - assertNull("initiallyNull", newValue); - newNode.setNodeValue("This should have no effect"); - newValue = newNode.getNodeValue(); - assertNull("nullAfterAttemptedChange", newValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodevalue08"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodevalue08.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue09.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue09.java deleted file mode 100644 index 832e7f06f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/nodevalue09.java +++ /dev/null @@ -1,85 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An processing instruction is created, setNodeValue is called with a non-null argument, but getNodeValue - * should still return null. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1004215813 -*/ -public final class nodevalue09 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodevalue09(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node newNode; - String newValue; - doc = (Document) load("staff", true); - newNode = doc.createProcessingInstruction("TARGET", "DATA"); - newValue = newNode.getNodeValue(); - assertEquals("initial", "DATA", newValue); - newNode.setNodeValue("This should have an effect"); - newValue = newNode.getNodeValue(); - assertEquals("after", "This should have an effect", newValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodevalue09"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodevalue09.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetnotationname.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetnotationname.java deleted file mode 100644 index 8bc1128f1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetnotationname.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the notation named "notation1" and access its - * name by invoking the "getNodeName()" method inherited - * from the Node interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5431D1B9 -*/ -public final class notationgetnotationname extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public notationgetnotationname(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap notations; - Notation notationNode; - String notationName; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - notations = docType.getNotations(); - assertNotNull("notationsNotNull", notations); - notationNode = (Notation) notations.getNamedItem("notation1"); - notationName = notationNode.getNodeName(); - assertEquals("notationGetNotationNameAssert", "notation1", notationName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/notationgetnotationname"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(notationgetnotationname.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetpublicid.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetpublicid.java deleted file mode 100644 index be1598d93..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetpublicid.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the notation named "notation1" and access its - * public identifier. The string "notation1File" should be - * returned. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-54F2B4D0 -*/ -public final class notationgetpublicid extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public notationgetpublicid(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap notations; - Notation notationNode; - String publicId; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - notations = docType.getNotations(); - assertNotNull("notationsNotNull", notations); - notationNode = (Notation) notations.getNamedItem("notation1"); - publicId = notationNode.getPublicId(); - assertEquals("publicId", "notation1File", publicId); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/notationgetpublicid"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(notationgetpublicid.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetpublicidnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetpublicidnull.java deleted file mode 100644 index 28bce4588..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetpublicidnull.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getPublicId()" method of a Notation node contains - * the public identifier associated with the notation, if - * one was not specified a null value should be returned. - * - * Retrieve the notation named "notation2" and access its - * public identifier. Since a public identifier was not - * specified for this notation, the "getPublicId()" method - * should return null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-54F2B4D0 -*/ -public final class notationgetpublicidnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public notationgetpublicidnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap notations; - Notation notationNode; - String publicId; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - notations = docType.getNotations(); - assertNotNull("notationsNotNull", notations); - notationNode = (Notation) notations.getNamedItem("notation2"); - publicId = notationNode.getPublicId(); - assertNull("publicId", publicId); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/notationgetpublicidnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(notationgetpublicidnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetsystemid.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetsystemid.java deleted file mode 100644 index dce7fca45..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetsystemid.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getSystemId()" method of a Notation node contains - * the system identifier associated with the notation, if - * one was specified. - * - * Retrieve the notation named "notation2" and access its - * system identifier. The string "notation2File" should be - * returned. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E8AAB1D0 -*/ -public final class notationgetsystemid extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public notationgetsystemid(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap notations; - Notation notationNode; - String systemId; - int index; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - notations = docType.getNotations(); - assertNotNull("notationsNotNull", notations); - notationNode = (Notation) notations.getNamedItem("notation2"); - systemId = notationNode.getSystemId(); - assertURIEquals("uriEquals", null, null, null, "notation2File", null, null, null, null, systemId); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/notationgetsystemid"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(notationgetsystemid.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetsystemidnull.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetsystemidnull.java deleted file mode 100644 index 28663367b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/notationgetsystemidnull.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the notation named "notation1" and access its - * system identifier. Since a system identifier was not - * specified for this notation, the "getSystemId()" method - * should return null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E8AAB1D0 -*/ -public final class notationgetsystemidnull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public notationgetsystemidnull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap notations; - Notation notationNode; - String systemId; - doc = (Document) load("staff", false); - docType = doc.getDoctype(); - assertNotNull("docTypeNotNull", docType); - notations = docType.getNotations(); - assertNotNull("notationsNotNull", notations); - notationNode = (Notation) notations.getNamedItem("notation1"); - systemId = notationNode.getSystemId(); - assertNull("systemId", systemId); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/notationgetsystemidnull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(notationgetsystemidnull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/processinginstructiongetdata.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/processinginstructiongetdata.java deleted file mode 100644 index 80002e7f3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/processinginstructiongetdata.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getData()" method returns the content of the - * processing instruction. It starts at the first non - * white character following the target and ends at the - * character immediately preceding the "?>". - * - * Retrieve the ProcessingInstruction node located - * immediately after the prolog. Create a nodelist of the - * child nodes of this document. Invoke the "getData()" - * method on the first child in the list. This should - * return the content of the ProcessingInstruction. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-837822393 -*/ -public final class processinginstructiongetdata extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public processinginstructiongetdata(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList childNodes; - ProcessingInstruction piNode; - String data; - doc = (Document) load("staff", false); - childNodes = doc.getChildNodes(); - piNode = (ProcessingInstruction) childNodes.item(0); - data = piNode.getData(); - assertEquals("processinginstructionGetTargetAssert", "PIDATA", data); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/processinginstructiongetdata"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(processinginstructiongetdata.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/processinginstructiongettarget.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/processinginstructiongettarget.java deleted file mode 100644 index 3bb01a9a6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/processinginstructiongettarget.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getTarget()" method returns the target of the - * processing instruction. It is the first token following - * the markup that begins the processing instruction. - * - * Retrieve the ProcessingInstruction node located - * immediately after the prolog. Create a nodelist of the - * child nodes of this document. Invoke the "getTarget()" - * method on the first child in the list. This should - * return the target of the ProcessingInstruction. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1478689192 -*/ -public final class processinginstructiongettarget extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public processinginstructiongettarget(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList childNodes; - ProcessingInstruction piNode; - String target; - doc = (Document) load("staff", false); - childNodes = doc.getChildNodes(); - piNode = (ProcessingInstruction) childNodes.item(0); - target = piNode.getTarget(); - assertEquals("processinginstructionGetTargetAssert", "TEST-STYLE", target); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/processinginstructiongettarget"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(processinginstructiongettarget.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/processinginstructionsetdatanomodificationallowederr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/processinginstructionsetdatanomodificationallowederr.java deleted file mode 100644 index edbe9d512..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/processinginstructionsetdatanomodificationallowederr.java +++ /dev/null @@ -1,112 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setData(data)" method for a processing instruction causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Try to remove the "domestic" attribute - * from the entity reference by executing the "setData(data)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-837822393 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-837822393')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-837822393 -*/ -public final class processinginstructionsetdatanomodificationallowederr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public processinginstructionsetdatanomodificationallowederr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.notExpandEntityReferences - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node gender; - Node entRef; - ProcessingInstruction piNode; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - gender = genderList.item(2); - entRef = gender.getFirstChild(); - assertNotNull("entRefNotNull", entRef); - piNode = (ProcessingInstruction) entRef.getLastChild(); - assertNotNull("piNodeNotNull", piNode); - - { - boolean success = false; - try { - piNode.setData("newData"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/processinginstructionsetdatanomodificationallowederr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(processinginstructionsetdatanomodificationallowederr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/processinginstructionsetdatanomodificationallowederrEE.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/processinginstructionsetdatanomodificationallowederrEE.java deleted file mode 100644 index 1856181f4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/processinginstructionsetdatanomodificationallowederrEE.java +++ /dev/null @@ -1,110 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setData(data)" method for a processing instruction causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Create an ent4 entity reference and add to document of the THIRD "gender" element. The elements - * content is an entity reference. Try to remove the "domestic" attribute - * from the entity reference by executing the "setData(data)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-837822393 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-837822393')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-837822393 -* @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Apr/0053.html -* @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/processinginstructionsetdatanomodificationallowederr.xml -*/ -public final class processinginstructionsetdatanomodificationallowederrEE extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public processinginstructionsetdatanomodificationallowederrEE(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node gender; - Node entRef; - ProcessingInstruction piNode; - Node appendedChild; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - gender = genderList.item(2); - entRef = doc.createEntityReference("ent4"); - appendedChild = gender.appendChild(entRef); - entRef = gender.getLastChild(); - assertNotNull("entRefNotNull", entRef); - piNode = (ProcessingInstruction) entRef.getLastChild(); - assertNotNull("piNodeNotNull", piNode); - - { - boolean success = false; - try { - piNode.setData("newData"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/processinginstructionsetdatanomodificationallowederrEE"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(processinginstructionsetdatanomodificationallowederrEE.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textindexsizeerrnegativeoffset.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/textindexsizeerrnegativeoffset.java deleted file mode 100644 index 4a870a83c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textindexsizeerrnegativeoffset.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "splitText(offset)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset is - * negative. - * - * Retrieve the textual data from the second child of the - * third employee and invoke the "splitText(offset)" method. - * The desired exception should be raised since the offset - * is a negative number. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-38853C1D')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -*/ -public final class textindexsizeerrnegativeoffset extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public textindexsizeerrnegativeoffset(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.signed - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - Text textNode; - Text splitNode; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("name"); - nameNode = elementList.item(2); - textNode = (Text) nameNode.getFirstChild(); - - { - boolean success = false; - try { - splitNode = textNode.splitText(-69); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throws_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/textindexsizeerrnegativeoffset"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(textindexsizeerrnegativeoffset.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textindexsizeerroffsetoutofbounds.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/textindexsizeerroffsetoutofbounds.java deleted file mode 100644 index b91a537d5..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textindexsizeerroffsetoutofbounds.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "splitText(offset)" method raises an - * INDEX_SIZE_ERR DOMException if the specified offset is - * greater than the number of characters in the Text node. - * - * Retrieve the textual data from the second child of the - * third employee and invoke the "splitText(offset)" method. - * The desired exception should be raised since the offset - * is a greater than the number of characters in the Text - * node. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-38853C1D')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 -*/ -public final class textindexsizeerroffsetoutofbounds extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public textindexsizeerroffsetoutofbounds(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - Text textNode; - Text splitNode; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("name"); - nameNode = elementList.item(2); - textNode = (Text) nameNode.getFirstChild(); - - { - boolean success = false; - try { - splitNode = textNode.splitText(300); - } catch (DOMException ex) { - success = (ex.code == DOMException.INDEX_SIZE_ERR); - } - assertTrue("throw_INDEX_SIZE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/textindexsizeerroffsetoutofbounds"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(textindexsizeerroffsetoutofbounds.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textparseintolistofelements.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/textparseintolistofelements.java deleted file mode 100644 index 07b78386c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textparseintolistofelements.java +++ /dev/null @@ -1,126 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retrieve the textual data from the last child of the - * second employee. That node is composed of two - * EntityReference nodes and two Text nodes. After - * the content node is parsed, the "address" Element - * should contain four children with each one of the - * EntityReferences containing one child. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-11C98490 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-745549614 -*/ -public final class textparseintolistofelements extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public textparseintolistofelements(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node addressNode; - NodeList childList; - Node child; - int length; - String value; - Node grandChild; - java.util.List result = new java.util.ArrayList(); - - java.util.List expectedNormal = new java.util.ArrayList(); - expectedNormal.add("1900 Dallas Road"); - expectedNormal.add(" Dallas, "); - expectedNormal.add("Texas"); - expectedNormal.add("\n 98554"); - - java.util.List expectedExpanded = new java.util.ArrayList(); - expectedExpanded.add("1900 Dallas Road Dallas, Texas\n 98554"); - - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - addressNode = elementList.item(1); - childList = addressNode.getChildNodes(); - length = (int) childList.getLength(); - for (int indexN1007F = 0; indexN1007F < childList.getLength(); indexN1007F++) { - child = (Node) childList.item(indexN1007F); - value = child.getNodeValue(); - - if ((value == null)) { - grandChild = child.getFirstChild(); - assertNotNull("grandChildNotNull", grandChild); - value = grandChild.getNodeValue(); - result.add(value); - } else { - result.add(value); - } - - } - - if (equals(4, length)) { - assertEquals("assertEqNormal", expectedNormal, result); - } else { - assertEquals("assertEqCoalescing", expectedExpanded, result); - } - - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/textparseintolistofelements"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(textparseintolistofelements.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextfour.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextfour.java deleted file mode 100644 index 3e54d3275..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextfour.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "splitText(offset)" method returns the new Text node. - * - * Retrieve the textual data from the last child of the - * first employee and invoke the "splitText(offset)" method. - * The method should return the new Text node. The offset - * value used for this test is 30. The "getNodeValue()" - * method is called to check that the new node now contains - * the characters at and after position 30. - * (Starting count at 0) -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D -*/ -public final class textsplittextfour extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public textsplittextfour(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node addressNode; - Text textNode; - Text splitNode; - String value; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("address"); - addressNode = elementList.item(0); - textNode = (Text) addressNode.getFirstChild(); - splitNode = textNode.splitText(30); - value = splitNode.getNodeValue(); - assertEquals("textSplitTextFourAssert", "98551", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/textsplittextfour"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(textsplittextfour.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextnomodificationallowederr.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextnomodificationallowederr.java deleted file mode 100644 index 9e33fdef7..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextnomodificationallowederr.java +++ /dev/null @@ -1,117 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "splitText(offset)" method raises a - * NO_MODIFICATION_ALLOWED_ERR DOMException if the - * node is readonly. - * - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Get the element content of the FIRST - * Text Node of the entity reference and execute the "splitText(offset)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-38853C1D')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D -*/ -public final class textsplittextnomodificationallowederr extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public textsplittextnomodificationallowederr(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node gender; - Node entRef; - Node entElement; - Node entElementText; - Text splitNode; - int nodeType; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - gender = genderList.item(2); - entRef = gender.getFirstChild(); - assertNotNull("entRefNotNull", entRef); - nodeType = (int) entRef.getNodeType(); - - if (equals(1, nodeType)) { - entRef = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entRef); - } - entElement = entRef.getFirstChild(); - assertNotNull("entElementNotNull", entElement); - entElementText = entElement.getFirstChild(); - assertNotNull("entElementTextNotNull", entElementText); - - { - boolean success = false; - try { - splitNode = ((Text) /*Node */entElementText).splitText(2); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/textsplittextnomodificationallowederr"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(textsplittextnomodificationallowederr.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextnomodificationallowederrEE.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextnomodificationallowederrEE.java deleted file mode 100644 index 1143f7339..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextnomodificationallowederrEE.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Create an ent3 reference and execute the "splitText(offset)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-38853C1D')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D -* @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/textsplittextnomodificationallowederr.xml -*/ -public final class textsplittextnomodificationallowederrEE extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public textsplittextnomodificationallowederrEE(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node entRef; - Node entText; - Text splitNode; - doc = (Document) load("staff", true); - entRef = doc.createEntityReference("ent3"); - assertNotNull("createdEntRefNotNull", entRef); - entText = entRef.getFirstChild(); - assertNotNull("entTextNotNull", entText); - - { - boolean success = false; - try { - splitNode = ((Text) /*Node */entText).splitText(2); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/textsplittextnomodificationallowederrEE"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(textsplittextnomodificationallowederrEE.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextone.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextone.java deleted file mode 100644 index c0bbbf4af..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextone.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "splitText(offset)" method breaks the Text node into - * two Text nodes at the specified offset keeping each node - * as siblings in the tree. - * - * Retrieve the textual data from the second child of the - * third employee and invoke the "splitText(offset)" method. - * The method splits the Text node into two new sibling - * Text nodes keeping both of them in the tree. This test - * checks the "nextSibling()" method of the original node - * to ensure that the two nodes are indeed siblings. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D -*/ -public final class textsplittextone extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public textsplittextone(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - Text textNode; - Text splitNode; - Node secondPart; - String value; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("name"); - nameNode = elementList.item(2); - textNode = (Text) nameNode.getFirstChild(); - splitNode = textNode.splitText(7); - secondPart = textNode.getNextSibling(); - value = secondPart.getNodeValue(); - assertEquals("textSplitTextOneAssert", "Jones", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/textsplittextone"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(textsplittextone.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextthree.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextthree.java deleted file mode 100644 index a2d3e1366..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittextthree.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * After the "splitText(offset)" method breaks the Text node - * into two Text nodes, the new Text node contains all the - * content at and after the offset point. - * - * Retrieve the textual data from the second child of the - * third employee and invoke the "splitText(offset)" method. - * The new Text node should contain all the content - * at and after the offset point. The "getNodeValue()" - * method is called to check that the new node now contains - * the characters at and after position seven. - * (Starting count at 0) -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D -*/ -public final class textsplittextthree extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public textsplittextthree(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - Text textNode; - Text splitNode; - String value; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("name"); - nameNode = elementList.item(2); - textNode = (Text) nameNode.getFirstChild(); - splitNode = textNode.splitText(6); - value = splitNode.getNodeValue(); - assertEquals("textSplitTextThreeAssert", " Jones", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/textsplittextthree"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(textsplittextthree.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittexttwo.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittexttwo.java deleted file mode 100644 index ac686f0a1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textsplittexttwo.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * After the "splitText(offset)" method breaks the Text node - * into two Text nodes, the original node contains all the - * content up to the offset point. - * - * Retrieve the textual data from the second child of the - * third employee and invoke the "splitText(offset)" method. - * The original Text node should contain all the content - * up to the offset point. The "getNodeValue()" method - * is called to check that the original node now contains - * the first five characters. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D -*/ -public final class textsplittexttwo extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public textsplittexttwo(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - Text textNode; - Text splitNode; - String value; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("name"); - nameNode = elementList.item(2); - textNode = (Text) nameNode.getFirstChild(); - splitNode = textNode.splitText(5); - value = textNode.getNodeValue(); - assertEquals("textSplitTextTwoAssert", "Roger", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/textsplittexttwo"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(textsplittexttwo.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textwithnomarkup.java b/libcore/dom/src/test/java/org/w3c/domts/level1/core/textwithnomarkup.java deleted file mode 100644 index ab0746005..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/core/textwithnomarkup.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level1.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * If there is not any markup inside an Element or Attr node - * content, then the text is contained in a single object - * implementing the Text interface that is the only child - * of the element. - * - * Retrieve the textual data from the second child of the - * third employee. That Text node contains a block of - * multiple text lines without markup, so they should be - * treated as a single Text node. The "getNodeValue()" - * method should contain the combination of the two lines. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1312295772 -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 -*/ -public final class textwithnomarkup extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public textwithnomarkup(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node nameNode; - Node nodeV; - String value; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("name"); - nameNode = elementList.item(2); - nodeV = nameNode.getFirstChild(); - value = nodeV.getNodeValue(); - assertEquals("textNodeValue", "Roger\n Jones", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/textwithnomarkup"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(textwithnomarkup.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/html/TestDefaultLS.java b/libcore/dom/src/test/java/org/w3c/domts/level1/html/TestDefaultLS.java deleted file mode 100644 index 0c7aaeab5..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/html/TestDefaultLS.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level1.html; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.LSDocumentBuilderFactory; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L1 HTML tests using the - * Default LS parser in default configuration. - * - * @author Curt Arnold - * - */ -public class TestDefaultLS extends TestSuite { - - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level1.html.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new LSDocumentBuilderFactory( - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/html/TestDefaultLSAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level1/html/TestDefaultLSAltConfig.java deleted file mode 100644 index 4fb1c75bf..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/html/TestDefaultLSAltConfig.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level1.html; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.LSDocumentBuilderFactory; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L1 HTML tests using the - * Default LS parser in an alternate configuration. - * - * @author Curt Arnold - * - */ -public class TestDefaultLSAltConfig extends TestSuite { - - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level1.html.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new LSDocumentBuilderFactory( - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level1/html/TestXercesHTML.java b/libcore/dom/src/test/java/org/w3c/domts/level1/html/TestXercesHTML.java deleted file mode 100644 index 9e9c6dd11..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level1/html/TestXercesHTML.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level1.html; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JUnitTestSuiteAdapter; -import org.w3c.domts.XercesHTMLDocumentBuilderFactory; - -public class TestXercesHTML extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level1.html.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new XercesHTMLDocumentBuilderFactory( - XercesHTMLDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestBatik.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestBatik.java deleted file mode 100644 index 41dc17e71..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestBatik.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level2.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.BatikTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.DocumentBuilderSetting; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestBatik extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level2.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new BatikTestDocumentBuilderFactory(new DocumentBuilderSetting[0]); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestCrimson.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestCrimson.java deleted file mode 100644 index ee8fd3983..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestCrimson.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level2.core; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestCrimson extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level2.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory crimsonFactory = (DocumentBuilderFactory) - ClassLoader.getSystemClassLoader().loadClass("org.apache.crimson.jaxp.DocumentBuilderFactoryImpl").newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(crimsonFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestCrimsonAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestCrimsonAltConfig.java deleted file mode 100644 index 1ac4fc065..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestCrimsonAltConfig.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level2.core; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestCrimsonAltConfig extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level2.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory crimsonFactory = (DocumentBuilderFactory) - ClassLoader.getSystemClassLoader().loadClass("org.apache.crimson.jaxp.DocumentBuilderFactoryImpl").newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(crimsonFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDOM4J.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDOM4J.java deleted file mode 100644 index 576842f5f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDOM4J.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level2.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOM4JTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.DocumentBuilderSetting; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestDOM4J extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level2.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new DOM4JTestDocumentBuilderFactory(new DocumentBuilderSetting[0]); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDefaultLS.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDefaultLS.java deleted file mode 100644 index ed86cd535..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDefaultLS.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level2.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; -import org.w3c.domts.LSDocumentBuilderFactory; - -/** - * Test suite that runs all DOM L2 Core tests using the - * Default LS parser in default configuration. - * - * @author Curt Arnold - * - */ -public class TestDefaultLS extends TestSuite { - - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level2.core.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new LSDocumentBuilderFactory( - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDefaultLSAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDefaultLSAltConfig.java deleted file mode 100644 index b25330289..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDefaultLSAltConfig.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level2.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.LSDocumentBuilderFactory; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L2 Core tests using the - * Default LS parser in an alternate configuration - * - * @author Curt Arnold - * - */ -public class TestDefaultLSAltConfig extends TestSuite { - - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level2.core.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new LSDocumentBuilderFactory( - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDefaultParser.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDefaultParser.java deleted file mode 100644 index 2a8b09331..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDefaultParser.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level2.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite using the default JAXP parser in the default configuration - * - * - */ -public class TestDefaultParser extends TestSuite { - - /** - * Create a new instance of the test suite - * @return new test suite - * @exception Exception if tests or implementation can be created. - */ - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level2.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(null, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDefaultParserAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDefaultParserAltConfig.java deleted file mode 100644 index 69ac3c68d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestDefaultParserAltConfig.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level2.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - - - -/** - * Test suite using the default JAXP parser in the alternative configuration - * - * - */ -public class TestDefaultParserAltConfig extends TestSuite { - - /** - * Create a new instance of the test suite - * @return new test suite - * @exception Exception if tests or implementation can be created. - */ - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level2.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(null, - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestGNUJAXP.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestGNUJAXP.java deleted file mode 100644 index c703b3c0f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestGNUJAXP.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level2.core; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestGNUJAXP extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level2.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - - DocumentBuilderFactory gnujaxpFactory = (DocumentBuilderFactory) - ClassLoader.getSystemClassLoader(). - loadClass("gnu.xml.dom.JAXPFactory").newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(gnujaxpFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestGNUJAXPAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestGNUJAXPAltConfig.java deleted file mode 100644 index 26a5b593c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestGNUJAXPAltConfig.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level2.core; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestGNUJAXPAltConfig extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level2.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory gnujaxpFactory = (DocumentBuilderFactory) - ClassLoader.getSystemClassLoader(). - loadClass("gnu.xml.dom.JAXPFactory").newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(gnujaxpFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestJTidy.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestJTidy.java deleted file mode 100644 index 77e240d4e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestJTidy.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level2.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.DocumentBuilderSetting; -import org.w3c.domts.JTidyDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestJTidy extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level2.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new JTidyDocumentBuilderFactory(new DocumentBuilderSetting[0]); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestOracle.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestOracle.java deleted file mode 100644 index cf1c9e960..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestOracle.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute of - * Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level2.core; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L2 Core tests using the - * Oracle Parser for Java in default configuration. - * - * @author Curt Arnold - * - */ -public class TestOracle extends TestSuite { - - /** - * Constructor - * @return test suite - * @throws Exception - */ - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level2.core.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory oracleFactory = - (DocumentBuilderFactory) ClassLoader - .getSystemClassLoader() - .loadClass("oracle.xml.jaxp.JXDocumentBuilderFactory") - .newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory( - oracleFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestOracleAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestOracleAltConfig.java deleted file mode 100644 index 80d951e8a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestOracleAltConfig.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute of - * Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level2.core; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L2 Core tests using the - * Oracle Parser for Java in default configuration. - * - * @author Curt Arnold - * - */ -public class TestOracleAltConfig extends TestSuite { - /** - * Constructor - * @return test suite - * @throws Exception - */ - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level2.core.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory oracleFactory = - (DocumentBuilderFactory) ClassLoader - .getSystemClassLoader() - .loadClass("oracle.xml.jaxp.JXDocumentBuilderFactory") - .newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory( - oracleFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestXerces.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestXerces.java deleted file mode 100644 index 44c867895..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestXerces.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level2.core; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestXerces extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level2.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory xercesFactory = (DocumentBuilderFactory) - ClassLoader.getSystemClassLoader().loadClass("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl").newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(xercesFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestXercesAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestXercesAltConfig.java deleted file mode 100644 index 17067bb79..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/TestXercesAltConfig.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level2.core; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestXercesAltConfig extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level2.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory xercesFactory = (DocumentBuilderFactory) - ClassLoader.getSystemClassLoader().loadClass("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl").newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(xercesFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/alltests.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/alltests.java deleted file mode 100644 index 8aaf13b25..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/alltests.java +++ /dev/null @@ -1,350 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.DOMTestSink; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - -/** - * -* @author DOM Test Suite Project -*/ -public class alltests extends DOMTestSuite { - - /** - * Constructor - * @param factory document factory, may not be null - * @throws Exception Thrown if test is not compatible with settings - */ - public alltests(DOMTestDocumentBuilderFactory factory) throws Exception { - super(factory); - - setFactory(factory); - } - - /** - * Build test suite by adding each test to the test sink - * @param sink test sink - */ - public void build(DOMTestSink sink) { -// sink.addTest(attrgetownerelement01.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(attrgetownerelement02.class); - sink.addTest(attrgetownerelement03.class); - sink.addTest(attrgetownerelement04.class); - sink.addTest(attrgetownerelement05.class); - sink.addTest(createAttributeNS01.class); - sink.addTest(createAttributeNS02.class); - sink.addTest(createAttributeNS03.class); - sink.addTest(createAttributeNS04.class); - sink.addTest(createAttributeNS05.class); -// sink.addTest(createAttributeNS06.class); - sink.addTest(createDocument01.class); - sink.addTest(createDocument02.class); -// sink.addTest(createDocument03.class); -// sink.addTest(createDocument04.class); - sink.addTest(createDocument05.class); - sink.addTest(createDocument06.class); - sink.addTest(createDocument07.class); -// sink.addTest(createDocument08.class); - sink.addTest(createDocumentType01.class); - sink.addTest(createDocumentType02.class); - sink.addTest(createDocumentType03.class); -// sink.addTest(createDocumentType04.class); - sink.addTest(createElementNS01.class); - sink.addTest(createElementNS02.class); - sink.addTest(createElementNS03.class); - sink.addTest(createElementNS04.class); - sink.addTest(createElementNS05.class); - sink.addTest(documentcreateattributeNS01.class); - sink.addTest(documentcreateattributeNS02.class); - sink.addTest(documentcreateattributeNS03.class); - sink.addTest(documentcreateattributeNS04.class); - sink.addTest(documentcreateattributeNS05.class); - sink.addTest(documentcreateattributeNS06.class); - sink.addTest(documentcreateattributeNS07.class); - sink.addTest(documentcreateelementNS01.class); - sink.addTest(documentcreateelementNS02.class); - sink.addTest(documentcreateelementNS05.class); - sink.addTest(documentcreateelementNS06.class); - sink.addTest(documentgetelementbyid01.class); - sink.addTest(documentgetelementsbytagnameNS01.class); - sink.addTest(documentgetelementsbytagnameNS02.class); - sink.addTest(documentgetelementsbytagnameNS03.class); - sink.addTest(documentgetelementsbytagnameNS04.class); - sink.addTest(documentgetelementsbytagnameNS05.class); -// sink.addTest(documentimportnode01.class); - sink.addTest(documentimportnode02.class); -// sink.addTest(documentimportnode03.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available -// sink.addTest(documentimportnode04.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(documentimportnode05.class); - sink.addTest(documentimportnode06.class); - sink.addTest(documentimportnode07.class); - sink.addTest(documentimportnode08.class); - sink.addTest(documentimportnode09.class); - sink.addTest(documentimportnode10.class); - sink.addTest(documentimportnode11.class); - sink.addTest(documentimportnode12.class); - sink.addTest(documentimportnode13.class); -// sink.addTest(documentimportnode14.class); - sink.addTest(documentimportnode15.class); - sink.addTest(documentimportnode17.class); - sink.addTest(documentimportnode18.class); -// sink.addTest(documentimportnode19.class); -// sink.addTest(documentimportnode20.class); -// sink.addTest(documentimportnode21.class); -// sink.addTest(documentimportnode22.class); - sink.addTest(documenttypeinternalSubset01.class); - sink.addTest(documenttypepublicid01.class); - sink.addTest(documenttypesystemid01.class); - sink.addTest(domimplementationcreatedocument03.class); - sink.addTest(domimplementationcreatedocument04.class); - sink.addTest(domimplementationcreatedocument05.class); - sink.addTest(domimplementationcreatedocument07.class); - sink.addTest(domimplementationcreatedocumenttype01.class); - sink.addTest(domimplementationcreatedocumenttype02.class); - sink.addTest(domimplementationcreatedocumenttype04.class); - sink.addTest(domimplementationfeaturecore.class); - sink.addTest(domimplementationfeaturexmlversion2.class); - sink.addTest(domimplementationhasfeature01.class); - sink.addTest(domimplementationhasfeature02.class); - sink.addTest(elementgetattributenodens01.class); - sink.addTest(elementgetattributenodens02.class); -// sink.addTest(elementgetattributenodens03.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available -// sink.addTest(elementgetattributens02.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(elementgetelementsbytagnamens02.class); - sink.addTest(elementgetelementsbytagnamens04.class); - sink.addTest(elementgetelementsbytagnamens05.class); - sink.addTest(elementhasattribute01.class); -// sink.addTest(elementhasattribute02.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(elementhasattribute03.class); - sink.addTest(elementhasattribute04.class); -// sink.addTest(elementhasattributens01.class); - sink.addTest(elementhasattributens02.class); - sink.addTest(elementhasattributens03.class); - sink.addTest(elementremoveattributens01.class); - sink.addTest(elementsetattributenodens01.class); - sink.addTest(elementsetattributenodens02.class); - sink.addTest(elementsetattributenodens03.class); - sink.addTest(elementsetattributenodens04.class); - sink.addTest(elementsetattributenodens05.class); -// sink.addTest(elementsetattributenodens06.class); - sink.addTest(elementsetattributens01.class); - sink.addTest(elementsetattributens02.class); - sink.addTest(elementsetattributens03.class); - sink.addTest(elementsetattributens04.class); - sink.addTest(elementsetattributens05.class); - sink.addTest(elementsetattributens08.class); - sink.addTest(elementsetattributensurinull.class); -// sink.addTest(getAttributeNS01.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(getAttributeNS02.class); - sink.addTest(getAttributeNS03.class); - sink.addTest(getAttributeNS04.class); - sink.addTest(getAttributeNS05.class); - sink.addTest(getAttributeNodeNS01.class); - sink.addTest(getAttributeNodeNS02.class); -// sink.addTest(getElementById01.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(getElementById02.class); -// sink.addTest(getElementsByTagNameNS01.class); - sink.addTest(getElementsByTagNameNS02.class); - sink.addTest(getElementsByTagNameNS03.class); - sink.addTest(getElementsByTagNameNS04.class); - sink.addTest(getElementsByTagNameNS05.class); - sink.addTest(getElementsByTagNameNS06.class); - sink.addTest(getElementsByTagNameNS07.class); - sink.addTest(getElementsByTagNameNS08.class); - sink.addTest(getElementsByTagNameNS09.class); - sink.addTest(getElementsByTagNameNS10.class); - sink.addTest(getElementsByTagNameNS11.class); - sink.addTest(getElementsByTagNameNS12.class); - sink.addTest(getElementsByTagNameNS13.class); - sink.addTest(getElementsByTagNameNS14.class); - sink.addTest(getNamedItemNS01.class); - sink.addTest(getNamedItemNS02.class); -// sink.addTest(getNamedItemNS03.class); -// sink.addTest(getNamedItemNS04.class); - sink.addTest(hasAttribute01.class); -// sink.addTest(hasAttribute02.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(hasAttribute03.class); -// sink.addTest(hasAttribute04.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(hasAttributeNS01.class); - sink.addTest(hasAttributeNS02.class); - sink.addTest(hasAttributeNS03.class); -// sink.addTest(hasAttributeNS04.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(hasAttributeNS05.class); - sink.addTest(hasAttributes01.class); - sink.addTest(hasAttributes02.class); -// sink.addTest(hc_entitiesremovenameditemns1.class); -// sink.addTest(hc_entitiessetnameditemns1.class); - sink.addTest(hc_namednodemapinvalidtype1.class); - sink.addTest(hc_nodedocumentfragmentnormalize1.class); - sink.addTest(hc_nodedocumentfragmentnormalize2.class); -// sink.addTest(hc_notationsremovenameditemns1.class); -// sink.addTest(hc_notationssetnameditemns1.class); -// sink.addTest(importNode01.class); - sink.addTest(importNode02.class); - sink.addTest(importNode03.class); - sink.addTest(importNode04.class); -// sink.addTest(importNode05.class); -// sink.addTest(importNode06.class); -// sink.addTest(importNode07.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(importNode08.class); -// sink.addTest(importNode09.class); - sink.addTest(importNode10.class); -// sink.addTest(importNode11.class); -// sink.addTest(importNode12.class); -// sink.addTest(importNode13.class); - sink.addTest(importNode14.class); - sink.addTest(importNode15.class); - sink.addTest(importNode16.class); - sink.addTest(importNode17.class); - sink.addTest(internalSubset01.class); - sink.addTest(isSupported01.class); - sink.addTest(isSupported02.class); - sink.addTest(isSupported04.class); - sink.addTest(isSupported05.class); - sink.addTest(isSupported06.class); - sink.addTest(isSupported07.class); - sink.addTest(isSupported09.class); - sink.addTest(isSupported10.class); - sink.addTest(isSupported11.class); - sink.addTest(isSupported12.class); - sink.addTest(isSupported13.class); - sink.addTest(isSupported14.class); - sink.addTest(localName01.class); - sink.addTest(localName02.class); - sink.addTest(localName03.class); - sink.addTest(localName04.class); -// sink.addTest(namednodemapgetnameditemns01.class); - sink.addTest(namednodemapgetnameditemns02.class); - sink.addTest(namednodemapgetnameditemns03.class); - sink.addTest(namednodemapgetnameditemns04.class); - sink.addTest(namednodemapgetnameditemns05.class); - sink.addTest(namednodemapgetnameditemns06.class); - sink.addTest(namednodemapremovenameditemns01.class); -// sink.addTest(namednodemapremovenameditemns02.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(namednodemapremovenameditemns03.class); -// sink.addTest(namednodemapremovenameditemns04.class); -// sink.addTest(namednodemapremovenameditemns05.class); - sink.addTest(namednodemapremovenameditemns06.class); - sink.addTest(namednodemapremovenameditemns07.class); - sink.addTest(namednodemapremovenameditemns08.class); - sink.addTest(namednodemapremovenameditemns09.class); - sink.addTest(namednodemapsetnameditemns01.class); - sink.addTest(namednodemapsetnameditemns02.class); - sink.addTest(namednodemapsetnameditemns03.class); - sink.addTest(namednodemapsetnameditemns04.class); -// sink.addTest(namednodemapsetnameditemns05.class); - sink.addTest(namednodemapsetnameditemns06.class); - sink.addTest(namednodemapsetnameditemns07.class); - sink.addTest(namednodemapsetnameditemns08.class); -// sink.addTest(namednodemapsetnameditemns09.class); -// sink.addTest(namednodemapsetnameditemns10.class); -// sink.addTest(namednodemapsetnameditemns11.class); -// sink.addTest(namespaceURI01.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(namespaceURI02.class); - sink.addTest(namespaceURI03.class); - sink.addTest(namespaceURI04.class); - sink.addTest(nodegetlocalname03.class); - sink.addTest(nodegetnamespaceuri03.class); - sink.addTest(nodegetownerdocument01.class); - sink.addTest(nodegetownerdocument02.class); - sink.addTest(nodegetprefix03.class); - sink.addTest(nodehasattributes01.class); - sink.addTest(nodehasattributes02.class); - sink.addTest(nodehasattributes03.class); - sink.addTest(nodehasattributes04.class); - sink.addTest(nodeissupported01.class); - sink.addTest(nodeissupported02.class); - sink.addTest(nodeissupported03.class); - sink.addTest(nodeissupported04.class); - sink.addTest(nodeissupported05.class); - sink.addTest(nodenormalize01.class); - sink.addTest(nodesetprefix01.class); - sink.addTest(nodesetprefix02.class); - sink.addTest(nodesetprefix03.class); -// sink.addTest(nodesetprefix04.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(nodesetprefix05.class); - sink.addTest(nodesetprefix06.class); - sink.addTest(nodesetprefix07.class); - sink.addTest(nodesetprefix08.class); -// sink.addTest(nodesetprefix09.class); - sink.addTest(normalize01.class); - sink.addTest(ownerDocument01.class); - sink.addTest(ownerElement01.class); - sink.addTest(ownerElement02.class); - sink.addTest(prefix01.class); - sink.addTest(prefix02.class); - sink.addTest(prefix03.class); - sink.addTest(prefix04.class); - sink.addTest(prefix05.class); -// sink.addTest(prefix06.class); - sink.addTest(prefix07.class); -// sink.addTest(prefix08.class); -// sink.addTest(prefix09.class); - sink.addTest(prefix10.class); - sink.addTest(prefix11.class); - sink.addTest(publicId01.class); -// sink.addTest(removeAttributeNS01.class); -// sink.addTest(removeAttributeNS02.class); // javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available - sink.addTest(removeNamedItemNS01.class); - sink.addTest(removeNamedItemNS02.class); -// sink.addTest(removeNamedItemNS03.class); - sink.addTest(setAttributeNS01.class); - sink.addTest(setAttributeNS02.class); -// sink.addTest(setAttributeNS03.class); - sink.addTest(setAttributeNS04.class); - sink.addTest(setAttributeNS05.class); - sink.addTest(setAttributeNS06.class); - sink.addTest(setAttributeNS07.class); - sink.addTest(setAttributeNS09.class); -// sink.addTest(setAttributeNS10.class); - sink.addTest(setAttributeNodeNS01.class); -// sink.addTest(setAttributeNodeNS02.class); - sink.addTest(setAttributeNodeNS03.class); - sink.addTest(setAttributeNodeNS04.class); - sink.addTest(setAttributeNodeNS05.class); - sink.addTest(setNamedItemNS01.class); - sink.addTest(setNamedItemNS02.class); - sink.addTest(setNamedItemNS03.class); -// sink.addTest(setNamedItemNS04.class); -// sink.addTest(setNamedItemNS05.class); - sink.addTest(systemId01.class); - - } - /** - * Gets URI that identifies the test suite - * @return uri identifier of test suite - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/alltests"; - } - - /** - * Runs individual test - * @param args command line arguments - */ - public static void main(String[] args) { - DOMTestCase.doMain(alltests.class, args); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement01.java deleted file mode 100644 index ff224204a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement01.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getOwnerElement()" will return the Element node this attribute is attached to or - * null if this attribute is not in use. - * - * Retreive the default attribute defaultAttr and check its owner element. Verify if the name - * the nodeName of the returned ownerElement is emp:employee. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Attr-ownerElement -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class attrgetownerelement01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrgetownerelement01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware, -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr attr; - Element element; - Element ownerElement; - String ownerElementName; - NodeList elementList; - NamedNodeMap attributes; - String nullNS = null; - - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "employee"); - element = (Element) elementList.item(1); - attributes = element.getAttributes(); - attr = (Attr) attributes.getNamedItemNS(nullNS, "defaultAttr"); - ownerElement = attr.getOwnerElement(); - ownerElementName = ownerElement.getNodeName(); - assertEquals("attrgetownerelement01", "emp:employee", ownerElementName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/attrgetownerelement01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrgetownerelement01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement02.java deleted file mode 100644 index 1c4f939e3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement02.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getOwnerElement()" will return the Element node this attribute - * is attached to or null if this attribute is not in use. - * - * Create a new element and attribute node, attach the attribute to the element. - * Check the value of owner element of the new attribute node -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Attr-ownerElement -*/ -public final class attrgetownerelement02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrgetownerelement02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - Element ownerElement; - String ownerElementName; - Attr attr; - Attr newAttr; - doc = (Document) load("staffNS", false); - element = doc.createElement("root"); - attr = doc.createAttributeNS("http://www.w3.org/DOM/L1", "L1:att"); - newAttr = element.setAttributeNodeNS(attr); - ownerElement = attr.getOwnerElement(); - ownerElementName = ownerElement.getNodeName(); - assertEqualsIgnoreCase("attrgetownerelement02", "root", ownerElementName); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/attrgetownerelement02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrgetownerelement02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement03.java deleted file mode 100644 index 30378d807..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement03.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getOwnerElement()" will return the Element node this attribute - * is attached to or null if this attribute is not in use. - * - * Create a new attribute node for this document node. Since the newly attribute is - * not it use its owner element should be null. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Attr-ownerElement -*/ -public final class attrgetownerelement03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrgetownerelement03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node ownerElement; - Attr attr; - doc = (Document) load("staffNS", false); - attr = doc.createAttributeNS("http://www.w3.org/DOM", "dom:attr"); - ownerElement = attr.getOwnerElement(); - assertNull("attrgetownerelement03", ownerElement); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/attrgetownerelement03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrgetownerelement03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement04.java deleted file mode 100644 index 917a05af4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement04.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getOwnerElement()" will return the Element node this attribute is attached to or - * null if this attribute is not in use. - * Import an attribute node to another document. If an Attr node is imported, its - * ownerElement attribute should be set to null. Verify if the ownerElement has been set - * to null. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Attr-ownerElement -*/ -public final class attrgetownerelement04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrgetownerelement04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document docImp; - Node ownerElement; - Element element; - Attr attr; - Attr attrImp; - NodeList addresses; - doc = (Document) load("staffNS", false); - docImp = (Document) load("staff", false); - addresses = doc.getElementsByTagNameNS("http://www.nist.gov", "address"); - element = (Element) addresses.item(1); - assertNotNull("empAddressNotNull", element); - attr = element.getAttributeNodeNS("http://www.nist.gov", "zone"); - attrImp = (Attr) docImp.importNode(attr, true); - ownerElement = attrImp.getOwnerElement(); - assertNull("attrgetownerelement04", ownerElement); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/attrgetownerelement04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrgetownerelement04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement05.java deleted file mode 100644 index 5e0278620..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/attrgetownerelement05.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getOwnerElement()" will return the Element node this attribute is attached to - * or null if this attribute is not in use. - * - * Retreive an element and its attributes. Then remove the element and check the name of - * the ownerElement of attribute of the attribute "street". -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Attr-ownerElement -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class attrgetownerelement05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public attrgetownerelement05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node element; - Element ownerElement; - Element parentElement; - NodeList elementList; - String ownerElementName; - Attr attr; - Node removedChild; - NamedNodeMap nodeMap; - String nullNS = null; - - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagNameNS("*", "address"); - element = elementList.item(1); - parentElement = (Element) element.getParentNode(); - nodeMap = element.getAttributes(); - removedChild = parentElement.removeChild(element); - attr = (Attr) nodeMap.getNamedItemNS(nullNS, "street"); - ownerElement = attr.getOwnerElement(); - ownerElementName = ownerElement.getNodeName(); - assertEquals("attrgetownerelement05", "address", ownerElementName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/attrgetownerelement05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(attrgetownerelement05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS01.java deleted file mode 100644 index fa2f3d5f3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS01.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createAttributeNS(namespaceURI,qualifiedName)" method for a - * Document should raise NAMESPACE_ERR DOMException - * if qualifiedName is malformed. - * - * Invoke method createAttributeNS(namespaceURI,qualifiedName) on - * the XMLNS Document with namespaceURI being "http://www.ecommerce.org/", - * qualifiedName as "prefix::local". Method should raise - * NAMESPACE_ERR DOMException. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrAttrNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-DocCrAttrNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR']) -*/ -public final class createAttributeNS01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createAttributeNS01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.ecommerce.org/"; - String malformedName = "prefix::local"; - Document doc; - Attr newAttr; - doc = (Document) load("staffNS", false); - - { - boolean success = false; - try { - newAttr = doc.createAttributeNS(namespaceURI, malformedName); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createAttributeNS01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createAttributeNS01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS02.java deleted file mode 100644 index 444a401ff..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS02.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createAttributeNS(namespaceURI,qualifiedName)" method for a - * Document should raise NAMESPACE_ERR DOMException - * if qualifiedName has a prefix and namespaceURI is null. - * - * Invoke method createAttributeNS(namespaceURI,qualifiedName) on this document - * with namespaceURI being null and qualifiedName contains the prefix "person". - * Method should raise NAMESPACE_ERR DOMException. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrAttrNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-DocCrAttrNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR']) -*/ -public final class createAttributeNS02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createAttributeNS02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = null; - - String qualifiedName = "prefix:local"; - Document doc; - Attr newAttr; - doc = (Document) load("staffNS", false); - - { - boolean success = false; - try { - newAttr = doc.createAttributeNS(namespaceURI, qualifiedName); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createAttributeNS02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createAttributeNS02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS03.java deleted file mode 100644 index abce6014d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS03.java +++ /dev/null @@ -1,132 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createAttributeNS(namespaceURI,qualifiedName)" method for a - * Document should raise INVALID_CHARACTER_ERR DOMException - * if qualifiedName contains an illegal character. - * - * Invoke method createAttributeNS(namespaceURI,qualifiedName) on this document - * with qualifiedName containing an illegal character from illegalChars[]. - * Method should raise INVALID_CHARACTER_ERR DOMException for all - * characters in illegalChars[]. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrAttrNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-DocCrAttrNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -*/ -public final class createAttributeNS03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createAttributeNS03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.wedding.com/"; - String qualifiedName; - Document doc; - Attr newAttr; - java.util.List illegalQNames = new java.util.ArrayList(); - illegalQNames.add("person:{"); - illegalQNames.add("person:}"); - illegalQNames.add("person:~"); - illegalQNames.add("person:'"); - illegalQNames.add("person:!"); - illegalQNames.add("person:@"); - illegalQNames.add("person:#"); - illegalQNames.add("person:$"); - illegalQNames.add("person:%"); - illegalQNames.add("person:^"); - illegalQNames.add("person:&"); - illegalQNames.add("person:*"); - illegalQNames.add("person:("); - illegalQNames.add("person:)"); - illegalQNames.add("person:+"); - illegalQNames.add("person:="); - illegalQNames.add("person:["); - illegalQNames.add("person:]"); - illegalQNames.add("person:\\"); - illegalQNames.add("person:/"); - illegalQNames.add("person:;"); - illegalQNames.add("person:`"); - illegalQNames.add("person:<"); - illegalQNames.add("person:>"); - illegalQNames.add("person:,"); - illegalQNames.add("person:a "); - illegalQNames.add("person:\""); - - doc = (Document) load("staffNS", false); - for (int indexN10090 = 0; indexN10090 < illegalQNames.size(); indexN10090++) { - qualifiedName = (String) illegalQNames.get(indexN10090); - - { - boolean success = false; - try { - newAttr = doc.createAttributeNS(namespaceURI, qualifiedName); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createAttributeNS03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createAttributeNS03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS04.java deleted file mode 100644 index 2301989d4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS04.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createAttributeNS(namespaceURI,qualifiedName)" method for a - * Document should raise NAMESPACE_ERR DOMException - * if qualifiedName has the "xml" prefix and namespaceURI is different - * from "http://www.w3.org/XML/1998/namespace". - * - * Invoke method createAttributeNS(namespaceURI,qualifiedName) on this document - * with qualifiedName being "xml:attr1 and namespaceURI equals - * the string "http://www.w3.org/XML/1998/namespaces" (which differs from the required - * string "http://www.w3.org/XML/1998/namespace"). - * Method should raise NAMESPACE_ERR DOMException. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrAttrNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-DocCrAttrNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR']) -*/ -public final class createAttributeNS04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createAttributeNS04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.w3.org/XML/1998/namespaces"; - String qualifiedName = "xml:attr1"; - Document doc; - Attr newAttr; - doc = (Document) load("staffNS", false); - - { - boolean success = false; - try { - newAttr = doc.createAttributeNS(namespaceURI, qualifiedName); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createAttributeNS04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createAttributeNS04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS05.java deleted file mode 100644 index e0bd5dd68..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS05.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createAttributeNS(namespaceURI,qualifiedName)" method for a - * Document should return a new Attr object given that all parameters are - * valid and correctly formed. - * - * Invoke method createAttributeNS(namespaceURI,qualifiedName) on this document with - * parameters equal "http://www.ecommerce.org/" and "ecom:local" - * respectively. Method should return a new Attr object whose name is "ecom:local". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-1112119403 -*/ -public final class createAttributeNS05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createAttributeNS05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.ecommerce.org/"; - String qualifiedName = "econm:local"; - Document doc; - Attr newAttr; - String attrName; - doc = (Document) load("staffNS", false); - newAttr = doc.createAttributeNS(namespaceURI, qualifiedName); - attrName = newAttr.getName(); - assertEquals("throw_Equals", qualifiedName, attrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createAttributeNS05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createAttributeNS05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS06.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS06.java deleted file mode 100644 index f16137019..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createAttributeNS06.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Document.createAttributeNS with an empty qualified name should cause an INVALID_CHARACTER_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrAttrNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-DocCrAttrNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525 -*/ -public final class createAttributeNS06 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createAttributeNS06(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.example.com/"; - String qualifiedName; - Document doc; - Attr newAttr; - doc = (Document) load("hc_staff", true); - - { - boolean success = false; - try { - newAttr = doc.createAttributeNS(namespaceURI, ""); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createAttributeNS06"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createAttributeNS06.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument01.java deleted file mode 100644 index bf6954195..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument01.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createDocument(namespaceURI,qualifiedName,doctype)" method for a - * DOMImplementation should raise NAMESPACE_ERR DOMException - * if parameter qualifiedName is malformed. - * - * Retrieve the DOMImplementation on the XMLNS Document. - * Invoke method createDocument(namespaceURI,qualifiedName,doctype) - * on the retrieved DOMImplementation with namespaceURI being - * the literal string "http://www.ecommerce.org/", qualifiedName as - * "prefix::local", and doctype as null. Method should raise - * NAMESPACE_ERR DOMException. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocument -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('Level-2-Core-DOM-createDocument')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR']) -*/ -public final class createDocument01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createDocument01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.ecommerce.org/"; - String malformedName = "prefix::local"; - Document doc; - DocumentType docType = null; - - DOMImplementation domImpl; - Document aNewDoc; - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - - { - boolean success = false; - try { - aNewDoc = domImpl.createDocument(namespaceURI, malformedName, docType); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocument01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createDocument01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument02.java deleted file mode 100644 index 687773f58..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument02.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createDocument(namespaceURI,qualifiedName,doctype)" method for a - * DOMImplementation should raise NAMESPACE_ERR DOMException - * if qualifiedName has a prefix and namespaceURI is null. - * - * Invoke method createDocument(namespaceURI,qualifiedName,doctype) on - * this domimplementation with namespaceURI being null and qualifiedName - * equals "k:local". Method should raise NAMESPACE_ERR DOMException. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocument -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('Level-2-Core-DOM-createDocument')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR']) -*/ -public final class createDocument02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createDocument02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = null; - - String qualifiedName = "k:local"; - Document doc; - DocumentType docType = null; - - DOMImplementation domImpl; - Document aNewDoc; - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - - { - boolean success = false; - try { - aNewDoc = domImpl.createDocument(namespaceURI, qualifiedName, docType); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocument02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createDocument02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument03.java deleted file mode 100644 index c7faef999..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument03.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createDocument(namespaceURI,qualifiedName,doctype)" method for a - * DOMImplementation should raise WRONG_DOCUMENT_ERR DOMException - * if parameter doctype has been used with a different document. - * - * Invoke method createDocument(namespaceURI,qualifiedName,doctype) on - * this domimplementation where doctype is the type of this document. - * Method should raise WRONG_DOCUMENT_ERR DOMException. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocument -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('Level-2-Core-DOM-createDocument')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR']) -*/ -public final class createDocument03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createDocument03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.ecommerce.org/schema"; - String qualifiedName = "namespaceURI:x"; - Document doc; - DocumentType docType; - DOMImplementation domImpl; - Document aNewDoc; - doc = (Document) load("staffNS", false); - docType = doc.getDoctype(); - domImpl = doc.getImplementation(); - - { - boolean success = false; - try { - aNewDoc = domImpl.createDocument(namespaceURI, qualifiedName, docType); - } catch (DOMException ex) { - success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); - } - assertTrue("throw_WRONG_DOCUMENT_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocument03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createDocument03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument04.java deleted file mode 100644 index 652ece9af..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument04.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createDocument(namespaceURI,qualifiedName,doctype)" method for a - * DOMImplementation should raise WRONG_DOCUMENT_ERR DOMException - * if parameter doctype was created from a different implementation. - * - * Invoke method createDocument(namespaceURI,qualifiedName,doctype) on - * a domimplementation that is different from this domimplementation. - * Doctype is the type of this document. - * Method should raise WRONG_DOCUMENT_ERR DOMException. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocument -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('Level-2-Core-DOM-createDocument')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR']) -*/ -public final class createDocument04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createDocument04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.ecommerce.org/schema"; - String qualifiedName = "namespaceURI:x"; - Document doc; - DocumentType docType; - DOMImplementation domImpl; - Document aNewDoc; - doc = (Document) load("staffNS", false); - aNewDoc = (Document) load("staffNS", false); - docType = doc.getDoctype(); - domImpl = aNewDoc.getImplementation(); - - { - boolean success = false; - try { - aNewDoc = domImpl.createDocument(namespaceURI, qualifiedName, docType); - } catch (DOMException ex) { - success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); - } - assertTrue("throw_WRONG_DOCUMENT_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocument04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createDocument04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument05.java deleted file mode 100644 index 16cf86d48..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument05.java +++ /dev/null @@ -1,137 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createDocument(namespaceURI,qualifiedName,doctype)" method for a - * DOMImplementation should raise INVALID_CHARACTER_ERR DOMException - * if parameter qualifiedName contains an illegal character. - * - * Invoke method createDocument(namespaceURI,qualifiedName,doctype) on - * this domimplementation with namespaceURI equals "http://www.ecommerce.org/schema", - * doctype is null and qualifiedName contains an illegal character from - * illegalChars[]. Method should raise INVALID_CHARACTER_ERR DOMException - * for all characters in illegalChars[]. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core# -*/ -public final class createDocument05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createDocument05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.ecommerce.org/schema"; - String qualifiedName; - Document doc; - DocumentType docType = null; - - DOMImplementation domImpl; - Document aNewDoc; - String charact; - java.util.List illegalQNames = new java.util.ArrayList(); - illegalQNames.add("namespaceURI:{"); - illegalQNames.add("namespaceURI:}"); - illegalQNames.add("namespaceURI:~"); - illegalQNames.add("namespaceURI:'"); - illegalQNames.add("namespaceURI:!"); - illegalQNames.add("namespaceURI:@"); - illegalQNames.add("namespaceURI:#"); - illegalQNames.add("namespaceURI:$"); - illegalQNames.add("namespaceURI:%"); - illegalQNames.add("namespaceURI:^"); - illegalQNames.add("namespaceURI:&"); - illegalQNames.add("namespaceURI:*"); - illegalQNames.add("namespaceURI:("); - illegalQNames.add("namespaceURI:)"); - illegalQNames.add("namespaceURI:+"); - illegalQNames.add("namespaceURI:="); - illegalQNames.add("namespaceURI:["); - illegalQNames.add("namespaceURI:]"); - illegalQNames.add("namespaceURI:\\"); - illegalQNames.add("namespaceURI:/"); - illegalQNames.add("namespaceURI:;"); - illegalQNames.add("namespaceURI:`"); - illegalQNames.add("namespaceURI:<"); - illegalQNames.add("namespaceURI:>"); - illegalQNames.add("namespaceURI:,"); - illegalQNames.add("namespaceURI:a "); - illegalQNames.add("namespaceURI:\""); - - doc = (Document) load("staffNS", false); - for (int indexN1009A = 0; indexN1009A < illegalQNames.size(); indexN1009A++) { - qualifiedName = (String) illegalQNames.get(indexN1009A); - domImpl = doc.getImplementation(); - - { - boolean success = false; - try { - aNewDoc = domImpl.createDocument(namespaceURI, qualifiedName, docType); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocument05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createDocument05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument06.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument06.java deleted file mode 100644 index 7653d26e3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument06.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createDocument(namespaceURI,qualifiedName,doctype)" method for a - * DOMImplementation should raise NAMESPACE_ERR DOMException - * if qualifiedName has the "xml" prefix and namespaceURI different from - * "http://www.w3.org/XML/1998/namespace" - * - * Invoke method createDocument(namespaceURI,qualifiedName,doctype) on - * this domimplementation with qualifiedName "xml:local" - * and namespaceURI as the string - * "http://www.ecommerce.org/schema" (which is different from the required - * "http://www.w3.org/XML/1998/namespace"). Method should raise - * NAMESPACE_ERR DOMException. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocument -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('Level-2-Core-DOM-createDocument')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR']) -*/ -public final class createDocument06 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createDocument06(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://ecommerce.org/schema"; - String qualifiedName = "xml:local"; - Document doc; - DocumentType docType = null; - - DOMImplementation domImpl; - Document aNewDoc; - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - - { - boolean success = false; - try { - aNewDoc = domImpl.createDocument(namespaceURI, qualifiedName, docType); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocument06"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createDocument06.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument07.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument07.java deleted file mode 100644 index 9976ad3ba..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument07.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createDocument(namespaceURI,qualifiedName,doctype)" method for a - * DOMImplementation should return a new xml Document object of the - * specified type with its document element given that all parameters are - * valid and correctly formed. - * - * Invoke method createDocument(namespaceURI,qualifiedName,doctype) on - * this domimplementation. namespaceURI is "http://www.ecommerce.org/schema" - * qualifiedName is "y:x" and doctype is null. - * Method should return a new xml Document as specified by the listed parameters. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocument -*/ -public final class createDocument07 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createDocument07(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.ecommerce.org/schema"; - String qualifiedName = "y:x"; - Document doc; - DocumentType docType = null; - - DOMImplementation domImpl; - Document aNewDoc; - String nodeName; - String nodeValue; - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - aNewDoc = domImpl.createDocument(namespaceURI, qualifiedName, docType); - nodeName = aNewDoc.getNodeName(); - nodeValue = aNewDoc.getNodeValue(); - assertEquals("nodeName", "#document", nodeName); - assertNull("nodeValue", nodeValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocument07"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createDocument07.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument08.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument08.java deleted file mode 100644 index 5cb52bdf4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocument08.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * DOMImplementation.createDocument with an empty qualified name should cause an INVALID_CHARACTER_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core# -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525 -*/ -public final class createDocument08 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - */ - public createDocument08(final DOMTestDocumentBuilderFactory factory) { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.example.org/schema"; - DocumentType docType = null; - - DOMImplementation domImpl; - Document aNewDoc; - String charact; - domImpl = getImplementation(); - - { - boolean success = false; - try { - aNewDoc = domImpl.createDocument(namespaceURI, "", docType); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocument08"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createDocument08.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocumentType01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocumentType01.java deleted file mode 100644 index dc4b4a32e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocumentType01.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createDocumentType(qualifiedName,publicId,systemId)" method for a - * DOMImplementation should raise NAMESPACE_ERR DOMException if - * qualifiedName is malformed. - * - * Retrieve the DOMImplementation on the XMLNS Document. - * Invoke method createDocumentType(qualifiedName,publicId,systemId) - * on the retrieved DOMImplementation with qualifiedName being the literal - * string "prefix::local", publicId as "STAFF", and systemId as "staff". - * Method should raise NAMESPACE_ERR DOMException. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocType -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('Level-2-Core-DOM-createDocType')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR']) -*/ -public final class createDocumentType01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createDocumentType01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String publicId = "STAFF"; - String systemId = "staff.xml"; - String malformedName = "prefix::local"; - Document doc; - DOMImplementation domImpl; - DocumentType newType; - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - - { - boolean success = false; - try { - newType = domImpl.createDocumentType(malformedName, publicId, systemId); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocumentType01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createDocumentType01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocumentType02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocumentType02.java deleted file mode 100644 index 39317ae14..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocumentType02.java +++ /dev/null @@ -1,136 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createDocumentType(qualifiedName,publicId,systemId)" method for a - * DOMImplementation should raise INVALID_CHARACTER_ERR DOMException if - * qualifiedName contains an illegal character. - * - * Invoke method createDocumentType(qualifiedName,publicId,systemId) on - * this domimplementation with qualifiedName containing an illegal character - * from illegalChars[]. Method should raise INVALID_CHARACTER_ERR - * DOMException for all characters in illegalChars[]. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocType -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('Level-2-Core-DOM-createDocType')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -*/ -public final class createDocumentType02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createDocumentType02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String publicId = "http://www.localhost.com/"; - String systemId = "myDoc.dtd"; - String qualifiedName; - Document doc; - DocumentType docType = null; - - DOMImplementation domImpl; - java.util.List illegalQNames = new java.util.ArrayList(); - illegalQNames.add("edi:{"); - illegalQNames.add("edi:}"); - illegalQNames.add("edi:~"); - illegalQNames.add("edi:'"); - illegalQNames.add("edi:!"); - illegalQNames.add("edi:@"); - illegalQNames.add("edi:#"); - illegalQNames.add("edi:$"); - illegalQNames.add("edi:%"); - illegalQNames.add("edi:^"); - illegalQNames.add("edi:&"); - illegalQNames.add("edi:*"); - illegalQNames.add("edi:("); - illegalQNames.add("edi:)"); - illegalQNames.add("edi:+"); - illegalQNames.add("edi:="); - illegalQNames.add("edi:["); - illegalQNames.add("edi:]"); - illegalQNames.add("edi:\\"); - illegalQNames.add("edi:/"); - illegalQNames.add("edi:;"); - illegalQNames.add("edi:`"); - illegalQNames.add("edi:<"); - illegalQNames.add("edi:>"); - illegalQNames.add("edi:,"); - illegalQNames.add("edi:a "); - illegalQNames.add("edi:\""); - - doc = (Document) load("staffNS", false); - for (int indexN1009A = 0; indexN1009A < illegalQNames.size(); indexN1009A++) { - qualifiedName = (String) illegalQNames.get(indexN1009A); - domImpl = doc.getImplementation(); - - { - boolean success = false; - try { - docType = domImpl.createDocumentType(qualifiedName, publicId, systemId); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocumentType02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createDocumentType02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocumentType03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocumentType03.java deleted file mode 100644 index 277733106..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocumentType03.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createDocumentType(qualifiedName,publicId,systemId)" method for a - * DOMImplementation should return a new DocumentType node - * given that qualifiedName is valid and correctly formed. - * - * Invoke method createDocumentType(qualifiedName,publicId,systemId) on - * this domimplementation with qualifiedName "prefix:myDoc". - * Method should return a new DocumentType node. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocType -*/ -public final class createDocumentType03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createDocumentType03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://ecommerce.org/schema"; - String qualifiedName = "prefix:myDoc"; - String publicId = "http://www.localhost.com"; - String systemId = "myDoc.dtd"; - Document doc; - DOMImplementation domImpl; - DocumentType newType = null; - - String nodeName; - String nodeValue; - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - newType = domImpl.createDocumentType(qualifiedName, publicId, systemId); - nodeName = newType.getNodeName(); - assertEquals("nodeName", "prefix:myDoc", nodeName); - nodeValue = newType.getNodeValue(); - assertNull("nodeValue", nodeValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocumentType03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createDocumentType03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocumentType04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocumentType04.java deleted file mode 100644 index c69a08bd3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createDocumentType04.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * DOMImplementation.createDocumentType with an empty name should cause an INVALID_CHARACTER_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocType -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('Level-2-Core-DOM-createDocType')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525 -*/ -public final class createDocumentType04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - */ - public createDocumentType04(final DOMTestDocumentBuilderFactory factory) { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String publicId = "http://www.example.com/"; - String systemId = "myDoc.dtd"; - String qualifiedName; - DocumentType docType = null; - - DOMImplementation domImpl; - domImpl = getImplementation(); - - { - boolean success = false; - try { - docType = domImpl.createDocumentType("", publicId, systemId); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocumentType04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createDocumentType04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS01.java deleted file mode 100644 index 6b59b44af..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS01.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createElementNS(namespaceURI,qualifiedName)" method for a - * Document should raise NAMESPACE_ERR DOMException if - * qualifiedName is malformed. - * - * Invoke method createElementNS(namespaceURI,qualifiedName) on - * the XMLNS Document with namespaceURI being the literal string - * "http://www.ecommerce.org/", and qualifiedName as "prefix::local". - * Method should raise NAMESPACE_ERR DOMException. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrElNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-DocCrElNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR']) -*/ -public final class createElementNS01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createElementNS01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.ecommerce.org/"; - String malformedName = "prefix::local"; - Document doc; - Element newElement; - doc = (Document) load("staffNS", false); - - { - boolean success = false; - try { - newElement = doc.createElementNS(namespaceURI, malformedName); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createElementNS01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createElementNS01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS02.java deleted file mode 100644 index a2c26a78e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS02.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createElementNS(namespaceURI,qualifiedName)" method for a - * Document should raise NAMESPACE_ERR DOMException if - * qualifiedName has a prefix and namespaceURI is null. - * - * Invoke method createElementNS(namespaceURI,qualifiedName) on this document - * with namespaceURI being null and qualifiedName being "elem:attr1". - * Method should raise NAMESPACE_ERR DOMException. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrElNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-DocCrElNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR']) -*/ -public final class createElementNS02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createElementNS02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = null; - - String qualifiedName = "prefix:local"; - Document doc; - Element newElement; - doc = (Document) load("staffNS", false); - - { - boolean success = false; - try { - newElement = doc.createElementNS(namespaceURI, qualifiedName); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createElementNS02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createElementNS02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS03.java deleted file mode 100644 index fe503b30c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS03.java +++ /dev/null @@ -1,134 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createElementNS(namespaceURI,qualifiedName)" method for a - * Document should raise INVALID_CHARACTER_ERR DOMException if - * qualifiedName contains an illegal character. - * - * Invoke method createElementNS(namespaceURI,qualifiedName) on this document - * with qualifiedName containing an illegal character from illegalChars[]. - * Method should raise INVALID_CHARACTER_ERR DOMException for all characters - * in illegalChars[]. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrElNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-DocCrElNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -*/ -public final class createElementNS03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createElementNS03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.wedding.com/"; - String qualifiedName; - Document doc; - boolean done; - Element newElement; - String charact; - java.util.List illegalQNames = new java.util.ArrayList(); - illegalQNames.add("person:{"); - illegalQNames.add("person:}"); - illegalQNames.add("person:~"); - illegalQNames.add("person:'"); - illegalQNames.add("person:!"); - illegalQNames.add("person:@"); - illegalQNames.add("person:#"); - illegalQNames.add("person:$"); - illegalQNames.add("person:%"); - illegalQNames.add("person:^"); - illegalQNames.add("person:&"); - illegalQNames.add("person:*"); - illegalQNames.add("person:("); - illegalQNames.add("person:)"); - illegalQNames.add("person:+"); - illegalQNames.add("person:="); - illegalQNames.add("person:["); - illegalQNames.add("person:]"); - illegalQNames.add("person:\\"); - illegalQNames.add("person:/"); - illegalQNames.add("person:;"); - illegalQNames.add("person:`"); - illegalQNames.add("person:<"); - illegalQNames.add("person:>"); - illegalQNames.add("person:,"); - illegalQNames.add("person:a "); - illegalQNames.add("person:\""); - - doc = (Document) load("staffNS", false); - for (int indexN10098 = 0; indexN10098 < illegalQNames.size(); indexN10098++) { - qualifiedName = (String) illegalQNames.get(indexN10098); - - { - boolean success = false; - try { - newElement = doc.createElementNS(namespaceURI, qualifiedName); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createElementNS03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createElementNS03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS04.java deleted file mode 100644 index b54d1826b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS04.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createElementNS(namespaceURI,qualifiedName") method for - * a Document should raise NAMESPACE_ERR DOMException if the - * qualifiedName has an "xml" prefix and the namespaceURI is different - * from http://www.w3.org/XML/1998/namespace". - * - * Invoke method createElementNS(namespaceURI,qualifiedName) on this document - * with qualifiedName being "xml:element1" and namespaceURI equals the string - * "http://www.w3.org/XML/1997/namespace" (which differs from the required - * string "http://www.w3.org/XML/1998/namespace"). - * Method should raise NAMESPACE_ERR DOMException. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrElNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-DocCrElNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR']) -*/ -public final class createElementNS04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createElementNS04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.w3.org/XML/1998/namespaces"; - String qualifiedName = "xml:element1"; - Document doc; - Element newElement; - doc = (Document) load("staffNS", false); - - { - boolean success = false; - try { - newElement = doc.createElementNS(namespaceURI, qualifiedName); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createElementNS04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createElementNS04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS05.java deleted file mode 100644 index 33ff00c24..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS05.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "createElementNS(namespaceURI,qualifiedName)" method for a - * Document should return a new Element object given that all parameters - * are valid and correctly formed. - * - * Invoke method createElementNS(namespaceURI,qualifiedName on this document - * with namespaceURI as "http://www.nist.gov" and qualifiedName as "gov:faculty". - * Method should return a new Element object whose name is "gov:faculty". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-104682815 -*/ -public final class createElementNS05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createElementNS05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.nist.gov"; - String qualifiedName = "gov:faculty"; - Document doc; - Element newElement; - String elementName; - doc = (Document) load("staffNS", false); - newElement = doc.createElementNS(namespaceURI, qualifiedName); - elementName = newElement.getTagName(); - assertEquals("throw_Equals", qualifiedName, elementName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createElementNS05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createElementNS05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS06.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS06.java deleted file mode 100644 index e4744f374..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/createElementNS06.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Document.createElementNS with an empty qualified name should cause an INVALID_CHARACTER_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrElNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-DocCrElNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525 -*/ -public final class createElementNS06 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public createElementNS06(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.example.com/"; - String qualifiedName; - Document doc; - boolean done; - Element newElement; - String charact; - doc = (Document) load("hc_staff", true); - - { - boolean success = false; - try { - newElement = doc.createElementNS(namespaceURI, ""); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createElementNS06"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(createElementNS06.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS01.java deleted file mode 100644 index 1bb6da160..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS01.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method createAttributeNS creates an attribute of the given qualified name and namespace URI - * - * Invoke the createAttributeNS method on this Document object with a null - * namespaceURI, and a qualifiedName without a prefix. This should return a valid Attr - * node object. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrAttrNS -*/ -public final class documentcreateattributeNS01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreateattributeNS01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr attribute; - String namespaceURI = null; - - String qualifiedName = "test"; - String name; - String nodeName; - String nodeValue; - doc = (Document) load("staffNS", false); - attribute = doc.createAttributeNS(namespaceURI, qualifiedName); - nodeName = attribute.getNodeName(); - nodeValue = attribute.getNodeValue(); - assertEquals("documentcreateattributeNS01", "test", nodeName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateattributeNS01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreateattributeNS01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS02.java deleted file mode 100644 index 8582ff31d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS02.java +++ /dev/null @@ -1,111 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method createAttributeNS creates an attribute of the given qualified name and namespace URI - * - * Invoke the createAttributeNS method on this Document object with a valid values for - * namespaceURI, and a qualifiedName as below. This should return a valid Attr node. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrAttrNS -*/ -public final class documentcreateattributeNS02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreateattributeNS02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr attribute1; - Attr attribute2; - String name; - String nodeName; - String nodeValue; - String prefix; - String namespaceURI; - doc = (Document) load("staffNS", false); - attribute1 = doc.createAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:xml"); - name = attribute1.getName(); - nodeName = attribute1.getNodeName(); - nodeValue = attribute1.getNodeValue(); - prefix = attribute1.getPrefix(); - namespaceURI = attribute1.getNamespaceURI(); - assertEquals("documentcreateattributeNS02_att1_name", "xml:xml", name); - assertEquals("documentcreateattributeNS02_att1_nodeName", "xml:xml", nodeName); - assertEquals("documentcreateattributeNS02_att1_nodeValue", "", nodeValue); - assertEquals("documentcreateattributeNS02_att1_prefix", "xml", prefix); - assertEquals("documentcreateattributeNS02_att1_namespaceURI", "http://www.w3.org/XML/1998/namespace", namespaceURI); - attribute2 = doc.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns"); - name = attribute2.getName(); - nodeName = attribute2.getNodeName(); - nodeValue = attribute2.getNodeValue(); - prefix = attribute2.getPrefix(); - namespaceURI = attribute2.getNamespaceURI(); - assertEquals("documentcreateattributeNS02_att2_name", "xmlns", name); - assertEquals("documentcreateattributeNS02_att2_nodeName", "xmlns", nodeName); - assertEquals("documentcreateattributeNS02_att2_nodeValue", "", nodeValue); - assertEquals("documentcreateattributeNS02_att2_namespaceURI", "http://www.w3.org/2000/xmlns/", namespaceURI); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateattributeNS02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreateattributeNS02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS03.java deleted file mode 100644 index 8f457b049..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS03.java +++ /dev/null @@ -1,125 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method createAttributeNS raises an INVALID_CHARACTER_ERR if the specified - * qualified name contains an illegal character - * - * Invoke the createAttributeNS method on this Document object with a valid value for - * namespaceURI, and qualifiedNames that contain illegal characters. Check if the an - * INVALID_CHARACTER_ERR was thrown. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrAttrNS -*/ -public final class documentcreateattributeNS03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreateattributeNS03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr attribute; - String namespaceURI = "http://www.w3.org/DOM/Test/Level2"; - String qualifiedName; - java.util.List qualifiedNames = new java.util.ArrayList(); - qualifiedNames.add("/"); - qualifiedNames.add("//"); - qualifiedNames.add("\\"); - qualifiedNames.add(";"); - qualifiedNames.add("&"); - qualifiedNames.add("*"); - qualifiedNames.add("]]"); - qualifiedNames.add(">"); - qualifiedNames.add("<"); - - doc = (Document) load("staffNS", false); - for (int indexN1005A = 0; indexN1005A < qualifiedNames.size(); indexN1005A++) { - qualifiedName = (String) qualifiedNames.get(indexN1005A); - - { - boolean success = false; - try { - attribute = doc.createAttributeNS(namespaceURI, qualifiedName); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("documentcreateattributeNS03", success); - } - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateattributeNS03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreateattributeNS03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS04.java deleted file mode 100644 index bc7b32321..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS04.java +++ /dev/null @@ -1,120 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method createAttributeNS raises a NAMESPACE_ERR if the specified qualified name - * is malformed. - * - * Invoke the createAttributeNS method on this Document object with a valid value for - * namespaceURI, and malformed qualifiedNames. Check if the a NAMESPACE_ERR was thrown. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrAttrNS -*/ -public final class documentcreateattributeNS04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreateattributeNS04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr attribute; - String namespaceURI = "http://www.w3.org/DOM/Test/Level2"; - String qualifiedName; - java.util.List qualifiedNames = new java.util.ArrayList(); - qualifiedNames.add("_:"); - qualifiedNames.add(":0a"); - qualifiedNames.add(":"); - qualifiedNames.add("a:b:c"); - qualifiedNames.add("_::a"); - - doc = (Document) load("staffNS", false); - for (int indexN1004E = 0; indexN1004E < qualifiedNames.size(); indexN1004E++) { - qualifiedName = (String) qualifiedNames.get(indexN1004E); - - { - boolean success = false; - try { - attribute = doc.createAttributeNS(namespaceURI, qualifiedName); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("documentcreateattributeNS04", success); - } - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateattributeNS04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreateattributeNS04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS05.java deleted file mode 100644 index 7eecea33d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS05.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method createAttributeNS raises a NAMESPACE_ERR if the qualifiedName has a prefix and - * the namespaceURI is null. - * - * Invoke the createAttributeNS method on a new Document object with a null value for - * namespaceURI, and a valid qualifiedName. Check if a NAMESPACE_ERR is thrown. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrAttrNS -*/ -public final class documentcreateattributeNS05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreateattributeNS05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document newDoc; - DocumentType docType = null; - - DOMImplementation domImpl; - Attr attribute; - String namespaceURI = null; - - String qualifiedName = "abc:def"; - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - newDoc = domImpl.createDocument("http://www.w3.org/DOM/Test", "dom:doc", docType); - - { - boolean success = false; - try { - attribute = newDoc.createAttributeNS(namespaceURI, qualifiedName); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("documentcreateattributeNS05", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateattributeNS05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreateattributeNS05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS06.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS06.java deleted file mode 100644 index 8f4780114..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS06.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method createAttributeNS raises a NAMESPACE_ERR if the qualifiedName has a prefix that - * is "xml" and the namespaceURI is different from "http://www.w3.org/XML/1998/namespace". - * - * Invoke the createAttributeNS method on a new DOMImplementation object with the qualifiedName - * as xml:root and namespaceURI as http://www.w3.org/XML/1998 /namespace. - * Check if the NAMESPACE_ERR exception is thrown. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrAttrNS -*/ -public final class documentcreateattributeNS06 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreateattributeNS06(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document newDoc; - DocumentType docType = null; - - DOMImplementation domImpl; - Attr attribute; - String namespaceURI = "http://www.w3.org/XML/1998 /namespace"; - String qualifiedName = "xml:root"; - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - newDoc = domImpl.createDocument("http://www.w3.org/DOM/Test", "dom:doc", docType); - - { - boolean success = false; - try { - attribute = newDoc.createAttributeNS(namespaceURI, qualifiedName); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("documentcreateattributeNS06", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateattributeNS06"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreateattributeNS06.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS07.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS07.java deleted file mode 100644 index 399479784..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateattributeNS07.java +++ /dev/null @@ -1,111 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method createAttributeNS raises a NAMESPACE_ERR if the qualifiedName is xmlns and - * the namespaceURI is different from http://www.w3.org/2000/xmlns - * - * Invoke the createAttributeNS method on this DOMImplementation object with - * the qualifiedName as xmlns and namespaceURI as http://www.W3.org/2000/xmlns. - * Check if the NAMESPACE_ERR exception is thrown. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrAttrNS -*/ -public final class documentcreateattributeNS07 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreateattributeNS07(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr attribute; - String namespaceURI = "http://www.W3.org/2000/xmlns"; - String qualifiedName = "xmlns"; - doc = (Document) load("staffNS", false); - - { - boolean success = false; - try { - attribute = doc.createAttributeNS(namespaceURI, qualifiedName); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("documentcreateattributeNS07", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateattributeNS07"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreateattributeNS07.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateelementNS01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateelementNS01.java deleted file mode 100644 index e0319411f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateelementNS01.java +++ /dev/null @@ -1,115 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method createElementNS creates an element of the given valid qualifiedName and NamespaceURI. - * - * Invoke the createElementNS method on this Document object with a valid namespaceURI - * and qualifiedName. Check if a valid Element object is returned with the same node attributes. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrElNS -*/ -public final class documentcreateelementNS01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreateelementNS01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - String namespaceURI = "http://www.w3.org/DOM/Test/level2"; - String qualifiedName = "XML:XML"; - String nodeName; - String nsURI; - String localName; - String prefix; - String tagName; - doc = (Document) load("staffNS", false); - element = doc.createElementNS(namespaceURI, qualifiedName); - nodeName = element.getNodeName(); - nsURI = element.getNamespaceURI(); - localName = element.getLocalName(); - prefix = element.getPrefix(); - tagName = element.getTagName(); - assertEquals("documentcreateelementNS01_nodeName", "XML:XML", nodeName); - assertEquals("documentcreateelementNS01_namespaceURI", "http://www.w3.org/DOM/Test/level2", nsURI); - assertEquals("documentcreateelementNS01_localName", "XML", localName); - assertEquals("documentcreateelementNS01_prefix", "XML", prefix); - assertEquals("documentcreateelementNS01_tagName", "XML:XML", tagName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateelementNS01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreateelementNS01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateelementNS02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateelementNS02.java deleted file mode 100644 index b6cedb229..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateelementNS02.java +++ /dev/null @@ -1,110 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method createElementNS creates an element of the given valid qualifiedName and NamespaceURI. - * - * Invoke the createElementNS method on this Document object with null values for namespaceURI, - * and a qualifiedName with an invalid character and check if an INVALID_CHARACTER_ERR is thrown. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrElNS -*/ -public final class documentcreateelementNS02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreateelementNS02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - String namespaceURI = null; - - String qualifiedName = "^^"; - doc = (Document) load("staffNS", false); - - { - boolean success = false; - try { - element = doc.createElementNS(namespaceURI, qualifiedName); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("documentcreateelementNS02", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateelementNS02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreateelementNS02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateelementNS05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateelementNS05.java deleted file mode 100644 index f01150f6f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateelementNS05.java +++ /dev/null @@ -1,111 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method createElementNS raises a NAMESPACE_ERR if the qualifiedName has a prefix and - * the namespaceURI is null. - * - * Invoke the createElementNS method on a new Document object with a null value for - * namespaceURI, and a valid qualifiedName. Check if a NAMESPACE_ERR is thrown. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrElNS -*/ -public final class documentcreateelementNS05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreateelementNS05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - String namespaceURI = null; - - String qualifiedName = "null:xml"; - doc = (Document) load("staffNS", false); - - { - boolean success = false; - try { - element = doc.createElementNS(namespaceURI, qualifiedName); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("documentcreateelementNS05", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateelementNS05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreateelementNS05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateelementNS06.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateelementNS06.java deleted file mode 100644 index 42e3935c4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentcreateelementNS06.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method createElementNS raises a NAMESPACE_ERR if the qualifiedName - * has a prefix that is "xml" and the namespaceURI is different - * from http://www.w3.org/XML/1998/namespace - * - * Invoke the createElementNS method on this DOMImplementation object with - * the qualifiedName as xml:root and namespaceURI as http://www.w3.org/xml/1998/namespace - * Check if the NAMESPACE_ERR exception is thrown. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-DocCrElNS -*/ -public final class documentcreateelementNS06 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentcreateelementNS06(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document newDoc; - DocumentType docType = null; - - DOMImplementation domImpl; - Element element; - String namespaceURI = "http://www.w3.org/xml/1998/namespace "; - String qualifiedName = "xml:root"; - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - newDoc = domImpl.createDocument("http://www.w3.org/DOM/Test", "dom:doc", docType); - - { - boolean success = false; - try { - element = newDoc.createElementNS(namespaceURI, qualifiedName); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("documentcreateelementNS06", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateelementNS06"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentcreateelementNS06.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementbyid01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementbyid01.java deleted file mode 100644 index 472fa47dd..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementbyid01.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getElementById returns the element whose ID is given by elementId. - * If not such element exists, returns null. - * - * Invoke the getElementById method on this Document object with an invalid elementId. - * This should return a null element. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBId -*/ -public final class documentgetelementbyid01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentgetelementbyid01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - String elementId = "---"; - doc = (Document) load("staffNS", false); - element = doc.getElementById(elementId); - assertNull("documentgetelementbyid01", element); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentgetelementbyid01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentgetelementbyid01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS01.java deleted file mode 100644 index 88320dced..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS01.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getElementsByTagNameNS returns a NodeList of all the Elements with - * a given local name and namespace URI in the order in which they are encountered - * in a preorder traversal of the Document tree. - * - * Invoke the getElementsByTagNameNS method on a new Document object with the values of - * namespaceURI=* and localName=*. This should return a nodeList of 1 item. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBTNNS -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class documentgetelementsbytagnameNS01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentgetelementsbytagnameNS01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document newDoc; - DocumentType docType = null; - - DOMImplementation domImpl; - NodeList childList; - String nullNS = null; - - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - newDoc = domImpl.createDocument(nullNS, "root", docType); - childList = newDoc.getElementsByTagNameNS("*", "*"); - assertSize("documentgetelementsbytagnameNS01", 1, childList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentgetelementsbytagnameNS01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentgetelementsbytagnameNS01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS02.java deleted file mode 100644 index 10b72888d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS02.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getElementsByTagNameNS returns a NodeList of all the Elements with - * a given local name and namespace URI in the order in which they are encountered - * in a preorder traversal of the Document tree. - * - * - * Create a new element having a local name="employeeId" belonging to the namespace "test" - * and append it to this document. Invoke the getElementsByTagNameNS method on a this - * Document object with the values of namespaceURI=* and localName="elementId". This - * should return a nodeList of 6 item. Check the length of the nodeList returned. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBTNNS -*/ -public final class documentgetelementsbytagnameNS02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentgetelementsbytagnameNS02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element docElem; - Element element; - NodeList childList; - Node appendedChild; - doc = (Document) load("staffNS", true); - docElem = doc.getDocumentElement(); - element = doc.createElementNS("test", "employeeId"); - appendedChild = docElem.appendChild(element); - childList = doc.getElementsByTagNameNS("*", "employeeId"); - assertSize("documentgetelementsbytagnameNS02", 6, childList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentgetelementsbytagnameNS02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentgetelementsbytagnameNS02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS03.java deleted file mode 100644 index 27fc7f43d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS03.java +++ /dev/null @@ -1,88 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getElementsByTagNameNS returns a NodeList of all the Elements with - * a given local name and namespace URI in the order in which they are encountered - * in a preorder traversal of the Document tree. - * - * Invoke the getElementsByTagNameNS method on a new Document object with the values of - * namespaceURI=** and localName=**. This should return a nodeList of 0 items. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBTNNS -*/ -public final class documentgetelementsbytagnameNS03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentgetelementsbytagnameNS03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList childList; - doc = (Document) load("staffNS", false); - childList = doc.getElementsByTagNameNS("**", "*"); - assertSize("documentgetelementsbytagnameNS03", 0, childList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentgetelementsbytagnameNS03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentgetelementsbytagnameNS03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS04.java deleted file mode 100644 index 1349037f6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS04.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getElementsByTagNameNS returns a NodeList of all the Elements with - * a given local name and namespace URI in the order in which they are encountered - * in a preorder traversal of the Document tree. - * - * Invoke the getElementsByTagNameNS method on a new Document object with the values of - * namespaceURI="null" and localName="0". This should return a nodeList of 0 items. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBTNNS -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class documentgetelementsbytagnameNS04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentgetelementsbytagnameNS04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList childList; - String nullNS = null; - - doc = (Document) load("staffNS", false); - childList = doc.getElementsByTagNameNS(nullNS, "0"); - assertSize("documentgetelementsbytagnameNS04", 0, childList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentgetelementsbytagnameNS04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentgetelementsbytagnameNS04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS05.java deleted file mode 100644 index 1adadd40c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentgetelementsbytagnameNS05.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getElementsByTagNameNS returns a NodeList of all the Elements with - * a given local name and namespace URI in the order in which they are encountered - * in a preorder traversal of the Document tree. - * - * - * Invoke the getElementsByTagNameNS method on a this Document object with the - * values of namespaceURI=null and localName="elementId". This - * should return a nodeList of 0 item. Check the length of the nodeList returned. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBTNNS -*/ -public final class documentgetelementsbytagnameNS05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentgetelementsbytagnameNS05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList childList; - doc = (Document) load("staffNS", false); - childList = doc.getElementsByTagNameNS("null", "elementId"); - assertSize("documentgetelementsbytagnameNS05", 0, childList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentgetelementsbytagnameNS05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentgetelementsbytagnameNS05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode01.java deleted file mode 100644 index 63e49291f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode01.java +++ /dev/null @@ -1,111 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * The returned node has no parent; (parentNode is null). The source node is not - * altered or removed from the original document but a new copy of the source node - * is created. - * - * Using the method importNode with deep=true, import the attribute, "street" of the second - * element node, from a list of nodes whose local names are "address" and namespaceURI - * "http://www.nist.gov" into the same document. Check the parentNode, nodeName, - * nodeType and nodeValue of the imported node to verify if it has been imported correctly. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class documentimportnode01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - Attr attr; - NodeList childList; - Node importedAttr; - String nodeName; - int nodeType; - String nodeValue; - doc = (Document) load("staffNS", true); - childList = doc.getElementsByTagNameNS("http://www.nist.gov", "address"); - element = (Element) childList.item(1); - attr = element.getAttributeNode("street"); - importedAttr = doc.importNode(attr, false); - nodeName = importedAttr.getNodeName(); - nodeValue = importedAttr.getNodeValue(); - nodeType = (int) importedAttr.getNodeType(); - assertEquals("documentimportnode01_nodeName", "street", nodeName); - assertEquals("documentimportnode01_nodeType", 2, nodeType); - assertEquals("documentimportnode01_nodeValue", "Yes", nodeValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode02.java deleted file mode 100644 index 693d725c4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode02.java +++ /dev/null @@ -1,117 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * The returned node has no parent; (parentNode is null). The source node is not - * altered or removed from the original document but a new copy of the source node - * is created. - * - * Using the method importNode with deep=false, import the attribute, "emp:zone" of the - * element node which is retreived by its elementId="CANADA", into the another document. - * Check the parentNode, nodeName, nodeType and nodeValue of the imported node to - * verify if it has been imported correctly. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class documentimportnode02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document docImported; - Element element; - Attr attr; - Node importedAttr; - String nodeName; - int nodeType; - String nodeValue; - NodeList addresses; - Node attrsParent; - doc = (Document) load("staffNS", true); - docImported = (Document) load("staff", true); - addresses = doc.getElementsByTagNameNS("http://www.nist.gov", "address"); - element = (Element) addresses.item(1); - attr = element.getAttributeNodeNS("http://www.nist.gov", "zone"); - importedAttr = docImported.importNode(attr, false); - nodeName = importedAttr.getNodeName(); - nodeType = (int) importedAttr.getNodeType(); - nodeValue = importedAttr.getNodeValue(); - attrsParent = importedAttr.getParentNode(); - assertNull("documentimportnode02_parentNull", attrsParent); - assertEquals("documentimportnode02_nodeName", "emp:zone", nodeName); - assertEquals("documentimportnode02_nodeType", 2, nodeType); - assertEquals("documentimportnode02_nodeValue", "CANADA", nodeValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode03.java deleted file mode 100644 index 6cdb98df4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode03.java +++ /dev/null @@ -1,113 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * The returned node has no parent; (parentNode is null). The source node is not - * altered or removed from the original document but a new copy of the source node - * is created. - * - * Using the method importNode with deep=false, import the default Attribute attribute, - * "defaultAttr" of the second element node whose namespaceURI="http://www.nist.gov" and - * localName="defaultAttr", into the same document. - * Check the parentNode, nodeName, nodeType and nodeValue of the imported node to - * verify if it has been imported correctly. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class documentimportnode03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware, -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - Attr attr; - NodeList childList; - Node importedAttr; - String nodeName; - int nodeType; - String nodeValue; - doc = (Document) load("staffNS", true); - childList = doc.getElementsByTagNameNS("http://www.nist.gov", "employee"); - element = (Element) childList.item(1); - attr = element.getAttributeNode("defaultAttr"); - importedAttr = doc.importNode(attr, false); - nodeName = importedAttr.getNodeName(); - nodeValue = importedAttr.getNodeValue(); - nodeType = (int) importedAttr.getNodeType(); - assertEquals("documentimportnode03_nodeName", "defaultAttr", nodeName); - assertEquals("documentimportnode03_nodeType", 2, nodeType); - assertEquals("documentimportnode03_nodeValue", "defaultVal", nodeValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode04.java deleted file mode 100644 index a74cfc121..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode04.java +++ /dev/null @@ -1,119 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * The returned node has no parent; (parentNode is null). The source node is not - * altered or removed from the original document but a new copy of the source node - * is created. - * - * Using the method importNode with deep=true, import the default Attribute attribute, - * "defaultAttr" of the second element node whose namespaceURI="http://www.nist.gov" and - * localName="defaultAttr", into a new document. - * Check the parentNode, nodeName, nodeType and nodeValue of the imported node to - * verify if it has been imported correctly. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class documentimportnode04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware, -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document newDoc; - DocumentType docType = null; - - DOMImplementation domImpl; - Element element; - Attr attr; - NodeList childList; - Node importedAttr; - String nodeName; - int nodeType; - String nodeValue; - doc = (Document) load("staffNS", true); - domImpl = doc.getImplementation(); - newDoc = domImpl.createDocument("http://www.w3.org/DOM/Test", "l2:root", docType); - childList = doc.getElementsByTagNameNS("http://www.nist.gov", "employee"); - element = (Element) childList.item(1); - attr = element.getAttributeNode("defaultAttr"); - importedAttr = newDoc.importNode(attr, true); - nodeName = importedAttr.getNodeName(); - nodeValue = importedAttr.getNodeValue(); - nodeType = (int) importedAttr.getNodeType(); - assertEquals("documentimportnode04_nodeName", "defaultAttr", nodeName); - assertEquals("documentimportnode04_nodeType", 2, nodeType); - assertEquals("documentimportnode04_nodeValue", "defaultVal", nodeValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode05.java deleted file mode 100644 index ba2e9e16c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode05.java +++ /dev/null @@ -1,113 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * The returned node has no parent; (parentNode is null). The source node is not - * altered or removed from the original document but a new copy of the source node - * is created. - * - * Using the method importNode with deep=false, import a newly created attribute node, - * into the another document. - * Check the nodeName, nodeType and nodeValue namespaceURI of the imported node to - * verify if it has been imported correctly. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class documentimportnode05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document docImported; - Attr attr; - Node importedAttr; - String nodeName; - int nodeType; - String nodeValue; - String namespaceURI; - doc = (Document) load("staffNS", true); - docImported = (Document) load("staff", true); - attr = doc.createAttributeNS("http://www.w3.org/DOM/Test", "a_:b0"); - importedAttr = docImported.importNode(attr, false); - nodeName = importedAttr.getNodeName(); - nodeValue = importedAttr.getNodeValue(); - nodeType = (int) importedAttr.getNodeType(); - namespaceURI = importedAttr.getNamespaceURI(); - assertEquals("documentimportnode05_nodeName", "a_:b0", nodeName); - assertEquals("documentimportnode05_nodeType", 2, nodeType); - assertEquals("documentimportnode05_nodeValue", "", nodeValue); - assertEquals("documentimportnode05_namespaceURI", "http://www.w3.org/DOM/Test", namespaceURI); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode06.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode06.java deleted file mode 100644 index 3e7e228ea..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode06.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * A NOT_SUPPORTED_ERR is raised if the type of node being imported is - * not supported - * - * Using the method importNode with deep=false, try to import this document object to itself. - * Since Document nodes cannot be imported, a NOT_SUPPORTED_ERR should be raised. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class documentimportnode06 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode06(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document docImported; - doc = (Document) load("staffNS", true); - - { - boolean success = false; - try { - docImported = (Document) doc.importNode(doc, false); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_SUPPORTED_ERR); - } - assertTrue("throw_NOT_SUPPORTED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode06"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode06.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode07.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode07.java deleted file mode 100644 index 01ffd60c6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode07.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * A NOT_SUPPORTED_ERR is raised if the type of node being imported is - * not supported - * - * Using the method importNode with deep=true, try to import this Document's - * DocumentType object. Since DocumentType nodes cannot be imported, a - * NOT_SUPPORTED_ERR should be raised. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class documentimportnode07 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode07(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node imported; - DocumentType docType; - doc = (Document) load("staffNS", true); - docType = doc.getDoctype(); - - { - boolean success = false; - try { - imported = doc.importNode(docType, true); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_SUPPORTED_ERR); - } - assertTrue("throw_NOT_SUPPORTED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode07"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode07.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode08.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode08.java deleted file mode 100644 index 15c7d1f52..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode08.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * A NOT_SUPPORTED_ERR is raised if the type of node being imported is - * not supported - * - * Using the method importNode with deep=true, try to import a newly created DOcumentType - * node. Since DocumentType nodes cannot be imported, a NOT_SUPPORTED_ERR should be raised. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class documentimportnode08 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode08(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node imported; - DocumentType docType; - DOMImplementation domImpl; - String nullNS = null; - - doc = (Document) load("staffNS", true); - domImpl = doc.getImplementation(); - docType = domImpl.createDocumentType("test:root", nullNS, nullNS); - - { - boolean success = false; - try { - imported = doc.importNode(docType, true); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_SUPPORTED_ERR); - } - assertTrue("throw_NOT_SUPPORTED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode08"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode08.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode09.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode09.java deleted file mode 100644 index fefe8add2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode09.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * The returned node has no parent; (parentNode is null). The source node is not - * altered or removed from the original document but a new copy of the source node - * is created. - * - * Using the method importNode with deep=false, import a newly created DocumentFragment node - * with the first address element from this Document appended to it into this document. - * Since deep=false, an empty DocumentFragment should be returned -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class documentimportnode09 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode09(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentFragment docFragment; - NodeList childList; - boolean success; - Node addressNode; - Node appendedChild; - Node importedDocFrag; - doc = (Document) load("staffNS", true); - docFragment = doc.createDocumentFragment(); - childList = doc.getElementsByTagNameNS("*", "address"); - addressNode = childList.item(0); - appendedChild = docFragment.appendChild(addressNode); - importedDocFrag = doc.importNode(docFragment, false); - success = importedDocFrag.hasChildNodes(); - assertFalse("documentimportnode09", success); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode09"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode09.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode10.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode10.java deleted file mode 100644 index c9c5202c7..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode10.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * The returned node has no parent; (parentNode is null). The source node is not - * altered or removed from the original document but a new copy of the source node - * is created. - * - * Using the method importNode with deep=false, import a newly created DocumentFragment node - * with the first address element from this Document appended to it into this document. - * Since deep=true, a DocumentFragment with its child should be returned -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class documentimportnode10 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode10(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentFragment docFragment; - NodeList childList; - boolean success; - Node addressNode; - Node appendedChild; - Node importedDocFrag; - doc = (Document) load("staffNS", true); - docFragment = doc.createDocumentFragment(); - childList = doc.getElementsByTagNameNS("*", "address"); - addressNode = childList.item(0); - appendedChild = docFragment.appendChild(addressNode); - importedDocFrag = doc.importNode(docFragment, true); - success = importedDocFrag.hasChildNodes(); - assertTrue("documentimportnode10", success); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode10"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode10.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode11.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode11.java deleted file mode 100644 index d3c91463a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode11.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * The returned node has no parent; (parentNode is null). The source node is not - * altered or removed from the original document but a new copy of the source node - * is created. - * - * Using the method importNode with deep=false, import this Document's documentElement - * node. Verify if the node has been imported correctly by its nodeName atttribute and - * if the original document is not altered by checking if hasChildNodes returns false. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class documentimportnode11 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode11(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element docElement; - Node imported; - boolean success; - String nodeNameOrig; - String nodeNameImported; - doc = (Document) load("staffNS", true); - docElement = doc.getDocumentElement(); - imported = doc.importNode(docElement, false); - success = imported.hasChildNodes(); - assertFalse("documentimportnode11", success); -nodeNameImported = imported.getNodeName(); - nodeNameOrig = docElement.getNodeName(); - assertEquals("documentimportnode11_NodeName", nodeNameImported, nodeNameOrig); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode11"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode11.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode12.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode12.java deleted file mode 100644 index f698b0dd2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode12.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * The returned node has no parent; (parentNode is null). The source node is not - * altered or removed from the original document but a new copy of the source node - * is created. - * - * Using the method importNode with deep=true, import the first address element node of this - * Document. Verify if the node has been imported correctly by checking the length of the - * this elements childNode list before and after the import. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class documentimportnode12 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode12(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList childList; - Node imported; - Node addressElem; - NodeList addressElemChildren; - NodeList importedChildren; - int addressElemLen; - int importedLen; - doc = (Document) load("staffNS", true); - childList = doc.getElementsByTagNameNS("*", "address"); - addressElem = childList.item(0); - imported = doc.importNode(addressElem, true); - addressElemChildren = addressElem.getChildNodes(); - importedChildren = imported.getChildNodes(); - addressElemLen = (int) addressElemChildren.getLength(); - importedLen = (int) importedChildren.getLength(); - assertEquals("documentimportnode12", importedLen, addressElemLen); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode12"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode12.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode13.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode13.java deleted file mode 100644 index 1e534dff3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode13.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * The returned node has no parent; (parentNode is null). The source node is not - * altered or removed from the original document but a new copy of the source node - * is created. - * - * Using the method importNode with deep=false, import the first employee element node of this - * Document. Verify if the node has been imported correctly by checking the length of the - * this elements childNode list before and after the import. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class documentimportnode13 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode13(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList childList; - Node imported; - NodeList importedList; - Node employeeElem; - int importedLen; - doc = (Document) load("staffNS", true); - childList = doc.getElementsByTagNameNS("*", "employee"); - employeeElem = childList.item(0); - imported = doc.importNode(employeeElem, false); - importedList = imported.getChildNodes(); - importedLen = (int) importedList.getLength(); - assertEquals("documentimportnode13", 0, importedLen); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode13"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode13.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode14.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode14.java deleted file mode 100644 index 0ab0a444d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode14.java +++ /dev/null @@ -1,111 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Using the method importNode with deep=true, import the fourth employee element node of this - * Document. Verify if the node has been imported correctly by checking - * if the default attribute present on this node has not been imported - * and an explicit attribute has been imported. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=402 -*/ -public final class documentimportnode14 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode14(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document newDoc; - DOMImplementation domImpl; - DocumentType nullDocType = null; - - NodeList childList; - Node imported; - Node employeeElem; - Attr attrNode; - String attrValue; - String nullNS = null; - - doc = (Document) load("staffNS", true); - childList = doc.getElementsByTagNameNS("*", "employee"); - employeeElem = childList.item(3); - domImpl = getImplementation(); - newDoc = domImpl.createDocument(nullNS, "staff", nullDocType); - imported = newDoc.importNode(employeeElem, true); - attrNode = ((Element) /*Node */imported).getAttributeNodeNS(nullNS, "defaultAttr"); - assertNull("defaultAttrNotImported", attrNode); - attrValue = ((Element) /*Node */imported).getAttributeNS("http://www.w3.org/2000/xmlns/", "emp"); - assertEquals("explicitAttrImported", "http://www.nist.gov", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode14"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode14.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode15.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode15.java deleted file mode 100644 index 9d2680465..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode15.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * The returned node has no parent; (parentNode is null). The source node is not - * altered or removed from the original document but a new copy of the source node - * is created. - * - * Using the method importNode with deep=true, import a newly created Text node for this - * Document. Verify if the node has been imported correctly by checking the value of the - * imported text node. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class documentimportnode15 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode15(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document docImp; - Node textImport; - Node textToImport; - String nodeValue; - doc = (Document) load("staffNS", true); - docImp = (Document) load("staffNS", true); - textToImport = doc.createTextNode("Document.importNode test for a TEXT_NODE"); - textImport = doc.importNode(textToImport, true); - nodeValue = textImport.getNodeValue(); - assertEquals("documentimportnode15", "Document.importNode test for a TEXT_NODE", nodeValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode15"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode15.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode17.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode17.java deleted file mode 100644 index ae57411ad..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode17.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * The returned node has no parent; (parentNode is null). The source node is not - * altered or removed from the original document but a new copy of the source node - * is created. - * - * Using the method importNode with deep=true, import a newly created Comment node for this - * Document. Verify if the node has been imported correctly by checking the value of the - * imported Comment node. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class documentimportnode17 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode17(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document docImp; - Node commentImport; - Node commentToImport; - String nodeValue; - doc = (Document) load("staffNS", true); - docImp = (Document) load("staffNS", true); - commentToImport = doc.createComment("Document.importNode test for a COMMENT_NODE"); - commentImport = doc.importNode(commentToImport, true); - nodeValue = commentImport.getNodeValue(); - assertEquals("documentimportnode17", "Document.importNode test for a COMMENT_NODE", nodeValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode17"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode17.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode18.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode18.java deleted file mode 100644 index dcb9c09f7..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode18.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * The returned node has no parent; (parentNode is null). The source node is not - * altered or removed from the original document but a new copy of the source node - * is created. - * - * Using the method importNode with deep=true, import a newly created PI node for this - * Document. Verify if the node has been imported correctly by checking the PITarget and - * PIData values of the imported PI node. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class documentimportnode18 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode18(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document docImp; - ProcessingInstruction piImport; - ProcessingInstruction piToImport; - String piData; - String piTarget; - doc = (Document) load("staffNS", true); - docImp = (Document) load("staffNS", true); - piToImport = doc.createProcessingInstruction("Target", "Data"); - piImport = (ProcessingInstruction) doc.importNode(piToImport, false); - piTarget = piImport.getTarget(); - piData = piImport.getData(); - assertEquals("documentimportnode18_Target", "Target", piTarget); - assertEquals("documentimportnode18_Data", "Data", piData); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode18"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode18.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode19.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode19.java deleted file mode 100644 index 3be355b0c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode19.java +++ /dev/null @@ -1,136 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * The returned node has no parent; (parentNode is null). The source node is not - * altered or removed from the original document but a new copy of the source node - * is created. - * - * Using the method importNode with deep=true/false, import a entity nodes ent2 and ent6 - * from this document to a new document object. Verify if the nodes have been - * imported correctly by checking the nodeNames of the imported nodes and public and system ids. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class documentimportnode19 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode19(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docTypeNull = null; - - Document docImp; - DOMImplementation domImpl; - DocumentType docType; - NamedNodeMap nodeMap; - Entity entity2; - Entity entity6; - Entity entityImp2; - Entity entityImp6; - String nodeName; - String systemId; - String notationName; - String nodeNameImp; - String systemIdImp; - String notationNameImp; - doc = (Document) load("staffNS", true); - domImpl = doc.getImplementation(); - docType = doc.getDoctype(); - docImp = domImpl.createDocument("http://www.w3.org/DOM/Test", "a:b", docTypeNull); - nodeMap = docType.getEntities(); - assertNotNull("entitiesNotNull", nodeMap); - entity2 = (Entity) nodeMap.getNamedItem("ent2"); - entity6 = (Entity) nodeMap.getNamedItem("ent6"); - entityImp2 = (Entity) docImp.importNode(entity2, false); - entityImp6 = (Entity) docImp.importNode(entity6, true); - nodeName = entity2.getNodeName(); - nodeNameImp = entityImp2.getNodeName(); - assertEquals("documentimportnode19_Ent2NodeName", nodeName, nodeNameImp); - nodeName = entity6.getNodeName(); - nodeNameImp = entityImp6.getNodeName(); - assertEquals("documentimportnode19_Ent6NodeName", nodeName, nodeNameImp); - systemId = entity2.getSystemId(); - systemIdImp = entityImp2.getSystemId(); - assertEquals("documentimportnode19_Ent2SystemId", systemId, systemIdImp); - systemId = entity6.getSystemId(); - systemIdImp = entityImp6.getSystemId(); - assertEquals("documentimportnode19_Ent6SystemId", systemId, systemIdImp); - notationName = entity2.getNotationName(); - notationNameImp = entityImp2.getNotationName(); - assertEquals("documentimportnode19_Ent2NotationName", notationName, notationNameImp); - notationName = entity6.getNotationName(); - notationNameImp = entityImp6.getNotationName(); - assertEquals("documentimportnode19_Ent6NotationName", notationName, notationNameImp); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode19"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode19.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode20.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode20.java deleted file mode 100644 index bb7771374..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode20.java +++ /dev/null @@ -1,134 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * The returned node has no parent; (parentNode is null). The source node is not - * altered or removed from the original document but a new copy of the source node - * is created. - * - * Using the method importNode with deep=true, import a entity node ent4 - * from this document to a new document object. The replacement text of this entity is an element - * node, a cdata node and a pi. Verify if the nodes have been - * imported correctly by checking the nodeNames of the imported element node, the data for the - * cdata nodes and the PItarget and PIData for the pi nodes. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class documentimportnode20 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode20(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware, -org.w3c.domts.DocumentBuilderSetting.notExpandEntityReferences - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document docImp; - DOMImplementation domImpl; - DocumentType docType; - DocumentType docTypeNull = null; - - NamedNodeMap nodeMap; - Entity entity4; - Entity entityImp4; - Element element; - CharacterData cdata; - ProcessingInstruction pi; - NodeList childList; - NodeList elemchildList; - String ent4Name; - String ent4ImpName; - String cdataVal; - String piTargetVal; - String piDataVal; - doc = (Document) load("staffNS", true); - domImpl = doc.getImplementation(); - docType = doc.getDoctype(); - docImp = domImpl.createDocument("http://www.w3.org/DOM/Test", "a:b", docTypeNull); - nodeMap = docType.getEntities(); - entity4 = (Entity) nodeMap.getNamedItem("ent4"); - entityImp4 = (Entity) docImp.importNode(entity4, true); - childList = entityImp4.getChildNodes(); - element = (Element) childList.item(0); - elemchildList = element.getChildNodes(); - cdata = (CharacterData) elemchildList.item(0); - pi = (ProcessingInstruction) childList.item(1); - ent4Name = entity4.getNodeName(); - ent4ImpName = entityImp4.getNodeName(); - cdataVal = cdata.getData(); - piTargetVal = pi.getTarget(); - piDataVal = pi.getData(); - assertEquals("documentimportnode20_Ent4NodeName", ent4Name, ent4ImpName); - assertEquals("documentimportnode20_Cdata", "Element data", cdataVal); - assertEquals("documentimportnode20_PITarget", "PItarget", piTargetVal); - assertEquals("documentimportnode20_PIData", "PIdata", piDataVal); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode20"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode20.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode21.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode21.java deleted file mode 100644 index 9aeccf32c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode21.java +++ /dev/null @@ -1,144 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * The returned node has no parent; (parentNode is null). The source node is not - * altered or removed from the original document but a new copy of the source node - * is created. - * - * Using the method importNode with deep=true, retreive the entity refs present in the - * second element node whose tagName is address and import these nodes into another document. - * Verify if the nodes have been imported correctly by checking the nodeNames of the - * imported nodes, since they are imported into a new document which doesnot have thes defined, - * the imported nodes should not have any children. - * Now import the entityRef nodes into the same document and verify if the nodes have been - * imported correctly by checking the nodeNames of the imported nodes, and by checking the - * value of the replacement text of the imported nodes. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class documentimportnode21 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode21(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware, -org.w3c.domts.DocumentBuilderSetting.notExpandEntityReferences - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docTypeNull = null; - - Document docImp; - DOMImplementation domImpl; - NodeList addressList; - NodeList addressChildList; - Element element; - EntityReference entRef2; - EntityReference entRefImp2; - EntityReference entRef3; - EntityReference entRefImp3; - String nodeName2; - String nodeName3; - String nodeNameImp2; - String nodeNameImp3; - NodeList nodes; - Node nodeImp3; - Node nodeImp2; - String nodeValueImp2; - String nodeValueImp3; - doc = (Document) load("staffNS", true); - domImpl = doc.getImplementation(); - docImp = domImpl.createDocument("http://www.w3.org/DOM/Test", "a:b", docTypeNull); - addressList = doc.getElementsByTagName("address"); - element = (Element) addressList.item(1); - addressChildList = element.getChildNodes(); - entRef2 = (EntityReference) addressChildList.item(0); - entRef3 = (EntityReference) addressChildList.item(2); - entRefImp2 = (EntityReference) docImp.importNode(entRef2, true); - entRefImp3 = (EntityReference) docImp.importNode(entRef3, false); - nodeName2 = entRef2.getNodeName(); - nodeName3 = entRef3.getNodeName(); - nodeNameImp2 = entRefImp2.getNodeName(); - nodeNameImp3 = entRefImp3.getNodeName(); - assertEquals("documentimportnode21_Ent2NodeName", nodeName2, nodeNameImp2); - assertEquals("documentimportnode21_Ent3NodeName", nodeName3, nodeNameImp3); - entRefImp2 = (EntityReference) doc.importNode(entRef2, true); - entRefImp3 = (EntityReference) doc.importNode(entRef3, false); - nodes = entRefImp2.getChildNodes(); - nodeImp2 = nodes.item(0); - nodeValueImp2 = nodeImp2.getNodeValue(); - nodes = entRefImp3.getChildNodes(); - nodeImp3 = nodes.item(0); - nodeValueImp3 = nodeImp3.getNodeValue(); - assertEquals("documentimportnode21_Ent2NodeValue", "1900 Dallas Road", nodeValueImp2); - assertEquals("documentimportnode21_Ent3Nodevalue", "Texas", nodeValueImp3); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode21"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode21.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode22.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode22.java deleted file mode 100644 index 0ce897729..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documentimportnode22.java +++ /dev/null @@ -1,144 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The importNode method imports a node from another document to this document. - * The returned node has no parent; (parentNode is null). The source node is not - * altered or removed from the original document but a new copy of the source node - * is created. - * - * Using the method importNode with deep=true/false, import two notaiton nodes into the - * same and different documnet objects. In each case check if valid public and systemids - * are returned if any and if none, check if a null value was returned. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class documentimportnode22 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documentimportnode22(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docTypeNull = null; - - Document docImp; - DOMImplementation domImpl; - DocumentType docType; - NamedNodeMap nodeMap; - Notation notation1; - Notation notation2; - Notation notationImp1; - Notation notationImp2; - Notation notationImpNew1; - Notation notationImpNew2; - String publicId1; - String publicId1Imp; - String publicId1NewImp; - String publicId2Imp; - String publicId2NewImp; - String systemId1Imp; - String systemId1NewImp; - String systemId2; - String systemId2Imp; - String systemId2NewImp; - doc = (Document) load("staffNS", true); - domImpl = doc.getImplementation(); - docType = doc.getDoctype(); - docImp = domImpl.createDocument("http://www.w3.org/DOM/Test", "a:b", docTypeNull); - nodeMap = docType.getNotations(); - assertNotNull("notationsNotNull", nodeMap); - notation1 = (Notation) nodeMap.getNamedItem("notation1"); - notation2 = (Notation) nodeMap.getNamedItem("notation2"); - notationImp1 = (Notation) doc.importNode(notation1, true); - notationImp2 = (Notation) doc.importNode(notation2, false); - notationImpNew1 = (Notation) docImp.importNode(notation1, false); - notationImpNew2 = (Notation) docImp.importNode(notation2, true); - publicId1 = notation1.getPublicId(); - publicId1Imp = notation1.getPublicId(); - publicId1NewImp = notation1.getPublicId(); - systemId1Imp = notation1.getSystemId(); - systemId1NewImp = notation1.getSystemId(); - publicId2Imp = notation2.getPublicId(); - publicId2NewImp = notation2.getPublicId(); - systemId2 = notation2.getSystemId(); - systemId2Imp = notation2.getSystemId(); - systemId2NewImp = notation2.getSystemId(); - assertEquals("documentimportnode22_N1PID", publicId1, publicId1Imp); - assertEquals("documentimportnode22_N1NPID", publicId1, publicId1NewImp); - assertNull("documentimportnode22_N1SID", systemId1Imp); - assertNull("documentimportnode22_N1NSID", systemId1NewImp); - assertEquals("documentimportnode22_N2SID", systemId2, systemId2Imp); - assertEquals("documentimportnode22_N2NSID", systemId2, systemId2NewImp); - assertNull("documentimportnode22_N2PID", publicId2Imp); - assertNull("documentimportnode22_N2NPID", publicId2Imp); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode22"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documentimportnode22.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documenttypeinternalSubset01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documenttypeinternalSubset01.java deleted file mode 100644 index 043241116..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documenttypeinternalSubset01.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getInternalSubset() returns the internal subset as a string. - * - * Create a new DocumentType node with null values for publicId and systemId. - * Verify that its internal subset is null. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-Core-DocType-internalSubset -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class documenttypeinternalSubset01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documenttypeinternalSubset01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - DOMImplementation domImpl; - String internal; - String nullNS = null; - - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - docType = domImpl.createDocumentType("l2:root", nullNS, nullNS); - internal = docType.getInternalSubset(); - assertNull("internalSubsetNull", internal); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documenttypeinternalSubset01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documenttypeinternalSubset01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documenttypepublicid01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documenttypepublicid01.java deleted file mode 100644 index 47834cde2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documenttypepublicid01.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getInternalSubset() returns the public identifier of the external subset. - * - * Create a new DocumentType node with the value "PUB" for its publicId. - * Check the value of the publicId attribute using getPublicId(). -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-Core-DocType-publicId -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class documenttypepublicid01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documenttypepublicid01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - DOMImplementation domImpl; - String publicId; - String nullNS = null; - - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - docType = domImpl.createDocumentType("l2:root", "PUB", nullNS); - publicId = docType.getPublicId(); - assertEquals("documenttypepublicid01", "PUB", publicId); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documenttypepublicid01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documenttypepublicid01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documenttypesystemid01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/documenttypesystemid01.java deleted file mode 100644 index f266bf5ab..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/documenttypesystemid01.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getInternalSubset() returns the public identifier of the external subset. - * - * Create a new DocumentType node with the value "SYS" for its systemId and PUB for - * its publicId. Check the value of the systemId and pbulicId attributes. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-Core-DocType-systemId -*/ -public final class documenttypesystemid01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public documenttypesystemid01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - DOMImplementation domImpl; - String publicId; - String systemId; - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - docType = domImpl.createDocumentType("l2:root", "PUB", "SYS"); - publicId = docType.getPublicId(); - systemId = docType.getSystemId(); - assertEquals("documenttypepublicid01", "PUB", publicId); - assertEquals("documenttypesystemid01", "SYS", systemId); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documenttypesystemid01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(documenttypesystemid01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocument03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocument03.java deleted file mode 100644 index 740e9a8a8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocument03.java +++ /dev/null @@ -1,127 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The createDocument method with valid arguments, should create a DOM Document of - * the specified type. - * - * Call the createDocument on this DOMImplementation with - * createDocument ("http://www.w3.org/DOMTest/L2",see the array below for valid QNames,null). - * Check if the returned Document object is is empty with no Document Element. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocument -*/ -public final class domimplementationcreatedocument03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public domimplementationcreatedocument03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation domImpl; - Document newDoc; - DocumentType docType = null; - - String namespaceURI = "http://www.w3.org/DOMTest/L2"; - String qualifiedName; - java.util.List qualifiedNames = new java.util.ArrayList(); - qualifiedNames.add("_:_"); - qualifiedNames.add("_:h0"); - qualifiedNames.add("_:test"); - qualifiedNames.add("l_:_"); - qualifiedNames.add("ns:_0"); - qualifiedNames.add("ns:a0"); - qualifiedNames.add("ns0:test"); - qualifiedNames.add("a.b:c"); - qualifiedNames.add("a-b:c"); - qualifiedNames.add("a-b:c"); - - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - for (int indexN1006B = 0; indexN1006B < qualifiedNames.size(); indexN1006B++) { - qualifiedName = (String) qualifiedNames.get(indexN1006B); - newDoc = domImpl.createDocument(namespaceURI, qualifiedName, docType); - assertNotNull("domimplementationcreatedocument03", newDoc); - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationcreatedocument03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(domimplementationcreatedocument03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocument04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocument04.java deleted file mode 100644 index de24aef4c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocument04.java +++ /dev/null @@ -1,116 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The createDocument method should throw a NAMESPACE_ERR if the qualifiedName has - * a prefix and the namespaceURI is null. - * - * Call the createDocument on this DOMImplementation with null namespaceURI and a - * qualifiedName that has a namespace prefix using this DOMImplementation. - * Check if the NAMESPACE_ERR is thrown. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocument -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocument -*/ -public final class domimplementationcreatedocument04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public domimplementationcreatedocument04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation domImpl; - Document newDoc; - String namespaceURI = null; - - String qualifiedName = "dom:root"; - DocumentType docType = null; - - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - - { - boolean success = false; - try { - newDoc = domImpl.createDocument(namespaceURI, qualifiedName, docType); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("domimplementationcreatedocument04", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationcreatedocument04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(domimplementationcreatedocument04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocument05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocument05.java deleted file mode 100644 index 0efee487a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocument05.java +++ /dev/null @@ -1,115 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The createDocument method should throw a NAMESPACE_ERR if the qualifiedName has - * a prefix that is xml and the namespaceURI is different from - * http://www..w3.org/XML/1998/namespace. - * - * Call the createDocument on this DOMImplementation with namespaceURI that is - * http://www.w3.org/xml/1998/namespace and a qualifiedName that has the prefix xml - * Check if the NAMESPACE_ERR is thrown. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocument -*/ -public final class domimplementationcreatedocument05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public domimplementationcreatedocument05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation domImpl; - Document newDoc; - String namespaceURI = "http://www.w3.org/xml/1998/namespace"; - String qualifiedName = "xml:root"; - DocumentType docType = null; - - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - - { - boolean success = false; - try { - newDoc = domImpl.createDocument(namespaceURI, qualifiedName, docType); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("domimplementationcreatedocument05", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationcreatedocument05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(domimplementationcreatedocument05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocument07.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocument07.java deleted file mode 100644 index 46a47cd5a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocument07.java +++ /dev/null @@ -1,112 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The createDocument method should raise a NAMESPACE_ERR if the qualifiedName is malformed - * - * Invoke the createDocument method on this DOMImplementation object with null values - * for namespaceURI and docType and a malformed qualifiedName. - * The NAMESPACE_ERR should be raised. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocument -*/ -public final class domimplementationcreatedocument07 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public domimplementationcreatedocument07(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation domImpl; - Document newDoc; - String namespaceURI = "http://www.w3.org/DOMTest/level2"; - DocumentType docType = null; - - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - - { - boolean success = false; - try { - newDoc = domImpl.createDocument(namespaceURI, ":", docType); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("domimplementationcreatedocument07", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationcreatedocument07"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(domimplementationcreatedocument07.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocumenttype01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocumenttype01.java deleted file mode 100644 index 99f1a63f3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocumenttype01.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method createDocumentType with valid values for qualifiedName, publicId and - * systemId should create an empty DocumentType node. - * - * Invoke createDocument on this DOMImplementation with a valid qualifiedName and different - * publicIds and systemIds. Check if the the DocumentType node was created with its - * ownerDocument attribute set to null. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocument -*/ -public final class domimplementationcreatedocumenttype01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public domimplementationcreatedocumenttype01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation domImpl; - DocumentType newDocType; - Document ownerDocument; - String qualifiedName = "test:root"; - String publicId; - String systemId; - java.util.List publicIds = new java.util.ArrayList(); - publicIds.add("1234"); - publicIds.add("test"); - - java.util.List systemIds = new java.util.ArrayList(); - systemIds.add(""); - systemIds.add("test"); - - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - for (int indexN1005D = 0; indexN1005D < publicIds.size(); indexN1005D++) { - publicId = (String) publicIds.get(indexN1005D); - for (int indexN10061 = 0; indexN10061 < systemIds.size(); indexN10061++) { - systemId = (String) systemIds.get(indexN10061); - newDocType = domImpl.createDocumentType(qualifiedName, publicId, systemId); - assertNotNull("domimplementationcreatedocumenttype01_newDocType", newDocType); - ownerDocument = newDocType.getOwnerDocument(); - assertNull("domimplementationcreatedocumenttype01_ownerDocument", ownerDocument); - } - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationcreatedocumenttype01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(domimplementationcreatedocumenttype01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocumenttype02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocumenttype02.java deleted file mode 100644 index 5962bfa7a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocumenttype02.java +++ /dev/null @@ -1,127 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method createDocumentType with valid values for qualifiedName, publicId and - * systemId should create an empty DocumentType node. - * - * Invoke createDocument on this DOMImplementation with a different valid qualifiedNames - * and a valid publicId and systemId. Check if the the DocumentType node was created - * with its ownerDocument attribute set to null. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocType -*/ -public final class domimplementationcreatedocumenttype02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public domimplementationcreatedocumenttype02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation domImpl; - DocumentType newDocType; - Document ownerDocument; - String publicId = "http://www.w3.org/DOM/Test/dom2.dtd"; - String systemId = "dom2.dtd"; - String qualifiedName; - java.util.List qualifiedNames = new java.util.ArrayList(); - qualifiedNames.add("_:_"); - qualifiedNames.add("_:h0"); - qualifiedNames.add("_:test"); - qualifiedNames.add("_:_."); - qualifiedNames.add("_:a-"); - qualifiedNames.add("l_:_"); - qualifiedNames.add("ns:_0"); - qualifiedNames.add("ns:a0"); - qualifiedNames.add("ns0:test"); - qualifiedNames.add("ns:EEE."); - qualifiedNames.add("ns:_-"); - qualifiedNames.add("a.b:c"); - qualifiedNames.add("a-b:c.j"); - qualifiedNames.add("a-b:c"); - - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - for (int indexN10077 = 0; indexN10077 < qualifiedNames.size(); indexN10077++) { - qualifiedName = (String) qualifiedNames.get(indexN10077); - newDocType = domImpl.createDocumentType(qualifiedName, publicId, systemId); - assertNotNull("domimplementationcreatedocumenttype02_newDocType", newDocType); - ownerDocument = newDocType.getOwnerDocument(); - assertNull("domimplementationcreatedocumenttype02_ownerDocument", ownerDocument); - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationcreatedocumenttype02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(domimplementationcreatedocumenttype02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocumenttype04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocumenttype04.java deleted file mode 100644 index ae0084c3e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationcreatedocumenttype04.java +++ /dev/null @@ -1,131 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method createDocumentType should raise a INVALID_CHARACTER_ERR if the qualifiedName - * contains an illegal characters. - * - * Invoke createDocument on this DOMImplementation with qualifiedNames having illegal characters. - * Check if an INVALID_CHARACTER_ERR is raised in each case. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocType -*/ -public final class domimplementationcreatedocumenttype04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public domimplementationcreatedocumenttype04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation domImpl; - DocumentType newDocType; - String publicId = "http://www.w3.org/DOM/Test/dom2.dtd"; - String systemId = "dom2.dtd"; - String qualifiedName; - java.util.List qualifiedNames = new java.util.ArrayList(); - qualifiedNames.add("{"); - qualifiedNames.add("}"); - qualifiedNames.add("'"); - qualifiedNames.add("~"); - qualifiedNames.add("`"); - qualifiedNames.add("@"); - qualifiedNames.add("#"); - qualifiedNames.add("$"); - qualifiedNames.add("%"); - qualifiedNames.add("^"); - qualifiedNames.add("&"); - qualifiedNames.add("*"); - qualifiedNames.add("("); - qualifiedNames.add(")"); - - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - for (int indexN10073 = 0; indexN10073 < qualifiedNames.size(); indexN10073++) { - qualifiedName = (String) qualifiedNames.get(indexN10073); - - { - boolean success = false; - try { - newDocType = domImpl.createDocumentType(qualifiedName, publicId, systemId); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("domimplementationcreatedocumenttype04", success); - } - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationcreatedocumenttype04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(domimplementationcreatedocumenttype04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationfeaturecore.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationfeaturecore.java deleted file mode 100644 index 6a299f069..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationfeaturecore.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "feature" parameter in the - * "hasFeature(feature,version)" method is the package name - * of the feature. Legal values are XML and HTML and CORE. - * (Test for feature core, lower case) - * - * Retrieve the entire DOM document and invoke its - * "getImplementation()" method. This should create a - * DOMImplementation object whose "hasFeature(feature, - * version)" method is invoked with feature equal to "core". - * The method should return a boolean "true". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-5CED94D7 -*/ -public final class domimplementationfeaturecore extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public domimplementationfeaturecore(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation domImpl; - boolean state; - doc = (Document) load("staff", false); - domImpl = doc.getImplementation(); - state = domImpl.hasFeature("core", "2.0"); -assertTrue("domimplementationFeaturecoreAssert", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationfeaturecore"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(domimplementationfeaturecore.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationfeaturexmlversion2.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationfeaturexmlversion2.java deleted file mode 100644 index 47302cfc5..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationfeaturexmlversion2.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "feature" parameter in the - * "hasFeature(feature,version)" method is the package name - * of the feature. Legal values are XML and HTML. - * (Test for feature "xml" and version "2.0") - * - * Retrieve the entire DOM document and invoke its - * "getImplementation()" method. This should create a - * DOMImplementation object whose "hasFeature(feature, - * version)" method is invoked with "feature" equal to "xml". - * The method should return a boolean "true". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-5CED94D7 -*/ -public final class domimplementationfeaturexmlversion2 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public domimplementationfeaturexmlversion2(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation domImpl; - boolean state; - doc = (Document) load("staff", false); - domImpl = doc.getImplementation(); - state = domImpl.hasFeature("xml", "2.0"); -assertTrue("domimplementationFeaturexmlVersion2Assert", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationfeaturexmlversion2"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(domimplementationfeaturexmlversion2.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationhasfeature01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationhasfeature01.java deleted file mode 100644 index 2174f1baa..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationhasfeature01.java +++ /dev/null @@ -1,116 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method "hasFeature(feature,version)" tests if the DOMImplementation implements - * a specific feature and if so returns true. - * - * Call the hasFeature method on this DOMImplementation with a combination of features - * versions as below. Valid feature names are case insensitive and versions "2.0", - * "1.0" and if the version is not specified, supporting any version of the feature - * should return true. Check if the value returned value was true. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-5CED94D7 -*/ -public final class domimplementationhasfeature01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public domimplementationhasfeature01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation domImpl; - String version = ""; - String version1 = "1.0"; - String version2 = "2.0"; - String featureCore; - String featureXML; - boolean success; - java.util.List featuresXML = new java.util.ArrayList(); - featuresXML.add("XML"); - featuresXML.add("xmL"); - - java.util.List featuresCore = new java.util.ArrayList(); - featuresCore.add("Core"); - featuresCore.add("CORE"); - - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - for (int indexN10063 = 0; indexN10063 < featuresXML.size(); indexN10063++) { - featureXML = (String) featuresXML.get(indexN10063); - success = domImpl.hasFeature(featureXML, version); -assertTrue("domimplementationhasfeature01_XML_1", success); - success = domImpl.hasFeature(featureXML, version1); -assertTrue("domimplementationhasfeature01_XML_2", success); - } - for (int indexN1007C = 0; indexN1007C < featuresCore.size(); indexN1007C++) { - featureCore = (String) featuresCore.get(indexN1007C); - success = domImpl.hasFeature(featureCore, version); -assertTrue("domimplementationhasfeature01_Core_1", success); - success = domImpl.hasFeature(featureCore, version1); -success = domImpl.hasFeature(featureCore, version2); -assertTrue("domimplementationhasfeature01_Core_3", success); - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationhasfeature01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(domimplementationhasfeature01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationhasfeature02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationhasfeature02.java deleted file mode 100644 index 075329902..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/domimplementationhasfeature02.java +++ /dev/null @@ -1,88 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method "hasFeature(feature,version)" tests if the DOMImplementation implements - * a specific feature and if not returns false. - * - * Call the hasFeature method on this DOMImplementation with a unfimiliar values for - * feature and version. Check if the value returned was false. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-5CED94D7 -*/ -public final class domimplementationhasfeature02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public domimplementationhasfeature02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation domImpl; - boolean success; - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - success = domImpl.hasFeature("Blah Blah", ""); -assertFalse("domimplementationhasfeature02", success); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationhasfeature02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(domimplementationhasfeature02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetattributenodens01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetattributenodens01.java deleted file mode 100644 index 286e07d2d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetattributenodens01.java +++ /dev/null @@ -1,115 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getAttributeNodeNS retrieves an Attr node by local name and namespace URI. - * Create a new element node and add 2 new attribute nodes to it that have the same - * local name but different namespaceURIs and prefixes. - * Retrieve an attribute using namespace and localname and check its value, name and - * namespaceURI. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElGetAtNodeNS -*/ -public final class elementgetattributenodens01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementgetattributenodens01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - Attr attribute1; - Attr attribute2; - Attr newAttribute1; - Attr newAttribute2; - Attr attribute; - String attrValue; - String attrName; - String attNodeName; - String attrLocalName; - String attrNS; - doc = (Document) load("staffNS", false); - element = doc.createElementNS("namespaceURI", "root"); - attribute1 = doc.createAttributeNS("http://www.w3.org/DOM/Level2", "l2:att"); - newAttribute1 = element.setAttributeNodeNS(attribute1); - attribute2 = doc.createAttributeNS("http://www.w3.org/DOM/Level1", "att"); - newAttribute2 = element.setAttributeNodeNS(attribute2); - attribute = element.getAttributeNodeNS("http://www.w3.org/DOM/Level2", "att"); - attrValue = attribute.getNodeValue(); - attrName = attribute.getName(); - attNodeName = attribute.getNodeName(); - attrLocalName = attribute.getLocalName(); - attrNS = attribute.getNamespaceURI(); - assertEquals("elementgetattributenodens01_attrValue", "", attrValue); - assertEquals("elementgetattributenodens01_attrName", "l2:att", attrName); - assertEquals("elementgetattributenodens01_attrNodeName", "l2:att", attNodeName); - assertEquals("elementgetattributenodens01_attrLocalName", "att", attrLocalName); - assertEquals("elementgetattributenodens01_attrNs", "http://www.w3.org/DOM/Level2", attrNS); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementgetattributenodens01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementgetattributenodens01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetattributenodens02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetattributenodens02.java deleted file mode 100644 index 0ea6b58ef..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetattributenodens02.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getAttributeNodeNS retrieves an Attr node by local name and namespace URI. - * Create a new element node and add a new attribute node to it. Using the getAttributeNodeNS, - * retrieve the newly added attribute node and check its value. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElGetAtNodeNS -*/ -public final class elementgetattributenodens02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementgetattributenodens02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - Attr attribute; - Attr newAttribute1; - String attrValue; - doc = (Document) load("staffNS", false); - element = doc.createElementNS("namespaceURI", "root"); - attribute = doc.createAttributeNS("http://www.w3.org/DOM/Level2", "l2:att"); - newAttribute1 = element.setAttributeNodeNS(attribute); - attribute = element.getAttributeNodeNS("http://www.w3.org/DOM/Level2", "att"); - attrValue = attribute.getNodeValue(); - assertEquals("elementgetattributenodens02", "", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementgetattributenodens02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementgetattributenodens02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetattributenodens03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetattributenodens03.java deleted file mode 100644 index 00a509341..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetattributenodens03.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getAttributeNodeNS retrieves an Attr node by local name and namespace URI. - * Using the getAttributeNodeNS, retrieve and verify the value of the default - * attribute node. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElGetAtNodeNS -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class elementgetattributenodens03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementgetattributenodens03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware, -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - Attr attribute; - String attrValue; - NodeList childList; - String nullNS = null; - - doc = (Document) load("staffNS", false); - childList = doc.getElementsByTagNameNS("http://www.nist.gov", "employee"); - element = (Element) childList.item(1); - attribute = element.getAttributeNodeNS(nullNS, "defaultAttr"); - attrValue = attribute.getNodeValue(); - assertEquals("elementgetattributenodens03", "defaultVal", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementgetattributenodens03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementgetattributenodens03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetattributens02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetattributens02.java deleted file mode 100644 index 5da336728..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetattributens02.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getAttributeNS retrieves an attribute value by local name and namespace URI. - * Using the getAttributeNodeNS, retreive and verify the value of the default - * attribute node. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElGetAttrNS -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class elementgetattributens02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementgetattributens02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware, -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - String attrValue; - NodeList childList; - String nullNS = null; - - doc = (Document) load("staffNS", false); - childList = doc.getElementsByTagNameNS("http://www.nist.gov", "employee"); - element = (Element) childList.item(1); - attrValue = element.getAttributeNS(nullNS, "defaultAttr"); - assertEquals("elementgetattributens02", "defaultVal", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementgetattributens02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementgetattributens02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetelementsbytagnamens02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetelementsbytagnamens02.java deleted file mode 100644 index 07e16d835..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetelementsbytagnamens02.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getElementsByTagNameNS returns a NodeList of all the Elements with a given local - * name and namespace URI in the order in which they are encountered in a preorder traversal - * of the Document tree. - * Invoke getElementsByTagNameNS on the documentElement with values for namespaceURI '*' and - * localName '*'. Verify if this returns a nodeList of 0 elements. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBTNNS -*/ -public final class elementgetelementsbytagnamens02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementgetelementsbytagnamens02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - NodeList elementList; - doc = (Document) load("staffNS", false); - element = doc.getDocumentElement(); - elementList = element.getElementsByTagNameNS("**", "*"); - assertSize("elementgetelementsbytagnamens02", 0, elementList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementgetelementsbytagnamens02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementgetelementsbytagnamens02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetelementsbytagnamens04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetelementsbytagnamens04.java deleted file mode 100644 index 41a69e1ba..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetelementsbytagnamens04.java +++ /dev/null @@ -1,112 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Returns a NodeList of all the Elements with a given local name and namespace URI in the - * order in which they are encountered in a preorder traversal of the Document tree. - * Create a new element node ('root') and append three newly created child nodes (all have - * local name 'child' and defined in different namespaces). - * Test 1: invoke getElementsByTagNameNS to retrieve one of the children. - * Test 2: invoke getElementsByTagNameNS with the value of namespace equals to '*', and - * verify that the node list has length of 3. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBTNNS -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class elementgetelementsbytagnamens04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementgetelementsbytagnamens04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - Element child1; - Element child2; - Element child3; - Node appendedChild; - NodeList elementList; - String nullNS = null; - - doc = (Document) load("staffNS", false); - element = doc.createElementNS("http://www.w3.org/DOM", "root"); - child1 = doc.createElementNS("http://www.w3.org/DOM/Level1", "dom:child"); - child2 = doc.createElementNS(nullNS, "child"); - child3 = doc.createElementNS("http://www.w3.org/DOM/Level2", "dom:child"); - appendedChild = element.appendChild(child1); - appendedChild = element.appendChild(child2); - appendedChild = element.appendChild(child3); - elementList = element.getElementsByTagNameNS(nullNS, "child"); - assertSize("elementgetelementsbytagnamens04_1", 1, elementList); - elementList = element.getElementsByTagNameNS("*", "child"); - assertSize("elementgetelementsbytagnamens04_2", 3, elementList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementgetelementsbytagnamens04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementgetelementsbytagnamens04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetelementsbytagnamens05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetelementsbytagnamens05.java deleted file mode 100644 index d205f5a33..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementgetelementsbytagnamens05.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Returns a NodeList of all the Elements with a given local name and namespace URI in the - * order in which they are encountered in a preorder traversal of the Document tree. - * Invoke getElementsByTagNameNS on the documentElement with the following values: - * namespaceURI: 'http://www.altavista.com' - * localName: '*'. - * Verify if this returns a nodeList of 1 elements. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBTNNS -*/ -public final class elementgetelementsbytagnamens05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementgetelementsbytagnamens05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - NodeList elementList; - doc = (Document) load("staffNS", false); - element = doc.getDocumentElement(); - elementList = element.getElementsByTagNameNS("http://www.altavista.com", "*"); - assertSize("elementgetelementsbytagnamens05", 1, elementList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementgetelementsbytagnamens05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementgetelementsbytagnamens05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattribute01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattribute01.java deleted file mode 100644 index 167fb3af8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattribute01.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method hasAttribute returns true when an attribute with a given name is specified - * on this element or has a default value, false otherwise - * Invoke the hasAttribute method to check if the documentElement has attributres. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeHasAttrs -*/ -public final class elementhasattribute01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementhasattribute01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.notNamespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - boolean state; - doc = (Document) load("staff", false); - element = doc.getDocumentElement(); - state = element.hasAttribute(""); - assertFalse("elementhasattribute01", state); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementhasattribute01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementhasattribute01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattribute02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattribute02.java deleted file mode 100644 index 762e4de84..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattribute02.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method hasAttribute returns true when an attribute with a given name is specified - * on this element or has a default value, false otherwise - * Invoke the hasAttribute method to on an element with default attributes and verify if it - * returns true. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeHasAttrs -*/ -public final class elementhasattribute02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementhasattribute02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - boolean state; - NodeList elementList; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("emp:employee"); - element = (Element) elementList.item(0); - assertNotNull("empEmployeeNotNull", element); - state = element.hasAttribute("defaultAttr"); - assertTrue("elementhasattribute02", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementhasattribute02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementhasattribute02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattribute03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattribute03.java deleted file mode 100644 index 8877007df..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattribute03.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method hasAttribute returns true when an attribute with a given name is specified - * on this element or has a default value, false otherwise. - * Create an element Node and an attribute Node. Invoke hasAttribute method - * to verify that there is no attribute. Append the attribute node to the element node. - * Invoke the hasAttribute method on the element and verify if it returns true. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeHasAttrs -*/ -public final class elementhasattribute03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementhasattribute03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - boolean state; - Attr attribute; - Attr newAttribute; - doc = (Document) load("staff", false); - element = doc.createElement("address"); - attribute = doc.createAttribute("domestic"); - state = element.hasAttribute("domestic"); - assertFalse("elementhasattribute03_False", state); -newAttribute = element.setAttributeNode(attribute); - state = element.hasAttribute("domestic"); - assertTrue("elementhasattribute03_True", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementhasattribute03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementhasattribute03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattribute04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattribute04.java deleted file mode 100644 index 9d6759020..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattribute04.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method hasAttribute returns true when an attribute with a given name is specified - * on this element or has a default value, false otherwise. - * Create an element Node and an attribute Node and add the attribute node to the element. - * Invoke the hasAttribute method on the element and verify if the method returns true. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeHasAttrs -*/ -public final class elementhasattribute04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementhasattribute04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - boolean state; - Attr attribute; - Attr newAttribute; - doc = (Document) load("staff", false); - element = doc.createElement("address"); - attribute = doc.createAttribute("domestic"); - newAttribute = element.setAttributeNode(attribute); - state = element.hasAttribute("domestic"); - assertTrue("elementhasattribute04", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementhasattribute04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementhasattribute04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattributens01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattributens01.java deleted file mode 100644 index 9bfbc5097..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattributens01.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method hasAttributeNS returns true when an attribute with a given local name - * and namespace - * URI is specified on this element or has a default value, false otherwise. - * - * Retreive the first employee element node. Invoke the hasAttributeNS method to check if it - * has the xmlns attribute that belongs to the namespace http://www.w3.org/2000/xmlns/. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElHasAttrNS -*/ -public final class elementhasattributens01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementhasattributens01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - boolean state; - NodeList elementList; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagNameNS("*", "employee"); - element = (Element) elementList.item(0); - state = element.hasAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns"); - assertTrue("elementhasattributens01", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementhasattributens01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementhasattributens01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattributens02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattributens02.java deleted file mode 100644 index e1a06c2f1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattributens02.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method hasAttributeNS returns true when an attribute with a given local - * name and namespace URI is specified on this element or has a default value, - * false otherwise. - * Create a new element and attribute node that belong to the same namespace. - * Add the attribute node to the element node. Check if the newly created element - * node has an attribute by invoking the hasAttributeNS method with appropriate - * values for the namespaceURI and localName parameters. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElHasAttrNS -*/ -public final class elementhasattributens02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementhasattributens02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - boolean state; - Attr attribute; - Attr newAttribute; - doc = (Document) load("staff", false); - element = doc.createElementNS("http://www.w3.org/DOM", "address"); - attribute = doc.createAttributeNS("http://www.w3.org/DOM", "domestic"); - newAttribute = element.setAttributeNode(attribute); - state = element.hasAttributeNS("http://www.w3.org/DOM", "domestic"); - assertTrue("hasDomesticAttr", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementhasattributens02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementhasattributens02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattributens03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattributens03.java deleted file mode 100644 index b15bd9662..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementhasattributens03.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method hasAttributeNS returns true when an attribute with a given local name - * and namespace URI is specified on this element or has a default value, - * false otherwise. - * - * Create a new element and an attribute node that has an empty namespace. - * Add the attribute node to the element node. Check if the newly created element - * node has an attribute by invoking the hasAttributeNS method with appropriate - * values for the namespaceURI and localName parameters. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElHasAttrNS -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class elementhasattributens03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementhasattributens03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - boolean state; - Attr attribute; - Attr newAttribute; - String nullNS = null; - - doc = (Document) load("staff", false); - element = doc.createElementNS("http://www.w3.org/DOM", "address"); - assertNotNull("createElementNotNull", element); - attribute = doc.createAttributeNS(nullNS, "domestic"); - newAttribute = element.setAttributeNode(attribute); - state = element.hasAttributeNS(nullNS, "domestic"); - assertTrue("elementhasattributens03", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementhasattributens03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementhasattributens03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementremoveattributens01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementremoveattributens01.java deleted file mode 100644 index b6ec27a77..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementremoveattributens01.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method removeAttributeNS removes an attribute by local name and namespace URI. - * Create a new element and add a new attribute node to it. - * Remove the attribute node using the removeAttributeNodeNS method. - * Check if the attribute was remove by invoking the hasAttributeNS - * method on the element and check if it returns false. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElRemAtNS -*/ -public final class elementremoveattributens01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementremoveattributens01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - boolean state; - Attr attribute; - Attr newAttribute; - doc = (Document) load("staff", false); - element = doc.createElementNS("http://www.w3.org/DOM", "elem"); - attribute = doc.createAttributeNS("http://www.w3.org/DOM/Test/createAttributeNS", "attr"); - newAttribute = element.setAttributeNodeNS(attribute); - element.removeAttributeNS("http://www.w3.org/DOM/Test/createAttributeNS", "attr"); - state = element.hasAttributeNS("http://www.w3.org/DOM/Test/createAttributeNS", "attr"); - assertFalse("elementremoveattributens01", state); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementremoveattributens01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementremoveattributens01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens01.java deleted file mode 100644 index 3fc2ee7db..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens01.java +++ /dev/null @@ -1,117 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Testing Element.setAttributeNodeNS: If an attribute with that local name - * and that namespace URI is already present in the element, it is replaced - * by the new one. - * Create a new element and two new attribute nodes (in the same namespace - * and same localNames). - * Add the two new attribute nodes to the element node using the - * setAttributeNodeNS method. Check that only one attribute is added, check - * the value of this attribute. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS -*/ -public final class elementsetattributenodens01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementsetattributenodens01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - Attr attribute1; - Attr attribute2; - Attr attrNode; - String attrName; - String attrNS; - String attrValue; - NamedNodeMap attributes; - Attr newAttribute; - int length; - doc = (Document) load("staff", true); - element = doc.createElementNS("http://www.w3.org/DOM/Test/Level2", "new:element"); - attribute1 = doc.createAttributeNS("http://www.w3.org/DOM/Test/att1", "p1:att"); - attribute2 = doc.createAttributeNS("http://www.w3.org/DOM/Test/att1", "p2:att"); - attribute2.setValue("value2"); - newAttribute = element.setAttributeNodeNS(attribute1); - newAttribute = element.setAttributeNodeNS(attribute2); - attrNode = element.getAttributeNodeNS("http://www.w3.org/DOM/Test/att1", "att"); - attrName = attrNode.getNodeName(); - attrNS = attrNode.getNamespaceURI(); - assertEquals("elementsetattributenodens01_attrName", "p2:att", attrName); - assertEquals("elementsetattributenodens01_attrNS", "http://www.w3.org/DOM/Test/att1", attrNS); - attributes = element.getAttributes(); - length = (int) attributes.getLength(); - assertEquals("length", 1, length); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributenodens01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementsetattributenodens01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens02.java deleted file mode 100644 index f5eed4bf8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens02.java +++ /dev/null @@ -1,110 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Test the setAttributeNodeNS method. - * Retreive the street attribute from the second address element node. - * Clone it and add it to the first address node. The INUSE_ATTRIBUTE_ERR exception - * should not be thrown. Check the name and value of the newly added node. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class elementsetattributenodens02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementsetattributenodens02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - Element element2; - Attr attribute; - Attr attributeCloned; - Attr newAttr; - NodeList elementList; - String attrName; - String attrValue; - String nullNS = null; - - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "address"); - element = (Element) elementList.item(1); - attribute = element.getAttributeNodeNS(nullNS, "street"); - attributeCloned = (Attr) attribute.cloneNode(true); - element2 = (Element) elementList.item(2); - newAttr = element2.setAttributeNodeNS(attributeCloned); - attrName = newAttr.getNodeName(); - attrValue = newAttr.getNodeValue(); - assertEquals("elementsetattributenodens02_attrName", "street", attrName); - assertEquals("elementsetattributenodens02_attrValue", "Yes", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributenodens02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementsetattributenodens02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens03.java deleted file mode 100644 index c51ec2e5a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens03.java +++ /dev/null @@ -1,113 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setAttributeNodeNS adds a new attribute and raises the - * INUSE_ATTRIBUTE_ERR exception if the newAttr is already an attribute of - * another Element object. - * - * Retreive an attribute node of an existing element node. Attempt to add it to an another - * element node. Check if the INUSE_ATTRIBUTE_ERR exception is thrown. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS -*/ -public final class elementsetattributenodens03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementsetattributenodens03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware, -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element1; - Element element2; - Attr attribute; - Attr newAttribute; - NodeList elementList; - String nullNS = null; - - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "address"); - element1 = (Element) elementList.item(1); - attribute = element1.getAttributeNodeNS(nullNS, "street"); - element2 = (Element) elementList.item(2); - - { - boolean success = false; - try { - newAttribute = element2.setAttributeNodeNS(attribute); - } catch (DOMException ex) { - success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR); - } - assertTrue("elementsetattributenodens03", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributenodens03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementsetattributenodens03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens04.java deleted file mode 100644 index 28b142ba6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens04.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setAttributeNodeNS Adds a new attribute and raises an INUSE_ATTRIBUTE_ERR - * if newAttr is already an attribute of another Element object. - * - * Create two new element nodes and a new attribute node. Attempt to add the same attribute - * node to the same two element nodes. - * Check if an INUSE_ATTRIBUTE_ERR is thrown. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS -*/ -public final class elementsetattributenodens04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementsetattributenodens04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element1; - Element element2; - Attr attribute; - Attr newAttribute; - doc = (Document) load("staffNS", true); - element1 = doc.createElementNS("http://www.w3.org/DOM/Test", "elem1"); - element2 = doc.createElementNS("http://www.w3.org/DOM/Test", "elem2"); - attribute = doc.createAttributeNS("http://www.w3.org/DOM/Test", "attr"); - newAttribute = element1.setAttributeNodeNS(attribute); - - { - boolean success = false; - try { - newAttribute = element2.setAttributeNodeNS(attribute); - } catch (DOMException ex) { - success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR); - } - assertTrue("elementsetattributenodens04", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributenodens04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementsetattributenodens04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens05.java deleted file mode 100644 index be1ebbafc..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens05.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setAttributeNodeNS Adds a new attribute and raises - * an WRONG_DOCUMENT_ERR if newAttr was created from a different document - * than the one that created the element. - * Create new element and attribute nodes in different documents. - * Attempt to add the attribute node to the element node. - * Check if an WRONG_DOCUMENT_ERR is thrown. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS -*/ -public final class elementsetattributenodens05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementsetattributenodens05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document docAlt; - Element element; - Attr attribute; - Attr newAttribute; - doc = (Document) load("staffNS", true); - docAlt = (Document) load("staffNS", true); - element = doc.createElementNS("http://www.w3.org/DOM/Test", "elem1"); - attribute = docAlt.createAttributeNS("http://www.w3.org/DOM/Test", "attr"); - - { - boolean success = false; - try { - newAttribute = element.setAttributeNodeNS(attribute); - } catch (DOMException ex) { - success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); - } - assertTrue("throw_WRONG_DOCUMENT_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributenodens05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementsetattributenodens05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens06.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens06.java deleted file mode 100644 index e5d3691b3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributenodens06.java +++ /dev/null @@ -1,114 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setAttributeNodeNS Adds a new attribute and raises an WRONG_DOCUMENT_ERR if this node - * is readonly. - * Attempt to add an attribute node to an element node which is part of the replacement text of - * a read-only EntityReference node. - * Check if a NO_MODIFICATION_ALLOWED_ERR is thrown. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS -*/ -public final class elementsetattributenodens06 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementsetattributenodens06(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.notExpandEntityReferences - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - Attr attribute; - Attr attribute2; - EntityReference entRef; - NodeList elementList; - Node newAttribute; - Node newChild; - doc = (Document) load("staffNS", true); - element = doc.createElementNS("http://www.w3.org/DOM/Test", "elem1"); - attribute = doc.createAttributeNS("http://www.w3.org/DOM/Test", "attr"); - entRef = doc.createEntityReference("ent4"); - newChild = attribute.appendChild(entRef); - newAttribute = element.setAttributeNodeNS(attribute); - elementList = entRef.getChildNodes(); - element = (Element) elementList.item(0); - attribute2 = doc.createAttributeNS("http://www.w3.org/DOM/Test", "attr2"); - - { - boolean success = false; - try { - newAttribute = element.setAttributeNodeNS(attribute2); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("elementsetattributenodens06", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributenodens06"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementsetattributenodens06.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens01.java deleted file mode 100644 index 639454d8b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens01.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setAttributeNS adds a new attribute. - * Create a new element and add a new attribute node to it using the setAttributeNS method. - * Check if the attribute was correctly set by invoking the getAttributeNodeNS method - * and checking the nodeName and nodeValue of the returned nodes. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAttrNS -*/ -public final class elementsetattributens01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementsetattributens01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - Attr attribute; - String attrName; - String attrValue; - doc = (Document) load("staff", true); - element = doc.createElementNS("http://www.w3.org/DOM", "dom:elem"); - element.setAttributeNS("http://www.w3.org/DOM/Test/setAttributeNS", "attr", "value"); - attribute = element.getAttributeNodeNS("http://www.w3.org/DOM/Test/setAttributeNS", "attr"); - attrName = attribute.getNodeName(); - attrValue = attribute.getNodeValue(); - assertEquals("elementsetattributens01_attrName", "attr", attrName); - assertEquals("elementsetattributens01_attrValue", "value", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributens01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementsetattributens01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens02.java deleted file mode 100644 index 030f81b4b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens02.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setAttributeNS adds a new attribute. - * - * Retrieve an existing element node with attributes and add a new attribute node to it using - * the setAttributeNS method. Check if the attribute was correctly set by invoking the - * getAttributeNodeNS method and checking the nodeName and nodeValue of the returned nodes. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAttrNS -*/ -public final class elementsetattributens02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementsetattributens02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - Attr attribute; - NodeList elementList; - String attrName; - String attrValue; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagNameNS("*", "address"); - element = (Element) elementList.item(0); - element.setAttributeNS("http://www.w3.org/DOM/Test/setAttributeNS", "this:street", "Silver Street"); - attribute = element.getAttributeNodeNS("http://www.w3.org/DOM/Test/setAttributeNS", "street"); - attrName = attribute.getNodeName(); - attrValue = attribute.getNodeValue(); - assertEquals("elementsetattributens02_attrName", "this:street", attrName); - assertEquals("elementsetattributens02_attrValue", "Silver Street", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributens02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementsetattributens02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens03.java deleted file mode 100644 index 051ac3ef6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens03.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setAttributeNS adds a new attribute. - * Retreive an existing element node with a default attribute node and - * add two new attribute nodes that have the same local name as the - * default attribute but different namespaceURI to it using the setAttributeNS method. - * Check if the attribute was correctly set by invoking the getAttributeNodeNS method - * and checking the nodeName and nodeValue of the returned nodes. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAttrNS -*/ -public final class elementsetattributens03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementsetattributens03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - Attr attribute; - NodeList elementList; - String attrName; - String attrValue; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("emp:employee"); - element = (Element) elementList.item(0); - assertNotNull("empEmployeeNotNull", element); - element.setAttributeNS("http://www.w3.org/DOM/Test/1", "defaultAttr", "default1"); - element.setAttributeNS("http://www.w3.org/DOM/Test/2", "defaultAttr", "default2"); - attribute = element.getAttributeNodeNS("http://www.w3.org/DOM/Test/1", "defaultAttr"); - attrName = attribute.getNodeName(); - attrValue = attribute.getNodeValue(); - assertEquals("elementsetattributens03_attrName", "defaultAttr", attrName); - assertEquals("elementsetattributens03_attrValue", "default1", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributens03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementsetattributens03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens04.java deleted file mode 100644 index 37bbda024..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens04.java +++ /dev/null @@ -1,111 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setAttributeNS adds a new attribute and raises a INVALID_CHARACTER_ERR if - * the specified qualified name contains an illegal character. - * Invoke the setAttributeNS method on this Element object with a valid value for - * namespaceURI, and qualifiedNames that contain illegal characters. Check if the an - * INVALID_CHARACTER_ERR was thrown. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAttrNS -*/ -public final class elementsetattributens04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementsetattributens04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - String qualifiedName; - java.util.List qualifiedNames = new java.util.ArrayList(); - qualifiedNames.add("/"); - qualifiedNames.add("//"); - qualifiedNames.add("\\"); - qualifiedNames.add(";"); - qualifiedNames.add("&"); - qualifiedNames.add("*"); - qualifiedNames.add("]]"); - qualifiedNames.add(">"); - qualifiedNames.add("<"); - - doc = (Document) load("staffNS", true); - element = doc.createElementNS("http://www.w3.org/DOM/Test/L2", "dom:elem"); - for (int indexN10058 = 0; indexN10058 < qualifiedNames.size(); indexN10058++) { - qualifiedName = (String) qualifiedNames.get(indexN10058); - - { - boolean success = false; - try { - element.setAttributeNS("http://www.w3.org/DOM/Test/L2", qualifiedName, "test"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("elementsetattributens04", success); - } - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributens04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementsetattributens04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens05.java deleted file mode 100644 index 778529b1f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens05.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setAttributeNS adds a new attribute and raises a NAMESPACE_ERR if the - * qualifiedName has a prefix and the namespaceURI is null. - * Invoke the setAttributeNS method on a new Element object with null namespaceURI and a - * qualifiedName that has a namespace prefix. Check if the NAMESPACE_ERR was thrown. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAttrNS -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class elementsetattributens05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementsetattributens05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - String nullNS = null; - - doc = (Document) load("staffNS", true); - element = doc.createElementNS("http://www.w3.org/DOM/Test/L2", "dom:elem"); - - { - boolean success = false; - try { - element.setAttributeNS(nullNS, "dom:root", "test"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("elementsetattributens05", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributens05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementsetattributens05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens08.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens08.java deleted file mode 100644 index 53a4b76b0..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributens08.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setAttributeNS adds a new attribute and raises a NAMESPACE_ERR - * if the qualifiedName, or its prefix, is "xmlns" and the namespaceURI is - * different from "http://www.w3.org/2000/xmlns/". - * - * Invoke the setAttributeNS method on a new Element object with namespaceURI that is - * http://www.w3.org/DOMTest/level2 and a qualifiedName that has the prefix xmlns and once - * again with a qualifiedName that is xmlns. - * Check if the NAMESPACE_ERR was thrown. - * -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAttrNS -*/ -public final class elementsetattributens08 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementsetattributens08(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - doc = (Document) load("staffNS", true); - element = doc.createElementNS("http://www.w3.org/DOMTest/level2", "dom:elem"); - - { - boolean success = false; - try { - element.setAttributeNS("http://www.w3.org/DOMTest/level2", "xmlns", "test"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("elementsetattributens08_Err1", success); - } - - { - boolean success = false; - try { - element.setAttributeNS("http://www.w3.org/DOMTest/level2", "xmlns:root", "test"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("elementsetattributens08_Err2", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributens08"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementsetattributens08.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributensurinull.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributensurinull.java deleted file mode 100644 index 829d9f734..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/elementsetattributensurinull.java +++ /dev/null @@ -1,116 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNS(namespaceURI,qualifiedName,value)" method raises a - * NAMESPACE_ERR DOMException if the specified - * qualifiedName has a prefix and the namespaceURI is null. - * - * Attempt to add a new attribute on the first employee node. - * An exception should be raised since the "qualifiedName" has a - * prefix and the namespaceURI is null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAttrNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-ElSetAttrNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR']) -*/ -public final class elementsetattributensurinull extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public elementsetattributensurinull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = null; - - String qualifiedName = "emp:qualifiedName"; - Document doc; - NodeList elementList; - Node testAddr; - doc = (Document) load("staff", true); - elementList = doc.getElementsByTagName("employee"); - testAddr = elementList.item(0); - - { - boolean success = false; - try { - ((Element) /*Node */testAddr).setAttributeNS(namespaceURI, qualifiedName, "newValue"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributensurinull"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(elementsetattributensurinull.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS01.java deleted file mode 100644 index ba4c0e5ec..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS01.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributeNS(namespaceURI,localName)" method retrieves an - * attribute value by local name and NamespaceURI. - * - * Retrieve the first "emp:address" element. - * The value returned by the "getAttributeNS()" method should be the - * value "DISTRICT" since the attribute has a default value. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElGetAttrNS -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=238 -*/ -public final class getAttributeNS01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getAttributeNS01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware, -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.nist.gov"; - String localName = "district"; - String qualifiedName = "emp:district"; - Document doc; - NodeList elementList; - Element testAddr; - String attrValue; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("emp:address"); - testAddr = (Element) elementList.item(0); - attrValue = testAddr.getAttributeNS(namespaceURI, localName); - assertEquals("attrValue", "DISTRICT", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getAttributeNS01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getAttributeNS01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS02.java deleted file mode 100644 index 0c8d71841..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS02.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributeNS(namespaceURI,localName)" method retrieves an - * attribute value by local name and NamespaceURI. - * - * Retrieve the first "emp:address" element. - * Create a new attribute with the "createAttributeNS()" method. - * Add the new attribute with the "setAttributeNS()" method. - * The value returned by the "getAttributeNS()" method should be the - * empty string since the attribute does not have a default value. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElGetAttrNS -*/ -public final class getAttributeNS02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getAttributeNS02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.nist.gov"; - String localName = "district"; - String qualifiedName = "emp:district"; - Document doc; - Attr newAttribute; - NodeList elementList; - Element testAddr; - Attr districtAttr; - String attrValue; - doc = (Document) load("staffNS", true); - newAttribute = doc.createAttributeNS(namespaceURI, qualifiedName); - elementList = doc.getElementsByTagName("emp:address"); - testAddr = (Element) elementList.item(0); - assertNotNull("empAddrNotNull", testAddr); - districtAttr = testAddr.setAttributeNodeNS(newAttribute); - elementList = doc.getElementsByTagName("emp:address"); - testAddr = (Element) elementList.item(0); - attrValue = testAddr.getAttributeNS(namespaceURI, localName); - assertEquals("throw_Equals", "", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getAttributeNS02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getAttributeNS02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS03.java deleted file mode 100644 index dbbaeb560..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS03.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributeNS(namespaceURI,localName)" method retrieves an - * attribute value by local name and NamespaceURI. - * - * Retrieve the first "emp:address" element. - * The value returned by the "getAttributeNS()" method for the emp:domestic attribute - * should be the empty string since the attribute does not have a specified value - * because it was removed by the "removeAttributeNS()" method. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElGetAttrNS -*/ -public final class getAttributeNS03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getAttributeNS03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.nist.gov"; - String localName = "domestic"; - Document doc; - NodeList elementList; - Element testAddr; - String attrValue; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("emp:address"); - testAddr = (Element) elementList.item(0); - assertNotNull("empAddrNotNull", testAddr); - testAddr.removeAttributeNS(namespaceURI, localName); - attrValue = testAddr.getAttributeNS(namespaceURI, localName); - assertEquals("throw_Equals", "", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getAttributeNS03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getAttributeNS03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS04.java deleted file mode 100644 index 4c9fa064e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS04.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributeNS(namespaceURI,localName)" method retrieves an - * attribute value by local name and NamespaceURI. - * - * Retrieve the first "emp:address" element. - * Create a new attribute with the "createAttributeNS()" method. - * Add the new attribute and value with the "setAttributeNS()" method. - * The value returned by the "getAttributeNS()" method should be - * the string "NewValue" since the attribute had a specified value. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElGetAttrNS -*/ -public final class getAttributeNS04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getAttributeNS04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.nist.gov"; - String localName = "blank"; - String qualifiedName = "emp:blank"; - Document doc; - Attr newAttribute; - NodeList elementList; - Element testAddr; - Attr districtAttr; - String attrValue; - doc = (Document) load("staffNS", true); - newAttribute = doc.createAttributeNS(namespaceURI, qualifiedName); - elementList = doc.getElementsByTagName("emp:address"); - testAddr = (Element) elementList.item(0); - assertNotNull("empAddrNotNull", testAddr); - testAddr.setAttributeNS(namespaceURI, qualifiedName, "NewValue"); - attrValue = testAddr.getAttributeNS(namespaceURI, localName); - assertEquals("throw_Equals", "NewValue", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getAttributeNS04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getAttributeNS04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS05.java deleted file mode 100644 index e424d6b32..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNS05.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributeNS(namespaceURI,localName)" method retrieves an - * attribute value by local name and NamespaceURI. - * - * Retrieve the first emp:address element node - * and retrieve the emp:domestic attribute. The method returns an - * Attr value as a string, the "value" can be examined to ensure the - * proper attribute value was retrieved. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElGetAttrNS -*/ -public final class getAttributeNS05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getAttributeNS05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - String attrValue; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("emp:address"); - testAddr = (Element) elementList.item(0); - assertNotNull("empAddrNotNull", testAddr); - attrValue = testAddr.getAttributeNS("http://www.nist.gov", "domestic"); - assertEquals("attrValue", "Yes", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getAttributeNS05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getAttributeNS05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNodeNS01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNodeNS01.java deleted file mode 100644 index 39bb06c38..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNodeNS01.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributeNodeNS(namespaceURI,localName)" method retrieves an - * attribute node by local name and NamespaceURI. - * - * Retrieve the first emp:address element node. - * The getAttributeNodeNS method returns an - * Attr node, the "value" can be examined to ensure the - * proper attribute node was retrieved. This attribute - * value should be null since there is no such attribute. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElGetAtNodeNS -*/ -public final class getAttributeNodeNS01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getAttributeNodeNS01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.nist.gov"; - String localName = "invalidlocalname"; - Document doc; - NodeList elementList; - Element testAddr; - Attr attribute; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("emp:address"); - testAddr = (Element) elementList.item(0); - assertNotNull("empAddrNotNull", testAddr); - attribute = testAddr.getAttributeNodeNS(namespaceURI, localName); - assertNull("throw_Null", attribute); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getAttributeNodeNS01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getAttributeNodeNS01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNodeNS02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNodeNS02.java deleted file mode 100644 index 6b2325ed0..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getAttributeNodeNS02.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getAttributeNodeNS(namespaceURI,localName)" method retrieves an - * attribute node by local name and NamespaceURI. - * - * Retrieve the first emp:address element node. - * The getAttributeNodeNS method returns an - * Attr node, the "value" can be examined to ensure the - * proper attribute node was retrieved. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-F68D095 -*/ -public final class getAttributeNodeNS02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getAttributeNodeNS02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - Attr attribute; - String attrName; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("emp:address"); - testAddr = (Element) elementList.item(0); - assertNotNull("empAddrNotNull", testAddr); - attribute = testAddr.getAttributeNodeNS("http://www.nist.gov", "domestic"); - attrName = attribute.getNodeName(); - assertEquals("attrName", "emp:domestic", attrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getAttributeNodeNS02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getAttributeNodeNS02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementById01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementById01.java deleted file mode 100644 index dec140c65..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementById01.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementById(elementId)" method for a - * Document should return an element whose ID matches elementId. - * - * Invoke method getElementById(elementId) on this document - * with elementId equals "CANADA". Method should return an element - * whose tag name is "emp:address". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-104682815 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=383 -*/ -public final class getElementById01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getElementById01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - String tagname; - doc = (Document) load("staffNS", false); - element = doc.getElementById("CANADA"); - tagname = element.getTagName(); - assertEquals("throw_Equals", "emp:address", tagname); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementById01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getElementById01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementById02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementById02.java deleted file mode 100644 index c683faca2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementById02.java +++ /dev/null @@ -1,88 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * - * The "getElementById(elementId)" method for a - * Document should return null if elementId does not identify any - * elements in this document. - * - * Invoke method getElementById(elementId) on this document - * with elementId equals "Cancun". Method should return null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBId -*/ -public final class getElementById02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getElementById02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - doc = (Document) load("staffNS", false); - element = doc.getElementById("Cancun"); - assertNull("throw_Null", element); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementById02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getElementById02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS01.java deleted file mode 100644 index 5c751fcc8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS01.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagNameNS(namespaceURI,localName)" method for a - * Document should return a new NodeList of all Elements that have a namespace - * when local name is specified as ' '. - * - * Invoke method getElementsByTagNameNS(namespaceURI,localName) on this document - * with namespaceURI and localName as " ". - * Method should return a new NodeList of 37 elements. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBTNNS -*/ -public final class getElementsByTagNameNS01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getElementsByTagNameNS01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "*"; - String localName = "*"; - Document doc; - NodeList newList; - doc = (Document) load("staffNS", false); - newList = doc.getElementsByTagNameNS(namespaceURI, localName); - assertSize("throw_Size", 37, newList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getElementsByTagNameNS01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS02.java deleted file mode 100644 index 706de3967..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS02.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagNameNS(namespaceURI,localName)" method for a - * Document should return a new NodeList of all Elements with a given - * localName and namespaceURI in the order they were encountered in a preorder - * traversal of the document tree. - * - * Invoke method getElementsByTagNameNS(namespaceURI,localName) on this document - * with namespaceURI being " " and localName is "employee". - * Method should return a new NodeList containing five Elements. - * Retrieve the FOURTH element whose name should be "emp:employee". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBTNNS -*/ -public final class getElementsByTagNameNS02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getElementsByTagNameNS02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList newList; - Element newElement; - String prefix; - String lname; - doc = (Document) load("staffNS", false); - newList = doc.getElementsByTagNameNS("*", "employee"); - assertSize("employeeCount", 5, newList); - newElement = (Element) newList.item(3); - prefix = newElement.getPrefix(); - assertEquals("prefix", "emp", prefix); - lname = newElement.getLocalName(); - assertEquals("lname", "employee", lname); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getElementsByTagNameNS02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS03.java deleted file mode 100644 index eec09e438..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS03.java +++ /dev/null @@ -1,121 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagNameNS(namespaceURI,localName)" method returns a NodeList - * of all descendant Elements with a given local name and namespace URI in the - * order in which they are encountered in a preorder traversal of this Element tree. - * - * Create a NodeList of all the descendant elements - * using the "http://www.nist.gov" as the namespaceURI and the special value " " as the - * localName. - * The method should return a NodeList of elements that have "http://www.nist.gov - * as a namespace URI. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBTNNS -*/ -public final class getElementsByTagNameNS03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getElementsByTagNameNS03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node child; - String childName; - java.util.List result = new java.util.ArrayList(); - - java.util.List expectedResult = new java.util.ArrayList(); - expectedResult.add("employee"); - expectedResult.add("employeeId"); - expectedResult.add("name"); - expectedResult.add("position"); - expectedResult.add("salary"); - expectedResult.add("gender"); - expectedResult.add("address"); - expectedResult.add("emp:employee"); - expectedResult.add("emp:employeeId"); - expectedResult.add("emp:position"); - expectedResult.add("emp:salary"); - expectedResult.add("emp:gender"); - expectedResult.add("emp:address"); - expectedResult.add("address"); - - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "*"); - for (int indexN10076 = 0; indexN10076 < elementList.getLength(); indexN10076++) { - child = (Node) elementList.item(indexN10076); - childName = child.getNodeName(); - result.add(childName); - } - assertEquals("nodeNames", expectedResult, result); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getElementsByTagNameNS03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS04.java deleted file mode 100644 index 5600408c4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS04.java +++ /dev/null @@ -1,112 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagNameNS(namespaceURI,localName)" method returns a NodeList - * of all descendant Elements with a given local name and namespace URI in the - * order in which they are encountered in a preorder traversal of this Element tree. - * - * Create a NodeList of all the descendant elements - * using the special value " " as the namespaceURI and "address" as the - * localName. - * The method should return a NodeList of Elements that have - * "address" as the local name. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBTNNS -*/ -public final class getElementsByTagNameNS04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getElementsByTagNameNS04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node child; - String childName; - java.util.List result = new java.util.ArrayList(); - - java.util.List expectedResult = new java.util.ArrayList(); - expectedResult.add("address"); - expectedResult.add("address"); - expectedResult.add("address"); - expectedResult.add("emp:address"); - expectedResult.add("address"); - - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagNameNS("*", "address"); - for (int indexN10059 = 0; indexN10059 < elementList.getLength(); indexN10059++) { - child = (Node) elementList.item(indexN10059); - childName = child.getNodeName(); - result.add(childName); - } - assertEquals("nodeNames", expectedResult, result); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getElementsByTagNameNS04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS05.java deleted file mode 100644 index 543fb701c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS05.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagNameNS(namespaceURI,localName)" method returns a NodeList - * of all descendant Elements with a given local name and namespace URI in the - * order in which they are encountered in a preorder traversal of this Element tree. - * - * Create a NodeList of all the descendant elements - * using the "http://www.nist.gov" as the namespaceURI and "nomatch" as the - * localName. - * The method should return a NodeList whose length is - * "0". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBTNNS -*/ -public final class getElementsByTagNameNS05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getElementsByTagNameNS05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.nist.gov"; - String localName = "nomatch"; - Document doc; - NodeList elementList; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagNameNS(namespaceURI, localName); - assertSize("throw_Size", 0, elementList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getElementsByTagNameNS05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS06.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS06.java deleted file mode 100644 index c355f71e6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS06.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagNameNS(namespaceURI,localName)" method returns a NodeList - * of all descendant Elements with a given local name and namespace URI in the - * order in which they are encountered in a preorder traversal of this Element tree. - * - * Create a NodeList of all the descendant elements - * using the "http://www.nomatch.com" as the namespaceURI and "address" as the - * localName. - * The method should return a NodeList whose length is - * "0". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBTNNS -*/ -public final class getElementsByTagNameNS06 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getElementsByTagNameNS06(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagNameNS("http://www.nomatch.com", "address"); - assertSize("matchSize", 0, elementList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS06"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getElementsByTagNameNS06.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS07.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS07.java deleted file mode 100644 index 0663da154..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS07.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagNameNS(namespaceURI,localName)" method returns a NodeList - * of all descendant Elements with a given local name and namespace URI in the - * order in which they are encountered in a preorder traversal of this Element tree. - * - * Create a NodeList of all the descendant elements - * using the string "http://www.nist.gov" as the namespaceURI and "address" as the - * localName. - * The method should return a NodeList whose length is - * "3". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBTNNS -*/ -public final class getElementsByTagNameNS07 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getElementsByTagNameNS07(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "address"); - assertSize("addresses", 3, elementList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS07"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getElementsByTagNameNS07.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS08.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS08.java deleted file mode 100644 index 4afe92784..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS08.java +++ /dev/null @@ -1,88 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Element.getElementsByTagNameNS('*','*') should return all child - * elements. There is some contention on whether this should match - * unqualified elements, this test reflects the interpretation that - * '*' should match elements in all namespaces and unqualified elements. - * Derived from getElementsByTagNameNS01 which tests similar functionality - * on the Document interface. -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-1938918D -*/ -public final class getElementsByTagNameNS08 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getElementsByTagNameNS08(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element docElem; - NodeList newList; - doc = (Document) load("staffNS", false); - docElem = doc.getDocumentElement(); - newList = docElem.getElementsByTagNameNS("*", "*"); - assertSize("listSize", 36, newList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS08"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getElementsByTagNameNS08.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS09.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS09.java deleted file mode 100644 index db6529c38..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS09.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagNameNS(namespaceURI,localName)" method for a - * Element should return a new NodeList of all descendant Elements with a given - * localName and namespaceURI in the order they were encountered in a preorder - * traversal of the document tree. - * - * Invoke method getElementsByTagNameNS(namespaceURI,localName) on the document - * element with namespaceURI being "*" and localName is "employee". - * Method should return a new NodeList containing five Elements. - * Retrieve the FOURTH element whose name should be "emp:employee". - * Derived from getElementsByTagNameNS02 and reflects its interpretation - * that namespace="*" matches namespace unqualified tagnames. -* @author Curt Arnold -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-1938918D -*/ -public final class getElementsByTagNameNS09 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getElementsByTagNameNS09(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList newList; - Element newElement; - String prefix; - String lname; - Element docElem; - doc = (Document) load("staffNS", false); - docElem = doc.getDocumentElement(); - newList = docElem.getElementsByTagNameNS("*", "employee"); - assertSize("employeeCount", 5, newList); - newElement = (Element) newList.item(3); - prefix = newElement.getPrefix(); - assertEquals("prefix", "emp", prefix); - lname = newElement.getLocalName(); - assertEquals("lname", "employee", lname); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS09"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getElementsByTagNameNS09.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS10.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS10.java deleted file mode 100644 index 491c51c2c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS10.java +++ /dev/null @@ -1,124 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagNameNS(namespaceURI,localName)" method returns a NodeList - * of all descendant Elements with a given local name and namespace URI in the - * order in which they are encountered in a preorder traversal of this Element tree. - * - * Create a NodeList of all the descendant elements of the document element - * using the "http://www.nist.gov" as the namespaceURI and the special value "*" as the - * localName. - * The method should return a NodeList of elements that have "http://www.nist.gov - * as a namespace URI. - * Derived from getElementsByTagNameNS03 -* @author Curt Arnold -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-1938918D -*/ -public final class getElementsByTagNameNS10 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getElementsByTagNameNS10(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element docElem; - NodeList elementList; - Node child; - String childName; - java.util.List result = new java.util.ArrayList(); - - java.util.List expectedResult = new java.util.ArrayList(); - expectedResult.add("employee"); - expectedResult.add("employeeId"); - expectedResult.add("name"); - expectedResult.add("position"); - expectedResult.add("salary"); - expectedResult.add("gender"); - expectedResult.add("address"); - expectedResult.add("emp:employee"); - expectedResult.add("emp:employeeId"); - expectedResult.add("emp:position"); - expectedResult.add("emp:salary"); - expectedResult.add("emp:gender"); - expectedResult.add("emp:address"); - expectedResult.add("address"); - - doc = (Document) load("staffNS", false); - docElem = doc.getDocumentElement(); - elementList = docElem.getElementsByTagNameNS("http://www.nist.gov", "*"); - for (int indexN1007E = 0; indexN1007E < elementList.getLength(); indexN1007E++) { - child = (Node) elementList.item(indexN1007E); - childName = child.getNodeName(); - result.add(childName); - } - assertEquals("nodeNames", expectedResult, result); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS10"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getElementsByTagNameNS10.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS11.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS11.java deleted file mode 100644 index 197acbcd3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS11.java +++ /dev/null @@ -1,114 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagNameNS(namespaceURI,localName)" method returns a NodeList - * of all descendant Elements with a given local name and namespace URI in the - * order in which they are encountered in a preorder traversal of this Element tree. - * - * Create a NodeList of all the descendant elements - * using the special value "*" as the namespaceURI and "address" as the - * localName. - * The method should return a NodeList of Elements that have - * "address" as the local name. - * This test is derived from getElementsByTagNameNS04 -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-1938918D -*/ -public final class getElementsByTagNameNS11 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getElementsByTagNameNS11(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element docElem; - NodeList elementList; - Node child; - String childName; - java.util.List result = new java.util.ArrayList(); - - java.util.List expectedResult = new java.util.ArrayList(); - expectedResult.add("address"); - expectedResult.add("address"); - expectedResult.add("address"); - expectedResult.add("emp:address"); - expectedResult.add("address"); - - doc = (Document) load("staffNS", false); - docElem = doc.getDocumentElement(); - elementList = docElem.getElementsByTagNameNS("*", "address"); - for (int indexN1005E = 0; indexN1005E < elementList.getLength(); indexN1005E++) { - child = (Node) elementList.item(indexN1005E); - childName = child.getNodeName(); - result.add(childName); - } - assertEquals("nodeNames", expectedResult, result); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS11"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getElementsByTagNameNS11.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS12.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS12.java deleted file mode 100644 index 41cb437ce..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS12.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagNameNS(namespaceURI,localName)" method returns a NodeList - * of all descendant Elements with a given local name and namespace URI in the - * order in which they are encountered in a preorder traversal of this Element tree. - * - * Create a NodeList of all the descendant elements - * using the "http://www.nist.gov" as the namespaceURI and "nomatch" as the - * localName. - * The method should return a NodeList whose length is "0". - * This test is a modification of getElementsByTagName05 -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-1938918D -*/ -public final class getElementsByTagNameNS12 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getElementsByTagNameNS12(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element docElem; - NodeList elementList; - doc = (Document) load("staffNS", false); - docElem = doc.getDocumentElement(); - elementList = docElem.getElementsByTagNameNS("http://www.nist.gov", "nomatch"); - assertSize("size", 0, elementList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS12"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getElementsByTagNameNS12.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS13.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS13.java deleted file mode 100644 index 8e2d7a6d8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS13.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagNameNS(namespaceURI,localName)" method returns a NodeList - * of all descendant Elements with a given local name and namespace URI in the - * order in which they are encountered in a preorder traversal of this Element tree. - * - * Create a NodeList of all the descendant elements - * using the "http://www.nomatch.com" as the namespaceURI and "address" as the - * localName. - * The method should return a NodeList whose length is - * "0". -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-1938918D -*/ -public final class getElementsByTagNameNS13 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getElementsByTagNameNS13(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element docElem; - NodeList elementList; - doc = (Document) load("staffNS", false); - docElem = doc.getDocumentElement(); - elementList = docElem.getElementsByTagNameNS("http://www.nomatch.com", "address"); - assertSize("matchSize", 0, elementList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS13"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getElementsByTagNameNS13.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS14.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS14.java deleted file mode 100644 index 2334f2743..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getElementsByTagNameNS14.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getElementsByTagNameNS(namespaceURI,localName)" method returns a NodeList - * of all descendant Elements with a given local name and namespace URI in the - * order in which they are encountered in a preorder traversal of this Element tree. - * - * Create a NodeList of all the descendant elements - * using the string "http://www.nist.gov" as the namespaceURI and "address" as the - * localName. - * The method should return a NodeList whose length is - * "3". -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-1938918D -*/ -public final class getElementsByTagNameNS14 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getElementsByTagNameNS14(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element docElem; - NodeList elementList; - doc = (Document) load("staffNS", false); - docElem = doc.getDocumentElement(); - elementList = docElem.getElementsByTagNameNS("http://www.nist.gov", "address"); - assertSize("addresses", 3, elementList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS14"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getElementsByTagNameNS14.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getNamedItemNS01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getNamedItemNS01.java deleted file mode 100644 index 859a5827f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getNamedItemNS01.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNamedItemNS(namespaceURI,localName)" method for a - * NamedNodeMap should return a node specified by localName and namespaceURI - * - * Retrieve a list of elements with tag name "address". - * Access the second element from the list and get its attributes. - * Try to retrieve the attribute node with local name "domestic" - * and namespace uri "http://www.usa.com" with - * method getNamedItemNS(namespaceURI,localName). -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-F68D095 -*/ -public final class getNamedItemNS01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getNamedItemNS01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - NamedNodeMap attributes; - Attr domesticAttr; - String attrName; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("address"); - testEmployee = elementList.item(1); - attributes = testEmployee.getAttributes(); - domesticAttr = (Attr) attributes.getNamedItemNS("http://www.usa.com", "domestic"); - attrName = domesticAttr.getNodeName(); - assertEquals("attrName", "dmstc:domestic", attrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getNamedItemNS01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getNamedItemNS01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getNamedItemNS02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getNamedItemNS02.java deleted file mode 100644 index 087b9e0be..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getNamedItemNS02.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNamedItemNS(namespaceURI,localName)" method for a - * NamedNodeMap should return null - * if parameters do not identify any node in this map. - * - * Retrieve a list of elements with tag name "address". - * Access the second element from the list and get its attributes. - * Try to retrieve an attribute node with local name "domest" - * and namespace uri "http://www.usa.com" with - * method getNamedItemNS(namespaceURI,localName). - * This should return null because "domest" does not match any local names in this map. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getNamedItemNS -*/ -public final class getNamedItemNS02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getNamedItemNS02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.usa.com"; - String localName = "domest"; - Document doc; - NodeList elementList; - Node testEmployee; - NamedNodeMap attributes; - Attr newAttr; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("address"); - testEmployee = elementList.item(1); - attributes = testEmployee.getAttributes(); - newAttr = (Attr) attributes.getNamedItemNS(namespaceURI, localName); - assertNull("throw_Null", newAttr); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getNamedItemNS02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getNamedItemNS02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getNamedItemNS03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getNamedItemNS03.java deleted file mode 100644 index 235352f22..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getNamedItemNS03.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Entity nodes are not namespaced and should not be retrievable using - * getNamedItemNS. -* @author Curt Arnold -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getNamedItemNS -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class getNamedItemNS03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getNamedItemNS03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap entities; - Entity entity; - String nullNS = null; - - doc = (Document) load("staffNS", false); - docType = doc.getDoctype(); - entities = docType.getEntities(); - assertNotNull("entitiesNotNull", entities); - entity = (Entity) entities.getNamedItemNS(nullNS, "ent1"); - assertNull("entityNull", entity); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getNamedItemNS03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getNamedItemNS03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getNamedItemNS04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/getNamedItemNS04.java deleted file mode 100644 index f22f9630b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/getNamedItemNS04.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Notation nodes are not namespaced and should not be retrievable using - * getNamedItemNS. -* @author Curt Arnold -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getNamedItemNS -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class getNamedItemNS04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public getNamedItemNS04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap notations; - Notation notation; - String nullNS = null; - - doc = (Document) load("staffNS", false); - docType = doc.getDoctype(); - notations = docType.getNotations(); - assertNotNull("notationsNotNull", notations); - notation = (Notation) notations.getNamedItemNS(nullNS, "notation1"); - assertNull("notationNull", notation); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getNamedItemNS04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(getNamedItemNS04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttribute01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttribute01.java deleted file mode 100644 index b9e2d7adf..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttribute01.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "hasAttribute()" method for an Element should - * return true if the element has an attribute with the given name. - * Retrieve the first "address" element and the "hasAttribute()" method - * should return false since the element does not have a default value. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElHasAttr -*/ -public final class hasAttribute01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hasAttribute01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testNode; - boolean state; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - testNode = (Element) elementList.item(4); - state = testNode.hasAttribute("domestic"); - assertFalse("throw_False", state); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttribute01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hasAttribute01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttribute02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttribute02.java deleted file mode 100644 index 23ef84c77..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttribute02.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "hasAttribute()" method for an Element should - * return true if the element has an attribute with the given name. - * Retrieve the first "address" element and the "hasAttribute()" method - * should return true since the attribute "street" has a default value. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElHasAttr -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=238 -*/ -public final class hasAttribute02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hasAttribute02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testNode; - boolean state; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - testNode = (Element) elementList.item(0); - state = testNode.hasAttribute("street"); - assertTrue("throw_True", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttribute02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hasAttribute02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttribute03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttribute03.java deleted file mode 100644 index adc23e4c0..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttribute03.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "hasAttribute()" method for an Element should - * return false if the element does not have an attribute with the given name. - * Retrieve the first "address" element and the "hasAttribute()" method - * should return false since the element does not have "nomatch" as an attribute. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElHasAttr -*/ -public final class hasAttribute03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hasAttribute03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testNode; - boolean state; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("address"); - testNode = (Element) elementList.item(0); - state = testNode.hasAttribute("nomatch"); - assertFalse("throw_False", state); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttribute03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hasAttribute03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttribute04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttribute04.java deleted file mode 100644 index 98a9f242c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttribute04.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "hasAttribute()" method for an Element should - * return true if the element has an attribute with the given name. - * Retrieve the first "address" element and the "hasAttribute()" method - * should return true since the element has "domestic" as an attribute. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElHasAttr -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=238 -*/ -public final class hasAttribute04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hasAttribute04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testNode; - boolean state; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("address"); - testNode = (Element) elementList.item(0); - state = testNode.hasAttribute("dmstc:domestic"); - assertTrue("hasDomesticAttr", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttribute04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hasAttribute04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS01.java deleted file mode 100644 index da6c53270..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS01.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * - * The "hasAttributeNS()" method for an Element should - * return false if the element does not have an attribute with the given local name - * and/or a namespace URI specified on this element or does not have a default value. - * Retrieve the first "address" element and the "hasAttributeNS()" method - * should return false since the element has "nomatch" as the local name - * and "http://www.usa.com" as the namespace URI. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElHasAttrNS -*/ -public final class hasAttributeNS01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hasAttributeNS01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String localName = "nomatch"; - String namespaceURI = "http://www.usa.com"; - Document doc; - NodeList elementList; - Element testNode; - boolean state; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("address"); - testNode = (Element) elementList.item(0); - state = testNode.hasAttributeNS(namespaceURI, localName); - assertFalse("throw_False", state); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttributeNS01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hasAttributeNS01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS02.java deleted file mode 100644 index 4f71e999a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS02.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "hasAttributeNS()" method for an Element should - * return false if the element does not have an attribute with the given local name - * and/or namespace URI specified on this element or does not have a default value. - * Retrieve the first "address" element and the "hasAttributeNS()" method - * should return false since the element has "domestic" as the local name - * and "http://www.nomatch.com" as the namespace URI. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElHasAttrNS -*/ -public final class hasAttributeNS02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hasAttributeNS02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String localName = "domestic"; - String namespaceURI = "http://www.nomatch.com"; - Document doc; - NodeList elementList; - Element testNode; - boolean state; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("address"); - testNode = (Element) elementList.item(0); - state = testNode.hasAttributeNS(namespaceURI, localName); - assertFalse("throw_False", state); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttributeNS02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hasAttributeNS02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS03.java deleted file mode 100644 index f2f67928e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS03.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "hasAttributeNS()" method for an Element should - * return false if the element does not have an attribute with the given local name - * and/or namespace URI specified on this element or does not have a default value. - * Retrieve the first "emp:address" element. - * The boolean value returned by the "hasAttributeNS()" should be false - * since the attribute does not have a default value. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElHasAttrNS -*/ -public final class hasAttributeNS03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hasAttributeNS03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String localName = "blank"; - String namespaceURI = "http://www.nist.gov"; - Document doc; - NodeList elementList; - Element testNode; - boolean state; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("emp:address"); - testNode = (Element) elementList.item(0); - assertNotNull("empAddrNotNull", testNode); - state = testNode.hasAttributeNS(namespaceURI, localName); - assertFalse("throw_False", state); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttributeNS03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hasAttributeNS03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS04.java deleted file mode 100644 index 48e205064..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS04.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "hasAttributeNS()" method for an Element should - * return true if the attribute with the given local name - * and namespace URI has a default value. - * Retrieve the first "emp:address" element. - * The boolean value returned by the "hasAttributeNS()" should be true - * since the attribute has a default value. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElHasAttrNS -*/ -public final class hasAttributeNS04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hasAttributeNS04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware, -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String localName = "district"; - String namespaceURI = "http://www.nist.gov"; - Document doc; - NodeList elementList; - Element testNode; - boolean state; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("emp:address"); - testNode = (Element) elementList.item(0); - assertNotNull("empAddressNotNull", testNode); - state = testNode.hasAttributeNS(namespaceURI, localName); - assertTrue("hasAttribute", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttributeNS04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hasAttributeNS04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS05.java deleted file mode 100644 index a4d99edf0..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributeNS05.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "hasAttributeNS()" method for an Element should - * return true if the element has an attribute with the given local name - * and the namespace URI is specified on this element or has a default value. - * Retrieve the first "address" element and the "hasAttributeNS()" method - * should return true since the element has "domestic" as the local name - * and "http://www.usa.com" as the namespace URI. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElHasAttrNS -*/ -public final class hasAttributeNS05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hasAttributeNS05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String localName = "domestic"; - String namespaceURI = "http://www.usa.com"; - Document doc; - NodeList elementList; - Element testNode; - boolean state; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("address"); - testNode = (Element) elementList.item(0); - state = testNode.hasAttributeNS(namespaceURI, localName); - assertTrue("hasAttribute", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttributeNS05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hasAttributeNS05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributes01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributes01.java deleted file mode 100644 index 412e1324b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributes01.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "hasAttributes()" method for a node should - * return false if the node does not have an attribute. - * Retrieve the first "name" node and invoke the "hasAttributes()" method. - * The method should return false since the node does not have an attribute. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeHasAttrs -*/ -public final class hasAttributes01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hasAttributes01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addrList; - Node addrNode; - boolean state; - doc = (Document) load("staff", false); - addrList = doc.getElementsByTagName("name"); - addrNode = addrList.item(0); - state = addrNode.hasAttributes(); - assertFalse("throw_False", state); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttributes01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hasAttributes01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributes02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributes02.java deleted file mode 100644 index 8855e58d4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hasAttributes02.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "hasAttributes()" method for a node should - * return true if the node has attributes. - * Retrieve the first address node and the "hasAttributes()" method - * should return true since the node has "domestic" as an attribute. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeHasAttrs -*/ -public final class hasAttributes02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hasAttributes02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addrList; - Node addrNode; - boolean state; - doc = (Document) load("staff", false); - addrList = doc.getElementsByTagName("address"); - addrNode = addrList.item(0); - state = addrNode.hasAttributes(); - assertTrue("throw_True", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttributes02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hasAttributes02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_entitiesremovenameditemns1.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_entitiesremovenameditemns1.java deleted file mode 100644 index c57698f75..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_entitiesremovenameditemns1.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An attempt to add remove an entity using removeNamedItemNS should result in - * a NO_MODIFICATION_ERR or a NOT_FOUND_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-1788794630 -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-removeNamedItemNS -*/ -public final class hc_entitiesremovenameditemns1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_entitiesremovenameditemns1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap entities; - DocumentType docType; - Node retval; - doc = (Document) load("hc_staff", true); - docType = doc.getDoctype(); - - if ( - !(("text/html".equals(getContentType()))) -) { - assertNotNull("docTypeNotNull", docType); - entities = docType.getEntities(); - assertNotNull("entitiesNotNull", entities); - - try { - retval = entities.removeNamedItemNS("http://www.w3.org/1999/xhtml", "alpha"); - fail("throw_NO_MOD_OR_NOT_FOUND_ERR"); - - } catch (DOMException ex) { - switch (ex.code) { - case 7 : - break; - case 8 : - break; - default: - throw ex; - } - } -} - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/hc_entitiesremovenameditemns1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_entitiesremovenameditemns1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_entitiessetnameditemns1.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_entitiessetnameditemns1.java deleted file mode 100644 index 47f6fd55e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_entitiessetnameditemns1.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An attempt to add an element to the named node map returned by entities should - * result in a NO_MODIFICATION_ERR or HIERARCHY_REQUEST_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-1788794630 -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS -*/ -public final class hc_entitiessetnameditemns1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_entitiessetnameditemns1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap entities; - DocumentType docType; - Node retval; - Element elem; - doc = (Document) load("hc_staff", true); - docType = doc.getDoctype(); - - if ( - !(("text/html".equals(getContentType()))) -) { - assertNotNull("docTypeNotNull", docType); - entities = docType.getEntities(); - assertNotNull("entitiesNotNull", entities); - elem = doc.createElementNS("http://www.w3.org/1999/xhtml", "br"); - - try { - retval = entities.setNamedItemNS(elem); - fail("throw_HIER_OR_NO_MOD_ERR"); - - } catch (DOMException ex) { - switch (ex.code) { - case 3 : - break; - case 7 : - break; - default: - throw ex; - } - } -} - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/hc_entitiessetnameditemns1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_entitiessetnameditemns1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_namednodemapinvalidtype1.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_namednodemapinvalidtype1.java deleted file mode 100644 index f9ee1c54f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_namednodemapinvalidtype1.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Attempt to insert an element into an attribute list, - * should raise a HIERARCHY_REQUEST_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR']) -* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788 -* @see http://www.w3.org/2000/11/DOM-Level-2-errata#core-4 -*/ -public final class hc_namednodemapinvalidtype1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_namednodemapinvalidtype1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attributes; - Element docElem; - Element newElem; - Node retval; - doc = (Document) load("hc_staff", true); - docElem = doc.getDocumentElement(); - attributes = docElem.getAttributes(); - newElem = doc.createElement("html"); - - { - boolean success = false; - try { - retval = attributes.setNamedItem(newElem); - } catch (DOMException ex) { - success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR); - } - assertTrue("throw_HIERARCHY_REQUEST_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/hc_namednodemapinvalidtype1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_namednodemapinvalidtype1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_nodedocumentfragmentnormalize1.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_nodedocumentfragmentnormalize1.java deleted file mode 100644 index e065a66a3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_nodedocumentfragmentnormalize1.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Create a document fragment with two adjacent text nodes, normalize and see if the text nodes - * were combined. -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-F68D095 -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-B63ED1A3 -*/ -public final class hc_nodedocumentfragmentnormalize1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodedocumentfragmentnormalize1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentFragment docFragment; - String nodeValue; - Text txtNode; - Node retval; - doc = (Document) load("hc_staff", true); - docFragment = doc.createDocumentFragment(); - txtNode = doc.createTextNode("foo"); - retval = docFragment.appendChild(txtNode); - txtNode = doc.createTextNode("bar"); - retval = docFragment.appendChild(txtNode); - docFragment.normalize(); - txtNode = (Text) docFragment.getFirstChild(); - nodeValue = txtNode.getNodeValue(); - assertEquals("normalizedNodeValue", "foobar", nodeValue); - retval = txtNode.getNextSibling(); - assertNull("singleChild", retval); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/hc_nodedocumentfragmentnormalize1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodedocumentfragmentnormalize1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_nodedocumentfragmentnormalize2.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_nodedocumentfragmentnormalize2.java deleted file mode 100644 index bd8e97675..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_nodedocumentfragmentnormalize2.java +++ /dev/null @@ -1,87 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Create a document fragment with an empty text node, after normalization there should be no child nodes. - * were combined. -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-F68D095 -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-B63ED1A3 -*/ -public final class hc_nodedocumentfragmentnormalize2 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_nodedocumentfragmentnormalize2(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentFragment docFragment; - String nodeValue; - Text txtNode; - Node retval; - doc = (Document) load("hc_staff", true); - docFragment = doc.createDocumentFragment(); - txtNode = doc.createTextNode(""); - retval = docFragment.appendChild(txtNode); - docFragment.normalize(); - txtNode = (Text) docFragment.getFirstChild(); - assertNull("noChild", txtNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/hc_nodedocumentfragmentnormalize2"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_nodedocumentfragmentnormalize2.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_notationsremovenameditemns1.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_notationsremovenameditemns1.java deleted file mode 100644 index 724dcc589..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_notationsremovenameditemns1.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An attempt to add remove an notation using removeNamedItemNS should result in - * a NO_MODIFICATION_ERR or a NOT_FOUND_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-D46829EF -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-removeNamedItemNS -*/ -public final class hc_notationsremovenameditemns1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_notationsremovenameditemns1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap notations; - DocumentType docType; - Node retval; - doc = (Document) load("hc_staff", true); - docType = doc.getDoctype(); - - if ( - !(("text/html".equals(getContentType()))) -) { - assertNotNull("docTypeNotNull", docType); - notations = docType.getNotations(); - assertNotNull("notationsNotNull", notations); - - try { - retval = notations.removeNamedItemNS("http://www.w3.org/1999/xhtml", "alpha"); - fail("throw_NO_MOD_OR_NOT_FOUND_ERR"); - - } catch (DOMException ex) { - switch (ex.code) { - case 7 : - break; - case 8 : - break; - default: - throw ex; - } - } -} - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/hc_notationsremovenameditemns1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_notationsremovenameditemns1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_notationssetnameditemns1.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_notationssetnameditemns1.java deleted file mode 100644 index 65a13f6d3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/hc_notationssetnameditemns1.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * An attempt to add an element to the named node map returned by notations should - * result in a NO_MODIFICATION_ERR or HIERARCHY_REQUEST_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-D46829EF -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS -*/ -public final class hc_notationssetnameditemns1 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public hc_notationssetnameditemns1(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap notations; - DocumentType docType; - Node retval; - Element elem; - doc = (Document) load("hc_staff", true); - docType = doc.getDoctype(); - - if ( - !(("text/html".equals(getContentType()))) -) { - assertNotNull("docTypeNotNull", docType); - notations = docType.getNotations(); - assertNotNull("notationsNotNull", notations); - elem = doc.createElementNS("http://www.w3.org/1999/xhtml", "br"); - - try { - retval = notations.setNamedItemNS(elem); - fail("throw_HIER_OR_NO_MOD_ERR"); - - } catch (DOMException ex) { - switch (ex.code) { - case 3 : - break; - case 7 : - break; - default: - throw ex; - } - } -} - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/hc_notationssetnameditemns1"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(hc_notationssetnameditemns1.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode01.java deleted file mode 100644 index 98f83f70b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode01.java +++ /dev/null @@ -1,132 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "importNode(importedNode,deep)" method for a - * Document should import the given importedNode into that Document. - * The importedNode is of type Attr. - * The ownerElement is set to null. Specified flag is set to true. - * Children is imported. - * - * Create a new attribute whose name is "elem:attr1" in a different document. - * Create a child Text node with value "importedText" for the attribute node above. - * Invoke method importNode(importedNode,deep) on this document with - * importedNode being the newly created attribute. - * Method should return a node whose name matches "elem:attr1" and a child node - * whose value equals "importedText". - * The returned node should belong to this document whose systemId is "staff.dtd" -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class importNode01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public importNode01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document aNewDoc; - Attr newAttr; - Text importedChild; - Node aNode; - Document ownerDocument; - Element attrOwnerElement; - DocumentType docType; - String system; - boolean specified; - NodeList childList; - String nodeName; - Node child; - String childValue; - java.util.List result = new java.util.ArrayList(); - - java.util.List expectedResult = new java.util.ArrayList(); - expectedResult.add("elem:attr1"); - expectedResult.add("importedText"); - - doc = (Document) load("staffNS", true); - aNewDoc = (Document) load("staffNS", true); - newAttr = aNewDoc.createAttribute("elem:attr1"); - importedChild = aNewDoc.createTextNode("importedText"); - aNode = newAttr.appendChild(importedChild); - aNode = doc.importNode(newAttr, false); - ownerDocument = aNode.getOwnerDocument(); - docType = ownerDocument.getDoctype(); - system = docType.getSystemId(); - assertNotNull("aNode", aNode); - assertURIEquals("systemId", null, null, null, "staffNS.dtd", null, null, null, null, system); -attrOwnerElement = ((Attr) /*Node */aNode).getOwnerElement(); - assertNull("ownerElement", attrOwnerElement); - specified = ((Attr) /*Node */aNode).getSpecified(); - assertTrue("specified", specified); - childList = aNode.getChildNodes(); - assertSize("childList", 1, childList); - nodeName = aNode.getNodeName(); - assertEquals("nodeName", "elem:attr1", nodeName); - child = aNode.getFirstChild(); - childValue = child.getNodeValue(); - assertEquals("childValue", "importedText", childValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(importNode01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode02.java deleted file mode 100644 index dc0180549..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode02.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "importNode(importedNode,deep)" method for a - * Document should import the given importedNode into that Document. - * The importedNode is of type CData_Section. - * - * Create a CDATASection node with value being the string "this is CDATASection data" in - * a different document. Invoke method importNode(importedNode,deep) on - * this document. Method should return a CDATASection node whose value matches - * the above string. The returned node should belong to this document whose systemId is "staff.dtd" -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class importNode02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public importNode02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document aNewDoc; - CDATASection cDataSec; - Node aNode; - Document ownerDocument; - DocumentType docType; - String system; - String value; - doc = (Document) load("staffNS", true); - aNewDoc = (Document) load("staffNS", true); - cDataSec = aNewDoc.createCDATASection("this is CDATASection data"); - aNode = doc.importNode(cDataSec, false); - ownerDocument = aNode.getOwnerDocument(); - assertNotNull("ownerDocumentNotNull", ownerDocument); - docType = ownerDocument.getDoctype(); - system = docType.getSystemId(); - assertURIEquals("dtdSystemId", null, null, null, "staffNS.dtd", null, null, null, null, system); -value = aNode.getNodeValue(); - assertEquals("nodeValue", "this is CDATASection data", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(importNode02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode03.java deleted file mode 100644 index 0a4eebe3e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode03.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "importNode(importedNode,deep)" method for a - * Document should import the given importedNode into that Document. - * The importedNode is of type Comment. - * - * Create a comment node with value being the string "this is a comment" in - * a different document. Invoke method importNode(importedNode,deep) on - * this document. Method should return a comment node whose value matches - * the above string. The returned node should belong to this document whose - * systemId is "staff.dtd" -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class importNode03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public importNode03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document aNewDoc; - Comment comment; - Node aNode; - Document ownerDocument; - DocumentType docType; - String system; - String value; - doc = (Document) load("staffNS", true); - aNewDoc = (Document) load("staffNS", true); - comment = aNewDoc.createComment("this is a comment"); - aNode = doc.importNode(comment, false); - ownerDocument = aNode.getOwnerDocument(); - assertNotNull("ownerDocumentNotNull", ownerDocument); - docType = ownerDocument.getDoctype(); - system = docType.getSystemId(); - assertURIEquals("systemId", null, null, null, "staffNS.dtd", null, null, null, null, system); -value = aNode.getNodeValue(); - assertEquals("nodeValue", "this is a comment", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(importNode03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode04.java deleted file mode 100644 index 7723e4304..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode04.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "importNode(importedNode,deep)" method for a - * Document should import the given importedNode into that Document. - * The importedNode is of type Document_Fragment. - * - * Create a DocumentFragment in a different document. - * Create a Comment child node for the Document Fragment. - * Invoke method importNode(importedNode,deep) on this document - * with importedNode being the newly created DocumentFragment. - * Method should return a node of type DocumentFragment whose child has - * comment value "descendant1". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class importNode04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public importNode04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document aNewDoc; - DocumentFragment docFrag; - Comment comment; - Node aNode; - NodeList children; - Node child; - String childValue; - doc = (Document) load("staff", true); - aNewDoc = (Document) load("staff", true); - docFrag = aNewDoc.createDocumentFragment(); - comment = aNewDoc.createComment("descendant1"); - aNode = docFrag.appendChild(comment); - aNode = doc.importNode(docFrag, true); - children = aNode.getChildNodes(); - assertSize("throw_Size", 1, children); - child = aNode.getFirstChild(); - childValue = child.getNodeValue(); - assertEquals("descendant1", "descendant1", childValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(importNode04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode05.java deleted file mode 100644 index cecaf2210..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode05.java +++ /dev/null @@ -1,111 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "importNode(importedNode,deep)" method for a - * Document should import the given importedNode into that Document. - * The importedNode is of type Element. - * - * Retrieve element "emp:address" from staffNS.xml document. - * Invoke method importNode(importedNode,deep) on this document - * with importedNode being the element from above and deep is false. - * Method should return an element node whose name matches "emp:address" - * and whose children are not imported. The returned node should - * belong to this document whose systemId is "staff.dtd" -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class importNode05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public importNode05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document aNewDoc; - Element element; - Node aNode; - boolean hasChild; - Document ownerDocument; - DocumentType docType; - String system; - String name; - NodeList addresses; - doc = (Document) load("staffNS", true); - aNewDoc = (Document) load("staffNS", true); - addresses = aNewDoc.getElementsByTagName("emp:address"); - element = (Element) addresses.item(0); - assertNotNull("empAddressNotNull", element); - aNode = doc.importNode(element, false); - hasChild = aNode.hasChildNodes(); - assertFalse("hasChild", hasChild); -ownerDocument = aNode.getOwnerDocument(); - docType = ownerDocument.getDoctype(); - system = docType.getSystemId(); - assertURIEquals("dtdSystemId", null, null, null, "staffNS.dtd", null, null, null, null, system); -name = aNode.getNodeName(); - assertEquals("nodeName", "emp:address", name); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(importNode05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode06.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode06.java deleted file mode 100644 index 0e91eb566..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode06.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "importNode(importedNode,deep)" method for a - * Document should import the given importedNode into that Document. - * The importedNode is of type Element. - * - * Retrieve element "emp:address" from staffNS.xml document. - * Invoke method importNode(importedNode,deep) on this document - * with importedNode being the element from above and deep is true. - * Method should return an element node whose name matches "emp:address" and - * whose descendant is imported. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class importNode06 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public importNode06(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document aNewDoc; - Element element; - Node aNode; - boolean hasChild; - String name; - Node child; - String value; - NodeList addresses; - doc = (Document) load("staffNS", true); - aNewDoc = (Document) load("staffNS", true); - addresses = aNewDoc.getElementsByTagName("emp:address"); - element = (Element) addresses.item(0); - assertNotNull("empAddressNotNull", element); - aNode = doc.importNode(element, true); - hasChild = aNode.hasChildNodes(); - assertTrue("throw_True", hasChild); - name = aNode.getNodeName(); - assertEquals("nodeName", "emp:address", name); - child = aNode.getFirstChild(); - value = child.getNodeValue(); - assertEquals("nodeValue", "27 South Road. Dallas, texas 98556", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode06"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(importNode06.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode07.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode07.java deleted file mode 100644 index 199d1a874..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode07.java +++ /dev/null @@ -1,116 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "importNode(importedNode,deep)" method for a - * Document should import the given importedNode into that Document. - * The importedNode is of type Element. - * If this document defines default attributes for this element name (importedNode), - * those default attributes are assigned. - * - * Create an element whose name is "emp:employee" in a different document. - * Invoke method importNode(importedNode,deep) on this document which - * defines default attribute for the element name "emp:employee". - * Method should return an the imported element with an assigned default attribute. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=238 -*/ -public final class importNode07 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public importNode07(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware, -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document aNewDoc; - Element element; - Node aNode; - NamedNodeMap attributes; - String name; - Node attr; - String lname; - String namespaceURI = "http://www.nist.gov"; - String qualifiedName = "emp:employee"; - doc = (Document) load("staffNS", true); - aNewDoc = (Document) load("staff", true); - element = aNewDoc.createElementNS(namespaceURI, qualifiedName); - aNode = doc.importNode(element, false); - attributes = aNode.getAttributes(); - assertSize("throw_Size", 1, attributes); - name = aNode.getNodeName(); - assertEquals("nodeName", "emp:employee", name); - attr = attributes.item(0); - lname = attr.getLocalName(); - assertEquals("lname", "defaultAttr", lname); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode07"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(importNode07.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode08.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode08.java deleted file mode 100644 index df8f0ce79..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode08.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "importNode(importedNode,deep)" method for a - * Document should import the given importedNode into that Document. - * The importedNode is of type Document_Fragment. - * - * Create a DocumentFragment in a different document. - * Invoke method importNode(importedNode,deep) on this document - * with importedNode being the newly created DocumentFragment. - * Method should return an empty DocumentFragment that belongs - * to this document whose systemId is "staff.dtd" -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-Core-DocType-systemId -*/ -public final class importNode08 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public importNode08(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document aNewDoc; - DocumentFragment docFrag; - Node aNode; - boolean hasChild; - Document ownerDocument; - DocumentType docType; - String system; - doc = (Document) load("staffNS", true); - aNewDoc = (Document) load("staffNS", true); - docFrag = aNewDoc.createDocumentFragment(); - aNode = doc.importNode(docFrag, false); - hasChild = aNode.hasChildNodes(); - assertFalse("hasChild", hasChild); -ownerDocument = aNode.getOwnerDocument(); - docType = ownerDocument.getDoctype(); - system = docType.getSystemId(); - assertURIEquals("system", null, null, null, "staffNS.dtd", null, null, null, null, system); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode08"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(importNode08.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode09.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode09.java deleted file mode 100644 index 0186cee46..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode09.java +++ /dev/null @@ -1,117 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "importNode(importedNode,deep)" method for a - * Document should import the given importedNode into that Document. - * The importedNode is of type Entity. - * - * Retrieve entity "ent6" from staffNS.xml document. - * Invoke method importNode(importedNode,deep) on this document. - * Method should return a node of type Entity whose publicId, systemId and - * notationName attributes are copied. - * The returned node should belong to this document whose systemId is "staff.dtd" -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class importNode09 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public importNode09(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document aNewDoc; - DocumentType doc1Type; - NamedNodeMap entityList; - Entity entity2; - Entity entity1; - Document ownerDocument; - DocumentType docType; - String system; - String entityName; - String publicVal; - String notationName; - doc = (Document) load("staffNS", true); - aNewDoc = (Document) load("staffNS", true); - docType = aNewDoc.getDoctype(); - entityList = docType.getEntities(); - assertNotNull("entitiesNotNull", entityList); - entity2 = (Entity) entityList.getNamedItem("ent6"); - entity1 = (Entity) doc.importNode(entity2, false); - ownerDocument = entity1.getOwnerDocument(); - docType = ownerDocument.getDoctype(); - system = docType.getSystemId(); - assertURIEquals("dtdSystemId", null, null, null, "staffNS.dtd", null, null, null, null, system); -entityName = entity1.getNodeName(); - assertEquals("entityName", "ent6", entityName); - publicVal = entity1.getPublicId(); - assertEquals("entityPublicId", "uri", publicVal); - system = entity1.getSystemId(); - assertURIEquals("entitySystemId", null, null, null, "file", null, null, null, null, system); -notationName = entity1.getNotationName(); - assertEquals("notationName", "notation2", notationName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode09"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(importNode09.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode10.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode10.java deleted file mode 100644 index 3395506a8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode10.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "importNode(importedNode,deep)" method for a - * Document should import the given importedNode into that Document. - * The importedNode is of type Entity_Reference. - * Only the EntityReference is copied, regardless of deep's value. - * - * Create an entity reference whose name is "entRef1" in a different document. - * Give it value "entRef1Value". - * Invoke method importNode(importedNode,deep) on this document with importedNode - * being "entRef1". - * Method should return a node of type Entity_Reference (whose value is null) that - * belongs to this document whose systemId is "staff.dtd". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class importNode10 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public importNode10(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document aNewDoc; - EntityReference entRef; - Node aNode; - Document ownerDocument; - DocumentType docType; - String system; - String name; - doc = (Document) load("staffNS", true); - aNewDoc = (Document) load("staffNS", true); - entRef = aNewDoc.createEntityReference("entRef1"); - assertNotNull("createdEntRefNotNull", entRef); - entRef.setNodeValue("entRef1Value"); - aNode = doc.importNode(entRef, false); - ownerDocument = aNode.getOwnerDocument(); - docType = ownerDocument.getDoctype(); - system = docType.getSystemId(); - assertURIEquals("systemId", null, null, null, "staffNS.dtd", null, null, null, null, system); -name = aNode.getNodeName(); - assertEquals("nodeName", "entRef1", name); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode10"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(importNode10.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode11.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode11.java deleted file mode 100644 index ae016c655..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode11.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "importNode(importedNode,deep)" method for a - * Document should import the given importedNode into that Document. - * The importedNode is of type Entity_Reference. - * Only the EntityReference is copied, regardless of deep's value. - * If the Document provides a definition for the entity name, its value is assigned. - * - * Create an entity reference whose name is "ent3" in a different document. - * Invoke method importNode(importedNode,deep) on this document with importedNode - * being "ent3". - * Method should return a node of type Entity_Reference whose first child's value is "Texas" as defined - * in this document. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class importNode11 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public importNode11(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document aNewDoc; - EntityReference entRef; - Node aNode; - String name; - Node child; - String childValue; - doc = (Document) load("staff", true); - aNewDoc = (Document) load("staff", true); - entRef = aNewDoc.createEntityReference("ent3"); - assertNotNull("createdEntRefNotNull", entRef); - aNode = doc.importNode(entRef, true); - name = aNode.getNodeName(); - assertEquals("entityName", "ent3", name); - child = aNode.getFirstChild(); - assertNotNull("child", child); - childValue = child.getNodeValue(); - assertEquals("childValue", "Texas", childValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode11"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(importNode11.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode12.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode12.java deleted file mode 100644 index 471c5862f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode12.java +++ /dev/null @@ -1,114 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "importNode(importedNode,deep)" method for a - * Document should import the given importedNode into that Document. - * The importedNode is of type Entity. - * - * Retrieve entity "ent4" from staffNS.xml document. - * Invoke method importNode(importedNode,deep) on this document with deep as false. - * Method should return a node of type Entity whose descendant is copied. - * The returned node should belong to this document whose systemId is "staffNS.dtd" -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class importNode12 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public importNode12(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document aNewDoc; - DocumentType doc1Type; - NamedNodeMap entityList; - Entity entity2; - Entity entity1; - Document ownerDocument; - DocumentType docType; - String system; - String entityName; - Node child; - String childName; - doc = (Document) load("staffNS", true); - aNewDoc = (Document) load("staffNS", true); - doc1Type = aNewDoc.getDoctype(); - entityList = doc1Type.getEntities(); - assertNotNull("entitiesNotNull", entityList); - entity2 = (Entity) entityList.getNamedItem("ent4"); - entity1 = (Entity) doc.importNode(entity2, true); - ownerDocument = entity1.getOwnerDocument(); - docType = ownerDocument.getDoctype(); - system = docType.getSystemId(); - assertURIEquals("systemId", null, null, null, "staffNS.dtd", null, null, null, null, system); -entityName = entity1.getNodeName(); - assertEquals("entityName", "ent4", entityName); - child = entity1.getFirstChild(); - assertNotNull("notnull", child); - childName = child.getNodeName(); - assertEquals("childName", "entElement1", childName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode12"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(importNode12.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode13.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode13.java deleted file mode 100644 index 265e6b0eb..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode13.java +++ /dev/null @@ -1,111 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "importNode(importedNode,deep)" method for a - * Document should import the given importedNode into that Document. - * The importedNode is of type Notation. - * - * Retrieve notation named "notation1" from document staffNS.xml. - * Invoke method importNode(importedNode,deep) where importedNode - * contains the retrieved notation and deep is false. Method should - * return a node of type notation whose name is "notation1". - * The returned node should belong to this document whose systemId is "staff.dtd" -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class importNode13 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public importNode13(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document aNewDoc; - DocumentType doc1Type; - NamedNodeMap notationList; - Notation notation; - Notation aNode; - Document ownerDocument; - DocumentType docType; - String system; - String publicVal; - doc = (Document) load("staffNS", true); - aNewDoc = (Document) load("staffNS", true); - doc1Type = aNewDoc.getDoctype(); - notationList = doc1Type.getNotations(); - assertNotNull("notationsNotNull", notationList); - notation = (Notation) notationList.getNamedItem("notation1"); - aNode = (Notation) doc.importNode(notation, false); - ownerDocument = aNode.getOwnerDocument(); - docType = ownerDocument.getDoctype(); - system = docType.getSystemId(); - assertURIEquals("systemId", null, null, null, "staffNS.dtd", null, null, null, null, system); -publicVal = aNode.getPublicId(); - assertEquals("publicId", "notation1File", publicVal); - system = aNode.getSystemId(); - assertNull("notationSystemId", system); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode13"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(importNode13.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode14.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode14.java deleted file mode 100644 index df7788625..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode14.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "importNode(importedNode,deep)" method for a - * Document should import the given importedNode into that Document. - * The importedNode is of type Processing Instruction. - * - * Create a processing instruction with target as "target1" and data as "data1" - * in a different document. Invoke method importNode(importedNode,deep) on this document. - * Method should return a processing instruction whose target and data match the given - * parameters. The returned PI should belong to this document whose systemId is "staff.dtd". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class importNode14 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public importNode14(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document aNewDoc; - ProcessingInstruction pi; - ProcessingInstruction aNode; - Document ownerDocument; - DocumentType docType; - String system; - String target; - String data; - java.util.List result = new java.util.ArrayList(); - - doc = (Document) load("staffNS", true); - aNewDoc = (Document) load("staffNS", true); - pi = aNewDoc.createProcessingInstruction("target1", "data1"); - aNode = (ProcessingInstruction) doc.importNode(pi, false); - ownerDocument = aNode.getOwnerDocument(); - assertNotNull("ownerDocumentNotNull", ownerDocument); - docType = ownerDocument.getDoctype(); - system = docType.getSystemId(); - assertURIEquals("systemId", null, null, null, "staffNS.dtd", null, null, null, null, system); -target = aNode.getTarget(); - assertEquals("piTarget", "target1", target); - data = aNode.getData(); - assertEquals("piData", "data1", data); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode14"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(importNode14.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode15.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode15.java deleted file mode 100644 index e0d2b86be..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode15.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "importNode(importedNode,deep)" method for a - * Document should import the given importedNode into that Document. - * The importedNode is of type Text. - * - * Create a text node with value being the string "this is text data" in - * a different document. Invoke method importNode(importedNode,deep) on - * this document. Method should return a text node whose value matches - * the above string. The returned node should belong to this document - * whose systemId is "staff.dtd" -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -*/ -public final class importNode15 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public importNode15(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document aNewDoc; - Text text; - Node aNode; - Document ownerDocument; - DocumentType docType; - String system; - String value; - doc = (Document) load("staffNS", true); - aNewDoc = (Document) load("staffNS", true); - text = aNewDoc.createTextNode("this is text data"); - aNode = doc.importNode(text, false); - ownerDocument = aNode.getOwnerDocument(); - assertNotNull("ownerDocumentNotNull", ownerDocument); - docType = ownerDocument.getDoctype(); - system = docType.getSystemId(); - assertURIEquals("systemId", null, null, null, "staffNS.dtd", null, null, null, null, system); -value = aNode.getNodeValue(); - assertEquals("nodeValue", "this is text data", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode15"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(importNode15.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode16.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode16.java deleted file mode 100644 index 0901d9585..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode16.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "importNode(importedNode,deep)" method for a - * Document should raise NOT_SUPPORTED_ERR DOMException if - * the type of node being imported is DocumentType. - * - * Retrieve document staff.xml and get its type. - * Invoke method importNode(importedNode,deep) where importedNode - * contains the document type of the staff.xml. - * Method should raise NOT_SUPPORT_ERR DOMException. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NOT_SUPPORTED_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('Core-Document-importNode')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NOT_SUPPORTED_ERR']) -*/ -public final class importNode16 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public importNode16(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document anotherDoc; - DocumentType docType; - Node node; - doc = (Document) load("staffNS", true); - anotherDoc = (Document) load("staffNS", true); - docType = anotherDoc.getDoctype(); - - { - boolean success = false; - try { - node = doc.importNode(docType, false); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_SUPPORTED_ERR); - } - assertTrue("throw_NOT_SUPPORTED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode16"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(importNode16.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode17.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode17.java deleted file mode 100644 index e2ebe53b9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/importNode17.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "importNode(importedNode,deep)" method for a - * Document should raise NOT_SUPPORTED_ERR DOMException if - * the type of node being imported is Document. - * - * Retrieve staff.xml document. - * Invoke method importNode(importedNode,deep) where importedNode - * contains staff.xml and deep is true. - * Method should raise NOT_SUPPORTED_ERR DOMException. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NOT_SUPPORTED_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('Core-Document-importNode')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NOT_SUPPORTED_ERR']) -*/ -public final class importNode17 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public importNode17(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document anotherDoc; - Node node; - doc = (Document) load("staffNS", true); - anotherDoc = (Document) load("staffNS", true); - - { - boolean success = false; - try { - node = doc.importNode(anotherDoc, false); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_SUPPORTED_ERR); - } - assertTrue("throw_NOT_SUPPORTED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode17"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(importNode17.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/internalSubset01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/internalSubset01.java deleted file mode 100644 index 64c4a7e8e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/internalSubset01.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getInternalSubset()" method returns - * the internal subset as a string or null if there is none. - * This does not contain the delimiting brackets. - * - * Retrieve the documenttype. - * Apply the "getInternalSubset()" method. Null is returned since there - * is not an internal subset. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-Core-DocType-internalSubset -*/ -public final class internalSubset01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public internalSubset01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff2", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - String internal; - doc = (Document) load("staff2", false); - docType = doc.getDoctype(); - internal = docType.getInternalSubset(); - assertNull("internalSubsetNull", internal); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/internalSubset01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(internalSubset01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported01.java deleted file mode 100644 index e13aff314..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported01.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "feature" parameter in the - * isSupported(feature,version)" method is the name - * of the feature and the version is the version number of the - * feature to test. XXX is NOT a legal value for the feature parameter. - * The method should return "false" since XXX is not a valid feature. - * - * Retrieve the root node of the DOM document by invoking - * the "getDocumentElement()" method. This should create a - * node object on which the "isSupported(feature,version)" - * method is invoked with "feature" equal to "XXX" and version to "1.0". - * The method should return a boolean "false" since XXX is not a valid feature. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports -*/ -public final class isSupported01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public isSupported01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node rootNode; - boolean state; - doc = (Document) load("staff", false); - rootNode = doc.getDocumentElement(); - state = rootNode.isSupported("XXX", "1.0"); - assertFalse("throw_False", state); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(isSupported01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported02.java deleted file mode 100644 index cc842d7a2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported02.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "feature" parameter in the - * isSupported(feature,version)" method is the name - * of the feature and the version is the version number of the - * feature to test. XML is a legal value for the feature parameter. - * The method should return "false" since 9.0 is not a valid version. - * - * Retrieve the root node of the DOM document by invoking - * the "getDocumentElement()" method. This should create a - * node object on which the "isSupported(feature,version)" - * method is invoked with "feature" equal to "XML" and version to "9.0". - * The method should return a boolean "false" since 9.0 is not a valid version. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports -*/ -public final class isSupported02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public isSupported02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node rootNode; - boolean state; - doc = (Document) load("staff", false); - rootNode = doc.getDocumentElement(); - state = rootNode.isSupported("XML", "9.0"); - assertFalse("throw_False", state); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(isSupported02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported04.java deleted file mode 100644 index fc499fcb9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported04.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "feature" parameter in the - * isSupported(feature,version)" method is the name - * of the feature and the version is the version number of the - * feature to test. XML is a legal value for the feature parameter - * (Test for xml, lower case). - * Legal values for the version parameter are 1.0 and 2.0 - * (Test for 1.0). - * - * Retrieve the root node of the DOM document by invoking - * the "getDocumentElement()" method. This should create a - * node object on which the "isSupported(feature,version)" - * method is invoked with "feature" equal to "xml" and the version equal to 1.0. - * The method should return a boolean "true". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports -*/ -public final class isSupported04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public isSupported04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node rootNode; - boolean state; - doc = (Document) load("staff", false); - rootNode = doc.getDocumentElement(); - state = rootNode.isSupported("xml", "1.0"); - assertTrue("throw_True", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(isSupported04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported05.java deleted file mode 100644 index 323ddecb9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported05.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "feature" parameter in the - * isSupported(feature,version)" method is the name - * of the feature and the version is the version number of the - * feature to test. Core is a legal value for the feature parameter - * (Test for core, lower case). - * Legal values for the version parameter are 1.0 and 2.0 - * (Test for 2.0). - * - * Retrieve the root node of the DOM document by invoking - * the "getDocumentElement()" method. This should create a - * node object on which the "isSupported(feature,version)" - * method is invoked with "feature" equal to "core" and the version equal to 2.0. - * The method should return a boolean "true". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports -*/ -public final class isSupported05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public isSupported05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node rootNode; - boolean state; - doc = (Document) load("staff", false); - rootNode = doc.getDocumentElement(); - state = rootNode.isSupported("core", "2.0"); - assertTrue("throw_True", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(isSupported05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported06.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported06.java deleted file mode 100644 index 5a49c7398..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported06.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "feature" parameter in the - * isSupported(feature,version)" method is the name - * of the feature and the version is the version number of the - * feature to test. XML is a legal value for the feature parameter - * (Test for xml, lower case). - * Legal values for the version parameter are 1.0 and 2.0 - * (Test for 2.0). - * - * Retrieve the root node of the DOM document by invoking - * the "getDocumentElement()" method. This should create a - * node object on which the "isSupported(feature,version)" - * method is invoked with "feature" equal to "xml" and the version equal to 2.0. - * The method should return a boolean "true". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports -*/ -public final class isSupported06 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public isSupported06(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node rootNode; - boolean state; - doc = (Document) load("staff", false); - rootNode = doc.getDocumentElement(); - state = rootNode.isSupported("xml", "2.0"); - assertTrue("throw_True", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported06"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(isSupported06.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported07.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported07.java deleted file mode 100644 index d01f71d06..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported07.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "feature" parameter in the - * isSupported(feature,version)" method is the name - * of the feature and the version is the version number of the - * feature to test. XML is a legal value for the feature parameter - * (Test for XML). - * If the version is not specified, supporting any version of the - * method to return true. - * - * Retrieve the root node of the DOM document by invoking - * the "getDocumentElement()" method. This should create a - * node object on which the "isSupported(feature,version)" - * method is invoked with "feature" equal to "XML" and the version equal blank. - * The method should return a boolean "true". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports -*/ -public final class isSupported07 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public isSupported07(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node rootNode; - boolean state; - doc = (Document) load("staff", false); - rootNode = doc.getDocumentElement(); - state = rootNode.isSupported("XML", ""); - assertTrue("throw_True", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported07"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(isSupported07.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported09.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported09.java deleted file mode 100644 index 8b4ae14c7..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported09.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "feature" parameter in the - * isSupported(feature,version)" method is the name - * of the feature and the version is the version number of the - * feature to test. XML is a legal value for the feature parameter - * (Test for XML, upper case). - * Legal values for the version parameter are 1.0 and 2.0 - * (Test for 1.0). - * - * Retrieve the root node of the DOM document by invoking - * the "getDocumentElement()" method. This should create a - * node object on which the "isSupported(feature,version)" - * method is invoked with "feature" equal to "XML" and the version equal to 1.0. - * The method should return a boolean "true". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports -*/ -public final class isSupported09 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public isSupported09(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node rootNode; - boolean state; - doc = (Document) load("staff", false); - rootNode = doc.getDocumentElement(); - state = rootNode.isSupported("XML", "1.0"); - assertTrue("throw_True", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported09"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(isSupported09.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported10.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported10.java deleted file mode 100644 index 4414db4b0..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported10.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "feature" parameter in the - * isSupported(feature,version)" method is the name - * of the feature and the version is the version number of the - * feature to test. CORE is a legal value for the feature parameter - * (Test for CORE, upper case). - * Legal values for the version parameter are 1.0 and 2.0 - * (Test for 2.0). - * - * Retrieve the root node of the DOM document by invoking - * the "getDocumentElement()" method. This should create a - * node object on which the "isSupported(feature,version)" - * method is invoked with "feature" equal to "CORE" and the version equal to 2.0. - * The method should return a boolean "true". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports -*/ -public final class isSupported10 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public isSupported10(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node rootNode; - boolean state; - doc = (Document) load("staff", false); - rootNode = doc.getDocumentElement(); - state = rootNode.isSupported("CORE", "2.0"); - assertTrue("throw_True", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported10"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(isSupported10.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported11.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported11.java deleted file mode 100644 index 77e28de17..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported11.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "feature" parameter in the - * isSupported(feature,version)" method is the name - * of the feature and the version is the version number of the - * feature to test. XML is a legal value for the feature parameter - * (Test for XML, upper case). - * Legal values for the version parameter are 1.0 and 2.0 - * (Test for 2.0). - * - * Retrieve the root node of the DOM document by invoking - * the "getDocumentElement()" method. This should create a - * node object on which the "isSupported(feature,version)" - * method is invoked with "feature" equal to "XML" and the version equal to 2.0. - * The method should return a boolean "true". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports -*/ -public final class isSupported11 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public isSupported11(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node rootNode; - boolean state; - doc = (Document) load("staff", false); - rootNode = doc.getDocumentElement(); - state = rootNode.isSupported("XML", "2.0"); - assertTrue("throw_True", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported11"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(isSupported11.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported12.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported12.java deleted file mode 100644 index 6ec49883a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported12.java +++ /dev/null @@ -1,122 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "feature" parameter in the - * isSupported(feature,version)" method is the name - * of the feature and the version is the version number of the - * feature to test. CORE is a legal value for the feature parameter - * (Test for CORE, upper case). - * Legal values for the version parameter are 1.0 and 2.0 - * (Test for 1.0). - * - * Retrieve the root node of the DOM document by invoking - * the "getDocumentElement()" method. This should create a - * node object on which the "isSupported(feature,version)" - * method is invoked with "feature" equal to "CORE" and the version equal to 1.0. - * The method should return a boolean "true". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports -*/ -public final class isSupported12 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public isSupported12(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - java.util.List features = new java.util.ArrayList(); - features.add("Core"); - features.add("XML"); - features.add("HTML"); - features.add("Views"); - features.add("StyleSheets"); - features.add("CSS"); - features.add("CSS2"); - features.add("Events"); - features.add("UIEvents"); - features.add("MouseEvents"); - features.add("MutationEvents"); - features.add("HTMLEvents"); - features.add("Range"); - features.add("Traversal"); - features.add("bogus.bogus.bogus"); - - Document doc; - Node rootNode; - String featureElement; - boolean state; - doc = (Document) load("staff", false); - rootNode = doc.getDocumentElement(); - state = rootNode.isSupported("Core", "2.0"); - assertTrue("Core2", state); - for (int indexN10078 = 0; indexN10078 < features.size(); indexN10078++) { - featureElement = (String) features.get(indexN10078); - state = rootNode.isSupported(featureElement, "1.0"); - } - for (int indexN10083 = 0; indexN10083 < features.size(); indexN10083++) { - featureElement = (String) features.get(indexN10083); - state = rootNode.isSupported(featureElement, "2.0"); - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported12"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(isSupported12.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported13.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported13.java deleted file mode 100644 index 5c5867421..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported13.java +++ /dev/null @@ -1,84 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Calls isSupported("Core","") should return true for all implementations (by extension of core-14). -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports -* @see http://www.w3.org/2000/11/DOM-Level-2-errata#core-14 -*/ -public final class isSupported13 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public isSupported13(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node rootNode; - boolean state; - doc = (Document) load("staff", false); - rootNode = doc.getDocumentElement(); - state = rootNode.isSupported("Core", ""); - assertTrue("Core", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported13"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(isSupported13.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported14.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported14.java deleted file mode 100644 index 2c0cc6b10..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/isSupported14.java +++ /dev/null @@ -1,86 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Calls isSupported("Core",null) should return true for all implementations (by extension of core-14). -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports -* @see http://www.w3.org/2000/11/DOM-Level-2-errata#core-14 -*/ -public final class isSupported14 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public isSupported14(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node rootNode; - boolean state; - String nullString = null; - - doc = (Document) load("staff", false); - rootNode = doc.getDocumentElement(); - state = rootNode.isSupported("Core", nullString); - assertTrue("Core", state); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/isSupported14"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(isSupported14.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/localName01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/localName01.java deleted file mode 100644 index 6b731938c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/localName01.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getLocalName()" method for a Node - * returns the local part of the qualified name of this node, - * and for nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE - * and nodes created with a DOM Level 1 method, this is null. - * - * Retrieve the first emp:address node and get the attributes of this node." - * Then apply the getLocalName() method to the emp:domestic attribute. - * The method should return "domestic". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSLocalN -*/ -public final class localName01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public localName01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - Attr addrAttr; - String localName; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("emp:address"); - testAddr = (Element) elementList.item(0); - assertNotNull("empAddrNotNull", testAddr); - addrAttr = testAddr.getAttributeNode("emp:domestic"); - localName = addrAttr.getLocalName(); - assertEquals("localName", "domestic", localName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/localName01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(localName01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/localName02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/localName02.java deleted file mode 100644 index 5c9f3d184..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/localName02.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getLocalName()" method for a Node - * returns the local part of the qualified name of this node, - * and for nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE - * and nodes created with a DOM Level 1 method, this is null. - * - * Create an new Element with the createElement() method. - * Invoke the "getLocalName()" method on the newly created element - * node will cause "null" to be returned. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSLocalN -*/ -public final class localName02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public localName02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node createdNode; - String localName; - doc = (Document) load("staffNS", false); - createdNode = doc.createElement("test:employee"); - localName = createdNode.getLocalName(); - assertNull("localNameNull", localName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/localName02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(localName02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/localName03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/localName03.java deleted file mode 100644 index 8724c2131..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/localName03.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getLocalName()" method for a Node - * returns the local part of the qualified name of this node, - * and for nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE - * and nodes created with a DOM Level 1 method, this is null. - * - * Retrieve the first employeeId node and get the first child of this node. - * Since the first child is Text node invoking the "getLocalName()" - * method will cause "null" to be returned. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSLocalN -*/ -public final class localName03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public localName03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - Node textNode; - String localName; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("employeeId"); - testEmployee = elementList.item(0); - textNode = testEmployee.getFirstChild(); - localName = textNode.getLocalName(); - assertNull("textNodeLocalName", localName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/localName03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(localName03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/localName04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/localName04.java deleted file mode 100644 index 28e047a1d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/localName04.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getLocalName()" method for a Node - * returns the local part of the qualified name of this node, - * and for nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE - * and nodes created with a DOM Level 1 method, this is null. - * - * Retrieve the first employee node and invoke the "getLocalName()" - * method. The method should return "employee". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSLocalN -*/ -public final class localName04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public localName04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - String employeeLocalName; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("employee"); - testEmployee = elementList.item(0); - employeeLocalName = testEmployee.getLocalName(); - assertEquals("lname", "employee", employeeLocalName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/localName04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(localName04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns01.java deleted file mode 100644 index 9346ba280..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns01.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Using the method getNamedItemNS, retreive the entity "ent1" and notation "notation1" - * from a NamedNodeMap of this DocumentTypes entities and notations. - * Both should be null since entities and notations are not namespaced. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getNamedItemNS -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=407 -* @see http://lists.w3.org/Archives/Member/w3c-dom-ig/2003Nov/0016.html -*/ -public final class namednodemapgetnameditemns01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapgetnameditemns01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap entities; - NamedNodeMap notations; - Entity entity; - Notation notation; - String entityName; - String notationName; - String nullNS = null; - - doc = (Document) load("staffNS", false); - docType = doc.getDoctype(); - entities = docType.getEntities(); - assertNotNull("entitiesNotNull", entities); - notations = docType.getNotations(); - assertNotNull("notationsNotNull", notations); - entity = (Entity) entities.getNamedItemNS(nullNS, "ent1"); - assertNull("entityNull", entity); - notation = (Notation) notations.getNamedItemNS(nullNS, "notation1"); - assertNull("notationNull", notation); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapgetnameditemns01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapgetnameditemns01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns02.java deleted file mode 100644 index a1da01a9e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns02.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getNamedItemNS retrieves a node specified by local name and namespace URI. - * - * Using the method getNamedItemNS, retreive an attribute node having namespaceURI=http://www.nist.gov - * and localName=domestic, from a NamedNodeMap of attribute nodes, for the second element - * whose namespaceURI=http://www.nist.gov and localName=address. Verify if the attr node - * has been retreived successfully by checking its nodeName atttribute. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getNamedItemNS -*/ -public final class namednodemapgetnameditemns02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapgetnameditemns02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attributes; - Node element; - Attr attribute; - NodeList elementList; - String attrName; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "address"); - element = elementList.item(1); - attributes = element.getAttributes(); - attribute = (Attr) attributes.getNamedItemNS("http://www.nist.gov", "domestic"); - attrName = attribute.getNodeName(); - assertEquals("namednodemapgetnameditemns02", "emp:domestic", attrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapgetnameditemns02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapgetnameditemns02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns03.java deleted file mode 100644 index 370ee23bc..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns03.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getNamedItemNS retrieves a node specified by local name and namespace URI. - * - * Create a new Element node and add 2 new attribute nodes having the same local name but different - * namespace names and namespace prefixes to it. Using the getNamedItemNS retreive the second attribute node. - * Verify if the attr node has been retreived successfully by checking its nodeName atttribute. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getNamedItemNS -*/ -public final class namednodemapgetnameditemns03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapgetnameditemns03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attributes; - Node element; - Attr attribute; - Attr newAttr1; - Attr newAttr2; - Attr newAttribute; - String attrName; - doc = (Document) load("staffNS", false); - element = doc.createElementNS("http://www.w3.org/DOM/Test", "root"); - newAttr1 = doc.createAttributeNS("http://www.w3.org/DOM/L1", "L1:att"); - newAttribute = ((Element) /*Node */element).setAttributeNodeNS(newAttr1); - newAttr2 = doc.createAttributeNS("http://www.w3.org/DOM/L2", "L2:att"); - newAttribute = ((Element) /*Node */element).setAttributeNodeNS(newAttr2); - attributes = element.getAttributes(); - attribute = (Attr) attributes.getNamedItemNS("http://www.w3.org/DOM/L2", "att"); - attrName = attribute.getNodeName(); - assertEquals("namednodemapgetnameditemns03", "L2:att", attrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapgetnameditemns03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapgetnameditemns03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns04.java deleted file mode 100644 index 8e901b33d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns04.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getNamedItemNS retrieves a node specified by local name and namespace URI. - * - * Retreive the second address element node having localName=adrress. - * Create a new attribute node having the same name as an existing node but different namespaceURI - * and add it to this element. Using the getNamedItemNS retreive the newly created attribute - * node from a nodemap of attributes of the retreive element node. - * Verify if the attr node has been retreived successfully by checking its nodeName atttribute. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getNamedItemNS -*/ -public final class namednodemapgetnameditemns04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapgetnameditemns04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attributes; - Element element; - Attr attribute; - Attr newAttr1; - Attr newAttribute; - NodeList elementList; - String attrName; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagNameNS("*", "address"); - element = (Element) elementList.item(1); - newAttr1 = doc.createAttributeNS("http://www.w3.org/DOM/L1", "street"); - newAttribute = element.setAttributeNodeNS(newAttr1); - attributes = element.getAttributes(); - attribute = (Attr) attributes.getNamedItemNS("http://www.w3.org/DOM/L1", "street"); - attrName = attribute.getNodeName(); - assertEquals("namednodemapgetnameditemns04", "street", attrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapgetnameditemns04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapgetnameditemns04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns05.java deleted file mode 100644 index 76f937ad9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns05.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getNamedItemNS retrieves a node specified by local name and namespace URI. - * - * Retreieve the second address element and its attribute into a named node map. - * Try retreiving the street attribute from the namednodemap using the - * default namespace uri and the street attribute name. Since the default - * namespace doesnot apply to attributes this should return null. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getNamedItemNS -*/ -public final class namednodemapgetnameditemns05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapgetnameditemns05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attributes; - Node element; - Attr attribute; - NodeList elementList; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagNameNS("*", "address"); - element = elementList.item(1); - attributes = element.getAttributes(); - attribute = (Attr) attributes.getNamedItemNS("*", "street"); - assertNull("namednodemapgetnameditemns05", attribute); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapgetnameditemns05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapgetnameditemns05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns06.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns06.java deleted file mode 100644 index 4ee5a996e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapgetnameditemns06.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retreive the second address element node having localName=adrress. Retreive the attributes - * of this element into 2 nodemaps. Create a new attribute node and add it to this element. - * Since NamedNodeMaps are live each one should get updated, using the getNamedItemNS retreive - * the newly created attribute from each node map. - * Verify if the attr node has been retreived successfully by checking its nodeName atttribute. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getNamedItemNS -*/ -public final class namednodemapgetnameditemns06 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapgetnameditemns06(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attributesMap1; - NamedNodeMap attributesMap2; - Element element; - Attr attribute; - Attr newAttr1; - Attr newAttribute; - NodeList elementList; - String attrName; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagNameNS("*", "address"); - element = (Element) elementList.item(1); - attributesMap1 = element.getAttributes(); - attributesMap2 = element.getAttributes(); - newAttr1 = doc.createAttributeNS("http://www.w3.org/DOM/L1", "street"); - newAttribute = element.setAttributeNodeNS(newAttr1); - attribute = (Attr) attributesMap1.getNamedItemNS("http://www.w3.org/DOM/L1", "street"); - attrName = attribute.getNodeName(); - assertEquals("namednodemapgetnameditemnsMap106", "street", attrName); - attribute = (Attr) attributesMap2.getNamedItemNS("http://www.w3.org/DOM/L1", "street"); - attrName = attribute.getNodeName(); - assertEquals("namednodemapgetnameditemnsMap206", "street", attrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapgetnameditemns06"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapgetnameditemns06.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns01.java deleted file mode 100644 index 9b2ed075c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns01.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method removeNamedItemNS removes a node specified by local name and namespace - * - * Retreive an attribute node and then remove from the NamedNodeMap. Verify if the attribute - * node was actually remove from the node map. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-D58B193 -*/ -public final class namednodemapremovenameditemns01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapremovenameditemns01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attributes; - Node element; - Attr attribute; - NodeList elementList; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "address"); - element = elementList.item(1); - attributes = element.getAttributes(); - attribute = (Attr) attributes.removeNamedItemNS("http://www.nist.gov", "domestic"); - attribute = (Attr) attributes.getNamedItemNS("http://www.nist.gov", "domestic"); - assertNull("namednodemapremovenameditemns01", attribute); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapremovenameditemns01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapremovenameditemns01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns02.java deleted file mode 100644 index 24a451821..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns02.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method removeNamedItemNS removes a node specified by local name and namespace - * A removed attribute may be known to have a default value when this map contains the - * attributes attached to an element, as returned by the attributes attribute of the Node - * interface. If so, an attribute immediately appears containing the default value as well - * as the corresponding namespace URI, local name, and prefix when applicable. - * - * Retreive a default attribute node. Remove it from the NodeMap. Check if a new one immediately - * appears containing the default value. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-D58B193 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class namednodemapremovenameditemns02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapremovenameditemns02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware, -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attributes; - Node element; - Attr attribute; - NodeList elementList; - String attrValue; - String nullNS = null; - - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "employee"); - element = elementList.item(1); - attributes = element.getAttributes(); - attribute = (Attr) attributes.removeNamedItemNS(nullNS, "defaultAttr"); - attribute = (Attr) attributes.getNamedItemNS(nullNS, "defaultAttr"); - attrValue = attribute.getNodeValue(); - assertNotNull("namednodemapremovenameditemns02", attribute); - assertEquals("namednodemapremovenameditemns02_attrValue", "defaultVal", attrValue); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapremovenameditemns02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapremovenameditemns02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns03.java deleted file mode 100644 index 461ba7f69..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns03.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method removeNamedItemNS removes a node specified by local name and namespace - * - * Create a new element node and add 2 new attribute nodes to it that have the same localName - * but different namespaceURI's. Remove the first attribute node from the namedNodeMap of the - * new element node and check to see that the second attribute still exists. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-D58B193 -*/ -public final class namednodemapremovenameditemns03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapremovenameditemns03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attributes; - Node element; - Attr attribute; - Attr newAttribute; - Attr attribute1; - Attr attribute2; - String nodeName; - doc = (Document) load("staffNS", true); - element = doc.createElementNS("http://www.w3.org/DOM/Test", "root"); - attribute1 = doc.createAttributeNS("http://www.w3.org/DOM/L1", "L1:att"); - newAttribute = ((Element) /*Node */element).setAttributeNodeNS(attribute1); - attribute2 = doc.createAttributeNS("http://www.w3.org/DOM/L2", "L2:att"); - newAttribute = ((Element) /*Node */element).setAttributeNodeNS(attribute2); - attributes = element.getAttributes(); - attribute = (Attr) attributes.removeNamedItemNS("http://www.w3.org/DOM/L1", "att"); - attribute = (Attr) attributes.getNamedItemNS("http://www.w3.org/DOM/L2", "att"); - nodeName = attribute.getNodeName(); - assertEquals("namednodemapremovenameditemns02", "L2:att", nodeName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapremovenameditemns03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapremovenameditemns03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns04.java deleted file mode 100644 index a7c361a13..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns04.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method removeNamedItemNS removes a node specified by local name and namespace - * - * Attempt to remove the xmlns and dmstc attributes of the first element node with the localName - * employee. Verify if the 2 attributes were successfully removed. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-D58B193 -*/ -public final class namednodemapremovenameditemns04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapremovenameditemns04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attributes; - Node element; - Attr attribute; - Attr attributeRemoved; - NodeList elementList; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagNameNS("*", "employee"); - element = elementList.item(0); - attributes = element.getAttributes(); - attributeRemoved = (Attr) attributes.removeNamedItemNS("http://www.w3.org/2000/xmlns/", "xmlns"); - attribute = (Attr) attributes.getNamedItemNS("http://www.w3.org/2000/xmlns/", "xmlns"); - assertNull("namednodemapremovenameditemns04_1", attribute); - attributeRemoved = (Attr) attributes.removeNamedItemNS("http://www.w3.org/2000/xmlns/", "dmstc"); - attribute = (Attr) attributes.getNamedItemNS("http://www.w3.org/2000/xmlns/", "dmstc"); - assertNull("namednodemapremovenameditemns04_2", attribute); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapremovenameditemns04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapremovenameditemns04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns05.java deleted file mode 100644 index d5971f782..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns05.java +++ /dev/null @@ -1,131 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retreive an entity and notation node and remove the first notation from the - * entity node map and first entity node from the notation map. Since both these - * maps are readonly, a NO_MODIFICATION_ALLOWED_ERR should be raised. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=407 -* @see http://lists.w3.org/Archives/Member/w3c-dom-ig/2003Nov/0016.html -*/ -public final class namednodemapremovenameditemns05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapremovenameditemns05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap entities; - NamedNodeMap notations; - Node removedNode; - String nullNS = null; - - doc = (Document) load("staffNS", true); - docType = doc.getDoctype(); - entities = docType.getEntities(); - assertNotNull("entitiesNotNull", entities); - notations = docType.getNotations(); - assertNotNull("notationsNotNull", notations); - - try { - removedNode = entities.removeNamedItemNS(nullNS, "ent1"); - fail("entity_throw_DOMException"); - - } catch (DOMException ex) { - switch (ex.code) { - case 8 : - break; - case 7 : - break; - default: - throw ex; - } - } - - try { - removedNode = notations.removeNamedItemNS(nullNS, "notation1"); - fail("notation_throw_DOMException"); - - } catch (DOMException ex) { - switch (ex.code) { - case 8 : - break; - case 7 : - break; - default: - throw ex; - } - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapremovenameditemns05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapremovenameditemns05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns06.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns06.java deleted file mode 100644 index 42d6eff2c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns06.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method removeNamedItemNS removes a node using its namespaceURI and localName and - * raises a NOT_FOUND_ERR if there is no node with the specified namespaceURI and - * localName in this map - * - * Retreive an attribute node into a namednodemap. While removing it from the map specify - * an incorrect namespaceURI. This should raise a NOT_FOUND_ERR. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-D58B193 -*/ -public final class namednodemapremovenameditemns06 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapremovenameditemns06(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attributes; - Node element; - Attr attribute; - NodeList elementList; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "employee"); - element = elementList.item(1); - attributes = element.getAttributes(); - - { - boolean success = false; - try { - attribute = (Attr) attributes.removeNamedItemNS("http://www.Nist.gov", "domestic"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_FOUND_ERR); - } - assertTrue("throw_NOT_FOUND_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapremovenameditemns06"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapremovenameditemns06.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns07.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns07.java deleted file mode 100644 index 86b9ee419..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns07.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method removeNamedItemNS removes a node using its namespaceURI and localName and - * raises a NOT_FOUND_ERR if there is no node with the specified namespaceURI and - * localName in this map - * - * Retreive an attribute node from a namednodemap. While removing it from the map specify - * an incorrect localName. This should raise a NOT_FOUND_ERR. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-D58B193 -*/ -public final class namednodemapremovenameditemns07 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapremovenameditemns07(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attributes; - Node element; - Attr attribute; - NodeList elementList; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "employee"); - element = elementList.item(1); - attributes = element.getAttributes(); - - { - boolean success = false; - try { - attribute = (Attr) attributes.removeNamedItemNS("http://www.nist.gov", "domestic"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_FOUND_ERR); - } - assertTrue("throw_NOT_FOUND_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapremovenameditemns07"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapremovenameditemns07.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns08.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns08.java deleted file mode 100644 index 5c4cad33b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns08.java +++ /dev/null @@ -1,110 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method removeNamedItemNS removes a node using its namespaceURI and localName and - * raises a NOT_FOUND_ERR if there is no node with the specified namespaceURI and - * localName in this map - * - * Retreive an attribute node from a namednodemap. Remove the attribute node from the document - * object. Since NamedNodeMaps are live it should also automatically get removed from - * the node map. And so if an attempt is made to remove it using removeAttributeNS, this should - * raise a NOT_FOUND_ERR. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-D58B193 -*/ -public final class namednodemapremovenameditemns08 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapremovenameditemns08(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attributes; - Element element; - Attr attribute; - NodeList elementList; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "address"); - element = (Element) elementList.item(1); - attributes = element.getAttributes(); - element.removeAttributeNS("http://www.nist.gov", "domestic"); - - { - boolean success = false; - try { - attribute = (Attr) attributes.removeNamedItemNS("http://www.nist.gov", "domestic"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_FOUND_ERR); - } - assertTrue("throw_NOT_FOUND_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapremovenameditemns08"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapremovenameditemns08.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns09.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns09.java deleted file mode 100644 index a04e42fea..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapremovenameditemns09.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method removeNamedItemNS removes a node using its namespaceURI and localName and - * raises a NOT_FOUND_ERR if there is no node with the specified namespaceURI and - * localName in this map - * - * Retreive an attribute node. Remove the attribute node from the node map. - * Check the element object to ensure that the attribute node has been removed from it. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-D58B193 -*/ -public final class namednodemapremovenameditemns09 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapremovenameditemns09(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attributes; - NamedNodeMap newAttributes; - Element element; - Attr attribute; - NodeList elementList; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "address"); - element = (Element) elementList.item(1); - attributes = element.getAttributes(); - attribute = (Attr) attributes.removeNamedItemNS("http://www.nist.gov", "domestic"); - newAttributes = element.getAttributes(); - attribute = (Attr) newAttributes.getNamedItemNS("http://www.nist.gov", "domestic"); - assertNull("namednodemapremovenameditemns09", attribute); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapremovenameditemns09"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapremovenameditemns09.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns01.java deleted file mode 100644 index c11246333..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns01.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setNamedItemNS adds a node using its namespaceURI and localName. If a node with - * that namespace URI and that local name is already present in this map, it is replaced - * by the new one. - * - * Retreive the first element whose localName is address and namespaceURI http://www.nist.gov", - * and put its attributes into a named node map. Create a new attribute node and add it to this map. - * Verify if the attr node was successfully added by checking the nodeName of the retreived atttribute. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getNamedItemNS -*/ -public final class namednodemapsetnameditemns01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapsetnameditemns01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attributes; - Node element; - Attr attribute; - Attr newAttribute; - Attr newAttr1; - NodeList elementList; - String attrName; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "address"); - element = elementList.item(0); - attributes = element.getAttributes(); - newAttr1 = doc.createAttributeNS("http://www.w3.org/DOM/L1", "streets"); - newAttribute = ((Element) /*Node */element).setAttributeNodeNS(newAttr1); - attribute = (Attr) attributes.getNamedItemNS("http://www.w3.org/DOM/L1", "streets"); - attrName = attribute.getNodeName(); - assertEquals("namednodemapsetnameditemns01", "streets", attrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapsetnameditemns01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns02.java deleted file mode 100644 index 1660694a5..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns02.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setNamedItemNS adds a node using its namespaceURI and localName. If a node with - * that namespace URI and that local name is already present in this map, it is replaced - * by the new one. - * - * Create a new element and attribute Node and add the newly created attribute node to the elements - * NamedNodeMap. Verify if the new attr node has been successfully added to the map by checking - * the nodeName of the retreived atttribute from the list of attribute nodes in this map. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS -*/ -public final class namednodemapsetnameditemns02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapsetnameditemns02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attributes; - Element element; - Attr attribute; - Attr attribute1; - Node newNode; - String attrName; - doc = (Document) load("staffNS", true); - element = doc.createElementNS("http://www.w3.org/DOM/Test", "root"); - attribute1 = doc.createAttributeNS("http://www.w3.org/DOM/L1", "L1:att"); - attributes = element.getAttributes(); - newNode = attributes.setNamedItemNS(attribute1); - attribute = (Attr) attributes.getNamedItemNS("http://www.w3.org/DOM/L1", "att"); - attrName = attribute.getNodeName(); - assertEquals("namednodemapsetnameditemns02", "L1:att", attrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapsetnameditemns02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns03.java deleted file mode 100644 index 2cc8279c8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns03.java +++ /dev/null @@ -1,125 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setNamedItemNS adds a node using its namespaceURI and localName and - * raises a WRONG_DOCUMENT_ERR if arg was created from a different document than the - * one that created this map. - * - * Retreieve the second element whose local name is address and its attribute into a named node map. - * Do the same for another document and retreive its street attribute. Call the setNamedItemNS - * using the first namedNodeMap and the retreive street attribute of the second. This should - * raise a WRONG_DOCUMENT_ERR. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=408 -*/ -public final class namednodemapsetnameditemns03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapsetnameditemns03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document docAlt; - NamedNodeMap attributes; - NamedNodeMap attributesAlt; - NodeList elementList; - NodeList elementListAlt; - Element element; - Element elementAlt; - Attr attr; - Node newNode; - String nullNS = null; - - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagNameNS("*", "address"); - element = (Element) elementList.item(1); - attributes = element.getAttributes(); - docAlt = (Document) load("staffNS", true); - elementListAlt = docAlt.getElementsByTagNameNS("*", "address"); - elementAlt = (Element) elementListAlt.item(1); - attributesAlt = elementAlt.getAttributes(); - attr = (Attr) attributesAlt.getNamedItemNS(nullNS, "street"); - newNode = attributesAlt.removeNamedItemNS(nullNS, "street"); - - { - boolean success = false; - try { - newNode = attributes.setNamedItemNS(attr); - } catch (DOMException ex) { - success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); - } - assertTrue("throw_WRONG_DOCUMENT_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapsetnameditemns03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns04.java deleted file mode 100644 index 475b95c52..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns04.java +++ /dev/null @@ -1,120 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setNamedItemNS adds a node using its namespaceURI and localName and - * raises a WRONG_DOCUMENT_ERR if arg was created from a different document than the - * one that created this map. - * - * Retreieve the second element whose local name is address and its attribute into a named node map. - * Create a new document and a new attribute node in it. Call the setNamedItemNS using the first - * namedNodeMap and the new attribute node attribute of the new document. This should - * raise a WRONG_DOCUMENT_ERR. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class namednodemapsetnameditemns04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapsetnameditemns04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DOMImplementation domImpl; - Document docAlt; - DocumentType docType = null; - - NamedNodeMap attributes; - NodeList elementList; - Element element; - Attr attrAlt; - Node newNode; - String nullNS = null; - - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagNameNS("*", "address"); - element = (Element) elementList.item(1); - attributes = element.getAttributes(); - domImpl = doc.getImplementation(); - docAlt = domImpl.createDocument(nullNS, "newDoc", docType); - attrAlt = docAlt.createAttributeNS(nullNS, "street"); - - { - boolean success = false; - try { - newNode = attributes.setNamedItemNS(attrAlt); - } catch (DOMException ex) { - success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); - } - assertTrue("throw_WRONG_DOCUMENT_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapsetnameditemns04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns05.java deleted file mode 100644 index 673f46de1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns05.java +++ /dev/null @@ -1,125 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retreive an entity and notation node and add the first notation to the - * notation node map and first entity node to the entity map. Since both these - * maps are for readonly node, a NO_MODIFICATION_ALLOWED_ERR should be raised. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=407 -* @see http://lists.w3.org/Archives/Member/w3c-dom-ig/2003Nov/0016.html -*/ -public final class namednodemapsetnameditemns05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapsetnameditemns05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap entities; - NamedNodeMap notations; - Entity entity; - Notation notation; - Node newNode; - String nullNS = null; - - doc = (Document) load("staffNS", true); - docType = doc.getDoctype(); - entities = docType.getEntities(); - assertNotNull("entitiesNotNull", entities); - notations = docType.getNotations(); - assertNotNull("notationsNotNull", notations); - entity = (Entity) entities.getNamedItem("ent1"); - notation = (Notation) notations.getNamedItem("notation1"); - - { - boolean success = false; - try { - newNode = entities.setNamedItemNS(entity); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR_entities", success); - } - - { - boolean success = false; - try { - newNode = notations.setNamedItemNS(notation); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR_notations", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapsetnameditemns05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns06.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns06.java deleted file mode 100644 index 93c2886a3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns06.java +++ /dev/null @@ -1,110 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Retreieve the first element whose localName is address and its attributes into a named node map. - * Retreiving the domestic attribute from the namednodemap. - * Retreieve the second element whose localName is address and its attributes into a named node map. - * Invoke setNamedItemNS on the second NamedNodeMap specifying the first domestic attribute from - * the first map. This should raise an INUSE_ATTRIBIUTE_ERR. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS -*/ -public final class namednodemapsetnameditemns06 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapsetnameditemns06(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attributes; - NodeList elementList; - Element element; - Attr attr; - Node newNode; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagNameNS("*", "address"); - element = (Element) elementList.item(0); - attributes = element.getAttributes(); - attr = (Attr) attributes.getNamedItemNS("http://www.usa.com", "domestic"); - element = (Element) elementList.item(1); - attributes = element.getAttributes(); - - { - boolean success = false; - try { - newNode = attributes.setNamedItemNS(attr); - } catch (DOMException ex) { - success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR); - } - assertTrue("namednodemapsetnameditemns06", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns06"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapsetnameditemns06.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns07.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns07.java deleted file mode 100644 index 69582cf0b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns07.java +++ /dev/null @@ -1,116 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setNamedItemNS adds a node using its namespaceURI and localName and - * raises a INUSE_ATTRIBUTE_ERR Raised if arg is an Attr that is already an - * attribute of another Element object. - * - * Retreieve the attributes of first element whose localName is address into a named node map. - * Retreive the attribute whose namespaceURI=http://www.usa.com and localName=domestic - * from the NamedNodeMap. Retreieve the attributes of second element whose localName is address - * into a named node map. Call the setNamedItemNS method on the second nodemap with the domestic - * attribute that was retreived and removed from the first nodeMap as an argument. - * Assuming that when an attribute is removed from a nodemap, it still remains in the domtree - * his should raise an INUSE_ATTRIBIUTE_ERR. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS -*/ -public final class namednodemapsetnameditemns07 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapsetnameditemns07(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attributes; - NodeList elementList; - Element element; - Attr attr; - Node newNode; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagNameNS("*", "address"); - element = (Element) elementList.item(0); - attributes = element.getAttributes(); - attr = (Attr) attributes.getNamedItemNS("http://www.usa.com", "domestic"); - element = (Element) elementList.item(1); - attributes = element.getAttributes(); - - { - boolean success = false; - try { - newNode = attributes.setNamedItemNS(attr); - } catch (DOMException ex) { - success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR); - } - assertTrue("namednodemapsetnameditemns07", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns07"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapsetnameditemns07.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns08.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns08.java deleted file mode 100644 index fd0985a59..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns08.java +++ /dev/null @@ -1,112 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * raises a INUSE_ATTRIBUTE_ERR Raised if arg is an Attr that is already an - * attribute of another Element object. - * Retreieve the first element whose localName is address and its attributes into a named node map. - * Retreiving the domestic attribute from the namednodemap. Retreieve the second element whose - * localName is address and its attributes into a named node map. Invoke setNamedItemNS on the - * second NamedNodeMap specifying the attribute from the first map. - * This should raise an INUSE_ATTRIBIUTE_ERR. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS -*/ -public final class namednodemapsetnameditemns08 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapsetnameditemns08(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NamedNodeMap attributes; - NodeList elementList; - Element element; - Attr attr; - Node newNode; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagNameNS("*", "address"); - element = (Element) elementList.item(0); - attributes = element.getAttributes(); - attr = (Attr) attributes.getNamedItemNS("http://www.usa.com", "domestic"); - element = (Element) elementList.item(1); - attributes = element.getAttributes(); - - { - boolean success = false; - try { - newNode = attributes.setNamedItemNS(attr); - } catch (DOMException ex) { - success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR); - } - assertTrue("namednodemapsetnameditemns08", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns08"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapsetnameditemns08.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns09.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns09.java deleted file mode 100644 index b9102ba6f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns09.java +++ /dev/null @@ -1,118 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setNamedItemNS adds a node using its namespaceURI and localName and - * raises a NO_MODIFICATION_ALLOWED_ERR if this map is readonly. - * - * Create a new attribute node and attempt to add it to the nodemap of entities and notations - * for this documenttype. This should reaise a NO_MODIFICATION_ALLOWED_ERR. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS -*/ -public final class namednodemapsetnameditemns09 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapsetnameditemns09(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap entities; - NamedNodeMap notations; - Attr attr; - Node newNode; - doc = (Document) load("staffNS", true); - docType = doc.getDoctype(); - entities = docType.getEntities(); - notations = docType.getNotations(); - attr = doc.createAttributeNS("http://www.w3.org/DOM/Test", "test"); - - { - boolean success = false; - try { - newNode = entities.setNamedItemNS(attr); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR_entities", success); - } - - { - boolean success = false; - try { - newNode = notations.setNamedItemNS(attr); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR_notations", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns09"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapsetnameditemns09.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns10.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns10.java deleted file mode 100644 index abe6940d1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns10.java +++ /dev/null @@ -1,116 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setNamedItemNS adds a node using its namespaceURI and localName and - * raises a HIERARCHY_REQUEST_ERR if an attempt is made to add a node doesn't belong - * in this NamedNodeMap. - * Attempt to add an entity to a NamedNodeMap of attribute nodes, - * Since nodes of this type cannot be added to the attribute node map a HIERARCHY_REQUEST_ERR - * should be raised. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class namednodemapsetnameditemns10 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapsetnameditemns10(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap entities; - NamedNodeMap attributes; - Entity entity; - Notation notation; - Element element; - NodeList elementList; - Node newNode; - doc = (Document) load("staffNS", true); - docType = doc.getDoctype(); - entities = docType.getEntities(); - assertNotNull("entitiesNotNull", entities); - entity = (Entity) entities.getNamedItem("ent1"); - elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "address"); - element = (Element) elementList.item(0); - attributes = element.getAttributes(); - - { - boolean success = false; - try { - newNode = attributes.setNamedItemNS(entity); - } catch (DOMException ex) { - success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR); - } - assertTrue("throw_HIERARCHY_REQUEST_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns10"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapsetnameditemns10.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns11.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns11.java deleted file mode 100644 index cb9d1b6d3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namednodemapsetnameditemns11.java +++ /dev/null @@ -1,117 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setNamedItemNS adds a node using its namespaceURI and localName and - * raises a HIERARCHY_REQUEST_ERR if an attempt is made to add a node doesn't belong - * in this NamedNodeMap. - * Attempt to add a notation node to a NamedNodeMap of attribute nodes, - * Since notations nodes do not belong in the attribute node map a HIERARCHY_REQUEST_ERR - * should be raised. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class namednodemapsetnameditemns11 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namednodemapsetnameditemns11(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - NamedNodeMap notations; - NamedNodeMap attributes; - Notation notation; - Element element; - NodeList elementList; - Node newNode; - String nullNS = null; - - doc = (Document) load("staffNS", true); - docType = doc.getDoctype(); - notations = docType.getNotations(); - assertNotNull("notationsNotNull", notations); - notation = (Notation) notations.getNamedItem("notation1"); - elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "address"); - element = (Element) elementList.item(0); - attributes = element.getAttributes(); - - { - boolean success = false; - try { - newNode = attributes.setNamedItemNS(notation); - } catch (DOMException ex) { - success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR); - } - assertTrue("throw_HIERARCHY_REQUEST_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns11"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namednodemapsetnameditemns11.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namespaceURI01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namespaceURI01.java deleted file mode 100644 index 7f3b5d00a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namespaceURI01.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNamespaceURI()" method for an Attribute - * returns the namespace URI of this node, or null if unspecified. - * - * Retrieve the first "emp:address" node which has an attribute of "emp:district" - * that is specified in the DTD. - * Invoke the "getNamespaceURI()" method on the attribute. - * The method should return "http://www.nist.gov". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSname -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=238 -*/ -public final class namespaceURI01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namespaceURI01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware, -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - Attr addrAttr; - String attrNamespaceURI; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("emp:address"); - testAddr = (Element) elementList.item(0); - addrAttr = testAddr.getAttributeNodeNS("http://www.nist.gov", "district"); - attrNamespaceURI = addrAttr.getNamespaceURI(); - assertEquals("namespaceURI", "http://www.nist.gov", attrNamespaceURI); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namespaceURI01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namespaceURI01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namespaceURI02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namespaceURI02.java deleted file mode 100644 index ee548ba78..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namespaceURI02.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNamespaceURI()" method for an Attribute - * returns the namespace URI of this node, or null if unspecified. - * - * Retrieve the first emp:address node and get the emp:domestic attribute. - * Invoke the "getNamespaceURI()" method on the attribute. - * The method should return "http://www.nist.gov". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSname -*/ -public final class namespaceURI02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namespaceURI02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element testAddr; - Attr addrAttr; - String attrNamespaceURI; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("emp:address"); - testAddr = (Element) elementList.item(0); - assertNotNull("empAddressNotNull", testAddr); - addrAttr = testAddr.getAttributeNodeNS("http://www.nist.gov", "domestic"); - attrNamespaceURI = addrAttr.getNamespaceURI(); - assertEquals("namespaceURI", "http://www.nist.gov", attrNamespaceURI); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namespaceURI02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namespaceURI02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namespaceURI03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namespaceURI03.java deleted file mode 100644 index 9be77aae5..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namespaceURI03.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNamespaceURI()" method for a Node - * returns the namespace URI of this node, or null if unspecified. - * - * Retrieve the first employee node and invoke the "getNamespaceURI()" - * method. The method should return "http://www.nist.gov". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSname -*/ -public final class namespaceURI03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namespaceURI03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - String employeeNamespace; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("employee"); - testEmployee = elementList.item(0); - assertNotNull("employeeNotNull", testEmployee); - employeeNamespace = testEmployee.getNamespaceURI(); - assertEquals("namespaceURI", "http://www.nist.gov", employeeNamespace); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namespaceURI03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namespaceURI03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namespaceURI04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/namespaceURI04.java deleted file mode 100644 index ad602dc87..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/namespaceURI04.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getNamespaceURI()" method for a Node - * returns the namespace URI of this node, or null if unspecified. - * - * Retrieve the second employee node and invoke the "getNamespaceURI()" - * method. The method should return "null". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSname -*/ -public final class namespaceURI04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public namespaceURI04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - String employeeNamespace; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("employee"); - testEmployee = elementList.item(1); - employeeNamespace = testEmployee.getNamespaceURI(); - assertNull("throw_Null", employeeNamespace); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namespaceURI04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(namespaceURI04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetlocalname03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetlocalname03.java deleted file mode 100644 index 4ff651d9e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetlocalname03.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getLocalName returns the local part of the qualified name of this node. - * - * Ceate two new element nodes and atribute nodes, with and without namespace prefixes. - * Retreive the local part of their qualified names using getLocalName and verrify - * if it is correct. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSLocalN -*/ -public final class nodegetlocalname03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodegetlocalname03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - Element qelement; - Attr attr; - Attr qattr; - String localElemName; - String localQElemName; - String localAttrName; - String localQAttrName; - doc = (Document) load("staff", false); - element = doc.createElementNS("http://www.w3.org/DOM/Test/elem", "elem"); - qelement = doc.createElementNS("http://www.w3.org/DOM/Test/elem", "qual:qelem"); - attr = doc.createAttributeNS("http://www.w3.org/DOM/Test/attr", "attr"); - qattr = doc.createAttributeNS("http://www.w3.org/DOM/Test/attr", "qual:qattr"); - localElemName = element.getLocalName(); - localQElemName = qelement.getLocalName(); - localAttrName = attr.getLocalName(); - localQAttrName = qattr.getLocalName(); - assertEquals("nodegetlocalname03_localElemName", "elem", localElemName); - assertEquals("nodegetlocalname03_localQElemName", "qelem", localQElemName); - assertEquals("nodegetlocalname03_localAttrName", "attr", localAttrName); - assertEquals("nodegetlocalname03_localQAttrName", "qattr", localQAttrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodegetlocalname03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodegetlocalname03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetnamespaceuri03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetnamespaceuri03.java deleted file mode 100644 index e4ee9fe04..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetnamespaceuri03.java +++ /dev/null @@ -1,113 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getNamespaceURI returns the namespace URI of this node, or null if it is unspecified - * For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with - * a DOM Level 1 method, such as createElement from the Document interface, this is always null. - * - * Ceate two new element nodes and atribute nodes, with and without namespace prefixes. - * Retreive their namespaceURI's using getNamespaceURI and verrify if it is correct. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSname -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class nodegetnamespaceuri03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodegetnamespaceuri03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - Element elementNS; - Attr attr; - Attr attrNS; - String elemNSURI; - String elemNSURINull; - String attrNSURI; - String attrNSURINull; - String nullNS = null; - - doc = (Document) load("staff", false); - element = doc.createElementNS(nullNS, "elem"); - elementNS = doc.createElementNS("http://www.w3.org/DOM/Test/elem", "qual:qelem"); - attr = doc.createAttributeNS(nullNS, "attr"); - attrNS = doc.createAttributeNS("http://www.w3.org/DOM/Test/attr", "qual:qattr"); - elemNSURI = elementNS.getNamespaceURI(); - elemNSURINull = element.getNamespaceURI(); - attrNSURI = attrNS.getNamespaceURI(); - attrNSURINull = attr.getNamespaceURI(); - assertEquals("nodegetnamespaceuri03_elemNSURI", "http://www.w3.org/DOM/Test/elem", elemNSURI); - assertNull("nodegetnamespaceuri03_1", elemNSURINull); - assertEquals("nodegetnamespaceuri03_attrNSURI", "http://www.w3.org/DOM/Test/attr", attrNSURI); - assertNull("nodegetnamespaceuri03_2", attrNSURINull); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodegetnamespaceuri03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodegetnamespaceuri03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetownerdocument01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetownerdocument01.java deleted file mode 100644 index d90d86694..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetownerdocument01.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getOwnerDocument returns the Document object associated with this node - * - * Create a new DocumentType node. Since this node is not used with any Document yet - * verify if the ownerDocument is null. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#node-ownerDoc -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class nodegetownerdocument01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodegetownerdocument01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document ownerDoc; - DOMImplementation domImpl; - DocumentType docType; - String nullID = null; - - doc = (Document) load("staff", false); - domImpl = doc.getImplementation(); - docType = domImpl.createDocumentType("mydoc", nullID, nullID); - ownerDoc = docType.getOwnerDocument(); - assertNull("nodegetownerdocument01", ownerDoc); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodegetownerdocument01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodegetownerdocument01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetownerdocument02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetownerdocument02.java deleted file mode 100644 index 9c7b89dc8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetownerdocument02.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getOwnerDocument returns the Document object associated with this node - * - * Create a new Document node. Since this node is not used with any Document yet - * verify if the ownerDocument is null. Create a new element Node on the new Document - * object. Check the ownerDocument of the new element node. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#node-ownerDoc -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class nodegetownerdocument02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodegetownerdocument02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document newDoc; - Element newElem; - Document ownerDocDoc; - Document ownerDocElem; - DOMImplementation domImpl; - DocumentType docType; - String nullNS = null; - - doc = (Document) load("staff", false); - domImpl = doc.getImplementation(); - docType = domImpl.createDocumentType("mydoc", nullNS, nullNS); - newDoc = domImpl.createDocument("http://www.w3.org/DOM/Test", "mydoc", docType); - ownerDocDoc = newDoc.getOwnerDocument(); - assertNull("nodegetownerdocument02_1", ownerDocDoc); - newElem = newDoc.createElementNS("http://www.w3.org/DOM/Test", "myelem"); - ownerDocElem = newElem.getOwnerDocument(); - assertNotNull("nodegetownerdocument02_2", ownerDocElem); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodegetownerdocument02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodegetownerdocument02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetprefix03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetprefix03.java deleted file mode 100644 index 2cba0eb30..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodegetprefix03.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method getPrefix returns the namespace prefix of this node, or null if it is unspecified. - * - * Ceate two new element nodes and atribute nodes, with and without namespace prefixes. - * Retreive the prefix part of their qualified names using getPrefix and verify - * if it is correct. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -*/ -public final class nodegetprefix03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodegetprefix03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - Element qelement; - Attr attr; - Attr qattr; - String elemNoPrefix; - String elemPrefix; - String attrNoPrefix; - String attrPrefix; - doc = (Document) load("staff", false); - element = doc.createElementNS("http://www.w3.org/DOM/Test/elem", "elem"); - qelement = doc.createElementNS("http://www.w3.org/DOM/Test/elem", "qual:qelem"); - attr = doc.createAttributeNS("http://www.w3.org/DOM/Test/attr", "attr"); - qattr = doc.createAttributeNS("http://www.w3.org/DOM/Test/attr", "qual:qattr"); - elemNoPrefix = element.getPrefix(); - elemPrefix = qelement.getPrefix(); - attrNoPrefix = attr.getPrefix(); - attrPrefix = qattr.getPrefix(); - assertNull("nodegetprefix03_1", elemNoPrefix); - assertEquals("nodegetprefix03_2", "qual", elemPrefix); - assertNull("nodegetprefix03_3", attrNoPrefix); - assertEquals("nodegetprefix03_4", "qual", attrPrefix); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodegetprefix03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodegetprefix03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodehasattributes01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodehasattributes01.java deleted file mode 100644 index 45c90d2a6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodehasattributes01.java +++ /dev/null @@ -1,92 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method hasAttributes returns whether this node (if it is an element) has any attributes. - * Retreive an element node without attributes. Verify if hasAttributes returns false. - * Retreive another element node with attributes. Verify if hasAttributes returns true. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeHasAttrs -*/ -public final class nodehasattributes01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodehasattributes01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - NodeList elementList; - boolean hasAttributes; - doc = (Document) load("staff", false); - elementList = doc.getElementsByTagName("employee"); - element = (Element) elementList.item(0); - hasAttributes = element.hasAttributes(); - assertFalse("nodehasattributes01_1", hasAttributes); -elementList = doc.getElementsByTagName("address"); - element = (Element) elementList.item(0); - hasAttributes = element.hasAttributes(); - assertTrue("nodehasattributes01_2", hasAttributes); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodehasattributes01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodehasattributes01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodehasattributes02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodehasattributes02.java deleted file mode 100644 index 93660cdde..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodehasattributes02.java +++ /dev/null @@ -1,99 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method hasAttributes returns whether this node (if it is an element) has any attributes. - * Retrieve the docType node. Since this is not an element node check if hasAttributes returns - * null. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeHasAttrs -*/ -public final class nodehasattributes02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodehasattributes02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - boolean hasAttributes; - doc = (Document) load("staffNS", false); - docType = doc.getDoctype(); - hasAttributes = docType.hasAttributes(); - assertFalse("nodehasattributes02", hasAttributes); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodehasattributes02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodehasattributes02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodehasattributes03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodehasattributes03.java deleted file mode 100644 index 555b93488..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodehasattributes03.java +++ /dev/null @@ -1,88 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method hasAttributes returns whether this node (if it is an element) has any attributes. - * Retreive an element node with a default attributes. Verify if hasAttributes returns true. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeHasAttrs -*/ -public final class nodehasattributes03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodehasattributes03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - NodeList elementList; - boolean hasAttributes; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("emp:employee"); - element = (Element) elementList.item(0); - assertNotNull("empEmployeeNotNull", element); - hasAttributes = element.hasAttributes(); - assertTrue("hasAttributes", hasAttributes); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodehasattributes03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodehasattributes03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodehasattributes04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodehasattributes04.java deleted file mode 100644 index eeef3d0d9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodehasattributes04.java +++ /dev/null @@ -1,111 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method hasAttributes returns whether this node (if it is an element) has any attributes. - * Create a new Document, Element and Attr node. Add the Attr to the Element and append the - * Element to the Document. Retreive the newly created element node from the document and check - * if it has attributes using hasAttributes. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeHasAttrs -*/ -public final class nodehasattributes04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodehasattributes04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document newDoc; - DocumentType docType = null; - - DOMImplementation domImpl; - Element element; - Element elementTest; - Element elementDoc; - Attr attribute; - Node setNode; - Node appendedChild; - NodeList elementList; - boolean hasAttributes; - doc = (Document) load("staffNS", false); - domImpl = doc.getImplementation(); - newDoc = domImpl.createDocument("http://www.w3.org/DOM/Test", "test", docType); - element = newDoc.createElementNS("http://www.w3.org/DOM/Test", "dom:elem"); - attribute = newDoc.createAttribute("attr"); - setNode = element.setAttributeNode(attribute); - elementDoc = newDoc.getDocumentElement(); - appendedChild = elementDoc.appendChild(element); - elementList = newDoc.getElementsByTagNameNS("http://www.w3.org/DOM/Test", "elem"); - elementTest = (Element) elementList.item(0); - hasAttributes = elementTest.hasAttributes(); - assertTrue("nodehasattributes04", hasAttributes); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodehasattributes04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodehasattributes04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported01.java deleted file mode 100644 index 7747d983f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported01.java +++ /dev/null @@ -1,116 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method "isSupported(feature,version)" Tests whether the DOM implementation - * implements a specific feature and that feature is supported by this node. - * - * Call the isSupported method on the document element node with a combination of features - * versions and versions as below. Valid feature names are case insensitive and versions - * "2.0", "1.0" and if the version is not specified, supporting any version of the feature - * should return true. Check if the value returned value was true. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports -*/ -public final class nodeissupported01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeissupported01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - String version = ""; - String version1 = "1.0"; - String version2 = "2.0"; - String featureCore; - String featureXML; - boolean success; - java.util.List featuresXML = new java.util.ArrayList(); - featuresXML.add("XML"); - featuresXML.add("xmL"); - - java.util.List featuresCore = new java.util.ArrayList(); - featuresCore.add("Core"); - featuresCore.add("CORE"); - - doc = (Document) load("staffNS", false); - element = doc.getDocumentElement(); - for (int indexN10063 = 0; indexN10063 < featuresXML.size(); indexN10063++) { - featureXML = (String) featuresXML.get(indexN10063); - success = element.isSupported(featureXML, version); - assertTrue("nodeissupported01_XML1", success); - success = element.isSupported(featureXML, version1); - assertTrue("nodeissupported01_XML2", success); - } - for (int indexN1007C = 0; indexN1007C < featuresCore.size(); indexN1007C++) { - featureCore = (String) featuresCore.get(indexN1007C); - success = element.isSupported(featureCore, version); - assertTrue("nodeissupported01_Core1", success); - success = element.isSupported(featureCore, version1); - success = element.isSupported(featureCore, version2); - assertTrue("nodeissupported01_Core3", success); - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodeissupported01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeissupported01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported02.java deleted file mode 100644 index 0db6e1a03..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported02.java +++ /dev/null @@ -1,116 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method "isSupported(feature,version)" Tests whether the DOM implementation - * implements a specific feature and that feature is supported by this node. - * - * Call the isSupported method on a new attribute node with a combination of features - * versions and versions as below. Valid feature names are case insensitive and versions - * "2.0", "1.0" and if the version is not specified, supporting any version of the feature - * should return true. Check if the value returned value was true. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports -*/ -public final class nodeissupported02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeissupported02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr attribute; - String version = ""; - String version1 = "1.0"; - String version2 = "2.0"; - String featureCore; - String featureXML; - boolean success; - java.util.List featuresXML = new java.util.ArrayList(); - featuresXML.add("XML"); - featuresXML.add("xmL"); - - java.util.List featuresCore = new java.util.ArrayList(); - featuresCore.add("Core"); - featuresCore.add("CORE"); - - doc = (Document) load("staffNS", false); - attribute = doc.createAttribute("TestAttr"); - for (int indexN10064 = 0; indexN10064 < featuresXML.size(); indexN10064++) { - featureXML = (String) featuresXML.get(indexN10064); - success = attribute.isSupported(featureXML, version); - assertTrue("nodeissupported02_XML1", success); - success = attribute.isSupported(featureXML, version1); - assertTrue("nodeissupported02_XML2", success); - } - for (int indexN1007D = 0; indexN1007D < featuresCore.size(); indexN1007D++) { - featureCore = (String) featuresCore.get(indexN1007D); - success = attribute.isSupported(featureCore, version); - assertTrue("nodeissupported02_Core1", success); - success = attribute.isSupported(featureCore, version1); - success = attribute.isSupported(featureCore, version2); - assertTrue("nodeissupported02_Core3", success); - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodeissupported02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeissupported02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported03.java deleted file mode 100644 index 2565c42b4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported03.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method "isSupported(feature,version)" Tests whether the DOM implementation - * implements a specific feature and that feature is supported by this node. - * - * Call the isSupported method specifying empty strings for feature and version on a docType - * Node. Check if the value returned value was false. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports -*/ -public final class nodeissupported03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeissupported03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - boolean success; - doc = (Document) load("staffNS", false); - docType = doc.getDoctype(); - success = docType.isSupported("", ""); - assertFalse("nodeissupported03", success); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodeissupported03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeissupported03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported04.java deleted file mode 100644 index b3180c817..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported04.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method "isSupported(feature,version)" Tests whether the DOM implementation - * implements a specific feature and that feature is supported by this node. - * - * Call the isSupported method specifying empty strings for feature and version on a - * new EntityReference node. Check if the value returned value was false. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports -*/ -public final class nodeissupported04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeissupported04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - EntityReference entRef; - boolean success; - doc = (Document) load("staffNS", false); - entRef = doc.createEntityReference("ent1"); - assertNotNull("createdEntRefNotNull", entRef); - success = entRef.isSupported("XML CORE", ""); - assertFalse("nodeissupported04", success); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodeissupported04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeissupported04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported05.java deleted file mode 100644 index eaa5a90f6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodeissupported05.java +++ /dev/null @@ -1,101 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - - - -Copyright (c) 2001 World Wide Web Consortium, - -(Massachusetts Institute of Technology, Institut National de - -Recherche en Informatique et en Automatique, Keio University). All - -Rights Reserved. This program is distributed under the W3C's Software - -Intellectual Property License. This program is distributed in the - -hope that it will be useful, but WITHOUT ANY WARRANTY; without even - -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - -PURPOSE. - - - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method "isSupported(feature,version)" Tests whether the DOM implementation - * implements a specific feature and that feature is supported by this node. - * - * Call the isSupported method specifying bad values for feature and version on a new - * Processing Instruction node. Check if the value returned from this method value was false. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports -*/ -public final class nodeissupported05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodeissupported05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - ProcessingInstruction pi; - boolean success; - doc = (Document) load("staffNS", false); - pi = doc.createProcessingInstruction("PITarget", "PIData"); - success = pi.isSupported("-", "+"); - assertFalse("nodeissupported05", success); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodeissupported05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodeissupported05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodenormalize01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodenormalize01.java deleted file mode 100644 index b2d4563a0..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodenormalize01.java +++ /dev/null @@ -1,193 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method "normalize" puts all Text nodes in the full depth of the sub-tree underneath - * this Node, including attribute nodes, into a "normal" form where only structure - * (e.g., elements, comments, processing instructions, CDATA sections, and entity references) - * separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes. - * - * Create a dom tree consisting of elements, comments, processing instructions, CDATA sections, - * and entity references nodes seperated by text nodes. Check the length of the node list of each - * before and after normalize has been called. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-normalize -*/ -public final class nodenormalize01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodenormalize01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Document newDoc; - DOMImplementation domImpl; - DocumentType docType; - DocumentType docTypeNull = null; - - Element documentElement; - Element element1; - Element element2; - Element element3; - Element element4; - Element element5; - Element element6; - Element element7; - Text text1; - Text text2; - Text text3; - ProcessingInstruction pi; - CDATASection cData; - Comment comment; - EntityReference entRef; - NodeList elementList; - Node appendedChild; - doc = (Document) load("staffNS", true); - domImpl = doc.getImplementation(); - newDoc = domImpl.createDocument("http://www.w3.org/DOM/Test", "dom:root", docTypeNull); - element1 = newDoc.createElement("element1"); - element2 = newDoc.createElement("element2"); - element3 = newDoc.createElement("element3"); - element4 = newDoc.createElement("element4"); - element5 = newDoc.createElement("element5"); - element6 = newDoc.createElement("element6"); - element7 = newDoc.createElement("element7"); - text1 = newDoc.createTextNode("text1"); - text2 = newDoc.createTextNode("text2"); - text3 = newDoc.createTextNode("text3"); - cData = newDoc.createCDATASection("Cdata"); - comment = newDoc.createComment("comment"); - pi = newDoc.createProcessingInstruction("PITarget", "PIData"); - entRef = newDoc.createEntityReference("EntRef"); - assertNotNull("createdEntRefNotNull", entRef); - documentElement = newDoc.getDocumentElement(); - appendedChild = documentElement.appendChild(element1); - appendedChild = element2.appendChild(text1); - appendedChild = element2.appendChild(text2); - appendedChild = element2.appendChild(text3); - appendedChild = element1.appendChild(element2); - text1 = (Text) text1.cloneNode(false); - text2 = (Text) text2.cloneNode(false); - appendedChild = element3.appendChild(entRef); - appendedChild = element3.appendChild(text1); - appendedChild = element3.appendChild(text2); - appendedChild = element1.appendChild(element3); - text1 = (Text) text1.cloneNode(false); - text2 = (Text) text2.cloneNode(false); - appendedChild = element4.appendChild(cData); - appendedChild = element4.appendChild(text1); - appendedChild = element4.appendChild(text2); - appendedChild = element1.appendChild(element4); - text2 = (Text) text2.cloneNode(false); - text3 = (Text) text3.cloneNode(false); - appendedChild = element5.appendChild(comment); - appendedChild = element5.appendChild(text2); - appendedChild = element5.appendChild(text3); - appendedChild = element1.appendChild(element5); - text2 = (Text) text2.cloneNode(false); - text3 = (Text) text3.cloneNode(false); - appendedChild = element6.appendChild(pi); - appendedChild = element6.appendChild(text2); - appendedChild = element6.appendChild(text3); - appendedChild = element1.appendChild(element6); - entRef = (EntityReference) entRef.cloneNode(false); - text1 = (Text) text1.cloneNode(false); - text2 = (Text) text2.cloneNode(false); - text3 = (Text) text3.cloneNode(false); - appendedChild = element7.appendChild(entRef); - appendedChild = element7.appendChild(text1); - appendedChild = element7.appendChild(text2); - appendedChild = element7.appendChild(text3); - appendedChild = element1.appendChild(element7); - elementList = element1.getChildNodes(); - assertSize("nodeNormalize01_1Bef", 6, elementList); - elementList = element2.getChildNodes(); - assertSize("nodeNormalize01_2Bef", 3, elementList); - elementList = element3.getChildNodes(); - assertSize("nodeNormalize01_3Bef", 3, elementList); - elementList = element4.getChildNodes(); - assertSize("nodeNormalize01_4Bef", 3, elementList); - elementList = element5.getChildNodes(); - assertSize("nodeNormalize01_5Bef", 3, elementList); - elementList = element6.getChildNodes(); - assertSize("nodeNormalize01_6Bef", 3, elementList); - elementList = element7.getChildNodes(); - assertSize("nodeNormalize01_7Bef", 4, elementList); - newDoc.normalize(); - elementList = element1.getChildNodes(); - assertSize("nodeNormalize01_1Aft", 6, elementList); - elementList = element2.getChildNodes(); - assertSize("nodeNormalize01_2Aft", 1, elementList); - elementList = element3.getChildNodes(); - assertSize("nodeNormalize01_3Aft", 2, elementList); - elementList = element4.getChildNodes(); - assertSize("nodeNormalize01_4Aft", 2, elementList); - elementList = element5.getChildNodes(); - assertSize("nodeNormalize01_5Aft", 2, elementList); - elementList = element6.getChildNodes(); - assertSize("nodeNormalize01_6Aft", 2, elementList); - elementList = element7.getChildNodes(); - assertSize("nodeNormalize01_7Aft", 2, elementList); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodenormalize01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodenormalize01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix01.java deleted file mode 100644 index efd2e5068..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix01.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setPrefix sets the namespace prefix of this node. Note that setting this attribute, - * when permitted, changes the nodeName attribute, which holds the qualified name, as well as the - * tagName and name attributes of the Element and Attr interfaces, when applicable. - * - * Create a new element node with a namespace prefix. Add it to a new DocumentFragment Node without - * a prefix. Call setPrefix on the elemen node. Check if the prefix was set correctly on the element. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -*/ -public final class nodesetprefix01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodesetprefix01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentFragment docFragment; - Element element; - String elementTagName; - String elementNodeName; - Node appendedChild; - doc = (Document) load("staff", true); - docFragment = doc.createDocumentFragment(); - element = doc.createElementNS("http://www.w3.org/DOM/Test", "emp:address"); - appendedChild = docFragment.appendChild(element); - element.setPrefix("dmstc"); - elementTagName = element.getTagName(); - elementNodeName = element.getNodeName(); - assertEquals("nodesetprefix01_tagname", "dmstc:address", elementTagName); - assertEquals("nodesetprefix01_nodeName", "dmstc:address", elementNodeName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodesetprefix01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodesetprefix01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix02.java deleted file mode 100644 index ef710d74a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix02.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setPrefix sets the namespace prefix of this node. Note that setting this attribute, - * when permitted, changes the nodeName attribute, which holds the qualified name, as well as the - * tagName and name attributes of the Element and Attr interfaces, when applicable. - * Create a new attribute node and add it to an element node with an existing attribute having - * the same localName as this attribute but different namespaceURI. Change the prefix of the - * newly created attribute using setPrefix. Check if the new attribute nodeName has changed - * and the existing attribute is the same. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -*/ -public final class nodesetprefix02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodesetprefix02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - Attr attribute; - Attr newAttribute; - Node setNode; - NodeList elementList; - String attrName; - String newAttrName; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("address"); - element = (Element) elementList.item(1); - newAttribute = doc.createAttributeNS("http://www.w3.org/DOM/Test", "test:address"); - setNode = element.setAttributeNodeNS(newAttribute); - newAttribute.setPrefix("dom"); - attribute = element.getAttributeNodeNS("http://www.usa.com", "domestic"); - attrName = attribute.getNodeName(); - newAttrName = newAttribute.getNodeName(); - assertEquals("nodesetprefix02_attrName", "dmstc:domestic", attrName); - assertEquals("nodesetprefix02_newAttrName", "dom:address", newAttrName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodesetprefix02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodesetprefix02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix03.java deleted file mode 100644 index ceaf5a7ab..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix03.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setPrefix raises a NAMESPACE_ERR if the namespaceURI of this node is null. - * - * Create a new element node without a namespace prefix. Call setPrefix on the newly created elemenent node. - * Check if a NAMESPACE_ERR is thrown. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -*/ -public final class nodesetprefix03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodesetprefix03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - doc = (Document) load("staffNS", true); - element = doc.createElement("address"); - - { - boolean success = false; - try { - element.setPrefix("test"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodesetprefix03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodesetprefix03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix04.java deleted file mode 100644 index 9d17031d4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix04.java +++ /dev/null @@ -1,108 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setPrefix raises a NAMESPACE_ERR if the namespaceURI of this node is null. - * Retreive the a default Attribute node which does not have a namespace prefix. Call the setPrefix - * method on it. Check if a NAMESPACE_ERR is thrown. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259 -*/ -public final class nodesetprefix04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodesetprefix04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware, -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - Attr attribute; - NodeList elementList; - String nullNS = null; - - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("emp:employee"); - element = (Element) elementList.item(0); - assertNotNull("empEmployeeNotNull", element); - attribute = element.getAttributeNodeNS(nullNS, "defaultAttr"); - - { - boolean success = false; - try { - attribute.setPrefix("test"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("nodesetprefix04", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodesetprefix04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodesetprefix04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix05.java deleted file mode 100644 index b9ba1c6a9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix05.java +++ /dev/null @@ -1,110 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setPrefix raises a NAMESPACE_ERR if the specified prefix is malformed. - * Create a new namespace aware element node and call the setPrefix method on it with several malformed - * prefix values. Check if a NAMESPACE_ERR is thrown. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -*/ -public final class nodesetprefix05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodesetprefix05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - String prefixValue; - java.util.List prefixValues = new java.util.ArrayList(); - prefixValues.add("_:"); - prefixValues.add(":0"); - prefixValues.add(":"); - prefixValues.add("_::"); - prefixValues.add("a:0:c"); - - doc = (Document) load("staffNS", true); - element = doc.createElementNS("http://www.w3.org/DOM/Test/L2", "dom:elem"); - for (int indexN10050 = 0; indexN10050 < prefixValues.size(); indexN10050++) { - prefixValue = (String) prefixValues.get(indexN10050); - - { - boolean success = false; - try { - element.setPrefix(prefixValue); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } - } - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodesetprefix05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodesetprefix05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix06.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix06.java deleted file mode 100644 index 6292d736d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix06.java +++ /dev/null @@ -1,95 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setPrefix raises a NAMESPACE_ERR if the specified prefix is "xml" and the namespaceURI - * of this node is different from "http://www.w3.org/XML/1998/namespace". - * Invoke the setPrefix method on this Element object with namespaceURI that is different from - * http://www..w3.org/xml/1998/namespace and a prefix whose values is xml. - * Check if the NAMESPACE_ERR was thrown. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -*/ -public final class nodesetprefix06 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodesetprefix06(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - doc = (Document) load("staffNS", true); - element = doc.createElementNS("http://www.w3.org/DOM/Test/L2", "dom:elem"); - - { - boolean success = false; - try { - element.setPrefix("xml"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodesetprefix06"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodesetprefix06.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix07.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix07.java deleted file mode 100644 index 19dcb6ed1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix07.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setPrefix raises a NAMESPACE_ERR if this node is an attribute and the specified - * prefix is "xmlns" and the namespaceURI of this node is different from - * "http://www.w3.org/2000/xmlns/". - * Create a new attribute node whose namespaceURI is different form "http://www.w3.org/2000/xmlns/" - * and node prefix is "xmlns". - * Check if the NAMESPACE_ERR was thrown. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -*/ -public final class nodesetprefix07 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodesetprefix07(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr attribute; - doc = (Document) load("staffNS", true); - attribute = doc.createAttributeNS("http://www.w3.org/DOM/Test/L2", "abc:elem"); - - { - boolean success = false; - try { - attribute.setPrefix("xmlns"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodesetprefix07"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodesetprefix07.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix08.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix08.java deleted file mode 100644 index 6ddad330c..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix08.java +++ /dev/null @@ -1,98 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setPrefix raises a NAMESPACE_ERR if this node is an attribute and the qualifiedName - * of this node is "xmlns - * Retreive an attribute node whose qualifiedName is xmlns. Try setting a prefix on this node. - * Check if the NAMESPACE_ERR was thrown. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -*/ -public final class nodesetprefix08 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodesetprefix08(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element element; - NodeList elementList; - Attr attribute; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("employee"); - element = (Element) elementList.item(0); - attribute = element.getAttributeNode("xmlns"); - - { - boolean success = false; - try { - attribute.setPrefix("xml"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodesetprefix08"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodesetprefix08.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix09.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix09.java deleted file mode 100644 index 426489f1b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/nodesetprefix09.java +++ /dev/null @@ -1,94 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The method setPrefix raises a INVALID_CHARACTER_ERR if the specified prefix contains an illegal character. - * Create a new namespace aware element node and call the setPrefix method on it with a prefix having - * an invalid character. Check if a NAMESPACE_ERR is thrown. -* @author IBM -* @author Neil Delima -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -*/ -public final class nodesetprefix09 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public nodesetprefix09(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - String value = "#$%&'()@"; - Element element; - doc = (Document) load("staffNS", true); - element = doc.createElementNS("http://www.w3.org/DOM/Test/L2", "dom:elem"); - - { - boolean success = false; - try { - element.setPrefix(value); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodesetprefix09"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(nodesetprefix09.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/normalize01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/normalize01.java deleted file mode 100644 index d3b76bff1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/normalize01.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "normalize()" method puts all the nodes in the full - * depth of the sub-tree underneath this element into a - * "normal" form. - * - * Retrieve the third employee and access its second child. - * This child contains a block of text that is spread - * across multiple lines. The content of the "name" child - * should be parsed and treated as a single Text node. - * This appears to be a duplicate of elementnormalize.xml in DOM L1 Test Suite -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-normalize -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-72AB8359 -*/ -public final class normalize01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public normalize01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Element root; - NodeList elementList; - Node firstChild; - NodeList textList; - CharacterData textNode; - String data; - doc = (Document) load("staff", false); - root = doc.getDocumentElement(); - root.normalize(); - elementList = root.getElementsByTagName("name"); - firstChild = elementList.item(2); - textList = firstChild.getChildNodes(); - textNode = (CharacterData) textList.item(0); - data = textNode.getData(); - assertEquals("data", "Roger\n Jones", data); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/normalize01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(normalize01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/ownerDocument01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/ownerDocument01.java deleted file mode 100644 index f77f32a2d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/ownerDocument01.java +++ /dev/null @@ -1,86 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getOwnerDocument()" method returns null if the target - * node itself is a DocumentType which is not used with any document yet. - * - * Invoke the "getOwnerDocument()" method on the master - * document. The DocumentType returned should be null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#node-ownerDoc -*/ -public final class ownerDocument01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public ownerDocument01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType ownerDocument; - doc = (Document) load("staff", false); - ownerDocument = (DocumentType) doc.getOwnerDocument(); - assertNull("throw_Null", ownerDocument); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/ownerDocument01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(ownerDocument01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/ownerElement01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/ownerElement01.java deleted file mode 100644 index 29fae6e4f..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/ownerElement01.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getOwnerElement()" will return the Element node this attribute - * is attached to or null if this attribute is not in use. - * Get the "domestic" attribute from the first "address" node. - * Apply the "getOwnerElement()" method to get the Element associated - * with the attribute. The value returned should be "address". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-F68D095 -*/ -public final class ownerElement01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public ownerElement01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList addressList; - Node testNode; - NamedNodeMap attributes; - Attr domesticAttr; - Element elementNode; - String name; - doc = (Document) load("staff", false); - addressList = doc.getElementsByTagName("address"); - testNode = addressList.item(0); - attributes = testNode.getAttributes(); - domesticAttr = (Attr) attributes.getNamedItem("domestic"); - elementNode = domesticAttr.getOwnerElement(); - name = elementNode.getNodeName(); - assertEquals("throw_Equals", "address", name); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/ownerElement01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(ownerElement01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/ownerElement02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/ownerElement02.java deleted file mode 100644 index f138c05ac..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/ownerElement02.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getOwnerElement()" will return the Element node this attribute - * is attached to or null if this attribute is not in use. - * Create a new attribute. - * Apply the "getOwnerElement()" method to get the Element associated - * with the attribute. The value returned should be "null" since this - * attribute is not in use. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Attr-ownerElement -*/ -public final class ownerElement02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public ownerElement02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Attr newAttr; - Element elementNode; - doc = (Document) load("staff", false); - newAttr = doc.createAttribute("newAttribute"); - elementNode = newAttr.getOwnerElement(); - assertNull("throw_Null", elementNode); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/ownerElement02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(ownerElement02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix01.java deleted file mode 100644 index b338452f7..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix01.java +++ /dev/null @@ -1,91 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getPrefix()" method for a Node - * returns the namespace prefix of the node, - * and for nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE - * and nodes created with a DOM Level 1 method, this is null. - * - * Create an new Element with the createElement() method. - * Invoke the "getPrefix()" method on the newly created element - * node will cause "null" to be returned. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -*/ -public final class prefix01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public prefix01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - Node createdNode; - String prefix; - doc = (Document) load("staffNS", false); - createdNode = doc.createElement("test:employee"); - prefix = createdNode.getPrefix(); - assertNull("throw_Null", prefix); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(prefix01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix02.java deleted file mode 100644 index bed3f29c4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix02.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getPrefix()" method - * returns the namespace prefix of this node, or null if unspecified. - * For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE, - * this is always null. - * - * Retrieve the first emp:employeeId node and get the first child of this node. - * Since the first child is Text node invoking the "getPrefix()" - * method will cause "null" to be returned. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -*/ -public final class prefix02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public prefix02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - Node textNode; - String prefix; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("emp:employeeId"); - testEmployee = elementList.item(0); - assertNotNull("empEmployeeNotNull", testEmployee); - textNode = testEmployee.getFirstChild(); - prefix = textNode.getPrefix(); - assertNull("textNodePrefix", prefix); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(prefix02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix03.java deleted file mode 100644 index e3285d0b5..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix03.java +++ /dev/null @@ -1,97 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getPrefix()" method for a node - * returns the namespace prefix of this node, or null if it is unspecified. - * - * Retrieve the first emp:employee node and invoke the getPrefix() method." - * The method should return "emp". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -*/ -public final class prefix03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public prefix03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - String prefix; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("emp:employee"); - testEmployee = elementList.item(0); - assertNotNull("empEmployeeNotNull", testEmployee); - prefix = testEmployee.getPrefix(); - assertEquals("prefix", "emp", prefix); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(prefix03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix04.java deleted file mode 100644 index 456e1f753..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix04.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getPrefix()" method for a node - * returns the namespace prefix of this node, or null if it is unspecified. - * - * Retrieve the first employee node and invoke the getPrefix() method." - * The method should return "null". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -*/ -public final class prefix04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public prefix04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testEmployee; - String prefix; - doc = (Document) load("staffNS", false); - elementList = doc.getElementsByTagName("employee"); - testEmployee = elementList.item(0); - prefix = testEmployee.getPrefix(); - assertNull("throw_Null", prefix); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(prefix04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix05.java deleted file mode 100644 index 61a4205c4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix05.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setPrefix(prefix)" method raises a - * NAMESPACE_ERR DOMException if the specified node is an attribute - * and the specified prefix is xmlns and the namespaceURI is different from - * http://www.w3.org/2000/xmlns. - * - * Attempt to insert "xmlns" as the new namespace prefix on the emp:domestic - * attribute within the emp:address node. - * An exception should be raised since the namespaceURI of this node is not - * http://www.w3.org/2000/xmlns. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-NodeNSPrefix')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR']) -*/ -public final class prefix05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public prefix05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element addrNode; - Attr addrAttr; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("emp:address"); - addrNode = (Element) elementList.item(0); - assertNotNull("empAddrNotNull", addrNode); - addrAttr = addrNode.getAttributeNode("emp:domestic"); - - { - boolean success = false; - try { - addrAttr.setPrefix("xmlns"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(prefix05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix06.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix06.java deleted file mode 100644 index 2d0e25191..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix06.java +++ /dev/null @@ -1,107 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setPrefix(prefix)" method raises a - * INVALID_CHARACTER_ERR DOMException if the specified - * prefix contains an illegal character. - * - * Attempt to insert a new namespace prefix on the first employee node. - * An exception should be raised since the namespace prefix has an invalid - * character. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-NodeNSPrefix')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -*/ -public final class prefix06 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public prefix06(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(0); - - { - boolean success = false; - try { - employeeNode.setPrefix("pre^fix xmlns='http//www.nist.gov'"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix06"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(prefix06.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix07.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix07.java deleted file mode 100644 index 941a4e1fb..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix07.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setPrefix(prefix)" method raises a - * NAMESPACE_ERR DOMException if the specified - * prefix if malformed. - * - * Attempt to insert a new namespace prefix on the second employee node. - * An exception should be raised since the namespace prefix is malformed. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-NodeNSPrefix')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR']) -*/ -public final class prefix07 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public prefix07(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(0); - - { - boolean success = false; - try { - employeeNode.setPrefix("emp::"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix07"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(prefix07.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix08.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix08.java deleted file mode 100644 index 4fbd5bfb5..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix08.java +++ /dev/null @@ -1,122 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setPrefix(prefix)" method causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Get the FIRST item - * from the entity reference and execute the "setPrefix(prefix)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-NodeNSPrefix')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -*/ -public final class prefix08 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public prefix08(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node genderNode; - Node entRef; - Node entElement; - Node createdNode; - int nodeType; - doc = (Document) load("staff", true); - genderList = doc.getElementsByTagName("gender"); - genderNode = genderList.item(2); - entRef = genderNode.getFirstChild(); - nodeType = (int) entRef.getNodeType(); - - if (equals(1, nodeType)) { - entRef = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", entRef); - } - entElement = entRef.getFirstChild(); - assertNotNull("entElement", entElement); - createdNode = doc.createElement("text3"); - - { - boolean success = false; - try { - entElement.setPrefix("newPrefix"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix08"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(prefix08.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix09.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix09.java deleted file mode 100644 index db2e0277d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix09.java +++ /dev/null @@ -1,110 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setPrefix(prefix)" method raises a - * NAMESPACE_ERR DOMException if the specified node is an attribute - * and the qualifiedName of this node is xmlns. - * - * Attempt to set the prefix on the xmlns attribute within the fourth address - * element. - * An exception should be raised since the qualifiedName of this attribute - * is "xmlns". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-NodeNSPrefix')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR']) -*/ -public final class prefix09 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public prefix09(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Element addrNode; - Attr addrAttr; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("address"); - addrNode = (Element) elementList.item(3); - addrAttr = addrNode.getAttributeNode("xmlns"); - - { - boolean success = false; - try { - addrAttr.setPrefix("xxx"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix09"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(prefix09.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix10.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix10.java deleted file mode 100644 index 3db6c8407..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix10.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setPrefix(prefix)" method raises a - * NAMESPACE_ERR DOMException if the specified - * prefix is xml and the namespaceURI is different from - * http://www.w3.org/XML/1998/namespace. - * - * Attempt to insert "xml" as the new namespace prefix on the first employee node. - * An exception should be raised since the namespaceURI of this node is not - * http://www.w3.org/XML/1998/namespace. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-NodeNSPrefix')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR']) -*/ -public final class prefix10 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public prefix10(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - - { - boolean success = false; - try { - employeeNode.setPrefix("xml"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix10"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(prefix10.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix11.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix11.java deleted file mode 100644 index 8e644a804..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/prefix11.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setPrefix(prefix)" method raises a - * NAMESPACE_ERR DOMException if the specified - * prefix is set on a node with a namespaceURI that is null. - * - * Attempt to insert a new namespace prefix on the second employee node. - * An exception should be raised since the namespace prefix is set - * on a node whose namespaceURI is null. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core# -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR']) -*/ -public final class prefix11 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public prefix11(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node employeeNode; - String namespaceURI; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("employee"); - employeeNode = elementList.item(1); - namespaceURI = employeeNode.getNamespaceURI(); - - { - boolean success = false; - try { - employeeNode.setPrefix("employee1"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix11"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(prefix11.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/publicId01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/publicId01.java deleted file mode 100644 index 156f2c4bf..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/publicId01.java +++ /dev/null @@ -1,89 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getPublicId()" method of a documenttype node contains - * the public identifier associated with the external subset. - * - * Retrieve the documenttype. - * Apply the "getPublicId()" method. The string "STAFF" should be - * returned. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-Core-DocType-publicId -*/ -public final class publicId01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public publicId01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - String publicId; - doc = (Document) load("staffNS", false); - docType = doc.getDoctype(); - publicId = docType.getPublicId(); - assertEquals("throw_Equals", "STAFF", publicId); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/publicId01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(publicId01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/removeAttributeNS01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/removeAttributeNS01.java deleted file mode 100644 index 15a538440..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/removeAttributeNS01.java +++ /dev/null @@ -1,123 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeAttributeNS(namespaceURI,localName)" method for an attribute causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Try to remove an attribute - * from the entity reference by executing the - * "removeAttributeNS(namespaceURI,localName)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElRemAtNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-ElRemAtNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -*/ -public final class removeAttributeNS01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public removeAttributeNS01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node gender; - Node gen; - NodeList gList; - Element genElement; - int nodeType; - doc = (Document) load("staffNS", true); - genderList = doc.getElementsByTagName("gender"); - gender = genderList.item(2); - gen = gender.getFirstChild(); - nodeType = (int) gen.getNodeType(); - - if (equals(1, nodeType)) { - gen = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", gen); - } - gList = gen.getChildNodes(); - genElement = (Element) gList.item(0); - assertNotNull("notnull", genElement); - - { - boolean success = false; - try { - genElement.removeAttributeNS("www.xyz.com", "local1"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/removeAttributeNS01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(removeAttributeNS01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/removeAttributeNS02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/removeAttributeNS02.java deleted file mode 100644 index 9b5277d55..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/removeAttributeNS02.java +++ /dev/null @@ -1,118 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2003 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeAttributeNS(namespaceURI,localName)" removes an attribute by - * local name and namespace URI. If the removed attribute has a - * default value it is immediately replaced. The replacing attribute has the same - * namespace URI and local name, as well as the original prefix. - * - * Retrieve the attribute named "emp:local" from emp:address - * node, then remove the "emp:local" - * attribute by invoking the "removeAttributeNS(namespaceURI,localName)" method. - * The "emp:local" attribute has a default value defined in the - * DTD file, that value should immediately replace the old - * value. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElRemAtNS -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=238 -*/ -public final class removeAttributeNS02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public removeAttributeNS02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware, -org.w3c.domts.DocumentBuilderSetting.validating - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testAddr; - Attr addrAttr; - String attr; - String namespaceURI; - String localName; - String prefix; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("emp:address"); - testAddr = elementList.item(0); - ((Element) /*Node */testAddr).removeAttributeNS("http://www.nist.gov", "local1"); - elementList = doc.getElementsByTagName("emp:address"); - testAddr = elementList.item(0); - addrAttr = ((Element) /*Node */testAddr).getAttributeNodeNS("http://www.nist.gov", "local1"); - attr = ((Element) /*Node */testAddr).getAttributeNS("http://www.nist.gov", "local1"); - namespaceURI = addrAttr.getNamespaceURI(); - localName = addrAttr.getLocalName(); - prefix = testAddr.getPrefix(); - assertEquals("attr", "FALSE", attr); - assertEquals("uri", "http://www.nist.gov", namespaceURI); - assertEquals("lname", "local1", localName); - assertEquals("prefix", "emp", prefix); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/removeAttributeNS02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(removeAttributeNS02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/removeNamedItemNS01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/removeNamedItemNS01.java deleted file mode 100644 index ddd5d7698..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/removeNamedItemNS01.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeNamedItemNS(namespaceURI,localName)" method for a - * NamedNodeMap should remove a node specified by localName and namespaceURI. - * - * Retrieve a list of elements with tag name "address". - * Access the second element from the list and get its attributes. - * Try to remove the attribute node with local name "domestic" - * and namespace uri "http://www.usa.com" with - * method removeNamedItemNS(namespaceURI,localName). - * Check to see if the node has been removed. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-1074577549 -*/ -public final class removeNamedItemNS01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public removeNamedItemNS01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testAddress; - NamedNodeMap attributes; - Attr newAttr; - Node removedNode; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("address"); - testAddress = elementList.item(1); - attributes = testAddress.getAttributes(); - removedNode = attributes.removeNamedItemNS("http://www.usa.com", "domestic"); - assertNotNull("retval", removedNode); - newAttr = (Attr) attributes.getNamedItem("dmstc:domestic"); - assertNull("nodeRemoved", newAttr); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/removeNamedItemNS01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(removeNamedItemNS01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/removeNamedItemNS02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/removeNamedItemNS02.java deleted file mode 100644 index 2dc34fef3..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/removeNamedItemNS02.java +++ /dev/null @@ -1,109 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeNamedItemNS(namespaceURI,localName)" method for a - * NamedNodeMap should raise NOT_FOUND_ERR DOMException if - * there is no node with the specified namespaceURI and localName in this map. - * - * Retrieve a list of elements with tag name "address". - * Access the second element from the list and get its attributes. - * Try to remove an attribute node with local name "domest" - * and namespace uri "http://www.usa.com" with - * method removeNamedItemNS(namespaceURI,localName). - * This should raise NOT_FOUND_ERR DOMException. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-removeNamedItemNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-removeNamedItemNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NOT_FOUND_ERR']) -*/ -public final class removeNamedItemNS02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public removeNamedItemNS02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.usa.com"; - String localName = "domest"; - Document doc; - NodeList elementList; - Node testAddress; - NamedNodeMap attributes; - Node removedNode; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("address"); - testAddress = elementList.item(1); - attributes = testAddress.getAttributes(); - - { - boolean success = false; - try { - removedNode = attributes.removeNamedItemNS(namespaceURI, localName); - } catch (DOMException ex) { - success = (ex.code == DOMException.NOT_FOUND_ERR); - } - assertTrue("throw_NOT_FOUND_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/removeNamedItemNS02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(removeNamedItemNS02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/removeNamedItemNS03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/removeNamedItemNS03.java deleted file mode 100644 index 3fd310dc6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/removeNamedItemNS03.java +++ /dev/null @@ -1,130 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "removeNamedItemNS(namespaceURI,localName)" method for a - * NamedNodeMap should raise NO_MODIFICATION_ALLOWED_ERR DOMException if - * this map is readonly. - * - * Retrieve a list of "gender" elements. Get access to the THIRD element - * which contains an ENTITY_REFERENCE child node. Try to remove the attribute - * in the node's map with method removeNamedItemNS(namespaceURI,localName). - * This should result in NO_MODIFICATION_ALLOWED_ERR - * DOMException. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-removeNamedItemNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-removeNamedItemNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -*/ -public final class removeNamedItemNS03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public removeNamedItemNS03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.w3.org/2000/xmlns/"; - String localName = "local1"; - Document doc; - NodeList elementList; - Node testAddress; - NodeList nList; - Node child; - NodeList n2List; - Node child2; - NamedNodeMap attributes; - Node removedNode; - int nodeType; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("gender"); - testAddress = elementList.item(2); - nList = testAddress.getChildNodes(); - child = nList.item(0); - nodeType = (int) child.getNodeType(); - - if (equals(1, nodeType)) { - child = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", child); - } - n2List = child.getChildNodes(); - child2 = n2List.item(0); - assertNotNull("notnull", child2); - attributes = child2.getAttributes(); - - { - boolean success = false; - try { - removedNode = attributes.removeNamedItemNS(namespaceURI, localName); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/removeNamedItemNS03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(removeNamedItemNS03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS01.java deleted file mode 100644 index ce0992b3e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS01.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNS(namespaceURI,qualifiedName,Value)" method raises a - * INVALID_CHARACTER_ERR DOMException if the specified - * prefix contains an illegal character. - * - * Attempt to add a new attribute on the first employee node. - * An exception should be raised since the "qualifiedName" has an invalid - * character. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAttrNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-ElSetAttrNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -*/ -public final class setAttributeNS01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public setAttributeNS01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.nist.gov"; - String qualifiedName = "emp:qual?name"; - Document doc; - NodeList elementList; - Node testAddr; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("employee"); - testAddr = elementList.item(0); - - { - boolean success = false; - try { - ((Element) /*Node */testAddr).setAttributeNS(namespaceURI, qualifiedName, "newValue"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNS01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(setAttributeNS01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS02.java deleted file mode 100644 index 7300f807a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS02.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNS(namespaceURI,qualifiedName,value)" method raises a - * NAMESPACE_ERR DOMException if the specified - * qualifiedName if malformed. - * - * Attempt to add a new attribute on the second employee node. - * An exception should be raised since the "qualifiedName" is malformed. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAttrNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-ElSetAttrNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR']) -*/ -public final class setAttributeNS02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public setAttributeNS02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.nist.gov"; - String qualifiedName = "emp:"; - Document doc; - NodeList elementList; - Node testAddr; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("emp:employee"); - testAddr = elementList.item(0); - - { - boolean success = false; - try { - ((Element) /*Node */testAddr).setAttributeNS(namespaceURI, qualifiedName, "newValue"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNS02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(setAttributeNS02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS03.java deleted file mode 100644 index 0177449e4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS03.java +++ /dev/null @@ -1,121 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNS(namespaceURI,qualifiedName,value)" method for an attribute causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Try to set an attribute - * in the entity reference by executing the - * "setAttributeNS(namespaceURI,qualifiedName,value)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAttrNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-ElSetAttrNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -*/ -public final class setAttributeNS03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public setAttributeNS03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "www.xyz.com"; - String qualifiedName = "emp:local1"; - Document doc; - NodeList genderList; - Node gender; - NodeList genList; - Node gen; - NodeList gList; - Element genElement; - int nodeType; - doc = (Document) load("staffNS", true); - genderList = doc.getElementsByTagName("gender"); - gender = genderList.item(2); - genList = gender.getChildNodes(); - gen = genList.item(0); - nodeType = (int) gen.getNodeType(); - - if (equals(1, nodeType)) { - gen = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", gen); - } - gList = gen.getChildNodes(); - genElement = (Element) gList.item(0); - assertNotNull("notnull", genElement); - - { - boolean success = false; - try { - genElement.setAttributeNS(namespaceURI, qualifiedName, "newValue"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNS03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(setAttributeNS03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS04.java deleted file mode 100644 index f72fc639e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS04.java +++ /dev/null @@ -1,116 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNS(namespaceURI,qualifiedName,value)" method adds a new attribute. - * If an attribute with the same local name and namespace URI is already present - * on the element, its prefix is changed to be the prefix part of the "qualifiedName", - * and its vale is changed to be the "value" paramter. - * null value if no previously existing Attr node with the - * same name was replaced. - * - * Add a new attribute to the "emp:address" element. - * Check to see if the new attribute has been successfully added to the document - * by getting the attributes value, namespace URI, local Name and prefix. - * The prefix will be changed to the prefix part of the "qualifiedName" - * and its value changed to the "value" parameter. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core# -*/ -public final class setAttributeNS04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public setAttributeNS04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testAddr; - Attr addrAttr; - String resultAttr; - String resultNamespaceURI; - String resultLocalName; - String resultPrefix; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("emp:address"); - testAddr = elementList.item(0); - assertNotNull("empAddrNotNull", testAddr); - ((Element) /*Node */testAddr).setAttributeNS("http://www.nist.gov", "newprefix:zone", "newValue"); - addrAttr = ((Element) /*Node */testAddr).getAttributeNodeNS("http://www.nist.gov", "zone"); - resultAttr = ((Element) /*Node */testAddr).getAttributeNS("http://www.nist.gov", "zone"); - assertEquals("attrValue", "newValue", resultAttr); - resultNamespaceURI = addrAttr.getNamespaceURI(); - assertEquals("nsuri", "http://www.nist.gov", resultNamespaceURI); - resultLocalName = addrAttr.getLocalName(); - assertEquals("lname", "zone", resultLocalName); - resultPrefix = addrAttr.getPrefix(); - assertEquals("prefix", "newprefix", resultPrefix); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNS04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(setAttributeNS04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS05.java deleted file mode 100644 index c8c23ba9d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS05.java +++ /dev/null @@ -1,102 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNS(namespaceURI,qualifiedName,value)" method adds a new attribute. - * If an attribute with the same local name and namespace URI is already present - * on the element, its prefix is changed to be the prefix part of the "qualifiedName", - * and its vale is changed to be the "value" paramter. - * null value if no previously existing Attr node with the - * same name was replaced. - * - * Add a new attribute to the "emp:address" element. - * Check to see if the new attribute has been successfully added to the document. - * The new attribute "" contains markup and therefore is escaped - * by the implementation. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElGetAttrNS -*/ -public final class setAttributeNS05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public setAttributeNS05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String localName = "newAttr"; - String namespaceURI = "http://www.newattr.com"; - String qualifiedName = "emp:newAttr"; - Document doc; - NodeList elementList; - Node testAddr; - Attr addrAttr; - String resultAttr; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("emp:address"); - testAddr = elementList.item(0); - assertNotNull("empAddrNotNull", testAddr); - ((Element) /*Node */testAddr).setAttributeNS(namespaceURI, qualifiedName, ""); - resultAttr = ((Element) /*Node */testAddr).getAttributeNS(namespaceURI, localName); - assertEquals("throw_Equals", "", resultAttr); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNS05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(setAttributeNS05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS06.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS06.java deleted file mode 100644 index 687fe39aa..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS06.java +++ /dev/null @@ -1,104 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNS(namespaceURI,localName,value)" method raises a - * NAMESPACE_ERR DOMException if the "qualifiedName" has a - * prefix of "xml" and the namespaceURI is different from - * http://www.w3.org/XML/1998/namespace. - * - * Attempt to add an attribute with a prefix of "xml" as the on the first employee node. - * An exception should be raised since the namespaceURI of this node is not - * http://www.w3.org/XML/1998/namespace. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAttrNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-ElSetAttrNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR']) -*/ -public final class setAttributeNS06 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public setAttributeNS06(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.nist.gov"; - String qualifiedName = "xml:qualifiedName"; - Document doc; - NodeList elementList; - Node testAddr; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("employee"); - testAddr = elementList.item(0); - - { - boolean success = false; - try { - ((Element) /*Node */testAddr).setAttributeNS(namespaceURI, qualifiedName, "newValue"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNS06"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(setAttributeNS06.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS07.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS07.java deleted file mode 100644 index a903eeb64..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS07.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNS(namespaceURI,localName,value)" method raises a - * NAMESPACE_ERR DOMException if the "qualifiedName" has a - * value of "xmlns" and the namespaceURI is different from - * http://www.w3.org/2000/xmlns. - * - * Attempt to add an attribute with a "qualifiedName" of "xmlns" as the - * on the first employee node. - * An exception should be raised since the namespaceURI of this node is not - * http://www.w3.org/2000/xmlns. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAttrNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-ElSetAttrNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR']) -*/ -public final class setAttributeNS07 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public setAttributeNS07(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.nist.gov"; - String qualifiedName = "xmlns"; - Document doc; - NodeList elementList; - Node testAddr; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("employee"); - testAddr = elementList.item(0); - - { - boolean success = false; - try { - ((Element) /*Node */testAddr).setAttributeNS(namespaceURI, qualifiedName, "newValue"); - } catch (DOMException ex) { - success = (ex.code == DOMException.NAMESPACE_ERR); - } - assertTrue("throw_NAMESPACE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNS07"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(setAttributeNS07.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS09.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS09.java deleted file mode 100644 index 78171d120..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS09.java +++ /dev/null @@ -1,111 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNS(namespaceURI,qualifiedName,value)" method adds a new attribute. - * If an attribute with the same local name and namespace URI is already present - * on the element, its prefix is changed to be the prefix part of the "qualifiedName", - * and its vale is changed to be the "value" paramter. - * null value if no previously existing Attr node with the - * same name was replaced. - * - * Add a new attribute to the "emp:address" element. - * Check to see if the new attribute has been successfully added to the document - * by getting the attributes value, namespace URI, local Name and prefix. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAttrNS -*/ -public final class setAttributeNS09 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public setAttributeNS09(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String localName = "newAttr"; - String namespaceURI = "http://www.newattr.com"; - String qualifiedName = "emp:newAttr"; - Document doc; - NodeList elementList; - Node testAddr; - Attr addrAttr; - String resultAttr; - String resultNamespaceURI; - String resultLocalName; - String resultPrefix; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("emp:address"); - testAddr = elementList.item(0); - assertNotNull("empAddrNotNull", testAddr); - ((Element) /*Node */testAddr).setAttributeNS(namespaceURI, qualifiedName, "newValue"); - addrAttr = ((Element) /*Node */testAddr).getAttributeNodeNS(namespaceURI, localName); - resultAttr = ((Element) /*Node */testAddr).getAttributeNS(namespaceURI, localName); - assertEquals("attrValue", "newValue", resultAttr); - resultNamespaceURI = addrAttr.getNamespaceURI(); - assertEquals("nsuri", "http://www.newattr.com", resultNamespaceURI); - resultLocalName = addrAttr.getLocalName(); - assertEquals("lname", "newAttr", resultLocalName); - resultPrefix = addrAttr.getPrefix(); - assertEquals("prefix", "emp", resultPrefix); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNS09"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(setAttributeNS09.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS10.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS10.java deleted file mode 100644 index 73053a8aa..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNS10.java +++ /dev/null @@ -1,96 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * Element.setAttributeNS with an empty qualified name should cause an INVALID_CHARACTER_ERR. -* @author Curt Arnold -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAttrNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-ElSetAttrNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) -* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525 -*/ -public final class setAttributeNS10 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public setAttributeNS10(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "hc_staff", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.example.gov"; - Document doc; - NodeList elementList; - Node testAddr; - doc = (Document) load("hc_staff", true); - elementList = doc.getElementsByTagName("em"); - testAddr = elementList.item(0); - - { - boolean success = false; - try { - ((Element) /*Node */testAddr).setAttributeNS(namespaceURI, "", "newValue"); - } catch (DOMException ex) { - success = (ex.code == DOMException.INVALID_CHARACTER_ERR); - } - assertTrue("throw_INVALID_CHARACTER_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNS10"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(setAttributeNS10.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS01.java deleted file mode 100644 index d2cd15250..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS01.java +++ /dev/null @@ -1,118 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNode(newAttr)" method raises an - * "INUSE_ATTRIBUTE_ERR DOMException if the "newAttr" - * is already an attribute of another element. - * - * Retrieve the first emp:address and append - * a newly created element. The "createAttributeNS(namespaceURI,qualifiedName)" - * and "setAttributeNodeNS(newAttr)" methods are invoked - * to create and add a new attribute to the newly created - * Element. The "setAttributeNodeNS(newAttr)" method is - * once again called to add the new attribute causing an - * exception to be raised since the attribute is already - * an attribute of another element. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-ElSetAtNodeNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR']) -*/ -public final class setAttributeNodeNS01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public setAttributeNodeNS01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.newattr.com"; - String qualifiedName = "emp:newAttr"; - Document doc; - Element newElement; - Attr newAttr; - NodeList elementList; - Node testAddr; - Node appendedChild; - Attr setAttr1; - Attr setAttr2; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("emp:address"); - testAddr = elementList.item(0); - assertNotNull("empAddrNotNull", testAddr); - newElement = doc.createElement("newElement"); - appendedChild = testAddr.appendChild(newElement); - newAttr = doc.createAttributeNS(namespaceURI, qualifiedName); - setAttr1 = newElement.setAttributeNodeNS(newAttr); - - { - boolean success = false; - try { - setAttr2 = ((Element) /*Node */testAddr).setAttributeNodeNS(newAttr); - } catch (DOMException ex) { - success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR); - } - assertTrue("throw_INUSE_ATTRIBUTE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNodeNS01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(setAttributeNodeNS01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS02.java deleted file mode 100644 index 2b2965a2b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS02.java +++ /dev/null @@ -1,127 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNodeNS(namespaceURI,qualifiedName,value)" method for an attribute causes the - * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised - * if the node is readonly. - * - * Obtain the children of the THIRD "gender" element. The elements - * content is an entity reference. Try to set an attribute - * in the entity reference by executing the - * "setAttributeNodeNS(newAttr)" method. - * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-ElSetAtNodeNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -*/ -public final class setAttributeNodeNS02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public setAttributeNodeNS02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.notNamespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList genderList; - Node gender; - NodeList genList; - Node gen; - NodeList gList; - Element genElement; - Attr newAttr; - Attr setAttr1; - doc = (Document) load("staffNS", true); - - if (!isExpandEntityReferences()) { - genderList = doc.getElementsByTagName("gender"); - gender = genderList.item(2); - genList = gender.getChildNodes(); - gen = genList.item(0); - } else { - gen = doc.createEntityReference("ent4"); - } - - gList = gen.getChildNodes(); - genElement = (Element) gList.item(0); - assertNotNull("notnull", genElement); - newAttr = doc.createAttributeNS("www.xyz.com", "emp:local1"); - - { - boolean success = false; - try { - setAttr1 = genElement.setAttributeNodeNS(newAttr); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNodeNS02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(setAttributeNodeNS02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS03.java deleted file mode 100644 index 5215acbf4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS03.java +++ /dev/null @@ -1,100 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNodeNS(newAttr)" adds a new attribute. - * If an attribute with that local name and that namespaceURI is already - * present in the element, it is replaced by the new one. - * - * Retrieve the first emp:address element and add a new attribute - * to the element. Since an attribute with the same local name - * and namespaceURI as the newly created attribute does not exist - * the value "null" is returned. - * This test uses the "createAttributeNS(namespaceURI,localName) - * method from the Document interface to create the new attribute to add. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS -*/ -public final class setAttributeNodeNS03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public setAttributeNodeNS03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.newattr.com"; - String qualifiedName = "emp:newAttr"; - Document doc; - NodeList elementList; - Node testAddr; - Attr newAttr; - Attr newAddrAttr; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("emp:address"); - testAddr = elementList.item(0); - assertNotNull("empAddrNotNull", testAddr); - newAttr = doc.createAttributeNS(namespaceURI, qualifiedName); - newAddrAttr = ((Element) /*Node */testAddr).setAttributeNodeNS(newAttr); - assertNull("throw_Null", newAddrAttr); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNodeNS03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(setAttributeNodeNS03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS04.java deleted file mode 100644 index b1b742dc8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS04.java +++ /dev/null @@ -1,106 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNodeNS(newAttr)" adds a new attribute. - * If an attribute with that local name and that namespaceURI is already - * present in the element, it is replaced by the new one. - * - * Retrieve the first emp:address element and add a new attribute - * to the element. Since an attribute with the same local name - * and namespaceURI already exists, it is replaced by the new one and - * returns the replaced "Attr" node. - * This test uses the "createAttributeNS(namespaceURI,localName) - * method from the Document interface to create the new attribute to add. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-F68D095 -*/ -public final class setAttributeNodeNS04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public setAttributeNodeNS04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node testAddr; - Attr newAttr; - Attr newAddrAttr; - String newName; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("emp:address"); - testAddr = elementList.item(0); - assertNotNull("empAddrNotNull", testAddr); - newAttr = doc.createAttributeNS("http://www.nist.gov", "xxx:domestic"); - newAddrAttr = ((Element) /*Node */testAddr).setAttributeNodeNS(newAttr); - newName = newAddrAttr.getNodeName(); - assertEquals("nodeName", "emp:domestic", newName); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNodeNS04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(setAttributeNodeNS04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS05.java deleted file mode 100644 index 8c24d39f8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS05.java +++ /dev/null @@ -1,114 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setAttributeNodeNS(newAttr)" method raises an - * "WRONG_DOCUMENT_ERR DOMException if the "newAttr" - * was created from a different document than the one that - * created this document. - * - * Retrieve the first emp:address and attempt to set a new - * attribute node. The new - * attribute was created from a document other than the - * one that created this element, therefore a - * WRONG_DOCUMENT_ERR DOMException should be raised. - * This test uses the "createAttributeNS(newAttr)" method - * from the Document interface. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-ElSetAtNodeNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR']) -*/ -public final class setAttributeNodeNS05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public setAttributeNodeNS05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.newattr.com"; - String qualifiedName = "emp:newAttr"; - Document doc1; - Document doc2; - Attr newAttr; - NodeList elementList; - Node testAddr; - Attr setAttr1; - doc1 = (Document) load("staffNS", true); - doc2 = (Document) load("staffNS", true); - newAttr = doc2.createAttributeNS(namespaceURI, qualifiedName); - elementList = doc1.getElementsByTagName("emp:address"); - testAddr = elementList.item(0); - - { - boolean success = false; - try { - setAttr1 = ((Element) /*Node */testAddr).setAttributeNodeNS(newAttr); - } catch (DOMException ex) { - success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); - } - assertTrue("throw_WRONG_DOCUMENT_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNodeNS05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(setAttributeNodeNS05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS01.java deleted file mode 100644 index 469f0239d..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS01.java +++ /dev/null @@ -1,118 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setNamedItemNS(arg)" method for a - * NamedNodeMap should raise INUSE_ATTRIBUTE_ERR DOMException if - * arg is an Attr that is already an attribute of another Element object. - * - * Retrieve an attr node from the third "address" element whose local name - * is "domestic" and namespaceURI is "http://www.netzero.com". - * Invoke method setNamedItemNS(arg) on the map of the first "address" element with - * arg being the attr node from above. Method should raise - * INUSE_ATTRIBUTE_ERR DOMException. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-setNamedItemNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR']) -*/ -public final class setNamedItemNS01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public setNamedItemNS01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - NodeList elementList; - Node anotherElement; - NamedNodeMap anotherMap; - Node arg; - Node testAddress; - NamedNodeMap map; - Node setNode; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("address"); - anotherElement = elementList.item(2); - anotherMap = anotherElement.getAttributes(); - arg = anotherMap.getNamedItemNS("http://www.netzero.com", "domestic"); - testAddress = elementList.item(0); - map = testAddress.getAttributes(); - - { - boolean success = false; - try { - setNode = map.setNamedItemNS(arg); - } catch (DOMException ex) { - success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR); - } - assertTrue("throw_INUSE_ATTRIBUTE_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setNamedItemNS01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(setNamedItemNS01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS02.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS02.java deleted file mode 100644 index ac2b4a38e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS02.java +++ /dev/null @@ -1,114 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setNamedItemNS(arg)" method for a - * NamedNodeMap should raise WRONG_DOCUMENT_ERR DOMException if arg was - * created from a different document than the one that created this map. - * - * Create an attr node in a different document with qualifiedName equals - * "dmstc:domestic" and namespaceURI is "http://www.usa.com". - * Access the namednodemap of the first "address" element in this document. - * Invoke method setNamedItemNS(arg) with arg being the attr node from above. - * Method should raise WRONG_DOCUMENT_ERR DOMException. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-setNamedItemNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR']) -*/ -public final class setNamedItemNS02 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public setNamedItemNS02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.usa.com"; - String qualifiedName = "dmstc:domestic"; - Document doc; - Document anotherDoc; - Node arg; - NodeList elementList; - Node testAddress; - NamedNodeMap attributes; - Node setNode; - doc = (Document) load("staffNS", true); - anotherDoc = (Document) load("staffNS", true); - arg = anotherDoc.createAttributeNS(namespaceURI, qualifiedName); - arg.setNodeValue("Maybe"); - elementList = doc.getElementsByTagName("address"); - testAddress = elementList.item(0); - attributes = testAddress.getAttributes(); - - { - boolean success = false; - try { - setNode = attributes.setNamedItemNS(arg); - } catch (DOMException ex) { - success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); - } - assertTrue("throw_WRONG_DOCUMENT_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setNamedItemNS02"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(setNamedItemNS02.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS03.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS03.java deleted file mode 100644 index a7002d284..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS03.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setNamedItemNS(arg)" method for a - * NamedNodeMap should add a node using its namespaceURI and localName given that - * there is no existing node with the same namespaceURI and localName in the map. - * - * Create an attr node with namespaceURI "http://www.nist.gov",qualifiedName - * "prefix:newAttr" and value "newValue". - * Invoke method setNamedItemNS(arg) on the map of the first "address" - * element where arg is identified by the namespaceURI and qualifiedName - * from above. Method should return the newly added attr node. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-F68D080 -*/ -public final class setNamedItemNS03 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public setNamedItemNS03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.nist.gov"; - String qualifiedName = "prefix:newAttr"; - Document doc; - Node arg; - NodeList elementList; - Node testAddress; - NamedNodeMap attributes; - Node retnode; - String value; - Node setNode; - doc = (Document) load("staffNS", true); - arg = doc.createAttributeNS(namespaceURI, qualifiedName); - arg.setNodeValue("newValue"); - elementList = doc.getElementsByTagName("address"); - testAddress = elementList.item(0); - attributes = testAddress.getAttributes(); - setNode = attributes.setNamedItemNS(arg); - retnode = attributes.getNamedItemNS(namespaceURI, "newAttr"); - value = retnode.getNodeValue(); - assertEquals("throw_Equals", "newValue", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setNamedItemNS03"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(setNamedItemNS03.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS04.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS04.java deleted file mode 100644 index f2cffdf2b..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS04.java +++ /dev/null @@ -1,132 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001-2004 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setNamedItemNS(arg)" method for a - * NamedNodeMap should raise NO_MODIFICATION_ALLOWED_ERR DOMException if - * this map is readonly. - * - * Retrieve a list of "gender" elements. Get access to the THIRD element - * which contains an ENTITY_REFERENCE child node. Get access to the node's - * map. Try to add an attribute node specified by arg with - * method setNamedItemNS(arg). This should result in NO_MODIFICATION_ALLOWED_ERR - * DOMException. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-setNamedItemNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) -*/ -public final class setNamedItemNS04 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public setNamedItemNS04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - - org.w3c.domts.DocumentBuilderSetting[] settings = - new org.w3c.domts.DocumentBuilderSetting[] { -org.w3c.domts.DocumentBuilderSetting.namespaceAware - }; - DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); - setFactory(testFactory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.w3.org/2000/xmlns/"; - String localName = "local1"; - Document doc; - NodeList elementList; - Node testAddress; - NodeList nList; - Node child; - NodeList n2List; - Node child2; - NamedNodeMap attributes; - Node arg; - Node setNode; - int nodeType; - doc = (Document) load("staffNS", true); - elementList = doc.getElementsByTagName("gender"); - testAddress = elementList.item(2); - nList = testAddress.getChildNodes(); - child = nList.item(0); - nodeType = (int) child.getNodeType(); - - if (equals(1, nodeType)) { - child = doc.createEntityReference("ent4"); - assertNotNull("createdEntRefNotNull", child); - } - n2List = child.getChildNodes(); - child2 = n2List.item(0); - assertNotNull("notnull", child2); - attributes = child2.getAttributes(); - arg = attributes.getNamedItemNS(namespaceURI, localName); - - { - boolean success = false; - try { - setNode = attributes.setNamedItemNS(arg); - } catch (DOMException ex) { - success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); - } -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setNamedItemNS04"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(setNamedItemNS04.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS05.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS05.java deleted file mode 100644 index 509dad6f8..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/setNamedItemNS05.java +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "setNamedItemNS(arg)" method for a - * NamedNodeMap should replace an existing node n1 found in the map with arg if n1 - * has the same namespaceURI and localName as arg and return n1. - * - * Create an attribute node in with namespaceURI "http://www.usa.com" - * and qualifiedName "dmstc:domestic" whose value is "newVal". - * Invoke method setNamedItemNS(arg) on the map of the first "address" - * element. Method should return the old attribute node identified - * by namespaceURI and qualifiedName from above,whose value is "Yes". -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS -*/ -public final class setNamedItemNS05 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public setNamedItemNS05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", true); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - String namespaceURI = "http://www.usa.com"; - String qualifiedName = "dmstc:domestic"; - Document doc; - Node arg; - NodeList elementList; - Node testAddress; - NamedNodeMap attributes; - Node retnode; - String value; - doc = (Document) load("staffNS", true); - arg = doc.createAttributeNS(namespaceURI, qualifiedName); - arg.setNodeValue("newValue"); - elementList = doc.getElementsByTagName("address"); - testAddress = elementList.item(0); - attributes = testAddress.getAttributes(); - retnode = attributes.setNamedItemNS(arg); - value = retnode.getNodeValue(); - assertEquals("throw_Equals", "Yes", value); - } - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setNamedItemNS05"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(setNamedItemNS05.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/core/systemId01.java b/libcore/dom/src/test/java/org/w3c/domts/level2/core/systemId01.java deleted file mode 100644 index 396904b78..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/core/systemId01.java +++ /dev/null @@ -1,90 +0,0 @@ - -/* -This Java source file was generated by test-to-java.xsl -and is a derived work from the source document. -The source document contained the following notice: - - - -Copyright (c) 2001 World Wide Web Consortium, -(Massachusetts Institute of Technology, Institut National de -Recherche en Informatique et en Automatique, Keio University). All -Rights Reserved. This program is distributed under the W3C's Software -Intellectual Property License. This program is distributed in the -hope that it will be useful, but WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. - -See W3C License http://www.w3.org/Consortium/Legal/ for more details. - - -*/ - -package org.w3c.domts.level2.core; - -import org.w3c.dom.*; - - -import org.w3c.domts.DOMTestCase; -import org.w3c.domts.DOMTestDocumentBuilderFactory; - - - -/** - * The "getSystemId()" method of a documenttype node contains - * the system identifier associated with the external subset. - * - * Retrieve the documenttype. - * Apply the "getSystemId()" method. The string "staffNS.dtd" should be - * returned. -* @author NIST -* @author Mary Brady -* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-Core-DocType-systemId -*/ -public final class systemId01 extends DOMTestCase { - - /** - * Constructor. - * @param factory document factory, may not be null - * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration - */ - public systemId01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { - super(factory); - - // - // check if loaded documents are supported for content type - // - String contentType = getContentType(); - preload(contentType, "staffNS", false); - } - - /** - * Runs the test case. - * @throws Throwable Any uncaught exception causes test to fail - */ - public void runTest() throws Throwable { - Document doc; - DocumentType docType; - String systemId; - int index; - doc = (Document) load("staffNS", false); - docType = doc.getDoctype(); - systemId = docType.getSystemId(); - assertURIEquals("systemId", null, null, null, "staffNS.dtd", null, null, null, null, systemId); -} - /** - * Gets URI that identifies the test. - * @return uri identifier of test - */ - public String getTargetURI() { - return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/systemId01"; - } - /** - * Runs this test from the command line. - * @param args command line arguments - */ - public static void main(final String[] args) { - DOMTestCase.doMain(systemId01.class, args); - } -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestBatik.java b/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestBatik.java deleted file mode 100644 index 044911dcb..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestBatik.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level2.events; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.BatikTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.DocumentBuilderSetting; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestBatik extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level2.events.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new BatikTestDocumentBuilderFactory(new DocumentBuilderSetting[0]); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestDefaultLS.java b/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestDefaultLS.java deleted file mode 100644 index 67faacd33..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestDefaultLS.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level2.events; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.LSDocumentBuilderFactory; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L2 Events tests using the - * Default LS parser in default configuration. - * - * @author Curt Arnold - * - */ -public class TestDefaultLS extends TestSuite { - - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level2.events.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new LSDocumentBuilderFactory( - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestDefaultLSAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestDefaultLSAltConfig.java deleted file mode 100644 index f6976afee..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestDefaultLSAltConfig.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level2.events; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.LSDocumentBuilderFactory; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L2 Events tests using the - * Default LS parser in an alternate configuration - * - * @author Curt Arnold - * - */ -public class TestDefaultLSAltConfig extends TestSuite { - - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level2.events.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new LSDocumentBuilderFactory( - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestDefaultParser.java b/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestDefaultParser.java deleted file mode 100644 index fa51d2389..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestDefaultParser.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level2.events; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestDefaultParser extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level2.events.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(null, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestDefaultParserAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestDefaultParserAltConfig.java deleted file mode 100644 index f56dae428..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestDefaultParserAltConfig.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level2.events; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestDefaultParserAltConfig extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level2.events.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(null, - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestOracle.java b/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestOracle.java deleted file mode 100644 index adc0a4f79..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestOracle.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute of - * Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level2.events; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L2 Events tests using the - * Oracle Parser for Java in default configuration. - * - * @author Curt Arnold - * - */ -public class TestOracle extends TestSuite { - - /** - * Constructor - * @return test suite - * @throws Exception - */ - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level2.events.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory oracleFactory = - (DocumentBuilderFactory) ClassLoader - .getSystemClassLoader() - .loadClass("oracle.xml.jaxp.JXDocumentBuilderFactory") - .newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory( - oracleFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestOracleAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestOracleAltConfig.java deleted file mode 100644 index 2a6c2f30a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestOracleAltConfig.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute of - * Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level2.events; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L2 Events tests using the - * Oracle Parser for Java in an alternative configuration. - * - * @author Curt Arnold - * - */ -public class TestOracleAltConfig extends TestSuite { - /** - * Constructor - * @return test suite - * @throws Exception - */ - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level2.events.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory oracleFactory = - (DocumentBuilderFactory) ClassLoader - .getSystemClassLoader() - .loadClass("oracle.xml.jaxp.JXDocumentBuilderFactory") - .newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory( - oracleFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestXerces.java b/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestXerces.java deleted file mode 100644 index 8cced7139..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestXerces.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level2.events; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestXerces extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level2.events.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory xercesFactory = (DocumentBuilderFactory) - ClassLoader.getSystemClassLoader().loadClass("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl").newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(xercesFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestXercesAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestXercesAltConfig.java deleted file mode 100644 index 6079c6ffd..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/events/TestXercesAltConfig.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level2.events; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -public class TestXercesAltConfig extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level2.events.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory xercesFactory = (DocumentBuilderFactory) - ClassLoader.getSystemClassLoader().loadClass("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl").newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(xercesFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/html/TestDefaultLS.java b/libcore/dom/src/test/java/org/w3c/domts/level2/html/TestDefaultLS.java deleted file mode 100644 index b78726db2..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/html/TestDefaultLS.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level2.html; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.LSDocumentBuilderFactory; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L2 HTML tests using the - * Default LS parser in default configuration. - * - * @author Curt Arnold - * - */ -public class TestDefaultLS extends TestSuite { - - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level2.html.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new LSDocumentBuilderFactory( - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/html/TestDefaultLSAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level2/html/TestDefaultLSAltConfig.java deleted file mode 100644 index 26f70b9f9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/html/TestDefaultLSAltConfig.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level2.html; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.LSDocumentBuilderFactory; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L2 HTML tests using the - * Default LS parser in an alternative configuration. - * - * @author Curt Arnold - * - */ -public class TestDefaultLSAltConfig extends TestSuite { - - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level2.html.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new LSDocumentBuilderFactory( - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level2/html/TestXercesHTML.java b/libcore/dom/src/test/java/org/w3c/domts/level2/html/TestXercesHTML.java deleted file mode 100644 index 52b20f952..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level2/html/TestXercesHTML.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level2.html; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JUnitTestSuiteAdapter; -import org.w3c.domts.XercesHTML2DocumentBuilderFactory; - -public class TestXercesHTML extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level2.html.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new XercesHTML2DocumentBuilderFactory( - XercesHTML2DocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestBatik.java b/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestBatik.java deleted file mode 100644 index e1256bd60..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestBatik.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ -package org.w3c.domts.level3.core; -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.BatikTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.DocumentBuilderSetting; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * - * Runs test suite using Batik SVG. - * - */ -public class TestBatik extends TestSuite { - /** - * Factory method for suite. - * - * @return suite - * @throws Exception if Batik is not available or could not be instantiated - */ - public static TestSuite suite() throws Exception { - Class testClass = ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level3.core.alltests"); - Constructor testConstructor = testClass - .getConstructor(new Class[]{DOMTestDocumentBuilderFactory.class}); - DOMTestDocumentBuilderFactory factory = new BatikTestDocumentBuilderFactory( - new DocumentBuilderSetting[0]); - Object test = testConstructor.newInstance(new Object[]{factory}); - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestDefaultLS.java b/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestDefaultLS.java deleted file mode 100644 index b9e3a15ab..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestDefaultLS.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level3.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.LSDocumentBuilderFactory; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L3 Core tests using the - * a parser provided by DOM L3 Core bootstrapping. - * - * @author Curt Arnold - * - */ -public class TestDefaultLS extends TestSuite { - - /** - * Create instance of test suite. - * - * @return test suite - * @throws Exception if tests or implementation could not be loaded - */ - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level3.core.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new LSDocumentBuilderFactory( - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestDefaultLSAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestDefaultLSAltConfig.java deleted file mode 100644 index 1ce4d7473..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestDefaultLSAltConfig.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level3.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.LSDocumentBuilderFactory; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L3 Core tests using a - * parser provided by DOM L3 Core bootstrapping - * in alternative configuration - * - * @author Curt Arnold - * - */ -public class TestDefaultLSAltConfig extends TestSuite { - - /** - * Create a new instance of the test suite - * @return test suite - * @throws Exception if tests or implementation not loaded - */ - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level3.core.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new LSDocumentBuilderFactory( - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestDefaultParser.java b/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestDefaultParser.java deleted file mode 100644 index 541a13ac4..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestDefaultParser.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level3.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite using the default JAXP parser in the default configuration - * - * - */ -public class TestDefaultParser extends TestSuite { - - /** - * Create a new instance of the test suite - * @return new test suite - * @exception Exception if tests or implementation can be created. - */ - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level3.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(null, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestDefaultParserAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestDefaultParserAltConfig.java deleted file mode 100644 index 7cf0241b0..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestDefaultParserAltConfig.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level3.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - - - -/** - * Test suite using the default JAXP parser in the alternative configuration - * - * - */ -public class TestDefaultParserAltConfig extends TestSuite { - - /** - * Create a new instance of the test suite - * @return new test suite - * @exception Exception if tests or implementation can be created. - */ - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level3.core.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(null, - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestOracle.java b/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestOracle.java deleted file mode 100644 index 56932ee71..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestOracle.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2001-2003 World Wide Web Consortium, (Massachusetts Institute of - * Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level3.core; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L3 Core tests using the - * Oracle Parser for Java in default configuration. - * - * @author Curt Arnold - * - */ -public class TestOracle extends TestSuite { - - /** - * Constructor - * @return test suite - * @throws Exception - */ - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level3.core.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory oracleFactory = - (DocumentBuilderFactory) ClassLoader - .getSystemClassLoader() - .loadClass("oracle.xml.jaxp.JXDocumentBuilderFactory") - .newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory( - oracleFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestOracleAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestOracleAltConfig.java deleted file mode 100644 index 830af44ae..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestOracleAltConfig.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2001-2003 World Wide Web Consortium, (Massachusetts Institute of - * Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level3.core; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L3 Core tests using the - * Oracle Parser for Java in an alternative configuration. - * - * @author Curt Arnold - * - */ -public class TestOracleAltConfig extends TestSuite { - /** - * Constructor - * @return test suite - * @throws Exception - */ - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level3.core.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory oracleFactory = - (DocumentBuilderFactory) ClassLoader - .getSystemClassLoader() - .loadClass("oracle.xml.jaxp.JXDocumentBuilderFactory") - .newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory( - oracleFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestXerces.java b/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestXerces.java deleted file mode 100644 index e7f3b2782..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestXerces.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2001-2003 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level3.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import javax.xml.parsers.DocumentBuilderFactory; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L3 Core tests using the - * Xerces-J in default configuration. - * - * @author Curt Arnold - * - */ -public class TestXerces extends TestSuite { - - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level3.core.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory xercesFactory = - (DocumentBuilderFactory) ClassLoader - .getSystemClassLoader() - .loadClass("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl") - .newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory( - xercesFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestXercesAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestXercesAltConfig.java deleted file mode 100644 index b7dc2a91e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/core/TestXercesAltConfig.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2001-2003 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level3.core; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import javax.xml.parsers.DocumentBuilderFactory; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L3 Core tests using the - * Xerces-J in an alternative configuration. - * - * @author Curt Arnold - * - */ -public class TestXercesAltConfig extends TestSuite { - - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level3.core.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory xercesFactory = - (DocumentBuilderFactory) ClassLoader - .getSystemClassLoader() - .loadClass("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl") - .newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory( - xercesFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestBatik.java b/libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestBatik.java deleted file mode 100644 index f76c6000a..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestBatik.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ -package org.w3c.domts.level3.ls; -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.BatikTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.DocumentBuilderSetting; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * - * Runs test suite using Batik SVG. - * - */ -public class TestBatik extends TestSuite { - /** - * Factory method for suite. - * - * @return suite - * @throws Exception if Batik is not available or could not be instantiated - */ - public static TestSuite suite() throws Exception { - Class testClass = ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level3.ls.alltests"); - Constructor testConstructor = testClass - .getConstructor(new Class[]{DOMTestDocumentBuilderFactory.class}); - DOMTestDocumentBuilderFactory factory = new BatikTestDocumentBuilderFactory( - new DocumentBuilderSetting[0]); - Object test = testConstructor.newInstance(new Object[]{factory}); - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestDefaultLS.java b/libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestDefaultLS.java deleted file mode 100644 index 2a20d6cd9..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestDefaultLS.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level3.ls; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.LSDocumentBuilderFactory; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L3 Core tests using the - * a parser provided by DOM L3 Core bootstrapping. - * - * @author Curt Arnold - * - */ -public class TestDefaultLS extends TestSuite { - - /** - * Create instance of test suite. - * - * @return test suite - * @throws Exception if tests or implementation could not be loaded - */ - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level3.ls.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new LSDocumentBuilderFactory( - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestDefaultParser.java b/libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestDefaultParser.java deleted file mode 100644 index 3b317d3fc..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestDefaultParser.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level3.ls; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite using the default JAXP parser in the default configuration - * - * - */ -public class TestDefaultParser extends TestSuite { - - /** - * Create a new instance of the test suite - * @return new test suite - * @exception Exception if tests or implementation can be created. - */ - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level3.ls.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(null, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestOracle.java b/libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestOracle.java deleted file mode 100644 index ec882c095..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestOracle.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2003 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level3.ls; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * A JUnit test suite that will run all Load and Save tests - * using the Oracle XML Parser for Java - * - * @author Curt Arnold - * - */ -public class TestOracle extends TestSuite { - - /** - * Constructs the test suite - * - * @return test suite - * @throws Exception can throw class load exceptions - * if class path does not contain dom3-ls.jar or - * xmlparserv2.jar - */ - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level3.ls.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory jxFactory = - (DocumentBuilderFactory) ClassLoader - .getSystemClassLoader() - .loadClass("oracle.xml.jaxp.JXDocumentBuilderFactory") - .newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory( - jxFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestXerces.java b/libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestXerces.java deleted file mode 100644 index 8a183674e..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/ls/TestXerces.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2001-2003 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level3.ls; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * A JUnit test suite that will run all Load and Save tests - * using Xerces-J - * - * @author Curt Arnold - * - */ -public class TestXerces extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level3.ls.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory xercesFactory = (DocumentBuilderFactory) - ClassLoader.getSystemClassLoader().loadClass("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl").newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(xercesFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestBatik.java b/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestBatik.java deleted file mode 100644 index 1199768fd..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestBatik.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ -package org.w3c.domts.level3.validation; -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.BatikTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.DocumentBuilderSetting; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * - * Runs test suite using Batik SVG. - * - */ -public class TestBatik extends TestSuite { - /** - * Factory method for suite. - * - * @return suite - * @throws Exception if Batik is not available or could not be instantiated - */ - public static TestSuite suite() throws Exception { - Class testClass = ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level3.validation.alltests"); - Constructor testConstructor = testClass - .getConstructor(new Class[]{DOMTestDocumentBuilderFactory.class}); - DOMTestDocumentBuilderFactory factory = new BatikTestDocumentBuilderFactory( - new DocumentBuilderSetting[0]); - Object test = testConstructor.newInstance(new Object[]{factory}); - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestDefaultLS.java b/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestDefaultLS.java deleted file mode 100644 index 71d759dc7..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestDefaultLS.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level3.validation; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.LSDocumentBuilderFactory; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L3 Validation tests using the - * a parser provided by DOM L3 Core bootstrapping. - * - * @author Curt Arnold - * - */ -public class TestDefaultLS extends TestSuite { - - /** - * Create instance of test suite. - * - * @return test suite - * @throws Exception if tests or implementation could not be loaded - */ - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level3.validation.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new LSDocumentBuilderFactory( - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestDefaultLSAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestDefaultLSAltConfig.java deleted file mode 100644 index 66160c217..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestDefaultLSAltConfig.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level3.validation; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.LSDocumentBuilderFactory; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L3 Validation tests using a - * parser provided by DOM L3 Core bootstrapping - * in alternative configuration - * - * @author Curt Arnold - * - */ -public class TestDefaultLSAltConfig extends TestSuite { - - /** - * Create a new instance of the test suite - * @return test suite - * @throws Exception if tests or implementation not loaded - */ - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level3.validation.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new LSDocumentBuilderFactory( - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestDefaultParser.java b/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestDefaultParser.java deleted file mode 100644 index 4d50461f6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestDefaultParser.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level3.validation; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite using the default JAXP parser in the default configuration - * - * - */ -public class TestDefaultParser extends TestSuite { - - /** - * Create a new instance of the test suite - * @return new test suite - * @exception Exception if tests or implementation can be created. - */ - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level3.validation.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(null, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestDefaultParserAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestDefaultParserAltConfig.java deleted file mode 100644 index 904fa99db..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestDefaultParserAltConfig.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level3.validation; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - - - -/** - * Test suite using the default JAXP parser in the alternative configuration - * - * - */ -public class TestDefaultParserAltConfig extends TestSuite { - - /** - * Create a new instance of the test suite - * @return new test suite - * @exception Exception if tests or implementation can be created. - */ - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level3.validation.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(null, - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestOracle.java b/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestOracle.java deleted file mode 100644 index f178d28dc..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestOracle.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute of - * Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level3.validation; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L3 Validation tests using the - * Oracle Parser for Java in default configuration. - * - * @author Curt Arnold - * - */ -public class TestOracle extends TestSuite { - - /** - * Constructor - * @return test suite - * @throws Exception - */ - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level3.validation.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory oracleFactory = - (DocumentBuilderFactory) ClassLoader - .getSystemClassLoader() - .loadClass("oracle.xml.jaxp.JXDocumentBuilderFactory") - .newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory( - oracleFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestOracleAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestOracleAltConfig.java deleted file mode 100644 index bbac83b08..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/validation/TestOracleAltConfig.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute of - * Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level3.validation; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L3 Validation tests using the - * Oracle Parser for Java in an alternative configuration. - * - * @author Curt Arnold - * - */ -public class TestOracleAltConfig extends TestSuite { - /** - * Constructor - * @return test suite - * @throws Exception - */ - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level3.validation.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory oracleFactory = - (DocumentBuilderFactory) ClassLoader - .getSystemClassLoader() - .loadClass("oracle.xml.jaxp.JXDocumentBuilderFactory") - .newInstance(); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory( - oracleFactory, - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestBatik.java b/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestBatik.java deleted file mode 100644 index 91e2ab520..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestBatik.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ -package org.w3c.domts.level3.xpath; -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.BatikTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.DocumentBuilderSetting; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * - * Runs test suite using Batik SVG. - * - */ -public class TestBatik extends TestSuite { - /** - * Factory method for suite. - * - * @return suite - * @throws Exception if Batik is not available or could not be instantiated - */ - public static TestSuite suite() throws Exception { - Class testClass = ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level3.xpath.alltests"); - Constructor testConstructor = testClass - .getConstructor(new Class[]{DOMTestDocumentBuilderFactory.class}); - DOMTestDocumentBuilderFactory factory = new BatikTestDocumentBuilderFactory( - new DocumentBuilderSetting[0]); - Object test = testConstructor.newInstance(new Object[]{factory}); - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestDefaultLS.java b/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestDefaultLS.java deleted file mode 100644 index 7e4a56a79..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestDefaultLS.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level3.xpath; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.LSDocumentBuilderFactory; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L3 XPath tests using the - * a parser provided by DOM L3 Core bootstrapping. - * - * @author Curt Arnold - * - */ -public class TestDefaultLS extends TestSuite { - - /** - * Create instance of test suite. - * - * @return test suite - * @throws Exception if tests or implementation could not be loaded - */ - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level3.xpath.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new LSDocumentBuilderFactory( - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestDefaultLSAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestDefaultLSAltConfig.java deleted file mode 100644 index dbbe502e1..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestDefaultLSAltConfig.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute - * of Technology, Institut National de Recherche en Informatique et en - * Automatique, Keio University). All Rights Reserved. This program is - * distributed under the W3C's Software Intellectual Property License. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See W3C License - * http://www.w3.org/Consortium/Legal/ for more details. - */ - -package org.w3c.domts.level3.xpath; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.LSDocumentBuilderFactory; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite that runs all DOM L3 XPath tests using a - * parser provided by DOM L3 XPath bootstrapping - * in alternative configuration - * - * @author Curt Arnold - * - */ -public class TestDefaultLSAltConfig extends TestSuite { - - /** - * Create a new instance of the test suite - * @return test suite - * @throws Exception if tests or implementation not loaded - */ - public static TestSuite suite() throws Exception { - Class testClass = - ClassLoader.getSystemClassLoader().loadClass( - "org.w3c.domts.level3.xpath.alltests"); - Constructor testConstructor = - testClass.getConstructor( - new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new LSDocumentBuilderFactory( - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - -} diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestDefaultParser.java b/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestDefaultParser.java deleted file mode 100644 index 2ecaba185..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestDefaultParser.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level3.xpath; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Test suite using the default JAXP parser in the default configuration - * - * - */ -public class TestDefaultParser extends TestSuite { - - /** - * Create a new instance of the test suite - * @return new test suite - * @exception Exception if tests or implementation can be created. - */ - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level3.xpath.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(null, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestDefaultParserAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestDefaultParserAltConfig.java deleted file mode 100644 index acc9141e6..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestDefaultParserAltConfig.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2001-2004 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level3.xpath; - -import java.lang.reflect.Constructor; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - - - -/** - * Test suite using the default JAXP parser in the alternative configuration - * - * - */ -public class TestDefaultParserAltConfig extends TestSuite { - - /** - * Create a new instance of the test suite - * @return new test suite - * @exception Exception if tests or implementation can be created. - */ - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level3.xpath.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DOMTestDocumentBuilderFactory factory = - new JAXPDOMTestDocumentBuilderFactory(null, - JAXPDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestXalan.java b/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestXalan.java deleted file mode 100644 index 83ffe79af..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestXalan.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2001-2003 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level3.xpath; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JUnitTestSuiteAdapter; -import org.w3c.domts.XalanDOMTestDocumentBuilderFactory; - -public class TestXalan extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level3.xpath.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory jaxpFactory = DocumentBuilderFactory.newInstance(); - - DOMTestDocumentBuilderFactory factory = - new XalanDOMTestDocumentBuilderFactory(jaxpFactory, - XalanDOMTestDocumentBuilderFactory.getConfiguration1()); - - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestXalanAltConfig.java b/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestXalanAltConfig.java deleted file mode 100644 index 268d34187..000000000 --- a/libcore/dom/src/test/java/org/w3c/domts/level3/xpath/TestXalanAltConfig.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2001-2003 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - - -package org.w3c.domts.level3.xpath; - -import java.lang.reflect.Constructor; - -import javax.xml.parsers.DocumentBuilderFactory; - -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JUnitTestSuiteAdapter; -import org.w3c.domts.XalanDOMTestDocumentBuilderFactory; - -public class TestXalanAltConfig extends TestSuite { - - public static TestSuite suite() throws Exception - { - Class testClass = ClassLoader.getSystemClassLoader().loadClass("org.w3c.domts.level3.xpath.alltests"); - Constructor testConstructor = testClass.getConstructor(new Class[] { DOMTestDocumentBuilderFactory.class }); - - DocumentBuilderFactory jaxpFactory = DocumentBuilderFactory.newInstance(); - - DOMTestDocumentBuilderFactory factory = - new XalanDOMTestDocumentBuilderFactory(jaxpFactory, - XalanDOMTestDocumentBuilderFactory.getConfiguration2()); - - Object test = testConstructor.newInstance(new Object[] { factory }); - - return new JUnitTestSuiteAdapter((DOMTestSuite) test); - } - - -} - diff --git a/libcore/dom/src/test/java/tests/api/org/w3c/dom/AllTests.java b/libcore/dom/src/test/java/tests/api/org/w3c/dom/AllTests.java deleted file mode 100644 index 677780a02..000000000 --- a/libcore/dom/src/test/java/tests/api/org/w3c/dom/AllTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package tests.api.org.w3c.dom; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * - */ -public class AllTests { - /*public static void run() { - TestRunner.main(new String[] {AllTests.class.getName()}); - }*/ - - public static final Test suite() { - TestSuite suite = tests.TestSuiteFactory.createTestSuite(); - suite.addTest(AllTests_Level1.suite()); - suite.addTest(AllTests_Level2.suite()); - return suite; - } -} diff --git a/libcore/dom/src/test/java/tests/api/org/w3c/dom/AllTests_Level1.java b/libcore/dom/src/test/java/tests/api/org/w3c/dom/AllTests_Level1.java deleted file mode 100644 index 778633b07..000000000 --- a/libcore/dom/src/test/java/tests/api/org/w3c/dom/AllTests_Level1.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package tests.api.org.w3c.dom; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Listing of all the tests that are to be run. - */ -public class AllTests_Level1 { - /*public static void run() { - TestRunner.main(new String[] {Main_AllTests.class.getName()}); - }*/ - - public static final Test suite() { - // from http://www.w3.org/DOM/Test/ - // Level 1 Core tests - DOMTestSuite domSuite; - try { - DOMTestDocumentBuilderFactory factory1 = - new JAXPDOMTestDocumentBuilderFactory(null, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - // android: coalescing, epand, ignorewhitespace, namespace, NOT validation - - domSuite = new org.w3c.domts.level1.core.alltests(factory1); - } catch (Exception e) { - throw new RuntimeException("problem creating dom test suite, "+e.getClass().getName()+", "+e.getMessage(), e); - } - TestSuite suite = new JUnitTestSuiteAdapter(domSuite); - return suite; - } -} diff --git a/libcore/dom/src/test/java/tests/api/org/w3c/dom/AllTests_Level2.java b/libcore/dom/src/test/java/tests/api/org/w3c/dom/AllTests_Level2.java deleted file mode 100644 index dff3d0d2e..000000000 --- a/libcore/dom/src/test/java/tests/api/org/w3c/dom/AllTests_Level2.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package tests.api.org.w3c.dom; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.w3c.domts.DOMTestDocumentBuilderFactory; -import org.w3c.domts.DOMTestSuite; -import org.w3c.domts.JAXPDOMTestDocumentBuilderFactory; -import org.w3c.domts.JUnitTestSuiteAdapter; - -/** - * Listing of all the tests that are to be run. - */ -public class AllTests_Level2 { - /*public static void run() { - TestRunner.main(new String[] {Main_AllTests.class.getName()}); - }*/ - - public static final Test suite() { - // from http://www.w3.org/DOM/Test/ - // Level 2 Core tests - DOMTestSuite domSuite; - try { - DOMTestDocumentBuilderFactory factory1 = - new JAXPDOMTestDocumentBuilderFactory(null, - JAXPDOMTestDocumentBuilderFactory.getConfiguration1()); - - // android: coalescing, epand, ignorewhitespace, namespace, NOT validation - - domSuite = new org.w3c.domts.level2.core.alltests(factory1); - } catch (Exception e) { - throw new RuntimeException("problem creating dom test suite", e); - } - TestSuite suite = new JUnitTestSuiteAdapter(domSuite); - return suite; - } -} diff --git a/libcore/dom/src/test/java/tests/dom/AllTests.java b/libcore/dom/src/test/java/tests/dom/AllTests.java deleted file mode 100644 index 6a5831f76..000000000 --- a/libcore/dom/src/test/java/tests/dom/AllTests.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2007 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package tests.dom; - -import org.w3c.domts.JunitTestCases; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class AllTests { - - public static Test suite() { - TestSuite suite = tests.TestSuiteFactory.createTestSuite(); - suite.addTestSuite(JunitTestCases.class); - return suite; - } - -} diff --git a/libcore/dom/src/test/resources/META-INF/MANIFEST.MF b/libcore/dom/src/test/resources/META-INF/MANIFEST.MF deleted file mode 100644 index aaf3eba8e..000000000 --- a/libcore/dom/src/test/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,16 +0,0 @@ -Manifest-Version: 2.0 -Class-Path: dom3-xml-apis.jar dom3-xercesImpl.jar xmlParserAPIs.jar x - ercesImpl.jar xerces.jar xml4j.jar xmlparserv2.jar crimson.jar parser - .jar jaxp.jar xml-apis.jar gnujaxp.jar dom4j-full.jar batik-svg-dom.j - ar crimson-parser.jar avalon-run.jar -Created-By: 1.4.2_04 (Sun Microsystems Inc.) -Main-Class: org.w3c.domts.level2.core.alltests - -Name: org/w3c/domts/level2/core -Implementation-Title: W3C/NIST Test Suite for DOM Level 2 Core -Specification-Title: W3C/NIST Test Suite for DOM Level 2 Core -Specification-Version: 0.0.1 -Specification-Vendor: World Wide Web Consortium -Implementation-Version: 0.0.1 -Implementation-Vendor: World Wide Web Consortium - diff --git a/libcore/dom/src/test/resources/build.xml b/libcore/dom/src/test/resources/build.xml deleted file mode 100644 index 50060e0c3..000000000 --- a/libcore/dom/src/test/resources/build.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libcore/dom/src/test/resources/hc_nodtdstaff.html b/libcore/dom/src/test/resources/hc_nodtdstaff.html deleted file mode 100644 index f98d0be11..000000000 --- a/libcore/dom/src/test/resources/hc_nodtdstaff.html +++ /dev/null @@ -1,10 +0,0 @@ -hc_nodtdstaff -

- EMP0001 - Margaret Martin - Accountant - 56,000 - Female - 1230 North Ave. Dallas, Texas 98551 -

- diff --git a/libcore/dom/src/test/resources/hc_nodtdstaff.svg b/libcore/dom/src/test/resources/hc_nodtdstaff.svg deleted file mode 100644 index 89f26f6c7..000000000 --- a/libcore/dom/src/test/resources/hc_nodtdstaff.svg +++ /dev/null @@ -1,10 +0,0 @@ -hc_nodtdstaff -

- EMP0001 - Margaret Martin - Accountant - 56,000 - Female - 1230 North Ave. Dallas, Texas 98551 -

- diff --git a/libcore/dom/src/test/resources/hc_nodtdstaff.xhtml b/libcore/dom/src/test/resources/hc_nodtdstaff.xhtml deleted file mode 100644 index 8a5d8a862..000000000 --- a/libcore/dom/src/test/resources/hc_nodtdstaff.xhtml +++ /dev/null @@ -1,10 +0,0 @@ -hc_nodtdstaff -

- EMP0001 - Margaret Martin - Accountant - 56,000 - Female - 1230 North Ave. Dallas, Texas 98551 -

- diff --git a/libcore/dom/src/test/resources/hc_nodtdstaff.xml b/libcore/dom/src/test/resources/hc_nodtdstaff.xml deleted file mode 100644 index 85c06931d..000000000 --- a/libcore/dom/src/test/resources/hc_nodtdstaff.xml +++ /dev/null @@ -1,10 +0,0 @@ -hc_nodtdstaff -

- EMP0001 - Margaret Martin - Accountant - 56,000 - Female - 1230 North Ave. Dallas, Texas 98551 -

- diff --git a/libcore/dom/src/test/resources/hc_staff.html b/libcore/dom/src/test/resources/hc_staff.html deleted file mode 100644 index 9acf75049..000000000 --- a/libcore/dom/src/test/resources/hc_staff.html +++ /dev/null @@ -1,48 +0,0 @@ - - -hc_staff -

- EMP0001 - Margaret Martin - Accountant - 56,000 - Female - 1230 North Ave. Dallas, Texas 98551 -

-

- EMP0002 - Martha RaynoldsThis is a CDATASection with EntityReference number 2 &ent2; -This is an adjacent CDATASection with a reference to a tab &tab; - Secretary - 35,000 - Female - β Dallas, γ - 98554 -

-

- EMP0003 - Roger - Jones - Department Manager - 100,000 - δ - PO Box 27 Irving, texas 98553 -

-

- EMP0004 - Jeny Oconnor - Personnel Director - 95,000 - Female - 27 South Road. Dallas, Texas 98556 -

-

- EMP0005 - Robert Myers - Computer Specialist - 90,000 - male - 1821 Nordic. Road, Irving Texas 98558 -

- diff --git a/libcore/dom/src/test/resources/hc_staff.svg b/libcore/dom/src/test/resources/hc_staff.svg deleted file mode 100644 index cd0cc47f9..000000000 --- a/libcore/dom/src/test/resources/hc_staff.svg +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - -]> - -hc_staff -

- EMP0001 - Margaret Martin - Accountant - 56,000 - Female - 1230 North Ave. Dallas, Texas 98551 -

-

- EMP0002 - Martha RaynoldsThis is a CDATASection with EntityReference number 2 &ent2; -This is an adjacent CDATASection with a reference to a tab &tab; - Secretary - 35,000 - Female - β Dallas, γ - 98554 -

-

- EMP0003 - Roger - Jones - Department Manager - 100,000 - δ - PO Box 27 Irving, texas 98553 -

-

- EMP0004 - Jeny Oconnor - Personnel Director - 95,000 - Female - 27 South Road. Dallas, Texas 98556 -

-

- EMP0005 - Robert Myers - Computer Specialist - 90,000 - male - 1821 Nordic. Road, Irving Texas 98558 -

- diff --git a/libcore/dom/src/test/resources/hc_staff.xhtml b/libcore/dom/src/test/resources/hc_staff.xhtml deleted file mode 100644 index 2df9a7415..000000000 --- a/libcore/dom/src/test/resources/hc_staff.xhtml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - -]> - -hc_staff -

- EMP0001 - Margaret Martin - Accountant - 56,000 - Female - 1230 North Ave. Dallas, Texas 98551 -

-

- EMP0002 - Martha RaynoldsThis is a CDATASection with EntityReference number 2 &ent2; -This is an adjacent CDATASection with a reference to a tab &tab; - Secretary - 35,000 - Female - β Dallas, γ - 98554 -

-

- EMP0003 - Roger - Jones - Department Manager - 100,000 - δ - PO Box 27 Irving, texas 98553 -

-

- EMP0004 - Jeny Oconnor - Personnel Director - 95,000 - Female - 27 South Road. Dallas, Texas 98556 -

-

- EMP0005 - Robert Myers - Computer Specialist - 90,000 - male - 1821 Nordic. Road, Irving Texas 98558 -

- diff --git a/libcore/dom/src/test/resources/hc_staff.xml b/libcore/dom/src/test/resources/hc_staff.xml deleted file mode 100644 index 2df9a7415..000000000 --- a/libcore/dom/src/test/resources/hc_staff.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - -]> - -hc_staff -

- EMP0001 - Margaret Martin - Accountant - 56,000 - Female - 1230 North Ave. Dallas, Texas 98551 -

-

- EMP0002 - Martha RaynoldsThis is a CDATASection with EntityReference number 2 &ent2; -This is an adjacent CDATASection with a reference to a tab &tab; - Secretary - 35,000 - Female - β Dallas, γ - 98554 -

-

- EMP0003 - Roger - Jones - Department Manager - 100,000 - δ - PO Box 27 Irving, texas 98553 -

-

- EMP0004 - Jeny Oconnor - Personnel Director - 95,000 - Female - 27 South Road. Dallas, Texas 98556 -

-

- EMP0005 - Robert Myers - Computer Specialist - 90,000 - male - 1821 Nordic. Road, Irving Texas 98558 -

- diff --git a/libcore/dom/src/test/resources/internalSubset01.js b/libcore/dom/src/test/resources/internalSubset01.js deleted file mode 100644 index e69de29bb..000000000 diff --git a/libcore/dom/src/test/resources/nodtdstaff.svg b/libcore/dom/src/test/resources/nodtdstaff.svg deleted file mode 100644 index 01aa823f3..000000000 --- a/libcore/dom/src/test/resources/nodtdstaff.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - EMP0001 - Margaret Martin - Accountant - 56,000 - Female -
1230 North Ave. Dallas, Texas 98551
-
-
diff --git a/libcore/dom/src/test/resources/nodtdstaff.xml b/libcore/dom/src/test/resources/nodtdstaff.xml deleted file mode 100644 index 054a5e180..000000000 --- a/libcore/dom/src/test/resources/nodtdstaff.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - EMP0001 - Margaret Martin - Accountant - 56,000 - Female -
1230 North Ave. Dallas, Texas 98551
-
-
diff --git a/libcore/dom/src/test/resources/staff.dtd b/libcore/dom/src/test/resources/staff.dtd deleted file mode 100644 index 02a994d57..000000000 --- a/libcore/dom/src/test/resources/staff.dtd +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - diff --git a/libcore/dom/src/test/resources/staff.svg b/libcore/dom/src/test/resources/staff.svg deleted file mode 100644 index fd67323a4..000000000 --- a/libcore/dom/src/test/resources/staff.svg +++ /dev/null @@ -1,72 +0,0 @@ - - - - - Element data"> - - - - - - - - - - - - - -]> - - - - EMP0001 - Margaret Martin - Accountant - 56,000 - Female -
1230 North Ave. Dallas, Texas 98551
-
- - EMP0002 - Martha RaynoldsThis is a CDATASection with EntityReference number 2 &ent2; -This is an adjacent CDATASection with a reference to a tab &tab; - Secretary - 35,000 - Female -
&ent2; Dallas, &ent3; - 98554
-
- - EMP0003 - Roger - Jones - Department Manager - 100,000 - &ent4; -
PO Box 27 Irving, texas 98553
-
- - EMP0004 - Jeny Oconnor - Personnel Director - 95,000 - Female -
27 South Road. Dallas, Texas 98556
-
- - EMP0005 - Robert Myers - Computer Specialist - 90,000 - male -
1821 Nordic. Road, Irving Texas 98558
-
-
diff --git a/libcore/dom/src/test/resources/staff.xml b/libcore/dom/src/test/resources/staff.xml deleted file mode 100644 index f89c5107d..000000000 --- a/libcore/dom/src/test/resources/staff.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - Element data"> - - - - -]> - - - - EMP0001 - Margaret Martin - Accountant - 56,000 - Female -
1230 North Ave. Dallas, Texas 98551
-
- - EMP0002 - Martha Raynolds - - Secretary - 35,000 - Female -
&ent2; Dallas, &ent3; - 98554
-
- - EMP0003 - Roger - Jones - Department Manager - 100,000 - &ent4; -
PO Box 27 Irving, texas 98553
-
- - EMP0004 - Jeny Oconnor - Personnel Director - 95,000 - Female -
27 South Road. Dallas, Texas 98556
-
- - EMP0005 - Robert Myers - Computer Specialist - 90,000 - male -
1821 Nordic. Road, Irving Texas 98558
-
-
diff --git a/libcore/dom/src/test/resources/staff2.dtd b/libcore/dom/src/test/resources/staff2.dtd deleted file mode 100644 index 0bac8f253..000000000 --- a/libcore/dom/src/test/resources/staff2.dtd +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/libcore/dom/src/test/resources/staff2.svg b/libcore/dom/src/test/resources/staff2.svg deleted file mode 100644 index 6f89dad04..000000000 --- a/libcore/dom/src/test/resources/staff2.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - EMP0001 - Margaret Martin - Accountant - 56,000 - Female -
1230 North Ave. Dallas, Texas 98551
-
-
diff --git a/libcore/dom/src/test/resources/staff2.xml b/libcore/dom/src/test/resources/staff2.xml deleted file mode 100644 index d3d9a13dd..000000000 --- a/libcore/dom/src/test/resources/staff2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - EMP0001 - Margaret Martin - Accountant - 56,000 - Female -
1230 North Ave. Dallas, Texas 98551
-
-
diff --git a/libcore/dom/src/test/resources/staffNS.dtd b/libcore/dom/src/test/resources/staffNS.dtd deleted file mode 100644 index 7643773fc..000000000 --- a/libcore/dom/src/test/resources/staffNS.dtd +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libcore/dom/src/test/resources/staffNS.svg b/libcore/dom/src/test/resources/staffNS.svg deleted file mode 100644 index 7a7c26ee8..000000000 --- a/libcore/dom/src/test/resources/staffNS.svg +++ /dev/null @@ -1,73 +0,0 @@ - - - - - Element data"> - - - - - - - - - - - - - -]> - - - - EMP0001 - Margaret Martin - Accountant - 56,000 - Female -
1230 North Ave. Dallas, Texas 98551
-
- - EMP0002 - Martha Raynolds -This is a CDATASection with EntityReference number 2 &ent2; -This is an adjacent CDATASection with a reference to a tab &tab; - Secretary - 35,000 - Female -
&ent2; Dallas, &ent3; - 98554
-
- - EMP0003 - Roger - Jones - Department Manager - 100,000 - &ent4; -
PO Box 27 Irving, texas 98553
-
- EMP0004 - Jeny Oconnor - Personnel Director - 95,000 - Female - 27 South Road. Dallas, texas 98556 - - - EMP0005 - Robert Myers - Computer Specialist - 90,000 - male -
1821 Nordic. Road, Irving Texas 98558
-
-
diff --git a/libcore/dom/src/test/resources/staffNS.xml b/libcore/dom/src/test/resources/staffNS.xml deleted file mode 100644 index 1cb1459e2..000000000 --- a/libcore/dom/src/test/resources/staffNS.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - Element data"> - - - - - -]> - - - - EMP0001 - Margaret Martin - Accountant - 56,000 - Female -
1230 North Ave. Dallas, Texas 98551
-
- - EMP0002 - Martha Raynolds - - - Secretary - 35,000 - Female -
&ent2; Dallas, &ent3; - 98554
-
- - EMP0003 - Roger - Jones - Department Manager - 100,000 - &ent4; -
PO Box 27 Irving, texas 98553
-
- EMP0004 - Jeny Oconnor - Personnel Director - 95,000 - Female - 27 South Road. Dallas, texas 98556 - - - EMP0005 - Robert Myers - Computer Specialist - 90,000 - male -
1821 Nordic. Road, Irving Texas 98558
-
-
diff --git a/libcore/dom/src/test/resources/svgtest.js b/libcore/dom/src/test/resources/svgtest.js deleted file mode 100644 index e69de29bb..000000000 diff --git a/libcore/dom/src/test/resources/svgunit.js b/libcore/dom/src/test/resources/svgunit.js deleted file mode 100644 index e69de29bb..000000000 diff --git a/libcore/dom/src/test/resources/xhtml1-strict.dtd b/libcore/dom/src/test/resources/xhtml1-strict.dtd deleted file mode 100644 index fefb77f4f..000000000 --- a/libcore/dom/src/test/resources/xhtml1-strict.dtd +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libcore/icu/MODULE_LICENSE_BSD_LIKE b/libcore/icu/MODULE_LICENSE_BSD_LIKE deleted file mode 100644 index e69de29bb..000000000 diff --git a/libcore/icu/license.html b/libcore/icu/license.html deleted file mode 100644 index b905ddf41..000000000 --- a/libcore/icu/license.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - -ICU License - ICU 1.8.1 and later - - - -

ICU License - ICU 1.8.1 and later

- -

COPYRIGHT AND PERMISSION NOTICE

- -

-Copyright (c) 1995-2006 International Business Machines Corporation and others -

-

-All rights reserved. -

-

-Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, and/or sell -copies of the Software, and to permit persons -to whom the Software is furnished to do so, provided that the above -copyright notice(s) and this permission notice appear in all copies -of the Software and that both the above copyright notice(s) and this -permission notice appear in supporting documentation. -

-

-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL -THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, -OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER -RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, -NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE -USE OR PERFORMANCE OF THIS SOFTWARE. -

-

-Except as contained in this notice, the name of a copyright holder shall not be -used in advertising or otherwise to promote the sale, use or other dealings in -this Software without prior written authorization of the copyright holder. -

- -
-

-All trademarks and registered trademarks mentioned herein are the property of their respective owners. -

- - diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/charset/CharsetDecoderICU.java b/libcore/icu/src/main/java/com/ibm/icu4jni/charset/CharsetDecoderICU.java deleted file mode 100644 index 919d8656e..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/charset/CharsetDecoderICU.java +++ /dev/null @@ -1,354 +0,0 @@ -/** -******************************************************************************* -* Copyright (C) 1996-2006, International Business Machines Corporation and * -* others. All Rights Reserved. * -******************************************************************************* -* -******************************************************************************* -*/ - /** - * A JNI interface for ICU converters. - * - * - * @author Ram Viswanadha, IBM - */ -package com.ibm.icu4jni.charset; - -import com.ibm.icu4jni.common.ErrorCode; -// BEGIN android-removed -// import com.ibm.icu4jni.converters.NativeConverter; -// END android-removed - - -import java.nio.CharBuffer; -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.nio.charset.CoderResult; -import java.nio.charset.CodingErrorAction; -import java.nio.ByteBuffer; - -public final class CharsetDecoderICU extends CharsetDecoder{ - - - private static final int INPUT_OFFSET = 0, - OUTPUT_OFFSET = 1, - INVALID_BYTES = 2, - INPUT_HELD = 3, - LIMIT = 4; - /* data is 3 element array where - * data[INPUT_OFFSET] = on input contains the start of input and on output the number of input chars consumed - * data[OUTPUT_OFFSET] = on input contains the start of output and on output the number of output bytes written - * data[INVALID_CHARS] = number of invalid chars - * data[INPUT_HELD] = number of input chars held in the converter's state - */ - private int[] data = new int[LIMIT]; - - /* handle to the ICU converter that is opened */ - private long converterHandle=0; - - - private byte[] input = null; - private char[] output= null; - - // BEGIN android-added - private byte[] allocatedInput = null; - private char[] allocatedOutput = null; - // END android-added - - // These instance variables are - // always assigned in the methods - // before being used. This class - // inhrently multithread unsafe - // so we dont have to worry about - // synchronization - private int inEnd; - private int outEnd; - private int ec; - private int onUnmappableInput = NativeConverter.STOP_CALLBACK;; - private int onMalformedInput = NativeConverter.STOP_CALLBACK;; - private int savedInputHeldLen; - - /** - * Constructs a new decoder for the given charset - * @param cs for which the decoder is created - * @param cHandle the address of ICU converter - * @exception RuntimeException - * @stable ICU 2.4 - */ - public CharsetDecoderICU(Charset cs,long cHandle){ - super(cs, - NativeConverter.getAveCharsPerByte(cHandle), - NativeConverter.getMaxCharsPerByte(cHandle) - ); - - char[] sub = replacement().toCharArray(); - ec = NativeConverter.setCallbackDecode(cHandle, - onMalformedInput, - onUnmappableInput, - sub, sub.length); - if(ErrorCode.isFailure(ec)){ - throw ErrorCode.getException(ec); - } - // store the converter handle - converterHandle=cHandle; - - } - - /** - * Sets this decoders replacement string. Substitutes the string in input if an - * umappable or illegal sequence is encountered - * @param newReplacement to replace the error bytes with - * @stable ICU 2.4 - */ - protected void implReplaceWith(String newReplacement) { - if(converterHandle > 0){ - if( newReplacement.length() > NativeConverter.getMaxBytesPerChar(converterHandle)) { - throw new IllegalArgumentException(); - } - ec =NativeConverter.setSubstitutionChars(converterHandle, - newReplacement.toCharArray(), - newReplacement.length() - ); - if(ErrorCode.isFailure(ec)){ - throw ErrorCode.getException(ec); - } - } - } - - /** - * Sets the action to be taken if an illegal sequence is encountered - * @param newAction action to be taken - * @exception IllegalArgumentException - * @stable ICU 2.4 - */ - protected final void implOnMalformedInput(CodingErrorAction newAction) { - if(newAction.equals(CodingErrorAction.IGNORE)){ - onMalformedInput = NativeConverter.SKIP_CALLBACK; - }else if(newAction.equals(CodingErrorAction.REPLACE)){ - onMalformedInput = NativeConverter.SUBSTITUTE_CALLBACK; - }else if(newAction.equals(CodingErrorAction.REPORT)){ - onMalformedInput = NativeConverter.STOP_CALLBACK; - } - char[] sub = replacement().toCharArray(); - //System.out.println(" setting callbacks mfi " + onMalformedInput +" umi " + onUnmappableInput); - ec = NativeConverter.setCallbackDecode(converterHandle, onMalformedInput, onUnmappableInput, sub, sub.length); - if(ErrorCode.isFailure(ec)){ - throw ErrorCode.getException(ec); - } - } - - /** - * Sets the action to be taken if an illegal sequence is encountered - * @param newAction action to be taken - * @exception IllegalArgumentException - * @stable ICU 2.4 - */ - protected final void implOnUnmappableCharacter(CodingErrorAction newAction) { - if(newAction.equals(CodingErrorAction.IGNORE)){ - onUnmappableInput = NativeConverter.SKIP_CALLBACK; - }else if(newAction.equals(CodingErrorAction.REPLACE)){ - onUnmappableInput = NativeConverter.SUBSTITUTE_CALLBACK; - }else if(newAction.equals(CodingErrorAction.REPORT)){ - onUnmappableInput = NativeConverter.STOP_CALLBACK; - } - char[] sub = replacement().toCharArray(); - ec = NativeConverter.setCallbackDecode(converterHandle,onMalformedInput, onUnmappableInput, sub, sub.length); - if(ErrorCode.isFailure(ec)){ - throw ErrorCode.getException(ec); - } - } - - /** - * Flushes any characters saved in the converter's internal buffer and - * resets the converter. - * @param out action to be taken - * @return result of flushing action and completes the decoding all input. - * Returns CoderResult.UNDERFLOW if the action succeeds. - * @stable ICU 2.4 - */ - protected final CoderResult implFlush(CharBuffer out) { - try{ - - data[OUTPUT_OFFSET] = getArray(out); - - ec=NativeConverter.flushByteToChar( - converterHandle, /* Handle to ICU Converter */ - output, /* input array of chars */ - outEnd, /* input index+1 to be written */ - data /* contains data, inOff,outOff */ - ); - - - /* If we don't have room for the output, throw an exception*/ - if (ErrorCode.isFailure(ec)) { - if (ec == ErrorCode.U_BUFFER_OVERFLOW_ERROR) { - return CoderResult.OVERFLOW; - }else if (ec == ErrorCode.U_TRUNCATED_CHAR_FOUND ) {//CSDL: add this truncated character error handling - if(data[INPUT_OFFSET]>0){ - return CoderResult.malformedForLength(data[INPUT_OFFSET]); - } - }else { - ErrorCode.getException(ec); - } - } - return CoderResult.UNDERFLOW; - }finally{ - /* save the flushed data */ - setPosition(out); - implReset(); - } - } - - /** - * Resets the to Unicode mode of converter - * @stable ICU 2.4 - */ - protected void implReset() { - NativeConverter.resetByteToChar(converterHandle); - data[INPUT_OFFSET] = 0; - data[OUTPUT_OFFSET] = 0; - data[INVALID_BYTES] = 0; - data[INPUT_HELD] = 0; - savedInputHeldLen = 0; - output = null; - input = null; - } - - /** - * Decodes one or more bytes. The default behaviour of the converter - * is stop and report if an error in input stream is encountered. - * To set different behaviour use @see CharsetDecoder.onMalformedInput() - * This method allows a buffer by buffer conversion of a data stream. - * The state of the conversion is saved between calls to convert. - * Among other things, this means multibyte input sequences can be - * split between calls. If a call to convert results in an Error, the - * conversion may be continued by calling convert again with suitably - * modified parameters.All conversions should be finished with a call to - * the flush method. - * @param in buffer to decode - * @param out buffer to populate with decoded result - * @return result of decoding action. Returns CoderResult.UNDERFLOW if the decoding - * action succeeds or more input is needed for completing the decoding action. - * @stable ICU 2.4 - */ - protected CoderResult decodeLoop(ByteBuffer in,CharBuffer out){ - - if(!in.hasRemaining()){ - return CoderResult.UNDERFLOW; - } - - data[INPUT_OFFSET] = getArray(in); - data[OUTPUT_OFFSET]= getArray(out); - data[INPUT_HELD] = 0; - - try{ - /* do the conversion */ - ec=NativeConverter.decode( - converterHandle, /* Handle to ICU Converter */ - input, /* input array of bytes */ - inEnd, /* last index+1 to be converted */ - output, /* input array of chars */ - outEnd, /* input index+1 to be written */ - data, /* contains data, inOff,outOff */ - false /* donot flush the data */ - ); - - - /* return an error*/ - if(ec == ErrorCode.U_BUFFER_OVERFLOW_ERROR){ - return CoderResult.OVERFLOW; - }else if(ec==ErrorCode.U_INVALID_CHAR_FOUND){ - return CoderResult.malformedForLength(data[INVALID_BYTES]); - }else if(ec==ErrorCode.U_ILLEGAL_CHAR_FOUND){ - return CoderResult.malformedForLength(data[INVALID_BYTES]); - } - /* decoding action succeded */ - return CoderResult.UNDERFLOW; - }finally{ - setPosition(in); - setPosition(out); - } - } - - /** - * Releases the system resources by cleanly closing ICU converter opened - * @stable ICU 2.4 - */ - protected void finalize()throws Throwable{ - NativeConverter.closeConverter(converterHandle); - super.finalize(); - converterHandle = 0; - } - - //------------------------------------------ - // private utility methods - //------------------------------------------ - - private final int getArray(CharBuffer out){ - if(out.hasArray()){ - output = out.array(); - outEnd = out.limit(); - return out.position(); - }else{ - outEnd = out.remaining(); - // BEGIN android-added - if (allocatedOutput == null || (outEnd > allocatedOutput.length)) { - allocatedOutput = new char[outEnd]; - } - output = allocatedOutput; - // END android-added - //since the new - // buffer start position - // is 0 - return 0; - } - - } - private final int getArray(ByteBuffer in){ - if(in.hasArray()){ - input = in.array(); - inEnd = in.limit(); - return in.position()+savedInputHeldLen;/*exclude the number fo bytes held in previous conversion*/ - }else{ - inEnd = in.remaining(); - // BEGIN android-added - if (allocatedInput == null || (inEnd > allocatedInput.length)) { - allocatedInput = new byte[inEnd]; - } - input = allocatedInput; - // END android-added - // save the current position - int pos = in.position(); - in.get(input,0,inEnd); - // reset the position - in.position(pos); - // the start position - // of the new buffer - // is whatever is savedInputLen - return savedInputHeldLen; - } - - } - private final void setPosition(CharBuffer out){ - if(out.hasArray()){ - out.position(out.position() + data[OUTPUT_OFFSET]); - }else{ - out.put(output,0,data[OUTPUT_OFFSET]); - } - // BEGIN android-added - // release reference to output array, which may not be ours - output = null; - // END android-added - } - private final void setPosition(ByteBuffer in){ - - // ok was there input held in the previous invocation of decodeLoop - // that resulted in output in this invocation? - // BEGIN android-changed - in.position(in.position() + data[INPUT_OFFSET] + savedInputHeldLen - data[INPUT_HELD]); - savedInputHeldLen = data[INPUT_HELD]; - // release reference to input array, which may not be ours - input = null; - // END android-changed - } -} diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/charset/CharsetEncoderICU.java b/libcore/icu/src/main/java/com/ibm/icu4jni/charset/CharsetEncoderICU.java deleted file mode 100644 index ec169f4fe..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/charset/CharsetEncoderICU.java +++ /dev/null @@ -1,428 +0,0 @@ -/** -******************************************************************************* -* Copyright (C) 1996-2006, International Business Machines Corporation and * -* others. All Rights Reserved. * -******************************************************************************* -* -******************************************************************************* -*/ -/** - * A JNI interface for ICU converters. - * - * - * @author Ram Viswanadha, IBM - */ -package com.ibm.icu4jni.charset; - -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.charset.Charset; -import java.nio.charset.CharsetEncoder; -import java.nio.charset.CoderResult; -import java.nio.charset.CodingErrorAction; - -import com.ibm.icu4jni.common.ErrorCode; -// BEGIN android-removed -// import com.ibm.icu4jni.converters.NativeConverter; -// END android-removed - -public final class CharsetEncoderICU extends CharsetEncoder { - - private static final int INPUT_OFFSET = 0, - OUTPUT_OFFSET = 1, - INVALID_CHARS = 2, - INPUT_HELD = 3, - LIMIT = 4; - /* data is 3 element array where - * data[INPUT_OFFSET] = on input contains the start of input and on output the number of input chars consumed - * data[OUTPUT_OFFSET] = on input contains the start of output and on output the number of output bytes written - * data[INVALID_CHARS] = number of invalid chars - * data[INPUT_HELD] = number of input chars held in the converter's state - */ - private int[] data = new int[LIMIT]; - /* handle to the ICU converter that is opened */ - private long converterHandle=0; - - private char[] input = null; - private byte[] output = null; - - // BEGIN android-added - private char[] allocatedInput = null; - private byte[] allocatedOutput = null; - // END android-added - - // These instance variables are - // always assigned in the methods - // before being used. This class - // inhrently multithread unsafe - // so we dont have to worry about - // synchronization - private int inEnd; - private int outEnd; - private int ec; - private int savedInputHeldLen; - private int onUnmappableInput = NativeConverter.STOP_CALLBACK;; - private int onMalformedInput = NativeConverter.STOP_CALLBACK;; - - /** - * Construcs a new encoder for the given charset - * @param cs for which the decoder is created - * @param cHandle the address of ICU converter - * @param replacement the substitution bytes - * @stable ICU 2.4 - */ - public CharsetEncoderICU(Charset cs, long cHandle, byte[] replacement) { - super( - cs, - (float) NativeConverter.getAveBytesPerChar(cHandle), - (float) NativeConverter.getMaxBytesPerChar(cHandle), - replacement); - byte[] sub = replacement(); - // The default callback action on unmappable input - // or malformed input is to ignore so we set ICU converter - // callback to stop and report the error - ec = NativeConverter.setCallbackEncode( cHandle, - onMalformedInput, - onUnmappableInput, - sub, sub.length); - converterHandle = cHandle; - if (ErrorCode.isFailure(ec)) { - throw ErrorCode.getException(ec); - } - } - - /** - * Sets this encoders replacement string. Substitutes the string in output if an - * umappable or illegal sequence is encountered - * @param newReplacement to replace the error chars with - * @stable ICU 2.4 - */ - protected void implReplaceWith(byte[] newReplacement) { - if (converterHandle != 0) { - if (newReplacement.length - > NativeConverter.getMaxBytesPerChar(converterHandle)) { - throw new IllegalArgumentException("Number of replacement Bytes are greater than max bytes per char"); - } - ec = NativeConverter.setSubstitutionBytes(converterHandle, - newReplacement, - newReplacement.length); - if (ErrorCode.isFailure(ec)) { - throw ErrorCode.getException(ec); - } - } - } - - /** - * Sets the action to be taken if an illegal sequence is encountered - * @param newAction action to be taken - * @exception IllegalArgumentException - * @stable ICU 2.4 - */ - protected void implOnMalformedInput(CodingErrorAction newAction) { - onMalformedInput = NativeConverter.STOP_CALLBACK; - - if (newAction.equals(CodingErrorAction.IGNORE)) { - onMalformedInput = NativeConverter.SKIP_CALLBACK; - } else if (newAction.equals(CodingErrorAction.REPLACE)) { - onMalformedInput = NativeConverter.SUBSTITUTE_CALLBACK; - } - byte[] sub = replacement(); - ec = NativeConverter.setCallbackEncode(converterHandle, onMalformedInput, onUnmappableInput, sub, sub.length); - if (ErrorCode.isFailure(ec)) { - throw ErrorCode.getException(ec); - } - - } - - /** - * Sets the action to be taken if an illegal sequence is encountered - * @param newAction action to be taken - * @exception IllegalArgumentException - * @stable ICU 2.4 - */ - protected void implOnUnmappableCharacter(CodingErrorAction newAction) { - onUnmappableInput = NativeConverter.STOP_CALLBACK; - - if (newAction.equals(CodingErrorAction.IGNORE)) { - onUnmappableInput = NativeConverter.SKIP_CALLBACK; - } else if (newAction.equals(CodingErrorAction.REPLACE)) { - onUnmappableInput = NativeConverter.SUBSTITUTE_CALLBACK; - } - byte[] sub = replacement(); - ec = NativeConverter.setCallbackEncode(converterHandle, onMalformedInput, onUnmappableInput, sub, sub.length); - if (ErrorCode.isFailure(ec)) { - throw ErrorCode.getException(ec); - } - } - - /** - * Flushes any characters saved in the converter's internal buffer and - * resets the converter. - * @param out action to be taken - * @return result of flushing action and completes the decoding all input. - * Returns CoderResult.UNDERFLOW if the action succeeds. - * @stable ICU 2.4 - */ - protected CoderResult implFlush(ByteBuffer out) { - try { - data[OUTPUT_OFFSET] = getArray(out); - ec = NativeConverter.flushCharToByte(converterHandle,/* Handle to ICU Converter */ - output, /* output array of chars */ - outEnd, /* output index+1 to be written */ - data /* contains data, inOff,outOff */ - ); - - /* If we don't have room for the output, throw an exception*/ - if (ErrorCode.isFailure(ec)) { - if (ec == ErrorCode.U_BUFFER_OVERFLOW_ERROR) { - return CoderResult.OVERFLOW; - }else if (ec == ErrorCode.U_TRUNCATED_CHAR_FOUND) {//CSDL: add this truncated character error handling - if(data[INPUT_OFFSET]>0){ - return CoderResult.malformedForLength(data[INPUT_OFFSET]); - } - }else { - ErrorCode.getException(ec); - } - } - return CoderResult.UNDERFLOW; - } finally { - setPosition(out); - implReset(); - } - } - - /** - * Resets the from Unicode mode of converter - * @stable ICU 2.4 - */ - protected void implReset() { - NativeConverter.resetCharToByte(converterHandle); - data[INPUT_OFFSET] = 0; - data[OUTPUT_OFFSET] = 0; - data[INVALID_CHARS] = 0; - data[INPUT_HELD] = 0; - savedInputHeldLen = 0; - } - - /** - * Encodes one or more chars. The default behaviour of the - * converter is stop and report if an error in input stream is encountered. - * To set different behaviour use @see CharsetEncoder.onMalformedInput() - * @param in buffer to decode - * @param out buffer to populate with decoded result - * @return result of decoding action. Returns CoderResult.UNDERFLOW if the decoding - * action succeeds or more input is needed for completing the decoding action. - * @stable ICU 2.4 - */ - protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out) { - - if (!in.hasRemaining()) { - return CoderResult.UNDERFLOW; - } - - data[INPUT_OFFSET] = getArray(in); - data[OUTPUT_OFFSET]= getArray(out); - data[INPUT_HELD] = 0; - // BEGIN android-added - data[INVALID_CHARS] = 0; // Make sure we don't see earlier errors. - // END android added - - try { - /* do the conversion */ - ec = NativeConverter.encode(converterHandle,/* Handle to ICU Converter */ - input, /* input array of bytes */ - inEnd, /* last index+1 to be converted */ - output, /* output array of chars */ - outEnd, /* output index+1 to be written */ - data, /* contains data, inOff,outOff */ - false /* donot flush the data */ - ); - if (ErrorCode.isFailure(ec)) { - /* If we don't have room for the output return error */ - if (ec == ErrorCode.U_BUFFER_OVERFLOW_ERROR) { - return CoderResult.OVERFLOW; - } else if (ec == ErrorCode.U_INVALID_CHAR_FOUND) { - return CoderResult.unmappableForLength(data[INVALID_CHARS]); - } else if (ec == ErrorCode.U_ILLEGAL_CHAR_FOUND) { - // in.position(in.position() - 1); - return CoderResult.malformedForLength(data[INVALID_CHARS]); - } - } - return CoderResult.UNDERFLOW; - } finally { - /* save state */ - setPosition(in); - setPosition(out); - } - } - - /** - * Ascertains if a given Unicode character can - * be converted to the target encoding - * - * @param c the character to be converted - * @return true if a character can be converted - * @stable ICU 2.4 - * - */ - public boolean canEncode(char c) { - return canEncode((int) c); - } - - /** - * Ascertains if a given Unicode code point (32bit value for handling surrogates) - * can be converted to the target encoding. If the caller wants to test if a - * surrogate pair can be converted to target encoding then the - * responsibility of assembling the int value lies with the caller. - * For assembling a code point the caller can use UTF16 class of ICU4J and do something like: - *
-     * while(i
-     * or
-     * 
-     * String src = new String(mySource);
-     * int i,codepoint;
-     * boolean passed = false;
-     * while(i0xfff)? 2:1;
-     *    if(!(CharsetEncoderICU) myConv).canEncode(codepoint)){
-     *        passed = false;
-     *    }
-     * }
-     * 
- * - * @param codepoint Unicode code point as int value - * @return true if a character can be converted - * @obsolete ICU 2.4 - * @deprecated ICU 3.4 - */ - public boolean canEncode(int codepoint) { - return NativeConverter.canEncode(converterHandle, codepoint); - } - - /** - * Releases the system resources by cleanly closing ICU converter opened - * @exception Throwable exception thrown by super class' finalize method - * @stable ICU 2.4 - */ - protected void finalize() throws Throwable { - NativeConverter.closeConverter(converterHandle); - super.finalize(); - converterHandle=0; - } - - //------------------------------------------ - // private utility methods - //------------------------------------------ - private final int getArray(ByteBuffer out) { - if(out.hasArray()){ - output = out.array(); - outEnd = out.limit(); - return out.position(); - }else{ - outEnd = out.remaining(); - // BEGIN android-added - if (allocatedOutput == null || (outEnd > allocatedOutput.length)) { - allocatedOutput = new byte[outEnd]; - } - output = allocatedOutput; - // END android-added - //since the new - // buffer start position - // is 0 - return 0; - } - } - - private final int getArray(CharBuffer in) { - if(in.hasArray()){ - input = in.array(); - inEnd = in.limit(); - return in.position()+savedInputHeldLen;/*exclude the number fo bytes held in previous conversion*/ - }else{ - inEnd = in.remaining(); - // BEGIN android-added - if (allocatedInput == null || (inEnd > allocatedInput.length)) { - allocatedInput = new char[inEnd]; - } - input = allocatedInput; - // END android-added - // save the current position - int pos = in.position(); - in.get(input,0,inEnd); - // reset the position - in.position(pos); - // the start position - // of the new buffer - // is whatever is savedInputLen - return savedInputHeldLen; - } - - } - private final void setPosition(ByteBuffer out) { - - if (out.hasArray()) { - // in getArray method we accessed the - // array backing the buffer directly and wrote to - // it, so just just set the position and return. - // This is done to avoid the creation of temp array. - out.position(out.position() + data[OUTPUT_OFFSET] ); - } else { - out.put(output, 0, data[OUTPUT_OFFSET]); - } - // BEGIN android-added - // release reference to output array, which may not be ours - output = null; - // END android-added - } - private final void setPosition(CharBuffer in){ - -// BEGIN android-removed -// // was there input held in the previous invocation of encodeLoop -// // that resulted in output in this invocation? -// if(data[OUTPUT_OFFSET]>0 && savedInputHeldLen>0){ -// int len = in.position() + data[INPUT_OFFSET] + savedInputHeldLen; -// in.position(len); -// savedInputHeldLen = data[INPUT_HELD]; -// }else{ -// in.position(in.position() + data[INPUT_OFFSET] + savedInputHeldLen); -// savedInputHeldLen = data[INPUT_HELD]; -// in.position(in.position() - savedInputHeldLen); -// } -// END android-removed - -// BEGIN android-added - // Slightly rewired original code to make it cleaner. Also - // added a fix for the problem where input charatcers got - // lost when invalid characters were encountered. Not sure - // what happens when data[INVALID_CHARS] is > 1, though, - // since we never saw that happening. - int len = in.position() + data[INPUT_OFFSET] + savedInputHeldLen; - len -= data[INVALID_CHARS]; // Otherwise position becomes wrong. - in.position(len); - savedInputHeldLen = data[INPUT_HELD]; - // was there input held in the previous invocation of encodeLoop - // that resulted in output in this invocation? - if(!(data[OUTPUT_OFFSET]>0 && savedInputHeldLen>0)){ - in.position(in.position() - savedInputHeldLen); - } -// END android-added - - // BEGIN android-added - // release reference to input array, which may not be ours - input = null; - // END android-added - } -} diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/charset/CharsetICU.java b/libcore/icu/src/main/java/com/ibm/icu4jni/charset/CharsetICU.java deleted file mode 100644 index df6f7dcf4..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/charset/CharsetICU.java +++ /dev/null @@ -1,129 +0,0 @@ -/** -******************************************************************************* -* Copyright (C) 1996-2005, International Business Machines Corporation and * -* others. All Rights Reserved. * -******************************************************************************* -* -******************************************************************************* -*/ - -package com.ibm.icu4jni.charset; - -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.nio.charset.CharsetEncoder; -import java.util.HashMap; -import java.util.Map; - -// BEGIN android-removed -// import com.ibm.icu4jni.common.ErrorCode; -// import com.ibm.icu4jni.converters.NativeConverter; -// END android-removed - - -public final class CharsetICU extends Charset{ - private String icuCanonicalName; - /** - * Constructor to create a the CharsetICU object - * @param canonicalName the canonical name as a string - * @param aliases the alias set as an array of strings - * @stable ICU 2.4 - */ - protected CharsetICU(String canonicalName, String icuCanonName, String[] aliases) { - super(canonicalName,aliases); - icuCanonicalName = icuCanonName; - - } - /** - * Returns a new decoder instance of this charset object - * @return a new decoder object - * @stable ICU 2.4 - */ - public CharsetDecoder newDecoder(){ - // the arrays are locals and not - // instance variables since the - // methods on this class need to - // be thread safe - long converterHandle = NativeConverter.openConverter(icuCanonicalName); - return new CharsetDecoderICU(this,converterHandle); - }; - - // hardCoded list of replacement bytes - private static final Map subByteMap = new HashMap(); - static{ - subByteMap.put("UTF-32",new byte[]{0x00, 0x00, (byte)0xfe, (byte)0xff}); - subByteMap.put("ibm-16684_P110-2003",new byte[]{0x40, 0x40}); // make \u3000 the sub char - subByteMap.put("ibm-971_P100-1995",new byte[]{(byte)0xa1, (byte)0xa1}); // make \u3000 the sub char - } - /** - * Returns a new encoder object of the charset - * @return a new encoder - * @stable ICU 2.4 - */ - public CharsetEncoder newEncoder(){ - // the arrays are locals and not - // instance variables since the - // methods on this class need to - // be thread safe - long converterHandle = NativeConverter.openConverter(icuCanonicalName); - - //According to the contract all converters should have non-empty replacement - byte[] replacement = NativeConverter.getSubstitutionBytes(converterHandle); - - try{ - return new CharsetEncoderICU(this,converterHandle, replacement); - }catch(IllegalArgumentException ex){ - // work around for the non-sensical check in the nio API that - // a substitution character must be mappable while decoding!! - replacement = (byte[])subByteMap.get(icuCanonicalName); - if(replacement==null){ - replacement = new byte[NativeConverter.getMinBytesPerChar(converterHandle)]; - for(int i=0; i 0) { - converterHandle2 = NativeConverter.openConverter(cs.name()); - if (converterHandle2 > 0) { - return NativeConverter.contains(converterHandle1, - converterHandle2); - } - } - return false; - } finally { - if (0 != converterHandle1) { - NativeConverter.closeConverter(converterHandle1); - if (0 != converterHandle2) { - NativeConverter.closeConverter(converterHandle2); - } - } - } - } -} - - diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/charset/CharsetProviderICU.java b/libcore/icu/src/main/java/com/ibm/icu4jni/charset/CharsetProviderICU.java deleted file mode 100644 index 6f6347962..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/charset/CharsetProviderICU.java +++ /dev/null @@ -1,118 +0,0 @@ -/** -******************************************************************************* -* Copyright (C) 1996-2005, International Business Machines Corporation and * -* others. All Rights Reserved. * -******************************************************************************* -* -******************************************************************************* -*/ - -package com.ibm.icu4jni.charset; - -import java.nio.charset.Charset; -import java.nio.charset.spi.CharsetProvider; -import java.util.*; -import java.util.Iterator; -// BEGIN android-removed -// import com.ibm.icu4jni.converters.NativeConverter; -// END android-removed - -public final class CharsetProviderICU extends CharsetProvider{ - - /** - * Constructs a CharsetProviderICU object - * @stable ICU 2.4 - */ - public CharsetProviderICU(){ - } - - /** - * Constructs a charset for the given charset name - * @param charsetName charset name - * @return charset objet for the given charset name - * @stable ICU 2.4 - */ - public final Charset charsetForName(String charsetName) { - // get the canonical name - String icuCanonicalName = NativeConverter.getICUCanonicalName(charsetName); - - // create the converter object and return it - if(icuCanonicalName==null || icuCanonicalName.length()==0){ - // this would make the Charset API to throw - // unsupported encoding exception - return null; - } - - // BEGIN android-added - try{ - long cn = NativeConverter.openConverter(icuCanonicalName); - NativeConverter.closeConverter(cn); - }catch (RuntimeException re) { - // unsupported encoding. let the charset api throw an - // UnsupportedEncodingException - return null; - } - // END android-added - - return getCharset(icuCanonicalName); - } - private final Charset getCharset(String icuCanonicalName){ - String[] aliases = (String[])NativeConverter.getAliases(icuCanonicalName); - String canonicalName = NativeConverter.getJavaCanonicalName(icuCanonicalName); - return (new CharsetICU(canonicalName,icuCanonicalName, aliases)); - } - /** - * Adds an entry to the given map whose key is the charset's - * canonical name and whose value is the charset itself. - * @param map a map to receive charset objects and names - * @stable ICU 2.4 - */ - public final void putCharsets(Map map) { - // Get the available converter canonical names and aliases - String[] charsets = NativeConverter.getAvailable(); - for(int i=0; i= U_ERROR_LIMIT) { - return null; - } - String errorname = ERROR_NAMES_[U_ILLEGAL_ARGUMENT_ERROR]; - switch (error) { - case U_ILLEGAL_ARGUMENT_ERROR : - return new IllegalArgumentException(errorname); - case U_INDEX_OUTOFBOUNDS_ERROR : - return new ArrayIndexOutOfBoundsException(errorname); - case U_BUFFER_OVERFLOW_ERROR : - return new ArrayIndexOutOfBoundsException(errorname); - case U_UNSUPPORTED_ERROR : - return new UnsupportedOperationException(errorname); - default : - return new RuntimeException(errorname); - } - } - - // public static data member --------------------------------------------- - - /** - * Start of information results (semantically successful) - */ - public static final int U_ERROR_INFO_START = -128; - /** - * A resource bundle lookup returned a fallback result (not an error) - */ - public static final int U_USING_FALLBACK_ERROR = -128; - /** - * A resource bundle lookup returned a result from the root locale (not an - * error) - */ - public static final int U_USING_DEFAULT_ERROR = -127; - /** - * A SafeClone operation required allocating memory (informational - * only - */ - public static final int U_SAFECLONE_ALLOCATED_ERROR = -126; - /** - * This must always be the last warning value to indicate the limit for - * UErrorCode warnings (last warning code +1) - */ - public static final int U_ERROR_INFO_LIMIT = -125; - - /** - * No error, no warning - */ - public static final int U_ZERO_ERROR = 0; - /** - * Start of codes indicating failure - */ - public static final int U_ILLEGAL_ARGUMENT_ERROR = 1; - public static final int U_MISSING_RESOURCE_ERROR = 2; - public static final int U_INVALID_FORMAT_ERROR = 3; - public static final int U_FILE_ACCESS_ERROR = 4; - /** - * Indicates a bug in the library code - */ - public static final int U_INTERNAL_PROGRAM_ERROR = 5; - public static final int U_MESSAGE_PARSE_ERROR = 6; - /** - * Memory allocation error - */ - public static final int U_MEMORY_ALLOCATION_ERROR = 7; - public static final int U_INDEX_OUTOFBOUNDS_ERROR = 8; - /** - * Equivalent to Java ParseException - */ - public static final int U_PARSE_ERROR = 9; - /** - * In the Character conversion routines: Invalid character or sequence was - * encountered - */ - public static final int U_INVALID_CHAR_FOUND = 10; - /** - * In the Character conversion routines: More bytes are required to complete - * the conversion successfully - */ - public static final int U_TRUNCATED_CHAR_FOUND = 11; - /** - * In codeset conversion: a sequence that does NOT belong in the codepage has - * been encountered - */ - public static final int U_ILLEGAL_CHAR_FOUND = 12; - /** - * Conversion table file found, but corrupted - */ - public static final int U_INVALID_TABLE_FORMAT = 13; - /** - * Conversion table file not found - */ - public static final int U_INVALID_TABLE_FILE = 14; - /** - * A result would not fit in the supplied buffer - */ - public static final int U_BUFFER_OVERFLOW_ERROR = 15; - /** - * Requested operation not supported in current context - */ - public static final int U_UNSUPPORTED_ERROR = 16; - /** - * an operation is requested over a resource that does not support it - */ - public static final int U_RESOURCE_TYPE_MISMATCH = 17; - /** - * ISO-2022 illlegal escape sequence - */ - public static final int U_ILLEGAL_ESCAPE_SEQUENCE = 18; - /** - * ISO-2022 unsupported escape sequence - */ - public static final int U_UNSUPPORTED_ESCAPE_SEQUENCE = 19; - /** - * No space available for in-buffer expansion for Arabic shaping - */ - public static final int U_NO_SPACE_AVAILABLE = 20; - /** - * This must always be the last value to indicate the limit for UErrorCode - * (last error code +1) - */ - public static final int U_ERROR_LIMIT = 21; - /** - * Load library flag - */ - public static boolean LIBRARY_LOADED = false; - - // private data member ---------------------------------------------------- - - /** - * Array of error code names corresponding to the errorcodes. - * ie ERROR_NAMES_[0] = name of U_ZERO_ERROR - */ - private static final String ERROR_NAMES_[] = { - "U_ZERO_ERROR", "U_ILLEGAL_ARGUMENT_ERROR", - "U_MISSING_RESOURCE_ERROR", "U_INVALID_FORMAT_ERROR", - "U_FILE_ACCESS_ERROR", "U_INTERNAL_PROGRAM_ERROR", - "U_MESSAGE_PARSE_ERROR", "U_MEMORY_ALLOCATION_ERROR", - "U_INDEX_OUTOFBOUNDS_ERROR", "U_PARSE_ERROR", - "U_INVALID_CHAR_FOUND", "U_TRUNCATED_CHAR_FOUND", - "U_ILLEGAL_CHAR_FOUND", "U_INVALID_TABLE_FORMAT", - "U_INVALID_TABLE_FILE", "U_BUFFER_OVERFLOW_ERROR", - "U_UNSUPPORTED_ERROR", "U_RESOURCE_TYPE_MISMATCH", - "U_ILLEGAL_ESCAPE_SEQUENCE", "U_UNSUPPORTED_ESCAPE_SEQUENCE" - }; - /** - * Returns the error name of the input error code - * @param ec int value of the error code - * @return String name of the error code - * @stable ICU 2.4 - */ - public static String getErrorName(int ec){ - return ERROR_NAMES_[ec]; - } - - /** - * Returns true if the input error code denotes success - * @param ec int value of the error code - * @return boolean - * @stable ICU 2.4 - */ - public static boolean isSuccess(int ec){ - return (ec<=U_ZERO_ERROR); - } - - /** - * Returns true if the input error code denotes failure - * @param ec int value of the error code - * @return boolean - * @stable ICU 2.4 - */ - public static boolean isFailure(int ec){ - return (ec>U_ZERO_ERROR); - } -} - diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/lang/UCharacter.java b/libcore/icu/src/main/java/com/ibm/icu4jni/lang/UCharacter.java deleted file mode 100644 index 7ab1843e7..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/lang/UCharacter.java +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.ibm.icu4jni.lang; - -import java.lang.Character.UnicodeBlock; - -public class UCharacter { - - public static int digit(int codePoint, int radix) { - return digitImpl(codePoint, radix); - } - - private static native int digitImpl(int codePoint, int radix); - - public static int getType(int codePoint) { - return getTypeImpl(codePoint); - } - - private static native int getTypeImpl(int codePoint); - - public static byte getDirectionality(int codePoint) { - return getDirectionalityImpl(codePoint); - } - - private static native byte getDirectionalityImpl(int codePoint); - - public static boolean isMirrored(int codePoint) { - return isMirroredImpl(codePoint); - } - - private static native boolean isMirroredImpl(int codePoint); - - public static int getNumericValue(int codePoint) { - return getNumericValueImpl(codePoint); - } - - private static native int getNumericValueImpl(int codePoint); - - public static boolean isDefined(int codePoint) { - return isDefinedValueImpl(codePoint); - } - - private static native boolean isDefinedValueImpl(int codePoint); - - public static boolean isDigit(int codePoint) { - return isDigitImpl(codePoint); - } - - private static native boolean isDigitImpl(int codePoint); - - public static boolean isIdentifierIgnorable(int codePoint) { - return isIdentifierIgnorableImpl(codePoint); - } - - private static native boolean isIdentifierIgnorableImpl(int codePoint); - - public static boolean isLetter(int codePoint) { - return isLetterImpl(codePoint); - } - - private static native boolean isLetterImpl(int codePoint); - - public static boolean isLetterOrDigit(int codePoint) { - return isLetterOrDigitImpl(codePoint); - } - - private static native boolean isLetterOrDigitImpl(int codePoint); - - public static boolean isSpaceChar(int codePoint) { - return isSpaceCharImpl(codePoint); - } - - private static native boolean isSpaceCharImpl(int codePoint); - - public static boolean isTitleCase(int codePoint) { - return isTitleCaseImpl(codePoint); - } - - private static native boolean isTitleCaseImpl(int codePoint); - - public static boolean isUnicodeIdentifierPart(int codePoint) { - return isUnicodeIdentifierPartImpl(codePoint); - } - - private static native boolean isUnicodeIdentifierPartImpl(int codePoint); - - public static boolean isUnicodeIdentifierStart(int codePoint) { - return isUnicodeIdentifierStartImpl(codePoint); - } - - private static native boolean isUnicodeIdentifierStartImpl(int codePoint); - - public static boolean isWhitespace(int codePoint) { - return isWhitespaceImpl(codePoint); - } - - private static native boolean isWhitespaceImpl(int codePoint); - - public static int toLowerCase(int codePoint) { - return toLowerCaseImpl(codePoint); - } - - private static native int toLowerCaseImpl(int codePoint); - - public static int toTitleCase(int codePoint) { - return toTitleCaseImpl(codePoint); - } - - private static native int toTitleCaseImpl(int codePoint); - - public static int toUpperCase(int codePoint) { - return toUpperCaseImpl(codePoint); - } - - private static native int toUpperCaseImpl(int codePoint); - - public static boolean isUpperCase(int codePoint) { - return isUpperCaseImpl(codePoint); - } - - private static native boolean isUpperCaseImpl(int codePoint); - - public static boolean isLowerCase(int codePoint) { - return isLowerCaseImpl(codePoint); - } - - private static native boolean isLowerCaseImpl(int codePoint); - - public static int forName(String blockName) { - if (blockName == null) { - throw new NullPointerException(); - } - return forname(blockName); - } - - private static native int forname(String blockName); - - public static int of(int codePoint) { - return codeblock(codePoint); - } - - private static native int codeblock(int codePoint); - - public static UnicodeBlock[] getBlockTable() { - /** - * The indices of the entries of this table correspond with the value - * of the ICU enum UBlockCode. When updating ICU it's necessary - * to check if there where any changes for the properties - * used by java.lang.Character. - * The enum is defined in common/unicode/uchar.h - */ - UnicodeBlock[] result = new UnicodeBlock[] { null, - UnicodeBlock.BASIC_LATIN, - UnicodeBlock.LATIN_1_SUPPLEMENT, - UnicodeBlock.LATIN_EXTENDED_A, - UnicodeBlock.LATIN_EXTENDED_B, - UnicodeBlock.IPA_EXTENSIONS, - UnicodeBlock.SPACING_MODIFIER_LETTERS, - UnicodeBlock.COMBINING_DIACRITICAL_MARKS, - UnicodeBlock.GREEK, - UnicodeBlock.CYRILLIC, - UnicodeBlock.ARMENIAN, - UnicodeBlock.HEBREW, - UnicodeBlock.ARABIC, - UnicodeBlock.SYRIAC, - UnicodeBlock.THAANA, - UnicodeBlock.DEVANAGARI, - UnicodeBlock.BENGALI, - UnicodeBlock.GURMUKHI, - UnicodeBlock.GUJARATI, - UnicodeBlock.ORIYA, - UnicodeBlock.TAMIL, - UnicodeBlock.TELUGU, - UnicodeBlock.KANNADA, - UnicodeBlock.MALAYALAM, - UnicodeBlock.SINHALA, - UnicodeBlock.THAI, - UnicodeBlock.LAO, - UnicodeBlock.TIBETAN, - UnicodeBlock.MYANMAR, - UnicodeBlock.GEORGIAN, - UnicodeBlock.HANGUL_JAMO, - UnicodeBlock.ETHIOPIC, - UnicodeBlock.CHEROKEE, - UnicodeBlock.UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS, - UnicodeBlock.OGHAM, - UnicodeBlock.RUNIC, - UnicodeBlock.KHMER, - UnicodeBlock.MONGOLIAN, - UnicodeBlock.LATIN_EXTENDED_ADDITIONAL, - UnicodeBlock.GREEK_EXTENDED, - UnicodeBlock.GENERAL_PUNCTUATION, - UnicodeBlock.SUPERSCRIPTS_AND_SUBSCRIPTS, - UnicodeBlock.CURRENCY_SYMBOLS, - UnicodeBlock.COMBINING_MARKS_FOR_SYMBOLS, - UnicodeBlock.LETTERLIKE_SYMBOLS, - UnicodeBlock.NUMBER_FORMS, - UnicodeBlock.ARROWS, - UnicodeBlock.MATHEMATICAL_OPERATORS, - UnicodeBlock.MISCELLANEOUS_TECHNICAL, - UnicodeBlock.CONTROL_PICTURES, - UnicodeBlock.OPTICAL_CHARACTER_RECOGNITION, - UnicodeBlock.ENCLOSED_ALPHANUMERICS, - UnicodeBlock.BOX_DRAWING, - UnicodeBlock.BLOCK_ELEMENTS, - UnicodeBlock.GEOMETRIC_SHAPES, - UnicodeBlock.MISCELLANEOUS_SYMBOLS, - UnicodeBlock.DINGBATS, - UnicodeBlock.BRAILLE_PATTERNS, - UnicodeBlock.CJK_RADICALS_SUPPLEMENT, - UnicodeBlock.KANGXI_RADICALS, - UnicodeBlock.IDEOGRAPHIC_DESCRIPTION_CHARACTERS, - UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION, - UnicodeBlock.HIRAGANA, - UnicodeBlock.KATAKANA, - UnicodeBlock.BOPOMOFO, - UnicodeBlock.HANGUL_COMPATIBILITY_JAMO, - UnicodeBlock.KANBUN, - UnicodeBlock.BOPOMOFO_EXTENDED, - UnicodeBlock.ENCLOSED_CJK_LETTERS_AND_MONTHS, - UnicodeBlock.CJK_COMPATIBILITY, - UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A, - UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS, - UnicodeBlock.YI_SYLLABLES, - UnicodeBlock.YI_RADICALS, - UnicodeBlock.HANGUL_SYLLABLES, - UnicodeBlock.HIGH_SURROGATES, - UnicodeBlock.HIGH_PRIVATE_USE_SURROGATES, - UnicodeBlock.LOW_SURROGATES, - UnicodeBlock.PRIVATE_USE_AREA, - UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS, - UnicodeBlock.ALPHABETIC_PRESENTATION_FORMS, - UnicodeBlock.ARABIC_PRESENTATION_FORMS_A, - UnicodeBlock.COMBINING_HALF_MARKS, - UnicodeBlock.CJK_COMPATIBILITY_FORMS, - UnicodeBlock.SMALL_FORM_VARIANTS, - UnicodeBlock.ARABIC_PRESENTATION_FORMS_B, - UnicodeBlock.SPECIALS, - UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS, - UnicodeBlock.OLD_ITALIC, - UnicodeBlock.GOTHIC, - UnicodeBlock.DESERET, - UnicodeBlock.BYZANTINE_MUSICAL_SYMBOLS, - UnicodeBlock.MUSICAL_SYMBOLS, - UnicodeBlock.MATHEMATICAL_ALPHANUMERIC_SYMBOLS, - UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B, - UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT, - UnicodeBlock.TAGS, - UnicodeBlock.CYRILLIC_SUPPLEMENTARY, - UnicodeBlock.TAGALOG, - UnicodeBlock.HANUNOO, - UnicodeBlock.BUHID, - UnicodeBlock.TAGBANWA, - UnicodeBlock.MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A, - UnicodeBlock.SUPPLEMENTAL_ARROWS_A, - UnicodeBlock.SUPPLEMENTAL_ARROWS_B, - UnicodeBlock.MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B, - UnicodeBlock.SUPPLEMENTAL_MATHEMATICAL_OPERATORS, - UnicodeBlock.KATAKANA_PHONETIC_EXTENSIONS, - UnicodeBlock.VARIATION_SELECTORS, - UnicodeBlock.SUPPLEMENTARY_PRIVATE_USE_AREA_A, - UnicodeBlock.SUPPLEMENTARY_PRIVATE_USE_AREA_B, - UnicodeBlock.LIMBU, - UnicodeBlock.TAI_LE, - UnicodeBlock.KHMER_SYMBOLS, - UnicodeBlock.PHONETIC_EXTENSIONS, - UnicodeBlock.MISCELLANEOUS_SYMBOLS_AND_ARROWS, - UnicodeBlock.YIJING_HEXAGRAM_SYMBOLS, - UnicodeBlock.LINEAR_B_SYLLABARY, - UnicodeBlock.LINEAR_B_IDEOGRAMS, - UnicodeBlock.AEGEAN_NUMBERS, - UnicodeBlock.UGARITIC, - UnicodeBlock.SHAVIAN, - UnicodeBlock.OSMANYA, - UnicodeBlock.CYPRIOT_SYLLABARY, - UnicodeBlock.TAI_XUAN_JING_SYMBOLS, - UnicodeBlock.VARIATION_SELECTORS_SUPPLEMENT - }; - return result; - } -} diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/regex/NativeRegEx.java b/libcore/icu/src/main/java/com/ibm/icu4jni/regex/NativeRegEx.java deleted file mode 100644 index bdfff5b63..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/regex/NativeRegEx.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.ibm.icu4jni.regex; - -public class NativeRegEx { - - /** - * Opens (compiles) an ICU regular expression. - */ - public static native int open(String pattern, int flags); - - /** - * Makes a copy of a compiled regular expression. - */ - public static native int clone(int regex); - - /** - * Closes the regular expression, recovering all resources (memory) it was - * holding. - */ - public static native void close(int regex); - - /** - * Sets the subject text string upon which the regular expression will look - * for matches. - */ - public static native void setText(int regex, String text); - - /** - * Attempts to match the input string, beginning at startIndex, against the - * pattern. - */ - public static native boolean matches(int regex, int startIndex); - - /** - * Attempts to match the input string, starting from the specified index, - * against the pattern. - */ - public static native boolean lookingAt(int regex, int startIndex); - - /** - * Finds the first matching substring of the input string that matches the - * pattern. - */ - public static native boolean find(int regex, int startIndex); - - /** - * Finds the first matching substring of the input string that matches the - * pattern. - */ - public static native boolean findNext(int regex); - - /** - * Gets the number of capturing groups in this regular expression's pattern. - */ - public static native int groupCount(int regex); - - /** - * Gets all the group information for the current match of the pattern. - */ - public static native void startEnd(int regex, int[] startEnd); - - /** - * Sets the region of the input to be considered during matching. - */ - public static native void setRegion(int regex, int start, int end); - - /** - * Queries the start of the region of the input to be considered during - * matching. - */ - public static native int regionStart(int regex); - - /** - * Queries the end of the region of the input to be considered during - * matching. - */ - public static native int regionEnd(int regex); - - /** - * Controls the transparency of the region bounds. - */ - public static native void useTransparentBounds(int regex, boolean value); - - /** - * Queries the transparency of the region bounds. - */ - public static native boolean hasTransparentBounds(int regex); - - /** - * Controls the anchoring property of the region bounds. - */ - public static native void useAnchoringBounds(int regex, boolean value); - - /** - * Queries the anchoring property of the region bounds. - */ - public static native boolean hasAnchoringBounds(int regex); - - /** - * Queries whether we hit the end of the input during the last match. - */ - public static native boolean hitEnd(int regex); - - /** - * Queries whether more input might change a current match, but wouldn't - * destroy it. - */ - public static native boolean requireEnd(int regex); - - /** - * Resets the matcher, cause a current match to be lost, and sets the - * position at which a subsequent findNext() would start. - */ - public static native void reset(int regex, int position); -} diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/text/BreakIterator.java b/libcore/icu/src/main/java/com/ibm/icu4jni/text/BreakIterator.java deleted file mode 100644 index c8f53721e..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/text/BreakIterator.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.ibm.icu4jni.text; - -import java.text.CharacterIterator; -import java.text.StringCharacterIterator; -import java.util.Locale; - -public abstract class BreakIterator implements Cloneable -{ - protected static int BI_CHAR_INSTANCE = 1; - protected static int BI_WORD_INSTANCE = 2; - protected static int BI_LINE_INSTANCE = 3; - protected static int BI_SENT_INSTANCE = 4; - - protected int type = 0; - - public static Locale[] getAvailableLocales() { - - String[] locales = NativeBreakIterator.getAvailableLocalesImpl(); - - Locale[] result = new Locale[locales.length]; - - String locale; - - int index, index2; - - for(int i = 0; i < locales.length; i++) { - locale = locales[i]; - - index = locale.indexOf('_'); - index2 = locale.lastIndexOf('_'); - - if(index == -1) { - result[i] = new Locale(locales[i]); - } else if(index > 0 && index == index2) { - result[i] = new Locale( - locale.substring(0,index), - locale.substring(index+1)); - } else if(index > 0 && index2 > index) { - result[i] = new Locale( - locale.substring(0,index), - locale.substring(index+1,index2), - locale.substring(index2+1)); - } - } - - return result; - } - - public static BreakIterator getCharacterInstance() { - int iter = NativeBreakIterator.getCharacterInstanceImpl(""); - return new RuleBasedBreakIterator(iter, BI_CHAR_INSTANCE); - } - - public static BreakIterator getCharacterInstance(Locale where) { - int iter = NativeBreakIterator.getCharacterInstanceImpl(where.toString()); - return new RuleBasedBreakIterator(iter, BI_CHAR_INSTANCE); - } - - public static BreakIterator getLineInstance() { - int iter = NativeBreakIterator.getLineInstanceImpl(""); - return new RuleBasedBreakIterator(iter, BI_LINE_INSTANCE); - } - - public static BreakIterator getLineInstance(Locale where) { - int iter = NativeBreakIterator.getLineInstanceImpl(where.toString()); - return new RuleBasedBreakIterator(iter, BI_LINE_INSTANCE); - } - - public static BreakIterator getSentenceInstance() { - int iter = NativeBreakIterator.getSentenceInstanceImpl(""); - return new RuleBasedBreakIterator(iter, BI_SENT_INSTANCE); - } - - public static BreakIterator getSentenceInstance(Locale where) { - int iter = NativeBreakIterator.getSentenceInstanceImpl(where.toString()); - return new RuleBasedBreakIterator(iter, BI_SENT_INSTANCE); - } - - public static BreakIterator getWordInstance() { - int iter = NativeBreakIterator.getWordInstanceImpl(""); - return new RuleBasedBreakIterator(iter, BI_WORD_INSTANCE); - } - - public static BreakIterator getWordInstance(Locale where) { - int iter = NativeBreakIterator.getWordInstanceImpl(where.toString()); - return new RuleBasedBreakIterator(iter, BI_WORD_INSTANCE); - } - - public void setText(String newText) { - setText(new StringCharacterIterator(newText)); - } - - public abstract boolean isBoundary(int offset); - - public abstract int preceding(int offset); - - public abstract Object clone(); - - public abstract int current(); - - public abstract int first(); - - public abstract int following(int offset); - - public abstract CharacterIterator getText(); - - public abstract int last(); - - public abstract int next(int n); - - public abstract int next(); - - public abstract int previous(); - - public abstract void setText(CharacterIterator newText); - -} diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/text/CollationAttribute.java b/libcore/icu/src/main/java/com/ibm/icu4jni/text/CollationAttribute.java deleted file mode 100644 index b1c6107cb..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/text/CollationAttribute.java +++ /dev/null @@ -1,214 +0,0 @@ -/** -******************************************************************************* -* Copyright (C) 1996-2005, International Business Machines Corporation and * -* others. All Rights Reserved. * -******************************************************************************* -* -******************************************************************************* -*/ - -package com.ibm.icu4jni.text; - -/** -* Interface for storing ICU collation equivalent enum values. -* Constants with the prefix VALUE corresponds to ICU's UColAttributeValues, -* the rest corresponds to UColAttribute. -* @author syn wee quek -* @stable ICU 2.4 -*/ - -public final class CollationAttribute -{ - // Collation strength constants ---------------------------------- - /** - * Default value, accepted by most attributes - * @stable ICU 2.4 - */ - public static final int VALUE_DEFAULT = -1; - /** - * Primary collation strength - * @stable ICU 2.4 - */ - public static final int VALUE_PRIMARY = 0; - /** - * Secondary collation strength - * @stable ICU 2.4 - */ - public static final int VALUE_SECONDARY = 1; - /** - * Tertiary collation strength - * @stable ICU 2.4 - */ - public static final int VALUE_TERTIARY = 2; - /** - * Default collation strength - * @stable ICU 2.4 - */ - public static final int VALUE_DEFAULT_STRENGTH = VALUE_TERTIARY; - /** - * Quaternary collation strength - * @stable ICU 2.4 - */ - public static final int VALUE_QUATERNARY = 3; - /** - * Identical collation strength - * @stable ICU 2.4 - */ - public static final int VALUE_IDENTICAL = 15; - - /** - * Turn the feature off - works for FRENCH_COLLATION, CASE_LEVEL, - * HIRAGANA_QUATERNARY_MODE and DECOMPOSITION_MODE - * @stable ICU 2.4 - */ - public static final int VALUE_OFF = 16; - /** @stable ICU 2.4 */ - public static final int VALUE_ON = 17; - - /** - * ALTERNATE_HANDLING mode constants - * @stable ICU 2.4 - */ - public static final int VALUE_SHIFTED = 20; - /** @stable ICU 2.4 */ - public static final int VALUE_NON_IGNORABLE = 21; - - /** - * CASE_FIRST mode constants - * @stable ICU 2.4 - */ - public static final int VALUE_LOWER_FIRST = 24; - /** @stable ICU 2.4 */ - public static final int VALUE_UPPER_FIRST = 25; - - /** - * NORMALIZATION_MODE mode constants - * @deprecated ICU 2.4. Users advised to use VALUE_ON instead. - */ - public static final int VALUE_ON_WITHOUT_HANGUL = 28; - - /** - * Number of attribute value constants - * @stable ICU 2.4 - */ - public static final int VALUE_ATTRIBUTE_VALUE_COUNT = 29; - - // Collation attribute constants ----------------------------------- - - /** - * Attribute for direction of secondary weights - * @stable ICU 2.4 - */ - public static final int FRENCH_COLLATION = 0; - /** - * Attribute for handling variable elements - * @stable ICU 2.4 - */ - public static final int ALTERNATE_HANDLING = 1; - /** - * Who goes first, lower case or uppercase. - * @stable ICU 2.4 - */ - public static final int CASE_FIRST = 2; - /** - * Do we have an extra case level - * @stable ICU 2.4 - */ - public static final int CASE_LEVEL = 3; - /** - * Attribute for normalization - * @stable ICU 2.4 - */ - public static final int NORMALIZATION_MODE = 4; - /** - * Attribute for strength - * @stable ICU 2.4 - */ - public static final int STRENGTH = 5; - /** - * Attribute count - * @stable ICU 2.4 - */ - public static final int ATTRIBUTE_COUNT = 6; - - // package methods -------------------------------------------------- - - /** - * Checks if argument is a valid collation strength - * @param strength potential collation strength - * @return true if strength is a valid collation strength, false otherwise - */ - static boolean checkStrength(int strength) - { - if (strength < VALUE_PRIMARY || - (strength > VALUE_QUATERNARY && strength != VALUE_IDENTICAL)) - return false; - return true; - } - - /** - * Checks if argument is a valid collation type - * @param type collation type to be checked - * @return true if type is a valid collation type, false otherwise - */ - static boolean checkType(int type) - { - if (type < FRENCH_COLLATION || type > STRENGTH) - return false; - return true; - } - - /** - * Checks if argument is a valid normalization type - * @param type normalization type to be checked - * @return true if type is a valid normalization type, false otherwise - */ - static boolean checkNormalization(int type) - { - if (type != VALUE_ON && type != VALUE_OFF - && type != VALUE_ON_WITHOUT_HANGUL) { - return false; - } - return true; - } - - /** - * Checks if attribute type and corresponding attribute value is valid - * @param type attribute type - * @param value attribute value - * @return true if the pair is valid, false otherwise - */ - static boolean checkAttribute(int type, int value) - { - if (value == VALUE_DEFAULT) { - return true; - } - - switch (type) - { - case FRENCH_COLLATION : - if (value >= VALUE_OFF && value <= VALUE_ON) - return true; - break; - case ALTERNATE_HANDLING : - if (value >= VALUE_SHIFTED && - value <= VALUE_NON_IGNORABLE) - return true; - break; - case CASE_FIRST : - if (value >= VALUE_LOWER_FIRST && - value <= VALUE_UPPER_FIRST) - return true; - break; - case CASE_LEVEL : - return (value == VALUE_ON || - value <= VALUE_OFF); - case NORMALIZATION_MODE : - return (value == VALUE_OFF || value == VALUE_ON || - value == VALUE_ON_WITHOUT_HANGUL); - case STRENGTH : - checkStrength(value); - } - return false; - } -} diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/text/CollationElementIterator.java b/libcore/icu/src/main/java/com/ibm/icu4jni/text/CollationElementIterator.java deleted file mode 100644 index 0f5bae46d..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/text/CollationElementIterator.java +++ /dev/null @@ -1,230 +0,0 @@ -/** -******************************************************************************* -* Copyright (C) 1996-2005, International Business Machines Corporation and * -* others. All Rights Reserved. * -******************************************************************************* -* -******************************************************************************* -*/ - -package com.ibm.icu4jni.text; - -import java.text.CharacterIterator; - - -/** -* Collation element iterator JNI wrapper. -* Iterates over the collation elements of a data string. -* The iterator supports both forward and backwards full iteration, ie if -* backwards iteration is performed in the midst of a forward iteration, the -* result is undefined. -* To perform a backwards iteration in the midst of a forward iteration, -* reset() has to be called. -* This will shift the position to either the start or the last character in the -* data string depending on whether next() is called or previous(). -*
-*   RuleBasedCollator coll = Collator.getInstance();
-*   CollationElementIterator iterator = coll.getCollationElementIterator("abc");
-*   int ce = 0;
-*   while (ce != CollationElementIterator.NULLORDER) {
-*     ce = iterator.next();
-*   }
-*   iterator.reset();
-*   while (ce != CollationElementIterator.NULLORDER) {
-*     ce = iterator.previous();
-*   }
-* 
-* @author syn wee quek -* @stable ICU 2.4 -*/ - -public final class CollationElementIterator -{ - // public data member ------------------------------------------- - - /** - * @stable ICU 2.4 - */ - public static final int NULLORDER = 0xFFFFFFFF; - - // public methods ----------------------------------------------- - - /** - * Reset the collation elements to their initial state. - * This will move the 'cursor' to the beginning of the text. - * @stable ICU 2.4 - */ - public void reset() - { - NativeCollation.reset(m_collelemiterator_); - } - - /** - * Get the ordering priority of the next collation element in the text. - * A single character may contain more than one collation element. - * @return next collation elements ordering, or NULLORDER if the end of the - * text is reached. - * @stable ICU 2.4 - */ - public int next() - { - return NativeCollation.next(m_collelemiterator_); - } - - /** - * Get the ordering priority of the previous collation element in the text. - * A single character may contain more than one collation element. - * @return previous collation element ordering, or NULLORDER if the end of - * the text is reached. - * @stable ICU 2.4 - */ - public int previous() - { - return NativeCollation.previous(m_collelemiterator_); - } - - /** - * Get the maximum length of any expansion sequences that end with the - * specified comparison order. - * @param order collation order returned by previous or next. - * @return maximum size of the expansion sequences ending with the collation - * element or 1 if collation element does not occur at the end of - * any expansion sequence - * @stable ICU 2.4 - */ - public int getMaxExpansion(int order) - { - return NativeCollation.getMaxExpansion(m_collelemiterator_, order); - } - - /** - * Set the text containing the collation elements. - * @param source text containing the collation elements. - * @stable ICU 2.4 - */ - public void setText(String source) - { - NativeCollation.setText(m_collelemiterator_, source); - } - - // BEGIN android-added - public void setText(CharacterIterator source) - { - NativeCollation.setText(m_collelemiterator_, source.toString()); - } - // END android-added - - /** - * Get the offset of the current source character. - * This is an offset into the text of the character containing the current - * collation elements. - * @return offset of the current source character. - * @stable ICU 2.4 - */ - public int getOffset() - { - return NativeCollation.getOffset(m_collelemiterator_); - } - - /** - * Set the offset of the current source character. - * This is an offset into the text of the character to be processed. - * @param offset The desired character offset. - * @stable ICU 2.4 - */ - public void setOffset(int offset) - { - NativeCollation.setOffset(m_collelemiterator_, offset); - } - - /** - * Gets the primary order of a collation order. - * @param order the collation order - * @return the primary order of a collation order. - * @stable ICU 2.4 - */ - public static int primaryOrder(int order) - { - return ((order & PRIMARY_ORDER_MASK_) >> PRIMARY_ORDER_SHIFT_) & - UNSIGNED_16_BIT_MASK_; - } - - /** - * Gets the secondary order of a collation order. - * @param order the collation order - * @return the secondary order of a collation order. - * @stable ICU 2.4 - */ - public static int secondaryOrder(int order) - { - return (order & SECONDARY_ORDER_MASK_) >> SECONDARY_ORDER_SHIFT_; - } - - /** - * Gets the tertiary order of a collation order. - * @param order the collation order - * @return the tertiary order of a collation order. - * @stable ICU 2.4 - */ - public static int tertiaryOrder(int order) - { - return order & TERTIARY_ORDER_MASK_; - } - - // protected constructor ---------------------------------------- - - /** - * CollationElementIteratorJNI constructor. - * The only caller of this class should be - * RuleBasedCollator.getCollationElementIterator(). - * @param collelemiteratoraddress address of C collationelementiterator - */ - CollationElementIterator(int collelemiteratoraddress) - { - m_collelemiterator_ = collelemiteratoraddress; - } - - // protected methods -------------------------------------------- - - /** - * Garbage collection. - * Close C collator and reclaim memory. - * @stable ICU 2.4 - */ - protected void finalize() - { - NativeCollation.closeElements(m_collelemiterator_); - } - - // private data members ----------------------------------------- - - /** - * C collator - */ - private int m_collelemiterator_; - - /** - * ICU constant primary order mask for collation elements - */ - private static final int PRIMARY_ORDER_MASK_ = 0xffff0000; - /** - * ICU constant secondary order mask for collation elements - */ - private static final int SECONDARY_ORDER_MASK_ = 0x0000ff00; - /** - * ICU constant tertiary order mask for collation elements - */ - private static final int TERTIARY_ORDER_MASK_ = 0x000000ff; - /** - * ICU constant primary order shift for collation elements - */ - private static final int PRIMARY_ORDER_SHIFT_ = 16; - /** - * ICU constant secondary order shift for collation elements - */ - private static final int SECONDARY_ORDER_SHIFT_ = 8; - /** - * Unsigned 16 bit mask - */ - private static final int UNSIGNED_16_BIT_MASK_ = 0x0000FFFF; -} diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/text/CollationKey.java b/libcore/icu/src/main/java/com/ibm/icu4jni/text/CollationKey.java deleted file mode 100644 index 7e8a0000f..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/text/CollationKey.java +++ /dev/null @@ -1,186 +0,0 @@ -/** -******************************************************************************* -* Copyright (C) 1996-2005, International Business Machines Corporation and * -* others. All Rights Reserved. * -******************************************************************************* -* -* -******************************************************************************* -*/ - -package com.ibm.icu4jni.text; - -/** -* Collation key wrapper, containing the byte array sort key. -* @author syn wee quek -* @stable ICU 2.4 -*/ - -public final class CollationKey implements Comparable -{ - // public methods ----------------------------------------------- - - /** - * Bitwise comparison for the collation keys - * @param target CollationKey to be compared - * @return comparison result from Collator, RESULT_LESS, RESULT_EQUAL, - * RESULT_GREATER - * @stable ICU 2.4 - */ - public int compareTo(CollationKey target) - { - byte tgtbytes[] = target.m_bytes_; - - if (m_bytes_ == null || m_bytes_.length == 0) { - if (tgtbytes == null || tgtbytes.length == 0) { - return Collator.RESULT_EQUAL; - } - return Collator.RESULT_LESS; - } - else { - if (tgtbytes == null || tgtbytes.length == 0) { - return Collator.RESULT_GREATER; - } - } - - int count = m_bytes_.length; - if (tgtbytes.length < count) { - count = tgtbytes.length; - } - - int s, - t; - for (int i = 0; i < count; i ++) - { - // unable to use Arrays.equals - s = m_bytes_[i] & UNSIGNED_BYTE_MASK_; - t = tgtbytes[i] & UNSIGNED_BYTE_MASK_; - if (s < t) { - return Collator.RESULT_LESS; - } - if (s > t) { - return Collator.RESULT_GREATER; - } - } - - if (m_bytes_.length < target.m_bytes_.length) { - return Collator.RESULT_LESS; - } - - if (m_bytes_.length > target.m_bytes_.length) { - return Collator.RESULT_GREATER; - } - - return Collator.RESULT_EQUAL; - } - - /** - * Bitwise comparison for the collation keys. - * Argument is casted to CollationKey - * @param target CollationKey to be compared - * @return comparison result from Collator, RESULT_LESS, RESULT_EQUAL, - * RESULT_GREATER - * @stable ICU 2.4 - */ - public int compareTo(Object target) - { - return compareTo((CollationKey)target); - } - - /** - * Checks if target object is equal to this object. - * Target is first casted to CollationKey and bitwise compared. - * @param target comparison object - * @return true if both objects are equal, false otherwise - * @stable ICU 2.4 - */ - public boolean equals(Object target) - { - if (this == target) { - return true; - } - - // checks getClass here since CollationKey is final not subclassable - if (target == null || target.getClass() != getClass()) { - return false; - } - - return compareTo((CollationKey)target) == Collator.RESULT_EQUAL; - } - - /** - * Creates a hash code for this CollationKey. - * Compute the hash by iterating sparsely over about 32 (up to 63) bytes - * spaced evenly through the string. For each byte, multiply the previous - * hash value by a prime number and add the new byte in, like a linear - * congruential random number generator, producing a pseudorandom - * deterministic value well distributed over the output range. - * @return hash value of collation key. Hash value is never 0. - * @stable ICU 2.4 - */ - public int hashCode() - { - if (m_hash_ == 0) - { - if (m_bytes_ != null || m_bytes_.length != 0) - { - int len = m_bytes_.length; - int inc = ((len - 32) / 32) + 1; - for (int i = 0; i < len;) - { - m_hash_ = (m_hash_ * 37) + m_bytes_[i]; - i += inc; - } - } - if (m_hash_ == 0) - m_hash_ = 1; - } - return m_hash_; - } - - /** - * Create the value of the Collation key in term of bytes - * @return value of Collation key in bytes - * @stable ICU 2.4 - */ - public byte[] toByteArray() - { - if (m_bytes_ == null || m_bytes_.length == 0) - return null; - - return (byte[])m_bytes_.clone(); - } - - // package constructors ---------------------------------------------- - - /** - * Default constructor, for use by the Collator and its subclasses. - */ - CollationKey() - { - m_hash_ = 0; - } - - /** - * Constructor, for use only by the Collator and its subclasses. - */ - CollationKey(byte[] bytes) - { - m_bytes_ = bytes; - m_hash_ = 0; - } - - // private data members ----------------------------------------------- - - private byte m_bytes_[]; - - /** - * Mask value to retrieve a single unsigned byte - */ - private static final int UNSIGNED_BYTE_MASK_ = 0x00FF; - - /** - * Cached hash value - */ - private int m_hash_; -} diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/text/Collator.java b/libcore/icu/src/main/java/com/ibm/icu4jni/text/Collator.java deleted file mode 100644 index 4a7e1bf61..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/text/Collator.java +++ /dev/null @@ -1,431 +0,0 @@ -/** -******************************************************************************* -* Copyright (C) 1996-2005, International Business Machines Corporation and * -* others. All Rights Reserved. * -******************************************************************************* -* -* -******************************************************************************* -*/ - -package com.ibm.icu4jni.text; - -import java.util.Locale; -import com.ibm.icu4jni.text.RuleBasedCollator; - -/** -* Abstract class handling locale specific collation via JNI and ICU. -* Subclasses implement specific collation strategies. One subclass, -* com.ibm.icu4jni.text.RuleBasedCollator, is currently provided and is -* applicable to a wide set of languages. Other subclasses may be created to -* handle more specialized needs. -* You can use the static factory method, getInstance(), to obtain the -* appropriate Collator object for a given locale. -* -*
-* // Compare two strings in the default locale
-* Collator myCollator = Collator.getInstance();
-* if (myCollator.compare("abc", "ABC") < 0) {
-*   System.out.println("abc is less than ABC");
-* }
-* else {
-*   System.out.println("abc is greater than or equal to ABC");
-* }
-* 
-* -* You can set a Collator's strength property to determine the level of -* difference considered significant in comparisons. -* Five strengths in CollationAttribute are provided: VALUE_PRIMARY, -* VALUE_SECONDARY, VALUE_TERTIARY, VALUE_QUARTENARY and VALUE_IDENTICAL. -* The exact assignment of strengths to language features is locale dependant. -* For example, in Czech, "e" and "f" are considered primary differences, while -* "e" and "?" latin small letter e with circumflex are secondary differences, -* "e" and "E" are tertiary differences and "e" and "e" are identical. -* -*

-* The following shows how both case and accents could be ignored for US -* English. -*

-* //Get the Collator for US English and set its strength to PRIMARY
-* Collator usCollator = Collator.getInstance(Locale.US);
-* usCollator.setStrength(Collator.PRIMARY);
-* if (usCollator.compare("abc", "ABC") == 0) {
-*   System.out.println("Strings are equivalent");
-* }
-* 
-* For comparing Strings exactly once, the compare method provides the best -* performance. -* When sorting a list of Strings however, it is generally necessary to compare -* each String multiple times. -* In this case, com.ibm.icu4jni.text.CollationKey provide better performance. -* The CollationKey class converts a String to a series of bits that can be -* compared bitwise against other CollationKeys. -* A CollationKey is created by a Collator object for a given String. -* Note: CollationKeys from different Collators can not be compared. -*

-* -* Considerations : -* 1) ErrorCode not returned to user throw exceptions instead -* 2) Similar API to java.text.Collator -* @author syn wee quek -* @stable ICU 2.4 -*/ - -public abstract class Collator implements Cloneable -{ - // public data members --------------------------------------------------- - - /** - * Strongest collator strength value. Typically used to denote differences - * between base characters. See class documentation for more explanation. - * @see #setStrength - * @see #getStrength - * @stable ICU 2.4 - */ - public final static int PRIMARY = CollationAttribute.VALUE_PRIMARY; - - /** - * Second level collator strength value. - * Accents in the characters are considered secondary differences. - * Other differences between letters can also be considered secondary - * differences, depending on the language. - * See class documentation for more explanation. - * @see #setStrength - * @see #getStrength - * @stable ICU 2.4 - */ - public final static int SECONDARY = CollationAttribute.VALUE_SECONDARY; - - /** - * Third level collator strength value. - * Upper and lower case differences in characters are distinguished at this - * strength level. In addition, a variant of a letter differs from the base - * form on the tertiary level. - * See class documentation for more explanation. - * @see #setStrength - * @see #getStrength - * @stable ICU 2.4 - */ - public final static int TERTIARY = CollationAttribute.VALUE_TERTIARY; - - /** - * Fourth level collator strength value. - * When punctuation is ignored - * - * (see Ignoring Punctuations in the user guide) at PRIMARY to TERTIARY - * strength, an additional strength level can - * be used to distinguish words with and without punctuation. - * See class documentation for more explanation. - * @see #setStrength - * @see #getStrength - * @stable ICU 2.4 - */ - public final static int QUATERNARY = CollationAttribute.VALUE_QUATERNARY; - - /** - *

- * Smallest Collator strength value. When all other strengths are equal, - * the IDENTICAL strength is used as a tiebreaker. The Unicode code point - * values of the NFD form of each string are compared, just in case there - * is no difference. - * See class documentation for more explanation. - *

- *

- * Note this value is different from JDK's - *

- * @stable ICU 2.4 - */ - public final static int IDENTICAL = CollationAttribute.VALUE_IDENTICAL; - - /** - *

Decomposition mode value. With NO_DECOMPOSITION set, Strings - * will not be decomposed for collation. This is the default - * decomposition setting unless otherwise specified by the locale - * used to create the Collator.

- * - *

Note this value is different from the JDK's.

- * @see #CANONICAL_DECOMPOSITION - * @see #getDecomposition - * @see #setDecomposition - * @stable ICU 2.4 - */ - public final static int NO_DECOMPOSITION = CollationAttribute.VALUE_OFF; - - /** - *

Decomposition mode value. With CANONICAL_DECOMPOSITION set, - * characters that are canonical variants according to the Unicode standard - * will be decomposed for collation.

- * - *

CANONICAL_DECOMPOSITION corresponds to Normalization Form D as - * described in - * Unicode Technical Report #15. - *

- * @see #NO_DECOMPOSITION - * @see #getDecomposition - * @see #setDecomposition - * @stable ICU 2.4 - */ - public final static int CANONICAL_DECOMPOSITION - = CollationAttribute.VALUE_ON; - - // Collation result constants ----------------------------------- - // corresponds to ICU's UCollationResult enum balues - /** - * string a == string b - * @stable ICU 2.4 - */ - public static final int RESULT_EQUAL = 0; - /** - * string a > string b - * @stable ICU 2.4 - */ - public static final int RESULT_GREATER = 1; - /** - * string a < string b - * @stable ICU 2.4 - */ - public static final int RESULT_LESS = -1; - /** - * accepted by most attributes - * @stable ICU 2.4 - */ - public static final int RESULT_DEFAULT = -1; - - // public methods ----------------------------------------------- - - /** - * Factory method to create an appropriate Collator which uses the default - * locale collation rules. - * Current implementation createInstance() returns a RuleBasedCollator(Locale) - * instance. The RuleBasedCollator will be created in the following order, - *
    - *
  • Data from argument locale resource bundle if found, otherwise - *
  • Data from parent locale resource bundle of arguemtn locale if found, - * otherwise - *
  • Data from built-in default collation rules if found, other - *
  • null is returned - *
- * @return an instance of Collator - * @stable ICU 2.4 - */ - public static Collator getInstance() - { - return getInstance(null); - } - - /** - * Factory method to create an appropriate Collator which uses the argument - * locale collation rules.
- * Current implementation createInstance() returns a RuleBasedCollator(Locale) - * instance. The RuleBasedCollator will be created in the following order, - *
    - *
  • Data from argument locale resource bundle if found, otherwise - *
  • Data from parent locale resource bundle of arguemtn locale if found, - * otherwise - *
  • Data from built-in default collation rules if found, other - *
  • null is returned - *
- * @param locale to be used for collation - * @return an instance of Collator - * @stable ICU 2.4 - */ - public static Collator getInstance(Locale locale) - { - RuleBasedCollator result = new RuleBasedCollator(locale); - return result; - } - - /** - * Locale dependent equality check for the argument strings. - * @param source string - * @param target string - * @return true if source is equivalent to target, false otherwise - * @stable ICU 2.4 - */ - public boolean equals(String source, String target) - { - return (compare(source, target) == RESULT_EQUAL); - } - - /** - * Checks if argument object is equals to this object. - * @param target object - * @return true if source is equivalent to target, false otherwise - * @stable ICU 2.4 - */ - public abstract boolean equals(Object target); - - /** - * Makes a copy of the current object. - * @return a copy of this object - * @stable ICU 2.4 - */ - public abstract Object clone() throws CloneNotSupportedException; - - /** - * The comparison function compares the character data stored in two - * different strings. Returns information about whether a string is less - * than, greater than or equal to another string. - *

Example of use: - *

-  * .  Collator myCollation = Collator.getInstance(Locale::US);
-  * .  myCollation.setStrength(CollationAttribute.VALUE_PRIMARY);
-  * .  // result would be CollationAttribute.VALUE_EQUAL 
-  * .  // ("abc" == "ABC")
-  * .  // (no primary difference between "abc" and "ABC")
-  * .  int result = myCollation.compare("abc", "ABC",3);
-  * .  myCollation.setStrength(CollationAttribute.VALUE_TERTIARY);
-  * .  // result would be Collation.LESS (abc" <<< "ABC")
-  * .  // (with tertiary difference between "abc" and "ABC")
-  * .  int result = myCollation.compare("abc", "ABC",3);
-  * 
- * @param source source string. - * @param target target string. - * @return result of the comparison, Collator.RESULT_EQUAL, - * Collator.RESULT_GREATER or Collator.RESULT_LESS - * @stable ICU 2.4 - */ - public abstract int compare(String source, String target); - - /** - * Get the decomposition mode of this Collator. - * @return the decomposition mode - * @see #CANONICAL_DECOMPOSITION - * @see #NO_DECOMPOSITION - * @stable ICU 2.4 - */ - public abstract int getDecomposition(); - - /** - * Set the normalization mode used int this object - * The normalization mode influences how strings are compared. - * @param mode desired normalization mode - * @see #CANONICAL_DECOMPOSITION - * @see #NO_DECOMPOSITION - * @stable ICU 2.4 - */ - public abstract void setDecomposition(int mode); - - /** - * Determines the minimum strength that will be use in comparison or - * transformation. - *

- * E.g. with strength == SECONDARY, the tertiary difference is ignored - *

- *

- * E.g. with strength == PRIMARY, the secondary and tertiary difference - * are ignored. - *

- * @return the current comparison level. - * @see #PRIMARY - * @see #SECONDARY - * @see #TERTIARY - * @see #QUATERNARY - * @see #IDENTICAL - * @stable ICU 2.4 - */ - public abstract int getStrength(); - - /** - * Gets the attribute to be used in comparison or transformation. - * @param type the attribute to be set from CollationAttribute - * @return value attribute value from CollationAttribute - * @stable ICU 2.4 - */ - public abstract int getAttribute(int type); - - /** - * Sets the minimum strength to be used in comparison or transformation. - *

Example of use: - *

-     * . Collator myCollation = Collator.createInstance(Locale::US);
-     * . myCollation.setStrength(PRIMARY);
-     * . // result will be "abc" == "ABC"
-     * . // tertiary differences will be ignored
-     * . int result = myCollation->compare("abc", "ABC"); 
-     * 
- * @param strength the new comparison level. - * @see #PRIMARY - * @see #SECONDARY - * @see #TERTIARY - * @see #QUATERNARY - * @see #IDENTICAL - * @stable ICU 2.4 - */ - public abstract void setStrength(int strength); - - /** - * Sets the attribute to be used in comparison or transformation. - *

Example of use: - *

-  * . Collator myCollation = Collator.createInstance(Locale::US);
-  * . myCollation.setAttribute(CollationAttribute.CASE_LEVEL, 
-  * .                          CollationAttribute.VALUE_ON);
-  * . int result = myCollation->compare("\\u30C3\\u30CF", 
-  * .                                   "\\u30C4\\u30CF");
-  * . // result will be Collator.RESULT_LESS.
-  * 
- * @param type the attribute to be set from CollationAttribute - * @param value attribute value from CollationAttribute - * @stable ICU 2.4 - */ - public abstract void setAttribute(int type, int value); - - /** - * Get the sort key as an CollationKey object from the argument string. - * To retrieve sort key in terms of byte arrays, use the method as below
- * - * Collator collator = Collator.getInstance(); - * CollationKey collationkey = collator.getCollationKey("string"); - * byte[] array = collationkey.toByteArray(); - *
- * Byte array result are zero-terminated and can be compared using - * java.util.Arrays.equals(); - * @param source string to be processed. - * @return the sort key - * @stable ICU 2.4 - */ - public abstract CollationKey getCollationKey(String source); - - /** - * Returns a hash of this collation object - * @return hash of this collation object - * @stable ICU 2.4 - */ - public abstract int hashCode(); - - // BEGIN android-added - public static Locale[] getAvailableLocales() { - - String[] locales = NativeCollation.getAvailableLocalesImpl(); - - Locale[] result = new Locale[locales.length]; - - String locale; - - int index, index2; - - for(int i = 0; i < locales.length; i++) { - locale = locales[i]; - - index = locale.indexOf('_'); - index2 = locale.lastIndexOf('_'); - - if(index == -1) { - result[i] = new Locale(locales[i]); - } else if(index == 2 && index == index2) { - result[i] = new Locale( - locale.substring(0,2), - locale.substring(3,5)); - } else if(index == 2 && index2 > index) { - result[i] = new Locale( - locale.substring(0,index), - locale.substring(index + 1,index2), - locale.substring(index2 + 1)); - } - } - - return result; - } - // END android-added -} diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/text/DecimalFormat.java b/libcore/icu/src/main/java/com/ibm/icu4jni/text/DecimalFormat.java deleted file mode 100644 index 5bee1fd70..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/text/DecimalFormat.java +++ /dev/null @@ -1,568 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.ibm.icu4jni.text; - -import com.ibm.icu4jni.text.NativeDecimalFormat.UNumberFormatAttribute; -import com.ibm.icu4jni.text.NativeDecimalFormat.UNumberFormatTextAttribute; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.text.AttributedCharacterIterator; -import java.text.AttributedString; -import java.text.FieldPosition; -import java.text.Format; -import java.text.NumberFormat; -import java.text.ParsePosition; -import java.util.Currency; -import java.util.Locale; - -public class DecimalFormat extends NumberFormat { - - private int addr; - - private DecimalFormatSymbols symbols; - - // fix to be icu4j conform (harmony wants this field to exist) - // for serialization of java.text.DecimalFormat - @SuppressWarnings("unused") - private boolean useExponentialNotation = false; - @SuppressWarnings("unused") - private byte minExponentDigits = 0; - - private boolean negPrefNull; - private boolean negSuffNull; - private boolean posPrefNull; - private boolean posSuffNull; - - public DecimalFormat(String pattern, DecimalFormatSymbols icuSymbols) { - this.addr = icuSymbols.getAddr(); - this.symbols = icuSymbols; - applyPattern(pattern); - } - - @Override - public int hashCode() { - return super.hashCode() * 37 + this.getPositivePrefix().hashCode(); - } - - @Override - public Object clone() { - String pat = this.toPattern(); - Locale loc = this.symbols.getLocale(); - DecimalFormatSymbols sym = (DecimalFormatSymbols) this.symbols.clone(); - DecimalFormat newdf = new DecimalFormat(pat, sym); - newdf.setMaximumIntegerDigits(this.getMaximumIntegerDigits()); - newdf.setMaximumFractionDigits(this.getMaximumFractionDigits()); - newdf.setMinimumIntegerDigits(this.getMinimumIntegerDigits()); - newdf.setMinimumFractionDigits(this.getMinimumFractionDigits()); - newdf.setGroupingUsed(this.isGroupingUsed()); - newdf.setGroupingSize(this.getGroupingSize()); - return newdf; - } - - @Override - public boolean equals(Object object) { - if (object == this) { - return true; - } - if (!(object instanceof DecimalFormat)) { - return false; - } - DecimalFormat obj = (DecimalFormat) object; - - if(obj.addr == this.addr) { - return true; - } - - boolean result = super.equals(object); - - - result &= obj.toPattern().equals(this.toPattern()); - result &= obj.isDecimalSeparatorAlwaysShown() == this.isDecimalSeparatorAlwaysShown(); - result &= obj.getGroupingSize() == this.getGroupingSize(); - result &= obj.getMultiplier() == this.getMultiplier(); - result &= obj.getNegativePrefix().equals(this.getNegativePrefix()); - result &= obj.getNegativeSuffix().equals(this.getNegativeSuffix()); - result &= obj.getPositivePrefix().equals(this.getPositivePrefix()); - result &= obj.getPositiveSuffix().equals(this.getPositiveSuffix()); - result &= obj.getMaximumIntegerDigits() == this.getMaximumIntegerDigits(); - result &= obj.getMaximumFractionDigits() == this.getMaximumFractionDigits(); - result &= obj.getMinimumIntegerDigits() == this.getMinimumIntegerDigits(); - result &= obj.getMinimumFractionDigits() == this.getMinimumFractionDigits(); - result &= obj.isGroupingUsed() == this.isGroupingUsed(); - Currency objCurr = obj.getCurrency(); - Currency thisCurr = this.getCurrency(); - if(objCurr != null) { - result &= objCurr.getCurrencyCode().equals(thisCurr.getCurrencyCode()); - result &= objCurr.getSymbol().equals(thisCurr.getSymbol()); - result &= objCurr.getDefaultFractionDigits() == thisCurr.getDefaultFractionDigits(); - } else { - result &= thisCurr == null; - } - result &= obj.getDecimalFormatSymbols().equals(this.getDecimalFormatSymbols()); - - return result; - } - - @Override - public StringBuffer format(Object value, StringBuffer buffer, FieldPosition field) { - - if(!(value instanceof Number)) { - throw new IllegalArgumentException(); - } - if(buffer == null || field == null) { - throw new NullPointerException(); - } - - String fieldType = getFieldType(field.getFieldAttribute()); - - Number number = (Number) value; - - if(number instanceof BigInteger) { - BigInteger valBigInteger = (BigInteger) number; - String result = NativeDecimalFormat.format(this.addr, - valBigInteger.toString(10), field, fieldType, null, 0); - return buffer.append(result); - } else if(number instanceof BigDecimal) { - BigDecimal valBigDecimal = (BigDecimal) number; - StringBuilder val = new StringBuilder(); - val.append(valBigDecimal.unscaledValue().toString(10)); - int scale = valBigDecimal.scale(); - scale = makeScalePositive(scale, val); - String result = NativeDecimalFormat.format(this.addr, - val.toString(), field, fieldType, null, scale); - return buffer.append(result); - } else { - double dv = number.doubleValue(); - long lv = number.longValue(); - if (dv == lv) { - String result = NativeDecimalFormat.format(this.addr, lv, field, - fieldType, null); - return buffer.append(result); - } - String result = NativeDecimalFormat.format(this.addr, dv, field, - fieldType, null); - return buffer.append(result); - } - } - - @Override - public StringBuffer format(long value, StringBuffer buffer, FieldPosition field) { - - if(buffer == null || field == null) { - throw new NullPointerException(); - } - - String fieldType = getFieldType(field.getFieldAttribute()); - - String result = NativeDecimalFormat.format(this.addr, value, field, - fieldType, null); - - buffer.append(result.toCharArray(), 0, result.length()); - - return buffer; - } - - @Override - public StringBuffer format(double value, StringBuffer buffer, FieldPosition field) { - - if(buffer == null || field == null) { - throw new NullPointerException(); - } - - String fieldType = getFieldType(field.getFieldAttribute()); - - String result = NativeDecimalFormat.format(this.addr, value, field, - fieldType, null); - - buffer.append(result.toCharArray(), 0, result.length()); - - return buffer; - } - - public void applyLocalizedPattern(String pattern) { - if (pattern == null) { - throw new NullPointerException("pattern was null"); - } - try { - NativeDecimalFormat.applyPatternImpl(this.addr, false, pattern); - } catch(RuntimeException re) { - throw new IllegalArgumentException( - "applying localized pattern failed for pattern: " + pattern, re); - } - } - - public void applyPattern(String pattern) { - if (pattern == null) { - throw new NullPointerException("pattern was null"); - } - try { - NativeDecimalFormat.applyPatternImpl(this.addr, false, pattern); - } catch(RuntimeException re) { - throw new IllegalArgumentException( - "applying pattern failed for pattern: " + pattern, re); - } - } - - @Override - public AttributedCharacterIterator formatToCharacterIterator(Object object) { - if (!(object instanceof Number)) { - throw new IllegalArgumentException(); - } - Number number = (Number) object; - String text = null; - StringBuffer attributes = new StringBuffer(); - - if(number instanceof BigInteger) { - BigInteger valBigInteger = (BigInteger) number; - text = NativeDecimalFormat.format(this.addr, - valBigInteger.toString(10), null, null, attributes, 0); - } else if(number instanceof BigDecimal) { - BigDecimal valBigDecimal = (BigDecimal) number; - StringBuilder val = new StringBuilder(); - val.append(valBigDecimal.unscaledValue().toString(10)); - int scale = valBigDecimal.scale(); - scale = makeScalePositive(scale, val); - text = NativeDecimalFormat.format(this.addr, val.toString(), null, - null, attributes, scale); - } else { - double dv = number.doubleValue(); - long lv = number.longValue(); - if (dv == lv) { - text = NativeDecimalFormat.format(this.addr, lv, null, - null, attributes); - } else { - text = NativeDecimalFormat.format(this.addr, dv, null, - null, attributes); - } - } - - AttributedString as = new AttributedString(text.toString()); - - String[] attrs = attributes.toString().split(";"); - // add NumberFormat field attributes to the AttributedString - int size = attrs.length / 3; - if(size * 3 != attrs.length) { - return as.getIterator(); - } - for (int i = 0; i < size; i++) { - Format.Field attribute = getField(attrs[3*i]); - as.addAttribute(attribute, attribute, Integer.parseInt(attrs[3*i+1]), - Integer.parseInt(attrs[3*i+2])); - } - - // return the CharacterIterator from AttributedString - return as.getIterator(); - } - - private int makeScalePositive(int scale, StringBuilder val) { - if (scale < 0) { - scale = -scale; - for (int i = scale; i > 0; i--) { - val.append('0'); - } - scale = 0; - } - return scale; - } - - public String toLocalizedPattern() { - return NativeDecimalFormat.toPatternImpl(this.addr, true); - } - - public String toPattern() { - return NativeDecimalFormat.toPatternImpl(this.addr, false); - } - - @Override - public Number parse(String string, ParsePosition position) { - return NativeDecimalFormat.parse(addr, string, position); - } - - // start getter and setter - - @Override - public int getMaximumFractionDigits() { - return NativeDecimalFormat.getAttribute(this .addr, - UNumberFormatAttribute.UNUM_MAX_FRACTION_DIGITS.ordinal()); - } - - @Override - public int getMaximumIntegerDigits() { - return NativeDecimalFormat.getAttribute(this .addr, - UNumberFormatAttribute.UNUM_MAX_INTEGER_DIGITS.ordinal()); - } - - @Override - public int getMinimumFractionDigits() { - return NativeDecimalFormat.getAttribute(this .addr, - UNumberFormatAttribute.UNUM_MIN_FRACTION_DIGITS.ordinal()); - } - - @Override - public int getMinimumIntegerDigits() { - return NativeDecimalFormat.getAttribute(this .addr, - UNumberFormatAttribute.UNUM_MIN_INTEGER_DIGITS.ordinal()); - } - - @Override - public Currency getCurrency() { - return this.symbols.getCurrency(); - } - - public int getGroupingSize() { - return NativeDecimalFormat.getAttribute(this.addr, - UNumberFormatAttribute.UNUM_GROUPING_SIZE.ordinal()); - } - - public int getMultiplier() { - return NativeDecimalFormat.getAttribute(this.addr, - UNumberFormatAttribute.UNUM_MULTIPLIER.ordinal()); - } - - public String getNegativePrefix() { - if (negPrefNull) { - return null; - } - return NativeDecimalFormat.getTextAttribute(this.addr, - UNumberFormatTextAttribute.UNUM_NEGATIVE_PREFIX.ordinal()); - } - - public String getNegativeSuffix() { - if (negSuffNull) { - return null; - } - return NativeDecimalFormat.getTextAttribute(this.addr, - UNumberFormatTextAttribute.UNUM_NEGATIVE_SUFFIX.ordinal()); - } - - public String getPositivePrefix() { - if (posPrefNull) { - return null; - } - return NativeDecimalFormat.getTextAttribute(this.addr, - UNumberFormatTextAttribute.UNUM_POSITIVE_PREFIX.ordinal()); - } - - public String getPositiveSuffix() { - if (posSuffNull) { - return null; - } - return NativeDecimalFormat.getTextAttribute(this.addr, - UNumberFormatTextAttribute.UNUM_POSITIVE_SUFFIX.ordinal()); - } - - public boolean isDecimalSeparatorAlwaysShown() { - return NativeDecimalFormat.getAttribute(this.addr, - UNumberFormatAttribute.UNUM_DECIMAL_ALWAYS_SHOWN.ordinal()) != 0; - } - - @Override - public boolean isParseIntegerOnly() { - return NativeDecimalFormat.getAttribute(this.addr, - UNumberFormatAttribute.UNUM_PARSE_INT_ONLY.ordinal()) != 0; - } - - @Override - public boolean isGroupingUsed() { - return NativeDecimalFormat.getAttribute(this.addr, - UNumberFormatAttribute.UNUM_GROUPING_USED.ordinal()) != 0; - } - - public DecimalFormatSymbols getDecimalFormatSymbols() { - return this.symbols; - } - - public void setDecimalFormatSymbols(DecimalFormatSymbols icuSymbols) { - this.symbols = icuSymbols; - } - - public void setDecimalSeparatorAlwaysShown(boolean value) { - int i = value ? -1 : 0; - NativeDecimalFormat.setAttribute(this.addr, - UNumberFormatAttribute.UNUM_DECIMAL_ALWAYS_SHOWN.ordinal(), i); - } - - @Override - public void setCurrency(Currency currency) { - this.symbols.setCurrency(currency); - } - - public void setGroupingSize(int value) { - NativeDecimalFormat.setAttribute(this.addr, - UNumberFormatAttribute.UNUM_GROUPING_SIZE.ordinal(), value); - } - - @Override - public void setGroupingUsed(boolean value) { - int i = value ? -1 : 0; - NativeDecimalFormat.setAttribute(this.addr, - UNumberFormatAttribute.UNUM_GROUPING_USED.ordinal(), i); - } - - @Override - public void setMaximumFractionDigits(int value) { - NativeDecimalFormat.setAttribute(this.addr, - UNumberFormatAttribute.UNUM_MAX_FRACTION_DIGITS.ordinal(), value); - } - - @Override - public void setMaximumIntegerDigits(int value) { - NativeDecimalFormat.setAttribute(this.addr, - UNumberFormatAttribute.UNUM_MAX_INTEGER_DIGITS.ordinal(), value); - } - - @Override - public void setMinimumFractionDigits(int value) { - NativeDecimalFormat.setAttribute(this.addr, - UNumberFormatAttribute.UNUM_MIN_FRACTION_DIGITS.ordinal(), value); - } - - @Override - public void setMinimumIntegerDigits(int value) { - NativeDecimalFormat.setAttribute(this.addr, - UNumberFormatAttribute.UNUM_MIN_INTEGER_DIGITS.ordinal(), value); - } - - public void setMultiplier(int value) { - NativeDecimalFormat.setAttribute(this.addr, - UNumberFormatAttribute.UNUM_MULTIPLIER.ordinal(), value); - } - - public void setNegativePrefix(String value) { - negPrefNull = value == null; - if (!negPrefNull) { - NativeDecimalFormat.setTextAttribute(this.addr, - UNumberFormatTextAttribute.UNUM_NEGATIVE_PREFIX.ordinal(), - value); - } - } - - public void setNegativeSuffix(String value) { - negSuffNull = value == null; - if (!negSuffNull) { - NativeDecimalFormat.setTextAttribute(this.addr, - UNumberFormatTextAttribute.UNUM_NEGATIVE_SUFFIX.ordinal(), - value); - } - } - - public void setPositivePrefix(String value) { - posPrefNull = value == null; - if (!posPrefNull) { - NativeDecimalFormat.setTextAttribute(this.addr, - UNumberFormatTextAttribute.UNUM_POSITIVE_PREFIX.ordinal(), - value); - } - } - - public void setPositiveSuffix(String value) { - posSuffNull = value == null; - if (!posSuffNull) { - NativeDecimalFormat.setTextAttribute(this.addr, - UNumberFormatTextAttribute.UNUM_POSITIVE_SUFFIX.ordinal(), - value); - } - } - - @Override - public void setParseIntegerOnly(boolean value) { - int i = value ? -1 : 0; - NativeDecimalFormat.setAttribute(this.addr, - UNumberFormatAttribute.UNUM_PARSE_INT_ONLY.ordinal(), i); - } - - static protected String getFieldType(Format.Field field) { - if(field == null) { - return null; - } - if(field.equals(NumberFormat.Field.SIGN)) { - return "sign"; - } - if(field.equals(NumberFormat.Field.INTEGER)) { - return "integer"; - } - if(field.equals(NumberFormat.Field.FRACTION)) { - return "fraction"; - } - if(field.equals(NumberFormat.Field.EXPONENT)) { - return "exponent"; - } - if(field.equals(NumberFormat.Field.EXPONENT_SIGN)) { - return "exponent_sign"; - } - if(field.equals(NumberFormat.Field.EXPONENT_SYMBOL)) { - return "exponent_symbol"; - } - if(field.equals(NumberFormat.Field.CURRENCY)) { - return "currency"; - } - if(field.equals(NumberFormat.Field.GROUPING_SEPARATOR)) { - return "grouping_separator"; - } - if(field.equals(NumberFormat.Field.DECIMAL_SEPARATOR)) { - return "decimal_separator"; - } - if(field.equals(NumberFormat.Field.PERCENT)) { - return "percent"; - } - if(field.equals(NumberFormat.Field.PERMILLE)) { - return "permille"; - } - return null; - } - - protected Format.Field getField(String type) { - if(type.equals("")) { - return null; - } - if(type.equals("sign")) { - return NumberFormat.Field.SIGN; - } - if(type.equals("integer")) { - return NumberFormat.Field.INTEGER; - } - if(type.equals("fraction")) { - return NumberFormat.Field.FRACTION; - } - if(type.equals("exponent")) { - return NumberFormat.Field.EXPONENT; - } - if(type.equals("exponent_sign")) { - return NumberFormat.Field.EXPONENT_SIGN; - } - if(type.equals("exponent_symbol")) { - return NumberFormat.Field.EXPONENT_SYMBOL; - } - if(type.equals("currency")) { - return NumberFormat.Field.CURRENCY; - } - if(type.equals("grouping_separator")) { - return NumberFormat.Field.GROUPING_SEPARATOR; - } - if(type.equals("decimal_separator")) { - return NumberFormat.Field.DECIMAL_SEPARATOR; - } - if(type.equals("percent")) { - return NumberFormat.Field.PERCENT; - } - if(type.equals("permille")) { - return NumberFormat.Field.PERMILLE; - } - return null; - } -} diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/text/DecimalFormatSymbols.java b/libcore/icu/src/main/java/com/ibm/icu4jni/text/DecimalFormatSymbols.java deleted file mode 100644 index 98463e4de..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/text/DecimalFormatSymbols.java +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.ibm.icu4jni.text; - -import com.ibm.icu4jni.text.NativeDecimalFormat.UNumberFormatSymbol; - -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.Currency; -import java.util.Locale; -import java.util.ResourceBundle; - -public class DecimalFormatSymbols { - - private int addr; - - private Locale loc; - - private DecimalFormatSymbols(int addr, Locale loc) { - this.addr = addr; - this.loc = loc; - } - - public DecimalFormatSymbols(Locale locale) { - this.loc = locale; - ResourceBundle bundle = AccessController. - doPrivileged(new PrivilegedAction() { - public ResourceBundle run() { - return ResourceBundle.getBundle( - "org.apache.harmony.luni.internal.locale.Locale", loc); //$NON-NLS-1$ - } - }); - String pattern = bundle.getString("Number"); - this.addr = NativeDecimalFormat.openDecimalFormatImpl( - locale.toString(), pattern); - String currSymbol = bundle.getString("CurrencySymbol"); - String intCurrSymbol = bundle.getString("IntCurrencySymbol"); - NativeDecimalFormat.setSymbol(this.addr, - UNumberFormatSymbol.UNUM_CURRENCY_SYMBOL.ordinal(), currSymbol); - NativeDecimalFormat.setSymbol(this.addr, - UNumberFormatSymbol.UNUM_INTL_CURRENCY_SYMBOL.ordinal(), - intCurrSymbol); - } - - @Override - public boolean equals(Object object) { - if(object == null) { - return false; - } - if(!(object instanceof DecimalFormatSymbols)) { - return false; - } - - DecimalFormatSymbols sym = (DecimalFormatSymbols) object; - - if(sym.addr == this.addr) { - return true; - } - - boolean result = true; - - Currency objCurr = sym.getCurrency(); - Currency thisCurr = this.getCurrency(); - if(objCurr != null) { - result &= objCurr.getCurrencyCode().equals(thisCurr.getCurrencyCode()); - result &= objCurr.getSymbol().equals(thisCurr.getSymbol()); - result &= objCurr.getDefaultFractionDigits() == thisCurr.getDefaultFractionDigits(); - } else { - result &= thisCurr == null; - } - result &= sym.getCurrencySymbol().equals(this.getCurrencySymbol()); - result &= sym.getDecimalSeparator() == this.getDecimalSeparator(); - result &= sym.getDigit() == this.getDigit(); - result &= sym.getGroupingSeparator() == this.getGroupingSeparator(); - result &= sym.getInfinity().equals(this.getInfinity()); - result &= sym.getInternationalCurrencySymbol().equals( - this.getInternationalCurrencySymbol()); - result &= sym.getMinusSign() == this.getMinusSign(); - result &= sym.getMonetaryDecimalSeparator() == - this.getMonetaryDecimalSeparator(); - result &= sym.getNaN().equals(this.getNaN()); - result &= sym.getPatternSeparator() == this.getPatternSeparator(); - result &= sym.getPercent() == this.getPercent(); - result &= sym.getPerMill() == this.getPerMill(); - result &= sym.getZeroDigit() == this.getZeroDigit(); - - return result; - } - - @Override - public Object clone() { - int addr = NativeDecimalFormat.cloneImpl(this.addr); - Locale loc = (Locale) this.loc.clone(); - return new DecimalFormatSymbols(addr, loc); - } - - public void setCurrency(Currency currency) { - NativeDecimalFormat.setSymbol(this.addr, - UNumberFormatSymbol.UNUM_CURRENCY_SYMBOL.ordinal(), - currency.getSymbol()); - NativeDecimalFormat.setSymbol(this.addr, - UNumberFormatSymbol.UNUM_INTL_CURRENCY_SYMBOL.ordinal(), - currency.getCurrencyCode()); - } - - public void setCurrencySymbol(String symbol) { - NativeDecimalFormat.setSymbol(this.addr, - UNumberFormatSymbol.UNUM_CURRENCY_SYMBOL.ordinal(), - symbol); - } - - public void setDecimalSeparator(char symbol) { - NativeDecimalFormat.setSymbol(this.addr, - UNumberFormatSymbol.UNUM_DECIMAL_SEPARATOR_SYMBOL.ordinal(), - "" + symbol); - } - - public void setDigit(char symbol) { - NativeDecimalFormat.setSymbol(this.addr, - UNumberFormatSymbol.UNUM_DIGIT_SYMBOL.ordinal(), - "" + symbol); - } - - public void setGroupingSeparator(char symbol) { - NativeDecimalFormat.setSymbol(this.addr, - UNumberFormatSymbol.UNUM_GROUPING_SEPARATOR_SYMBOL.ordinal(), - "" + symbol); - NativeDecimalFormat.setSymbol(this.addr, - UNumberFormatSymbol.UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL.ordinal(), - "" + symbol); - } - - public void setInfinity(String symbol) { - NativeDecimalFormat.setSymbol(this.addr, - UNumberFormatSymbol.UNUM_INFINITY_SYMBOL.ordinal(), - symbol); - } - - public void setInternationalCurrencySymbol(String symbol) { - NativeDecimalFormat.setSymbol(this.addr, - UNumberFormatSymbol.UNUM_INTL_CURRENCY_SYMBOL.ordinal(), - symbol); - } - - public void setMinusSign(char symbol) { - NativeDecimalFormat.setSymbol(this.addr, - UNumberFormatSymbol.UNUM_MINUS_SIGN_SYMBOL.ordinal(), - "" + symbol); - } - - public void setMonetaryDecimalSeparator(char symbol) { - NativeDecimalFormat.setSymbol(this.addr, - UNumberFormatSymbol.UNUM_MONETARY_SEPARATOR_SYMBOL.ordinal(), - "" + symbol); - } - - public void setNaN(String symbol) { - NativeDecimalFormat.setSymbol(this.addr, - UNumberFormatSymbol.UNUM_NAN_SYMBOL.ordinal(), - "" + symbol); - } - - public void setPatternSeparator(char symbol) { - NativeDecimalFormat.setSymbol(this.addr, - UNumberFormatSymbol.UNUM_PATTERN_SEPARATOR_SYMBOL.ordinal(), - "" + symbol); - } - - public void setPercent(char symbol) { - NativeDecimalFormat.setSymbol(this.addr, - UNumberFormatSymbol.UNUM_PERCENT_SYMBOL.ordinal(), - "" + symbol); - } - - public void setPerMill(char symbol) { - NativeDecimalFormat.setSymbol(this.addr, - UNumberFormatSymbol.UNUM_PERMILL_SYMBOL.ordinal(), - "" + symbol); - } - - public void setZeroDigit(char symbol) { - NativeDecimalFormat.setSymbol(this.addr, - UNumberFormatSymbol.UNUM_ZERO_DIGIT_SYMBOL.ordinal(), - "" + symbol); - } - - public Currency getCurrency() { - String curr = NativeDecimalFormat.getSymbol(this.addr, - UNumberFormatSymbol.UNUM_INTL_CURRENCY_SYMBOL.ordinal()); - if(curr.equals("") || curr.equals("\u00a4\u00a4")) { - return null; - } - return Currency.getInstance(curr); - } - - public String getCurrencySymbol() { - return NativeDecimalFormat.getSymbol(this.addr, - UNumberFormatSymbol.UNUM_CURRENCY_SYMBOL.ordinal()); - } - - public char getDecimalSeparator() { - return NativeDecimalFormat.getSymbol(this.addr, - UNumberFormatSymbol.UNUM_DECIMAL_SEPARATOR_SYMBOL.ordinal()) - .charAt(0); - } - - public char getDigit() { - return NativeDecimalFormat.getSymbol(this.addr, - UNumberFormatSymbol.UNUM_DIGIT_SYMBOL.ordinal()) - .charAt(0); - } - - public char getGroupingSeparator() { - return NativeDecimalFormat.getSymbol(this.addr, - UNumberFormatSymbol.UNUM_GROUPING_SEPARATOR_SYMBOL.ordinal()) - .charAt(0); - } - - public String getInfinity() { - return NativeDecimalFormat.getSymbol(this.addr, - UNumberFormatSymbol.UNUM_INFINITY_SYMBOL.ordinal()); - } - - public String getInternationalCurrencySymbol() { - return NativeDecimalFormat.getSymbol(this.addr, - UNumberFormatSymbol.UNUM_INTL_CURRENCY_SYMBOL.ordinal()); - } - - public char getMinusSign() { - return NativeDecimalFormat.getSymbol(this.addr, - UNumberFormatSymbol.UNUM_MINUS_SIGN_SYMBOL.ordinal()) - .charAt(0); - } - - public char getMonetaryDecimalSeparator() { - return NativeDecimalFormat.getSymbol(this.addr, - UNumberFormatSymbol.UNUM_MONETARY_SEPARATOR_SYMBOL.ordinal()) - .charAt(0); - } - - public String getNaN() { - return NativeDecimalFormat.getSymbol(this.addr, - UNumberFormatSymbol.UNUM_NAN_SYMBOL.ordinal()); - } - - public char getPatternSeparator() { - return NativeDecimalFormat.getSymbol(this.addr, - UNumberFormatSymbol.UNUM_PATTERN_SEPARATOR_SYMBOL.ordinal()) - .charAt(0); - } - - public char getPercent() { - return NativeDecimalFormat.getSymbol(this.addr, - UNumberFormatSymbol.UNUM_PERCENT_SYMBOL.ordinal()) - .charAt(0); - } - - public char getPerMill() { - return NativeDecimalFormat.getSymbol(this.addr, - UNumberFormatSymbol.UNUM_PERMILL_SYMBOL.ordinal()) - .charAt(0); - } - - public char getZeroDigit() { - return NativeDecimalFormat.getSymbol(this.addr, - UNumberFormatSymbol.UNUM_ZERO_DIGIT_SYMBOL.ordinal()) - .charAt(0); - } - - int getAddr() { - return this.addr; - } - - Locale getLocale() { - return this.loc; - } - - protected void finalize() { - NativeDecimalFormat.closeDecimalFormatImpl(this.addr); - } -} diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/text/NativeBreakIterator.java b/libcore/icu/src/main/java/com/ibm/icu4jni/text/NativeBreakIterator.java deleted file mode 100644 index 25249c7c6..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/text/NativeBreakIterator.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.ibm.icu4jni.text; - -final class NativeBreakIterator -{ - public NativeBreakIterator() { - - } - - static String[] getAvailableLocalesImpl() { - int count = getAvailableLocalesCountImpl(); - String[] result = new String[count]; - - for(int i = 0; i < count; i++) { - result[i] = getAvailableLocalesImpl(i); - } - return result; - } - - private static native String getAvailableLocalesImpl(int i); - - private static native int getAvailableLocalesCountImpl(); - - static native int getCharacterInstanceImpl(String locale); - - static native int getWordInstanceImpl(String locale); - - static native int getLineInstanceImpl(String locale); - - static native int getSentenceInstanceImpl(String locale); - - static native void closeBreakIteratorImpl(int biaddress); - - static native void setTextImpl(int biaddress, String text); - - static native int cloneImpl(int biaddress); - - static native int precedingImpl(int biaddress, int offset); - - static native boolean isBoundaryImpl(int biaddress, int offset); - - static native int nextImpl(int biaddress, int n); - - static native int previousImpl(int biaddress); - - static native int currentImpl(int biaddress); - - static native int firstImpl(int biaddress); - - static native int followingImpl(int biaddress, int offset); - - static native int lastImpl(int biaddress); -} diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/text/NativeCollation.java b/libcore/icu/src/main/java/com/ibm/icu4jni/text/NativeCollation.java deleted file mode 100644 index 2242b696e..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/text/NativeCollation.java +++ /dev/null @@ -1,263 +0,0 @@ -/** -******************************************************************************* -* Copyright (C) 1996-2005, International Business Machines Corporation and * -* others. All Rights Reserved. * -******************************************************************************* -* -* -******************************************************************************* -*/ - -package com.ibm.icu4jni.text; - -/** -* Package static class for declaring all native methods for collation use. -* @author syn wee quek -* @internal ICU 2.4 -*/ - -final class NativeCollation -{ - // collator methods --------------------------------------------- - - public NativeCollation() { - - } - - /** - * Method to create a new C Collator using the default locale rules. - * @return new c collator - * @internal ICU 2.4 - */ - static native int openCollator(); - - /** - * Method to create a new C Collator using the argument locale rules. - * @param locale locale name - * @return new c collator - * @internal ICU 2.4 - */ - static native int openCollator(String locale); - - /** - * Method to create a new C Collator using the argument rules. - * @param rules , set of collation rules - * @param normalizationmode default normalization mode - * @param collationstrength default collation strength - * @return new c collator - * @internal ICU 2.4 - */ - static native int openCollatorFromRules(String rules, - int normalizationmode, - int collationstrength); - - /** - * Close a C collator - * Once closed, a UCollatorOld should not be used. - * @param collatoraddress The UCollatorOld to close - * @internal ICU 2.4 - */ - static native void closeCollator(int collatoraddress); - - /** - * Compare two strings. - * The strings will be compared using the normalization mode and options - * specified in openCollator or openCollatorFromRules - * @param collatoraddress address of the c collator - * @param source The source string. - * @param target The target string. - * @return result of the comparison, Collation.EQUAL, - * Collation.GREATER or Collation.LESS - * @internal ICU 2.4 - */ - static native int compare(int collatoraddress, String source, - String target); - - /** - * Get the normalization mode for this object. - * The normalization mode influences how strings are compared. - * @param collatoraddress - * @return normalization mode; one of the values from Normalization - * @internal ICU 2.4 - */ - static native int getNormalization(int collatoraddress); - - /** - * Set the normalization mode used int this object - * The normalization mode influences how strings are compared. - * @param collatoraddress the address of the C collator - * @param normalizationmode desired normalization mode; one of the values - * from Normalization - * @internal ICU 2.4 - */ - static native void setNormalization(int collatoraddress, - int normalizationmode); - - /** - * Get the collation rules from a UCollator. - * The rules will follow the rule syntax. - * @param collatoraddress the address of the C collator - * @return collation rules. - * @internal ICU 2.4 - */ - static native String getRules(int collatoraddress); - - /** - * Get a sort key for the argument string - * Sort keys may be compared using java.util.Arrays.equals - * @param collatoraddress address of the C collator - * @param source string for key to be generated - * @return sort key - * @internal ICU 2.4 - */ - static native byte[] getSortKey(int collatoraddress, String source); - - /** - * Gets the version information for collation. - * @param collatoraddress address of the C collator - * @return version information - * @internal ICU 2.4 - */ - // private native String getVersion(int collatoraddress); - - /** - * Universal attribute setter. - * @param collatoraddress address of the C collator - * @param type type of attribute to be set - * @param value attribute value - * @exception RuntimeException when error occurs while setting attribute value - * @internal ICU 2.4 - */ - static native void setAttribute(int collatoraddress, int type, int value); - - /** - * Universal attribute getter - * @param collatoraddress address of the C collator - * @param type type of attribute to be set - * @return attribute value - * @exception RuntimeException thrown when error occurs while getting attribute value - * @internal ICU 2.4 - */ - static native int getAttribute(int collatoraddress, int type); - - /** - * Thread safe cloning operation - * @param collatoraddress address of C collator to be cloned - * @return address of the new clone - * @exception RuntimeException thrown when error occurs while cloning - * @internal ICU 2.4 - */ - static native int safeClone(int collatoraddress); - - /** - * Create a CollationElementIterator object that will iterator over the - * elements in a string, using the collation rules defined in this - * RuleBasedCollator - * @param collatoraddress address of C collator - * @param source string to iterate over - * @return address of C collationelementiterator - * @internal ICU 2.4 - */ - static native int getCollationElementIterator(int collatoraddress, - String source); - - /** - * Returns a hash of this collation object - * @param collatoraddress address of C collator - * @return hash of this collation object - * @internal ICU 2.4 - */ - static native int hashCode(int collatoraddress); - - - // collationelementiterator methods ------------------------------------- - - /** - * Close a C collation element iterator. - * @param address of C collation element iterator to close. - * @internal ICU 2.4 - */ - static native void closeElements(int address); - - /** - * Reset the collation elements to their initial state. - * This will move the 'cursor' to the beginning of the text. - * @param address of C collation element iterator to reset. - * @internal ICU 2.4 - */ - static native void reset(int address); - - /** - * Get the ordering priority of the next collation element in the text. - * A single character may contain more than one collation element. - * @param address if C collation elements containing the text. - * @return next collation elements ordering, or NULLORDER if the end of the - * text is reached. - * @internal ICU 2.4 - */ - static native int next(int address); - - /** - * Get the ordering priority of the previous collation element in the text. - * A single character may contain more than one collation element. - * @param address of the C collation element iterator containing the text. - * @return previous collation element ordering, or NULLORDER if the end of - * the text is reached. - * @internal ICU 2.4 - */ - static native int previous(int address); - - /** - * Get the maximum length of any expansion sequences that end with the - * specified comparison order. - * @param address of the C collation element iterator containing the text. - * @param order collation order returned by previous or next. - * @return maximum length of any expansion sequences ending with the - * specified order. - * @internal ICU 2.4 - */ - static native int getMaxExpansion(int address, int order); - - /** - * Set the text containing the collation elements. - * @param address of the C collation element iterator to be set - * @param source text containing the collation elements. - * @internal ICU 2.4 - */ - static native void setText(int address, String source); - - /** - * Get the offset of the current source character. - * This is an offset into the text of the character containing the current - * collation elements. - * @param address of the C collation elements iterator to query. - * @return offset of the current source character. - * @internal ICU 2.4 - */ - static native int getOffset(int address); - - /** - * Set the offset of the current source character. - * This is an offset into the text of the character to be processed. - * @param address of the C collation element iterator to set. - * @param offset The desired character offset. - * @internal ICU 2.4 - */ - static native void setOffset(int address, int offset); - - // BEGIN android-added - static String[] getAvailableLocalesImpl() { - int count = getAvailableLocalesCountImpl(); - String[] result = new String[count]; - - for(int i = 0; i < count; i++) { - result[i] = getAvailableLocalesImpl(i); - } - return result; - } - - private static native String getAvailableLocalesImpl(int i); - - private static native int getAvailableLocalesCountImpl(); - // END android-added -} diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/text/NativeDecimalFormat.java b/libcore/icu/src/main/java/com/ibm/icu4jni/text/NativeDecimalFormat.java deleted file mode 100644 index 39f7307cd..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/text/NativeDecimalFormat.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.ibm.icu4jni.text; - -import java.text.FieldPosition; -import java.text.ParsePosition; - -final class NativeDecimalFormat { - - enum UNumberFormatSymbol { - UNUM_DECIMAL_SEPARATOR_SYMBOL, - UNUM_GROUPING_SEPARATOR_SYMBOL, - UNUM_PATTERN_SEPARATOR_SYMBOL, - UNUM_PERCENT_SYMBOL, - UNUM_ZERO_DIGIT_SYMBOL, - UNUM_DIGIT_SYMBOL, - UNUM_MINUS_SIGN_SYMBOL, - UNUM_PLUS_SIGN_SYMBOL, - UNUM_CURRENCY_SYMBOL, - UNUM_INTL_CURRENCY_SYMBOL, - UNUM_MONETARY_SEPARATOR_SYMBOL, - UNUM_EXPONENTIAL_SYMBOL, - UNUM_PERMILL_SYMBOL, - UNUM_PAD_ESCAPE_SYMBOL, - UNUM_INFINITY_SYMBOL, - UNUM_NAN_SYMBOL, - UNUM_SIGNIFICANT_DIGIT_SYMBOL, - UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL, - UNUM_FORMAT_SYMBOL_COUNT - } - - enum UNumberFormatAttribute { - UNUM_PARSE_INT_ONLY, - UNUM_GROUPING_USED, - UNUM_DECIMAL_ALWAYS_SHOWN, - UNUM_MAX_INTEGER_DIGITS, - UNUM_MIN_INTEGER_DIGITS, - UNUM_INTEGER_DIGITS, - UNUM_MAX_FRACTION_DIGITS, - UNUM_MIN_FRACTION_DIGITS, - UNUM_FRACTION_DIGITS, - UNUM_MULTIPLIER, - UNUM_GROUPING_SIZE, - UNUM_ROUNDING_MODE, - UNUM_ROUNDING_INCREMENT, - UNUM_FORMAT_WIDTH, - UNUM_PADDING_POSITION, - UNUM_SECONDARY_GROUPING_SIZE, - UNUM_SIGNIFICANT_DIGITS_USED, - UNUM_MIN_SIGNIFICANT_DIGITS, - UNUM_MAX_SIGNIFICANT_DIGITS, - UNUM_LENIENT_PARSE - } - - enum UNumberFormatTextAttribute { - UNUM_POSITIVE_PREFIX, - UNUM_POSITIVE_SUFFIX, - UNUM_NEGATIVE_PREFIX, - UNUM_NEGATIVE_SUFFIX, - UNUM_PADDING_CHARACTER, - UNUM_CURRENCY_CODE, - UNUM_DEFAULT_RULESET, - UNUM_PUBLIC_RULESETS - } - - static native int openDecimalFormatImpl(String locale, String pattern); - - static native void closeDecimalFormatImpl(int addr); - - static native int cloneImpl(int addr); - - static native void setSymbol(int addr, int symbol, String str); - - static native String getSymbol(int addr, int symbol); - - static native void setAttribute(int addr, int symbol, int i); - - static native int getAttribute(int addr, int symbol); - - static native void setTextAttribute(int addr, int symbol, String str); - - static native String getTextAttribute(int addr, int symbol); - - static native void applyPatternImpl(int addr, boolean localized, String pattern); - - static native String toPatternImpl(int addr, boolean localized); - - static native String format(int addr, long value, FieldPosition position, String fieldType, StringBuffer attributes); - - static native String format(int addr, double value, FieldPosition position, String fieldType, StringBuffer attributes); - - static native String format(int addr, String value, FieldPosition position, String fieldType, StringBuffer attributes, int scale); - - static native Number parse(int addr, String string, ParsePosition position); -} diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/text/RuleBasedBreakIterator.java b/libcore/icu/src/main/java/com/ibm/icu4jni/text/RuleBasedBreakIterator.java deleted file mode 100644 index 4d38f2be4..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/text/RuleBasedBreakIterator.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.ibm.icu4jni.text; - -import java.text.CharacterIterator; -import java.text.StringCharacterIterator; - -public class RuleBasedBreakIterator extends BreakIterator { - - private CharacterIterator charIter; - - private int addr; - - RuleBasedBreakIterator(int iterAddr, int type) { - this.addr = iterAddr; - this.type = type; - this.charIter = new StringCharacterIterator(""); - } - - @Override - public Object clone() { - int cloneAddr = NativeBreakIterator.cloneImpl(this.addr); - RuleBasedBreakIterator rbbi = - new RuleBasedBreakIterator(cloneAddr, this.type); - - rbbi.charIter = this.charIter; - - return rbbi; - } - - @Override - public boolean equals(Object object) { - if(object == null) { - return false; - } - - if(!(object instanceof RuleBasedBreakIterator)) { - return false; - } - - CharacterIterator iter = ((RuleBasedBreakIterator) object).charIter; - - boolean result = this.type == ((RuleBasedBreakIterator) object).type; - - return result && iter.equals(this.charIter); - } - - @Override - public int current() { - return NativeBreakIterator.currentImpl(this.addr); - } - - @Override - public int first() { - return NativeBreakIterator.firstImpl(this.addr); - } - - @Override - public int following(int offset) { - return NativeBreakIterator.followingImpl(this.addr, offset); - } - - @Override - public CharacterIterator getText() { - int newLoc = NativeBreakIterator.currentImpl(this.addr); - this.charIter.setIndex(newLoc); - return this.charIter; - } - - @Override - public int last() { - return NativeBreakIterator.lastImpl(this.addr); - } - - @Override - public int next(int n) { - return NativeBreakIterator.nextImpl(this.addr, n); - } - - @Override - public int next() { - return NativeBreakIterator.nextImpl(this.addr, 1); - } - - @Override - public int previous() { - return NativeBreakIterator.previousImpl(this.addr); - } - - @Override - public void setText(CharacterIterator newText) { - this.charIter = newText; - - StringBuilder sb = new StringBuilder(); - - char c = newText.first(); - while(c != CharacterIterator.DONE) { - sb.append(c); - c = newText.next(); - } - - NativeBreakIterator.setTextImpl(this.addr, sb.toString()); - } - - protected void finalize() { - NativeBreakIterator.closeBreakIteratorImpl(this.addr); - } - - @Override - public boolean isBoundary(int offset) { - return NativeBreakIterator.isBoundaryImpl(this.addr, offset); - } - - @Override - public int preceding(int offset) { - return NativeBreakIterator.precedingImpl(this.addr, offset); - } - -} diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/text/RuleBasedCollator.java b/libcore/icu/src/main/java/com/ibm/icu4jni/text/RuleBasedCollator.java deleted file mode 100644 index c0aca3baf..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/text/RuleBasedCollator.java +++ /dev/null @@ -1,719 +0,0 @@ -/** -******************************************************************************* -* Copyright (C) 1996-2005, International Business Machines Corporation and * -* others. All Rights Reserved. * -******************************************************************************* -* -* -******************************************************************************* -*/ - -package com.ibm.icu4jni.text; - -import java.util.Locale; -import java.text.CharacterIterator; -import java.text.ParseException; -import com.ibm.icu4jni.common.ErrorCode; - -/** -* Concrete implementation class for Collation. -*

-* The collation table is composed of a list of collation rules, where each -* rule is of three forms: -*

-*    < modifier >
-*    < relation > < text-argument >
-*    < reset > < text-argument >
-* 
-*

-* RuleBasedCollator has the following restrictions for efficiency -* (other subclasses may be used for more complex languages) : -*

    -*
  1. If a French secondary ordering is specified it applies to the whole -* collator object. -*
  2. All non-mentioned Unicode characters are at the end of the collation -* order. -*
  3. If a character is not located in the RuleBasedCollator, the default -* Unicode Collation Algorithm (UCA) rulebased table is automatically -* searched as a backup. -*
-* -* The following demonstrates how to create your own collation rules: -*
    -*
  • Text-Argument: A text-argument is any sequence of -* characters, excluding special characters (that is, common whitespace -* characters [0009-000D, 0020] and rule syntax characters [0021-002F, -* 003A-0040, 005B-0060, 007B-007E]). If those characters are desired, -* you can put them in single quotes (e.g. ampersand => '&'). Note that -* unquoted white space characters are ignored; e.g. b c is -* treated as bc. -*
  • Modifier: There is a single modifier which is used -* to specify that all accents (secondary differences) are backwards. -*

    '@' : Indicates that accents are sorted backwards, as in French. -*

  • Relation: The relations are the following: -*
      -*
    • '<' : Greater, as a letter difference (primary) -*
    • ';' : Greater, as an accent difference (secondary) -*
    • ',' : Greater, as a case difference (tertiary) -*
    • '=' : Equal -*
    -*
  • Reset: There is a single reset which is used -* primarily for contractions and expansions, but which can also be used -* to add a modification at the end of a set of rules. -*

    '&' : Indicates that the next rule follows the position to where -* the reset text-argument would be sorted. -*

-* -*

-* This sounds more complicated than it is in practice. For example, the -* following are equivalent ways of expressing the same thing: -*

-*
-* a < b < c
-* a < b & b < c
-* a < c & a < b
-* 
-*
-* Notice that the order is important, as the subsequent item goes immediately -* after the text-argument. The following are not equivalent: -*
-*
-* a < b & a < c
-* a < c & a < b
-* 
-*
-* Either the text-argument must already be present in the sequence, or some -* initial substring of the text-argument must be present. (e.g. "a < b & ae < -* e" is valid since "a" is present in the sequence before "ae" is reset). In -* this latter case, "ae" is not entered and treated as a single character; -* instead, "e" is sorted as if it were expanded to two characters: "a" -* followed by an "e". This difference appears in natural languages: in -* traditional Spanish "ch" is treated as though it contracts to a single -* character (expressed as "c < ch < d"), while in traditional German a-umlaut -* is treated as though it expanded to two characters (expressed as "a,A < b,B -* ... & ae;? & AE;?"). [? and ? are, of course, the escape sequences for -* a-umlaut.] -*

-* Ignorable Characters -*

-* For ignorable characters, the first rule must start with a relation (the -* examples we have used above are really fragments; "a < b" really should be -* "< a < b"). If, however, the first relation is not "<", then all the all -* text-arguments up to the first "<" are ignorable. For example, ", - < a < b" -* makes "-" an ignorable character, as we saw earlier in the word -* "black-birds". In the samples for different languages, you see that most -* accents are ignorable. -* -*

Normalization and Accents -*

-* RuleBasedCollator automatically processes its rule table to -* include both pre-composed and combining-character versions of accented -* characters. Even if the provided rule string contains only base characters -* and separate combining accent characters, the pre-composed accented -* characters matching all canonical combinations of characters from the rule -* string will be entered in the table. -*

-* This allows you to use a RuleBasedCollator to compare accented strings even -* when the collator is set to NO_DECOMPOSITION. However, if the strings to be -* collated contain combining sequences that may not be in canonical order, you -* should set the collator to CANONICAL_DECOMPOSITION to enable sorting of -* combining sequences. -* For more information, see -* The Unicode Standard, Version 3.0.) -* -*

Errors -*

-* The following are errors: -*

    -*
  • A text-argument contains unquoted punctuation symbols -* (e.g. "a < b-c < d"). -*
  • A relation or reset character not followed by a text-argument -* (e.g. "a < , b"). -*
  • A reset where the text-argument (or an initial substring of the -* text-argument) is not already in the sequence or allocated in the -* default UCA table. -* (e.g. "a < b & e < f") -*
-* If you produce one of these errors, a RuleBasedCollator throws -* a ParseException. -* -*

Examples -*

Simple: "< a < b < c < d" -*

Norwegian: "< a,A< b,B< c,C< d,D< e,E< f,F< g,G< h,H< i,I< j,J -* < k,K< l,L< m,M< n,N< o,O< p,P< q,Q< r,R< s,S< t,T -* < u,U< v,V< w,W< x,X< y,Y< z,Z -* < ?=a?,?=A? -* ;aa,AA< ?,?< ?,?" -* -*

-* Normally, to create a rule-based Collator object, you will use -* Collator's factory method getInstance. -* However, to create a rule-based Collator object with specialized rules -* tailored to your needs, you construct the RuleBasedCollator -* with the rules contained in a String object. For example: -*

-*
-* String Simple = "< a < b < c < d";
-* RuleBasedCollator mySimple = new RuleBasedCollator(Simple);
-* 
-*
-* Or: -*
-*
-* String Norwegian = "< a,A< b,B< c,C< d,D< e,E< f,F< g,G< h,H< i,I< j,J" +
-*                 "< k,K< l,L< m,M< n,N< o,O< p,P< q,Q< r,R< s,S< t,T" +
-*                 "< u,U< v,V< w,W< x,X< y,Y< z,Z" +
-*                 "< ?=a?,?=A?" +
-*                 ";aa,AA< ?,?< ?,?";
-* RuleBasedCollator myNorwegian = new RuleBasedCollator(Norwegian);
-* 
-*
-* -*

-* Combining Collators is as simple as concatenating strings. -* Here's an example that combines two Collators from two -* different locales: -*

-*
-* // Create an en_US Collator object
-* RuleBasedCollator en_USCollator = (RuleBasedCollator)
-*     Collator.getInstance(new Locale("en", "US", ""));
-* // Create a da_DK Collator object
-* RuleBasedCollator da_DKCollator = (RuleBasedCollator)
-*     Collator.getInstance(new Locale("da", "DK", ""));
-* // Combine the two
-* // First, get the collation rules from en_USCollator
-* String en_USRules = en_USCollator.getRules();
-* // Second, get the collation rules from da_DKCollator
-* String da_DKRules = da_DKCollator.getRules();
-* RuleBasedCollator newCollator =
-*     new RuleBasedCollator(en_USRules + da_DKRules);
-* // newCollator has the combined rules
-* 
-*
-* -*

-* Another more interesting example would be to make changes on an existing -* table to create a new Collator object. For example, add -* "& C < ch, cH, Ch, CH" to the en_USCollator object to create -* your own: -*

-*
-* // Create a new Collator object with additional rules
-* String addRules = "& C < ch, cH, Ch, CH";
-* RuleBasedCollator myCollator =
-*     new RuleBasedCollator(en_USCollator + addRules);
-* // myCollator contains the new rules
-* 
-*
-* -*

-* The following example demonstrates how to change the order of -* non-spacing accents, -*

-*
-* // old rule
-* String oldRules = "=?;?;?"    // main accents Diaeresis 00A8, Macron 00AF
-*                               // Acute 00BF
-*                 + "< a , A ; ae, AE ; ? , ?"
-*                 + "< b , B < c, C < e, E & C < d, D";
-* // change the order of accent characters
-* String addOn = "& ?;?;?;"; // Acute 00BF, Macron 00AF, Diaeresis 00A8
-* RuleBasedCollator myCollator = new RuleBasedCollator(oldRules + addOn);
-* 
-*
-* -*

-* The last example shows how to put new primary ordering in before the -* default setting. For example, in Japanese Collator, you -* can either sort English characters before or after Japanese characters, -*

-*
-* // get en_US Collator rules
-* RuleBasedCollator en_USCollator = 
-*                      (RuleBasedCollator)Collator.getInstance(Locale.US);
-* // add a few Japanese character to sort before English characters
-* // suppose the last character before the first base letter 'a' in
-* // the English collation rule is ?
-* String jaString = "& \\u30A2 , \\u30FC < \\u30C8";
-* RuleBasedCollator myJapaneseCollator = new
-*     RuleBasedCollator(en_USCollator.getRules() + jaString);
-* 
-*
-*

-* @author syn wee quek -* @stable ICU 2.4 -*/ - -public final class RuleBasedCollator extends Collator -{ - // public constructors ------------------------------------------ - - /** - * RuleBasedCollator constructor. This takes the table rules and builds a - * collation table out of them. Please see RuleBasedCollator class - * description for more details on the collation rule syntax. - * @param rules the collation rules to build the collation table from. - * @exception ParseException thrown if rules are empty or a Runtime error - * if collator can not be created. - * @stable ICU 2.4 - */ - public RuleBasedCollator(String rules) throws ParseException - { - // BEGIN android-changed - if (rules == null) { - throw new NullPointerException(); - } - // if (rules.length() == 0) - // throw new ParseException("Build rules empty.", 0); - // END android-changed - m_collator_ = NativeCollation.openCollatorFromRules(rules, - CollationAttribute.VALUE_OFF, - CollationAttribute.VALUE_DEFAULT_STRENGTH); - } - - /** - * RuleBasedCollator constructor. This takes the table rules and builds a - * collation table out of them. Please see RuleBasedCollator class - * description for more details on the collation rule syntax. - * @param rules the collation rules to build the collation table from. - * @param strength collation strength - * @exception ParseException thrown if rules are empty or a Runtime error - * if collator can not be created. - * @see #PRIMARY - * @see #SECONDARY - * @see #TERTIARY - * @see #QUATERNARY - * @see #IDENTICAL - * @stable ICU 2.4 - */ - public RuleBasedCollator(String rules, int strength) throws ParseException - { - // BEGIN android-changed - if (rules == null) { - throw new NullPointerException(); - } - // if (rules.length() == 0) - // throw new ParseException("Build rules empty.", 0); - // END android-changed - if (!CollationAttribute.checkStrength(strength)) - throw ErrorCode.getException(ErrorCode.U_ILLEGAL_ARGUMENT_ERROR); - - m_collator_ = NativeCollation.openCollatorFromRules(rules, - CollationAttribute.VALUE_OFF, - strength); - } - - /** - * RuleBasedCollator constructor. This takes the table rules and builds a - * collation table out of them. Please see RuleBasedCollator class - * description for more details on the collation rule syntax. - *

Note API change starting from release 2.4. Prior to release 2.4, the - * normalizationmode argument values are from the class - * com.ibm.icu4jni.text.Normalization. In 2.4, - * the valid normalizationmode arguments for this API are - * CollationAttribute.VALUE_ON and CollationAttribute.VALUE_OFF. - *

- * @param rules the collation rules to build the collation table from. - * @param strength collation strength - * @param normalizationmode normalization mode - * @exception IllegalArgumentException thrown when constructor error occurs - * @see #PRIMARY - * @see #SECONDARY - * @see #TERTIARY - * @see #QUATERNARY - * @see #IDENTICAL - * @see #CANONICAL_DECOMPOSITION - * @see #NO_DECOMPOSITION - * @stable ICU 2.4 - */ - public RuleBasedCollator(String rules, int normalizationmode, int strength) - { - // BEGIN android-added - if (rules == null) { - throw new NullPointerException(); - } - // END android-added - if (!CollationAttribute.checkStrength(strength) || - !CollationAttribute.checkNormalization(normalizationmode)) { - throw ErrorCode.getException(ErrorCode.U_ILLEGAL_ARGUMENT_ERROR); - } - - m_collator_ = NativeCollation.openCollatorFromRules(rules, - normalizationmode, strength); - } - - // public methods ----------------------------------------------- - - /** - * Makes a complete copy of the current object. - * @return a copy of this object if data clone is a success, otherwise null - * @stable ICU 2.4 - */ - public Object clone() - { - RuleBasedCollator result = null; - int collatoraddress = NativeCollation.safeClone(m_collator_); - result = new RuleBasedCollator(collatoraddress); - return (Collator)result; - } - - /** - * The comparison function compares the character data stored in two - * different strings. Returns information about whether a string is less - * than, greater than or equal to another string. - *

Example of use: - *
- * - * Collator myCollation = Collator.createInstance(Locale::US); - * myCollation.setStrength(CollationAttribute.VALUE_PRIMARY); - * // result would be Collator.RESULT_EQUAL ("abc" == "ABC") - * // (no primary difference between "abc" and "ABC") - * int result = myCollation.compare("abc", "ABC",3); - * myCollation.setStrength(CollationAttribute.VALUE_TERTIARY); - * // result would be Collation::LESS (abc" <<< "ABC") - * // (with tertiary difference between "abc" and "ABC") - * int result = myCollation.compare("abc", "ABC",3); - * - * @param source The source string. - * @param target The target string. - * @return result of the comparison, Collator.RESULT_EQUAL, - * Collator.RESULT_GREATER or Collator.RESULT_LESS - * @stable ICU 2.4 - */ - public int compare(String source, String target) - { - return NativeCollation.compare(m_collator_, source, target); - } - - /** - * Get the normalization mode for this object. - * The normalization mode influences how strings are compared. - * @see #CANONICAL_DECOMPOSITION - * @see #NO_DECOMPOSITION - * @stable ICU 2.4 - */ - public int getDecomposition() - { - return NativeCollation.getNormalization(m_collator_); - } - - /** - *

Sets the decomposition mode of the Collator object on or off. - * If the decomposition mode is set to on, string would be decomposed into - * NFD format where necessary before sorting.

- *

- * @param decompositionmode the new decomposition mode - * @see #CANONICAL_DECOMPOSITION - * @see #NO_DECOMPOSITION - * @stable ICU 2.4 - */ - public void setDecomposition(int decompositionmode) - { - if (!CollationAttribute.checkNormalization(decompositionmode)) - throw ErrorCode.getException(ErrorCode.U_ILLEGAL_ARGUMENT_ERROR); - NativeCollation.setAttribute(m_collator_, - CollationAttribute.NORMALIZATION_MODE, - decompositionmode); - } - - /** - * Determines the minimum strength that will be use in comparison or - * transformation. - *

- * E.g. with strength == CollationAttribute.VALUE_SECONDARY, the tertiary difference - * is ignored - *

- *

- * E.g. with strength == PRIMARY, the secondary and tertiary difference are - * ignored. - *

- * @return the current comparison level. - * @see #PRIMARY - * @see #SECONDARY - * @see #TERTIARY - * @see #QUATERNARY - * @see #IDENTICAL - * @stable ICU 2.4 - */ - public int getStrength() - { - return NativeCollation.getAttribute(m_collator_, - CollationAttribute.STRENGTH); - } - - /** - * Sets the minimum strength to be used in comparison or transformation. - *

Example of use: - *
- * - * Collator myCollation = Collator.createInstance(Locale::US); - * myCollation.setStrength(PRIMARY); - * // result will be "abc" == "ABC" - * // tertiary differences will be ignored - * int result = myCollation->compare("abc", "ABC"); - * - * @param strength the new comparison level. - * @exception IllegalArgumentException when argument does not belong to any collation strength - * mode or error occurs while setting data. - * @see #PRIMARY - * @see #SECONDARY - * @see #TERTIARY - * @see #QUATERNARY - * @see #IDENTICAL - * @stable ICU 2.4 - */ - public void setStrength(int strength) - { - if (!CollationAttribute.checkStrength(strength)) - throw ErrorCode.getException(ErrorCode.U_ILLEGAL_ARGUMENT_ERROR); - NativeCollation.setAttribute(m_collator_, CollationAttribute.STRENGTH, - strength); - } - - /** - * Sets the attribute to be used in comparison or transformation. - *

Example of use: - *
- * - * Collator myCollation = Collator.createInstance(Locale::US); - * myCollation.setAttribute(CollationAttribute.CASE_LEVEL, - * CollationAttribute.VALUE_ON); - * int result = myCollation->compare("\\u30C3\\u30CF", - * "\\u30C4\\u30CF"); - * // result will be Collator.RESULT_LESS. - * - * @param type the attribute to be set from CollationAttribute - * @param value attribute value from CollationAttribute - * @stable ICU 2.4 - */ - public void setAttribute(int type, int value) - { - if (!CollationAttribute.checkAttribute(type, value)) - throw ErrorCode.getException(ErrorCode.U_ILLEGAL_ARGUMENT_ERROR); - NativeCollation.setAttribute(m_collator_, type, value); - } - - /** - * Gets the attribute to be used in comparison or transformation. - * @param type the attribute to be set from CollationAttribute - * @return value attribute value from CollationAttribute - * @stable ICU 2.4 - */ - public int getAttribute(int type) - { - if (!CollationAttribute.checkType(type)) - throw ErrorCode.getException(ErrorCode.U_ILLEGAL_ARGUMENT_ERROR); - return NativeCollation.getAttribute(m_collator_, type); - } - - /** - * Get the sort key as an CollationKey object from the argument string. - * To retrieve sort key in terms of byte arrays, use the method as below
- *
- * - * Collator collator = Collator.getInstance(); - * byte[] array = collator.getSortKey(source); - *
- * Byte array result are zero-terminated and can be compared using - * java.util.Arrays.equals(); - * @param source string to be processed. - * @return the sort key - * @stable ICU 2.4 - */ - public CollationKey getCollationKey(String source) - { - // BEGIN android-removed - // return new CollationKey(NativeCollation.getSortKey(m_collator_, source)); - // END android-removed - // BEGIN android-added - if(source == null) { - return null; - } - byte[] key = NativeCollation.getSortKey(m_collator_, source); - if(key == null) { - return null; - } - return new CollationKey(key); - // END android-added - } - - /** - * Get a sort key for the argument string - * Sort keys may be compared using java.util.Arrays.equals - * @param source string for key to be generated - * @return sort key - * @stable ICU 2.4 - */ - public byte[] getSortKey(String source) - { - return NativeCollation.getSortKey(m_collator_, source); - } - - /** - * Get the collation rules of this Collation object - * The rules will follow the rule syntax. - * @return collation rules. - * @stable ICU 2.4 - */ - public String getRules() - { - return NativeCollation.getRules(m_collator_); - } - - /** - * Create a CollationElementIterator object that will iterator over the - * elements in a string, using the collation rules defined in this - * RuleBasedCollator - * @param source string to iterate over - * @return address of C collationelement - * @exception IllegalArgumentException thrown when error occurs - * @stable ICU 2.4 - */ - public CollationElementIterator getCollationElementIterator(String source) - { - CollationElementIterator result = new CollationElementIterator( - NativeCollation.getCollationElementIterator(m_collator_, source)); - // result.setOwnCollationElementIterator(true); - return result; - } - - // BEGIN android-added - /** - * Create a CollationElementIterator object that will iterator over the - * elements in a string, using the collation rules defined in this - * RuleBasedCollator - * @param source string to iterate over - * @return address of C collationelement - * @exception IllegalArgumentException thrown when error occurs - * @stable ICU 2.4 - */ - public CollationElementIterator getCollationElementIterator( - CharacterIterator source) - { - CollationElementIterator result = new CollationElementIterator( - NativeCollation.getCollationElementIterator(m_collator_, - source.toString())); - // result.setOwnCollationElementIterator(true); - return result; - } - // END android-added - - /** - * Returns a hash of this collation object - * Note this method is not complete, it only returns 0 at the moment. - * @return hash of this collation object - * @stable ICU 2.4 - */ - public int hashCode() - { - // since rules do not change once it is created, we can cache the hash - if (m_hashcode_ == 0) { - m_hashcode_ = NativeCollation.hashCode(m_collator_); - if (m_hashcode_ == 0) - m_hashcode_ = 1; - } - return m_hashcode_; - } - - /** - * Checks if argument object is equals to this object. - * @param target object - * @return true if source is equivalent to target, false otherwise - * @stable ICU 2.4 - */ - public boolean equals(Object target) - { - if (this == target) - return true; - if (target == null) - return false; - if (getClass() != target.getClass()) - return false; - - RuleBasedCollator tgtcoll = (RuleBasedCollator)target; - return getRules().equals(tgtcoll.getRules()) && - getStrength() == tgtcoll.getStrength() && - getDecomposition() == tgtcoll.getDecomposition(); - } - - // package constructor ---------------------------------------- - - /** - * RuleBasedCollator default constructor. This constructor takes the default - * locale. The only caller of this class should be Collator.getInstance(). - * Current implementation createInstance() returns a RuleBasedCollator(Locale) - * instance. The RuleBasedCollator will be created in the following order, - *

    - *
  • Data from argument locale resource bundle if found, otherwise - *
  • Data from parent locale resource bundle of arguemtn locale if found, - * otherwise - *
  • Data from built-in default collation rules if found, other - *
  • null is returned - *
- */ - RuleBasedCollator() - { - m_collator_ = NativeCollation.openCollator(); - } - - /** - * RuleBasedCollator constructor. This constructor takes a locale. The - * only caller of this class should be Collator.createInstance(). - * Current implementation createInstance() returns a RuleBasedCollator(Locale) - * instance. The RuleBasedCollator will be created in the following order, - *
    - *
  • Data from argument locale resource bundle if found, otherwise - *
  • Data from parent locale resource bundle of arguemtn locale if found, - * otherwise - *
  • Data from built-in default collation rules if found, other - *
  • null is returned - *
- * @param locale locale used - */ - RuleBasedCollator(Locale locale) - { - if (locale == null) { - m_collator_ = NativeCollation.openCollator(); - } - else { - m_collator_ = NativeCollation.openCollator(locale.toString()); - } - } - - // protected methods -------------------------------------------- - - /** - * Garbage collection. - * Close C collator and reclaim memory. - */ - protected void finalize() - { - NativeCollation.closeCollator(m_collator_); - } - - // private data members ----------------------------------------- - - /** - * C collator - */ - private int m_collator_; - - /** - * Hash code for rules - */ - private int m_hashcode_ = 0; - - // private constructor ----------------------------------------- - - /** - * Private use constructor. - * Does not create any instance of the C collator. Accepts argument as the - * C collator for new instance. - * @param collatoraddress address of C collator - */ - private RuleBasedCollator(int collatoraddress) - { - m_collator_ = collatoraddress; - } -} diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/text/RuleBasedNumberFormat.java b/libcore/icu/src/main/java/com/ibm/icu4jni/text/RuleBasedNumberFormat.java deleted file mode 100644 index 3c865d8df..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/text/RuleBasedNumberFormat.java +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.ibm.icu4jni.text; - -import java.text.FieldPosition; -import java.text.Format; -import java.text.NumberFormat; -import java.text.ParsePosition; -import java.util.Locale; - -public class RuleBasedNumberFormat extends NumberFormat { - - /** - * Enum of predefined RBNF types. - */ - public enum RBNFType { - /** - * This creates a spellout instance of RBNF. - * It formats numbers into textual representation: - * 15 -> 'fifteen' or 15.15 -> 'fifteen point one five' - * and it can parse words into numbers: 'twenty' -> 20 - */ - SPELLOUT(0), - /** - * This creates an ordinal instance of RBNF. - * It formats numbers into an ordinal text representation: - * 15 -> '15th' and by parsing it also works in the other direction. - */ - ORDINAL(1), - /** - * This creates instance of RBNF that allows to format numbers into time - * values: 15 -> '15 sec.' and by parsing it also works in the other - * direction. - */ - DURATION(2); - - int type; - - RBNFType(int t) { - type = t; - } - - int getType() { - return type; - } - } - - @Override - protected void finalize(){ - close(); - } - - private int addr = 0; - - /** - * Open a new rule based number format of selected type for the - * default location - * - * @param type the type of rule based number format - */ - public void open(RBNFType type) { - this.addr = openRBNFImpl(type.getType(), - Locale.getDefault().toString()); - } - - /** - * Open a new rule based number format of selected type for the - * given location - * - * @param type the type of rule based number format - * @param locale the locale to use for this rule based number format - */ - public void open(RBNFType type, Locale locale) { - String loc = locale.toString(); - if (loc == null) { - throw new NullPointerException(); - } - this.addr = openRBNFImpl(type.getType(), loc); - } - - private static native int openRBNFImpl(int type, String loc); - - /** - * Open a new rule based number format for the - * default location. The rule passed to the method has to be of the form - * described in the ibm icu documentation for RuleBasedNumberFormat. - * - * @param rule the rule for the rule based number format - */ - public void open(String rule) { - if (rule == null) { - throw new NullPointerException(); - } - this.addr = openRBNFImpl(rule, Locale.getDefault().toString()); - } - - /** - * Open a new rule based number format for the - * given location. The rule passed to the method has to be of the form - * described in the ibm icu documentation for RuleBasedNumberFormat. - * - * @param rule the rule for the rule based number format - * @param locale the locale to use for this rule based number format - */ - public void open(String rule, Locale locale) { - String loc = locale.toString(); - if (loc == null || rule == null) { - throw new NullPointerException(); - } - this.addr = openRBNFImpl(rule, locale.toString()); - } - - private static native int openRBNFImpl(String rule, String loc); - - /** - * close a RuleBasedNumberFormat - */ - public void close() { - if(this.addr != 0) { - closeRBNFImpl(this.addr); - this.addr = 0; - } - } - - private static native void closeRBNFImpl(int addr); - - @Override - public StringBuffer format(long value, StringBuffer buffer, FieldPosition field) { - - if(buffer == null) { - throw new NullPointerException(); - } - - String fieldType = null; - - if(field != null) { - fieldType = getFieldType(field.getFieldAttribute()); - } - - String result = formatRBNFImpl(this.addr, value, field, - fieldType, null); - - buffer.append(result.toCharArray(), 0, result.length()); - - return buffer; - } - - private static native String formatRBNFImpl(int addr, long value, - FieldPosition field, String fieldType, StringBuffer buffer); - - @Override - public StringBuffer format(double value, StringBuffer buffer, FieldPosition field) { - - if(buffer == null) { - throw new NullPointerException(); - } - - String fieldType = null; - - if(field != null) { - fieldType = getFieldType(field.getFieldAttribute()); - } - - String result = formatRBNFImpl(this.addr, value, field, - fieldType, null); - - buffer.append(result.toCharArray(), 0, result.length()); - - return buffer; - } - - private static native String formatRBNFImpl(int addr, double value, - FieldPosition field, String fieldType, StringBuffer buffer); - - @Override - public Number parse(String string, ParsePosition position) { - if (string == null || position == null) { - throw new NullPointerException(); - } - return parseRBNFImpl(this.addr, string, position, false); - } - - /** - * This method has the same functionality - * as {@link #parse(String, ParsePosition)} - * But it uses lenient parsing. This means it also accepts strings that - * differ from the correct writing (e.g. case or umlaut differences). - * - * @param string the string to parse - * @param position the ParsePosition, updated on return with the index - * following the parsed text, or on error the index is unchanged and - * the error index is set to the index where the error occurred - * @return the Number resulting from the parse, or null if there is an error - */ - public Number parseLenient(String string, ParsePosition position) { - if (string == null || position == null) { - throw new NullPointerException(); - } - return parseRBNFImpl(this.addr, string, position, true); - } - - static native Number parseRBNFImpl(int addr, String string, ParsePosition position, boolean lenient); - - - static private String getFieldType(Format.Field field) { - if(field == null) { - return null; - } - if(field.equals(NumberFormat.Field.SIGN)) { - return "sign"; - } - if(field.equals(NumberFormat.Field.INTEGER)) { - return "integer"; - } - if(field.equals(NumberFormat.Field.FRACTION)) { - return "fraction"; - } - if(field.equals(NumberFormat.Field.EXPONENT)) { - return "exponent"; - } - if(field.equals(NumberFormat.Field.EXPONENT_SIGN)) { - return "exponent_sign"; - } - if(field.equals(NumberFormat.Field.EXPONENT_SYMBOL)) { - return "exponent_symbol"; - } - if(field.equals(NumberFormat.Field.CURRENCY)) { - return "currency"; - } - if(field.equals(NumberFormat.Field.GROUPING_SEPARATOR)) { - return "grouping_separator"; - } - if(field.equals(NumberFormat.Field.DECIMAL_SEPARATOR)) { - return "decimal_separator"; - } - if(field.equals(NumberFormat.Field.PERCENT)) { - return "percent"; - } - if(field.equals(NumberFormat.Field.PERMILLE)) { - return "permille"; - } - return null; - } -} diff --git a/libcore/icu/src/main/java/com/ibm/icu4jni/util/Resources.java b/libcore/icu/src/main/java/com/ibm/icu4jni/util/Resources.java deleted file mode 100644 index 0460fdef6..000000000 --- a/libcore/icu/src/main/java/com/ibm/icu4jni/util/Resources.java +++ /dev/null @@ -1,535 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.ibm.icu4jni.util; - -import java.util.Enumeration; -import java.util.ListResourceBundle; -import java.util.MissingResourceException; -import java.util.ResourceBundle; -import java.util.TimeZone; -import java.util.logging.Logger; - -/** - * Helper class that delivers ResourceBundle instances expected by Harmony, but - * with the data taken from ICU's database. This approach has a couple of - * advantages: - *
    - *
  1. We have less classes in the overall system, since we use different - * instances for different ResourceBundles. - *
  2. We don't have these classes that consists of monstrous static arrays - * with anymore. - *
  3. We have control over which values we load at which time or even cache - * for later use. - *
  4. There is only one central place left in the system where I18N data needs - * to be configured, namely ICU. - *
- * Since we're mimicking the original Harmony ResourceBundle structures, most of - * the Harmony code can stay the same. We basically just need to change the - * ResourceBundle instantiation. Only the special case of the Locale bundles - * needs some more tweaking, since we don't want to keep several hundred - * timezone names in memory. - */ -public class Resources { - - /** - * Cache for ISO language names. - */ - private static String[] isoLanguages = null; - - /** - * Cache for ISO country names. - */ - private static String[] isoCountries = null; - - /** - * Available locales cache. - */ - private static String[] availableLocales = null; - - /** - * Available timezones cache. - */ - private static String[] availableTimezones = null; - - /** - * Creates ResourceBundle instance and fills it with ICU data. - * - * @param bundleName The name of the requested Harmony resource bundle, - * excluding the package name. - * @param locale The locale to use for the resources. A null value denotes - * the default locale as configured in Java. - * @return The new ResourceBundle, or null, if no ResourceBundle was - * created. - */ - public static ResourceBundle getInstance(String bundleName, String locale) { - if (locale == null) { - locale = java.util.Locale.getDefault().toString(); - } - - if (bundleName.startsWith("Locale")) { - return new Locale(locale); - } else if (bundleName.startsWith("Country")) { - return new Country(locale); - } else if (bundleName.startsWith("Currency")) { - return new Currency(locale); - } else if (bundleName.startsWith("Language")) { - return new Language(locale); - } else if (bundleName.startsWith("Variant")) { - return new Variant(locale); - } else if (bundleName.equals("ISO3Countries")) { - return new ISO3Countries(); - } else if (bundleName.equals("ISO3Languages")) { - return new ISO3Languages(); - } else if (bundleName.equals("ISO4CurrenciesToDigits")) { - return new ISO4CurrenciesToDigits(); - } else if (bundleName.equals("ISO4Currencies")) { - return new ISO4Currencies(); - } - - return null; - } - - /** - * Returns an array of ISO language names (two-letter codes), fetched either - * from ICU's database or from our memory cache. - * - * @return The array. - */ - public static String[] getISOLanguages() { - if (isoLanguages == null) { - isoLanguages = getISOLanguagesNative(); - } - - return isoLanguages; - } - - /** - * Returns an array of ISO country names (two-letter codes), fetched either - * from ICU's database or from our memory cache. - * - * @return The array. - */ - public static String[] getISOCountries() { - if (isoCountries == null) { - isoCountries = getISOCountriesNative(); - } - - return isoCountries; - } - - /** - * Returns an array of names of locales that are available in the system, - * fetched either from ICU's database or from our memory cache. - * - * @return The array. - */ - public static String[] getAvailableLocales() { - if (availableLocales == null) { - availableLocales = getAvailableLocalesNative(); - } - - return availableLocales; - } - - /** - * Returns an array of names of timezones that are available in the system, - * fetched either from the TimeZone class or from our memory cache. - * - * @return The array. - */ - public static String[] getKnownTimezones() { - // TODO Drop the Linux ZoneInfo stuff in favor of ICU. - if (availableTimezones == null) { - availableTimezones = TimeZone.getAvailableIDs(); - } - - return availableTimezones; - } - - /** - * Returns the display name for the given time zone using the given locale. - * - * @param id The time zone ID, for example "Europe/Berlin" - * @param isDST Indicates whether daylight savings is in use - * @param style The style, 0 for long, 1 for short - * @param locale The locale name, for example "en_US". - * @return The desired display name - */ - public static String getDisplayTimeZone(String id, boolean isDST, int style, String locale) { - return getDisplayTimeZoneNative(id, isDST, style, locale); - } - - /** - * Gets the name of the default locale. - */ - private static String getDefaultLocaleName() { - return java.util.Locale.getDefault().toString(); - } - - /** - * Initialization holder for default time zone names. This class will - * be preloaded by the zygote to share the time and space costs of setting - * up the list of time zone names, so although it looks like the lazy - * initialization idiom, it's actually the opposite. - */ - private static class DefaultTimeZones { - /** - * Name of default locale at the time this class was initialized. - */ - private static final String locale = getDefaultLocaleName(); - - /** - * Names of time zones for the default locale. - */ - private static final String[][] names = createTimeZoneNamesFor(locale); - } - - /** - * Creates array of time zone names for the given locale. This method takes - * about 2s to run on a 400MHz ARM11. - */ - private static String[][] createTimeZoneNamesFor(String locale) { - long start = System.currentTimeMillis(); - - /* - * The following code is optimized for fast native response (the time a - * method call can be in native code is limited). It prepares an empty - * array to keep native code from having to create new Java objects. It - * also fill in the time zone IDs to speed things up a bit. There's one - * array for each time zone name type. (standard/long, standard/short, - * daylight/long, daylight/short) The native method that fetches these - * strings is faster if it can do all entries of one type, before having - * to change to the next type. That's why the array passed down to - * native has 5 entries, each providing space for all time zone names of - * one type. Likely this access to the fields is much faster in the - * native code because there's less array access overhead. - */ - String[][] arrayToFill = new String[5][]; - arrayToFill[0] = getKnownTimezones(); - arrayToFill[1] = new String[availableTimezones.length]; - arrayToFill[2] = new String[availableTimezones.length]; - arrayToFill[3] = new String[availableTimezones.length]; - arrayToFill[4] = new String[availableTimezones.length]; - - /* - * Fill in the zone names in native. - */ - getTimeZonesNative(arrayToFill, locale); - - /* - * Finally we need to reorder the entries so we get the expected result. - */ - String[][] result = new String[availableTimezones.length][5]; - for (int i = 0; i < availableTimezones.length; i++) { - result[i][0] = arrayToFill[0][i]; - result[i][1] = arrayToFill[1][i]; - result[i][2] = arrayToFill[2][i]; - result[i][3] = arrayToFill[3][i]; - result[i][4] = arrayToFill[4][i]; - } - - Logger.getLogger(Resources.class.getSimpleName()).info( - "Loaded time zone names for " + locale + " in " - + (System.currentTimeMillis() - start) + "ms."); - - return result; - } - - /** - * Returns the display names for all given timezones using the given locale. - * - * @return An array of time zone strings. Each row represents one time zone. - * The first columns holds the ID of the time zone, for example - * "Europe/Berlin". The other columns then hold for each row the - * four time zone names with and without daylight savings and in - * long and short format. It's exactly the array layout required by - * the TomeZone class. - */ - public static String[][] getDisplayTimeZones(String locale) { - String defaultLocale = getDefaultLocaleName(); - if (locale == null) { - locale = defaultLocale; - } - - // If locale == default and the default locale hasn't changed since - // DefaultTimeZones loaded, return the cached names. - // TODO: We should force a reboot if the default locale changes. - if (defaultLocale.equals(locale) && DefaultTimeZones.locale.equals(defaultLocale)) { - return DefaultTimeZones.names; - } - - return createTimeZoneNamesFor(locale); - } - - // --- Specialized ResourceBundle subclasses ------------------------------ - - /** - * Internal ResourceBundle mimicking the Harmony "ISO3Countries" bundle. - * Keys are the two-letter ISO country codes. Values are the three-letter - * ISO country abbreviations. An example entry is "US"->"USA". - */ - private static final class ISO3Countries extends ResourceBundle { - - @Override - public Enumeration getKeys() { - // Won't get used - throw new UnsupportedOperationException(); - } - - @Override - protected Object handleGetObject(String key) { - return getISO3CountryNative(key); - } - - } - - /** - * Internal ResourceBundle mimicking the Harmony "ISO3Languages" bundle. - * Keys are the two-letter ISO language codes. Values are the three-letter - * ISO language abbreviations. An example entry is "EN"->"ENG". - */ - private static final class ISO3Languages extends ResourceBundle { - - @Override - public Enumeration getKeys() { - // Won't get used - throw new UnsupportedOperationException(); - } - - @Override - protected Object handleGetObject(String key) { - return getISO3LanguageNative(key); - } - - } - - /** - * Internal ResourceBundle mimicking the Harmony "ISO4Currencies" bundle. - * Keys are the two-letter ISO language codes. Values are the three-letter - * ISO currency abbreviations. An example entry is "US"->"USD". - */ - private static final class ISO4Currencies extends ResourceBundle { - - @Override - public Enumeration getKeys() { - // Won't get used - throw new UnsupportedOperationException(); - } - - @Override - protected Object handleGetObject(String key) { - return getCurrencyCodeNative(key); - } - - } - - /** - * Internal ResourceBundle mimicking the Harmony "ISO4CurrenciesToDigits" - * bundle. Keys are the three-letter ISO currency codes. Values are strings - * containing the number of fraction digits to use for the currency. An - * example entry is "USD"->"2". - */ - private static final class ISO4CurrenciesToDigits extends ResourceBundle { - - @Override - public Enumeration getKeys() { - // Won't get used - throw new UnsupportedOperationException(); - } - - @Override - protected Object handleGetObject(String key) { - // In some places the triple-x code is used as the fall back - // currency. The harmony package returned -1 for this requested - // currency. - if ("XXX".equals(key)) { - return "-1"; - } - int res = getFractionDigitsNative(key); - if(res < 0) { - throw new MissingResourceException("couldn't find resource.", - ISO4CurrenciesToDigits.class.getName(), key); - } - return "" + res; - } - - } - - /** - * Internal ResourceBundle mimicking the Harmony "Country_*" bundles. Keys - * are the two-letter ISO country codes. Values are the printable country - * names in terms of the specified locale. An example entry is "US"->"United - * States". - */ - private static final class Country extends ResourceBundle { - private String locale; - - public Country(String locale) { - super(); - this.locale = locale; - } - - @Override - public Enumeration getKeys() { - // Won't get used - throw new UnsupportedOperationException(); - } - - @Override - protected Object handleGetObject(String key) { - return getDisplayCountryNative(key, locale); - } - - } - - /** - * Internal ResourceBundle mimicking the Harmony "Currency_*" bundles. Keys - * are the three-letter ISO currency codes. Values are the printable - * currency names in terms of the specified locale. An example entry is - * "USD"->"$" (for inside the US) and "USD->"US$" (for outside the US). - */ - private static final class Currency extends ResourceBundle { - - private String locale; - - public Currency(String locale) { - super(); - this.locale = locale; - } - - @Override - public Enumeration getKeys() { - // Won't get used - throw new UnsupportedOperationException(); - } - - @Override - protected Object handleGetObject(String key) { - return getCurrencySymbolNative(locale, key); - } - - } - - /** - * Internal ResourceBundle mimicking the Harmony "Language_*" bundles. Keys - * are the two-letter ISO language codes. Values are the printable language - * names in terms of the specified locale. An example entry is - * "en"->"English". - */ - private static final class Language extends ResourceBundle { - private String locale; - - public Language(String locale) { - super(); - this.locale = locale; - } - - @Override - public Enumeration getKeys() { - // Won't get used - throw new UnsupportedOperationException(); - } - - @Override - protected Object handleGetObject(String key) { - return getDisplayLanguageNative(key, locale); - } - - } - - /** - * Internal ResourceBundle mimicking the Harmony "Variant_*" bundles. Keys - * are a fixed set of variants codes known to Harmony. Values are the - * printable variant names in terms of the specified locale. An example - * entry is "EURO"->"Euro". - */ - private static final class Variant extends ResourceBundle { - - private String locale; - - public Variant(String locale) { - super(); - this.locale = locale; - } - - @Override - public Enumeration getKeys() { - // Won't get used - throw new UnsupportedOperationException(); - } - - @Override - protected Object handleGetObject(String key) { - return getDisplayVariantNative(key, locale); - } - - } - - /** - * Internal ResourceBundle mimicking the Harmony "Locale_*" bundles. This is - * clearly the most complex case, because the content covers a wide range of - * data items, with values even being arrays in some cases. Note we are - * cheating with the "timezones" entry, since we normally don't want to - * waste our precious RAM on several thousand of these Strings. - */ - private static final class Locale extends ListResourceBundle { - - private String locale; - - public Locale(String locale) { - super(); - this.locale = locale; - } - - @Override - protected Object[][] getContents() { - return getContentImpl(locale, false); - } - - } - - // --- Native methods accessing ICU's database ---------------------------- - - private static native int getFractionDigitsNative(String currencyCode); - - private static native String getCurrencyCodeNative(String locale); - - private static native String getCurrencySymbolNative(String locale, String currencyCode); - - private static native String getDisplayCountryNative(String countryCode, String locale); - - private static native String getDisplayLanguageNative(String languageCode, String locale); - - private static native String getDisplayVariantNative(String variantCode, String locale); - - private static native String getISO3CountryNative(String locale); - - private static native String getISO3LanguageNative(String locale); - - private static native String[] getAvailableLocalesNative(); - - private static native String[] getISOLanguagesNative(); - - private static native String[] getISOCountriesNative(); - - private static native void getTimeZonesNative(String[][] arrayToFill, String locale); - - private static native String getDisplayTimeZoneNative(String id, boolean isDST, int style, - String locale); - - private static native Object[][] getContentImpl(String locale, boolean needsTimeZones); -} diff --git a/libcore/icu/src/main/native/BidiWrapperInterface.c b/libcore/icu/src/main/native/BidiWrapperInterface.c deleted file mode 100644 index 2c6b3cd91..000000000 --- a/libcore/icu/src/main/native/BidiWrapperInterface.c +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "BidiWrapperInterface.h" - -typedef struct { - UBiDi *pBiDi; - void *embeddingLevels; -} BiDiData; - -void check_fail (JNIEnv * env, int err); - -JNIEXPORT jlong JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1open - (JNIEnv * env, jclass clazz) -{ - BiDiData *data = (BiDiData *)malloc(sizeof(BiDiData)); - (*data).pBiDi = ubidi_open (); - (*data).embeddingLevels = NULL; - return (jlong) (data); -} - -JNIEXPORT void JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1close - (JNIEnv * env, jclass clazz, jlong pBiDi) -{ - BiDiData *data = (BiDiData *)pBiDi; - - ubidi_close ((*data).pBiDi); - - if ((*data).embeddingLevels != NULL) - free((*data).embeddingLevels); - free(data); -} - -JNIEXPORT void JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1setPara - (JNIEnv * env, jclass clazz, jlong pBiDi, jcharArray text, jint length, - jbyte paraLevel, jbyteArray embeddingLevels) -{ - UErrorCode err = 0; - jchar *_text = NULL; - BiDiData *data = (BiDiData *)pBiDi; - /* Remembering old embedding levels */ - void *embLvls = (*data).embeddingLevels; - - _text = (*env)->GetCharArrayElements (env, text, NULL); - - if (embeddingLevels != NULL) - { - jbyte *el = (*env)->GetByteArrayElements (env, embeddingLevels, NULL); - (*data).embeddingLevels = malloc(length); - memcpy(((*data).embeddingLevels), el, length); - (*env)->ReleaseByteArrayElements (env, embeddingLevels, el, 0); - } else - { - (*data).embeddingLevels = NULL; - } - - ubidi_setPara ((*data).pBiDi, _text, length, paraLevel, - ((*data).embeddingLevels), &err); - check_fail (env, err); - - /* Freeing old embedding levels */ - if (embLvls != NULL) { - free(embLvls); - } - - (*env)->ReleaseCharArrayElements (env, text, _text, 0); -} - -JNIEXPORT jlong JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1setLine - (JNIEnv * env, jclass clazz, jlong pBiDi, jint start, jint limit) -{ - UErrorCode err = 0; - BiDiData *data = (BiDiData *)pBiDi; - BiDiData *lineData = (BiDiData *) malloc(sizeof(BiDiData)); - (*lineData).embeddingLevels = NULL; - - (*lineData).pBiDi = ubidi_openSized (limit - start, 0, &err); - check_fail (env, err); - - ubidi_setLine ((*data).pBiDi, start, limit, (*lineData).pBiDi, - &err); - check_fail (env, err); - - return (jlong) lineData; -} - -JNIEXPORT jint JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1getDirection - (JNIEnv * env, jclass clazz, jlong pBiDi) -{ - BiDiData *data = (BiDiData *)pBiDi; - return ubidi_getDirection ((*data).pBiDi); -} - -JNIEXPORT jint JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1getLength - (JNIEnv * env, jclass clazz, jlong pBiDi) -{ - BiDiData *data = (BiDiData *)pBiDi; - return ubidi_getLength ((*data).pBiDi); -} - -JNIEXPORT jbyte JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1getParaLevel - (JNIEnv * env, jclass clazz, jlong pBiDi) -{ - BiDiData *data = (BiDiData *)pBiDi; - return ubidi_getParaLevel ((*data).pBiDi); -} - -JNIEXPORT jbyteArray JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1getLevels - (JNIEnv * env, jclass clazz, jlong pBiDi) -{ - UErrorCode err = 0; - const UBiDiLevel *levels = NULL; - jbyteArray result = NULL; - int len = 0; - BiDiData *data = (BiDiData *)pBiDi; - - levels = ubidi_getLevels ((*data).pBiDi, &err); - check_fail (env, err); - - len = ubidi_getLength ((*data).pBiDi); - result = (*env)->NewByteArray (env, len); - (*env)->SetByteArrayRegion (env, result, 0, len, (jbyte *) levels); - - return result; -} - -JNIEXPORT jint JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1countRuns - (JNIEnv * env, jclass clazz, jlong pBiDi) -{ - UErrorCode err = 0; - BiDiData *data = (BiDiData *)pBiDi; - - int count = ubidi_countRuns ((*data).pBiDi, &err); - check_fail (env, err); - - return count; -} - -JNIEXPORT jobjectArray JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1getRuns - (JNIEnv * env, jclass clz, jlong pBiDi) -{ - int runCount = 0; - int start = 0; - int limit = 0; - int i = 0; - UBiDiLevel level = 0; - jclass run_clazz = 0; - jmethodID initID = 0; - jobject run = 0; - jobjectArray runs; - UErrorCode err = 0; - BiDiData *data = (BiDiData *)pBiDi; - - run_clazz = (*env)->FindClass (env, "org/apache/harmony/text/BidiRun"); - initID = (*env)->GetMethodID (env, run_clazz, "", "(III)V"); - - runCount = ubidi_countRuns ((*data).pBiDi, &err); - check_fail (env, err); - - runs = (*env)->NewObjectArray(env, runCount,run_clazz, NULL); - for (i = 0; i < runCount; i++) { - ubidi_getLogicalRun((*data).pBiDi, start, &limit, &level); - run = (*env)->NewObject (env, run_clazz, initID, start, limit, level); - (*env)->SetObjectArrayElement(env, runs, i, run); - start = limit; - } - return runs; -} - -void -check_fail (JNIEnv * env, int err) -{ - char message[] = "ICU Internal Error: "; - - if (U_FAILURE (err)) - { - sprintf (message, "ICU Internal Error: %d", err); - jniThrowException(env, "java/lang/RuntimeException", - message); - } -} - -JNIEXPORT jintArray JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1reorderVisual - (JNIEnv * env, jclass clazz, jbyteArray levels, jint length) -{ - UBiDiLevel *local_levels = 0; - int *local_indexMap = 0; - jintArray result = 0; - - local_indexMap = (int *) malloc(sizeof (int) * length); - local_levels = (*env)->GetByteArrayElements (env, levels, NULL); - - ubidi_reorderVisual (local_levels, length, local_indexMap); - - result = (*env)->NewIntArray (env, length); - (*env)->SetIntArrayRegion (env, result, 0, length, (jint *) local_indexMap); - - free(local_indexMap); - (*env)->ReleaseByteArrayElements (env, levels, local_levels, 0); - - return result; -} - -/* - * JNI registration - */ -static JNINativeMethod gMethods[] = { - /* NAME , SIGNATURE , FUNCPTR */ - { "ubidi_open" , "()J" , - Java_org_apache_harmony_text_BidiWrapper_ubidi_1open }, - { "ubidi_close" , "(J)V" , - Java_org_apache_harmony_text_BidiWrapper_ubidi_1close }, - { "ubidi_setPara" , "(J[CIB[B)V" , - Java_org_apache_harmony_text_BidiWrapper_ubidi_1setPara }, - { "ubidi_setLine" , "(JII)J" , - Java_org_apache_harmony_text_BidiWrapper_ubidi_1setLine }, - { "ubidi_getDirection" , "(J)I" , - Java_org_apache_harmony_text_BidiWrapper_ubidi_1getDirection }, - { "ubidi_getLength" , "(J)I" , - Java_org_apache_harmony_text_BidiWrapper_ubidi_1getLength }, - { "ubidi_getParaLevel" , "(J)B" , - Java_org_apache_harmony_text_BidiWrapper_ubidi_1getParaLevel }, - { "ubidi_getLevels" , "(J)[B" , - Java_org_apache_harmony_text_BidiWrapper_ubidi_1getLevels }, - { "ubidi_countRuns" , "(J)I" , - Java_org_apache_harmony_text_BidiWrapper_ubidi_1countRuns }, - { "ubidi_getRuns" , "(J)[Lorg/apache/harmony/text/BidiRun;", - Java_org_apache_harmony_text_BidiWrapper_ubidi_1getRuns }, - { "ubidi_reorderVisual", "([BI)[I" , - Java_org_apache_harmony_text_BidiWrapper_ubidi_1reorderVisual }, -}; -int register_org_apache_harmony_text_BidiWrapper(JNIEnv *env) -{ - return jniRegisterNativeMethods(env, "org/apache/harmony/text/BidiWrapper", - gMethods, NELEM(gMethods)); -} diff --git a/libcore/icu/src/main/native/BidiWrapperInterface.h b/libcore/icu/src/main/native/BidiWrapperInterface.h deleted file mode 100644 index c73597eb7..000000000 --- a/libcore/icu/src/main/native/BidiWrapperInterface.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -/* Header for class org_apache_harmony_text_BidiWrapper */ - -#if !defined(_Included_org_apache_harmony_text_BidiWrapper) -#define _Included_org_apache_harmony_text_BidiWrapper -#if defined(__cplusplus) -extern "C" -{ -#endif -#undef org_apache_harmony_text_BidiWrapper_UBIDI_DEFAULT_LTR -#define org_apache_harmony_text_BidiWrapper_UBIDI_DEFAULT_LTR 254L -#undef org_apache_harmony_text_BidiWrapper_UBIDI_DEFAULT_RTL -#define org_apache_harmony_text_BidiWrapper_UBIDI_DEFAULT_RTL 255L -#undef org_apache_harmony_text_BidiWrapper_UBIDI_MAX_EXPLICIT_LEVEL -#define org_apache_harmony_text_BidiWrapper_UBIDI_MAX_EXPLICIT_LEVEL 61L -#undef org_apache_harmony_text_BidiWrapper_UBIDI_LEVEL_OVERRIDE -#define org_apache_harmony_text_BidiWrapper_UBIDI_LEVEL_OVERRIDE 128L -#undef org_apache_harmony_text_BidiWrapper_UBIDI_KEEP_BASE_COMBINING -#define org_apache_harmony_text_BidiWrapper_UBIDI_KEEP_BASE_COMBINING 1L -#undef org_apache_harmony_text_BidiWrapper_UBIDI_DO_MIRRORING -#define org_apache_harmony_text_BidiWrapper_UBIDI_DO_MIRRORING 2L -#undef org_apache_harmony_text_BidiWrapper_UBIDI_INSERT_LRM_FOR_NUMERIC -#define org_apache_harmony_text_BidiWrapper_UBIDI_INSERT_LRM_FOR_NUMERIC 4L -#undef org_apache_harmony_text_BidiWrapper_UBIDI_REMOVE_BIDI_CONTROLS -#define org_apache_harmony_text_BidiWrapper_UBIDI_REMOVE_BIDI_CONTROLS 8L -#undef org_apache_harmony_text_BidiWrapper_UBIDI_OUTPUT_REVERSE -#define org_apache_harmony_text_BidiWrapper_UBIDI_OUTPUT_REVERSE 16L -#undef org_apache_harmony_text_BidiWrapper_UBiDiDirection_UBIDI_LTR -#define org_apache_harmony_text_BidiWrapper_UBiDiDirection_UBIDI_LTR 0L -#undef org_apache_harmony_text_BidiWrapper_UBiDiDirection_UBIDI_RTL -#define org_apache_harmony_text_BidiWrapper_UBiDiDirection_UBIDI_RTL 1L -#undef org_apache_harmony_text_BidiWrapper_UBiDiDirection_UBIDI_MIXED -#define org_apache_harmony_text_BidiWrapper_UBiDiDirection_UBIDI_MIXED 2L -/* - * Class: org_apache_harmony_text_BidiWrapper - * Method: ubidi_open - * Signature: ()J - */ - JNIEXPORT jlong JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1open - (JNIEnv *, jclass); -/* - * Class: org_apache_harmony_text_BidiWrapper - * Method: ubidi_close - * Signature: (J)V - */ - JNIEXPORT void JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1close - (JNIEnv *, jclass, jlong); -/* - * Class: org_apache_harmony_text_BidiWrapper - * Method: ubidi_setPara - * Signature: (J[CIB[B)V - */ - JNIEXPORT void JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1setPara - (JNIEnv *, jclass, jlong, jcharArray, jint, jbyte, jbyteArray); -/* - * Class: org_apache_harmony_text_BidiWrapper - * Method: ubidi_setLine - * Signature: (JII)J - */ - JNIEXPORT jlong JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1setLine - (JNIEnv *, jclass, jlong, jint, jint); -/* - * Class: org_apache_harmony_text_BidiWrapper - * Method: ubidi_getDirection - * Signature: (J)I - */ - JNIEXPORT jint JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1getDirection - (JNIEnv *, jclass, jlong); -/* - * Class: org_apache_harmony_text_BidiWrapper - * Method: ubidi_getLength - * Signature: (J)I - */ - JNIEXPORT jint JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1getLength - (JNIEnv *, jclass, jlong); -/* - * Class: org_apache_harmony_text_BidiWrapper - * Method: ubidi_getParaLevel - * Signature: (J)B - */ - JNIEXPORT jbyte JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1getParaLevel - (JNIEnv *, jclass, jlong); -/* - * Class: org_apache_harmony_text_BidiWrapper - * Method: ubidi_getLevels - * Signature: (J)[B - */ - JNIEXPORT jbyteArray JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1getLevels - (JNIEnv *, jclass, jlong); -/* - * Class: org_apache_harmony_text_BidiWrapper - * Method: ubidi_countRuns - * Signature: (J)I - */ - JNIEXPORT jint JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1countRuns - (JNIEnv *, jclass, jlong); -/* - * Class: org_apache_harmony_text_BidiWrapper - * Method: ubidi_getRuns - * Signature: (J)[Lorg/apache/harmony/text/BidiRun; - */ -JNIEXPORT jobjectArray JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1getRuns - (JNIEnv *, jclass, jlong); -/* - * Class: org_apache_harmony_text_BidiWrapper - * Method: ubidi_reorderVisual - * Signature: ([BI)[I - */ - JNIEXPORT jintArray JNICALL - Java_org_apache_harmony_text_BidiWrapper_ubidi_1reorderVisual (JNIEnv *, jclass, - jbyteArray, jint); -#if defined(__cplusplus) -} -#endif -#endif diff --git a/libcore/icu/src/main/native/BreakIteratorInterface.c b/libcore/icu/src/main/native/BreakIteratorInterface.c deleted file mode 100644 index 021ace1ca..000000000 --- a/libcore/icu/src/main/native/BreakIteratorInterface.c +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright 2006 The Android Open Source Project - * - * Internal native functions. All of the functions defined here make - * direct use of VM functions or data structures, so they can't be written - * with JNI and shouldn't really be in a shared library. - * - * All functions here either complete quickly or are used to enter a wait - * state, so we don't set the thread status to THREAD_NATIVE when executing - * these methods. This means that the GC will wait for these functions - * to finish. DO NOT perform long operations or blocking I/O in here. - * - * In some cases we're following the division of labor defined by GNU - * ClassPath, e.g. java.lang.Thread has "Thread" and "VMThread", with - * the VM-specific behavior isolated in VMThread. - */ - -#include "JNIHelp.h" -#include "AndroidSystemNatives.h" -#include "ErrorCode.h" -#include "unicode/ubrk.h" -#include "unicode/putil.h" -#include - -static jstring getAvailableLocalesImpl(JNIEnv *env, jclass clazz, jint index) { - - const char * locale = ubrk_getAvailable(index); - - return (*env)->NewStringUTF(env, locale); - -} - -static jint getAvailableLocalesCountImpl(JNIEnv *env, jclass clazz) { - return ubrk_countAvailable(); -} - -static jint getCharacterInstanceImpl(JNIEnv *env, jclass clazz, jstring locale) { - - UErrorCode status = U_ZERO_ERROR; - - const char *localeChars = (*env)->GetStringUTFChars(env, locale, 0); - - UBreakIterator *iter = ubrk_open(UBRK_CHARACTER, localeChars, NULL, 0, &status); - - (*env)->ReleaseStringUTFChars(env, locale, localeChars); - - if ( icu4jni_error(env, status) != FALSE) { - return 0; - } - - return (long) iter; -} - -static jint getLineInstanceImpl(JNIEnv *env, jclass clazz, jstring locale) { - - UErrorCode status = U_ZERO_ERROR; - - const char *localeChars = (*env)->GetStringUTFChars(env, locale, 0); - - enum UBreakIteratorType type = UBRK_LINE; - - UBreakIterator *iter = ubrk_open(type, localeChars, NULL, 0, &status); - - (*env)->ReleaseStringUTFChars(env, locale, localeChars); - - if ( icu4jni_error(env, status) != FALSE) { - return 0; - } - - return (long) iter; -} - -static jint getSentenceInstanceImpl(JNIEnv *env, jclass clazz, jstring locale) { - - UErrorCode status = U_ZERO_ERROR; - - const char *localeChars = (*env)->GetStringUTFChars(env, locale, 0); - - enum UBreakIteratorType type = UBRK_SENTENCE; - - UBreakIterator *iter = ubrk_open(type, localeChars, NULL, 0, &status); - - (*env)->ReleaseStringUTFChars(env, locale, localeChars); - - if ( icu4jni_error(env, status) != FALSE) { - return 0; - } - - return (long) iter; -} - -static jint getWordInstanceImpl(JNIEnv *env, jclass clazz, jstring locale) { - - UErrorCode status = U_ZERO_ERROR; - - const char *localeChars = (*env)->GetStringUTFChars(env, locale, 0); - - enum UBreakIteratorType type = UBRK_WORD; - - UBreakIterator *iter = ubrk_open(type, localeChars, NULL, 0, &status); - - (*env)->ReleaseStringUTFChars(env, locale, localeChars); - - if ( icu4jni_error(env, status) != FALSE) { - return 0; - } - - return (long) iter; -} - -static void closeBreakIteratorImpl(JNIEnv *env, jclass clazz, jint address) { - - UBreakIterator *bi = (UBreakIterator *)(long)address; - - ubrk_close(bi); -} - -static jint cloneImpl(JNIEnv *env, jclass clazz, jint address) { - - UErrorCode status = U_ZERO_ERROR; - - UBreakIterator *bi = (UBreakIterator *)(long)address; - - jint buffersize = U_BRK_SAFECLONE_BUFFERSIZE; - - UBreakIterator *iter = ubrk_safeClone(bi, NULL, &buffersize, &status); - - if (icu4jni_error(env, status) != FALSE) { - return 0; - } - - return (long) iter; -} - -static void setTextImpl(JNIEnv *env, jclass clazz, jint address, jstring text) { - - UErrorCode status = U_ZERO_ERROR; - - UBreakIterator *bi = (UBreakIterator *)(long)address; - - const UChar *strUChars = (*env)->GetStringChars(env, text, NULL); - int strLen = (*env)->GetStringLength(env, text); - - ubrk_setText(bi, strUChars, strLen, &status); - - (*env)->ReleaseStringChars(env, text, strUChars); - - icu4jni_error(env, status); -} - -static jboolean isBoundaryImpl(JNIEnv *env, jclass clazz, jint address, jint offset) { - - UBreakIterator *bi = (UBreakIterator *)(long)address; - - return ubrk_isBoundary(bi, offset); -} - -static jint nextImpl(JNIEnv *env, jclass clazz, jint address, jint n) { - - UBreakIterator *bi = (UBreakIterator *)(long)address; - - if(n < 0) { - while(n++ < -1) { - ubrk_previous(bi); - } - return ubrk_previous(bi); - } else if(n == 0) { - return ubrk_current(bi); - } else { - while(n-- > 1) { - ubrk_next(bi); - } - return ubrk_next(bi); - } - - return -1; -} - -static jint precedingImpl(JNIEnv *env, jclass clazz, jint address, jint offset) { - - UBreakIterator *bi = (UBreakIterator *)(long)address; - - return ubrk_preceding(bi, offset); -} - -static jint firstImpl(JNIEnv *env, jclass clazz, jint address) { - - UBreakIterator *bi = (UBreakIterator *)(long)address; - - return ubrk_first(bi); -} - -static jint followingImpl(JNIEnv *env, jclass clazz, jint address, jint offset) { - - UBreakIterator *bi = (UBreakIterator *)(long)address; - - return ubrk_following(bi, offset); -} - -static jint currentImpl(JNIEnv *env, jclass clazz, jint address) { - - UBreakIterator *bi = (UBreakIterator *)(long)address; - - return ubrk_current(bi); -} - -static jint previousImpl(JNIEnv *env, jclass clazz, jint address) { - - UBreakIterator *bi = (UBreakIterator *)(long)address; - - return ubrk_previous(bi); -} - -static jint lastImpl(JNIEnv *env, jclass clazz, jint address) { - - UBreakIterator *bi = (UBreakIterator *)(long)address; - - return ubrk_last(bi); -} - -/* - * JNI registration - */ -static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ - { "getAvailableLocalesImpl", "(I)Ljava/lang/String;", - (void*) getAvailableLocalesImpl }, - { "getAvailableLocalesCountImpl", "()I", - (void*) getAvailableLocalesCountImpl }, - { "getCharacterInstanceImpl", "(Ljava/lang/String;)I", - (void*) getCharacterInstanceImpl }, - { "getLineInstanceImpl", "(Ljava/lang/String;)I", - (void*) getLineInstanceImpl }, - { "getSentenceInstanceImpl", "(Ljava/lang/String;)I", - (void*) getSentenceInstanceImpl }, - { "getWordInstanceImpl", "(Ljava/lang/String;)I", - (void*) getWordInstanceImpl }, - { "closeBreakIteratorImpl", "(I)V", - (void*) closeBreakIteratorImpl }, - { "cloneImpl", "(I)I", - (void*) cloneImpl }, - { "setTextImpl", "(ILjava/lang/String;)V", - (void*) setTextImpl }, - { "isBoundaryImpl", "(II)Z", - (void*) isBoundaryImpl }, - { "nextImpl", "(II)I", - (void*) nextImpl }, - { "precedingImpl", "(II)I", - (void*) precedingImpl }, - { "firstImpl", "(I)I", - (void*) firstImpl }, - { "lastImpl", "(I)I", - (void*) lastImpl }, - { "currentImpl", "(I)I", - (void*) currentImpl }, - { "followingImpl", "(II)I", - (void*) followingImpl }, - { "previousImpl", "(I)I", - (void*) previousImpl }, -}; -int register_com_ibm_icu4jni_text_NativeBreakIterator(JNIEnv* env) { - return jniRegisterNativeMethods(env, "com/ibm/icu4jni/text/NativeBreakIterator", - gMethods, NELEM(gMethods)); -} diff --git a/libcore/icu/src/main/native/CharacterInterface.c b/libcore/icu/src/main/native/CharacterInterface.c deleted file mode 100644 index 70e9f295a..000000000 --- a/libcore/icu/src/main/native/CharacterInterface.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright 2006 The Android Open Source Project - * - * Internal native functions. All of the functions defined here make - * direct use of VM functions or data structures, so they can't be written - * with JNI and shouldn't really be in a shared library. - * - * All functions here either complete quickly or are used to enter a wait - * state, so we don't set the thread status to THREAD_NATIVE when executing - * these methods. This means that the GC will wait for these functions - * to finish. DO NOT perform long operations or blocking I/O in here. - * - * In some cases we're following the division of labor defined by GNU - * ClassPath, e.g. java.lang.Thread has "Thread" and "VMThread", with - * the VM-specific behavior isolated in VMThread. - */ - -#include "JNIHelp.h" -#include "AndroidSystemNatives.h" -#include "unicode/uchar.h" -#include -#include - -static jint digitImpl(JNIEnv *env, jclass clazz, jint codePoint, jint radix) { - return u_digit(codePoint, radix); -} - -static jint getTypeImpl(JNIEnv *env, jclass clazz, jint codePoint) { - return u_charType(codePoint); -} - -static jbyte getDirectionalityImpl(JNIEnv *env, jclass clazz, jint codePoint) { - return u_charDirection (codePoint); -} - -static jboolean isMirroredImpl(JNIEnv *env, jclass clazz, jint codePoint) { - return u_isMirrored (codePoint); -} - -static jint getNumericValueImpl(JNIEnv *env, jclass clazz, jint codePoint){ - // The letters A-Z in their uppercase ('\u0041' through '\u005A'), - // lowercase ('\u0061' through '\u007A'), - // and full width variant ('\uFF21' through '\uFF3A' - // and '\uFF41' through '\uFF5A') forms - // have numeric values from 10 through 35. This is independent of the - // Unicode specification, which does not assign numeric values to these - // char values. - if (codePoint >= 0x41 && codePoint <= 0x5A) { - return codePoint - 0x37; - } - if (codePoint >= 0x61 && codePoint <= 0x7A) { - return codePoint - 0x57; - } - if (codePoint >= 0xFF21 && codePoint <= 0xFF3A) { - return codePoint - 0xFF17; - } - if (codePoint >= 0xFF41 && codePoint <= 0xFF5A) { - return codePoint - 0xFF37; - } - - double result = u_getNumericValue(codePoint); - - if (result == U_NO_NUMERIC_VALUE) { - return -1; - } else if (result < 0 || floor(result + 0.5) != result) { - return -2; - } - - return result; -} - -static jboolean isDefinedValueImpl(JNIEnv *env, jclass clazz, jint codePoint) { - return u_isdefined(codePoint); -} - -static jboolean isDigitImpl(JNIEnv *env, jclass clazz, jint codePoint) { - return u_isdigit(codePoint); -} - -static jboolean isIdentifierIgnorableImpl(JNIEnv *env, jclass clazz, - jint codePoint) { - - // Java also returns TRUE for U+0085 Next Line (it omits U+0085 from whitespace ISO controls) - if(codePoint == 0x0085) { - return JNI_TRUE; - } - - return u_isIDIgnorable(codePoint); -} - -static jboolean isLetterImpl(JNIEnv *env, jclass clazz, jint codePoint) { - return u_isalpha(codePoint); -} - -static jboolean isLetterOrDigitImpl(JNIEnv *env, jclass clazz, jint codePoint) { - return u_isalnum(codePoint); -} - -static jboolean isSpaceCharImpl(JNIEnv *env, jclass clazz, jint codePoint) { - return u_isJavaSpaceChar(codePoint); -} - -static jboolean isTitleCaseImpl(JNIEnv *env, jclass clazz, jint codePoint) { - return u_istitle(codePoint); -} - -static jboolean isUnicodeIdentifierPartImpl(JNIEnv *env, jclass clazz, - jint codePoint) { - return u_isIDPart(codePoint); -} - -static jboolean isUnicodeIdentifierStartImpl(JNIEnv *env, jclass clazz, - jint codePoint) { - return u_isIDStart(codePoint); -} - -static jboolean isWhitespaceImpl(JNIEnv *env, jclass clazz, jint codePoint) { - - // Java omits U+0085 - if(codePoint == 0x0085) { - return JNI_FALSE; - } - - return u_isWhitespace(codePoint); -} - -static jint toLowerCaseImpl(JNIEnv *env, jclass clazz, jint codePoint) { - return u_tolower(codePoint); -} - -static jint toTitleCaseImpl(JNIEnv *env, jclass clazz, jint codePoint) { - return u_totitle(codePoint); -} - -static jint toUpperCaseImpl(JNIEnv *env, jclass clazz, jint codePoint) { - return u_toupper(codePoint); -} - -static jboolean isUpperCaseImpl(JNIEnv *env, jclass clazz, jint codePoint) { - return u_isupper(codePoint); -} - -static jboolean isLowerCaseImpl(JNIEnv *env, jclass clazz, jint codePoint) { - return u_islower(codePoint); -} - -static int forName(JNIEnv *env, jclass clazz, jstring blockName) { - const char *bName = (*env)->GetStringUTFChars(env, blockName, NULL); - int result = u_getPropertyValueEnum(UCHAR_BLOCK, bName); - (*env)->ReleaseStringUTFChars(env, blockName, bName); - return result; -} - -static int codeBlock(JNIEnv *env, jclass clazz, jint codePoint) { - return ublock_getCode(codePoint); -} - -/* - * JNI registration - */ -static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ - { "digitImpl", "(II)I", (void*) digitImpl }, - { "getTypeImpl", "(I)I", (void*) getTypeImpl }, - { "getDirectionalityImpl", "(I)B", (void*) getDirectionalityImpl }, - { "isMirroredImpl", "(I)Z", (void*) isMirroredImpl }, - { "getNumericValueImpl", "(I)I", (void*) getNumericValueImpl }, - { "isDefinedValueImpl", "(I)Z", (void*) isDefinedValueImpl }, - { "isDigitImpl", "(I)Z", (void*) isDigitImpl }, - { "isIdentifierIgnorableImpl", "(I)Z", (void*) isIdentifierIgnorableImpl }, - { "isLetterImpl", "(I)Z", (void*) isLetterImpl }, - { "isLetterOrDigitImpl", "(I)Z", (void*) isLetterOrDigitImpl }, - { "isSpaceCharImpl", "(I)Z", (void*) isSpaceCharImpl }, - { "isTitleCaseImpl", "(I)Z", (void*) isTitleCaseImpl }, - { "isUnicodeIdentifierPartImpl", "(I)Z", - (void*) isUnicodeIdentifierPartImpl }, - { "isUnicodeIdentifierStartImpl", "(I)Z", - (void*) isUnicodeIdentifierStartImpl }, - { "isWhitespaceImpl", "(I)Z", (void*) isWhitespaceImpl }, - { "toLowerCaseImpl", "(I)I", (void*) toLowerCaseImpl }, - { "toTitleCaseImpl", "(I)I", (void*) toTitleCaseImpl }, - { "toUpperCaseImpl", "(I)I", (void*) toUpperCaseImpl }, - { "isUpperCaseImpl", "(I)Z", (void*) isUpperCaseImpl }, - { "isLowerCaseImpl", "(I)Z", (void*) isLowerCaseImpl }, - { "forname", "(Ljava/lang/String;)I", (void*) forName }, - { "codeblock", "(I)I", (void*) codeBlock } -}; - -int register_com_ibm_icu4jni_lang_UCharacter(JNIEnv *env) { - return jniRegisterNativeMethods(env, "com/ibm/icu4jni/lang/UCharacter", - gMethods, NELEM(gMethods)); -} - - diff --git a/libcore/icu/src/main/native/CollationInterface.c b/libcore/icu/src/main/native/CollationInterface.c deleted file mode 100644 index 86246ac96..000000000 --- a/libcore/icu/src/main/native/CollationInterface.c +++ /dev/null @@ -1,589 +0,0 @@ -/** -******************************************************************************* -* Copyright (C) 1996-2005, International Business Machines Corporation and * -* others. All Rights Reserved. * -******************************************************************************* -* -******************************************************************************* -*/ - -#include "JNIHelp.h" -#include "AndroidSystemNatives.h" -#include "ErrorCode.h" -#include "unicode/ucol.h" -#include "unicode/ucoleitr.h" -#include "ucol_imp.h" - - -/** -* Closing a C UCollator with the argument locale rules. -* Note determining if a collator currently exist for the caller is to be handled -* by the caller. Hence if the caller has a existing collator, it is his -* responsibility to delete first before calling this method. -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param address of the C UCollator -*/ -static void closeCollator(JNIEnv *env, jclass obj, - jint address) { - - UCollator *collator = (UCollator *)(int)address; - ucol_close(collator); -} - - -/** -* Close a C collation element iterator. -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param address of C collation element iterator to close. -*/ -static void closeElements(JNIEnv *env, jclass obj, - jint address) { - - UCollationElements *iterator = (UCollationElements *)(int)address; - ucol_closeElements(iterator); -} - -/** -* Compare two strings. -* The strings will be compared using the normalization mode and options -* specified in openCollator or openCollatorFromRules -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param address address of the c collator -* @param source The source string. -* @param target The target string. -* @return result of the comparison, UCOL_EQUAL, UCOL_GREATER or UCOL_LESS -*/ -static jint compare(JNIEnv *env, jclass obj, jint address, - jstring source, jstring target) { - - const UCollator *collator = (const UCollator *)(int)address; - jint result = -2; - if(collator){ - jsize srclength = (*env)->GetStringLength(env, source); - const UChar *srcstr = (const UChar *)(*env)->GetStringCritical(env,source,0); - if(srcstr){ - jsize tgtlength = (*env)->GetStringLength(env, target); - const UChar *tgtstr = (const UChar *)(*env)->GetStringCritical(env,target,0); - if(tgtstr){ - result = ucol_strcoll(collator, srcstr, srclength, tgtstr, tgtlength); - (*env)->ReleaseStringCritical(env, source, srcstr); - (*env)->ReleaseStringCritical(env, target, tgtstr); - return result; - }else{ - icu4jni_error(env,U_ILLEGAL_ARGUMENT_ERROR); - } - }else{ - icu4jni_error(env,U_ILLEGAL_ARGUMENT_ERROR); - } - }else{ - icu4jni_error(env,U_ILLEGAL_ARGUMENT_ERROR); - } - return result; -} - -/** -* Universal attribute getter -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param address address of the C collator -* @param type type of attribute to be set -* @return attribute value -* @exception thrown when error occurs while getting attribute value -*/ -static jint getAttribute(JNIEnv *env, jclass obj, jint address, - jint type) { - - const UCollator *collator = (const UCollator *)(int)address; - UErrorCode status = U_ZERO_ERROR; - if(collator){ - jint result = (jint)ucol_getAttribute(collator, (UColAttribute)type, - &status); - if (icu4jni_error(env, status) != FALSE){ - return (jint)UCOL_DEFAULT; - } - return result; - }else{ - icu4jni_error(env,U_ILLEGAL_ARGUMENT_ERROR); - } - return (jint)UCOL_DEFAULT; -} - -/** -* Create a CollationElementIterator object that will iterator over the elements -* in a string, using the collation rules defined in this RuleBasedCollatorJNI -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param address address of C collator -* @param source string to iterate over -* @return address of C collationelement -*/ -static jint getCollationElementIterator(JNIEnv *env, - jclass obj, jint address, jstring source) { - - UErrorCode status = U_ZERO_ERROR; - UCollator *collator = (UCollator *)(int)address; - jint result=0; - if(collator){ - jsize srclength = (*env)->GetStringLength(env, source); - const UChar *srcstr = (const UChar *)(*env)->GetStringCritical(env,source,0); - if(srcstr){ - result = (jint)(ucol_openElements(collator, srcstr, srclength, &status)); - - (*env)->ReleaseStringCritical(env, source, srcstr); - icu4jni_error(env, status); - }else{ - icu4jni_error(env, U_ILLEGAL_ARGUMENT_ERROR); - } - }else{ - icu4jni_error(env, U_ILLEGAL_ARGUMENT_ERROR); - } - return result; -} - -/** -* Get the maximum length of any expansion sequences that end with the specified -* comparison order. -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param address of the C collation element iterator containing the text. -* @param order collation order returned by previous or next. -* @return maximum length of any expansion sequences ending with the specified -* order or 1 if collation order does not occur at the end of any -* expansion sequence. -*/ -static jint getMaxExpansion(JNIEnv *env, jclass obj, - jint address, jint order) { - - UCollationElements *iterator = (UCollationElements *)(int)address; - return ucol_getMaxExpansion(iterator, order); -} - -/** -* Get the normalization mode for this object. -* The normalization mode influences how strings are compared. -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param address of C collator -* @return normalization mode; one of the values from NormalizerEnum -*/ -static jint getNormalization(JNIEnv *env, jclass obj, - jint address) { - - UErrorCode status = U_ZERO_ERROR; - const UCollator *collator = (const UCollator *)(int)address; - if(U_FAILURE(status)){ - icu4jni_error(env, status); - } - return (jint)ucol_getAttribute(collator,UCOL_NORMALIZATION_MODE,&status); - -} - -/** -* Set the normalization mode for this object. -* The normalization mode influences how strings are compared. -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param address of C collator -* @param mode the normalization mode -*/ -static void setNormalization(JNIEnv *env, jclass obj, jint address, - jint mode) { - - UErrorCode status = U_ZERO_ERROR; - const UCollator *collator = (const UCollator *)(int)address; - if(U_FAILURE(status)){ - icu4jni_error(env, status); - } - ucol_setAttribute(collator,UCOL_NORMALIZATION_MODE,mode,&status); -} - - -/** -* Get the offset of the current source character. -* This is an offset into the text of the character containing the current -* collation elements. -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param addresss of the C collation elements iterator to query. -* @return offset of the current source character. -*/ -static jint getOffset(JNIEnv *env, jclass obj, jint address) { - - UCollationElements *iterator = (UCollationElements *)(int)address; - return ucol_getOffset(iterator); -} - -/** -* Get the collation rules from a UCollator. -* The rules will follow the rule syntax. -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param address the address of the C collator -* @return collation rules. -*/ -static jstring getRules(JNIEnv *env, jclass obj, - jint address) { - - const UCollator *collator = (const UCollator *)(int)address; - int32_t length=0; - const UChar *rules = ucol_getRules(collator, &length); - return (*env)->NewString(env, rules, length); -} - -/** -* Get a sort key for the argument string -* Sort keys may be compared using java.util.Arrays.equals -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param address address of the C collator -* @param source string for key to be generated -* @return sort key -*/ -static jbyteArray getSortKey(JNIEnv *env, jclass obj, - jint address, jstring source) { - - const UCollator *collator = (const UCollator *)(int)address; - jbyteArray result; - if(collator && source){ - // BEGIN android-added - if(!source) { - return NULL; - } - // END android-added - jsize srclength = (*env)->GetStringLength(env, source); - const UChar *srcstr = (const UChar *)(*env)->GetStringCritical(env,source, 0); - if(srcstr){ -// BEGIN android-changed - uint8_t bytearray[UCOL_MAX_BUFFER * 2]; - uint8_t *largerbytearray = NULL; - uint8_t *usedbytearray = bytearray; - - jint bytearraysize = ucol_getSortKey(collator, srcstr, srclength, bytearray, - sizeof(bytearray) - 1); - - if (bytearraysize > sizeof(bytearray) - 1) { - // didn't fit, try again with a larger buffer. - largerbytearray = malloc(bytearraysize + 1); - usedbytearray = largerbytearray; - bytearraysize = ucol_getSortKey(collator, srcstr, srclength, largerbytearray, - bytearraysize); - } - - (*env)->ReleaseStringCritical(env, source, srcstr); - - if (bytearraysize == 0) { - free(largerbytearray); - return NULL; - } - - /* no problem converting uint8_t to int8_t, gives back the correct value - * tried and tested - */ - result = (*env)->NewByteArray(env, bytearraysize); - (*env)->SetByteArrayRegion(env, result, 0, bytearraysize, usedbytearray); - free(largerbytearray); -// END android-changed - }else{ - icu4jni_error(env,U_ILLEGAL_ARGUMENT_ERROR); - } - }else{ - icu4jni_error(env,U_ILLEGAL_ARGUMENT_ERROR); - } - return result; -} - -/** -* Returns a hash of this collation object -* Note this method is not complete, it only returns 0 at the moment. -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param address address of C collator -* @return hash of this collation object -*/ -static jint hashCode(JNIEnv *env, jclass obj, jint address) { - - UCollator *collator = (UCollator *)(int)address; - int32_t length=0; - const UChar *rules = ucol_getRules(collator, &length); - /* temporary commented out - * return uhash_hashUCharsN(rules, length); - */ - return 0; -} - -/** -* Get the ordering priority of the next collation element in the text. -* A single character may contain more than one collation element. -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param address if C collation elements containing the text. -* @return next collation elements ordering, otherwise returns NULLORDER if an -* error has occured or if the end of string has been reached -*/ -static jint next(JNIEnv *env, jclass obj, jint address) { - UCollationElements *iterator = (UCollationElements *)(int)address; - UErrorCode status = U_ZERO_ERROR; - jint result = ucol_next(iterator, &status); - - icu4jni_error(env, status); - return result; -} - -/** -* Opening a new C UCollator with the default locale. -* Note determining if a collator currently exist for the caller is to be handled -* by the caller. Hence if the caller has a existing collator, it is his -* responsibility to delete first before calling this method. -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @return address of the new C UCollator -* @exception thrown if creation of the UCollator fails -*/ -static jint openCollator__(JNIEnv *env, jclass obj) { - jint result; - UErrorCode status = U_ZERO_ERROR; - - result = (jint)ucol_open(NULL, &status); - if ( icu4jni_error(env, status) != FALSE) - return 0; - - return result; -} - - -/** -* Opening a new C UCollator with the argument locale rules. -* Note determining if a collator currently exist for the caller is to be handled -* by the caller. Hence if the caller has a existing collator, it is his -* responsibility to delete first before calling this method. -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param locale name -* @return address of the new C UCollator -* @exception thrown if creation of the UCollator fails -*/ -static jint openCollator__Ljava_lang_String_2(JNIEnv *env, - jclass obj, jstring locale) { - - /* this will be null terminated */ - const char *localestr = (*env)->GetStringUTFChars(env, locale, 0); - jint result=0; - UErrorCode status = U_ZERO_ERROR; - - if(localestr){ - result = (jint)ucol_open(localestr, &status); - (*env)->ReleaseStringUTFChars(env, locale, localestr); - icu4jni_error(env, status); - }else{ - icu4jni_error(env,U_ILLEGAL_ARGUMENT_ERROR); - } - return result; -} - -/** -* Opening a new C UCollator with the argument locale rules. -* Note determining if a collator currently exist for the caller is to be -* handled by the caller. Hence if the caller has a existing collator, it is his -* responsibility to delete first before calling this method. -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param rules set of collation rules -* @param normalizationmode normalization mode -* @param strength collation strength -* @return address of the new C UCollator -* @exception thrown if creation of the UCollator fails -*/ -static jint openCollatorFromRules(JNIEnv *env, jclass obj, - jstring rules, jint normalizationmode, jint strength) { - - jsize ruleslength = (*env)->GetStringLength(env, rules); - const UChar *rulestr = (const UChar *)(*env)->GetStringCritical(env,rules, 0); - UErrorCode status = U_ZERO_ERROR; - jint result = 0; - if(rulestr){ - result = (jint)ucol_openRules(rulestr, ruleslength, - (UColAttributeValue)normalizationmode, - (UCollationStrength)strength, NULL, &status); - - (*env)->ReleaseStringCritical(env, rules, rulestr); - icu4jni_error(env, status); - }else{ - icu4jni_error(env,U_ILLEGAL_ARGUMENT_ERROR); - } - - return result; -} - -/** -* Get the ordering priority of the previous collation element in the text. -* A single character may contain more than one collation element. -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param address of the C collation element iterator containing the text. -* @return previous collation element ordering, otherwise returns NULLORDER if -* an error has occured or if the start of string has been reached -* @exception thrown when retrieval of previous collation element fails. -*/ -static jint previous(JNIEnv *env, jclass obj, jint address) { - - UCollationElements *iterator = (UCollationElements *)(int)address; - UErrorCode status = U_ZERO_ERROR; - jint result = ucol_previous(iterator, &status); - - icu4jni_error(env, status); - return result; -} - - -/** -* Reset the collation elements to their initial state. -* This will move the 'cursor' to the beginning of the text. -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param address of C collation element iterator to reset. -*/ -static void reset(JNIEnv *env, jclass obj, jint address) { - - UCollationElements *iterator = (UCollationElements *)(int)address; - ucol_reset(iterator); -} - -/** -* Thread safe cloning operation -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param address address of C collator to be cloned -* @return address of the new clone -* @exception thrown when error occurs while cloning -*/ -static jint safeClone(JNIEnv *env, jclass obj, jint address) { - - const UCollator *collator = (const UCollator *)(int)address; - UErrorCode status = U_ZERO_ERROR; - jint result; - jint buffersize = U_COL_SAFECLONE_BUFFERSIZE; - - result = (jint)ucol_safeClone(collator, NULL, &buffersize, &status); - - if ( icu4jni_error(env, status) != FALSE) { - return 0; - } - - return result; -} - -/** -* Universal attribute setter. -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param address address of the C collator -* @param type type of attribute to be set -* @param value attribute value -* @exception thrown when error occurs while setting attribute value -*/ -static void setAttribute(JNIEnv *env, jclass obj, jint address, - jint type, jint value) { - - UCollator *collator = (UCollator *)(int)address; - UErrorCode status = U_ZERO_ERROR; - ucol_setAttribute(collator, (UColAttribute)type, (UColAttributeValue)value, - &status); - icu4jni_error(env, status); -} - -/** -* Set the offset of the current source character. -* This is an offset into the text of the character to be processed. -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param address of the C collation element iterator to set. -* @param offset The desired character offset. -* @exception thrown when offset setting fails -*/ -static void setOffset(JNIEnv *env, jclass obj, jint address, - jint offset) { - - UCollationElements *iterator = (UCollationElements *)(int)address; - UErrorCode status = U_ZERO_ERROR; - - ucol_setOffset(iterator, offset, &status); - icu4jni_error(env, status); -} - -/** -* Set the text containing the collation elements. -* @param env JNI environment -* @param obj RuleBasedCollatorJNI object -* @param address of the C collation element iterator to be set -* @param source text containing the collation elements. -* @exception thrown when error occurs while setting offset -*/ -static void setText(JNIEnv *env, jclass obj, jint address, - jstring source) { - - UCollationElements *iterator = (UCollationElements *)(int)address; - UErrorCode status = U_ZERO_ERROR; - int strlength = (*env)->GetStringLength(env, source); - const UChar *str = (const UChar *)(*env)->GetStringCritical(env, source, 0); - - ucol_setText(iterator, str, strlength, &status); - (*env)->ReleaseStringCritical(env, source, str); - - icu4jni_error(env, status); -} - -// BEGIN android-added -static jstring getAvailableLocalesImpl(JNIEnv *env, jclass clazz, jint index) { - - const char * locale = ucol_getAvailable(index); - - return (*env)->NewStringUTF(env, locale); - -} - -static jint getAvailableLocalesCountImpl(JNIEnv *env, jclass clazz) { - return ucol_countAvailable(); -} -// END android-added - -/* - * JNI registratio - */ -static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ - // BEGIN android-added - { "getAvailableLocalesImpl", "(I)Ljava/lang/String;", (void*) getAvailableLocalesImpl }, - { "getAvailableLocalesCountImpl", "()I", (void*) getAvailableLocalesCountImpl }, - // END android-added - { "openCollator", "()I", (void*) openCollator__ }, - { "openCollator", "(Ljava/lang/String;)I", (void*) openCollator__Ljava_lang_String_2 }, - { "openCollatorFromRules", "(Ljava/lang/String;II)I", (void*) openCollatorFromRules }, - { "closeCollator", "(I)V", (void*) closeCollator }, - { "compare", "(ILjava/lang/String;Ljava/lang/String;)I", (void*) compare }, - { "getNormalization", "(I)I", (void*) getNormalization }, - { "setNormalization", "(II)V", (void*) setNormalization }, - { "getRules", "(I)Ljava/lang/String;", (void*) getRules }, - { "getSortKey", "(ILjava/lang/String;)[B", (void*) getSortKey }, - { "setAttribute", "(III)V", (void*) setAttribute }, - { "getAttribute", "(II)I", (void*) getAttribute }, - { "safeClone", "(I)I", (void*) safeClone }, - { "getCollationElementIterator", "(ILjava/lang/String;)I", (void*) getCollationElementIterator }, - { "hashCode", "(I)I", (void*) hashCode }, - { "closeElements", "(I)V", (void*) closeElements }, - { "reset", "(I)V", (void*) reset }, - { "next", "(I)I", (void*) next }, - { "previous", "(I)I", (void*) previous }, - { "getMaxExpansion", "(II)I", (void*) getMaxExpansion }, - { "setText", "(ILjava/lang/String;)V", (void*) setText }, - { "getOffset", "(I)I", (void*) getOffset }, - { "setOffset", "(II)V", (void*) setOffset } -}; - -int register_com_ibm_icu4jni_text_NativeCollator(JNIEnv *_env) { - return jniRegisterNativeMethods(_env, "com/ibm/icu4jni/text/NativeCollation", - gMethods, NELEM(gMethods)); -} - diff --git a/libcore/icu/src/main/native/CollationInterface.h b/libcore/icu/src/main/native/CollationInterface.h deleted file mode 100644 index bdb4b6780..000000000 --- a/libcore/icu/src/main/native/CollationInterface.h +++ /dev/null @@ -1,214 +0,0 @@ -/** -******************************************************************************* -* Copyright (C) 1996-2005, International Business Machines Corporation and * -* others. All Rights Reserved. * -******************************************************************************* -* -******************************************************************************* -*/ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class CollationInterface */ - -#ifndef _Included_com_ibm_icu4jni_text_NativeCollation -#define _Included_com_ibm_icu4jni_text_NativeCollation -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: closeCollator - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_ibm_icu4jni_text_NativeCollation_closeCollator - (JNIEnv *, jclass, jlong); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: closeElements - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_ibm_icu4jni_text_NativeCollation_closeElements - (JNIEnv *, jclass, jlong); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: compare - * Signature: (JLjava/lang/String;Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_text_NativeCollation_compare - (JNIEnv *, jclass, jlong, jstring, jstring); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: getAttribute - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_text_NativeCollation_getAttribute - (JNIEnv *, jclass, jlong, jint); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: getCollationElementIterator - * Signature: (JLjava/lang/String;)J - */ -JNIEXPORT jlong JNICALL Java_com_ibm_icu4jni_text_NativeCollation_getCollationElementIterator - (JNIEnv *, jclass, jlong, jstring); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: getMaxExpansion - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_text_NativeCollation_getMaxExpansion - (JNIEnv *, jclass, jlong, jint); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: getNormalization - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_text_NativeCollation_getNormalization - (JNIEnv *, jclass, jlong); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: getOffset - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_text_NativeCollation_getOffset - (JNIEnv *, jclass, jlong); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: getRules - * Signature: (J)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_ibm_icu4jni_text_NativeCollation_getRules - (JNIEnv *, jclass, jlong); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: getSortKey - * Signature: (JLjava/lang/String;)[B - */ -JNIEXPORT jbyteArray JNICALL Java_com_ibm_icu4jni_text_NativeCollation_getSortKey - (JNIEnv *, jclass, jlong, jstring); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: hashCode - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_text_NativeCollation_hashCode - (JNIEnv *, jclass, jlong); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: next - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_text_NativeCollation_next - (JNIEnv *, jclass, jlong); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: openCollator - * Signature: ()J - */ -JNIEXPORT jlong JNICALL Java_com_ibm_icu4jni_text_NativeCollation_openCollator__ - (JNIEnv *, jclass); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: openCollator - * Signature: (Ljava/lang/String;)J - */ -JNIEXPORT jlong JNICALL Java_com_ibm_icu4jni_text_NativeCollation_openCollator__Ljava_lang_String_2 - (JNIEnv *, jclass, jstring); - - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: openCollatorFromRules - * Signature: (Ljava/lang/String;II)J - */ -JNIEXPORT jlong JNICALL Java_com_ibm_icu4jni_text_NativeCollation_openCollatorFromRules - (JNIEnv *, jclass, jstring, jint, jint); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: previous - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_text_NativeCollation_previous - (JNIEnv *, jclass, jlong); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: primaryOrder - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_text_NativeCollation_primaryOrder - (JNIEnv *, jclass, jint); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: reset - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_ibm_icu4jni_text_NativeCollation_reset - (JNIEnv *, jclass, jlong); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: safeClone - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_com_ibm_icu4jni_text_NativeCollation_safeClone - (JNIEnv *, jclass, jlong); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: secondaryOrder - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_text_NativeCollation_secondaryOrder - (JNIEnv *, jclass, jint); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: setAttribute - * Signature: (JII)V - */ -JNIEXPORT void JNICALL Java_com_ibm_icu4jni_text_NativeCollation_setAttribute - (JNIEnv *, jclass, jlong, jint, jint); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: setOffset - * Signature: (JI)V - */ -JNIEXPORT void JNICALL Java_com_ibm_icu4jni_text_NativeCollation_setOffset - (JNIEnv *, jclass, jlong, jint); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: setText - * Signature: (JLjava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_com_ibm_icu4jni_text_NativeCollation_setText - (JNIEnv *, jclass, jlong, jstring); - -/* - * Class: com_ibm_icu4jni_text_NativeCollation - * Method: tertiaryOrder - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_text_NativeCollation_tertiaryOrder - (JNIEnv *, jclass, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/libcore/icu/src/main/native/ConverterInterface.c b/libcore/icu/src/main/native/ConverterInterface.c deleted file mode 100644 index d7f5c9b72..000000000 --- a/libcore/icu/src/main/native/ConverterInterface.c +++ /dev/null @@ -1,1378 +0,0 @@ -/** -******************************************************************************* -* Copyright (C) 1996-2006, International Business Machines Corporation and * -* others. All Rights Reserved. * -******************************************************************************* -* -* -******************************************************************************* -*/ -/* - * @(#) icujniinterface.c 1.2 00/10/11 - * - * (C) Copyright IBM Corp. 2000 - All Rights Reserved - * A JNI wrapper to ICU native converter Interface - * @author: Ram Viswanadha - */ - -#include "ConverterInterface.h" -#include "JNIHelp.h" -#include "AndroidSystemNatives.h" -#include "unicode/utypes.h" /* Basic ICU data types */ -#include "unicode/ucnv.h" /* C Converter API */ -#include "unicode/ustring.h" /* some more string functions*/ -#include "unicode/ucnv_cb.h" /* for callback functions */ -#include "unicode/uset.h" /* for contains function */ -#include "ErrorCode.h" -#include -#include - -// BEGIN android-removed -// #define UTF_16BE "UTF-16BE" -// #define UTF_16 "UTF-16" -// END android-removed - -/* Prototype of callback for substituting user settable sub chars */ -void JNI_TO_U_CALLBACK_SUBSTITUTE - (const void *,UConverterToUnicodeArgs *,const char* ,int32_t ,UConverterCallbackReason ,UErrorCode * ); - -/** - * Opens the ICU converter - * @param env environment handle for JNI - * @param jClass handle for the class - * @param handle buffer to recieve ICU's converter address - * @param converterName name of the ICU converter - */ -static jlong openConverter (JNIEnv *env, jclass jClass, jstring converterName) { - - UConverter* conv=NULL; - UErrorCode errorCode = U_ZERO_ERROR; - - const char* cnvName= (const char*) (*env)->GetStringUTFChars(env, converterName,NULL); - if(cnvName) { - int count = (*env)->GetStringUTFLength(env,converterName); - - conv = ucnv_open(cnvName,&errorCode); - } - (*env)->ReleaseStringUTFChars(env, converterName,cnvName); - - if (icu4jni_error(env, errorCode) != FALSE) { - return 0; - } - - return (jlong) conv; -} - -/** - * Closes the ICU converter - * @param env environment handle for JNI - * @param jClass handle for the class - * @param handle address of ICU converter - */ -static void closeConverter (JNIEnv *env, jclass jClass, jlong handle) { - - UConverter* cnv = (UConverter*)(long)handle; - if(cnv) { - // BEGIN android-added - // Free up any contexts created in setCallback[Encode|Decode]() - UConverterToUCallback toAction; - UConverterFromUCallback fromAction; - void * context1 = NULL; - void * context2 = NULL; - ucnv_getToUCallBack(cnv, &toAction, &context1); - ucnv_getFromUCallBack(cnv, &fromAction, &context2); - // END android-added - ucnv_close(cnv); - // BEGIN android-added - if (context1 != NULL) { - free(context1); - } - if (context2 != NULL) { - free(context2); - } - // END android-added - } -} - -/** - * Sets the substution mode for from Unicode conversion. Currently only - * two modes are supported: substitute or report - * @param env environment handle for JNI - * @param jClass handle for the class - * @param handle address of ICU converter - * @param mode the mode to set - */ -static jint setSubstitutionModeCharToByte (JNIEnv *env, jclass jClass, jlong handle, jboolean mode) { - - UConverter* conv = (UConverter*)(long)handle; - UErrorCode errorCode =U_ZERO_ERROR; - - if(conv) { - - UConverterFromUCallback fromUOldAction ; - void* fromUOldContext; - void* fromUNewContext=NULL; - if(mode) { - - ucnv_setFromUCallBack(conv, - UCNV_FROM_U_CALLBACK_SUBSTITUTE, - fromUNewContext, - &fromUOldAction, - (const void**)&fromUOldContext, - &errorCode); - - } - else{ - - ucnv_setFromUCallBack(conv, - UCNV_FROM_U_CALLBACK_STOP, - fromUNewContext, - &fromUOldAction, - (const void**)&fromUOldContext, - &errorCode); - - } - return errorCode; - } - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - return errorCode; -} -/** - * Sets the substution mode for to Unicode conversion. Currently only - * two modes are supported: substitute or report - * @param env environment handle for JNI - * @param jClass handle for the class - * @param handle address of ICU converter - * @param mode the mode to set - */ -static jint setSubstitutionModeByteToChar (JNIEnv *env, jclass jClass, jlong handle, jboolean mode) { - - UConverter* conv = (UConverter*)handle; - UErrorCode errorCode =U_ZERO_ERROR; - - if(conv) { - - UConverterToUCallback toUOldAction ; - void* toUOldContext; - void* toUNewContext=NULL; - if(mode) { - - ucnv_setToUCallBack(conv, - UCNV_TO_U_CALLBACK_SUBSTITUTE, - toUNewContext, - &toUOldAction, - (const void**)&toUOldContext, - &errorCode); - - } - else{ - - ucnv_setToUCallBack(conv, - UCNV_TO_U_CALLBACK_STOP, - toUNewContext, - &toUOldAction, - (const void**)&toUOldContext, - &errorCode); - - } - return errorCode; - } - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - return errorCode; -} -/** - * Converts a buffer of Unicode code units to target encoding - * @param env environment handle for JNI - * @param jClass handle for the class - * @param handle address of ICU converter - * @param source buffer of Unicode chars to convert - * @param sourceEnd limit of the source buffer - * @param target buffer to recieve the converted bytes - * @param targetEnd the limit of the target buffer - * @param data buffer to recieve state of the current conversion - * @param flush boolean that specifies end of source input - */ -static jint convertCharToByte(JNIEnv *env, jclass jClass, jlong handle, jcharArray source, jint sourceEnd, jbyteArray target, jint targetEnd, jintArray data, jboolean flush) { - - - UErrorCode errorCode =U_ZERO_ERROR; - UConverter* cnv = (UConverter*)handle; - if(cnv) { - jint* myData = (jint*) (*env)->GetPrimitiveArrayCritical(env,data,NULL); - if(myData) { - jint* sourceOffset = &myData[0]; - jint* targetOffset = &myData[1]; - const jchar* uSource =(jchar*) (*env)->GetPrimitiveArrayCritical(env,source, NULL); - if(uSource) { - jbyte* uTarget=(jbyte*) (*env)->GetPrimitiveArrayCritical(env,target,NULL); - if(uTarget) { - const jchar* mySource = uSource+ *sourceOffset; - const UChar* mySourceLimit= uSource+sourceEnd; - char* cTarget=uTarget+ *targetOffset; - const char* cTargetLimit=uTarget+targetEnd; - - ucnv_fromUnicode( cnv , &cTarget, cTargetLimit,&mySource, - mySourceLimit,NULL,(UBool) flush, &errorCode); - - *sourceOffset = (jint) (mySource - uSource)-*sourceOffset; - *targetOffset = (jint) ((jbyte*)cTarget - uTarget)- *targetOffset; - if(U_FAILURE(errorCode)) { - (*env)->ReleasePrimitiveArrayCritical(env,target,uTarget,0); - (*env)->ReleasePrimitiveArrayCritical(env,source,(jchar*)uSource,0); - (*env)->ReleasePrimitiveArrayCritical(env,data,(jint*)myData,0); - return errorCode; - } - }else{ - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - } - (*env)->ReleasePrimitiveArrayCritical(env,target,uTarget,0); - }else{ - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - } - (*env)->ReleasePrimitiveArrayCritical(env,source,(jchar*)uSource,0); - }else{ - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - } - (*env)->ReleasePrimitiveArrayCritical(env,data,(jint*)myData,0); - return errorCode; - } - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - return errorCode; -} - -static jint encode(JNIEnv *env, jclass jClass, jlong handle, jcharArray source, jint sourceEnd, jbyteArray target, jint targetEnd, jintArray data, jboolean flush) { - - UErrorCode ec = convertCharToByte(env,jClass,handle,source,sourceEnd, target,targetEnd,data,flush); - UConverter* cnv = (UConverter*)handle; - jint* myData = (jint*) (*env)->GetPrimitiveArrayCritical(env,data,NULL); - - if(cnv && myData) { - - UErrorCode errorCode = U_ZERO_ERROR; - myData[3] = ucnv_fromUCountPending(cnv, &errorCode); - - if(ec == U_ILLEGAL_CHAR_FOUND || ec == U_INVALID_CHAR_FOUND) { - int8_t count =32; - UChar invalidUChars[32]; - ucnv_getInvalidUChars(cnv,invalidUChars,&count,&errorCode); - - if(U_SUCCESS(errorCode)) { - myData[2] = count; - } - } - } - (*env)->ReleasePrimitiveArrayCritical(env,data,(jint*)myData,0); - return ec; -} - -/** - * Converts a buffer of encoded bytes to Unicode code units - * @param env environment handle for JNI - * @param jClass handle for the class - * @param handle address of ICU converter - * @param source buffer of Unicode chars to convert - * @param sourceEnd limit of the source buffer - * @param target buffer to recieve the converted bytes - * @param targetEnd the limit of the target buffer - * @param data buffer to recieve state of the current conversion - * @param flush boolean that specifies end of source input - */ -static jint convertByteToChar(JNIEnv *env, jclass jClass, jlong handle, jbyteArray source, jint sourceEnd, jcharArray target, jint targetEnd, jintArray data, jboolean flush) { - - UErrorCode errorCode =U_ZERO_ERROR; - UConverter* cnv = (UConverter*)handle; - if(cnv) { - jint* myData = (jint*) (*env)->GetPrimitiveArrayCritical(env,data,NULL); - if(myData) { - jint* sourceOffset = &myData[0]; - jint* targetOffset = &myData[1]; - - const jbyte* uSource =(jbyte*) (*env)->GetPrimitiveArrayCritical(env,source, NULL); - if(uSource) { - jchar* uTarget=(jchar*) (*env)->GetPrimitiveArrayCritical(env,target,NULL); - if(uTarget) { - const jbyte* mySource = uSource+ *sourceOffset; - const char* mySourceLimit= uSource+sourceEnd; - UChar* cTarget=uTarget+ *targetOffset; - const UChar* cTargetLimit=uTarget+targetEnd; - - ucnv_toUnicode( cnv , &cTarget, cTargetLimit,(const char**)&mySource, - mySourceLimit,NULL,(UBool) flush, &errorCode); - - *sourceOffset = mySource - uSource - *sourceOffset ; - *targetOffset = cTarget - uTarget - *targetOffset; - if(U_FAILURE(errorCode)) { - (*env)->ReleasePrimitiveArrayCritical(env,target,uTarget,0); - (*env)->ReleasePrimitiveArrayCritical(env,source,(jchar*)uSource,0); - (*env)->ReleasePrimitiveArrayCritical(env,data,(jint*)myData,0); - return errorCode; - } - }else{ - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - } - (*env)->ReleasePrimitiveArrayCritical(env,target,uTarget,0); - }else{ - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - } - (*env)->ReleasePrimitiveArrayCritical(env,source,(jchar*)uSource,0); - }else{ - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - } - (*env)->ReleasePrimitiveArrayCritical(env,data,(jint*)myData,0); - return errorCode; - } - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - return errorCode; -} - -static jint decode(JNIEnv *env, jclass jClass, jlong handle, jbyteArray source, jint sourceEnd, jcharArray target, jint targetEnd, jintArray data, jboolean flush) { - - jint ec = convertByteToChar(env, jClass,handle,source,sourceEnd, target,targetEnd,data,flush); - - jint* myData = (jint*) (*env)->GetPrimitiveArrayCritical(env,data,NULL); - UConverter* cnv = (UConverter*)handle; - - if(myData && cnv) { - UErrorCode errorCode = U_ZERO_ERROR; - myData[3] = ucnv_toUCountPending(cnv, &errorCode); - - if(ec == U_ILLEGAL_CHAR_FOUND || ec == U_INVALID_CHAR_FOUND ) { - char invalidChars[32] = {'\0'}; - int8_t len = 32; - ucnv_getInvalidChars(cnv,invalidChars,&len,&errorCode); - - if(U_SUCCESS(errorCode)) { - myData[2] = len; - } - } - } - (*env)->ReleasePrimitiveArrayCritical(env,data,(jint*)myData,0); - return ec; -} -static void resetByteToChar(JNIEnv *env, jclass jClass, jlong handle) { - - UConverter* cnv = (UConverter*)handle; - if(cnv) { - ucnv_resetToUnicode(cnv); - } -} - -static void resetCharToByte(JNIEnv *env, jclass jClass, jlong handle) { - - UConverter* cnv = (UConverter*)handle; - if(cnv) { - ucnv_resetFromUnicode(cnv); - } - -} - -static jint countInvalidBytes (JNIEnv *env, jclass jClass, jlong handle, jintArray length) { - - UConverter* cnv = (UConverter*)handle; - UErrorCode errorCode = U_ZERO_ERROR; - if(cnv) { - char invalidChars[32]; - - jint* len = (jint*) (*env)->GetPrimitiveArrayCritical(env,length, NULL); - if(len) { - ucnv_getInvalidChars(cnv,invalidChars,(int8_t*)len,&errorCode); - } - (*env)->ReleasePrimitiveArrayCritical(env,length,(jint*)len,0); - return errorCode; - } - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - return errorCode; - -} - - -static jint countInvalidChars(JNIEnv *env, jclass jClass, jlong handle, jintArray length) { - - UErrorCode errorCode =U_ZERO_ERROR; - UConverter* cnv = (UConverter*)handle; - UChar invalidUChars[32]; - if(cnv) { - jint* len = (jint*) (*env)->GetPrimitiveArrayCritical(env,length, NULL); - if(len) { - ucnv_getInvalidUChars(cnv,invalidUChars,(int8_t*)len,&errorCode); - } - (*env)->ReleasePrimitiveArrayCritical(env,length,(jint*)len,0); - return errorCode; - } - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - return errorCode; - -} - -static jint getMaxBytesPerChar(JNIEnv *env, jclass jClass, jlong handle) { - - UConverter* cnv = (UConverter*)handle; - if(cnv) { - return (jint)ucnv_getMaxCharSize(cnv); - } - return -1; -} - -static jint getMinBytesPerChar(JNIEnv *env, jclass jClass, jlong handle) { - - UConverter* cnv = (UConverter*)handle; - if(cnv) { - return (jint)ucnv_getMinCharSize(cnv); - } - return -1; -} -static jfloat getAveBytesPerChar(JNIEnv *env, jclass jClass, jlong handle) { - - UConverter* cnv = (UConverter*)handle; - if(cnv) { - jfloat max = (jfloat)ucnv_getMaxCharSize(cnv); - jfloat min = (jfloat)ucnv_getMinCharSize(cnv); - return (jfloat) ( (max+min)/2 ); - } - return -1; -} -static jint flushByteToChar(JNIEnv *env, jclass jClass,jlong handle, jcharArray target, jint targetEnd, jintArray data) { - - UErrorCode errorCode =U_ZERO_ERROR; - UConverter* cnv = (UConverter*)handle; - if(cnv) { - jbyte source ='\0'; - jint* myData = (jint*) (*env)->GetPrimitiveArrayCritical(env,data,NULL); - if(myData) { - jint* targetOffset = &myData[1]; - jchar* uTarget=(jchar*) (*env)->GetPrimitiveArrayCritical(env,target,NULL); - if(uTarget) { - const jbyte* mySource =&source; - const char* mySourceLimit=&source; - UChar* cTarget=uTarget+ *targetOffset; - const UChar* cTargetLimit=uTarget+targetEnd; - - ucnv_toUnicode( cnv , &cTarget, cTargetLimit,(const char**)&mySource, - mySourceLimit,NULL,TRUE, &errorCode); - - - *targetOffset = (jint) ((jchar*)cTarget - uTarget)- *targetOffset; - if(U_FAILURE(errorCode)) { - (*env)->ReleasePrimitiveArrayCritical(env,target,uTarget,0); - (*env)->ReleasePrimitiveArrayCritical(env,data,(jint*)myData,0); - return errorCode; - } - }else{ - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - } - (*env)->ReleasePrimitiveArrayCritical(env,target,uTarget,0); - - }else{ - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - } - (*env)->ReleasePrimitiveArrayCritical(env,data,(jint*)myData,0); - return errorCode; - } - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - return errorCode; -} - -static jint flushCharToByte (JNIEnv *env, jclass jClass, jlong handle, jbyteArray target, jint targetEnd, jintArray data) { - - UErrorCode errorCode =U_ZERO_ERROR; - UConverter* cnv = (UConverter*)handle; - jchar source = '\0'; - if(cnv) { - jint* myData = (jint*) (*env)->GetPrimitiveArrayCritical(env,data,NULL); - if(myData) { - jint* targetOffset = &myData[1]; - jbyte* uTarget=(jbyte*) (*env)->GetPrimitiveArrayCritical(env,target,NULL); - if(uTarget) { - const jchar* mySource = &source; - const UChar* mySourceLimit= &source; - char* cTarget=uTarget+ *targetOffset; - const char* cTargetLimit=uTarget+targetEnd; - - ucnv_fromUnicode( cnv , &cTarget, cTargetLimit,&mySource, - mySourceLimit,NULL,TRUE, &errorCode); - - - *targetOffset = (jint) ((jbyte*)cTarget - uTarget)- *targetOffset; - if(U_FAILURE(errorCode)) { - (*env)->ReleasePrimitiveArrayCritical(env,target,uTarget,0); - - (*env)->ReleasePrimitiveArrayCritical(env,data,(jint*)myData,0); - return errorCode; - } - }else{ - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - } - (*env)->ReleasePrimitiveArrayCritical(env,target,uTarget,0); - }else{ - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - } - (*env)->ReleasePrimitiveArrayCritical(env,data,(jint*)myData,0); - return errorCode; - } - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - return errorCode; -} - -void toChars(const UChar* us, char* cs, int32_t length) { - UChar u; - while(length>0) { - u=*us++; - *cs++=(char)u; - --length; - } -} -static jint setSubstitutionBytes(JNIEnv *env, jclass jClass, jlong handle, jbyteArray subChars, jint length) { - - UConverter* cnv = (UConverter*) handle; - UErrorCode errorCode = U_ZERO_ERROR; - if(cnv) { - jbyte* u_subChars = (*env)->GetPrimitiveArrayCritical(env,subChars,NULL); - if(u_subChars) { - char* mySubChars= (char*)malloc(sizeof(char)*length); - toChars((UChar*)u_subChars,&mySubChars[0],length); - ucnv_setSubstChars(cnv,mySubChars, (char)length,&errorCode); - if(U_FAILURE(errorCode)) { - (*env)->ReleasePrimitiveArrayCritical(env,subChars,mySubChars,0); - return errorCode; - } - free(mySubChars); - } - else{ - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - } - (*env)->ReleasePrimitiveArrayCritical(env,subChars,u_subChars,0); - return errorCode; - } - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - return errorCode; -} - - -#define VALUE_STRING_LENGTH 32 - -typedef struct{ - int length; - UChar subChars[256]; - UBool stopOnIllegal; -}SubCharStruct; - - -static UErrorCode -setToUCallbackSubs(UConverter* cnv,UChar* subChars, int32_t length,UBool stopOnIllegal ) { - SubCharStruct* substitutionCharS = (SubCharStruct*) malloc(sizeof(SubCharStruct)); - UErrorCode errorCode = U_ZERO_ERROR; - if(substitutionCharS) { - UConverterToUCallback toUOldAction; - void* toUOldContext=NULL; - void* toUNewContext=NULL ; - if(subChars) { - u_strncpy(substitutionCharS->subChars,subChars,length); - }else{ - substitutionCharS->subChars[length++] =0xFFFD; - } - substitutionCharS->subChars[length]=0; - substitutionCharS->length = length; - substitutionCharS->stopOnIllegal = stopOnIllegal; - toUNewContext = substitutionCharS; - - ucnv_setToUCallBack(cnv, - JNI_TO_U_CALLBACK_SUBSTITUTE, - toUNewContext, - &toUOldAction, - (const void**)&toUOldContext, - &errorCode); - - if(toUOldContext) { - SubCharStruct* temp = (SubCharStruct*) toUOldContext; - free(temp); - } - - return errorCode; - } - return U_MEMORY_ALLOCATION_ERROR; -} -static jint setSubstitutionChars(JNIEnv *env, jclass jClass, jlong handle, jcharArray subChars, jint length) { - - UErrorCode errorCode = U_ZERO_ERROR; - UConverter* cnv = (UConverter*) handle; - jchar* u_subChars=NULL; - if(cnv) { - if(subChars) { - int len = (*env)->GetArrayLength(env,subChars); - u_subChars = (*env)->GetPrimitiveArrayCritical(env,subChars,NULL); - if(u_subChars) { - errorCode = setToUCallbackSubs(cnv,u_subChars,len,FALSE); - }else{ - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - } - (*env)->ReleasePrimitiveArrayCritical(env,subChars,u_subChars,0); - return errorCode; - } - } - return U_ILLEGAL_ARGUMENT_ERROR; -} - - -void JNI_TO_U_CALLBACK_SUBSTITUTE( const void *context, UConverterToUnicodeArgs *toArgs, const char* codeUnits, int32_t length, UConverterCallbackReason reason, UErrorCode * err) { - - if(context) { - SubCharStruct* temp = (SubCharStruct*)context; - if( temp) { - if(temp->stopOnIllegal==FALSE) { - if (reason > UCNV_IRREGULAR) { - return; - } - /* reset the error */ - *err = U_ZERO_ERROR; - ucnv_cbToUWriteUChars(toArgs,temp->subChars ,temp->length , 0, err); - }else{ - if(reason != UCNV_UNASSIGNED) { - /* the caller must have set - * the error code accordingly - */ - return; - }else{ - *err = U_ZERO_ERROR; - ucnv_cbToUWriteUChars(toArgs,temp->subChars ,temp->length , 0, err); - return; - } - } - } - } - return; -} - -static jboolean canEncode(JNIEnv *env, jclass jClass, jlong handle, jint codeUnit) { - - UErrorCode errorCode =U_ZERO_ERROR; - UConverter* cnv = (UConverter*)handle; - if(cnv) { - UChar source[3]; - UChar *mySource=source; - const UChar* sourceLimit = (codeUnit<0x010000) ? &source[1] : &source[2]; - char target[5]; - char *myTarget = target; - const char* targetLimit = &target[4]; - int i=0; - UTF_APPEND_CHAR(&source[0],i,2,codeUnit); - - ucnv_fromUnicode(cnv,&myTarget,targetLimit, - (const UChar**)&mySource, - sourceLimit,NULL, TRUE,&errorCode); - - if(U_SUCCESS(errorCode)) { - return (jboolean)TRUE; - } - } - return (jboolean)FALSE; -} - - -static jboolean canDecode(JNIEnv *env, jclass jClass, jlong handle, jbyteArray source) { - - UErrorCode errorCode =U_ZERO_ERROR; - UConverter* cnv = (UConverter*)handle; - if(cnv) { - jint len = (*env)->GetArrayLength(env,source); - jbyte* cSource =(jbyte*) (*env)->GetPrimitiveArrayCritical(env,source, NULL); - if(cSource) { - const jbyte* cSourceLimit = cSource+len; - - /* Assume that we need at most twice the length of source */ - UChar* target = (UChar*) malloc(sizeof(UChar)* (len<<1)); - UChar* targetLimit = target + (len<<1); - if(target) { - ucnv_toUnicode(cnv,&target,targetLimit, - (const char**)&cSource, - cSourceLimit,NULL, TRUE,&errorCode); - - if(U_SUCCESS(errorCode)) { - free(target); - (*env)->ReleasePrimitiveArrayCritical(env,source,cSource,0); - return (jboolean)TRUE; - } - } - free(target); - } - (*env)->ReleasePrimitiveArrayCritical(env,source,cSource,0); - } - return (jboolean)FALSE; -} - -static jint countAvailable(JNIEnv *env, jclass jClass) { - return ucnv_countAvailable(); -} - -int32_t copyString(char* dest, int32_t destCapacity, int32_t startIndex, - const char* src, UErrorCode* status) { - int32_t srcLen = 0, i=0; - if(U_FAILURE(*status)) { - return 0; - } - if(dest == NULL || src == NULL || destCapacity < startIndex) { - *status = U_ILLEGAL_ARGUMENT_ERROR; - return 0; - } - srcLen = strlen(src); - if(srcLen >= destCapacity) { - *status = U_BUFFER_OVERFLOW_ERROR; - return 0; - } - for(i=0; i < srcLen; i++) { - dest[startIndex++] = src[i]; - } - /* null terminate the buffer */ - dest[startIndex] = 0; /* no bounds check already made sure that we have enough room */ - return startIndex; -} - -int32_t getJavaCanonicalName1(const char* icuCanonicalName, - char* canonicalName, int32_t capacity, - UErrorCode* status) { - /* - If a charset listed in the IANA Charset Registry is supported by an implementation - of the Java platform then its canonical name must be the name listed in the registry. - Many charsets are given more than one name in the registry, in which case the registry - identifies one of the names as MIME-preferred. If a charset has more than one registry - name then its canonical name must be the MIME-preferred name and the other names in - the registry must be valid aliases. If a supported charset is not listed in the IANA - registry then its canonical name must begin with one of the strings "X-" or "x-". - */ - int32_t retLen = 0; - const char* cName = NULL; - /* find out the alias with MIME tag */ - if((cName =ucnv_getStandardName(icuCanonicalName, "MIME", status)) != NULL) { - retLen = copyString(canonicalName, capacity, 0, cName, status); - /* find out the alias with IANA tag */ - }else if((cName =ucnv_getStandardName(icuCanonicalName, "IANA", status)) != NULL) { - retLen = copyString(canonicalName, capacity, 0, cName, status); - }else { - /* - check to see if an alias already exists with x- prefix, if yes then - make that the canonical name - */ - int32_t aliasNum = ucnv_countAliases(icuCanonicalName,status); - int32_t i=0; - const char* name; - for(i=0;i= 2) { - strcpy(canonicalName,"x-"); - } - retLen = copyString(canonicalName, capacity, 2, name, status); - } - } - return retLen; -} - -static jobjectArray getAvailable(JNIEnv *env, jclass jClass) { - - jobjectArray ret; - int32_t i = 0; - int32_t num = ucnv_countAvailable(); - UErrorCode error = U_ZERO_ERROR; - const char* name =NULL; - char canonicalName[256]={0}; - ret= (jobjectArray)(*env)->NewObjectArray( env,num, - (*env)->FindClass(env,"java/lang/String"), - (*env)->NewStringUTF(env,"")); - - for(i=0;iNewStringUTF(env,canonicalName); - (*env)->SetObjectArrayElement(env,ret,i,canonName); - (*env)->DeleteLocalRef(env, canonName); - // END android-changed - /*printf("canonical name : %s at %i\n", name,i); */ - canonicalName[0]='\0';/* nul terminate */ - } - return (ret); -} - -static jint countAliases(JNIEnv *env, jclass jClass,jstring enc) { - - UErrorCode error = U_ZERO_ERROR; - jint num =0; - const char* encName = (*env)->GetStringUTFChars(env,enc,NULL); - - if(encName) { - num = ucnv_countAliases(encName,&error); - } - - (*env)->ReleaseStringUTFChars(env,enc,encName); - - return num; -} - - -static jobjectArray getAliases(JNIEnv *env, jclass jClass, jstring enc) { - - jobjectArray ret=NULL; - int32_t aliasNum = 0; - UErrorCode error = U_ZERO_ERROR; - const char* encName = (*env)->GetStringUTFChars(env,enc,NULL); - int i=0; - int j=0; - const char* aliasArray[50]; - // BEGIN android-removed - // int32_t utf16AliasNum = 0; - // END android-removed - - - if(encName) { - const char* myEncName = encName; - aliasNum = ucnv_countAliases(myEncName,&error); - - // BEGIN android-removed - // /* special case for UTF-16. In java UTF-16 is always BE*/ - // if(strcmp(myEncName, UTF_16BE)==0) { - // utf16AliasNum=ucnv_countAliases(UTF_16,&error); - // } - // END android-removed - - if(aliasNum==0 && encName[0] == 0x78 /*x*/ && encName[1]== 0x2d /*-*/) { - myEncName = encName+2; - aliasNum = ucnv_countAliases(myEncName,&error); - } - if(U_SUCCESS(error)) { - for(i=0,j=0;i0) { - // for(i=0;iNewObjectArray(env,j, - (*env)->FindClass(env,"java/lang/String"), - (*env)->NewStringUTF(env,"")); - for(;--j>=0;) { - // BEGIN android-changed - jstring alias = (*env)->NewStringUTF(env, aliasArray[j]); - (*env)->SetObjectArrayElement(env, ret, j, alias); - (*env)->DeleteLocalRef(env, alias); - // END android-changed - } - } - } - (*env)->ReleaseStringUTFChars(env,enc,encName); - - return (ret); -} - -static jstring getCanonicalName(JNIEnv *env, jclass jClass,jstring enc) { - - UErrorCode error = U_ZERO_ERROR; - const char* encName = (*env)->GetStringUTFChars(env,enc,NULL); - const char* canonicalName = ""; - // BEGIN android-changed - jstring ret = NULL; - if(encName) { - canonicalName = ucnv_getAlias(encName,0,&error); - if(canonicalName !=NULL && strstr(canonicalName,",")!=0) { - canonicalName = ucnv_getAlias(canonicalName,1,&error); - } - ret = ((*env)->NewStringUTF(env, canonicalName)); - (*env)->ReleaseStringUTFChars(env,enc,encName); - } - // END android-changed - return ret; -} - -static jstring getICUCanonicalName(JNIEnv *env, jclass jClass, jstring enc) { - - UErrorCode error = U_ZERO_ERROR; - const char* encName = (*env)->GetStringUTFChars(env,enc,NULL); - const char* canonicalName = NULL; - jstring ret = NULL; - if(encName) { - // BEGIN android-removed - // if(strcmp(encName,"UTF-16")==0) { - // ret = ((*env)->NewStringUTF(env,UTF_16BE)); - // }else - // END android-removed - if((canonicalName = ucnv_getCanonicalName(encName, "MIME", &error))!=NULL) { - ret = ((*env)->NewStringUTF(env, canonicalName)); - }else if((canonicalName = ucnv_getCanonicalName(encName, "IANA", &error))!=NULL) { - ret = ((*env)->NewStringUTF(env, canonicalName)); - }else if((canonicalName = ucnv_getCanonicalName(encName, "", &error))!=NULL) { - ret = ((*env)->NewStringUTF(env, canonicalName)); - }else if((canonicalName = ucnv_getAlias(encName, 0, &error)) != NULL) { - /* we have some aliases in the form x-blah .. match those first */ - ret = ((*env)->NewStringUTF(env, canonicalName)); - }else if( ret ==NULL && strstr(encName, "x-") == encName) { - /* check if the converter can be opened with the encName given */ - UConverter* conv = NULL; - error = U_ZERO_ERROR; - conv = ucnv_open(encName+2, &error); - if(conv!=NULL) { - ret = ((*env)->NewStringUTF(env, encName+2)); - }else{ - /* unsupported encoding */ - ret = ((*env)->NewStringUTF(env, "")); - } - ucnv_close(conv); - }else{ - /* unsupported encoding */ - ret = ((*env)->NewStringUTF(env, "")); - } - } - (*env)->ReleaseStringUTFChars(env,enc,encName); - return ret; -} - -static jstring getJavaCanonicalName2(JNIEnv *env, jclass jClass, jstring icuCanonName) { - /* - If a charset listed in the IANA Charset Registry is supported by an implementation - of the Java platform then its canonical name must be the name listed in the registry. - Many charsets are given more than one name in the registry, in which case the registry - identifies one of the names as MIME-preferred. If a charset has more than one registry - name then its canonical name must be the MIME-preferred name and the other names in - the registry must be valid aliases. If a supported charset is not listed in the IANA - registry then its canonical name must begin with one of the strings "X-" or "x-". - */ - UErrorCode error = U_ZERO_ERROR; - const char* icuCanonicalName = (*env)->GetStringUTFChars(env,icuCanonName,NULL); - char cName[UCNV_MAX_CONVERTER_NAME_LENGTH] = {0}; - jstring ret; - if(icuCanonicalName && icuCanonicalName[0] != 0) { - getJavaCanonicalName1(icuCanonicalName, cName, UCNV_MAX_CONVERTER_NAME_LENGTH, &error); - } - ret = ((*env)->NewStringUTF(env, cName)); - (*env)->ReleaseStringUTFChars(env,icuCanonName,icuCanonicalName); - return ret; -} - -#define SUBS_ARRAY_CAPACITY 256 -typedef struct{ - int length; - char subChars[SUBS_ARRAY_CAPACITY]; - UConverterFromUCallback onUnmappableInput; - UConverterFromUCallback onMalformedInput; -}EncoderCallbackContext; - -void CHARSET_ENCODER_CALLBACK(const void *context, - UConverterFromUnicodeArgs *fromArgs, - const UChar* codeUnits, - int32_t length, - UChar32 codePoint, - UConverterCallbackReason reason, - UErrorCode * status) { - if(context) { - EncoderCallbackContext* ctx = (EncoderCallbackContext*)context; - - if(ctx) { - UConverterFromUCallback realCB = NULL; - switch(reason) { - case UCNV_UNASSIGNED: - realCB = ctx->onUnmappableInput; - break; - case UCNV_ILLEGAL:/*malformed input*/ - case UCNV_IRREGULAR:/*malformed input*/ - realCB = ctx->onMalformedInput; - break; - /* - case UCNV_RESET: - ucnv_resetToUnicode(args->converter); - break; - case UCNV_CLOSE: - ucnv_close(args->converter); - break; - case UCNV_CLONE: - ucnv_clone(args->clone); - */ - default: - *status = U_ILLEGAL_ARGUMENT_ERROR; - return; - } - if(realCB==NULL) { - *status = U_INTERNAL_PROGRAM_ERROR; - } - realCB(context, fromArgs, codeUnits, length, codePoint, reason, status); - } - } -} - -void JNI_FROM_U_CALLBACK_SUBSTITUTE_ENCODER(const void *context, - UConverterFromUnicodeArgs *fromArgs, - const UChar* codeUnits, - int32_t length, - UChar32 codePoint, - UConverterCallbackReason reason, - UErrorCode * err) { - if(context) { - EncoderCallbackContext* temp = (EncoderCallbackContext*)context; - *err = U_ZERO_ERROR; - ucnv_cbFromUWriteBytes(fromArgs,temp->subChars ,temp->length , 0, err); - } - return; -} - -UConverterFromUCallback getFromUCallback(int32_t mode) { - switch(mode) { - default: /* falls through */ - case com_ibm_icu4jni_converters_NativeConverter_STOP_CALLBACK: - return UCNV_FROM_U_CALLBACK_STOP; - case com_ibm_icu4jni_converters_NativeConverter_SKIP_CALLBACK: - return UCNV_FROM_U_CALLBACK_SKIP ; - case com_ibm_icu4jni_converters_NativeConverter_SUBSTITUTE_CALLBACK: - return JNI_FROM_U_CALLBACK_SUBSTITUTE_ENCODER; - } -} - -static jint setCallbackEncode(JNIEnv *env, jclass jClass, jlong handle, jint onMalformedInput, jint onUnmappableInput, jbyteArray subChars, jint length) { - - UConverter* conv = (UConverter*)handle; - UErrorCode errorCode =U_ZERO_ERROR; - - if(conv) { - - UConverterFromUCallback fromUOldAction = NULL; - void* fromUOldContext = NULL; - EncoderCallbackContext* fromUNewContext=NULL; - UConverterFromUCallback fromUNewAction=NULL; - jbyte* sub = (jbyte*) (*env)->GetPrimitiveArrayCritical(env,subChars, NULL); - ucnv_getFromUCallBack(conv, &fromUOldAction, &fromUOldContext); - - /* fromUOldContext can only be DecodeCallbackContext since - the converter created is private data for the decoder - and callbacks can only be set via this method! - */ - if(fromUOldContext==NULL) { - fromUNewContext = (EncoderCallbackContext*) malloc(sizeof(EncoderCallbackContext)); - fromUNewAction = CHARSET_ENCODER_CALLBACK; - }else{ - fromUNewContext = fromUOldContext; - fromUNewAction = fromUOldAction; - fromUOldAction = NULL; - fromUOldContext = NULL; - } - fromUNewContext->onMalformedInput = getFromUCallback(onMalformedInput); - fromUNewContext->onUnmappableInput = getFromUCallback(onUnmappableInput); - // BEGIN android-changed - if(sub!=NULL) { - fromUNewContext->length = length; - strncpy(fromUNewContext->subChars, sub, length); - (*env)->ReleasePrimitiveArrayCritical(env,subChars, sub, 0); - }else{ - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - } - // END android-changed - - ucnv_setFromUCallBack(conv, - fromUNewAction, - fromUNewContext, - &fromUOldAction, - (const void**)&fromUOldContext, - &errorCode); - - - return errorCode; - } - return U_ILLEGAL_ARGUMENT_ERROR; -} - -typedef struct{ - int length; - UChar subUChars[256]; - UConverterToUCallback onUnmappableInput; - UConverterToUCallback onMalformedInput; -}DecoderCallbackContext; - -void JNI_TO_U_CALLBACK_SUBSTITUTE_DECODER(const void *context, - UConverterToUnicodeArgs *toArgs, - const char* codeUnits, - int32_t length, - UConverterCallbackReason reason, - UErrorCode * err) { - if(context) { - DecoderCallbackContext* temp = (DecoderCallbackContext*)context; - *err = U_ZERO_ERROR; - ucnv_cbToUWriteUChars(toArgs,temp->subUChars ,temp->length , 0, err); - } - return; -} - -UConverterToUCallback getToUCallback(int32_t mode) { - switch(mode) { - default: /* falls through */ - case com_ibm_icu4jni_converters_NativeConverter_STOP_CALLBACK: - return UCNV_TO_U_CALLBACK_STOP; - case com_ibm_icu4jni_converters_NativeConverter_SKIP_CALLBACK: - return UCNV_TO_U_CALLBACK_SKIP ; - case com_ibm_icu4jni_converters_NativeConverter_SUBSTITUTE_CALLBACK: - return JNI_TO_U_CALLBACK_SUBSTITUTE_DECODER; - } -} - -void CHARSET_DECODER_CALLBACK(const void *context, - UConverterToUnicodeArgs *args, - const char* codeUnits, - int32_t length, - UConverterCallbackReason reason, - UErrorCode *status ) { - - if(context) { - DecoderCallbackContext* ctx = (DecoderCallbackContext*)context; - - if(ctx) { - UConverterToUCallback realCB = NULL; - switch(reason) { - case UCNV_UNASSIGNED: - realCB = ctx->onUnmappableInput; - break; - case UCNV_ILLEGAL:/*malformed input*/ - case UCNV_IRREGULAR:/*malformed input*/ - realCB = ctx->onMalformedInput; - break; - /* - case UCNV_RESET: - ucnv_resetToUnicode(args->converter); - break; - case UCNV_CLOSE: - ucnv_close(args->converter); - break; - case UCNV_CLONE: - ucnv_clone(args->clone); - */ - default: - *status = U_ILLEGAL_ARGUMENT_ERROR; - return; - } - if(realCB==NULL) { - *status = U_INTERNAL_PROGRAM_ERROR; - } - realCB(context, args, codeUnits, length, reason, status); - } - } -} - -static jint setCallbackDecode(JNIEnv *env, jclass jClass, jlong handle, jint onMalformedInput, jint onUnmappableInput, jcharArray subChars, jint length) { - - UConverter* conv = (UConverter*)handle; - UErrorCode errorCode =U_ZERO_ERROR; - if(conv) { - - UConverterToUCallback toUOldAction ; - void* toUOldContext; - DecoderCallbackContext* toUNewContext = NULL; - UConverterToUCallback toUNewAction = NULL; - jchar* sub = (jchar*) (*env)->GetPrimitiveArrayCritical(env,subChars, NULL); - - ucnv_getToUCallBack(conv, &toUOldAction, &toUOldContext); - - /* toUOldContext can only be DecodeCallbackContext since - the converter created is private data for the decoder - and callbacks can only be set via this method! - */ - if(toUOldContext==NULL) { - toUNewContext = (DecoderCallbackContext*) malloc(sizeof(DecoderCallbackContext)); - toUNewAction = CHARSET_DECODER_CALLBACK; - }else{ - toUNewContext = toUOldContext; - toUNewAction = toUOldAction; - toUOldAction = NULL; - toUOldContext = NULL; - } - toUNewContext->onMalformedInput = getToUCallback(onMalformedInput); - toUNewContext->onUnmappableInput = getToUCallback(onUnmappableInput); - // BEGIN android-changed - if(sub!=NULL) { - toUNewContext->length = length; - u_strncpy(toUNewContext->subUChars, sub, length); - (*env)->ReleasePrimitiveArrayCritical(env,subChars, sub, 0); - }else{ - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - } - // END android-changed - ucnv_setToUCallBack(conv, - toUNewAction, - toUNewContext, - &toUOldAction, - (const void**)&toUOldContext, - &errorCode); - - return errorCode; - } - return U_ILLEGAL_ARGUMENT_ERROR; -} - -static jlong safeClone(JNIEnv *env, jclass jClass, jlong src) { - - UErrorCode status = U_ZERO_ERROR; - - jint buffersize = U_CNV_SAFECLONE_BUFFERSIZE; - - UConverter* conv=NULL; - UErrorCode errorCode = U_ZERO_ERROR; - UConverter* source = (UConverter*) src; - - if(source) { - conv = ucnv_safeClone(source, NULL, &buffersize, &errorCode); - } - - if (icu4jni_error(env, errorCode) != FALSE) { - return NULL; - } - - return conv; -} - -static jint getMaxCharsPerByte(JNIEnv *env, jclass jClass, jlong handle) { - /* - * currently we know that max number of chars per byte is 2 - */ - return 2; -} - -static jfloat getAveCharsPerByte(JNIEnv *env, jclass jClass, jlong handle) { - jfloat ret = 0; - ret = (jfloat)( 1/(jfloat)getMaxBytesPerChar(env, jClass, handle)); - return ret; -} - -void toUChars(const char* cs, UChar* us, int32_t length) { - char c; - while(length>0) { - c=*cs++; - *us++=(char)c; - --length; - } -} - -static jbyteArray getSubstitutionBytes(JNIEnv *env, jclass jClass, jlong handle) { - - const UConverter * cnv = (const UConverter *) handle; - UErrorCode status = U_ZERO_ERROR; - char subBytes[10]; - int8_t len =(char)10; - jbyteArray arr; - if(cnv) { - ucnv_getSubstChars(cnv,subBytes,&len,&status); - if(U_SUCCESS(status)) { - arr = ((*env)->NewByteArray(env, len)); - if(arr) { - (*env)->SetByteArrayRegion(env,arr,0,len,(jbyte*)subBytes); - } - return arr; - } - } - return ((*env)->NewByteArray(env, 0)); -} - -static jboolean contains( JNIEnv *env, jclass jClass, jlong handle1, jlong handle2) { - UErrorCode status = U_ZERO_ERROR; - const UConverter * cnv1 = (const UConverter *) handle1; - const UConverter * cnv2 = (const UConverter *) handle2; - USet* set1; - USet* set2; - UBool bRet = 0; - - if(cnv1 != NULL && cnv2 != NULL) { - /* open charset 1 */ - set1 = uset_open(1, 2); - ucnv_getUnicodeSet(cnv1, set1, UCNV_ROUNDTRIP_SET, &status); - - if(U_SUCCESS(status)) { - /* open charset 2 */ - status = U_ZERO_ERROR; - set2 = uset_open(1, 2); - ucnv_getUnicodeSet(cnv2, set2, UCNV_ROUNDTRIP_SET, &status); - - /* contains? */ - if(U_SUCCESS(status)) { - bRet = uset_containsAll(set1, set2); - uset_close(set2); - } - uset_close(set1); - } - } - return bRet; -} - -/* - * JNI registration - */ -static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ - { "convertByteToChar", "(J[BI[CI[IZ)I", (void*) convertByteToChar }, - { "decode", "(J[BI[CI[IZ)I", (void*) decode }, - { "convertCharToByte", "(J[CI[BI[IZ)I", (void*) convertCharToByte }, - { "encode", "(J[CI[BI[IZ)I", (void*) encode }, - { "flushCharToByte", "(J[BI[I)I", (void*) flushCharToByte }, - { "flushByteToChar", "(J[CI[I)I", (void*) flushByteToChar }, - { "openConverter", "(Ljava/lang/String;)J", (void*) openConverter }, - { "resetByteToChar", "(J)V", (void*) resetByteToChar }, - { "resetCharToByte", "(J)V", (void*) resetCharToByte }, - { "closeConverter", "(J)V", (void*) closeConverter }, - { "setSubstitutionChars", "(J[CI)I", (void*) setSubstitutionChars }, - { "setSubstitutionBytes", "(J[BI)I", (void*) setSubstitutionBytes }, - { "setSubstitutionModeCharToByte", "(JZ)I", (void*) setSubstitutionModeCharToByte }, - { "setSubstitutionModeByteToChar", "(JZ)I", (void*) setSubstitutionModeByteToChar }, - { "countInvalidBytes", "(J[I)I", (void*) countInvalidBytes }, - { "countInvalidChars", "(J[I)I", (void*) countInvalidChars }, - { "getMaxBytesPerChar", "(J)I", (void*) getMaxBytesPerChar }, - { "getMinBytesPerChar", "(J)I", (void*) getMinBytesPerChar }, - { "getAveBytesPerChar", "(J)F", (void*) getAveBytesPerChar }, - { "getMaxCharsPerByte", "(J)I", (void*) getMaxCharsPerByte }, - { "getAveCharsPerByte", "(J)F", (void*) getAveCharsPerByte }, - { "contains", "(JJ)Z", (void*) contains }, - { "getSubstitutionBytes", "(J)[B", (void*) getSubstitutionBytes }, - { "canEncode", "(JI)Z", (void*) canEncode }, - { "canDecode", "(J[B)Z", (void*) canDecode }, - { "countAvailable", "()I", (void*) countAvailable }, - { "getAvailable", "()[Ljava/lang/String;", (void*) getAvailable }, - { "countAliases", "(Ljava/lang/String;)I", (void*) countAliases }, - { "getAliases", "(Ljava/lang/String;)[Ljava/lang/String;", (void*) getAliases }, - { "getCanonicalName", "(Ljava/lang/String;)Ljava/lang/String;", (void*) getCanonicalName }, - { "getICUCanonicalName", "(Ljava/lang/String;)Ljava/lang/String;", (void*) getICUCanonicalName }, - { "getJavaCanonicalName", "(Ljava/lang/String;)Ljava/lang/String;", (void*) getJavaCanonicalName2 }, - { "setCallbackDecode", "(JII[CI)I", (void*) setCallbackDecode }, - { "setCallbackEncode", "(JII[BI)I", (void*) setCallbackEncode }, - { "safeClone", "(J)J", (void*) safeClone } -}; - -int register_com_ibm_icu4jni_converters_NativeConverter(JNIEnv *_env) { - return jniRegisterNativeMethods(_env, "com/ibm/icu4jni/charset/NativeConverter", - gMethods, NELEM(gMethods)); -} - - diff --git a/libcore/icu/src/main/native/ConverterInterface.h b/libcore/icu/src/main/native/ConverterInterface.h deleted file mode 100644 index e9dbf6b99..000000000 --- a/libcore/icu/src/main/native/ConverterInterface.h +++ /dev/null @@ -1,299 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class com_ibm_icu4jni_converters_NativeConverter */ - -#ifndef _Included_com_ibm_icu4jni_converters_NativeConverter -#define _Included_com_ibm_icu4jni_converters_NativeConverter -#ifdef __cplusplus -extern "C" { -#endif -#undef com_ibm_icu4jni_converters_NativeConverter_STOP_CALLBACK -#define com_ibm_icu4jni_converters_NativeConverter_STOP_CALLBACK 0L -#undef com_ibm_icu4jni_converters_NativeConverter_SKIP_CALLBACK -#define com_ibm_icu4jni_converters_NativeConverter_SKIP_CALLBACK 1L -#undef com_ibm_icu4jni_converters_NativeConverter_SUBSTITUTE_CALLBACK -#define com_ibm_icu4jni_converters_NativeConverter_SUBSTITUTE_CALLBACK 2L -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: convertByteToChar - * Signature: (J[BI[CI[IZ)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_convertByteToChar - (JNIEnv *, jclass, jlong, jbyteArray, jint, jcharArray, jint, jintArray, jboolean); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: decode - * Signature: (J[BI[CI[IZ)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_decode - (JNIEnv *, jclass, jlong, jbyteArray, jint, jcharArray, jint, jintArray, jboolean); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: convertCharToByte - * Signature: (J[CI[BI[IZ)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_convertCharToByte - (JNIEnv *, jclass, jlong, jcharArray, jint, jbyteArray, jint, jintArray, jboolean); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: encode - * Signature: (J[CI[BI[IZ)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_encode - (JNIEnv *, jclass, jlong, jcharArray, jint, jbyteArray, jint, jintArray, jboolean); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: flushCharToByte - * Signature: (J[BI[I)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_flushCharToByte - (JNIEnv *, jclass, jlong, jbyteArray, jint, jintArray); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: flushByteToChar - * Signature: (J[CI[I)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_flushByteToChar - (JNIEnv *, jclass, jlong, jcharArray, jint, jintArray); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: openConverter - * Signature: ([JLjava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_openConverter - (JNIEnv *, jclass, jlongArray, jstring); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: resetByteToChar - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_resetByteToChar - (JNIEnv *, jclass, jlong); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: resetCharToByte - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_resetCharToByte - (JNIEnv *, jclass, jlong); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: closeConverter - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_closeConverter - (JNIEnv *, jclass, jlong); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: setSubstitutionChars - * Signature: (J[CI)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_setSubstitutionChars - (JNIEnv *, jclass, jlong, jcharArray, jint); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: setSubstitutionBytes - * Signature: (J[BI)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_setSubstitutionBytes - (JNIEnv *, jclass, jlong, jbyteArray, jint); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: setSubstitutionModeCharToByte - * Signature: (JZ)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_setSubstitutionModeCharToByte - (JNIEnv *, jclass, jlong, jboolean); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: setSubstitutionModeByteToChar - * Signature: (JZ)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_setSubstitutionModeByteToChar - (JNIEnv *, jclass, jlong, jboolean); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: countInvalidBytes - * Signature: (J[I)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_countInvalidBytes - (JNIEnv *, jclass, jlong, jintArray); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: countInvalidChars - * Signature: (J[I)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_countInvalidChars - (JNIEnv *, jclass, jlong, jintArray); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: getMaxBytesPerChar - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_getMaxBytesPerChar - (JNIEnv *, jclass, jlong); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: getMinBytesPerChar - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_getMinBytesPerChar - (JNIEnv *, jclass, jlong); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: getAveBytesPerChar - * Signature: (J)F - */ -JNIEXPORT jfloat JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_getAveBytesPerChar - (JNIEnv *, jclass, jlong); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: getMaxCharsPerByte - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_getMaxCharsPerByte - (JNIEnv *, jclass, jlong); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: getAveCharsPerByte - * Signature: (J)F - */ -JNIEXPORT jfloat JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_getAveCharsPerByte - (JNIEnv *, jclass, jlong); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: contains - * Signature: (JJ)Z - */ -JNIEXPORT jboolean JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_contains - (JNIEnv *, jclass, jlong, jlong); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: getSubstitutionBytes - * Signature: (J)[B - */ -JNIEXPORT jbyteArray JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_getSubstitutionBytes - (JNIEnv *, jclass, jlong); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: canEncode - * Signature: (JI)Z - */ -JNIEXPORT jboolean JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_canEncode - (JNIEnv *, jclass, jlong, jint); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: canDecode - * Signature: (J[B)Z - */ -JNIEXPORT jboolean JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_canDecode - (JNIEnv *, jclass, jlong, jbyteArray); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: countAvailable - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_countAvailable - (JNIEnv *, jclass); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: getAvailable - * Signature: ()[Ljava/lang/String; - */ -JNIEXPORT jobjectArray JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_getAvailable - (JNIEnv *, jclass); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: countAliases - * Signature: (Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_countAliases - (JNIEnv *, jclass, jstring); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: getAliases - * Signature: (Ljava/lang/String;)[Ljava/lang/String; - */ -JNIEXPORT jobjectArray JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_getAliases - (JNIEnv *, jclass, jstring); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: getCanonicalName - * Signature: (Ljava/lang/String;)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_getCanonicalName - (JNIEnv *, jclass, jstring); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: getICUCanonicalName - * Signature: (Ljava/lang/String;)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_getICUCanonicalName - (JNIEnv *, jclass, jstring); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: getJavaCanonicalName - * Signature: (Ljava/lang/String;)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_getJavaCanonicalName - (JNIEnv *, jclass, jstring); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: setCallbackDecode - * Signature: (JII[CI)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_setCallbackDecode - (JNIEnv *, jclass, jlong, jint, jint, jcharArray, jint); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: setCallbackEncode - * Signature: (JII[BI)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_setCallbackEncode - (JNIEnv *, jclass, jlong, jint, jint, jbyteArray, jint); - -/* - * Class: com_ibm_icu4jni_converters_NativeConverter - * Method: safeClone - * Signature: (J[J)I - */ -JNIEXPORT jint JNICALL Java_com_ibm_icu4jni_converters_NativeConverter_safeClone - (JNIEnv *, jclass, jlong, jlongArray); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/libcore/icu/src/main/native/DecimalFormatInterface.cpp b/libcore/icu/src/main/native/DecimalFormatInterface.cpp deleted file mode 100644 index 7e37d6cdc..000000000 --- a/libcore/icu/src/main/native/DecimalFormatInterface.cpp +++ /dev/null @@ -1,851 +0,0 @@ -/* - * Copyright 2006 The Android Open Source Project - * - * Internal native functions. All of the functions defined here make - * direct use of VM functions or data structures, so they can't be written - * with JNI and shouldn't really be in a shared library. - * - * All functions here either complete quickly or are used to enter a wait - * state, so we don't set the thread status to THREAD_NATIVE when executing - * these methods. This means that the GC will wait for these functions - * to finish. DO NOT perform long operations or blocking I/O in here. - * - * In some cases we're following the division of labor defined by GNU - * ClassPath, e.g. java.lang.Thread has "Thread" and "VMThread", with - * the VM-specific behavior isolated in VMThread. - */ - -#define LOG_TAG "DecimalFormatInterface" -#include "JNIHelp.h" -#include "AndroidSystemNatives.h" -#include "unicode/unum.h" -#include "unicode/numfmt.h" -#include "unicode/decimfmt.h" -#include "unicode/fmtable.h" -#include "unicode/ustring.h" -#include "digitlst.h" -#include "ErrorCode.h" -#include -#include -#include "cutils/log.h" - - -static UBool icuError(JNIEnv *env, UErrorCode errorcode) -{ - const char *emsg = u_errorName(errorcode); - jclass exception; - - if (U_FAILURE(errorcode)) {// errorcode > U_ZERO_ERROR && errorcode < U_ERROR_LIMIT) { - switch (errorcode) { - case U_ILLEGAL_ARGUMENT_ERROR : - exception = env->FindClass("java/lang/IllegalArgumentException"); - break; - case U_INDEX_OUTOFBOUNDS_ERROR : - case U_BUFFER_OVERFLOW_ERROR : - exception = env->FindClass("java/lang/ArrayIndexOutOfBoundsException"); - break; - case U_UNSUPPORTED_ERROR : - exception = env->FindClass("java/lang/UnsupportedOperationException"); - break; - default : - exception = env->FindClass("java/lang/RuntimeException"); - } - - return (env->ThrowNew(exception, emsg) != 0); - } - return 0; -} - -static jint openDecimalFormatImpl(JNIEnv *env, jclass clazz, jstring locale, - jstring pattern) { - - // the errorcode returned by unum_open - UErrorCode status = U_ZERO_ERROR; - - // prepare the pattern string for the call to unum_open - const UChar *pattChars = env->GetStringChars(pattern, NULL); - int pattLen = env->GetStringLength(pattern); - - // prepare the locale string for the call to unum_open - const char *localeChars = env->GetStringUTFChars(locale, NULL); - - // open a default type number format - UNumberFormat *fmt = unum_open(UNUM_PATTERN_DECIMAL, pattChars, pattLen, - localeChars, NULL, &status); - - // release the allocated strings - env->ReleaseStringChars(pattern, pattChars); - env->ReleaseStringUTFChars(locale, localeChars); - - // check for an error - if ( icuError(env, status) != FALSE) { - return 0; - } - - // return the handle to the number format - return (long) fmt; -} - -static void closeDecimalFormatImpl(JNIEnv *env, jclass clazz, jint addr) { - - // get the pointer to the number format - UNumberFormat *fmt = (UNumberFormat *)(int)addr; - - // close this number format - unum_close(fmt); -} - -static void setSymbol(JNIEnv *env, jclass clazz, jint addr, jint symbol, - jstring text) { - - // the errorcode returned by unum_setSymbol - UErrorCode status = U_ZERO_ERROR; - - // get the pointer to the number format - UNumberFormat *fmt = (UNumberFormat *)(int)addr; - - // prepare the symbol string for the call to unum_setSymbol - const UChar *textChars = env->GetStringChars(text, NULL); - int textLen = env->GetStringLength(text); - - // set the symbol - unum_setSymbol(fmt, (UNumberFormatSymbol) symbol, textChars, textLen, - &status); - - // release previously allocated space - env->ReleaseStringChars(text, textChars); - - // check if an error occured - icuError(env, status); -} - -static jstring getSymbol(JNIEnv *env, jclass clazz, jint addr, jint symbol) { - - uint32_t resultlength, reslenneeded; - - // the errorcode returned by unum_getSymbol - UErrorCode status = U_ZERO_ERROR; - - // get the pointer to the number format - UNumberFormat *fmt = (UNumberFormat *)(int)addr; - - UChar* result = NULL; - resultlength=0; - - // find out how long the result will be - reslenneeded=unum_getSymbol(fmt, (UNumberFormatSymbol) symbol, result, - resultlength, &status); - - result = NULL; - if(status==U_BUFFER_OVERFLOW_ERROR) { - status=U_ZERO_ERROR; - resultlength=reslenneeded+1; - result=(UChar*)malloc(sizeof(UChar) * resultlength); - reslenneeded=unum_getSymbol(fmt, (UNumberFormatSymbol) symbol, result, - resultlength, &status); - } - if (icuError(env, status) != FALSE) { - return NULL; - } - - jstring res = env->NewString(result, reslenneeded); - - free(result); - - return res; -} - -static void setAttribute(JNIEnv *env, jclass clazz, jint addr, jint symbol, - jint value) { - - UNumberFormat *fmt = (UNumberFormat *)(int)addr; - - unum_setAttribute(fmt, (UNumberFormatAttribute) symbol, value); -} - -static jint getAttribute(JNIEnv *env, jclass clazz, jint addr, jint symbol) { - - UNumberFormat *fmt = (UNumberFormat *)(int)addr; - - int res = unum_getAttribute(fmt, (UNumberFormatAttribute) symbol); - - return res; -} - -static void setTextAttribute(JNIEnv *env, jclass clazz, jint addr, jint symbol, - jstring text) { - - // the errorcode returned by unum_setTextAttribute - UErrorCode status = U_ZERO_ERROR; - - // get the pointer to the number format - UNumberFormat *fmt = (UNumberFormat *)(int)addr; - - const UChar *textChars = env->GetStringChars(text, NULL); - int textLen = env->GetStringLength(text); - - unum_setTextAttribute(fmt, (UNumberFormatTextAttribute) symbol, textChars, - textLen, &status); - - env->ReleaseStringChars(text, textChars); - - icuError(env, status); -} - -static jstring getTextAttribute(JNIEnv *env, jclass clazz, jint addr, - jint symbol) { - - uint32_t resultlength, reslenneeded; - - // the errorcode returned by unum_getTextAttribute - UErrorCode status = U_ZERO_ERROR; - - // get the pointer to the number format - UNumberFormat *fmt = (UNumberFormat *)(int)addr; - - UChar* result = NULL; - resultlength=0; - - // find out how long the result will be - reslenneeded=unum_getTextAttribute(fmt, (UNumberFormatTextAttribute) symbol, - result, resultlength, &status); - - result = NULL; - if(status==U_BUFFER_OVERFLOW_ERROR) { - status=U_ZERO_ERROR; - resultlength=reslenneeded+1; - result=(UChar*)malloc(sizeof(UChar) * resultlength); - reslenneeded=unum_getTextAttribute(fmt, - (UNumberFormatTextAttribute) symbol, result, resultlength, - &status); - } - if (icuError(env, status) != FALSE) { - return NULL; - } - - jstring res = env->NewString(result, reslenneeded); - - free(result); - - return res; -} - -static void applyPatternImpl(JNIEnv *env, jclass clazz, jint addr, - jboolean localized, jstring pattern) { - - // the errorcode returned by unum_applyPattern - UErrorCode status = U_ZERO_ERROR; - - // get the pointer to the number format - UNumberFormat *fmt = (UNumberFormat *)(int)addr; - - const UChar *pattChars = env->GetStringChars(pattern, NULL); - int pattLen = env->GetStringLength(pattern); - - unum_applyPattern(fmt, localized, pattChars, pattLen, NULL, &status); - - env->ReleaseStringChars(pattern, pattChars); - - icuError(env, status); -} - -static jstring toPatternImpl(JNIEnv *env, jclass clazz, jint addr, - jboolean localized) { - - uint32_t resultlength, reslenneeded; - - // the errorcode returned by unum_toPattern - UErrorCode status = U_ZERO_ERROR; - - // get the pointer to the number format - UNumberFormat *fmt = (UNumberFormat *)(int)addr; - - UChar* result = NULL; - resultlength=0; - - // find out how long the result will be - reslenneeded=unum_toPattern(fmt, localized, result, resultlength, &status); - - result = NULL; - if(status==U_BUFFER_OVERFLOW_ERROR) { - status=U_ZERO_ERROR; - resultlength=reslenneeded+1; - result=(UChar*)malloc(sizeof(UChar) * resultlength); - reslenneeded=unum_toPattern(fmt, localized, result, resultlength, - &status); - } - if (icuError(env, status) != FALSE) { - return NULL; - } - - jstring res = env->NewString(result, reslenneeded); - - free(result); - - return res; -} - -static jstring formatLong(JNIEnv *env, jclass clazz, jint addr, jlong value, - jobject field, jstring fieldType, jobject attributes) { - - const char * fieldPositionClassName = "java/text/FieldPosition"; - const char * stringBufferClassName = "java/lang/StringBuffer"; - jclass fieldPositionClass = env->FindClass(fieldPositionClassName); - jclass stringBufferClass = env->FindClass(stringBufferClassName); - jmethodID setBeginIndexMethodID = env->GetMethodID(fieldPositionClass, - "setBeginIndex", "(I)V"); - jmethodID setEndIndexMethodID = env->GetMethodID(fieldPositionClass, - "setEndIndex", "(I)V"); - jmethodID appendMethodID = env->GetMethodID(stringBufferClass, - "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;"); - - const char * fieldName = NULL; - - if(fieldType != NULL) { - fieldName = env->GetStringUTFChars(fieldType, NULL); - } - - uint32_t reslenneeded; - int64_t val = value; - UChar *result = NULL; - - FieldPosition fp; - fp.setField(FieldPosition::DONT_CARE); - - UErrorCode status = U_ZERO_ERROR; - - DecimalFormat::AttrBuffer attrBuffer = NULL; - attrBuffer = (DecimalFormat::AttrBuffer) malloc(sizeof(*attrBuffer)); - attrBuffer->bufferSize = 128; - attrBuffer->buffer = (char *) malloc(129 * sizeof(char)); - attrBuffer->buffer[0] = '\0'; - - DecimalFormat *fmt = (DecimalFormat *)(int)addr; - - UnicodeString *res = new UnicodeString(); - - fmt->format(val, *res, fp, attrBuffer); - - reslenneeded = res->extract(NULL, 0, status); - - if(status==U_BUFFER_OVERFLOW_ERROR) { - status=U_ZERO_ERROR; - - result = (UChar*)malloc(sizeof(UChar) * (reslenneeded + 1)); - - res->extract(result, reslenneeded + 1, status); - } - if (icuError(env, status) != FALSE) { - free(attrBuffer->buffer); - free(attrBuffer); - free(result); - delete(res); - return NULL; - } - - int attrLength = 0; - - attrLength = (strlen(attrBuffer->buffer) + 1 ); - - if(strlen(attrBuffer->buffer) > 0) { - - // check if we want to get all attributes - if(attributes != NULL) { - jstring attrString = env->NewStringUTF(attrBuffer->buffer + 1); // cut off the leading ';' - env->CallObjectMethod(attributes, appendMethodID, attrString); - } - - // check if we want one special attribute returned in the given FieldPos - if(fieldName != NULL && field != NULL) { - const char *delimiter = ";"; - int begin; - int end; - char * resattr; - resattr = strtok(attrBuffer->buffer, delimiter); - - while(resattr != NULL && strcmp(resattr, fieldName) != 0) { - resattr = strtok(NULL, delimiter); - } - - if(resattr != NULL && strcmp(resattr, fieldName) == 0) { - resattr = strtok(NULL, delimiter); - begin = (int) strtol(resattr, NULL, 10); - resattr = strtok(NULL, delimiter); - end = (int) strtol(resattr, NULL, 10); - - env->CallVoidMethod(field, setBeginIndexMethodID, (jint) begin); - env->CallVoidMethod(field, setEndIndexMethodID, (jint) end); - } - } - } - - if(fieldType != NULL) { - env->ReleaseStringUTFChars(fieldType, fieldName); - } - - jstring resulting = env->NewString(result, reslenneeded); - - free(attrBuffer->buffer); - free(attrBuffer); - free(result); - delete(res); - - return resulting; -} - -static jstring formatDouble(JNIEnv *env, jclass clazz, jint addr, jdouble value, - jobject field, jstring fieldType, jobject attributes) { - - const char * fieldPositionClassName = "java/text/FieldPosition"; - const char * stringBufferClassName = "java/lang/StringBuffer"; - jclass fieldPositionClass = env->FindClass(fieldPositionClassName); - jclass stringBufferClass = env->FindClass(stringBufferClassName); - jmethodID setBeginIndexMethodID = env->GetMethodID(fieldPositionClass, - "setBeginIndex", "(I)V"); - jmethodID setEndIndexMethodID = env->GetMethodID(fieldPositionClass, - "setEndIndex", "(I)V"); - jmethodID appendMethodID = env->GetMethodID(stringBufferClass, - "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;"); - - const char * fieldName = NULL; - - if(fieldType != NULL) { - fieldName = env->GetStringUTFChars(fieldType, NULL); - } - - uint32_t reslenneeded; - double val = value; - UChar *result = NULL; - - FieldPosition fp; - fp.setField(FieldPosition::DONT_CARE); - - UErrorCode status = U_ZERO_ERROR; - - DecimalFormat::AttrBuffer attrBuffer = NULL; - attrBuffer = (DecimalFormat::AttrBuffer) malloc(sizeof(*attrBuffer)); - attrBuffer->bufferSize = 128; - attrBuffer->buffer = (char *) malloc(129 * sizeof(char)); - attrBuffer->buffer[0] = '\0'; - - DecimalFormat *fmt = (DecimalFormat *)(int)addr; - - UnicodeString *res = new UnicodeString(); - - fmt->format(val, *res, fp, attrBuffer); - - reslenneeded = res->extract(NULL, 0, status); - - if(status==U_BUFFER_OVERFLOW_ERROR) { - status=U_ZERO_ERROR; - - result = (UChar*)malloc(sizeof(UChar) * (reslenneeded + 1)); - - res->extract(result, reslenneeded + 1, status); - - } - if (icuError(env, status) != FALSE) { - free(attrBuffer->buffer); - free(attrBuffer); - free(result); - delete(res); - return NULL; - } - - int attrLength = 0; - - attrLength = (strlen(attrBuffer->buffer) + 1 ); - - if(strlen(attrBuffer->buffer) > 0) { - - // check if we want to get all attributes - if(attributes != NULL) { - jstring attrString = env->NewStringUTF(attrBuffer->buffer + 1); // cut off the leading ';' - env->CallObjectMethod(attributes, appendMethodID, attrString); - } - - // check if we want one special attribute returned in the given FieldPos - if(fieldName != NULL && field != NULL) { - const char *delimiter = ";"; - int begin; - int end; - char * resattr; - resattr = strtok(attrBuffer->buffer, delimiter); - - while(resattr != NULL && strcmp(resattr, fieldName) != 0) { - resattr = strtok(NULL, delimiter); - } - - if(resattr != NULL && strcmp(resattr, fieldName) == 0) { - resattr = strtok(NULL, delimiter); - begin = (int) strtol(resattr, NULL, 10); - resattr = strtok(NULL, delimiter); - end = (int) strtol(resattr, NULL, 10); - - env->CallVoidMethod(field, setBeginIndexMethodID, (jint) begin); - env->CallVoidMethod(field, setEndIndexMethodID, (jint) end); - } - } - } - - if(fieldType != NULL) { - env->ReleaseStringUTFChars(fieldType, fieldName); - } - - jstring resulting = env->NewString(result, reslenneeded); - - free(attrBuffer->buffer); - free(attrBuffer); - free(result); - delete(res); - - return resulting; -} - -static jstring formatDigitList(JNIEnv *env, jclass clazz, jint addr, jstring value, - jobject field, jstring fieldType, jobject attributes, jint scale) { - - // const char * valueUTF = env->GetStringUTFChars(value, NULL); - // LOGI("ENTER formatDigitList: %s, scale: %d", valueUTF, scale); - // env->ReleaseStringUTFChars(value, valueUTF); - - if (scale < 0) { - icuError(env, U_ILLEGAL_ARGUMENT_ERROR); - return NULL; - } - - const char * fieldName = NULL; - if(fieldType != NULL) { - fieldName = env->GetStringUTFChars(fieldType, NULL); - } - - uint32_t reslenneeded; - - // prepare digit list - - const char *valueChars = env->GetStringUTFChars(value, NULL); - - bool isInteger = (scale == 0); - bool isPositive = (*valueChars != '-'); - - // skip the '-' if the number is negative - const char *digits = (isPositive ? valueChars : valueChars + 1); - int length = strlen(digits); - - // The length of our digit list buffer must be the actual string length + 3, - // because ICU will append some additional characters at the head and at the - // tail of the string, in order to keep strtod() happy: - // - // - The sign "+" or "-" is appended at the head - // - The exponent "e" and the "\0" terminator is appended at the tail - // - // In retrospect, the changes to ICU's DigitList that were necessary for - // big numbers look a bit hacky. It would make sense to rework all this - // once ICU 4.x has been integrated into Android. Ideally, big number - // support would make it into ICU itself, so we don't need our private - // fix anymore. - DigitList digitList(length + 3); - digitList.fCount = length; - strcpy(digitList.fDigits, digits); - env->ReleaseStringUTFChars(value, valueChars); - - digitList.fDecimalAt = digitList.fCount - scale; - digitList.fIsPositive = isPositive; - digitList.fRoundingMode = DecimalFormat::kRoundHalfUp; - - UChar *result = NULL; - - FieldPosition fp; - fp.setField(FieldPosition::DONT_CARE); - fp.setBeginIndex(0); - fp.setEndIndex(0); - - UErrorCode status = U_ZERO_ERROR; - - DecimalFormat::AttributeBuffer *attrBuffer = NULL; - attrBuffer = (DecimalFormat::AttributeBuffer *) calloc(sizeof(DecimalFormat::AttributeBuffer), 1); - attrBuffer->bufferSize = 128; - attrBuffer->buffer = (char *) calloc(129 * sizeof(char), 1); - - DecimalFormat *fmt = (DecimalFormat *)(int)addr; - - UnicodeString res; - - fmt->subformat(res, fp, attrBuffer, digitList, isInteger); - - reslenneeded = res.extract(NULL, 0, status); - - if(status==U_BUFFER_OVERFLOW_ERROR) { - status=U_ZERO_ERROR; - - result = (UChar*)malloc(sizeof(UChar) * (reslenneeded + 1)); - - res.extract(result, reslenneeded + 1, status); - - if (icuError(env, status) != FALSE) { - if(fieldType != NULL) { - env->ReleaseStringUTFChars(fieldType, fieldName); - } - free(result); - free(attrBuffer->buffer); - free(attrBuffer); - return NULL; - } - - } else { - if(fieldType != NULL) { - env->ReleaseStringUTFChars(fieldType, fieldName); - } - free(attrBuffer->buffer); - free(attrBuffer); - return NULL; - } - - int attrLength = (strlen(attrBuffer->buffer) + 1 ); - - if(attrLength > 1) { - - // check if we want to get all attributes - if(attributes != NULL) { - // prepare the classes and method ids - const char * stringBufferClassName = "java/lang/StringBuffer"; - jclass stringBufferClass = env->FindClass(stringBufferClassName); - jmethodID appendMethodID = env->GetMethodID(stringBufferClass, - "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;"); - - jstring attrString = env->NewStringUTF(attrBuffer->buffer + 1); // cut off the leading ';' - env->CallObjectMethod(attributes, appendMethodID, attrString); - } - - // check if we want one special attribute returned in the given FieldPos - if(fieldName != NULL && field != NULL) { - const char *delimiter = ";"; - int begin; - int end; - char * resattr; - resattr = strtok(attrBuffer->buffer, delimiter); - - while(resattr != NULL && strcmp(resattr, fieldName) != 0) { - resattr = strtok(NULL, delimiter); - } - - if(resattr != NULL && strcmp(resattr, fieldName) == 0) { - - // prepare the classes and method ids - const char * fieldPositionClassName = - "java/text/FieldPosition"; - jclass fieldPositionClass = env->FindClass( - fieldPositionClassName); - jmethodID setBeginIndexMethodID = env->GetMethodID( - fieldPositionClass, "setBeginIndex", "(I)V"); - jmethodID setEndIndexMethodID = env->GetMethodID( - fieldPositionClass, "setEndIndex", "(I)V"); - - - resattr = strtok(NULL, delimiter); - begin = (int) strtol(resattr, NULL, 10); - resattr = strtok(NULL, delimiter); - end = (int) strtol(resattr, NULL, 10); - - env->CallVoidMethod(field, setBeginIndexMethodID, (jint) begin); - env->CallVoidMethod(field, setEndIndexMethodID, (jint) end); - } - } - } - - if(fieldType != NULL) { - env->ReleaseStringUTFChars(fieldType, fieldName); - } - - jstring resulting = env->NewString(result, reslenneeded); - - free(attrBuffer->buffer); - free(attrBuffer); - free(result); - // const char * resultUTF = env->GetStringUTFChars(resulting, NULL); - // LOGI("RETURN formatDigitList: %s", resultUTF); - // env->ReleaseStringUTFChars(resulting, resultUTF); - - return resulting; -} - -static jobject parse(JNIEnv *env, jclass clazz, jint addr, jstring text, - jobject position) { - - const char * textUTF = env->GetStringUTFChars(text, NULL); - env->ReleaseStringUTFChars(text, textUTF); - - const char * parsePositionClassName = "java/text/ParsePosition"; - const char * longClassName = "java/lang/Long"; - const char * doubleClassName = "java/lang/Double"; - const char * bigDecimalClassName = "java/math/BigDecimal"; - const char * bigIntegerClassName = "java/math/BigInteger"; - - UErrorCode status = U_ZERO_ERROR; - - UNumberFormat *fmt = (UNumberFormat *)(int)addr; - - jchar *str = (UChar *)env->GetStringChars(text, NULL); - int strlength = env->GetStringLength(text); - - jclass parsePositionClass = env->FindClass(parsePositionClassName); - jclass longClass = env->FindClass(longClassName); - jclass doubleClass = env->FindClass(doubleClassName); - jclass bigDecimalClass = env->FindClass(bigDecimalClassName); - jclass bigIntegerClass = env->FindClass(bigIntegerClassName); - - jmethodID getIndexMethodID = env->GetMethodID(parsePositionClass, - "getIndex", "()I"); - jmethodID setIndexMethodID = env->GetMethodID(parsePositionClass, - "setIndex", "(I)V"); - jmethodID setErrorIndexMethodID = env->GetMethodID(parsePositionClass, - "setErrorIndex", "(I)V"); - - jmethodID longInitMethodID = env->GetMethodID(longClass, "", "(J)V"); - jmethodID dblInitMethodID = env->GetMethodID(doubleClass, "", "(D)V"); - jmethodID bigDecimalInitMethodID = env->GetMethodID(bigDecimalClass, "", "(Ljava/math/BigInteger;I)V"); - jmethodID bigIntegerInitMethodID = env->GetMethodID(bigIntegerClass, "", "(Ljava/lang/String;)V"); - jmethodID doubleValueMethodID = env->GetMethodID(bigDecimalClass, "doubleValue", "()D"); - - bool resultAssigned; - int parsePos = env->CallIntMethod(position, getIndexMethodID, NULL); - - // make sure the ParsePosition is valid. Actually icu4c would parse a number - // correctly even if the parsePosition is set to -1, but since the RI fails - // for that case we have to fail too - if(parsePos < 0 || parsePos > strlength) { - return NULL; - } - - Formattable res; - - const UnicodeString src((UChar*)str, strlength, strlength); - ParsePosition pp; - - pp.setIndex(parsePos); - - DigitList digits; - - ((const DecimalFormat*)fmt)->parse(src, resultAssigned, res, pp, FALSE, digits); - - env->ReleaseStringChars(text, str); - - if(pp.getErrorIndex() == -1) { - parsePos = pp.getIndex(); - } else { - env->CallVoidMethod(position, setErrorIndexMethodID, - (jint) pp.getErrorIndex()); - return NULL; - } - - Formattable::Type numType; - numType = res.getType(); - UErrorCode fmtStatus; - - double resultDouble; - long resultLong; - int64_t resultInt64; - UnicodeString resultString; - jstring resultStr; - int resLength; - const char * resultUTF; - jobject resultObject1, resultObject2; - jdouble doubleTest; - jchar * result; - - if (resultAssigned) - { - switch(numType) { - case Formattable::kDouble: - resultDouble = res.getDouble(); - env->CallVoidMethod(position, setIndexMethodID, (jint) parsePos); - return env->NewObject(doubleClass, dblInitMethodID, - (jdouble) resultDouble); - case Formattable::kLong: - resultLong = res.getLong(); - env->CallVoidMethod(position, setIndexMethodID, (jint) parsePos); - return env->NewObject(longClass, longInitMethodID, - (jlong) resultLong); - case Formattable::kInt64: - resultInt64 = res.getInt64(); - env->CallVoidMethod(position, setIndexMethodID, (jint) parsePos); - return env->NewObject(longClass, longInitMethodID, - (jlong) resultInt64); - default: - return NULL; - } - } - else - { - int scale = digits.fCount - digits.fDecimalAt; - // ATTENTION: Abuse of Implementation Knowlegde! - digits.fDigits[digits.fCount] = 0; - if (digits.fIsPositive) { - resultStr = env->NewStringUTF(digits.fDigits); - } else { - if (digits.fCount == 0) { - env->CallVoidMethod(position, setIndexMethodID, (jint) parsePos); - return env->NewObject(doubleClass, dblInitMethodID, (jdouble)-0); - } else { - // ATTENTION: Abuse of Implementation Knowlegde! - *(digits.fDigits - 1) = '-'; - resultStr = env->NewStringUTF(digits.fDigits - 1); - } - } - - env->CallVoidMethod(position, setIndexMethodID, (jint) parsePos); - - resultObject1 = env->NewObject(bigIntegerClass, bigIntegerInitMethodID, resultStr); - resultObject2 = env->NewObject(bigDecimalClass, bigDecimalInitMethodID, resultObject1, scale); - return resultObject2; - } -} - -static jint cloneImpl(JNIEnv *env, jclass clazz, jint addr) { - - UErrorCode status = U_ZERO_ERROR; - - UNumberFormat *fmt = (UNumberFormat *)(int)addr; - - UNumberFormat *result = unum_clone(fmt, &status); - - if(icuError(env, status) != FALSE) { - return 0; - } - - return (long) result; - -} - -static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ - {"openDecimalFormatImpl", "(Ljava/lang/String;Ljava/lang/String;)I", - (void*) openDecimalFormatImpl}, - {"closeDecimalFormatImpl", "(I)V", (void*) closeDecimalFormatImpl}, - {"setSymbol", "(IILjava/lang/String;)V", (void*) setSymbol}, - {"getSymbol", "(II)Ljava/lang/String;", (void*) getSymbol}, - {"setAttribute", "(III)V", (void*) setAttribute}, - {"getAttribute", "(II)I", (void*) getAttribute}, - {"setTextAttribute", "(IILjava/lang/String;)V", (void*) setTextAttribute}, - {"getTextAttribute", "(II)Ljava/lang/String;", (void*) getTextAttribute}, - {"applyPatternImpl", "(IZLjava/lang/String;)V", (void*) applyPatternImpl}, - {"toPatternImpl", "(IZ)Ljava/lang/String;", (void*) toPatternImpl}, - {"format", - "(IJLjava/text/FieldPosition;Ljava/lang/String;Ljava/lang/StringBuffer;)Ljava/lang/String;", - (void*) formatLong}, - {"format", - "(IDLjava/text/FieldPosition;Ljava/lang/String;Ljava/lang/StringBuffer;)Ljava/lang/String;", - (void*) formatDouble}, - {"format", - "(ILjava/lang/String;Ljava/text/FieldPosition;Ljava/lang/String;Ljava/lang/StringBuffer;I)Ljava/lang/String;", - (void*) formatDigitList}, - {"parse", - "(ILjava/lang/String;Ljava/text/ParsePosition;)Ljava/lang/Number;", - (void*) parse}, - {"cloneImpl", "(I)I", (void*) cloneImpl} -}; -int register_com_ibm_icu4jni_text_NativeDecimalFormat(JNIEnv* env) { - return jniRegisterNativeMethods(env, - "com/ibm/icu4jni/text/NativeDecimalFormat", gMethods, - NELEM(gMethods)); -} diff --git a/libcore/icu/src/main/native/ErrorCode.c b/libcore/icu/src/main/native/ErrorCode.c deleted file mode 100644 index b3e43cd31..000000000 --- a/libcore/icu/src/main/native/ErrorCode.c +++ /dev/null @@ -1,57 +0,0 @@ -/** -******************************************************************************* -* Copyright (C) 1996-2005, International Business Machines Corporation and * -* others. All Rights Reserved. * -******************************************************************************* -* -******************************************************************************* -*/ - -#include "ErrorCode.h" - -/* private data members ----------------------------------------------------*/ - -/** -* Name of the java runtime exception classes -*/ -#define ILLEGALARGUMENTEXCEPTION_ "java/lang/IllegalArgumentException" -#define ARRAYINDEXOUTOFBOUNDSEXCEPTION_ "java/lang/ArrayIndexOutOfBoundsException" -#define UNSUPPORTEDOPERATIONEXCEPTION_ "java/lang/UnsupportedOperationException" -#define RUNTIMEEXCEPTION_ "java/lang/RuntimeException" - -/* public methods ---------------------------------------------------------*/ - -/** -* Checks if an error has occured. -* Throws a generic Java RuntimeException if an error has occured. -* @param env JNI environment variable -* @param errorcode code to determine if it is an erro -* @return 0 if errorcode is not an error, 1 if errorcode is an error, but the -* creation of the exception to be thrown fails -* @exception thrown if errorcode represents an error -*/ -UBool icu4jni_error(JNIEnv *env, UErrorCode errorcode) -{ - const char *emsg = u_errorName(errorcode); - jclass exception; - - if (errorcode > U_ZERO_ERROR && errorcode < U_ERROR_LIMIT) { - switch (errorcode) { - case U_ILLEGAL_ARGUMENT_ERROR : - exception = (*env)->FindClass(env, ILLEGALARGUMENTEXCEPTION_); - break; - case U_INDEX_OUTOFBOUNDS_ERROR : - case U_BUFFER_OVERFLOW_ERROR : - exception = (*env)->FindClass(env, ARRAYINDEXOUTOFBOUNDSEXCEPTION_); - break; - case U_UNSUPPORTED_ERROR : - exception = (*env)->FindClass(env, UNSUPPORTEDOPERATIONEXCEPTION_); - break; - default : - exception = (*env)->FindClass(env, RUNTIMEEXCEPTION_); - } - - return ((*env)->ThrowNew(env, exception, emsg) != 0); - } - return 0; -} diff --git a/libcore/icu/src/main/native/ErrorCode.h b/libcore/icu/src/main/native/ErrorCode.h deleted file mode 100644 index a5bbfc644..000000000 --- a/libcore/icu/src/main/native/ErrorCode.h +++ /dev/null @@ -1,27 +0,0 @@ -/** -******************************************************************************* -* Copyright (C) 1996-2005, International Business Machines Corporation and * -* others. All Rights Reserved. * -******************************************************************************* -******************************************************************************* -*/ - -#ifndef ERRORCODE_H -#define ERRORCODE_H - -#include -#include "unicode/utypes.h" -#include "unicode/putil.h" - -/** -* Checks if an error has occured. -* Throws a generic Java RuntimeException if an error has occured. -* @param env JNI environment variable -* @param errorcode code to determine if it is an erro -* @return 0 if errorcode is not an error, 1 if errorcode is an error, but the -* creation of the exception to be thrown fails -* @exception thrown if errorcode represents an error -*/ -UBool icu4jni_error(JNIEnv *env, UErrorCode errorcode); - -#endif diff --git a/libcore/icu/src/main/native/RBNFInterface.cpp b/libcore/icu/src/main/native/RBNFInterface.cpp deleted file mode 100644 index d9bf460b5..000000000 --- a/libcore/icu/src/main/native/RBNFInterface.cpp +++ /dev/null @@ -1,382 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "JNIHelp.h" -#include "AndroidSystemNatives.h" -#include "unicode/numfmt.h" -#include "unicode/rbnf.h" -#include "unicode/fmtable.h" -#include "unicode/ustring.h" -#include "unicode/locid.h" -#include "ErrorCode.h" -#include -#include - -static UBool icuError(JNIEnv *env, UErrorCode errorcode) -{ - const char *emsg = u_errorName(errorcode); - jclass exception; - - if (errorcode > U_ZERO_ERROR && errorcode < U_ERROR_LIMIT) { - switch (errorcode) { - case U_ILLEGAL_ARGUMENT_ERROR : - exception = env->FindClass("java/lang/IllegalArgumentException"); - break; - case U_INDEX_OUTOFBOUNDS_ERROR : - case U_BUFFER_OVERFLOW_ERROR : - exception = env->FindClass("java/lang/ArrayIndexOutOfBoundsException"); - break; - case U_UNSUPPORTED_ERROR : - exception = env->FindClass("java/lang/UnsupportedOperationException"); - break; - default : - exception = env->FindClass("java/lang/RuntimeException"); - } - - return (env->ThrowNew(exception, emsg) != 0); - } - return 0; -} - -static jint openRBNFImpl1(JNIEnv* env, jclass clazz, - jint type, jstring locale) { - - // LOGI("ENTER openRBNFImpl1"); - - // the errorcode returned by unum_open - UErrorCode status = U_ZERO_ERROR; - - // prepare the locale string for the call to unum_open - const char *localeChars = env->GetStringUTFChars(locale, NULL); - - URBNFRuleSetTag style; - if(type == 0) { - style = URBNF_SPELLOUT; - } else if(type == 1) { - style = URBNF_ORDINAL; - } else if(type == 2) { - style = URBNF_DURATION; - } else if(type == 3) { - style = URBNF_COUNT; - } else { - icuError(env, U_ILLEGAL_ARGUMENT_ERROR); - } - - Locale loc = Locale::createFromName(localeChars); - - // open a default type number format - RuleBasedNumberFormat *fmt = new RuleBasedNumberFormat(style, loc, status); - - // release the allocated strings - env->ReleaseStringUTFChars(locale, localeChars); - - // check for an error - if ( icuError(env, status) != FALSE) { - return 0; - } - - // return the handle to the number format - return (long) fmt; - -} - -static jint openRBNFImpl2(JNIEnv* env, jclass clazz, - jstring rule, jstring locale) { - - // LOGI("ENTER openRBNFImpl2"); - - // the errorcode returned by unum_open - UErrorCode status = U_ZERO_ERROR; - - // prepare the pattern string for the call to unum_open - const UChar *ruleChars = env->GetStringChars(rule, NULL); - int ruleLen = env->GetStringLength(rule); - - // prepare the locale string for the call to unum_open - const char *localeChars = env->GetStringUTFChars(locale, NULL); - - // open a rule based number format - UNumberFormat *fmt = unum_open(UNUM_PATTERN_RULEBASED, ruleChars, ruleLen, - localeChars, NULL, &status); - - // release the allocated strings - env->ReleaseStringChars(rule, ruleChars); - env->ReleaseStringUTFChars(locale, localeChars); - - // check for an error - if ( icuError(env, status) != FALSE) { - return 0; - } - - // return the handle to the number format - return (long) fmt; - -} - -static void closeRBNFImpl(JNIEnv *env, jclass clazz, jint addr) { - - // LOGI("ENTER closeRBNFImpl"); - - // get the pointer to the number format - RuleBasedNumberFormat *fmt = (RuleBasedNumberFormat *)(int)addr; - - // close this number format - delete fmt; -} - -static jstring formatLongRBNFImpl(JNIEnv *env, jclass clazz, jint addr, jlong value, - jobject field, jstring fieldType, jobject attributes) { - - // LOGI("ENTER formatLongRBNFImpl"); - - const char * fieldPositionClassName = "java/text/FieldPosition"; - const char * stringBufferClassName = "java/lang/StringBuffer"; - jclass fieldPositionClass = env->FindClass(fieldPositionClassName); - jclass stringBufferClass = env->FindClass(stringBufferClassName); - jmethodID setBeginIndexMethodID = env->GetMethodID(fieldPositionClass, - "setBeginIndex", "(I)V"); - jmethodID setEndIndexMethodID = env->GetMethodID(fieldPositionClass, - "setEndIndex", "(I)V"); - jmethodID appendMethodID = env->GetMethodID(stringBufferClass, - "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;"); - - const char * fieldName = NULL; - - if(fieldType != NULL) { - fieldName = env->GetStringUTFChars(fieldType, NULL); - } - - uint32_t reslenneeded; - int64_t val = value; - UChar *result = NULL; - - FieldPosition fp; - fp.setField(FieldPosition::DONT_CARE); - - UErrorCode status = U_ZERO_ERROR; - - RuleBasedNumberFormat *fmt = (RuleBasedNumberFormat *)(int)addr; - - UnicodeString res; - - fmt->format(val, res, fp); - - reslenneeded = res.extract(NULL, 0, status); - - if(status==U_BUFFER_OVERFLOW_ERROR) { - status=U_ZERO_ERROR; - - result = (UChar*)malloc(sizeof(UChar) * (reslenneeded + 1)); - - res.extract(result, reslenneeded + 1, status); - } - if (icuError(env, status) != FALSE) { - free(result); - return NULL; - } - - if(fieldType != NULL) { - env->ReleaseStringUTFChars(fieldType, fieldName); - } - - jstring resulting = env->NewString(result, reslenneeded); - - free(result); - - return resulting; -} - -static jstring formatDoubleRBNFImpl(JNIEnv *env, jclass clazz, jint addr, jdouble value, - jobject field, jstring fieldType, jobject attributes) { - - // LOGI("ENTER formatDoubleRBNFImpl"); - - const char * fieldPositionClassName = "java/text/FieldPosition"; - const char * stringBufferClassName = "java/lang/StringBuffer"; - jclass fieldPositionClass = env->FindClass(fieldPositionClassName); - jclass stringBufferClass = env->FindClass(stringBufferClassName); - jmethodID setBeginIndexMethodID = env->GetMethodID(fieldPositionClass, - "setBeginIndex", "(I)V"); - jmethodID setEndIndexMethodID = env->GetMethodID(fieldPositionClass, - "setEndIndex", "(I)V"); - jmethodID appendMethodID = env->GetMethodID(stringBufferClass, - "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;"); - - const char * fieldName = NULL; - - if(fieldType != NULL) { - fieldName = env->GetStringUTFChars(fieldType, NULL); - } - - uint32_t reslenneeded; - double val = value; - UChar *result = NULL; - - FieldPosition fp; - fp.setField(FieldPosition::DONT_CARE); - - UErrorCode status = U_ZERO_ERROR; - - RuleBasedNumberFormat *fmt = (RuleBasedNumberFormat *)(int)addr; - - UnicodeString res; - - fmt->format(val, res, fp); - - reslenneeded = res.extract(NULL, 0, status); - - if(status==U_BUFFER_OVERFLOW_ERROR) { - status=U_ZERO_ERROR; - - result = (UChar*)malloc(sizeof(UChar) * (reslenneeded + 1)); - - res.extract(result, reslenneeded + 1, status); - } - if (icuError(env, status) != FALSE) { - free(result); - return NULL; - } - - if(fieldType != NULL) { - env->ReleaseStringUTFChars(fieldType, fieldName); - } - - jstring resulting = env->NewString(result, reslenneeded); - - free(result); - - return resulting; -} - -static jobject parseRBNFImpl(JNIEnv *env, jclass clazz, jint addr, jstring text, - jobject position, jboolean lenient) { - - // LOGI("ENTER parseRBNFImpl"); - - const char * parsePositionClassName = "java/text/ParsePosition"; - const char * longClassName = "java/lang/Long"; - const char * doubleClassName = "java/lang/Double"; - - - UErrorCode status = U_ZERO_ERROR; - - UNumberFormat *fmt = (UNumberFormat *)(int)addr; - - jchar *str = (UChar *)env->GetStringChars(text, NULL); - int strlength = env->GetStringLength(text); - - jclass parsePositionClass = env->FindClass(parsePositionClassName); - jclass longClass = env->FindClass(longClassName); - jclass doubleClass = env->FindClass(doubleClassName); - - jmethodID getIndexMethodID = env->GetMethodID(parsePositionClass, - "getIndex", "()I"); - jmethodID setIndexMethodID = env->GetMethodID(parsePositionClass, - "setIndex", "(I)V"); - jmethodID setErrorIndexMethodID = env->GetMethodID(parsePositionClass, - "setErrorIndex", "(I)V"); - - jmethodID longInitMethodID = env->GetMethodID(longClass, "", "(J)V"); - jmethodID dblInitMethodID = env->GetMethodID(doubleClass, "", "(D)V"); - - int parsePos = env->CallIntMethod(position, getIndexMethodID, NULL); - - // make sure the ParsePosition is valid. Actually icu4c would parse a number - // correctly even if the parsePosition is set to -1, but since the RI fails - // for that case we have to fail too - if(parsePos < 0 || parsePos > strlength) { - return NULL; - } - - Formattable res; - - const UnicodeString src((UChar*)str, strlength, strlength); - ParsePosition pp; - - pp.setIndex(parsePos); - - if(lenient) { - unum_setAttribute(fmt, UNUM_LENIENT_PARSE, JNI_TRUE); - } - - ((const NumberFormat*)fmt)->parse(src, res, pp); - - if(lenient) { - unum_setAttribute(fmt, UNUM_LENIENT_PARSE, JNI_FALSE); - } - - env->ReleaseStringChars(text, str); - - if(pp.getErrorIndex() == -1) { - parsePos = pp.getIndex(); - } else { - env->CallVoidMethod(position, setErrorIndexMethodID, - (jint) pp.getErrorIndex()); - return NULL; - } - - Formattable::Type numType; - numType = res.getType(); - UErrorCode fmtStatus; - - double resultDouble; - long resultLong; - int64_t resultInt64; - - switch(numType) { - case Formattable::kDouble: - resultDouble = res.getDouble(); - env->CallVoidMethod(position, setIndexMethodID, (jint) parsePos); - return env->NewObject(doubleClass, dblInitMethodID, - (jdouble) resultDouble); - case Formattable::kLong: - resultLong = res.getLong(); - env->CallVoidMethod(position, setIndexMethodID, (jint) parsePos); - return env->NewObject(longClass, longInitMethodID, - (jlong) resultLong); - case Formattable::kInt64: - resultInt64 = res.getInt64(); - env->CallVoidMethod(position, setIndexMethodID, (jint) parsePos); - return env->NewObject(longClass, longInitMethodID, - (jlong) resultInt64); - default: - break; - } - - return NULL; -} - -static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ - {"openRBNFImpl", "(ILjava/lang/String;)I", (void*) openRBNFImpl1}, - {"openRBNFImpl", "(Ljava/lang/String;Ljava/lang/String;)I", - (void*) openRBNFImpl2}, - {"closeRBNFImpl", "(I)V", (void*) closeRBNFImpl}, - {"formatRBNFImpl", - "(IJLjava/text/FieldPosition;Ljava/lang/String;Ljava/lang/StringBuffer;)Ljava/lang/String;", - (void*) formatLongRBNFImpl}, - {"formatRBNFImpl", - "(IDLjava/text/FieldPosition;Ljava/lang/String;Ljava/lang/StringBuffer;)Ljava/lang/String;", - (void*) formatDoubleRBNFImpl}, - {"parseRBNFImpl", - "(ILjava/lang/String;Ljava/text/ParsePosition;Z)Ljava/lang/Number;", - (void*) parseRBNFImpl}, -}; -int register_com_ibm_icu4jni_text_NativeRBNF(JNIEnv* env) { - return jniRegisterNativeMethods(env, - "com/ibm/icu4jni/text/RuleBasedNumberFormat", gMethods, - NELEM(gMethods)); -} diff --git a/libcore/icu/src/main/native/RegExInterface.cpp b/libcore/icu/src/main/native/RegExInterface.cpp deleted file mode 100644 index afa5cc435..000000000 --- a/libcore/icu/src/main/native/RegExInterface.cpp +++ /dev/null @@ -1,373 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include "unicode/uregex.h" -#include "unicode/utypes.h" -#include "unicode/parseerr.h" - -#include -#include - -static jchar EMPTY_STRING = 0; - -/** - * A data structure that ties together an ICU regular expression and the - * character data it refers to (but does not have a copy of), so we can - * manage memory properly. - */ -typedef struct RegExDataStruct { - // A pointer to the ICU regular expression - URegularExpression* regex; - // A pointer to (a copy of) the input text that *we* manage - jchar* text; -} RegExData; - -static void throwPatternSyntaxException(JNIEnv* env, UErrorCode status, - jstring pattern, UParseError error) -{ - jclass clazz = env->FindClass("java/util/regex/PatternSyntaxException"); - jmethodID method = env->GetMethodID(clazz, "", - "(Ljava/lang/String;Ljava/lang/String;I)V"); - - jstring message = env->NewStringUTF(u_errorName(status)); - jthrowable except = (jthrowable)(env->NewObject(clazz, method, message, - pattern, error.offset)); - env->Throw(except); -} - -static void throwRuntimeException(JNIEnv* env, UErrorCode status) -{ - jniThrowException(env, "java/lang/RuntimeException", u_errorName(status)); -} - -static void _close(JNIEnv* env, jclass clazz, RegExData* data) -{ - if (data->regex != NULL) { - uregex_close(data->regex); - } - - if (data->text != NULL && data->text != &EMPTY_STRING) { - free(data->text); - } - - free(data); -} - -static RegExData* open(JNIEnv* env, jclass clazz, jstring pattern, jint flags) -{ - flags = flags | UREGEX_ERROR_ON_UNKNOWN_ESCAPES; - - RegExData* data = (RegExData*)calloc(sizeof(RegExData), 1); - - UErrorCode status = U_ZERO_ERROR; - UParseError error; - error.offset = -1; - - jchar const * patternRaw; - int patternLen = env->GetStringLength(pattern); - if (patternLen == 0) { - data->regex = uregex_open(&EMPTY_STRING, -1, flags, &error, &status); - } else { - jchar const * patternRaw = env->GetStringChars(pattern, NULL); - data->regex = uregex_open(patternRaw, patternLen, flags, &error, - &status); - env->ReleaseStringChars(pattern, patternRaw); - } - - if (!U_SUCCESS(status)) { - _close(env, clazz, data); - throwPatternSyntaxException(env, status, pattern, error); - data = NULL; - } - - return data; -} - -static RegExData* _clone(JNIEnv* env, jclass clazz, RegExData* data) -{ - UErrorCode status = U_ZERO_ERROR; - - URegularExpression* clonedRegex = uregex_clone(data->regex, &status); - if (!U_SUCCESS(status)) { - throwRuntimeException(env, status); - } - - RegExData* result = (RegExData*)calloc(sizeof(RegExData), 1); - result->regex = clonedRegex; - - return result; -} - -static void setText(JNIEnv* env, jclass clazz, RegExData* data, jstring text) -{ - UErrorCode status = U_ZERO_ERROR; - - uregex_setText(data->regex, &EMPTY_STRING, 0, &status); - if (!U_SUCCESS(status)) { - throwRuntimeException(env, status); - return; - } - - if (data->text != NULL && data->text != &EMPTY_STRING) { - free(data->text); - data->text = NULL; - } - - int textLen = env->GetStringLength(text); - if (textLen == 0) { - data->text = &EMPTY_STRING; - } else { - jchar const * textRaw = env->GetStringChars(text, NULL); - data->text = (jchar*)malloc((textLen + 1) * sizeof(jchar)); - memcpy(data->text, textRaw, textLen * sizeof(jchar)); - data->text[textLen] = 0; - env->ReleaseStringChars(text, textRaw); - } - - uregex_setText(data->regex, data->text, textLen, &status); - if (!U_SUCCESS(status)) { - throwRuntimeException(env, status); - } -} - -static jboolean matches(JNIEnv* env, jclass clazz, RegExData* data, - jint startIndex) -{ - UErrorCode status = U_ZERO_ERROR; - - jboolean result = uregex_matches(data->regex, startIndex, &status); - if (!U_SUCCESS(status)) { - throwRuntimeException(env, status); - } - - return result; -} - -static jboolean lookingAt(JNIEnv* env, jclass clazz, RegExData* data, - jint startIndex) -{ - UErrorCode status = U_ZERO_ERROR; - - jboolean result = uregex_lookingAt(data->regex, startIndex, &status); - if (!U_SUCCESS(status)) { - throwRuntimeException(env, status); - } - - return result; -} - -static jboolean find(JNIEnv* env, jclass clazz, RegExData* data, - jint startIndex) -{ - UErrorCode status = U_ZERO_ERROR; - - jboolean result = uregex_find(data->regex, startIndex, &status); - if (!U_SUCCESS(status)) { - throwRuntimeException(env, status); - } - - return result; -} - -static jboolean findNext(JNIEnv* env, jclass clazz, RegExData* data) -{ - UErrorCode status = U_ZERO_ERROR; - - jboolean result = uregex_findNext(data->regex, &status); - if (!U_SUCCESS(status)) { - throwRuntimeException(env, status); - } - - return result; -} - -static jint groupCount(JNIEnv* env, jclass clazz, RegExData* data) -{ - UErrorCode status = U_ZERO_ERROR; - - jint result = uregex_groupCount(data->regex, &status); - if (!U_SUCCESS(status)) { - throwRuntimeException(env, status); - } - - return result; -} - -static void startEnd(JNIEnv* env, jclass clazz, RegExData* data, - jintArray offsets) -{ - UErrorCode status = U_ZERO_ERROR; - - jint * offsetsRaw = env->GetIntArrayElements(offsets, NULL); - - int groupCount = uregex_groupCount(data->regex, &status); - for (int i = 0; i <= groupCount && U_SUCCESS(status); i++) { - offsetsRaw[2 * i + 0] = uregex_start(data->regex, i, &status); - offsetsRaw[2 * i + 1] = uregex_end(data->regex, i, &status); - } - - env->ReleaseIntArrayElements(offsets, offsetsRaw, 0); - - if (!U_SUCCESS(status)) { - throwRuntimeException(env, status); - } -} - -static void setRegion(JNIEnv* env, jclass clazz, RegExData* data, jint start, - jint end) -{ - UErrorCode status = U_ZERO_ERROR; - uregex_setRegion(data->regex, start, end, &status); - if (!U_SUCCESS(status)) { - throwRuntimeException(env, status); - } -} - -static jint regionStart(JNIEnv* env, jclass clazz, RegExData* data) -{ - UErrorCode status = U_ZERO_ERROR; - int result = uregex_regionStart(data->regex, &status); - if (!U_SUCCESS(status)) { - throwRuntimeException(env, status); - } - return result; -} - -static jint regionEnd(JNIEnv* env, jclass clazz, RegExData* data) -{ - UErrorCode status = U_ZERO_ERROR; - int result = uregex_regionEnd(data->regex, &status); - if (!U_SUCCESS(status)) { - throwRuntimeException(env, status); - } - return result; -} - -static void useTransparentBounds(JNIEnv* env, jclass clazz, RegExData* data, - jboolean value) -{ - UErrorCode status = U_ZERO_ERROR; - uregex_useTransparentBounds(data->regex, value, &status); - if (!U_SUCCESS(status)) { - throwRuntimeException(env, status); - } -} - -static jboolean hasTransparentBounds(JNIEnv* env, jclass clazz, RegExData* data) -{ - UErrorCode status = U_ZERO_ERROR; - jboolean result = uregex_hasTransparentBounds(data->regex, &status); - if (!U_SUCCESS(status)) { - throwRuntimeException(env, status); - } - return result; -} - -static void useAnchoringBounds(JNIEnv* env, jclass clazz, RegExData* data, - jboolean value) -{ - UErrorCode status = U_ZERO_ERROR; - uregex_useAnchoringBounds(data->regex, value, &status); - if (!U_SUCCESS(status)) { - throwRuntimeException(env, status); - } -} - -static jboolean hasAnchoringBounds(JNIEnv* env, jclass clazz, RegExData* data) -{ - UErrorCode status = U_ZERO_ERROR; - jboolean result = uregex_hasAnchoringBounds(data->regex, &status); - if (!U_SUCCESS(status)) { - throwRuntimeException(env, status); - } - return result; -} - -static jboolean hitEnd(JNIEnv* env, jclass clazz, RegExData* data) -{ - UErrorCode status = U_ZERO_ERROR; - jboolean result = uregex_hitEnd(data->regex, &status); - if (!U_SUCCESS(status)) { - throwRuntimeException(env, status); - } - return result; -} - -static jboolean requireEnd(JNIEnv* env, jclass clazz, RegExData* data) -{ - UErrorCode status = U_ZERO_ERROR; - jboolean result = uregex_requireEnd(data->regex, &status); - if (!U_SUCCESS(status)) { - throwRuntimeException(env, status); - } - return result; -} - -static void reset(JNIEnv* env, jclass clazz, RegExData* data, jint position) -{ - UErrorCode status = U_ZERO_ERROR; - uregex_reset(data->regex, position, &status); - if (!U_SUCCESS(status)) { - throwRuntimeException(env, status); - } -} - -/* - * JNI registration. - */ -static JNINativeMethod sMethods[] = { - /* name, signature, funcPtr */ - { "open", "(Ljava/lang/String;I)I", (void*)open }, - { "clone", "(I)I", (void*)_clone }, - { "close", "(I)V", (void*)_close }, - { "setText", "(ILjava/lang/String;)V", (void*)setText }, - { "matches", "(II)Z", (void*)matches }, - { "lookingAt", "(II)Z", (void*)lookingAt }, - { "find", "(II)Z", (void*)find }, - { "findNext", "(I)Z", (void*)findNext }, - { "groupCount", "(I)I", (void*)groupCount }, - { "startEnd", "(I[I)V", (void*)startEnd }, - { "setRegion", "(III)V", (void*)setRegion }, - { "regionStart", "(I)I", (void*)regionStart }, - { "regionEnd", "(I)I", (void*)regionEnd }, - { "useTransparentBounds", "(IZ)V", (void*)useTransparentBounds }, - { "hasTransparentBounds", "(I)Z", (void*)hasTransparentBounds }, - { "useAnchoringBounds", "(IZ)V", (void*)useAnchoringBounds }, - { "hasAnchoringBounds", "(I)Z", (void*)hasAnchoringBounds }, - { "hitEnd", "(I)Z", (void*)hitEnd }, - { "requireEnd", "(I)Z", (void*)requireEnd }, - { "reset", "(II)V", (void*)reset } -}; - -extern "C" int register_com_ibm_icu4jni_regex_NativeRegEx(JNIEnv* env) -{ - jclass clazz; - - clazz = env->FindClass("com/ibm/icu4jni/regex/NativeRegEx"); - if (clazz == NULL) { - return -1; - } - - if (env->RegisterNatives(clazz, sMethods, NELEM(sMethods)) < 0) { - return -1; - } - - return 0; -} diff --git a/libcore/icu/src/main/native/ResourceInterface.cpp b/libcore/icu/src/main/native/ResourceInterface.cpp deleted file mode 100644 index a88e15cd6..000000000 --- a/libcore/icu/src/main/native/ResourceInterface.cpp +++ /dev/null @@ -1,1437 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "JNIHelp.h" -#include "AndroidSystemNatives.h" -#include "unicode/numfmt.h" -#include "unicode/locid.h" -#include "unicode/ucal.h" -#include "unicode/gregocal.h" -#include "unicode/ucurr.h" -#include "unicode/calendar.h" -#include "unicode/datefmt.h" -#include "unicode/dtfmtsym.h" -#include "unicode/decimfmt.h" -#include "unicode/dcfmtsym.h" -#include "unicode/uclean.h" -#include "unicode/smpdtfmt.h" -#include "unicode/strenum.h" -#include "unicode/ustring.h" -#include "unicode/timezone.h" -#include "ErrorCode.h" -#include -#include -#include -#include -#include - -jclass string_class; - -static UBool icuError(JNIEnv *env, UErrorCode errorcode) -{ - const char *emsg = u_errorName(errorcode); - jclass exception; - - if (U_FAILURE(errorcode)) { - switch (errorcode) { - case U_ILLEGAL_ARGUMENT_ERROR : - exception = env->FindClass("java/lang/IllegalArgumentException"); - break; - case U_INDEX_OUTOFBOUNDS_ERROR : - case U_BUFFER_OVERFLOW_ERROR : - exception = env->FindClass("java/lang/ArrayIndexOutOfBoundsException"); - break; - case U_UNSUPPORTED_ERROR : - exception = env->FindClass("java/lang/UnsupportedOperationException"); - break; - default : - exception = env->FindClass("java/lang/RuntimeException"); - } - - return (env->ThrowNew(exception, emsg) != 0); - } - return 0; -} - -static Locale getLocale(JNIEnv *env, jstring locale) { - const char *name = env->GetStringUTFChars(locale, NULL); - Locale result = Locale::createFromName(name); - env->ReleaseStringUTFChars(locale, name); - return result; -} - -static jstring getJStringFromUnicodeString(JNIEnv *env, UnicodeString string) { - - UErrorCode status = U_ZERO_ERROR; - - int stringLength = string.length(); - jchar *res = (jchar *) malloc(sizeof(jchar) * (stringLength + 1)); - string.extract(res, stringLength+1, status); - if(U_FAILURE(status)) { - free(res); - LOGI("Error getting string for getJStringFromUnicodeString"); - status = U_ZERO_ERROR; - return NULL; - } - jstring result = env->NewString(res, stringLength); - free(res); - return result; -} - -static void addObject(JNIEnv *env, jobjectArray result, const char *keyStr, jobject elem, int index) { - jclass objArray_class = env->FindClass("java/lang/Object"); - jobjectArray element = env->NewObjectArray(2, objArray_class, NULL); - jstring key = env->NewStringUTF(keyStr); - env->SetObjectArrayElement(element, 0, key); - env->SetObjectArrayElement(element, 1, elem); - env->SetObjectArrayElement(result, index, element); - env->DeleteLocalRef(key); - env->DeleteLocalRef(element); -} - -static jint getFractionDigitsNative(JNIEnv* env, jclass clazz, - jstring currencyCode) { - // LOGI("ENTER getFractionDigitsNative"); - - UErrorCode status = U_ZERO_ERROR; - - NumberFormat *fmt = NumberFormat::createCurrencyInstance(status); - if(U_FAILURE(status)) { - return -1; - } - - const jchar *cCode = env->GetStringChars(currencyCode, NULL); - fmt->setCurrency(cCode, status); - env->ReleaseStringChars(currencyCode, cCode); - if(U_FAILURE(status)) { - return -1; - } - - // for CurrencyFormats the minimum and maximum fraction digits are the same. - int result = fmt->getMinimumFractionDigits(); - delete(fmt); - return result; -} - -static jstring getCurrencyCodeNative(JNIEnv* env, jclass clazz, - jstring key) { - // LOGI("ENTER getCurrencyCodeNative"); - - UErrorCode status = U_ZERO_ERROR; - - UResourceBundle *supplData = ures_openDirect(NULL, "supplementalData", &status); - if(U_FAILURE(status)) { - return NULL; - } - - UResourceBundle *currencyMap = ures_getByKey(supplData, "CurrencyMap", NULL, &status); - if(U_FAILURE(status)) { - ures_close(supplData); - return NULL; - } - - const char *keyChars = env->GetStringUTFChars(key, NULL); - UResourceBundle *currency = ures_getByKey(currencyMap, keyChars, NULL, &status); - env->ReleaseStringUTFChars(key, keyChars); - if(U_FAILURE(status)) { - ures_close(currencyMap); - ures_close(supplData); - return NULL; - } - - UResourceBundle *currencyElem = ures_getByIndex(currency, 0, NULL, &status); - if(U_FAILURE(status)) { - ures_close(currency); - ures_close(currencyMap); - ures_close(supplData); - return env->NewStringUTF("None"); - } - - // check if there is a to date. If there is, the currency isn't used anymore. - UResourceBundle *currencyTo = ures_getByKey(currencyElem, "to", NULL, &status); - if(!U_FAILURE(status)) { - // return and let the ResourceBundle throw an exception - ures_close(currencyElem); - ures_close(currency); - ures_close(currencyMap); - ures_close(supplData); - return NULL; - } - status = U_ZERO_ERROR; - ures_close(currencyTo); - - UResourceBundle *currencyId = ures_getByKey(currencyElem, "id", NULL, &status); - if(U_FAILURE(status)) { - // No id defined for this country - ures_close(currencyElem); - ures_close(currency); - ures_close(currencyMap); - ures_close(supplData); - return env->NewStringUTF("None"); - } - - int length; - const jchar *id = ures_getString(currencyId, &length, &status); - if(U_FAILURE(status)) { - ures_close(currencyId); - ures_close(currencyElem); - ures_close(currency); - ures_close(currencyMap); - ures_close(supplData); - return env->NewStringUTF("None"); - } - - ures_close(currencyId); - ures_close(currencyElem); - ures_close(currency); - ures_close(currencyMap); - ures_close(supplData); - - if(length == 0) { - return env->NewStringUTF("None"); - } - return env->NewString(id, length); -} - -static jstring getCurrencySymbolNative(JNIEnv* env, jclass clazz, - jstring locale, jstring currencyCode) { - // LOGI("ENTER getCurrencySymbolNative"); - - UErrorCode status = U_ZERO_ERROR; - - const char *locName = env->GetStringUTFChars(locale, NULL); - UResourceBundle *root = ures_open(NULL, locName, &status); - env->ReleaseStringUTFChars(locale, locName); - if(U_FAILURE(status)) { - return NULL; - } - - UResourceBundle *rootElems = ures_getByKey(root, "Currencies", NULL, &status); - if(U_FAILURE(status)) { - ures_close(root); - return NULL; - } - - const char *currName = env->GetStringUTFChars(currencyCode, NULL); - UResourceBundle *currencyElems = ures_getByKey(rootElems, currName, NULL, &status); - env->ReleaseStringUTFChars(currencyCode, currName); - if(U_FAILURE(status)) { - ures_close(rootElems); - ures_close(root); - return NULL; - } - - int currSymbL; - const jchar *currSymbU = ures_getStringByIndex(currencyElems, 0, &currSymbL, &status); - if(U_FAILURE(status)) { - ures_close(currencyElems); - ures_close(rootElems); - ures_close(root); - return NULL; - } - - ures_close(currencyElems); - ures_close(rootElems); - ures_close(root); - - if(currSymbL == 0) { - return NULL; - } - return env->NewString(currSymbU, currSymbL); -} - -static jstring getDisplayCountryNative(JNIEnv* env, jclass clazz, - jstring targetLocale, jstring locale) { - // LOGI("ENTER getDisplayCountryNative"); - - UErrorCode status = U_ZERO_ERROR; - - Locale loc = getLocale(env, locale); - Locale targetLoc = getLocale(env, targetLocale); - - UnicodeString string; - targetLoc.getDisplayCountry(loc, string); - - jstring result = getJStringFromUnicodeString(env, string); - - return result; -} - -static jstring getDisplayLanguageNative(JNIEnv* env, jclass clazz, - jstring targetLocale, jstring locale) { - // LOGI("ENTER getDisplayLanguageNative"); - - Locale loc = getLocale(env, locale); - Locale targetLoc = getLocale(env, targetLocale); - - UnicodeString string; - targetLoc.getDisplayLanguage(loc, string); - - jstring result = getJStringFromUnicodeString(env, string); - - return result; -} - -static jstring getDisplayVariantNative(JNIEnv* env, jclass clazz, - jstring targetLocale, jstring locale) { - // LOGI("ENTER getDisplayVariantNative"); - - Locale loc = getLocale(env, locale); - Locale targetLoc = getLocale(env, targetLocale); - - UnicodeString string; - targetLoc.getDisplayVariant(loc, string); - - jstring result = getJStringFromUnicodeString(env, string); - - return result; -} - -static jstring getISO3CountryNative(JNIEnv* env, jclass clazz, jstring locale) { - // LOGI("ENTER getISO3CountryNative"); - - Locale loc = getLocale(env, locale); - - const char *string = loc.getISO3Country(); - - jstring result = env->NewStringUTF(string); - - return result; -} - -static jstring getISO3LanguageNative(JNIEnv* env, jclass clazz, jstring locale) { - // LOGI("ENTER getISO3LanguageNative"); - - Locale loc = getLocale(env, locale); - - const char *string = loc.getISO3Language(); - - jstring result = env->NewStringUTF(string); - - return result; -} - -static jobjectArray getISOCountriesNative(JNIEnv* env, jclass clazz) { - // LOGI("ENTER getISOCountriesNative"); - - const char* const* strings = Locale::getISOCountries(); - - int count = 0; - while(strings[count] != NULL) { - count++; - } - - jobjectArray result = env->NewObjectArray(count, string_class, NULL); - - jstring res; - for(int i = 0; i < count; i++) { - res = env->NewStringUTF(strings[i]); - env->SetObjectArrayElement(result, i, res); - env->DeleteLocalRef(res); - } - return result; -} - -static jobjectArray getISOLanguagesNative(JNIEnv* env, jclass clazz) { - // LOGI("ENTER getISOLanguagesNative"); - - const char* const* strings = Locale::getISOLanguages(); - - const char *string = strings[0]; - - int count = 0; - while(strings[count] != NULL) { - count++; - } - - jobjectArray result = env->NewObjectArray(count, string_class, NULL); - - jstring res; - for(int i = 0; i < count; i++) { - res = env->NewStringUTF(strings[i]); - env->SetObjectArrayElement(result, i, res); - env->DeleteLocalRef(res); - } - return result; -} - -static jobjectArray getAvailableLocalesNative(JNIEnv* env, jclass clazz) { - // LOGI("ENTER getAvailableLocalesNative"); - - int count = uloc_countAvailable(); - - jobjectArray result = env->NewObjectArray(count, string_class, NULL); - - jstring res; - const char * string; - for(int i = 0; i < count; i++) { - string = uloc_getAvailable(i); - res = env->NewStringUTF(string); - env->SetObjectArrayElement(result, i, res); - env->DeleteLocalRef(res); - } - - return result; -} - -static void getTimeZonesNative(JNIEnv* env, jclass clazz, - jobjectArray outerArray, jstring locale) { - // LOGI("ENTER getTimeZonesNative"); - - UErrorCode status = U_ZERO_ERROR; - - jobjectArray zoneIdArray; - jobjectArray longStdTimeArray; - jobjectArray shortStdTimeArray; - jobjectArray longDlTimeArray; - jobjectArray shortDlTimeArray; - - jstring content; - jstring strObj; - const jchar *res; - UnicodeString resU; - jint length; - const UnicodeString *zoneID; - DateFormat *df; - - UnicodeString longPattern("zzzz",""); - UnicodeString shortPattern("z",""); - - Locale loc = getLocale(env, locale); - - SimpleDateFormat longFormat(longPattern, loc, status); - SimpleDateFormat shortFormat(shortPattern, loc, status); - - - zoneIdArray = (jobjectArray) env->GetObjectArrayElement(outerArray, 0); - longStdTimeArray = (jobjectArray) env->GetObjectArrayElement(outerArray, 1); - shortStdTimeArray = (jobjectArray) env->GetObjectArrayElement(outerArray, 2); - longDlTimeArray = (jobjectArray) env->GetObjectArrayElement(outerArray, 3); - shortDlTimeArray = (jobjectArray) env->GetObjectArrayElement(outerArray, 4); - - int count = env->GetArrayLength(zoneIdArray); - - TimeZone* zones[count]; - - // get all timezone objects - for(int i = 0; i < count; i++) { - strObj = (jstring) env->GetObjectArrayElement(zoneIdArray, i); - length = env->GetStringLength(strObj); - res = env->GetStringChars(strObj, NULL); - const UnicodeString zoneID((UChar *)res, length); - env->ReleaseStringChars(strObj, res); - zones[i] = TimeZone::createTimeZone(zoneID); - env->DeleteLocalRef(strObj); - } - - // 15th January 2008 - UDate date1 = 1203105600000.0; - // 15th July 2008 - UDate date2 = 1218826800000.0; - - for (int i = 0; i < count; i++) { - TimeZone *tz = zones[i]; - longFormat.setTimeZone(*tz); - shortFormat.setTimeZone(*tz); - - int32_t daylightOffset; - int32_t rawOffset; - UDate standardDate; - UDate daylightSavingDate; - tz->getOffset(date1, false, rawOffset, daylightOffset, status); - if (daylightOffset != 0) { - // The Timezone is reporting that we are in daylight time - // for the winter date. The dates are for the wrong hemisphere, - // swap them. - standardDate = date2; - daylightSavingDate = date1; - } else { - standardDate = date1; - daylightSavingDate = date2; - } - - UnicodeString shortDayLight; - UnicodeString longDayLight; - UnicodeString shortStandard; - UnicodeString longStandard; - - shortFormat.format(daylightSavingDate, shortDayLight); - content = getJStringFromUnicodeString(env, shortDayLight); - env->SetObjectArrayElement(shortDlTimeArray, i, content); - env->DeleteLocalRef(content); - - shortFormat.format(standardDate, shortStandard); - content = getJStringFromUnicodeString(env, shortStandard); - env->SetObjectArrayElement(shortStdTimeArray, i, content); - env->DeleteLocalRef(content); - - longFormat.format (daylightSavingDate, longDayLight); - content = getJStringFromUnicodeString(env, longDayLight); - env->SetObjectArrayElement(longDlTimeArray, i, content); - env->DeleteLocalRef(content); - - longFormat.format (standardDate, longStandard); - content = getJStringFromUnicodeString(env, longStandard); - env->SetObjectArrayElement(longStdTimeArray, i, content); - env->DeleteLocalRef(content); - delete(tz); - } -} - - - - -static jstring getDisplayTimeZoneNative(JNIEnv* env, jclass clazz, - jstring zoneID, jboolean isDST, jint style, jstring localeID) { - - // Build TimeZone object - const jchar* idChars = env->GetStringChars(zoneID, NULL); - jint idLength = env->GetStringLength(zoneID); - UnicodeString idString((UChar*)idChars, idLength); - TimeZone* zone = TimeZone::createTimeZone(idString); - env->ReleaseStringChars(zoneID, idChars); - - // Build Locale object (can we rely on zero termination of JNI result?) - const char* localeChars = env->GetStringUTFChars(localeID, NULL); - jint localeLength = env->GetStringLength(localeID); - Locale locale = Locale::createFromName(localeChars); - - // Try to get the display name of the TimeZone according to the Locale - UnicodeString buffer; - zone->getDisplayName((UBool)isDST, (style == 0 ? TimeZone::SHORT : TimeZone::LONG), locale, buffer); - const UChar* tempChars = buffer.getBuffer(); - int tempLength = buffer.length(); - jstring result = env->NewString((jchar*)tempChars, tempLength); - env->ReleaseStringUTFChars(localeID, localeChars); - - // Clean up everything - delete(zone); - - return result; -} - -static void getDayInitVector(JNIEnv *env, UResourceBundle *gregorian, int *values) { - - UErrorCode status = U_ZERO_ERROR; - - // get the First day of week and the minimal days in first week numbers - UResourceBundle *gregorianElems = ures_getByKey(gregorian, "DateTimeElements", NULL, &status); - if(U_FAILURE(status)) { - return; - } - - int intVectSize; - const int *result; - result = ures_getIntVector(gregorianElems, &intVectSize, &status); - if(U_FAILURE(status)) { - ures_close(gregorianElems); - return; - } - - if(intVectSize == 2) { - values[0] = result[0]; - values[1] = result[1]; - } - - ures_close(gregorianElems); - -} - -static jobjectArray getAmPmMarkers(JNIEnv *env, UResourceBundle *gregorian) { - - jobjectArray amPmMarkers; - jstring pmU, amU; - - UErrorCode status = U_ZERO_ERROR; - - UResourceBundle *gregorianElems; - - gregorianElems = ures_getByKey(gregorian, "AmPmMarkers", NULL, &status); - if(U_FAILURE(status)) { - return NULL; - } - - int lengthAm, lengthPm; - - ures_resetIterator(gregorianElems); - - const jchar* am = ures_getStringByIndex(gregorianElems, 0, &lengthAm, &status); - const jchar* pm = ures_getStringByIndex(gregorianElems, 1, &lengthPm, &status); - - if(U_FAILURE(status)) { - ures_close(gregorianElems); - return NULL; - } - - amPmMarkers = env->NewObjectArray(2, string_class, NULL); - amU = env->NewString(am, lengthAm); - env->SetObjectArrayElement(amPmMarkers, 0, amU); - env->DeleteLocalRef(amU); - pmU = env->NewString(pm, lengthPm); - env->SetObjectArrayElement(amPmMarkers, 1, pmU); - env->DeleteLocalRef(pmU); - ures_close(gregorianElems); - - return amPmMarkers; -} - -static jobjectArray getEras(JNIEnv* env, UResourceBundle *gregorian) { - - jobjectArray eras; - jstring eraU; - const jchar* era; - - UErrorCode status = U_ZERO_ERROR; - - UResourceBundle *gregorianElems; - UResourceBundle *eraElems; - - gregorianElems = ures_getByKey(gregorian, "eras", NULL, &status); - if(U_FAILURE(status)) { - return NULL; - } - - eraElems = ures_getByKey(gregorianElems, "abbreviated", NULL, &status); - if(U_FAILURE(status)) { - ures_close(gregorianElems); - return NULL; - } - - int eraLength; - - int eraCount = ures_getSize(eraElems); - eras = env->NewObjectArray(eraCount, string_class, NULL); - - ures_resetIterator(eraElems); - for(int i = 0; i < eraCount; i++) { - era = ures_getStringByIndex(eraElems, i, &eraLength, &status); - if(U_FAILURE(status)) { - ures_close(gregorianElems); - ures_close(eraElems); - return NULL; - } - eraU = env->NewString(era, eraLength); - env->SetObjectArrayElement(eras, i, eraU); - env->DeleteLocalRef(eraU); - } - ures_close(eraElems); - ures_close(gregorianElems); - - return eras; -} - -static jobjectArray getMonthNames(JNIEnv *env, UResourceBundle *gregorian) { - - UErrorCode status = U_ZERO_ERROR; - - const jchar* month; - jstring monthU; - - UResourceBundle *gregorianElems = ures_getByKey(gregorian, "monthNames", NULL, &status); - if(U_FAILURE(status)) { - return NULL; - } - - UResourceBundle *monthNameElems = ures_getByKey(gregorianElems, "format", NULL, &status); - if(U_FAILURE(status)) { - ures_close(gregorianElems); - return NULL; - } - - UResourceBundle *monthNameElemsFormat = ures_getByKey(monthNameElems, "wide", NULL, &status); - if(U_FAILURE(status)) { - ures_close(monthNameElems); - ures_close(gregorianElems); - return NULL; - } - - int monthNameLength; - ures_resetIterator(monthNameElemsFormat); - int monthCount = ures_getSize(monthNameElemsFormat); - jobjectArray months = env->NewObjectArray(monthCount + 1, string_class, NULL); - for(int i = 0; i < monthCount; i++) { - month = ures_getStringByIndex(monthNameElemsFormat, i, &monthNameLength, &status); - if(U_FAILURE(status)) { - ures_close(monthNameElemsFormat); - ures_close(monthNameElems); - ures_close(gregorianElems); - return NULL; - } - monthU = env->NewString(month, monthNameLength); - env->SetObjectArrayElement(months, i, monthU); - env->DeleteLocalRef(monthU); - } - - monthU = env->NewStringUTF(""); - env->SetObjectArrayElement(months, monthCount, monthU); - env->DeleteLocalRef(monthU); - - ures_close(monthNameElemsFormat); - ures_close(monthNameElems); - ures_close(gregorianElems); - return months; -} - -static jobjectArray getShortMonthNames(JNIEnv *env, UResourceBundle *gregorian) { - - UErrorCode status = U_ZERO_ERROR; - - const jchar* shortMonth; - jstring shortMonthU; - - UResourceBundle *gregorianElems = ures_getByKey(gregorian, "monthNames", NULL, &status); - if(U_FAILURE(status)) { - return NULL; - } - - UResourceBundle *monthNameElems = ures_getByKey(gregorianElems, "format", NULL, &status); - if(U_FAILURE(status)) { - ures_close(gregorianElems); - return NULL; - } - - UResourceBundle *monthNameElemsFormat = ures_getByKey(monthNameElems, "abbreviated", NULL, &status); - if(U_FAILURE(status)) { - ures_close(monthNameElems); - ures_close(gregorianElems); - return NULL; - } - - int shortMonthNameLength; - ures_resetIterator(monthNameElemsFormat); - int shortMonthCount = ures_getSize(monthNameElemsFormat); - // the array length is +1 because the harmony locales had an empty string at the end of their month name array - jobjectArray shortMonths = env->NewObjectArray(shortMonthCount + 1, string_class, NULL); - for(int i = 0; i < shortMonthCount; i++) { - shortMonth = ures_getStringByIndex(monthNameElemsFormat, i, &shortMonthNameLength, &status); - if(U_FAILURE(status)) { - ures_close(monthNameElemsFormat); - ures_close(monthNameElems); - ures_close(gregorianElems); - return NULL; - } - shortMonthU = env->NewString(shortMonth, shortMonthNameLength); - env->SetObjectArrayElement(shortMonths, i, shortMonthU); - env->DeleteLocalRef(shortMonthU); - } - - shortMonthU = env->NewStringUTF(""); - env->SetObjectArrayElement(shortMonths, shortMonthCount, shortMonthU); - env->DeleteLocalRef(shortMonthU); - - ures_close(monthNameElemsFormat); - ures_close(monthNameElems); - ures_close(gregorianElems); - return shortMonths; -} - -static jobjectArray getWeekdayNames(JNIEnv *env, UResourceBundle *gregorian) { - - UErrorCode status = U_ZERO_ERROR; - - const jchar* day; - jstring dayU; - - UResourceBundle *gregorianElems = ures_getByKey(gregorian, "dayNames", NULL, &status); - if(U_FAILURE(status)) { - return NULL; - } - - UResourceBundle *dayNameElems = ures_getByKey(gregorianElems, "format", NULL, &status); - if(U_FAILURE(status)) { - ures_close(gregorianElems); - return NULL; - } - - UResourceBundle *dayNameElemsFormat = ures_getByKey(dayNameElems, "wide", NULL, &status); - if(U_FAILURE(status)) { - ures_close(dayNameElems); - ures_close(gregorianElems); - return NULL; - } - - int dayNameLength; - ures_resetIterator(dayNameElemsFormat); - int dayCount = ures_getSize(dayNameElemsFormat); - jobjectArray weekdays = env->NewObjectArray(dayCount + 1, string_class, NULL); - // first entry in the weekdays array is an empty string - env->SetObjectArrayElement(weekdays, 0, env->NewStringUTF("")); - for(int i = 0; i < dayCount; i++) { - day = ures_getStringByIndex(dayNameElemsFormat, i, &dayNameLength, &status); - if(U_FAILURE(status)) { - ures_close(dayNameElemsFormat); - ures_close(dayNameElems); - ures_close(gregorianElems); - return NULL; - } - dayU = env->NewString(day, dayNameLength); - env->SetObjectArrayElement(weekdays, i + 1, dayU); - env->DeleteLocalRef(dayU); - } - - ures_close(dayNameElemsFormat); - ures_close(dayNameElems); - ures_close(gregorianElems); - return weekdays; - -} - -static jobjectArray getShortWeekdayNames(JNIEnv *env, UResourceBundle *gregorian) { - - UErrorCode status = U_ZERO_ERROR; - - const jchar* shortDay; - jstring shortDayU; - - UResourceBundle *gregorianElems = ures_getByKey(gregorian, "dayNames", NULL, &status); - if(U_FAILURE(status)) { - return NULL; - } - - UResourceBundle *dayNameElems = ures_getByKey(gregorianElems, "format", NULL, &status); - if(U_FAILURE(status)) { - ures_close(gregorianElems); - return NULL; - } - - UResourceBundle *dayNameElemsFormat = ures_getByKey(dayNameElems, "abbreviated", NULL, &status); - if(U_FAILURE(status)) { - ures_close(dayNameElems); - ures_close(gregorianElems); - return NULL; - } - - int shortDayNameLength; - ures_resetIterator(dayNameElemsFormat); - int shortDayCount = ures_getSize(dayNameElemsFormat); - jobjectArray shortWeekdays = env->NewObjectArray(shortDayCount + 1, string_class, NULL); - env->SetObjectArrayElement(shortWeekdays, 0, env->NewStringUTF("")); - for(int i = 0; i < shortDayCount; i++) { - shortDay = ures_getStringByIndex(dayNameElemsFormat, i, &shortDayNameLength, &status); - if(U_FAILURE(status)) { - ures_close(dayNameElemsFormat); - ures_close(dayNameElems); - ures_close(gregorianElems); - return NULL; - } - shortDayU = env->NewString(shortDay, shortDayNameLength); - env->SetObjectArrayElement(shortWeekdays, i + 1, shortDayU); - env->DeleteLocalRef(shortDayU); - } - - ures_close(dayNameElemsFormat); - ures_close(dayNameElems); - ures_close(gregorianElems); - return shortWeekdays; -} - -static jstring getDecimalPatternChars(JNIEnv *env, UResourceBundle *rootElems) { - - UErrorCode status = U_ZERO_ERROR; - - int zeroL, digitL, decSepL, groupL, listL, percentL, permillL, expL, currSepL, minusL; - int patternLength; - - jchar *patternChars; - - const jchar* zero = ures_getStringByIndex(rootElems, 4, &zeroL, &status); - - const jchar* digit = ures_getStringByIndex(rootElems, 5, &digitL, &status); - - const jchar* decSep = ures_getStringByIndex(rootElems, 0, &decSepL, &status); - - const jchar* group = ures_getStringByIndex(rootElems, 1, &groupL, &status); - - const jchar* list = ures_getStringByIndex(rootElems, 2, &listL, &status); - - const jchar* percent = ures_getStringByIndex(rootElems, 3, &percentL, &status); - - const jchar* permill = ures_getStringByIndex(rootElems, 8, &permillL, &status); - - const jchar* exp = ures_getStringByIndex(rootElems, 7, &expL, &status); - - const jchar* currSep = ures_getStringByIndex(rootElems, 0, &currSepL, &status); - - const jchar* minus = ures_getStringByIndex(rootElems, 6, &minusL, &status); - - if(U_FAILURE(status)) { - return NULL; - } - - - patternChars = (jchar *) malloc(11 * sizeof(jchar)); - - patternChars[0] = 0; - - u_strncat(patternChars, zero, 1); - u_strncat(patternChars, digit, 1); - u_strncat(patternChars, decSep, 1); - u_strncat(patternChars, group, 1); - u_strncat(patternChars, list, 1); - u_strncat(patternChars, percent, 1); - u_strncat(patternChars, permill, 1); - u_strncat(patternChars, exp, 1); - u_strncat(patternChars, currSep, 1); - u_strncat(patternChars, minus, 1); - - jstring decimalPatternChars = env->NewString(patternChars, 10); - - free(patternChars); - - return decimalPatternChars; -} - -static jstring getIntCurrencyCode(JNIEnv *env, jclass clazz, jstring locale) { - - const char *locStr = env->GetStringUTFChars(locale, NULL); - char country[3] = {0,0,0}; - - // getting the 2 character country name - if(strlen(locStr) < 5) { - env->ReleaseStringUTFChars(locale, locStr); - return NULL; - } - if(locStr[3] < 'A' || locStr[3] > 'Z' || locStr[4] < 'A' || locStr[4] > 'Z') { - env->ReleaseStringUTFChars(locale, locStr); - return NULL; - } - country[0] = locStr[3]; - country[1] = locStr[4]; - - env->ReleaseStringUTFChars(locale, locStr); - - return getCurrencyCodeNative(env, clazz, env->NewStringUTF(country)); -} - -static jstring getCurrencySymbol(JNIEnv *env, jclass clazz, jstring locale, jstring intCurrencySymbol) { - - jstring result = getCurrencySymbolNative(env, clazz, locale, intCurrencySymbol); - if(result == intCurrencySymbol) { - return NULL; - } - return result; - -} - -static jobjectArray getContentImpl(JNIEnv* env, jclass clazz, - jstring locale, jboolean needsTZ) { - - UErrorCode status = U_ZERO_ERROR; - - const char *loc = env->GetStringUTFChars(locale, NULL); - UResourceBundle *root = ures_openU(NULL, loc, &status); - - env->ReleaseStringUTFChars(locale, loc); - if(U_FAILURE(status)) { - LOGI("Error getting resources"); - status = U_ZERO_ERROR; - return NULL; - } - - - - jclass obj_class = env->FindClass("[Ljava/lang/Object;"); - jclass integer_class = env->FindClass("java/lang/Integer"); - jmethodID integerInit = env->GetMethodID(integer_class, "", "(I)V"); - jobjectArray result; - - jobject firstDayOfWeek = NULL; - jobject minimalDaysInFirstWeek = NULL; - jobjectArray amPmMarkers = NULL; - jobjectArray eras = NULL; - jstring localPatternChars = NULL; - jobjectArray weekdays = NULL; - jobjectArray shortWeekdays = NULL; - jobjectArray months = NULL; - jobjectArray shortMonths = NULL; - jstring time_SHORT = NULL; - jstring time_MEDIUM = NULL; - jstring time_LONG = NULL; - jstring time_FULL = NULL; - jstring date_SHORT = NULL; - jstring date_MEDIUM = NULL; - jstring date_LONG = NULL; - jstring date_FULL = NULL; - jstring decimalPatternChars = NULL; - jstring naN = NULL; - jstring infinity = NULL; - jstring currencySymbol = NULL; - jstring intCurrencySymbol = NULL; - jstring numberPattern = NULL; - jstring integerPattern = NULL; - jstring currencyPattern = NULL; - jstring percentPattern = NULL; - jobjectArray zones = NULL; - - int counter = 0; - - int firstDayVals[2] = {-1, -1}; - - const jchar* nan = (const jchar *)NULL; - const jchar* inf = (const jchar *)NULL; - int nanL, infL; - - - UResourceBundle *gregorian; - UResourceBundle *gregorianElems; - UResourceBundle *rootElems; - - - - - // get the resources needed - rootElems = ures_getByKey(root, "calendar", NULL, &status); - if(U_FAILURE(status)) { - return NULL; - } - - gregorian = ures_getByKey(rootElems, "gregorian", NULL, &status); - if(U_FAILURE(status)) { - ures_close(rootElems); - return NULL; - } - - - - // adding the first day of week and minimal days in first week values - getDayInitVector(env, gregorian, firstDayVals); - if((firstDayVals[0] != -1) && (firstDayVals[1] != -1)) { - firstDayOfWeek = env->NewObject(integer_class, integerInit, firstDayVals[0]); - minimalDaysInFirstWeek = env->NewObject(integer_class, integerInit, firstDayVals[1]); - // adding First_Day and Minimal_Days integer to the result - counter += 2; - } - - - // adding ampm string array to the result"); - amPmMarkers = getAmPmMarkers(env, gregorian); - if(amPmMarkers != NULL) { - counter++; - } - - - // adding eras string array to the result - eras = getEras(env, gregorian); - if(eras != NULL) { - counter++; - } - - - // local pattern chars are initially always the same - localPatternChars = env->NewStringUTF("GyMdkHmsSEDFwWahKzZ"); - // adding local pattern chars string to the result - counter++; - - - // adding month names string array to the result - months = getMonthNames(env, gregorian); - if(months != NULL) { - counter++; - } - - - // adding short month names string array to the result - shortMonths = getShortMonthNames(env, gregorian); - if(shortMonths != NULL) { - counter++; - } - - - // adding day names string array to the result - weekdays = getWeekdayNames(env, gregorian); - if(weekdays != NULL) { - counter++; - } - - - // adding short day names string array to the result - shortWeekdays = getShortWeekdayNames(env, gregorian); - if(shortWeekdays != NULL) { - counter++; - } - - const UChar *pattern; - jchar check[2] = {0, 0}; - u_uastrcpy(check, "v"); - jchar replacement[2] = {0, 0}; - u_uastrcpy(replacement, "z"); - jchar *pos; - jchar *patternCopy; - int patternLength; - - // adding date and time format patterns to the result - gregorianElems = ures_getByKey(gregorian, "DateTimePatterns", NULL, &status); - if(U_FAILURE(status)) { - status = U_ZERO_ERROR; - goto endOfCalendar; - } - - pattern = ures_getStringByIndex(gregorianElems, 0, &patternLength, &status); - // there are some patterns in icu that use the pattern character 'v' - // java doesn't accept this, so it gets replaced by 'z' which has - // about the same result as 'v', the timezone name. - // 'v' -> "PT", 'z' -> "PST", v is the generic timezone and z the standard tz - // "vvvv" -> "Pacific Time", "zzzz" -> "Pacific Standard Time" - patternCopy = (jchar *) malloc((patternLength + 1) * sizeof(jchar)); - u_strcpy(patternCopy, pattern); - if(U_FAILURE(status)) { - free(patternCopy); - status = U_ZERO_ERROR; - goto endOfCalendar; - } - while((pos = u_strchr(patternCopy, check[0])) != NULL) { - u_memset(pos, replacement[0], 1); - } - time_FULL = env->NewString(patternCopy, patternLength); - free(patternCopy); - counter++; - - pattern = ures_getStringByIndex(gregorianElems, 1, &patternLength, &status); - if(U_FAILURE(status)) { - status = U_ZERO_ERROR; - goto endOfCalendar; - } - time_LONG = env->NewString(pattern, patternLength); - counter++; - - pattern = ures_getStringByIndex(gregorianElems, 2, &patternLength, &status); - if(U_FAILURE(status)) { - status = U_ZERO_ERROR; - goto endOfCalendar; - } - time_MEDIUM = env->NewString(pattern, patternLength); - counter++; - - pattern = ures_getStringByIndex(gregorianElems, 3, &patternLength, &status); - if(U_FAILURE(status)) { - status = U_ZERO_ERROR; - goto endOfCalendar; - } - time_SHORT = env->NewString(pattern, patternLength); - counter++; - - pattern = ures_getStringByIndex(gregorianElems, 4, &patternLength, &status); - if(U_FAILURE(status)) { - status = U_ZERO_ERROR; - goto endOfCalendar; - } - date_FULL = env->NewString(pattern, patternLength); - counter++; - - pattern = ures_getStringByIndex(gregorianElems, 5, &patternLength, &status); - if(U_FAILURE(status)) { - status = U_ZERO_ERROR; - goto endOfCalendar; - } - date_LONG = env->NewString(pattern, patternLength); - counter++; - - pattern = ures_getStringByIndex(gregorianElems, 6, &patternLength, &status); - if(U_FAILURE(status)) { - status = U_ZERO_ERROR; - goto endOfCalendar; - } - date_MEDIUM = env->NewString(pattern, patternLength); - counter++; - - pattern = ures_getStringByIndex(gregorianElems, 7, &patternLength, &status); - if(U_FAILURE(status)) { - status = U_ZERO_ERROR; - goto endOfCalendar; - } - date_SHORT = env->NewString(pattern, patternLength); - counter++; - - -endOfCalendar: - - if(gregorianElems != NULL) { - ures_close(gregorianElems); - } - ures_close(gregorian); - ures_close(rootElems); - - - rootElems = ures_getByKey(root, "NumberElements", NULL, &status); - if(U_FAILURE(status)) { - status = U_ZERO_ERROR; - } - - if(ures_getSize(rootElems) >= 11) { - - // adding decimal pattern chars to the result - decimalPatternChars = getDecimalPatternChars(env, rootElems); - if(decimalPatternChars != NULL) { - counter++; - } - - // adding NaN pattern char to the result - nan = ures_getStringByIndex(rootElems, 10, &nanL, &status); - if(U_SUCCESS(status)) { - naN = env->NewString(nan, nanL); - counter++; - } - status = U_ZERO_ERROR; - - // adding infinity pattern char to the result - inf = ures_getStringByIndex(rootElems, 9, &infL, &status); - if(U_SUCCESS(status)) { - infinity = env->NewString(inf, infL); - counter++; - } - status = U_ZERO_ERROR; - } - - ures_close(rootElems); - - - // adding intl currency code to result - intCurrencySymbol = getIntCurrencyCode(env, clazz, locale); - if(intCurrencySymbol != NULL) { - // adding currency symbol to result - currencySymbol = getCurrencySymbol(env, clazz, locale, intCurrencySymbol); - } else { - intCurrencySymbol = env->NewStringUTF("XXX"); - } - if(currencySymbol == NULL) { - // creating a new string explicitly with the UTF-8 encoding of "\u00a4" - currencySymbol = env->NewStringUTF("\xc2\xa4"); - } - counter += 2; - - - // adding number format patterns to the result - int numOfEntries; - int decSepOffset; - NumberFormat *nf; - jchar *tmpPattern; - - rootElems = ures_getByKey(root, "NumberPatterns", NULL, &status); - if(U_FAILURE(status)) { - status = U_ZERO_ERROR; - goto zones; - } - - numOfEntries = ures_getSize(rootElems); - if(numOfEntries < 3) { - ures_close(rootElems); - goto zones; - } - - // number pattern - pattern = ures_getStringByIndex(rootElems, 0, &patternLength, &status); - if(U_FAILURE(status)) { - status = U_ZERO_ERROR; - ures_close(rootElems); - goto zones; - } - numberPattern = env->NewString(pattern, patternLength); - counter++; - - // integer pattern derived from number pattern - // We need to convert a C string literal to a UChar string for u_strcspn. - static const char c_decSep[] = "."; - UChar decSep[sizeof(c_decSep)]; - u_charsToUChars(c_decSep, decSep, sizeof(c_decSep)); - decSepOffset = u_strcspn(pattern, decSep); - tmpPattern = (jchar *) malloc((decSepOffset + 1) * sizeof(jchar)); - u_strncpy(tmpPattern, pattern, decSepOffset); - integerPattern = env->NewString(tmpPattern, decSepOffset); - free(tmpPattern); - counter++; - - // currency pattern - pattern = ures_getStringByIndex(rootElems, 1, &patternLength, &status); - if(U_FAILURE(status)) { - status = U_ZERO_ERROR; - ures_close(rootElems); - goto zones; - } - currencyPattern = env->NewString(pattern, patternLength); - counter++; - - // percent pattern - pattern = ures_getStringByIndex(rootElems, 2, &patternLength, &status); - if(U_FAILURE(status)) { - status = U_ZERO_ERROR; - ures_close(rootElems); - goto zones; - } - percentPattern = env->NewString(pattern, patternLength); - counter++; - - ures_close(rootElems); - -zones: - - ures_close(root); - - - if(needsTZ == JNI_TRUE) { - counter++; //add empty timezone - } - - - - // collect all content and put it into an array - result = env->NewObjectArray(counter, obj_class, NULL); - - int index = 0; - - if(needsTZ == JNI_TRUE) { - addObject(env, result, "timezones", NULL, index++); - } - if(firstDayOfWeek != NULL && index < counter) { - addObject(env, result, "First_Day", firstDayOfWeek, index++); - } - if(minimalDaysInFirstWeek != NULL && index < counter) { - addObject(env, result, "Minimal_Days", minimalDaysInFirstWeek, index++); - } - if(amPmMarkers != NULL && index < counter) { - addObject(env, result, "ampm", amPmMarkers, index++); - } - if(eras != NULL && index < counter) { - addObject(env, result, "eras", eras, index++); - } - if(localPatternChars != NULL && index < counter) { - addObject(env, result, "LocalPatternChars", localPatternChars, index++); - } - if(weekdays != NULL && index < counter) { - addObject(env, result, "weekdays", weekdays, index++); - } - if(shortWeekdays != NULL && index < counter) { - addObject(env, result, "shortWeekdays", shortWeekdays, index++); - } - if(months != NULL && index < counter) { - addObject(env, result, "months", months, index++); - } - if(shortMonths != NULL && index < counter) { - addObject(env, result, "shortMonths", shortMonths, index++); - } - if(time_SHORT != NULL && index < counter) { - addObject(env, result, "Time_SHORT", time_SHORT, index++); - } - if(time_MEDIUM != NULL && index < counter) { - addObject(env, result, "Time_MEDIUM", time_MEDIUM, index++); - } - if(time_LONG != NULL && index < counter) { - addObject(env, result, "Time_LONG", time_LONG, index++); - } - if(time_FULL != NULL && index < counter) { - addObject(env, result, "Time_FULL", time_FULL, index++); - } - if(date_SHORT != NULL && index < counter) { - addObject(env, result, "Date_SHORT", date_SHORT, index++); - } - if(date_MEDIUM != NULL && index < counter) { - addObject(env, result, "Date_MEDIUM", date_MEDIUM, index++); - } - if(date_LONG != NULL && index < counter) { - addObject(env, result, "Date_LONG", date_LONG, index++); - } - if(date_FULL != NULL && index < counter) { - addObject(env, result, "Date_FULL", date_FULL, index++); - } - if(decimalPatternChars != NULL && index < counter) { - addObject(env, result, "DecimalPatternChars", decimalPatternChars, index++); - } - if(naN != NULL && index < counter) { - addObject(env, result, "NaN", naN, index++); - } - if(infinity != NULL && index < counter) { - addObject(env, result, "Infinity", infinity, index++); - } - if(currencySymbol != NULL && index < counter) { - addObject(env, result, "CurrencySymbol", currencySymbol, index++); - } - if(intCurrencySymbol != NULL && index < counter) { - addObject(env, result, "IntCurrencySymbol", intCurrencySymbol, index++); - } - if(numberPattern != NULL && index < counter) { - addObject(env, result, "Number", numberPattern, index++); - } - if(integerPattern != NULL && index < counter) { - addObject(env, result, "Integer", integerPattern, index++); - } - if(currencyPattern != NULL && index < counter) { - addObject(env, result, "Currency", currencyPattern, index++); - } - if(percentPattern != NULL && index < counter) { - addObject(env, result, "Percent", percentPattern, index++); - } - - return result; - -} - -static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ - {"getFractionDigitsNative", "(Ljava/lang/String;)I", - (void*) getFractionDigitsNative}, - {"getCurrencyCodeNative", "(Ljava/lang/String;)Ljava/lang/String;", - (void*) getCurrencyCodeNative}, - {"getCurrencySymbolNative", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", - (void*) getCurrencySymbolNative}, - {"getDisplayCountryNative", - "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", - (void*) getDisplayCountryNative}, - {"getDisplayLanguageNative", - "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", - (void*) getDisplayLanguageNative}, - {"getDisplayVariantNative", - "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", - (void*) getDisplayVariantNative}, - {"getISO3CountryNative", - "(Ljava/lang/String;)Ljava/lang/String;", - (void*) getISO3CountryNative}, - {"getISO3LanguageNative", - "(Ljava/lang/String;)Ljava/lang/String;", - (void*) getISO3LanguageNative}, - {"getISOCountriesNative", "()[Ljava/lang/String;", - (void*) getISOCountriesNative}, - {"getISOLanguagesNative", "()[Ljava/lang/String;", - (void*) getISOLanguagesNative}, - {"getAvailableLocalesNative", "()[Ljava/lang/String;", - (void*) getAvailableLocalesNative}, - {"getTimeZonesNative", - "([[Ljava/lang/String;Ljava/lang/String;)V", - (void*) getTimeZonesNative}, - {"getDisplayTimeZoneNative", - "(Ljava/lang/String;ZILjava/lang/String;)Ljava/lang/String;", - (void*) getDisplayTimeZoneNative}, - {"getContentImpl", - "(Ljava/lang/String;Z)[[Ljava/lang/Object;", - (void*) getContentImpl}, -}; - -int register_com_ibm_icu4jni_util_Resources(JNIEnv* env) { - - // initializing String - - jclass stringclass = env->FindClass("java/lang/String"); - - if(stringclass == NULL) { - LOGE("Can't find java/lang/String"); - jniThrowException(env, "java/lang/ClassNotFoundException", "java.lang.String"); - return -1; - } - - string_class = (jclass) env->NewGlobalRef(stringclass); - - return jniRegisterNativeMethods(env, - "com/ibm/icu4jni/util/Resources", gMethods, - NELEM(gMethods)); -} diff --git a/libcore/icu/src/main/native/sub.mk b/libcore/icu/src/main/native/sub.mk deleted file mode 100644 index 2f160f56e..000000000 --- a/libcore/icu/src/main/native/sub.mk +++ /dev/null @@ -1,30 +0,0 @@ -# This file is included by the top-level libcore Android.mk. -# It's not a normal makefile, so we don't include CLEAR_VARS -# or BUILD_*_LIBRARY. - -LOCAL_SRC_FILES := \ - BidiWrapperInterface.c \ - BreakIteratorInterface.c \ - DecimalFormatInterface.cpp \ - CharacterInterface.c \ - ConverterInterface.c \ - CollationInterface.c \ - RegExInterface.cpp \ - ResourceInterface.cpp \ - RBNFInterface.cpp \ - ErrorCode.c - -LOCAL_C_INCLUDES += \ - external/icu4c/common \ - external/icu4c/i18n - -# Any shared/static libs that are listed here must also -# be listed in libs/nativehelper/Android.mk. -# TODO: fix this requirement - -LOCAL_SHARED_LIBRARIES += \ - libicudata \ - libicuuc \ - libicui18n - -LOCAL_STATIC_LIBRARIES += diff --git a/libcore/icu/unicode-license.txt b/libcore/icu/unicode-license.txt deleted file mode 100644 index 8a3350b66..000000000 --- a/libcore/icu/unicode-license.txt +++ /dev/null @@ -1,48 +0,0 @@ -UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE - - Unicode Data Files include all data files under the directories -http://www.unicode.org/Public/, http://www.unicode.org/reports/, and -http://www.unicode.org/cldr/data/ . Unicode Software includes any source code -published in the Unicode Standard or under the directories -http://www.unicode.org/Public/, http://www.unicode.org/reports/, and -http://www.unicode.org/cldr/data/. - - NOTICE TO USER: Carefully read the following legal agreement. BY -DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S DATA FILES -("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"), YOU UNEQUIVOCALLY ACCEPT, AND -AGREE TO BE BOUND BY, ALL OF THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU -DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES -OR SOFTWARE. - - COPYRIGHT AND PERMISSION NOTICE - - Copyright © 1991-2006 Unicode, Inc. All rights reserved. Distributed under -the Terms of Use in http://www.unicode.org/copyright.html. - - Permission is hereby granted, free of charge, to any person obtaining a copy -of the Unicode data files and any associated documentation (the "Data Files") or -Unicode software and any associated documentation (the "Software") to deal in -the Data Files or Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, and/or sell copies of -the Data Files or Software, and to permit persons to whom the Data Files or -Software are furnished to do so, provided that (a) the above copyright notice(s) -and this permission notice appear with all copies of the Data Files or Software, -(b) both the above copyright notice(s) and this permission notice appear in -associated documentation, and (c) there is clear notice in each modified Data -File or in the Software as well as in the documentation associated with the Data -File(s) or Software that the data or software has been modified. - - THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD -PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS -NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL -DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING -OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR -SOFTWARE. - - Except as contained in this notice, the name of a copyright holder shall not -be used in advertising or otherwise to promote the sale, use or other dealings -in these Data Files or Software without prior written authorization of the -copyright holder. diff --git a/libcore/json/MODULE_LICENSE_BSD_LIKE b/libcore/json/MODULE_LICENSE_BSD_LIKE deleted file mode 100644 index e69de29bb..000000000 diff --git a/libcore/json/src/main/java/org/json/JSONArray.java b/libcore/json/src/main/java/org/json/JSONArray.java deleted file mode 100644 index 6bfca6e36..000000000 --- a/libcore/json/src/main/java/org/json/JSONArray.java +++ /dev/null @@ -1,778 +0,0 @@ -package org.json; - -/* -Copyright (c) 2002 JSON.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -The Software shall be used for Good, not Evil. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -import java.util.ArrayList; -import java.util.Collection; - -/** - * A JSONArray is an ordered sequence of values. Its external text form is a - * string wrapped in square brackets with commas separating the values. The - * internal form is an object having get and opt - * methods for accessing the values by index, and put methods for - * adding or replacing values. The values can be any of these types: - * Boolean, JSONArray, JSONObject, - * Number, String, or the - * JSONObject.NULL object. - *

- * The constructor can convert a JSON text into a Java object. The - * toString method converts to JSON text. - *

- * A get method returns a value if one can be found, and throws an - * exception if one cannot be found. An opt method returns a - * default value instead of throwing an exception, and so is useful for - * obtaining optional values. - *

- * The generic get() and opt() methods return an - * object which you can cast or query for type. There are also typed - * get and opt methods that do type checking and type - * coersion for you. - *

- * The texts produced by the toString methods strictly conform to - * JSON syntax rules. The constructors are more forgiving in the texts they will - * accept: - *

    - *
  • An extra , (comma) may appear just - * before the closing bracket.
  • - *
  • The null value will be inserted when there - * is , (comma) elision.
  • - *
  • Strings may be quoted with ' (single - * quote).
  • - *
  • Strings do not need to be quoted at all if they do not begin with a quote - * or single quote, and if they do not contain leading or trailing spaces, - * and if they do not contain any of these characters: - * { } [ ] / \ : , = ; # and if they do not look like numbers - * and if they are not the reserved words true, - * false, or null.
  • - *
  • Values can be separated by ; (semicolon) as - * well as by , (comma).
  • - *
  • Numbers may have the 0- (octal) or - * 0x- (hex) prefix.
  • - *
  • Comments written in the slashshlash, slashstar, and hash conventions - * will be ignored.
  • - *
- - * @author JSON.org - * @version 2 - */ -public class JSONArray { - - - /** - * The arrayList where the JSONArray's properties are kept. - */ - private ArrayList myArrayList; - - - /** - * Construct an empty JSONArray. - */ - public JSONArray() { - this.myArrayList = new ArrayList(); - } - - /** - * Construct a JSONArray from a JSONTokener. - * @param x A JSONTokener - * @throws JSONException If there is a syntax error. - */ - public JSONArray(JSONTokener x) throws JSONException { - this(); - if (x.nextClean() != '[') { - throw x.syntaxError("A JSONArray text must start with '['"); - } - if (x.nextClean() == ']') { - return; - } - x.back(); - for (;;) { - if (x.nextClean() == ',') { - x.back(); - this.myArrayList.add(null); - } else { - x.back(); - this.myArrayList.add(x.nextValue()); - } - switch (x.nextClean()) { - case ';': - case ',': - if (x.nextClean() == ']') { - this.myArrayList.add(null); - return; - } - x.back(); - break; - case ']': - return; - default: - throw x.syntaxError("Expected a ',' or ']'"); - } - } - } - - - public boolean equals(Object object) { - if (!(object instanceof JSONArray)) return false; - return myArrayList.equals(((JSONArray)object).myArrayList); - } - - - /** - * Construct a JSONArray from a source sJSON text. - * @param string A string that begins with - * [ (left bracket) - * and ends with ] (right bracket). - * @throws JSONException If there is a syntax error. - */ - public JSONArray(String string) throws JSONException { - this(new JSONTokener(string)); - } - - - /** - * Construct a JSONArray from a Collection. - * @param collection A Collection. - */ - public JSONArray(Collection collection) { - this.myArrayList = new ArrayList(collection); - } - - - /** - * Get the object value associated with an index. - * @param index - * The index must be between 0 and length() - 1. - * @return An object value. - * @throws JSONException If there is no value for the index. - */ - public Object get(int index) throws JSONException { - Object o = opt(index); - if (o == null) { - throw new JSONException("JSONArray[" + index + "] not found."); - } - return o; - } - - - /** - * Get the boolean value associated with an index. - * The string values "true" and "false" are converted to boolean. - * - * @param index The index must be between 0 and length() - 1. - * @return The truth. - * @throws JSONException If there is no value for the index or if the - * value is not convertable to boolean. - */ - public boolean getBoolean(int index) throws JSONException { - Object o = get(index); - if (o.equals(Boolean.FALSE) || - (o instanceof String && - ((String)o).equalsIgnoreCase("false"))) { - return false; - } else if (o.equals(Boolean.TRUE) || - (o instanceof String && - ((String)o).equalsIgnoreCase("true"))) { - return true; - } - throw new JSONException("JSONArray[" + index + "] is not a Boolean."); - } - - - /** - * Get the double value associated with an index. - * - * @param index The index must be between 0 and length() - 1. - * @return The value. - * @throws JSONException If the key is not found or if the value cannot - * be converted to a number. - */ - public double getDouble(int index) throws JSONException { - Object o = get(index); - try { - return o instanceof Number ? - ((Number)o).doubleValue() : Double.parseDouble((String)o); - } catch (Exception e) { - throw new JSONException("JSONArray[" + index + - "] is not a number."); - } - } - - - /** - * Get the int value associated with an index. - * - * @param index The index must be between 0 and length() - 1. - * @return The value. - * @throws JSONException If the key is not found or if the value cannot - * be converted to a number. - * if the value cannot be converted to a number. - */ - public int getInt(int index) throws JSONException { - Object o = get(index); - return o instanceof Number ? - ((Number)o).intValue() : (int)getDouble(index); - } - - - /** - * Get the JSONArray associated with an index. - * @param index The index must be between 0 and length() - 1. - * @return A JSONArray value. - * @throws JSONException If there is no value for the index. or if the - * value is not a JSONArray - */ - public JSONArray getJSONArray(int index) throws JSONException { - Object o = get(index); - if (o instanceof JSONArray) { - return (JSONArray)o; - } - throw new JSONException("JSONArray[" + index + - "] is not a JSONArray."); - } - - - /** - * Get the JSONObject associated with an index. - * @param index subscript - * @return A JSONObject value. - * @throws JSONException If there is no value for the index or if the - * value is not a JSONObject - */ - public JSONObject getJSONObject(int index) throws JSONException { - Object o = get(index); - if (o instanceof JSONObject) { - return (JSONObject)o; - } - throw new JSONException("JSONArray[" + index + - "] is not a JSONObject."); - } - - - /** - * Get the long value associated with an index. - * - * @param index The index must be between 0 and length() - 1. - * @return The value. - * @throws JSONException If the key is not found or if the value cannot - * be converted to a number. - */ - public long getLong(int index) throws JSONException { - Object o = get(index); - return o instanceof Number ? - ((Number)o).longValue() : (long)getDouble(index); - } - - - /** - * Get the string associated with an index. - * @param index The index must be between 0 and length() - 1. - * @return A string value. - * @throws JSONException If there is no value for the index. - */ - public String getString(int index) throws JSONException { - return get(index).toString(); - } - - - /** - * Determine if the value is null. - * @param index The index must be between 0 and length() - 1. - * @return true if the value at the index is null, or if there is no value. - */ - public boolean isNull(int index) { - return JSONObject.NULL.equals(opt(index)); - } - - - /** - * Make a string from the contents of this JSONArray. The - * separator string is inserted between each element. - * Warning: This method assumes that the data structure is acyclical. - * @param separator A string that will be inserted between the elements. - * @return a string. - * @throws JSONException If the array contains an invalid number. - */ - public String join(String separator) throws JSONException { - int len = length(); - StringBuilder sb = new StringBuilder(); - - for (int i = 0; i < len; i += 1) { - if (i > 0) { - sb.append(separator); - } - sb.append(JSONObject.valueToString(this.myArrayList.get(i))); - } - return sb.toString(); - } - - - /** - * Get the number of elements in the JSONArray, included nulls. - * - * @return The length (or size). - */ - public int length() { - return this.myArrayList.size(); - } - - - /** - * Get the optional object value associated with an index. - * @param index The index must be between 0 and length() - 1. - * @return An object value, or null if there is no - * object at that index. - */ - public Object opt(int index) { - return (index < 0 || index >= length()) ? - null : this.myArrayList.get(index); - } - - - /** - * Get the optional boolean value associated with an index. - * It returns false if there is no value at that index, - * or if the value is not Boolean.TRUE or the String "true". - * - * @param index The index must be between 0 and length() - 1. - * @return The truth. - */ - public boolean optBoolean(int index) { - return optBoolean(index, false); - } - - - /** - * Get the optional boolean value associated with an index. - * It returns the defaultValue if there is no value at that index or if - * it is not a Boolean or the String "true" or "false" (case insensitive). - * - * @param index The index must be between 0 and length() - 1. - * @param defaultValue A boolean default. - * @return The truth. - */ - public boolean optBoolean(int index, boolean defaultValue) { - try { - return getBoolean(index); - } catch (Exception e) { - return defaultValue; - } - } - - - /** - * Get the optional double value associated with an index. - * NaN is returned if there is no value for the index, - * or if the value is not a number and cannot be converted to a number. - * - * @param index The index must be between 0 and length() - 1. - * @return The value. - */ - public double optDouble(int index) { - return optDouble(index, Double.NaN); - } - - - /** - * Get the optional double value associated with an index. - * The defaultValue is returned if there is no value for the index, - * or if the value is not a number and cannot be converted to a number. - * - * @param index subscript - * @param defaultValue The default value. - * @return The value. - */ - public double optDouble(int index, double defaultValue) { - try { - return getDouble(index); - } catch (Exception e) { - return defaultValue; - } - } - - - /** - * Get the optional int value associated with an index. - * Zero is returned if there is no value for the index, - * or if the value is not a number and cannot be converted to a number. - * - * @param index The index must be between 0 and length() - 1. - * @return The value. - */ - public int optInt(int index) { - return optInt(index, 0); - } - - - /** - * Get the optional int value associated with an index. - * The defaultValue is returned if there is no value for the index, - * or if the value is not a number and cannot be converted to a number. - * @param index The index must be between 0 and length() - 1. - * @param defaultValue The default value. - * @return The value. - */ - public int optInt(int index, int defaultValue) { - try { - return getInt(index); - } catch (Exception e) { - return defaultValue; - } - } - - - /** - * Get the optional JSONArray associated with an index. - * @param index subscript - * @return A JSONArray value, or null if the index has no value, - * or if the value is not a JSONArray. - */ - public JSONArray optJSONArray(int index) { - Object o = opt(index); - return o instanceof JSONArray ? (JSONArray)o : null; - } - - - /** - * Get the optional JSONObject associated with an index. - * Null is returned if the key is not found, or null if the index has - * no value, or if the value is not a JSONObject. - * - * @param index The index must be between 0 and length() - 1. - * @return A JSONObject value. - */ - public JSONObject optJSONObject(int index) { - Object o = opt(index); - return o instanceof JSONObject ? (JSONObject)o : null; - } - - - /** - * Get the optional long value associated with an index. - * Zero is returned if there is no value for the index, - * or if the value is not a number and cannot be converted to a number. - * - * @param index The index must be between 0 and length() - 1. - * @return The value. - */ - public long optLong(int index) { - return optLong(index, 0); - } - - - /** - * Get the optional long value associated with an index. - * The defaultValue is returned if there is no value for the index, - * or if the value is not a number and cannot be converted to a number. - * @param index The index must be between 0 and length() - 1. - * @param defaultValue The default value. - * @return The value. - */ - public long optLong(int index, long defaultValue) { - try { - return getLong(index); - } catch (Exception e) { - return defaultValue; - } - } - - - /** - * Get the optional string value associated with an index. It returns an - * empty string if there is no value at that index. If the value - * is not a string and is not null, then it is coverted to a string. - * - * @param index The index must be between 0 and length() - 1. - * @return A String value. - */ - public String optString(int index) { - return optString(index, ""); - } - - - /** - * Get the optional string associated with an index. - * The defaultValue is returned if the key is not found. - * - * @param index The index must be between 0 and length() - 1. - * @param defaultValue The default value. - * @return A String value. - */ - public String optString(int index, String defaultValue) { - Object o = opt(index); - return o != null ? o.toString() : defaultValue; - } - - - /** - * Append a boolean value. This increases the array's length by one. - * - * @param value A boolean value. - * @return this. - */ - public JSONArray put(boolean value) { - put(Boolean.valueOf(value)); - return this; - } - - - /** - * Append a double value. This increases the array's length by one. - * - * @param value A double value. - * @throws JSONException if the value is not finite. - * @return this. - */ - public JSONArray put(double value) throws JSONException { - Double d = new Double(value); - JSONObject.testValidity(d); - put(d); - return this; - } - - - /** - * Append an int value. This increases the array's length by one. - * - * @param value An int value. - * @return this. - */ - public JSONArray put(int value) { - put(new Integer(value)); - return this; - } - - - /** - * Append an long value. This increases the array's length by one. - * - * @param value A long value. - * @return this. - */ - public JSONArray put(long value) { - put(new Long(value)); - return this; - } - - - /** - * Append an object value. This increases the array's length by one. - * @param value An object value. The value should be a - * Boolean, Double, Integer, JSONArray, JSObject, Long, or String, or the - * JSONObject.NULL object. - * @return this. - */ - public JSONArray put(Object value) { - this.myArrayList.add(value); - return this; - } - - - /** - * Put or replace a boolean value in the JSONArray. If the index is greater - * than the length of the JSONArray, then null elements will be added as - * necessary to pad it out. - * @param index The subscript. - * @param value A boolean value. - * @return this. - * @throws JSONException If the index is negative. - */ - public JSONArray put(int index, boolean value) throws JSONException { - put(index, Boolean.valueOf(value)); - return this; - } - - - /** - * Put or replace a double value. If the index is greater than the length of - * the JSONArray, then null elements will be added as necessary to pad - * it out. - * @param index The subscript. - * @param value A double value. - * @return this. - * @throws JSONException If the index is negative or if the value is - * not finite. - */ - public JSONArray put(int index, double value) throws JSONException { - put(index, new Double(value)); - return this; - } - - - /** - * Put or replace an int value. If the index is greater than the length of - * the JSONArray, then null elements will be added as necessary to pad - * it out. - * @param index The subscript. - * @param value An int value. - * @return this. - * @throws JSONException If the index is negative. - */ - public JSONArray put(int index, int value) throws JSONException { - put(index, new Integer(value)); - return this; - } - - - /** - * Put or replace a long value. If the index is greater than the length of - * the JSONArray, then null elements will be added as necessary to pad - * it out. - * @param index The subscript. - * @param value A long value. - * @return this. - * @throws JSONException If the index is negative. - */ - public JSONArray put(int index, long value) throws JSONException { - put(index, new Long(value)); - return this; - } - - - /** - * Put or replace an object value in the JSONArray. If the index is greater - * than the length of the JSONArray, then null elements will be added as - * necessary to pad it out. - * @param index The subscript. - * @param value The value to put into the array. - * @return this. - * @throws JSONException If the index is negative or if the the value is - * an invalid number. - */ - public JSONArray put(int index, Object value) throws JSONException { - JSONObject.testValidity(value); - if (index < 0) { - throw new JSONException("JSONArray[" + index + "] not found."); - } - if (index < length()) { - this.myArrayList.set(index, value); - } else { - while (index != length()) { - put(null); - } - put(value); - } - return this; - } - - - /** - * Produce a JSONObject by combining a JSONArray of names with the values - * of this JSONArray. - * @param names A JSONArray containing a list of key strings. These will be - * paired with the values. - * @return A JSONObject, or null if there are no names or if this JSONArray - * has no values. - * @throws JSONException If any of the names are null. - */ - public JSONObject toJSONObject(JSONArray names) throws JSONException { - if (names == null || names.length() == 0 || length() == 0) { - return null; - } - JSONObject jo = new JSONObject(); - for (int i = 0; i < names.length(); i += 1) { - jo.put(names.getString(i), this.opt(i)); - } - return jo; - } - - - /** - * Make an JSON text of this JSONArray. For compactness, no - * unnecessary whitespace is added. If it is not possible to produce a - * syntactically correct JSON text then null will be returned instead. This - * could occur if the array contains an invalid number. - *

- * Warning: This method assumes that the data structure is acyclical. - * - * @return a printable, displayable, transmittable - * representation of the array. - */ - public String toString() { - try { - return '[' + join(",") + ']'; - } catch (Exception e) { - return null; - } - } - - - /** - * Make a prettyprinted JSON text of this JSONArray. - * Warning: This method assumes that the data structure is acyclical. - * @param indentFactor The number of spaces to add to each level of - * indentation. - * @return a printable, displayable, transmittable - * representation of the object, beginning - * with [ (left bracket) and ending - * with ] (right bracket). - * @throws JSONException - */ - public String toString(int indentFactor) throws JSONException { - return toString(indentFactor, 0); - } - - - /** - * Make a prettyprinted JSON text of this JSONArray. - * Warning: This method assumes that the data structure is acyclical. - * @param indentFactor The number of spaces to add to each level of - * indentation. - * @param indent The indention of the top level. - * @return a printable, displayable, transmittable - * representation of the array. - * @throws JSONException - */ - String toString(int indentFactor, int indent) throws JSONException { - int len = length(); - if (len == 0) { - return "[]"; - } - int i; - StringBuilder sb = new StringBuilder("["); - if (len == 1) { - sb.append(JSONObject.valueToString(this.myArrayList.get(0), - indentFactor, indent)); - } else { - int newindent = indent + indentFactor; - sb.append('\n'); - for (i = 0; i < len; i += 1) { - if (i > 0) { - sb.append(",\n"); - } - for (int j = 0; j < newindent; j += 1) { - sb.append(' '); - } - sb.append(JSONObject.valueToString(this.myArrayList.get(i), - indentFactor, newindent)); - } - sb.append('\n'); - for (i = 0; i < indent; i += 1) { - sb.append(' '); - } - } - sb.append(']'); - return sb.toString(); - } -} diff --git a/libcore/json/src/main/java/org/json/JSONException.java b/libcore/json/src/main/java/org/json/JSONException.java deleted file mode 100644 index a2905bf9a..000000000 --- a/libcore/json/src/main/java/org/json/JSONException.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.json; - -/** - * The JSONException is thrown by the JSON.org classes then things are amiss. - * @author JSON.org - * @version 2 - */ -public class JSONException extends Exception { - /** - * Constructs a JSONException with an explanatory message. - * @param message Detail about the reason for the exception. - */ - public JSONException(String message) { - super(message); - } -} diff --git a/libcore/json/src/main/java/org/json/JSONObject.java b/libcore/json/src/main/java/org/json/JSONObject.java deleted file mode 100644 index b0ebea240..000000000 --- a/libcore/json/src/main/java/org/json/JSONObject.java +++ /dev/null @@ -1,1081 +0,0 @@ -package org.json; - -/* -Copyright (c) 2002 JSON.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -The Software shall be used for Good, not Evil. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -// BEGIN android-note -// - fixed bad htm in javadoc comments -joeo -// END android-note - -/** - * A JSONObject is an unordered collection of name/value pairs. Its - * external form is a string wrapped in curly braces with colons between the - * names and values, and commas between the values and names. The internal form - * is an object having get and opt methods for - * accessing the values by name, and put methods for adding or - * replacing values by name. The values can be any of these types: - * Boolean, JSONArray, JSONObject, - * Number, String, or the JSONObject.NULL - * object. A JSONObject constructor can be used to convert an external form - * JSON text into an internal form whose values can be retrieved with the - * get and opt methods, or to convert values into a - * JSON text using the put and toString methods. - * A get method returns a value if one can be found, and throws an - * exception if one cannot be found. An opt method returns a - * default value instead of throwing an exception, and so is useful for - * obtaining optional values. - *

- * The generic get() and opt() methods return an - * object, which you can cast or query for type. There are also typed - * get and opt methods that do type checking and type - * coersion for you. - *

- * The put methods adds values to an object. For example,

- *     myString = new JSONObject().put("JSON", "Hello, World!").toString();
- * produces the string {"JSON": "Hello, World"}. - *

- * The texts produced by the toString methods strictly conform to - * the JSON sysntax rules. - * The constructors are more forgiving in the texts they will accept: - *

    - *
  • An extra , (comma) may appear just - * before the closing brace.
  • - *
  • Strings may be quoted with ' (single - * quote).
  • - *
  • Strings do not need to be quoted at all if they do not begin with a quote - * or single quote, and if they do not contain leading or trailing spaces, - * and if they do not contain any of these characters: - * { } [ ] / \ : , = ; # and if they do not look like numbers - * and if they are not the reserved words true, - * false, or null.
  • - *
  • Keys can be followed by = or => as well as - * by :.
  • - *
  • Values can be followed by ; (semicolon) as - * well as by , (comma).
  • - *
  • Numbers may have the 0- (octal) or - * 0x- (hex) prefix.
  • - *
  • Comments written in the slashshlash, slashstar, and hash conventions - * will be ignored.
  • - *
- * @author JSON.org - * @version 2 - */ -public class JSONObject { - - /** - * JSONObject.NULL is equivalent to the value that JavaScript calls null, - * whilst Java's null is equivalent to the value that JavaScript calls - * undefined. - */ - private static final class Null { - - /** - * There is only intended to be a single instance of the NULL object, - * so the clone method returns itself. - * @return NULL. - */ - protected final Object clone() { - return this; - } - - - /** - * A Null object is equal to the null value and to itself. - * @param object An object to test for nullness. - * @return true if the object parameter is the JSONObject.NULL object - * or null. - */ - public boolean equals(Object object) { - return object == null || object == this; - } - - - /** - * Get the "null" string value. - * @return The string "null". - */ - public String toString() { - return "null"; - } - } - - - /** - * The hash map where the JSONObject's properties are kept. - */ - private HashMap myHashMap; - - - /** - * It is sometimes more convenient and less ambiguous to have a - * NULL object than to use Java's null value. - * JSONObject.NULL.equals(null) returns true. - * JSONObject.NULL.toString() returns "null". - */ - public static final Object NULL = new Null(); - - - /** - * Construct an empty JSONObject. - */ - public JSONObject() { - this.myHashMap = new HashMap(); - } - - - /** - * Construct a JSONObject from a subset of another JSONObject. - * An array of strings is used to identify the keys that should be copied. - * Missing keys are ignored. - * @param jo A JSONObject. - * @param sa An array of strings. - * @exception JSONException If a value is a non-finite number. - */ - public JSONObject(JSONObject jo, String[] sa) throws JSONException { - this(); - for (int i = 0; i < sa.length; i += 1) { - putOpt(sa[i], jo.opt(sa[i])); - } - } - - - /** - * Construct a JSONObject from a JSONTokener. - * @param x A JSONTokener object containing the source string. - * @throws JSONException If there is a syntax error in the source string. - */ - public JSONObject(JSONTokener x) throws JSONException { - this(); - char c; - String key; - - if (x.nextClean() != '{') { - throw x.syntaxError("A JSONObject text must begin with '{'"); - } - for (;;) { - c = x.nextClean(); - switch (c) { - case 0: - throw x.syntaxError("A JSONObject text must end with '}'"); - case '}': - return; - default: - x.back(); - key = x.nextValue().toString(); - } - - /* - * The key is followed by ':'. We will also tolerate '=' or '=>'. - */ - - c = x.nextClean(); - if (c == '=') { - if (x.next() != '>') { - x.back(); - } - } else if (c != ':') { - throw x.syntaxError("Expected a ':' after a key"); - } - this.myHashMap.put(key, x.nextValue()); - - /* - * Pairs are separated by ','. We will also tolerate ';'. - */ - - switch (x.nextClean()) { - case ';': - case ',': - if (x.nextClean() == '}') { - return; - } - x.back(); - break; - case '}': - return; - default: - throw x.syntaxError("Expected a ',' or '}'"); - } - } - } - - - /** - * Construct a JSONObject from a Map. - * @param map A map object that can be used to initialize the contents of - * the JSONObject. - */ - public JSONObject(Map map) { - this.myHashMap = new HashMap(map); - } - - - /** - * Construct a JSONObject from a string. - * This is the most commonly used JSONObject constructor. - * @param string A string beginning - * with { (left brace) and ending - * with } (right brace). - * @exception JSONException If there is a syntax error in the source string. - */ - public JSONObject(String string) throws JSONException { - this(new JSONTokener(string)); - } - - - /** - * Accumulate values under a key. It is similar to the put method except - * that if there is already an object stored under the key then a - * JSONArray is stored under the key to hold all of the accumulated values. - * If there is already a JSONArray, then the new value is appended to it. - * In contrast, the put method replaces the previous value. - * @param key A key string. - * @param value An object to be accumulated under the key. - * @return this. - * @throws JSONException If the value is an invalid number - * or if the key is null. - */ - public JSONObject accumulate(String key, Object value) - throws JSONException { - testValidity(value); - Object o = opt(key); - if (o == null) { - put(key, value); - } else if (o instanceof JSONArray) { - ((JSONArray)o).put(value); - } else { - put(key, new JSONArray().put(o).put(value)); - } - return this; - } - - - /** - * Get the value object associated with a key. - * - * @param key A key string. - * @return The object associated with the key. - * @throws JSONException if the key is not found. - */ - public Object get(String key) throws JSONException { - Object o = opt(key); - if (o == null) { - throw new JSONException("JSONObject[" + quote(key) + - "] not found."); - } - return o; - } - - - /** - * Get the boolean value associated with a key. - * - * @param key A key string. - * @return The truth. - * @throws JSONException - * if the value is not a Boolean or the String "true" or "false". - */ - public boolean getBoolean(String key) throws JSONException { - Object o = get(key); - if (o.equals(Boolean.FALSE) || - (o instanceof String && - ((String)o).equalsIgnoreCase("false"))) { - return false; - } else if (o.equals(Boolean.TRUE) || - (o instanceof String && - ((String)o).equalsIgnoreCase("true"))) { - return true; - } - throw new JSONException("JSONObject[" + quote(key) + - "] is not a Boolean."); - } - - - /** - * Get the double value associated with a key. - * @param key A key string. - * @return The numeric value. - * @throws JSONException if the key is not found or - * if the value is not a Number object and cannot be converted to a number. - */ - public double getDouble(String key) throws JSONException { - Object o = get(key); - try { - return o instanceof Number ? - ((Number)o).doubleValue() : Double.parseDouble((String)o); - } catch (Exception e) { - throw new JSONException("JSONObject[" + quote(key) + - "] is not a number."); - } - } - - - /** - * Get the int value associated with a key. If the number value is too - * large for an int, it will be clipped. - * - * @param key A key string. - * @return The integer value. - * @throws JSONException if the key is not found or if the value cannot - * be converted to an integer. - */ - public int getInt(String key) throws JSONException { - Object o = get(key); - return o instanceof Number ? - ((Number)o).intValue() : (int)getDouble(key); - } - - - /** - * Get the JSONArray value associated with a key. - * - * @param key A key string. - * @return A JSONArray which is the value. - * @throws JSONException if the key is not found or - * if the value is not a JSONArray. - */ - public JSONArray getJSONArray(String key) throws JSONException { - Object o = get(key); - if (o instanceof JSONArray) { - return (JSONArray)o; - } - throw new JSONException("JSONObject[" + quote(key) + - "] is not a JSONArray."); - } - - - /** - * Get the JSONObject value associated with a key. - * - * @param key A key string. - * @return A JSONObject which is the value. - * @throws JSONException if the key is not found or - * if the value is not a JSONObject. - */ - public JSONObject getJSONObject(String key) throws JSONException { - Object o = get(key); - if (o instanceof JSONObject) { - return (JSONObject)o; - } - throw new JSONException("JSONObject[" + quote(key) + - "] is not a JSONObject."); - } - - - /** - * Get the long value associated with a key. If the number value is too - * long for a long, it will be clipped. - * - * @param key A key string. - * @return The long value. - * @throws JSONException if the key is not found or if the value cannot - * be converted to a long. - */ - public long getLong(String key) throws JSONException { - Object o = get(key); - return o instanceof Number ? - ((Number)o).longValue() : (long)getDouble(key); - } - - - /** - * Get the string associated with a key. - * - * @param key A key string. - * @return A string which is the value. - * @throws JSONException if the key is not found. - */ - public String getString(String key) throws JSONException { - return get(key).toString(); - } - - - /** - * Determine if the JSONObject contains a specific key. - * @param key A key string. - * @return true if the key exists in the JSONObject. - */ - public boolean has(String key) { - return this.myHashMap.containsKey(key); - } - - - /** - * Determine if the value associated with the key is null or if there is - * no value. - * @param key A key string. - * @return true if there is no value associated with the key or if - * the value is the JSONObject.NULL object. - */ - public boolean isNull(String key) { - return JSONObject.NULL.equals(opt(key)); - } - - - /** - * Get an enumeration of the keys of the JSONObject. - * - * @return An iterator of the keys. - */ - public Iterator keys() { - return this.myHashMap.keySet().iterator(); - } - - - /** - * Get the number of keys stored in the JSONObject. - * - * @return The number of keys in the JSONObject. - */ - public int length() { - return this.myHashMap.size(); - } - - - /** - * Produce a JSONArray containing the names of the elements of this - * JSONObject. - * @return A JSONArray containing the key strings, or null if the JSONObject - * is empty. - */ - public JSONArray names() { - JSONArray ja = new JSONArray(); - Iterator keys = keys(); - while (keys.hasNext()) { - ja.put(keys.next()); - } - return ja.length() == 0 ? null : ja; - } - - /** - * Produce a string from a number. - * @param n A Number - * @return A String. - * @throws JSONException If n is a non-finite number. - */ - static public String numberToString(Number n) - throws JSONException { - if (n == null) { - throw new JSONException("Null pointer"); - } - testValidity(n); - -// Shave off trailing zeros and decimal point, if possible. - - String s = n.toString(); - if (s.indexOf('.') > 0 && s.indexOf('e') < 0 && s.indexOf('E') < 0) { - while (s.endsWith("0")) { - s = s.substring(0, s.length() - 1); - } - if (s.endsWith(".")) { - s = s.substring(0, s.length() - 1); - } - } - return s; - } - - - /** - * Get an optional value associated with a key. - * @param key A key string. - * @return An object which is the value, or null if there is no value. - */ - public Object opt(String key) { - return key == null ? null : this.myHashMap.get(key); - } - - - /** - * Get an optional boolean associated with a key. - * It returns false if there is no such key, or if the value is not - * Boolean.TRUE or the String "true". - * - * @param key A key string. - * @return The truth. - */ - public boolean optBoolean(String key) { - return optBoolean(key, false); - } - - - /** - * Get an optional boolean associated with a key. - * It returns the defaultValue if there is no such key, or if it is not - * a Boolean or the String "true" or "false" (case insensitive). - * - * @param key A key string. - * @param defaultValue The default. - * @return The truth. - */ - public boolean optBoolean(String key, boolean defaultValue) { - try { - return getBoolean(key); - } catch (Exception e) { - return defaultValue; - } - } - - - /** - * Get an optional double associated with a key, - * or NaN if there is no such key or if its value is not a number. - * If the value is a string, an attempt will be made to evaluate it as - * a number. - * - * @param key A string which is the key. - * @return An object which is the value. - */ - public double optDouble(String key) { - return optDouble(key, Double.NaN); - } - - - /** - * Get an optional double associated with a key, or the - * defaultValue if there is no such key or if its value is not a number. - * If the value is a string, an attempt will be made to evaluate it as - * a number. - * - * @param key A key string. - * @param defaultValue The default. - * @return An object which is the value. - */ - public double optDouble(String key, double defaultValue) { - try { - Object o = opt(key); - return o instanceof Number ? ((Number)o).doubleValue() : - new Double((String)o).doubleValue(); - } catch (Exception e) { - return defaultValue; - } - } - - - /** - * Get an optional int value associated with a key, - * or zero if there is no such key or if the value is not a number. - * If the value is a string, an attempt will be made to evaluate it as - * a number. - * - * @param key A key string. - * @return An object which is the value. - */ - public int optInt(String key) { - return optInt(key, 0); - } - - - /** - * Get an optional int value associated with a key, - * or the default if there is no such key or if the value is not a number. - * If the value is a string, an attempt will be made to evaluate it as - * a number. - * - * @param key A key string. - * @param defaultValue The default. - * @return An object which is the value. - */ - public int optInt(String key, int defaultValue) { - try { - return getInt(key); - } catch (Exception e) { - return defaultValue; - } - } - - - /** - * Get an optional JSONArray associated with a key. - * It returns null if there is no such key, or if its value is not a - * JSONArray. - * - * @param key A key string. - * @return A JSONArray which is the value. - */ - public JSONArray optJSONArray(String key) { - Object o = opt(key); - return o instanceof JSONArray ? (JSONArray)o : null; - } - - - /** - * Get an optional JSONObject associated with a key. - * It returns null if there is no such key, or if its value is not a - * JSONObject. - * - * @param key A key string. - * @return A JSONObject which is the value. - */ - public JSONObject optJSONObject(String key) { - Object o = opt(key); - return o instanceof JSONObject ? (JSONObject)o : null; - } - - - /** - * Get an optional long value associated with a key, - * or zero if there is no such key or if the value is not a number. - * If the value is a string, an attempt will be made to evaluate it as - * a number. - * - * @param key A key string. - * @return An object which is the value. - */ - public long optLong(String key) { - return optLong(key, 0); - } - - - /** - * Get an optional long value associated with a key, - * or the default if there is no such key or if the value is not a number. - * If the value is a string, an attempt will be made to evaluate it as - * a number. - * - * @param key A key string. - * @param defaultValue The default. - * @return An object which is the value. - */ - public long optLong(String key, long defaultValue) { - try { - return getLong(key); - } catch (Exception e) { - return defaultValue; - } - } - - - /** - * Get an optional string associated with a key. - * It returns an empty string if there is no such key. If the value is not - * a string and is not null, then it is coverted to a string. - * - * @param key A key string. - * @return A string which is the value. - */ - public String optString(String key) { - return optString(key, ""); - } - - - /** - * Get an optional string associated with a key. - * It returns the defaultValue if there is no such key. - * - * @param key A key string. - * @param defaultValue The default. - * @return A string which is the value. - */ - public String optString(String key, String defaultValue) { - Object o = opt(key); - return o != null ? o.toString() : defaultValue; - } - - - /** - * Put a key/boolean pair in the JSONObject. - * - * @param key A key string. - * @param value A boolean which is the value. - * @return this. - * @throws JSONException If the key is null. - */ - public JSONObject put(String key, boolean value) throws JSONException { - put(key, Boolean.valueOf(value)); - return this; - } - - - /** - * Put a key/double pair in the JSONObject. - * - * @param key A key string. - * @param value A double which is the value. - * @return this. - * @throws JSONException If the key is null or if the number is invalid. - */ - public JSONObject put(String key, double value) throws JSONException { - put(key, new Double(value)); - return this; - } - - - /** - * Put a key/int pair in the JSONObject. - * - * @param key A key string. - * @param value An int which is the value. - * @return this. - * @throws JSONException If the key is null. - */ - public JSONObject put(String key, int value) throws JSONException { - put(key, new Integer(value)); - return this; - } - - - /** - * Put a key/long pair in the JSONObject. - * - * @param key A key string. - * @param value A long which is the value. - * @return this. - * @throws JSONException If the key is null. - */ - public JSONObject put(String key, long value) throws JSONException { - put(key, new Long(value)); - return this; - } - - - /** - * Put a key/value pair in the JSONObject. If the value is null, - * then the key will be removed from the JSONObject if it is present. - * @param key A key string. - * @param value An object which is the value. It should be of one of these - * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, - * or the JSONObject.NULL object. - * @return this. - * @throws JSONException If the value is non-finite number - * or if the key is null. - */ - public JSONObject put(String key, Object value) - throws JSONException { - if (key == null) { - throw new JSONException("Null key."); - } - if (value != null) { - testValidity(value); - this.myHashMap.put(key, value); - } else { - remove(key); - } - return this; - } - - - /** - * Put a key/value pair in the JSONObject, but only if the - * key and the value are both non-null. - * @param key A key string. - * @param value An object which is the value. It should be of one of these - * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, - * or the JSONObject.NULL object. - * @return this. - * @throws JSONException If the value is a non-finite number. - */ - public JSONObject putOpt(String key, Object value) throws JSONException { - if (key != null && value != null) { - put(key, value); - } - return this; - } - - - /** - * Produce a string in double quotes with backslash sequences in all the - * right places. A backslash will be inserted within </, allowing JSON - * text to be delivered in HTML. In JSON text, a string cannot contain a - * control character or an unescaped quote or backslash. - * @param string A String - * @return A String correctly formatted for insertion in a JSON text. - */ - public static String quote(String string) { - if (string == null || string.length() == 0) { - return "\"\""; - } - - char b; - char c = 0; - int i; - int len = string.length(); - StringBuilder sb = new StringBuilder(len + 4); - String t; - - sb.append('"'); - for (i = 0; i < len; i += 1) { - b = c; - c = string.charAt(i); - switch (c) { - case '\\': - case '"': - sb.append('\\'); - sb.append(c); - break; - case '/': - if (b == '<') { - sb.append('\\'); - } - sb.append(c); - break; - case '\b': - sb.append("\\b"); - break; - case '\t': - sb.append("\\t"); - break; - case '\n': - sb.append("\\n"); - break; - case '\f': - sb.append("\\f"); - break; - case '\r': - sb.append("\\r"); - break; - default: - if (c < ' ') { - t = "000" + Integer.toHexString(c); - sb.append("\\u" + t.substring(t.length() - 4)); - } else { - sb.append(c); - } - } - } - sb.append('"'); - return sb.toString(); - } - - /** - * Remove a name and its value, if present. - * @param key The name to be removed. - * @return The value that was associated with the name, - * or null if there was no value. - */ - public Object remove(String key) { - return this.myHashMap.remove(key); - } - - /** - * Throw an exception if the object is an NaN or infinite number. - * @param o The object to test. - * @throws JSONException If o is a non-finite number. - */ - static void testValidity(Object o) throws JSONException { - if (o != null) { - if (o instanceof Double) { - if (((Double)o).isInfinite() || ((Double)o).isNaN()) { - throw new JSONException( - "JSON does not allow non-finite numbers"); - } - } else if (o instanceof Float) { - if (((Float)o).isInfinite() || ((Float)o).isNaN()) { - throw new JSONException( - "JSON does not allow non-finite numbers."); - } - } - } - } - - - /** - * Produce a JSONArray containing the values of the members of this - * JSONObject. - * @param names A JSONArray containing a list of key strings. This - * determines the sequence of the values in the result. - * @return A JSONArray of values. - * @throws JSONException If any of the values are non-finite numbers. - */ - public JSONArray toJSONArray(JSONArray names) throws JSONException { - if (names == null || names.length() == 0) { - return null; - } - JSONArray ja = new JSONArray(); - for (int i = 0; i < names.length(); i += 1) { - ja.put(this.opt(names.getString(i))); - } - return ja; - } - - /** - * Make an JSON text of this JSONObject. For compactness, no whitespace - * is added. If this would not result in a syntactically correct JSON text, - * then null will be returned instead. - *

- * Warning: This method assumes that the data structure is acyclical. - * - * @return a printable, displayable, portable, transmittable - * representation of the object, beginning - * with { (left brace) and ending - * with } (right brace). - */ - public String toString() { - try { - Iterator keys = keys(); - StringBuilder sb = new StringBuilder("{"); - - while (keys.hasNext()) { - if (sb.length() > 1) { - sb.append(','); - } - Object o = keys.next(); - sb.append(quote(o.toString())); - sb.append(':'); - sb.append(valueToString(this.myHashMap.get(o))); - } - sb.append('}'); - return sb.toString(); - } catch (Exception e) { - return null; - } - } - - - /** - * Make a prettyprinted JSON text of this JSONObject. - *

- * Warning: This method assumes that the data structure is acyclical. - * @param indentFactor The number of spaces to add to each level of - * indentation. - * @return a printable, displayable, portable, transmittable - * representation of the object, beginning - * with { (left brace) and ending - * with } (right brace). - * @throws JSONException If the object contains an invalid number. - */ - public String toString(int indentFactor) throws JSONException { - return toString(indentFactor, 0); - } - - - /** - * Make a prettyprinted JSON text of this JSONObject. - *

- * Warning: This method assumes that the data structure is acyclical. - * @param indentFactor The number of spaces to add to each level of - * indentation. - * @param indent The indentation of the top level. - * @return a printable, displayable, transmittable - * representation of the object, beginning - * with { (left brace) and ending - * with } (right brace). - * @throws JSONException If the object contains an invalid number. - */ - String toString(int indentFactor, int indent) throws JSONException { - int i; - int n = length(); - if (n == 0) { - return "{}"; - } - Iterator keys = keys(); - StringBuilder sb = new StringBuilder("{"); - int newindent = indent + indentFactor; - Object o; - if (n == 1) { - o = keys.next(); - sb.append(quote(o.toString())); - sb.append(": "); - sb.append(valueToString(this.myHashMap.get(o), indentFactor, - indent)); - } else { - while (keys.hasNext()) { - o = keys.next(); - if (sb.length() > 1) { - sb.append(",\n"); - } else { - sb.append('\n'); - } - for (i = 0; i < newindent; i += 1) { - sb.append(' '); - } - sb.append(quote(o.toString())); - sb.append(": "); - sb.append(valueToString(this.myHashMap.get(o), indentFactor, - newindent)); - } - if (sb.length() > 1) { - sb.append('\n'); - for (i = 0; i < indent; i += 1) { - sb.append(' '); - } - } - } - sb.append('}'); - return sb.toString(); - } - - - /** - * Make a JSON text of an object value. - *

- * Warning: This method assumes that the data structure is acyclical. - * @param value The value to be serialized. - * @return a printable, displayable, transmittable - * representation of the object, beginning - * with { (left brace) and ending - * with } (right brace). - * @throws JSONException If the value is or contains an invalid number. - */ - static String valueToString(Object value) throws JSONException { - if (value == null || value.equals(null)) { - return "null"; - } - if (value instanceof Number) { - return numberToString((Number) value); - } - if (value instanceof Boolean || value instanceof JSONObject || - value instanceof JSONArray) { - return value.toString(); - } - return quote(value.toString()); - } - - - /** - * Make a prettyprinted JSON text of an object value. - *

- * Warning: This method assumes that the data structure is acyclical. - * @param value The value to be serialized. - * @param indentFactor The number of spaces to add to each level of - * indentation. - * @param indent The indentation of the top level. - * @return a printable, displayable, transmittable - * representation of the object, beginning - * with { (left brace) and ending - * with } (right brace). - * @throws JSONException If the object contains an invalid number. - */ - static String valueToString(Object value, int indentFactor, int indent) - throws JSONException { - if (value == null || value.equals(null)) { - return "null"; - } - if (value instanceof Number) { - return numberToString((Number) value); - } - if (value instanceof Boolean) { - return value.toString(); - } - if (value instanceof JSONObject) { - return ((JSONObject)value).toString(indentFactor, indent); - } - if (value instanceof JSONArray) { - return ((JSONArray)value).toString(indentFactor, indent); - } - return quote(value.toString()); - } -} diff --git a/libcore/json/src/main/java/org/json/JSONStringer.java b/libcore/json/src/main/java/org/json/JSONStringer.java deleted file mode 100644 index 1154823c1..000000000 --- a/libcore/json/src/main/java/org/json/JSONStringer.java +++ /dev/null @@ -1,327 +0,0 @@ -package org.json; - -/* -Copyright (c) 2005 JSON.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -The Software shall be used for Good, not Evil. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -/** - * JSONStringer provides a quick and convenient way of producing JSON text. - * The texts produced strictly conform to JSON syntax rules. No whitespace is - * added, so the results are ready for transmission or storage. Each instance of - * JSONStringer can produce one JSON text. - *

- * A JSONStringer instance provides a value method for appending - * values to the - * text, and a key - * method for adding keys before values in objects. There are array - * and endArray methods that make and bound array values, and - * object and endObject methods which make and bound - * object values. All of these methods return the JSONStringer instance, - * permitting cascade style. For example,

- * myString = new JSONStringer()
- *     .object()
- *         .key("JSON").value("Hello, World!")
- *     .endObject()
- *     .toString();
which produces the string
- * {"JSON":"Hello, World!"}
- *

- * The first method called must be array or object. - * There are no methods for adding commas or colons. JSONStringer adds them for - * you. Objects and arrays can be nested up to 20 levels deep. - *

- * This can sometimes be easier than using a JSONObject to build a string. - * @author JSON.org - * @version 2 - */ -public class JSONStringer { - private static final int maxdepth = 20; - - /** - * The comma flag determines if a comma should be output before the next - * value. - */ - private boolean comma; - - /** - * The current mode. Values: - * 'a' (array), - * 'd' (done), - * 'i' (initial), - * 'k' (key), - * 'o' (object). - */ - private char mode; - - /** - * The string buffer that holds the JSON text that is built. - */ - private StringBuilder sb; - - /** - * The object/array stack. - */ - private char stack[]; - - /** - * The stack top index. A value of 0 indicates that the stack is empty. - */ - private int top; - - /** - * Make a fresh JSONStringer. It can be used to build one JSON text. - */ - public JSONStringer() { - this.sb = new StringBuilder(); - this.stack = new char[maxdepth]; - this.top = 0; - this.mode = 'i'; - this.comma = false; - } - - /** - * Append a value. - * @param s A string value. - * @return this - * @throws JSONException If the value is out of sequence. - */ - private JSONStringer append(String s) - throws JSONException { - if (s == null) { - throw new JSONException("Null pointer"); - } - if (this.mode == 'o' || this.mode == 'a') { - if (this.comma && this.mode == 'a') { - this.sb.append(','); - } - this.sb.append(s); - if (this.mode == 'o') { - this.mode = 'k'; - } - this.comma = true; - return this; - } - throw new JSONException("Value out of sequence."); - } - - /** - * Begin appending a new array. All values until the balancing - * endArray will be appended to this array. The - * endArray method must be called to mark the array's end. - * @return this - * @throws JSONException If the nesting is too deep, or if the object is - * started in the wrong place (for example as a key or after the end of the - * outermost array or object). - */ - public JSONStringer array() throws JSONException { - if (this.mode == 'i' || this.mode == 'o' || this.mode == 'a') { - push('a'); - this.append("["); - this.comma = false; - return this; - } - throw new JSONException("Misplaced array."); - } - - /** - * End something. - * @param m Mode - * @param c Closing character - * @return this - * @throws JSONException If unbalanced. - */ - private JSONStringer end(char m, char c) throws JSONException { - if (this.mode != m) { - throw new JSONException(m == 'o' ? "Misplaced endObject." : - "Misplaced endArray."); - } - pop(m); - this.sb.append(c); - this.comma = true; - return this; - } - - /** - * End an array. This method most be called to balance calls to - * array. - * @return this - * @throws JSONException If incorrectly nested. - */ - public JSONStringer endArray() throws JSONException { - return end('a', ']'); - } - - /** - * End an object. This method most be called to balance calls to - * object. - * @return this - * @throws JSONException If incorrectly nested. - */ - public JSONStringer endObject() throws JSONException { - return end('k', '}'); - } - - /** - * Append a key. The key will be associated with the next value. In an - * object, every value must be preceded by a key. - * @param s A key string. - * @return this - * @throws JSONException If the key is out of place. For example, keys - * do not belong in arrays or if the key is null. - */ - public JSONStringer key(String s) - throws JSONException { - if (s == null) { - throw new JSONException("Null key."); - } - if (this.mode == 'k') { - if (this.comma) { - this.sb.append(','); - } - this.sb.append(JSONObject.quote(s)); - this.sb.append(':'); - this.comma = false; - this.mode = 'o'; - return this; - } - throw new JSONException("Misplaced key."); - } - - - /** - * Begin appending a new object. All keys and values until the balancing - * endObject will be appended to this object. The - * endObject method must be called to mark the object's end. - * @return this - * @throws JSONException If the nesting is too deep, or if the object is - * started in the wrong place (for example as a key or after the end of the - * outermost array or object). - */ - public JSONStringer object() throws JSONException { - if (this.mode == 'i') { - this.mode = 'o'; - } - if (this.mode == 'o' || this.mode == 'a') { - this.append("{"); - push('k'); - this.comma = false; - return this; - } - throw new JSONException("Misplaced object."); - - } - - - /** - * Pop an array or object scope. - * @param c The scope to close. - * @throws JSONException If nesting is wrong. - */ - private void pop(char c) throws JSONException { - if (this.top <= 0 || this.stack[this.top - 1] != c) { - throw new JSONException("Nesting error."); - } - this.top -= 1; - this.mode = this.top == 0 ? 'd' : this.stack[this.top - 1]; - } - - /** - * Push an array or object scope. - * @param c The scope to open. - * @throws JSONException If nesting is too deep. - */ - private void push(char c) throws JSONException { - if (this.top >= maxdepth) { - throw new JSONException("Nesting too deep."); - } - this.stack[this.top] = c; - this.mode = c; - this.top += 1; - } - - - /** - * Append either the value true or the value - * false. - * @param b A boolean. - * @return this - * @throws JSONException - */ - public JSONStringer value(boolean b) throws JSONException { - return this.append(b ? "true" : "false"); - } - - /** - * Append a double value. - * @param d A double. - * @return this - * @throws JSONException If the number is not finite. - */ - public JSONStringer value(double d) throws JSONException { - return this.value(new Double(d)); - } - - /** - * Append a long value. - * @param l A long. - * @return this - * @throws JSONException - */ - public JSONStringer value(long l) throws JSONException { - return this.append(Long.toString(l)); - } - - - /** - * Append an object value. - * @param o The object to append. It can be null, or a Boolean, Number, - * String, JSONObject, or JSONArray. - * @return this - * @throws JSONException If the value is out of sequence. - */ - public JSONStringer value(Object o) throws JSONException { - if (JSONObject.NULL.equals(o)) { - return this.append("null"); - } - if (o instanceof Number) { - JSONObject.testValidity(o); - return this.append(JSONObject.numberToString((Number)o)); - } - if (o instanceof Boolean || - o instanceof JSONArray || o instanceof JSONObject) { - return this.append(o.toString()); - } - return this.append(JSONObject.quote(o.toString())); - } - - /** - * Return the JSON text. This method is used to obtain the product of the - * JSONStringer instance. It will return null if there was a - * problem in the construction of the JSON text (such as the calls to - * array were not properly balanced with calls to - * endArray). - * @return The JSON text. - */ - public String toString() { - return this.mode == 'd' ? this.sb.toString() : null; - } -} diff --git a/libcore/json/src/main/java/org/json/JSONTokener.java b/libcore/json/src/main/java/org/json/JSONTokener.java deleted file mode 100644 index 7ac1cd742..000000000 --- a/libcore/json/src/main/java/org/json/JSONTokener.java +++ /dev/null @@ -1,460 +0,0 @@ -package org.json; - -/* -Copyright (c) 2002 JSON.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -The Software shall be used for Good, not Evil. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -/** - * A JSONTokener takes a source string and extracts characters and tokens from - * it. It is used by the JSONObject and JSONArray constructors to parse - * JSON source strings. - * @author JSON.org - * @version 2 - */ -public class JSONTokener { - - /** - * The index of the next character. - */ - private int myIndex; - - - /** - * The source string being tokenized. - */ - private String mySource; - - - /** - * Construct a JSONTokener from a string. - * - * @param s A source string. - */ - public JSONTokener(String s) { - this.myIndex = 0; - this.mySource = s; - } - - - /** - * Back up one character. This provides a sort of lookahead capability, - * so that you can test for a digit or letter before attempting to parse - * the next number or identifier. - */ - public void back() { - if (this.myIndex > 0) { - this.myIndex -= 1; - } - } - - - - /** - * Get the hex value of a character (base16). - * @param c A character between '0' and '9' or between 'A' and 'F' or - * between 'a' and 'f'. - * @return An int between 0 and 15, or -1 if c was not a hex digit. - */ - public static int dehexchar(char c) { - if (c >= '0' && c <= '9') { - return c - '0'; - } - if (c >= 'A' && c <= 'F') { - return c - ('A' - 10); - } - if (c >= 'a' && c <= 'f') { - return c - ('a' - 10); - } - return -1; - } - - - /** - * Determine if the source string still contains characters that next() - * can consume. - * @return true if not yet at the end of the source. - */ - public boolean more() { - return this.myIndex < this.mySource.length(); - } - - - /** - * Get the next character in the source string. - * - * @return The next character, or 0 if past the end of the source string. - */ - public char next() { - if (more()) { - char c = this.mySource.charAt(this.myIndex); - this.myIndex += 1; - return c; - } - return 0; - } - - - /** - * Consume the next character, and check that it matches a specified - * character. - * @param c The character to match. - * @return The character. - * @throws JSONException if the character does not match. - */ - public char next(char c) throws JSONException { - char n = next(); - if (n != c) { - throw syntaxError("Expected '" + c + "' and instead saw '" + - n + "'."); - } - return n; - } - - - /** - * Get the next n characters. - * - * @param n The number of characters to take. - * @return A string of n characters. - * @throws JSONException - * Substring bounds error if there are not - * n characters remaining in the source string. - */ - public String next(int n) throws JSONException { - int i = this.myIndex; - int j = i + n; - if (j >= this.mySource.length()) { - throw syntaxError("Substring bounds error"); - } - this.myIndex += n; - return this.mySource.substring(i, j); - } - - - /** - * Get the next char in the string, skipping whitespace - * and comments (slashslash, slashstar, and hash). - * @throws JSONException - * @return A character, or 0 if there are no more characters. - */ - public char nextClean() throws JSONException { - for (;;) { - char c = next(); - if (c == '/') { - switch (next()) { - case '/': - do { - c = next(); - } while (c != '\n' && c != '\r' && c != 0); - break; - case '*': - for (;;) { - c = next(); - if (c == 0) { - throw syntaxError("Unclosed comment."); - } - if (c == '*') { - if (next() == '/') { - break; - } - back(); - } - } - break; - default: - back(); - return '/'; - } - } else if (c == '#') { - do { - c = next(); - } while (c != '\n' && c != '\r' && c != 0); - } else if (c == 0 || c > ' ') { - return c; - } - } - } - - - /** - * Return the characters up to the next close quote character. - * Backslash processing is done. The formal JSON format does not - * allow strings in single quotes, but an implementation is allowed to - * accept them. - * @param quote The quoting character, either - * " (double quote) or - * ' (single quote). - * @return A String. - * @throws JSONException Unterminated string. - */ - public String nextString(char quote) throws JSONException { - char c; - StringBuilder sb = new StringBuilder(); - for (;;) { - c = next(); - switch (c) { - case 0: - case '\n': - case '\r': - throw syntaxError("Unterminated string"); - case '\\': - c = next(); - switch (c) { - case 'b': - sb.append('\b'); - break; - case 't': - sb.append('\t'); - break; - case 'n': - sb.append('\n'); - break; - case 'f': - sb.append('\f'); - break; - case 'r': - sb.append('\r'); - break; - case 'u': - sb.append((char)Integer.parseInt(next(4), 16)); - break; - case 'x' : - sb.append((char) Integer.parseInt(next(2), 16)); - break; - default: - sb.append(c); - } - break; - default: - if (c == quote) { - return sb.toString(); - } - sb.append(c); - } - } - } - - - /** - * Get the text up but not including the specified character or the - * end of line, whichever comes first. - * @param d A delimiter character. - * @return A string. - */ - public String nextTo(char d) { - StringBuilder sb = new StringBuilder(); - for (;;) { - char c = next(); - if (c == d || c == 0 || c == '\n' || c == '\r') { - if (c != 0) { - back(); - } - return sb.toString().trim(); - } - sb.append(c); - } - } - - - /** - * Get the text up but not including one of the specified delimeter - * characters or the end of line, whichever comes first. - * @param delimiters A set of delimiter characters. - * @return A string, trimmed. - */ - public String nextTo(String delimiters) { - char c; - StringBuilder sb = new StringBuilder(); - for (;;) { - c = next(); - if (delimiters.indexOf(c) >= 0 || c == 0 || - c == '\n' || c == '\r') { - if (c != 0) { - back(); - } - return sb.toString().trim(); - } - sb.append(c); - } - } - - - /** - * Get the next value. The value can be a Boolean, Double, Integer, - * JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object. - * @throws JSONException If syntax error. - * - * @return An object. - */ - public Object nextValue() throws JSONException { - char c = nextClean(); - String s; - - switch (c) { - case '"': - case '\'': - return nextString(c); - case '{': - back(); - return new JSONObject(this); - case '[': - back(); - return new JSONArray(this); - } - - /* - * Handle unquoted text. This could be the values true, false, or - * null, or it can be a number. An implementation (such as this one) - * is allowed to also accept non-standard forms. - * - * Accumulate characters until we reach the end of the text or a - * formatting character. - */ - - StringBuilder sb = new StringBuilder(); - char b = c; - while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) { - sb.append(c); - c = next(); - } - back(); - - /* - * If it is true, false, or null, return the proper value. - */ - - s = sb.toString().trim(); - if (s.equals("")) { - throw syntaxError("Missing value."); - } - if (s.equalsIgnoreCase("true")) { - return Boolean.TRUE; - } - if (s.equalsIgnoreCase("false")) { - return Boolean.FALSE; - } - if (s.equalsIgnoreCase("null")) { - return JSONObject.NULL; - } - - /* - * If it might be a number, try converting it. We support the 0- and 0x- - * conventions. If a number cannot be produced, then the value will just - * be a string. Note that the 0-, 0x-, plus, and implied string - * conventions are non-standard. A JSON parser is free to accept - * non-JSON forms as long as it accepts all correct JSON forms. - */ - - if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+') { - if (b == '0') { - if (s.length() > 2 && - (s.charAt(1) == 'x' || s.charAt(1) == 'X')) { - try { - return new Integer(Integer.parseInt(s.substring(2), - 16)); - } catch (Exception e) { - /* Ignore the error */ - } - } else { - try { - return new Integer(Integer.parseInt(s, 8)); - } catch (Exception e) { - /* Ignore the error */ - } - } - } - try { - return new Integer(s); - } catch (Exception e) { - try { - return new Long(s); - } catch (Exception f) { - try { - return new Double(s); - } catch (Exception g) { - return s; - } - } - } - } - return s; - } - - - /** - * Skip characters until the next character is the requested character. - * If the requested character is not found, no characters are skipped. - * @param to A character to skip to. - * @return The requested character, or zero if the requested character - * is not found. - */ - public char skipTo(char to) { - char c; - int index = this.myIndex; - do { - c = next(); - if (c == 0) { - this.myIndex = index; - return c; - } - } while (c != to); - back(); - return c; - } - - - /** - * Skip characters until past the requested string. - * If it is not found, we are left at the end of the source. - * @param to A string to skip past. - */ - public void skipPast(String to) { - this.myIndex = this.mySource.indexOf(to, this.myIndex); - if (this.myIndex < 0) { - this.myIndex = this.mySource.length(); - } else { - this.myIndex += to.length(); - } - } - - - /** - * Make a JSONException to signal a syntax error. - * - * @param message The error message. - * @return A JSONException object, suitable for throwing - */ - public JSONException syntaxError(String message) { - return new JSONException(message + toString()); - } - - - /** - * Make a printable string of this JSONTokener. - * - * @return " at character [this.myIndex] of [this.mySource]" - */ - public String toString() { - return " at character " + this.myIndex + " of " + this.mySource; - } -} \ No newline at end of file diff --git a/libcore/junit/MODULE_LICENSE_CPL b/libcore/junit/MODULE_LICENSE_CPL deleted file mode 100644 index 541dbb53c..000000000 --- a/libcore/junit/MODULE_LICENSE_CPL +++ /dev/null @@ -1 +0,0 @@ -http://www.opensource.org/licenses/cpl1.0.php diff --git a/libcore/junit/src/main/java/junit/extensions/ActiveTestSuite.java b/libcore/junit/src/main/java/junit/extensions/ActiveTestSuite.java deleted file mode 100644 index 073e6f3ab..000000000 --- a/libcore/junit/src/main/java/junit/extensions/ActiveTestSuite.java +++ /dev/null @@ -1,64 +0,0 @@ -package junit.extensions; - -import junit.framework.*; - -/** - * A TestSuite for active Tests. It runs each - * test in a separate thread and waits until all - * threads have terminated. - * -- Aarhus Radisson Scandinavian Center 11th floor - */ -public class ActiveTestSuite extends TestSuite { - private volatile int fActiveTestDeathCount; - - public ActiveTestSuite() { - } - - public ActiveTestSuite(Class theClass) { - super(theClass); - } - - public ActiveTestSuite(String name) { - super (name); - } - - public ActiveTestSuite(Class theClass, String name) { - super(theClass, name); - } - - public void run(TestResult result) { - fActiveTestDeathCount= 0; - super.run(result); - waitUntilFinished(); - } - - public void runTest(final Test test, final TestResult result) { - Thread t= new Thread() { - public void run() { - try { - // inlined due to limitation in VA/Java - //ActiveTestSuite.super.runTest(test, result); - test.run(result); - } finally { - ActiveTestSuite.this.runFinished(test); - } - } - }; - t.start(); - } - - synchronized void waitUntilFinished() { - while (fActiveTestDeathCount < testCount()) { - try { - wait(); - } catch (InterruptedException e) { - return; // ignore - } - } - } - - synchronized public void runFinished(Test test) { - fActiveTestDeathCount++; - notifyAll(); - } -} diff --git a/libcore/junit/src/main/java/junit/extensions/ExceptionTestCase.java b/libcore/junit/src/main/java/junit/extensions/ExceptionTestCase.java deleted file mode 100644 index de64b5b41..000000000 --- a/libcore/junit/src/main/java/junit/extensions/ExceptionTestCase.java +++ /dev/null @@ -1,46 +0,0 @@ -package junit.extensions; - -import junit.framework.*; - -/** - * A TestCase that expects an Exception of class fExpected to be thrown. - * The other way to check that an expected exception is thrown is: - *

- * try {
- *   shouldThrow();
- * }
- * catch (SpecialException e) {
- *   return;
- * }
- * fail("Expected SpecialException");
- * 
- * - * To use ExceptionTestCase, create a TestCase like: - *
- * new ExceptionTestCase("testShouldThrow", SpecialException.class);
- * 
- */ -public class ExceptionTestCase extends TestCase { - Class fExpected; - - public ExceptionTestCase(String name, Class exception) { - super(name); - fExpected= exception; - } - /** - * Execute the test method expecting that an Exception of - * class fExpected or one of its subclasses will be thrown - */ - protected void runTest() throws Throwable { - try { - super.runTest(); - } - catch (Exception e) { - if (fExpected.isAssignableFrom(e.getClass())) - return; - else - throw e; - } - fail("Expected exception " + fExpected); - } -} diff --git a/libcore/junit/src/main/java/junit/extensions/RepeatedTest.java b/libcore/junit/src/main/java/junit/extensions/RepeatedTest.java deleted file mode 100644 index 34f2541ce..000000000 --- a/libcore/junit/src/main/java/junit/extensions/RepeatedTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package junit.extensions; - -import junit.framework.*; - -/** - * A Decorator that runs a test repeatedly. - * - */ -public class RepeatedTest extends TestDecorator { - private int fTimesRepeat; - - public RepeatedTest(Test test, int repeat) { - super(test); - if (repeat < 0) - throw new IllegalArgumentException("Repetition count must be > 0"); - fTimesRepeat= repeat; - } - public int countTestCases() { - return super.countTestCases()*fTimesRepeat; - } - public void run(TestResult result) { - for (int i= 0; i < fTimesRepeat; i++) { - if (result.shouldStop()) - break; - super.run(result); - } - } - public String toString() { - return super.toString()+"(repeated)"; - } -} diff --git a/libcore/junit/src/main/java/junit/extensions/TestDecorator.java b/libcore/junit/src/main/java/junit/extensions/TestDecorator.java deleted file mode 100644 index 6b5144ab2..000000000 --- a/libcore/junit/src/main/java/junit/extensions/TestDecorator.java +++ /dev/null @@ -1,38 +0,0 @@ -package junit.extensions; - -import junit.framework.*; - -/** - * A Decorator for Tests. Use TestDecorator as the base class - * for defining new test decorators. Test decorator subclasses - * can be introduced to add behaviour before or after a test - * is run. - * - */ -public class TestDecorator extends Assert implements Test { - protected Test fTest; - - public TestDecorator(Test test) { - fTest= test; - } - /** - * The basic run behaviour. - */ - public void basicRun(TestResult result) { - fTest.run(result); - } - public int countTestCases() { - return fTest.countTestCases(); - } - public void run(TestResult result) { - basicRun(result); - } - - public String toString() { - return fTest.toString(); - } - - public Test getTest() { - return fTest; - } -} diff --git a/libcore/junit/src/main/java/junit/extensions/TestSetup.java b/libcore/junit/src/main/java/junit/extensions/TestSetup.java deleted file mode 100644 index 3651501ab..000000000 --- a/libcore/junit/src/main/java/junit/extensions/TestSetup.java +++ /dev/null @@ -1,37 +0,0 @@ -package junit.extensions; - -import junit.framework.*; - -/** - * A Decorator to set up and tear down additional fixture state. - * Subclass TestSetup and insert it into your tests when you want - * to set up additional state once before the tests are run. - */ -public class TestSetup extends TestDecorator { - - public TestSetup(Test test) { - super(test); - } - public void run(final TestResult result) { - Protectable p= new Protectable() { - public void protect() throws Exception { - setUp(); - basicRun(result); - tearDown(); - } - }; - result.runProtected(this, p); - } - /** - * Sets up the fixture. Override to set up additional fixture - * state. - */ - protected void setUp() throws Exception { - } - /** - * Tears down the fixture. Override to tear down the additional - * fixture state. - */ - protected void tearDown() throws Exception { - } -} diff --git a/libcore/junit/src/main/java/junit/extensions/package.html b/libcore/junit/src/main/java/junit/extensions/package.html deleted file mode 100644 index 6b4be727d..000000000 --- a/libcore/junit/src/main/java/junit/extensions/package.html +++ /dev/null @@ -1,6 +0,0 @@ - - -Utility classes supporting the junit test framework. -{@hide} - Not needed for 1.0 SDK - - diff --git a/libcore/junit/src/main/java/junit/framework/Assert.java b/libcore/junit/src/main/java/junit/framework/Assert.java deleted file mode 100644 index c1bc7b2cd..000000000 --- a/libcore/junit/src/main/java/junit/framework/Assert.java +++ /dev/null @@ -1,291 +0,0 @@ -package junit.framework; - -/** - * A set of assert methods. Messages are only displayed when an assert fails. - */ - -public class Assert { - /** - * Protect constructor since it is a static only class - */ - protected Assert() { - } - - /** - * Asserts that a condition is true. If it isn't it throws - * an AssertionFailedError with the given message. - */ - static public void assertTrue(String message, boolean condition) { - if (!condition) - fail(message); - } - /** - * Asserts that a condition is true. If it isn't it throws - * an AssertionFailedError. - */ - static public void assertTrue(boolean condition) { - assertTrue(null, condition); - } - /** - * Asserts that a condition is false. If it isn't it throws - * an AssertionFailedError with the given message. - */ - static public void assertFalse(String message, boolean condition) { - assertTrue(message, !condition); - } - /** - * Asserts that a condition is false. If it isn't it throws - * an AssertionFailedError. - */ - static public void assertFalse(boolean condition) { - assertFalse(null, condition); - } - /** - * Fails a test with the given message. - */ - static public void fail(String message) { - throw new AssertionFailedError(message); - } - /** - * Fails a test with no message. - */ - static public void fail() { - fail(null); - } - /** - * Asserts that two objects are equal. If they are not - * an AssertionFailedError is thrown with the given message. - */ - static public void assertEquals(String message, Object expected, Object actual) { - if (expected == null && actual == null) - return; - if (expected != null && expected.equals(actual)) - return; - failNotEquals(message, expected, actual); - } - /** - * Asserts that two objects are equal. If they are not - * an AssertionFailedError is thrown. - */ - static public void assertEquals(Object expected, Object actual) { - assertEquals(null, expected, actual); - } - /** - * Asserts that two Strings are equal. - */ - static public void assertEquals(String message, String expected, String actual) { - if (expected == null && actual == null) - return; - if (expected != null && expected.equals(actual)) - return; - throw new ComparisonFailure(message, expected, actual); - } - /** - * Asserts that two Strings are equal. - */ - static public void assertEquals(String expected, String actual) { - assertEquals(null, expected, actual); - } - /** - * Asserts that two doubles are equal concerning a delta. If they are not - * an AssertionFailedError is thrown with the given message. If the expected - * value is infinity then the delta value is ignored. - */ - static public void assertEquals(String message, double expected, double actual, double delta) { - // handle infinity specially since subtracting to infinite values gives NaN and the - // the following test fails - if (Double.isInfinite(expected)) { - if (!(expected == actual)) - failNotEquals(message, new Double(expected), new Double(actual)); - } else if (!(Math.abs(expected-actual) <= delta)) // Because comparison with NaN always returns false - failNotEquals(message, new Double(expected), new Double(actual)); - } - /** - * Asserts that two doubles are equal concerning a delta. If the expected - * value is infinity then the delta value is ignored. - */ - static public void assertEquals(double expected, double actual, double delta) { - assertEquals(null, expected, actual, delta); - } - /** - * Asserts that two floats are equal concerning a delta. If they are not - * an AssertionFailedError is thrown with the given message. If the expected - * value is infinity then the delta value is ignored. - */ - static public void assertEquals(String message, float expected, float actual, float delta) { - // handle infinity specially since subtracting to infinite values gives NaN and the - // the following test fails - if (Float.isInfinite(expected)) { - if (!(expected == actual)) - failNotEquals(message, new Float(expected), new Float(actual)); - } else if (!(Math.abs(expected-actual) <= delta)) - failNotEquals(message, new Float(expected), new Float(actual)); - } - /** - * Asserts that two floats are equal concerning a delta. If the expected - * value is infinity then the delta value is ignored. - */ - static public void assertEquals(float expected, float actual, float delta) { - assertEquals(null, expected, actual, delta); - } - /** - * Asserts that two longs are equal. If they are not - * an AssertionFailedError is thrown with the given message. - */ - static public void assertEquals(String message, long expected, long actual) { - assertEquals(message, new Long(expected), new Long(actual)); - } - /** - * Asserts that two longs are equal. - */ - static public void assertEquals(long expected, long actual) { - assertEquals(null, expected, actual); - } - /** - * Asserts that two booleans are equal. If they are not - * an AssertionFailedError is thrown with the given message. - */ - static public void assertEquals(String message, boolean expected, boolean actual) { - assertEquals(message, new Boolean(expected), new Boolean(actual)); - } - /** - * Asserts that two booleans are equal. - */ - static public void assertEquals(boolean expected, boolean actual) { - assertEquals(null, expected, actual); - } - /** - * Asserts that two bytes are equal. If they are not - * an AssertionFailedError is thrown with the given message. - */ - static public void assertEquals(String message, byte expected, byte actual) { - assertEquals(message, new Byte(expected), new Byte(actual)); - } - /** - * Asserts that two bytes are equal. - */ - static public void assertEquals(byte expected, byte actual) { - assertEquals(null, expected, actual); - } - /** - * Asserts that two chars are equal. If they are not - * an AssertionFailedError is thrown with the given message. - */ - static public void assertEquals(String message, char expected, char actual) { - assertEquals(message, new Character(expected), new Character(actual)); - } - /** - * Asserts that two chars are equal. - */ - static public void assertEquals(char expected, char actual) { - assertEquals(null, expected, actual); - } - /** - * Asserts that two shorts are equal. If they are not - * an AssertionFailedError is thrown with the given message. - */ - static public void assertEquals(String message, short expected, short actual) { - assertEquals(message, new Short(expected), new Short(actual)); - } - /** - * Asserts that two shorts are equal. - */ - static public void assertEquals(short expected, short actual) { - assertEquals(null, expected, actual); - } - /** - * Asserts that two ints are equal. If they are not - * an AssertionFailedError is thrown with the given message. - */ - static public void assertEquals(String message, int expected, int actual) { - assertEquals(message, new Integer(expected), new Integer(actual)); - } - /** - * Asserts that two ints are equal. - */ - static public void assertEquals(int expected, int actual) { - assertEquals(null, expected, actual); - } - /** - * Asserts that an object isn't null. - */ - static public void assertNotNull(Object object) { - assertNotNull(null, object); - } - /** - * Asserts that an object isn't null. If it is - * an AssertionFailedError is thrown with the given message. - */ - static public void assertNotNull(String message, Object object) { - assertTrue(message, object != null); - } - /** - * Asserts that an object is null. - */ - static public void assertNull(Object object) { - assertNull(null, object); - } - /** - * Asserts that an object is null. If it is not - * an AssertionFailedError is thrown with the given message. - */ - static public void assertNull(String message, Object object) { - assertTrue(message, object == null); - } - /** - * Asserts that two objects refer to the same object. If they are not - * an AssertionFailedError is thrown with the given message. - */ - static public void assertSame(String message, Object expected, Object actual) { - if (expected == actual) - return; - failNotSame(message, expected, actual); - } - /** - * Asserts that two objects refer to the same object. If they are not - * the same an AssertionFailedError is thrown. - */ - static public void assertSame(Object expected, Object actual) { - assertSame(null, expected, actual); - } - /** - * Asserts that two objects refer to the same object. If they are not - * an AssertionFailedError is thrown with the given message. - */ - static public void assertNotSame(String message, Object expected, Object actual) { - if (expected == actual) - failSame(message); - } - /** - * Asserts that two objects refer to the same object. If they are not - * the same an AssertionFailedError is thrown. - */ - static public void assertNotSame(Object expected, Object actual) { - assertNotSame(null, expected, actual); - } - - static private void failSame(String message) { - String formatted= ""; - if (message != null) - formatted= message+" "; - fail(formatted+"expected not same"); - } - - static private void failNotSame(String message, Object expected, Object actual) { - String formatted= ""; - if (message != null) - formatted= message+" "; - fail(formatted+"expected same:<"+expected+"> was not:<"+actual+">"); - } - - static private void failNotEquals(String message, Object expected, Object actual) { - fail(format(message, expected, actual)); - } - - static String format(String message, Object expected, Object actual) { - String formatted= ""; - if (message != null) - formatted= message+" "; - return formatted+"expected:<"+expected+"> but was:<"+actual+">"; - } -} diff --git a/libcore/junit/src/main/java/junit/framework/AssertionFailedError.java b/libcore/junit/src/main/java/junit/framework/AssertionFailedError.java deleted file mode 100644 index e9cb3a385..000000000 --- a/libcore/junit/src/main/java/junit/framework/AssertionFailedError.java +++ /dev/null @@ -1,13 +0,0 @@ -package junit.framework; - -/** - * Thrown when an assertion failed. - */ -public class AssertionFailedError extends Error { - - public AssertionFailedError () { - } - public AssertionFailedError (String message) { - super (message); - } -} diff --git a/libcore/junit/src/main/java/junit/framework/ComparisonFailure.java b/libcore/junit/src/main/java/junit/framework/ComparisonFailure.java deleted file mode 100644 index a0ad17611..000000000 --- a/libcore/junit/src/main/java/junit/framework/ComparisonFailure.java +++ /dev/null @@ -1,68 +0,0 @@ -package junit.framework; - -/** - * Thrown when an assert equals for Strings failed. - * - * Inspired by a patch from Alex Chaffee mailto:alex@purpletech.com - */ -public class ComparisonFailure extends AssertionFailedError { - private String fExpected; - private String fActual; - - /** - * Constructs a comparison failure. - * @param message the identifying message or null - * @param expected the expected string value - * @param actual the actual string value - */ - public ComparisonFailure (String message, String expected, String actual) { - super (message); - fExpected= expected; - fActual= actual; - } - - /** - * Returns "..." in place of common prefix and "..." in - * place of common suffix between expected and actual. - * - * @see java.lang.Throwable#getMessage() - */ - public String getMessage() { - if (fExpected == null || fActual == null) - return Assert.format(super.getMessage(), fExpected, fActual); - - int end= Math.min(fExpected.length(), fActual.length()); - - int i= 0; - for(; i < end; i++) { - if (fExpected.charAt(i) != fActual.charAt(i)) - break; - } - int j= fExpected.length()-1; - int k= fActual.length()-1; - for (; k >= i && j >= i; k--,j--) { - if (fExpected.charAt(j) != fActual.charAt(k)) - break; - } - String actual, expected; - - // equal strings - if (j < i && k < i) { - expected= fExpected; - actual= fActual; - } else { - expected= fExpected.substring(i, j+1); - actual= fActual.substring(i, k+1); - if (i <= end && i > 0) { - expected= "..."+expected; - actual= "..."+actual; - } - - if (j < fExpected.length()-1) - expected= expected+"..."; - if (k < fActual.length()-1) - actual= actual+"..."; - } - return Assert.format(super.getMessage(), expected, actual); - } -} diff --git a/libcore/junit/src/main/java/junit/framework/Protectable.java b/libcore/junit/src/main/java/junit/framework/Protectable.java deleted file mode 100644 index 9a63c9695..000000000 --- a/libcore/junit/src/main/java/junit/framework/Protectable.java +++ /dev/null @@ -1,14 +0,0 @@ -package junit.framework; - -/** - * A Protectable can be run and can throw a Throwable. - * - * @see TestResult - */ -public interface Protectable { - - /** - * Run the the following method protected. - */ - public abstract void protect() throws Throwable; -} diff --git a/libcore/junit/src/main/java/junit/framework/Test.java b/libcore/junit/src/main/java/junit/framework/Test.java deleted file mode 100644 index 94f25cf9f..000000000 --- a/libcore/junit/src/main/java/junit/framework/Test.java +++ /dev/null @@ -1,17 +0,0 @@ -package junit.framework; - -/** - * A Test can be run and collect its results. - * - * @see TestResult - */ -public interface Test { - /** - * Counts the number of test cases that will be run by this test. - */ - public abstract int countTestCases(); - /** - * Runs a test and collects its result in a TestResult instance. - */ - public abstract void run(TestResult result); -} diff --git a/libcore/junit/src/main/java/junit/framework/TestCase.java b/libcore/junit/src/main/java/junit/framework/TestCase.java deleted file mode 100644 index f29e8d232..000000000 --- a/libcore/junit/src/main/java/junit/framework/TestCase.java +++ /dev/null @@ -1,197 +0,0 @@ -package junit.framework; - -import java.lang.reflect.*; - -/** - * A test case defines the fixture to run multiple tests. To define a test case
- * 1) implement a subclass of TestCase
- * 2) define instance variables that store the state of the fixture
- * 3) initialize the fixture state by overriding setUp
- * 4) clean-up after a test by overriding tearDown.
- * Each test runs in its own fixture so there - * can be no side effects among test runs. - * Here is an example: - *
- * public class MathTest extends TestCase {
- *     protected double fValue1;
- *     protected double fValue2;
- *
- *    protected void setUp() {
- *         fValue1= 2.0;
- *         fValue2= 3.0;
- *     }
- * }
- * 
- * - * For each test implement a method which interacts - * with the fixture. Verify the expected results with assertions specified - * by calling assertTrue with a boolean. - *
- *    public void testAdd() {
- *        double result= fValue1 + fValue2;
- *        assertTrue(result == 5.0);
- *    }
- * 
- * Once the methods are defined you can run them. The framework supports - * both a static type safe and more dynamic way to run a test. - * In the static way you override the runTest method and define the method to - * be invoked. A convenient way to do so is with an anonymous inner class. - *
- * TestCase test= new MathTest("add") {
- *        public void runTest() {
- *            testAdd();
- *        }
- * };
- * test.run();
- * 
- * The dynamic way uses reflection to implement runTest. It dynamically finds - * and invokes a method. - * In this case the name of the test case has to correspond to the test method - * to be run. - *
- * TestCase= new MathTest("testAdd");
- * test.run();
- * 
- * The tests to be run can be collected into a TestSuite. JUnit provides - * different test runners which can run a test suite and collect the results. - * A test runner either expects a static method suite as the entry - * point to get a test to run or it will extract the suite automatically. - *
- * public static Test suite() {
- *      suite.addTest(new MathTest("testAdd"));
- *      suite.addTest(new MathTest("testDivideByZero"));
- *      return suite;
- *  }
- * 
- * @see TestResult - * @see TestSuite - */ - -public abstract class TestCase extends Assert implements Test { - /** - * the name of the test case - */ - private String fName; - - /** - * No-arg constructor to enable serialization. This method - * is not intended to be used by mere mortals without calling setName(). - */ - public TestCase() { - fName= null; - } - /** - * Constructs a test case with the given name. - */ - public TestCase(String name) { - fName= name; - } - /** - * Counts the number of test cases executed by run(TestResult result). - */ - public int countTestCases() { - return 1; - } - /** - * Creates a default TestResult object - * - * @see TestResult - */ - protected TestResult createResult() { - return new TestResult(); - } - /** - * A convenience method to run this test, collecting the results with a - * default TestResult object. - * - * @see TestResult - */ - public TestResult run() { - TestResult result= createResult(); - run(result); - return result; - } - /** - * Runs the test case and collects the results in TestResult. - */ - public void run(TestResult result) { - result.run(this); - } - /** - * Runs the bare test sequence. - * @exception Throwable if any exception is thrown - */ - public void runBare() throws Throwable { - setUp(); - try { - runTest(); - } - finally { - tearDown(); - } - } - /** - * Override to run the test and assert its state. - * @exception Throwable if any exception is thrown - */ - protected void runTest() throws Throwable { - assertNotNull(fName); - Method runMethod= null; - try { - // use getMethod to get all public inherited - // methods. getDeclaredMethods returns all - // methods of this class but excludes the - // inherited ones. - runMethod= getClass().getMethod(fName, (Class[]) null); - } catch (NoSuchMethodException e) { - fail("Method \""+fName+"\" not found"); - } - if (!Modifier.isPublic(runMethod.getModifiers())) { - fail("Method \""+fName+"\" should be public"); - } - - try { - runMethod.invoke(this, (Object[]) null); - } - catch (InvocationTargetException e) { - e.fillInStackTrace(); - throw e.getTargetException(); - } - catch (IllegalAccessException e) { - e.fillInStackTrace(); - throw e; - } - } - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - */ - protected void setUp() throws Exception { - } - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - */ - protected void tearDown() throws Exception { - } - /** - * Returns a string representation of the test case - */ - public String toString() { - return getName() + "(" + getClass().getName() + ")"; - } - /** - * Gets the name of a TestCase - * @return returns a String - */ - public String getName() { - return fName; - } - /** - * Sets the name of a TestCase - * @param name The name to set - */ - public void setName(String name) { - fName= name; - } -} diff --git a/libcore/junit/src/main/java/junit/framework/TestFailure.java b/libcore/junit/src/main/java/junit/framework/TestFailure.java deleted file mode 100644 index ace2dbe5b..000000000 --- a/libcore/junit/src/main/java/junit/framework/TestFailure.java +++ /dev/null @@ -1,57 +0,0 @@ -package junit.framework; - -import java.io.PrintWriter; -import java.io.StringWriter; - - -/** - * A TestFailure collects a failed test together with - * the caught exception. - * @see TestResult - */ -public class TestFailure extends Object { - protected Test fFailedTest; - protected Throwable fThrownException; - - - /** - * Constructs a TestFailure with the given test and exception. - */ - public TestFailure(Test failedTest, Throwable thrownException) { - fFailedTest= failedTest; - fThrownException= thrownException; - } - /** - * Gets the failed test. - */ - public Test failedTest() { - return fFailedTest; - } - /** - * Gets the thrown exception. - */ - public Throwable thrownException() { - return fThrownException; - } - /** - * Returns a short description of the failure. - */ - public String toString() { - StringBuffer buffer= new StringBuffer(); - buffer.append(fFailedTest+": "+fThrownException.getMessage()); - return buffer.toString(); - } - public String trace() { - StringWriter stringWriter= new StringWriter(); - PrintWriter writer= new PrintWriter(stringWriter); - thrownException().printStackTrace(writer); - StringBuffer buffer= stringWriter.getBuffer(); - return buffer.toString(); - } - public String exceptionMessage() { - return thrownException().getMessage(); - } - public boolean isFailure() { - return thrownException() instanceof AssertionFailedError; - } -} diff --git a/libcore/junit/src/main/java/junit/framework/TestListener.java b/libcore/junit/src/main/java/junit/framework/TestListener.java deleted file mode 100644 index 3ef3e334a..000000000 --- a/libcore/junit/src/main/java/junit/framework/TestListener.java +++ /dev/null @@ -1,23 +0,0 @@ -package junit.framework; - -/** - * A Listener for test progress - */ -public interface TestListener { - /** - * An error occurred. - */ - public void addError(Test test, Throwable t); - /** - * A failure occurred. - */ - public void addFailure(Test test, AssertionFailedError t); - /** - * A test ended. - */ - public void endTest(Test test); - /** - * A test started. - */ - public void startTest(Test test); -} diff --git a/libcore/junit/src/main/java/junit/framework/TestResult.java b/libcore/junit/src/main/java/junit/framework/TestResult.java deleted file mode 100644 index 153a77b08..000000000 --- a/libcore/junit/src/main/java/junit/framework/TestResult.java +++ /dev/null @@ -1,166 +0,0 @@ -package junit.framework; - -import java.util.Vector; -import java.util.Enumeration; - -/** - * A TestResult collects the results of executing - * a test case. It is an instance of the Collecting Parameter pattern. - * The test framework distinguishes between failures and errors. - * A failure is anticipated and checked for with assertions. Errors are - * unanticipated problems like an ArrayIndexOutOfBoundsException. - * - * @see Test - */ -public class TestResult extends Object { - protected Vector fFailures; - protected Vector fErrors; - protected Vector fListeners; - protected int fRunTests; - private boolean fStop; - - public TestResult() { - fFailures= new Vector(); - fErrors= new Vector(); - fListeners= new Vector(); - fRunTests= 0; - fStop= false; - } - /** - * Adds an error to the list of errors. The passed in exception - * caused the error. - */ - public synchronized void addError(Test test, Throwable t) { - fErrors.addElement(new TestFailure(test, t)); - for (Enumeration e= cloneListeners().elements(); e.hasMoreElements(); ) { - ((TestListener)e.nextElement()).addError(test, t); - } - } - /** - * Adds a failure to the list of failures. The passed in exception - * caused the failure. - */ - public synchronized void addFailure(Test test, AssertionFailedError t) { - fFailures.addElement(new TestFailure(test, t)); - for (Enumeration e= cloneListeners().elements(); e.hasMoreElements(); ) { - ((TestListener)e.nextElement()).addFailure(test, t); - } - } - /** - * Registers a TestListener - */ - public synchronized void addListener(TestListener listener) { - fListeners.addElement(listener); - } - /** - * Unregisters a TestListener - */ - public synchronized void removeListener(TestListener listener) { - fListeners.removeElement(listener); - } - /** - * Returns a copy of the listeners. - */ - private synchronized Vector cloneListeners() { - return (Vector)fListeners.clone(); - } - /** - * Informs the result that a test was completed. - */ - public void endTest(Test test) { - for (Enumeration e= cloneListeners().elements(); e.hasMoreElements(); ) { - ((TestListener)e.nextElement()).endTest(test); - } - } - /** - * Gets the number of detected errors. - */ - public synchronized int errorCount() { - return fErrors.size(); - } - /** - * Returns an Enumeration for the errors - */ - public synchronized Enumeration errors() { - return fErrors.elements(); - } - /** - * Gets the number of detected failures. - */ - public synchronized int failureCount() { - return fFailures.size(); - } - /** - * Returns an Enumeration for the failures - */ - public synchronized Enumeration failures() { - return fFailures.elements(); - } - /** - * Runs a TestCase. - */ - protected void run(final TestCase test) { - startTest(test); - Protectable p= new Protectable() { - public void protect() throws Throwable { - test.runBare(); - } - }; - runProtected(test, p); - - endTest(test); - } - /** - * Gets the number of run tests. - */ - public synchronized int runCount() { - return fRunTests; - } - /** - * Runs a TestCase. - */ - public void runProtected(final Test test, Protectable p) { - try { - p.protect(); - } - catch (AssertionFailedError e) { - addFailure(test, e); - } - catch (ThreadDeath e) { // don't catch ThreadDeath by accident - throw e; - } - catch (Throwable e) { - addError(test, e); - } - } - /** - * Checks whether the test run should stop - */ - public synchronized boolean shouldStop() { - return fStop; - } - /** - * Informs the result that a test will be started. - */ - public void startTest(Test test) { - final int count= test.countTestCases(); - synchronized(this) { - fRunTests+= count; - } - for (Enumeration e= cloneListeners().elements(); e.hasMoreElements(); ) { - ((TestListener)e.nextElement()).startTest(test); - } - } - /** - * Marks that the test run should stop. - */ - public synchronized void stop() { - fStop= true; - } - /** - * Returns whether the entire test was successful or not. - */ - public synchronized boolean wasSuccessful() { - return failureCount() == 0 && errorCount() == 0; - } -} diff --git a/libcore/junit/src/main/java/junit/framework/TestSuite.java b/libcore/junit/src/main/java/junit/framework/TestSuite.java deleted file mode 100644 index bf231981d..000000000 --- a/libcore/junit/src/main/java/junit/framework/TestSuite.java +++ /dev/null @@ -1,267 +0,0 @@ -package junit.framework; - -import java.util.Vector; -import java.util.Enumeration; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.lang.reflect.*; -import java.lang.reflect.Constructor; - -/** - * A TestSuite is a Composite of Tests. - * It runs a collection of test cases. Here is an example using - * the dynamic test definition. - *
- * TestSuite suite= new TestSuite();
- * suite.addTest(new MathTest("testAdd"));
- * suite.addTest(new MathTest("testDivideByZero"));
- * 
- * Alternatively, a TestSuite can extract the tests to be run automatically. - * To do so you pass the class of your TestCase class to the - * TestSuite constructor. - *
- * TestSuite suite= new TestSuite(MathTest.class);
- * 
- * This constructor creates a suite with all the methods - * starting with "test" that take no arguments. - * - * @see Test - */ -public class TestSuite implements Test { - - private Vector fTests= new Vector(10); - private String fName; - - /** - * Constructs an empty TestSuite. - */ - public TestSuite() { - } - - /** - * Constructs a TestSuite from the given class with the given name. - * @see TestSuite#TestSuite(Class) - */ - public TestSuite(Class theClass, String name) { - this(theClass); - setName(name); - } - - /** - * Constructs a TestSuite from the given class. Adds all the methods - * starting with "test" as test cases to the suite. - * Parts of this method was written at 2337 meters in the Huffihutte, - * Kanton Uri - */ - public TestSuite(final Class theClass) { - fName= theClass.getName(); - try { - getTestConstructor(theClass); // Avoid generating multiple error messages - } catch (NoSuchMethodException e) { - addTest(warning("Class "+theClass.getName()+" has no public constructor TestCase(String name) or TestCase()")); - return; - } - - if (!Modifier.isPublic(theClass.getModifiers())) { - addTest(warning("Class "+theClass.getName()+" is not public")); - return; - } - - Class superClass= theClass; - Vector names= new Vector(); - while (Test.class.isAssignableFrom(superClass)) { - Method[] methods= superClass.getDeclaredMethods(); - for (int i= 0; i < methods.length; i++) { - addTestMethod(methods[i], names, theClass); - } - superClass= superClass.getSuperclass(); - } - if (fTests.size() == 0) - addTest(warning("No tests found in "+theClass.getName())); - } - - /** - * Constructs an empty TestSuite. - */ - public TestSuite(String name) { - setName(name); - } - - /** - * Adds a test to the suite. - */ - public void addTest(Test test) { - fTests.addElement(test); - } - - /** - * Adds the tests from the given class to the suite - */ - public void addTestSuite(Class testClass) { - addTest(new TestSuite(testClass)); - } - - private void addTestMethod(Method m, Vector names, Class theClass) { - String name= m.getName(); - if (names.contains(name)) - return; - if (! isPublicTestMethod(m)) { - if (isTestMethod(m)) - addTest(warning("Test method isn't public: "+m.getName())); - return; - } - names.addElement(name); - addTest(createTest(theClass, name)); - } - - /** - * ...as the moon sets over the early morning Merlin, Oregon - * mountains, our intrepid adventurers type... - */ - static public Test createTest(Class theClass, String name) { - Constructor constructor; - try { - constructor= getTestConstructor(theClass); - } catch (NoSuchMethodException e) { - return warning("Class "+theClass.getName()+" has no public constructor TestCase(String name) or TestCase()"); - } - Object test; - try { - if (constructor.getParameterTypes().length == 0) { - test= constructor.newInstance(new Object[0]); - if (test instanceof TestCase) - ((TestCase) test).setName(name); - } else { - test= constructor.newInstance(new Object[]{name}); - } - } catch (InstantiationException e) { - return(warning("Cannot instantiate test case: "+name+" ("+exceptionToString(e)+")")); - } catch (InvocationTargetException e) { - return(warning("Exception in constructor: "+name+" ("+exceptionToString(e.getTargetException())+")")); - } catch (IllegalAccessException e) { - return(warning("Cannot access test case: "+name+" ("+exceptionToString(e)+")")); - } - return (Test) test; - } - - /** - * Converts the stack trace into a string - */ - private static String exceptionToString(Throwable t) { - StringWriter stringWriter= new StringWriter(); - PrintWriter writer= new PrintWriter(stringWriter); - t.printStackTrace(writer); - return stringWriter.toString(); - - } - - /** - * Counts the number of test cases that will be run by this test. - */ - public int countTestCases() { - int count= 0; - for (Enumeration e= tests(); e.hasMoreElements(); ) { - Test test= (Test)e.nextElement(); - count= count + test.countTestCases(); - } - return count; - } - - /** - * Gets a constructor which takes a single String as - * its argument or a no arg constructor. - */ - public static Constructor getTestConstructor(Class theClass) throws NoSuchMethodException { - Class[] args= { String.class }; - try { - return theClass.getConstructor(args); - } catch (NoSuchMethodException e) { - // fall through - } - return theClass.getConstructor(new Class[0]); - } - - private boolean isPublicTestMethod(Method m) { - return isTestMethod(m) && Modifier.isPublic(m.getModifiers()); - } - - private boolean isTestMethod(Method m) { - String name= m.getName(); - Class[] parameters= m.getParameterTypes(); - Class returnType= m.getReturnType(); - return parameters.length == 0 && name.startsWith("test") && returnType.equals(Void.TYPE); - } - - /** - * Runs the tests and collects their result in a TestResult. - */ - public void run(TestResult result) { - for (Enumeration e= tests(); e.hasMoreElements(); ) { - if (result.shouldStop() ) - break; - Test test= (Test)e.nextElement(); - runTest(test, result); - } - } - - public void runTest(Test test, TestResult result) { - test.run(result); - } - - /** - * Returns the test at the given index - */ - public Test testAt(int index) { - return (Test)fTests.elementAt(index); - } - - /** - * Returns the number of tests in this suite - */ - public int testCount() { - return fTests.size(); - } - - /** - * Returns the tests as an enumeration - */ - public Enumeration tests() { - return fTests.elements(); - } - - /** - */ - public String toString() { - if (getName() != null) - return getName(); - return super.toString(); - } - - /** - * Sets the name of the suite. - * @param name The name to set - */ - public void setName(String name) { - fName= name; - } - - /** - * Returns the name of the suite. Not all - * test suites have a name and this method - * can return null. - */ - public String getName() { - return fName; - } - - /** - * Returns a test which will fail and log a warning message. - */ - private static Test warning(final String message) { - return new TestCase("warning") { - protected void runTest() { - fail(message); - } - }; - } -} diff --git a/libcore/junit/src/main/java/junit/framework/package.html b/libcore/junit/src/main/java/junit/framework/package.html deleted file mode 100644 index 770d470c9..000000000 --- a/libcore/junit/src/main/java/junit/framework/package.html +++ /dev/null @@ -1,5 +0,0 @@ - - -The junit test framework. - - diff --git a/libcore/logging/MODULE_LICENSE_APACHE2 b/libcore/logging/MODULE_LICENSE_APACHE2 deleted file mode 100644 index e69de29bb..000000000 diff --git a/libcore/logging/src/main/java/java/util/logging/ConsoleHandler.java b/libcore/logging/src/main/java/java/util/logging/ConsoleHandler.java deleted file mode 100644 index ef365ca4d..000000000 --- a/libcore/logging/src/main/java/java/util/logging/ConsoleHandler.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.logging; - -/** - * A handler that writes log messages to the standard output stream - * {@code System.err}. - *

- * This handler reads the following properties from the log manager to - * initialize itself: - *

    - *
  • java.util.logging.ConsoleHandler.level specifies the logging level, - * defaults to {@code Level.INFO} if this property is not found or has an - * invalid value. - *
  • java.util.logging.ConsoleHandler.filter specifies the name of the filter - * class to be associated with this handler, defaults to {@code null} if this - * property is not found or has an invalid value. - *
  • java.util.logging.ConsoleHandler.formatter specifies the name of the - * formatter class to be associated with this handler, defaults to - * {@code java.util.logging.SimpleFormatter} if this property is not found or - * has an invalid value. - *
  • java.util.logging.ConsoleHandler.encoding specifies the encoding this - * handler will use to encode log messages, defaults to {@code null} if this - * property is not found or has an invalid value. - *
- *

- * This class is not thread-safe. - */ -public class ConsoleHandler extends StreamHandler { - - /** - * Constructs a {@code ConsoleHandler} object. - */ - public ConsoleHandler() { - super(System.err); - } - - /** - * Closes this handler. The {@code System.err} is flushed but not closed. - */ - @Override - public void close() { - super.close(false); - } - - /** - * Logs a record if necessary. A flush operation will be done. - * - * @param record - * the log record to be logged. - */ - @Override - public void publish(LogRecord record) { - super.publish(record); - super.flush(); - } -} diff --git a/libcore/logging/src/main/java/java/util/logging/ErrorManager.java b/libcore/logging/src/main/java/java/util/logging/ErrorManager.java deleted file mode 100644 index 708ddfa75..000000000 --- a/libcore/logging/src/main/java/java/util/logging/ErrorManager.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.logging; - -import org.apache.harmony.logging.internal.nls.Messages; - -/** - * An error reporting facility for {@link Handler} implementations to record any - * error that may happen during logging. {@code Handlers} should report errors - * to an {@code ErrorManager}, instead of throwing exceptions, which would - * interfere with the log issuer's execution. - */ -public class ErrorManager { - - /** - * The error code indicating a failure that does not fit in any of the - * specific types of failures that follow. - */ - public static final int GENERIC_FAILURE = 0; - - /** - * The error code indicating a failure when writing to an output stream. - */ - public static final int WRITE_FAILURE = 1; - - /** - * The error code indicating a failure when flushing an output stream. - */ - public static final int FLUSH_FAILURE = 2; - - /** - * The error code indicating a failure when closing an output stream. - */ - public static final int CLOSE_FAILURE = 3; - - /** - * The error code indicating a failure when opening an output stream. - */ - public static final int OPEN_FAILURE = 4; - - /** - * The error code indicating a failure when formatting the error messages. - */ - public static final int FORMAT_FAILURE = 5; - - @SuppressWarnings("nls") - private static final String[] FAILURES = new String[] { "GENERIC_FAILURE", - "WRITE_FAILURE", "FLUSH_FAILURE", "CLOSE_FAILURE", "OPEN_FAILURE", - "FORMAT_FAILURE" }; - - /** - * An indicator for determining if the error manager has been called at - * least once before. - */ - private boolean called; - - /** - * Constructs an instance of {@code ErrorManager}. - */ - public ErrorManager() { - super(); - } - - /** - * Reports an error using the given message, exception and error code. This - * implementation will write out the message to {@link System#err} on the - * first call and all subsequent calls are ignored. A subclass of this class - * should override this method. - * - * @param message - * the error message, which may be {@code null}. - * @param exception - * the exception associated with the error, which may be - * {@code null}. - * @param errorCode - * the error code that identifies the type of error; see the - * constant fields of this class for possible values. - */ - public void error(String message, Exception exception, int errorCode) { - synchronized (this) { - if (called) { - return; - } - called = true; - } - System.err.println(this.getClass().getName() - + ": " + FAILURES[errorCode]); //$NON-NLS-1$ - if (message != null) { - // logging.1E=Error message - {0} - System.err.println(Messages.getString("logging.1E", message)); //$NON-NLS-1$ - } - if (exception != null) { - // logging.1F=Exception - {0} - System.err.println(Messages.getString("logging.1F", exception)); //$NON-NLS-1$ - } - } -} diff --git a/libcore/logging/src/main/java/java/util/logging/FileHandler.java b/libcore/logging/src/main/java/java/util/logging/FileHandler.java deleted file mode 100644 index e1eba9ea5..000000000 --- a/libcore/logging/src/main/java/java/util/logging/FileHandler.java +++ /dev/null @@ -1,643 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.logging; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.nio.channels.FileChannel; -import java.nio.channels.FileLock; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.Hashtable; - -import org.apache.harmony.logging.internal.nls.Messages; - -/** - * A {@code FileHandler} writes logging records into a specified file or a - * rotating set of files. - *

- * When a set of files is used and a given amount of data has been written to - * one file, then this file is closed and another file is opened. The name of - * these files are generated by given name pattern, see below for details. - * When the files have all been filled the Handler returns to the first and goes - * through the set again. - *

- * By default, the I/O buffering mechanism is enabled, but when each log record - * is complete, it is flushed out. - *

- * {@code XMLFormatter} is the default formatter for {@code FileHandler}. - *

- * {@code FileHandler} reads the following {@code LogManager} properties for - * initialization; if a property is not defined or has an invalid value, a - * default value is used. - *

    - *
  • java.util.logging.FileHandler.append specifies whether this - * {@code FileHandler} should append onto existing files, defaults to - * {@code false}.
  • - *
  • java.util.logging.FileHandler.count specifies how many output files to - * rotate, defaults to 1.
  • - *
  • java.util.logging.FileHandler.filter specifies the {@code Filter} class - * name, defaults to no {@code Filter}.
  • - *
  • java.util.logging.FileHandler.formatter specifies the {@code Formatter} - * class, defaults to {@code java.util.logging.XMLFormatter}.
  • - *
  • java.util.logging.FileHandler.encoding specifies the character set - * encoding name, defaults to the default platform encoding.
  • - *
  • java.util.logging.FileHandler.level specifies the level for this - * {@code Handler}, defaults to {@code Level.ALL}.
  • - *
  • java.util.logging.FileHandler.limit specifies the maximum number of - * bytes to write to any one file, defaults to zero, which means no limit.
  • - *
  • java.util.logging.FileHandler.pattern specifies name pattern for the - * output files. See below for details. Defaults to "%h/java%u.log".
  • - *
- *

- * Name pattern is a string that may include some special substrings, which will - * be replaced to generate output files: - *

    - *
  • "/" represents the local pathname separator
  • - *
  • "%g" represents the generation number to distinguish rotated logs
  • - *
  • "%h" represents the home directory of the current user, which is - * specified by "user.home" system property
  • - *
  • "%t" represents the system's temporary directory
  • - *
  • "%u" represents a unique number to resolve conflicts
  • - *
  • "%%" represents the percent sign character '%'
  • - *
- *

- * Normally, the generation numbers are not larger than the given file count and - * follow the sequence 0, 1, 2.... If the file count is larger than one, but the - * generation field("%g") has not been specified in the pattern, then the - * generation number after a dot will be added to the end of the file name. - *

- * The "%u" unique field is used to avoid conflicts and is set to 0 at first. If - * one {@code FileHandler} tries to open the filename which is currently in use - * by another process, it will repeatedly increment the unique number field and - * try again. If the "%u" component has not been included in the file name - * pattern and some contention on a file does occur, then a unique numerical - * value will be added to the end of the filename in question immediately to the - * right of a dot. The generation of unique IDs for avoiding conflicts is only - * guaranteed to work reliably when using a local disk file system. - */ -public class FileHandler extends StreamHandler { - - private static final String LCK_EXT = ".lck"; //$NON-NLS-1$ - - private static final int DEFAULT_COUNT = 1; - - private static final int DEFAULT_LIMIT = 0; - - private static final boolean DEFAULT_APPEND = false; - - private static final String DEFAULT_PATTERN = "%h/java%u.log"; //$NON-NLS-1$ - - // maintain all file locks hold by this process - private static final Hashtable allLocks = new Hashtable(); - - // the count of files which the output cycle through - private int count; - - // the size limitation in byte of log file - private int limit; - - // whether the FileHandler should open a existing file for output in append - // mode - private boolean append; - - // the pattern for output file name - private String pattern; - - // maintain a LogManager instance for convenience - private LogManager manager; - - // output stream, which can measure the output file length - private MeasureOutputStream output; - - // used output file - private File[] files; - - // output file lock - FileLock lock = null; - - // current output file name - String fileName = null; - - // current unique ID - int uniqueID = -1; - - /** - * Construct a {@code FileHandler} using {@code LogManager} properties or - * their default value. - * - * @throws IOException - * if any I/O error occurs. - * @throws SecurityException - * if a security manager exists and it determines that the - * caller does not have the required permissions to control this - * handler; required permissions include - * {@code LogPermission("control")}, - * {@code FilePermission("write")} etc. - */ - public FileHandler() throws IOException { - init(null, null, null, null); - } - - // init properties - private void init(String p, Boolean a, Integer l, Integer c) - throws IOException { - // check access - manager = LogManager.getLogManager(); - manager.checkAccess(); - initProperties(p, a, l, c); - initOutputFiles(); - } - - private void initOutputFiles() throws FileNotFoundException, IOException { - while (true) { - // try to find a unique file which is not locked by other process - uniqueID++; - // FIXME: improve performance here - for (int generation = 0; generation < count; generation++) { - // cache all file names for rotation use - files[generation] = new File(parseFileName(generation)); - } - fileName = files[0].getAbsolutePath(); - synchronized (allLocks) { - /* - * if current process has held lock for this fileName continue - * to find next file - */ - if (null != allLocks.get(fileName)) { - continue; - } - if (files[0].exists() - && (!append || files[0].length() >= limit)) { - for (int i = count - 1; i > 0; i--) { - if (files[i].exists()) { - files[i].delete(); - } - files[i - 1].renameTo(files[i]); - } - } - FileOutputStream fileStream = new FileOutputStream(fileName - + LCK_EXT); - FileChannel channel = fileStream.getChannel(); - /* - * if lock is unsupported and IOException thrown, just let the - * IOException throws out and exit otherwise it will go into an - * undead cycle - */ - lock = channel.tryLock(); - if (null == lock) { - try { - fileStream.close(); - } catch (Exception e) { - // ignore - } - continue; - } - allLocks.put(fileName, lock); - break; - } - } - // BEGIN android-modified - output = new MeasureOutputStream( - new BufferedOutputStream( - new FileOutputStream(fileName, append), 8192), - files[0].length()); - // END android-modified - setOutputStream(output); - } - - @SuppressWarnings("nls") - private void initProperties(String p, Boolean a, Integer l, Integer c) { - super.initProperties("ALL", null, "java.util.logging.XMLFormatter", - null); - String className = this.getClass().getName(); - pattern = (null == p) ? getStringProperty(className + ".pattern", - DEFAULT_PATTERN) : p; - if (null == pattern || "".equals(pattern)) { - // logging.19=Pattern cannot be empty - throw new NullPointerException(Messages.getString("logging.19")); - } - append = (null == a) ? getBooleanProperty(className + ".append", - DEFAULT_APPEND) : a.booleanValue(); - count = (null == c) ? getIntProperty(className + ".count", - DEFAULT_COUNT) : c.intValue(); - limit = (null == l) ? getIntProperty(className + ".limit", - DEFAULT_LIMIT) : l.intValue(); - count = count < 1 ? DEFAULT_COUNT : count; - limit = limit < 0 ? DEFAULT_LIMIT : limit; - files = new File[count]; - } - - void findNextGeneration() { - super.close(); - for (int i = count - 1; i > 0; i--) { - if (files[i].exists()) { - files[i].delete(); - } - files[i - 1].renameTo(files[i]); - } - try { - // BEGIN android-modified - output = new MeasureOutputStream( - new BufferedOutputStream( - new FileOutputStream(files[0]), - 8192)); - // END android-modified - } catch (FileNotFoundException e1) { - // logging.1A=Error happened when open log file. - this.getErrorManager().error(Messages.getString("logging.1A"), //$NON-NLS-1$ - e1, ErrorManager.OPEN_FAILURE); - } - setOutputStream(output); - } - - /** - * Transform the pattern to the valid file name, replacing any patterns, and - * applying generation and uniqueID if present. - * - * @param gen - * generation of this file - * @return transformed filename ready for use. - */ - private String parseFileName(int gen) { - int cur = 0; - int next = 0; - boolean hasUniqueID = false; - boolean hasGeneration = false; - - // TODO privilege code? - - String tempPath = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$ - boolean tempPathHasSepEnd = (tempPath == null ? false : tempPath - .endsWith(File.separator)); - - String homePath = System.getProperty("user.home"); //$NON-NLS-1$ - boolean homePathHasSepEnd = (homePath == null ? false : homePath - .endsWith(File.separator)); - - StringBuilder sb = new StringBuilder(); - pattern = pattern.replace('/', File.separatorChar); - - char[] value = pattern.toCharArray(); - while ((next = pattern.indexOf('%', cur)) >= 0) { - if (++next < pattern.length()) { - switch (value[next]) { - case 'g': - sb.append(value, cur, next - cur - 1).append(gen); - hasGeneration = true; - break; - case 'u': - sb.append(value, cur, next - cur - 1).append(uniqueID); - hasUniqueID = true; - break; - case 't': - /* - * we should probably try to do something cute here like - * lookahead for adjacent '/' - */ - sb.append(value, cur, next - cur - 1).append(tempPath); - if (!tempPathHasSepEnd) { - sb.append(File.separator); - } - break; - case 'h': - sb.append(value, cur, next - cur - 1).append(homePath); - if (!homePathHasSepEnd) { - sb.append(File.separator); - } - break; - case '%': - sb.append(value, cur, next - cur - 1).append('%'); - break; - default: - sb.append(value, cur, next - cur); - } - cur = ++next; - } else { - // fail silently - } - } - - sb.append(value, cur, value.length - cur); - - if (!hasGeneration && count > 1) { - sb.append(".").append(gen); //$NON-NLS-1$ - } - - if (!hasUniqueID && uniqueID > 0) { - sb.append(".").append(uniqueID); //$NON-NLS-1$ - } - - return sb.toString(); - } - - // get boolean LogManager property, if invalid value got, using default - // value - private boolean getBooleanProperty(String key, boolean defaultValue) { - String property = manager.getProperty(key); - if (null == property) { - return defaultValue; - } - boolean result = defaultValue; - if ("true".equalsIgnoreCase(property)) { //$NON-NLS-1$ - result = true; - } else if ("false".equalsIgnoreCase(property)) { //$NON-NLS-1$ - result = false; - } - return result; - } - - // get String LogManager property, if invalid value got, using default value - private String getStringProperty(String key, String defaultValue) { - String property = manager.getProperty(key); - return property == null ? defaultValue : property; - } - - // get int LogManager property, if invalid value got, using default value - private int getIntProperty(String key, int defaultValue) { - String property = manager.getProperty(key); - int result = defaultValue; - if (null != property) { - try { - result = Integer.parseInt(property); - } catch (Exception e) { - // ignore - } - } - return result; - } - - /** - * Constructs a new {@code FileHandler}. The given name pattern is used as - * output filename, the file limit is set to zero (no limit), the file count - * is set to one; the remaining configuration is done using - * {@code LogManager} properties or their default values. This handler - * writes to only one file with no size limit. - * - * @param pattern - * the name pattern for the output file. - * @throws IOException - * if any I/O error occurs. - * @throws SecurityException - * if a security manager exists and it determines that the - * caller does not have the required permissions to control this - * handler; required permissions include - * {@code LogPermission("control")}, - * {@code FilePermission("write")} etc. - * @throws IllegalArgumentException - * if the pattern is empty. - * @throws NullPointerException - * if the pattern is {@code null}. - */ - public FileHandler(String pattern) throws IOException { - if (pattern.equals("")) { //$NON-NLS-1$ - // logging.19=Pattern cannot be empty - throw new IllegalArgumentException(Messages.getString("logging.19")); //$NON-NLS-1$ - } - init(pattern, null, Integer.valueOf(DEFAULT_LIMIT), Integer - .valueOf(DEFAULT_COUNT)); - } - - /** - * Construct a new {@code FileHandler}. The given name pattern is used as - * output filename, the file limit is set to zero (no limit), the file count - * is initialized to one and the value of {@code append} becomes the new - * instance's append mode. The remaining configuration is done using - * {@code LogManager} properties. This handler writes to only one file - * with no size limit. - * - * @param pattern - * the name pattern for the output file. - * @param append - * the append mode. - * @throws IOException - * if any I/O error occurs. - * @throws SecurityException - * if a security manager exists and it determines that the - * caller does not have the required permissions to control this - * handler; required permissions include - * {@code LogPermission("control")}, - * {@code FilePermission("write")} etc. - * @throws IllegalArgumentException - * if {@code pattern} is empty. - * @throws NullPointerException - * if {@code pattern} is {@code null}. - */ - public FileHandler(String pattern, boolean append) throws IOException { - if (pattern.equals("")) { //$NON-NLS-1$ - throw new IllegalArgumentException(Messages.getString("logging.19")); //$NON-NLS-1$ - } - - init(pattern, Boolean.valueOf(append), Integer.valueOf(DEFAULT_LIMIT), - Integer.valueOf(DEFAULT_COUNT)); - } - - /** - * Construct a new {@code FileHandler}. The given name pattern is used as - * output filename, the maximum file size is set to {@code limit} and the - * file count is initialized to {@code count}. The remaining configuration - * is done using {@code LogManager} properties. This handler is configured - * to write to a rotating set of count files, when the limit of bytes has - * been written to one output file, another file will be opened instead. - * - * @param pattern - * the name pattern for the output file. - * @param limit - * the data amount limit in bytes of one output file, can not be - * negative. - * @param count - * the maximum number of files to use, can not be less than one. - * @throws IOException - * if any I/O error occurs. - * @throws SecurityException - * if a security manager exists and it determines that the - * caller does not have the required permissions to control this - * handler; required permissions include - * {@code LogPermission("control")}, - * {@code FilePermission("write")} etc. - * @throws IllegalArgumentException - * if {@code pattern} is empty, {@code limit < 0} or - * {@code count < 1}. - * @throws NullPointerException - * if {@code pattern} is {@code null}. - */ - public FileHandler(String pattern, int limit, int count) throws IOException { - if (pattern.equals("")) { //$NON-NLS-1$ - throw new IllegalArgumentException(Messages.getString("logging.19")); //$NON-NLS-1$ - } - if (limit < 0 || count < 1) { - // logging.1B=The limit and count property must be larger than 0 and - // 1, respectively - throw new IllegalArgumentException(Messages.getString("logging.1B")); //$NON-NLS-1$ - } - init(pattern, null, Integer.valueOf(limit), Integer.valueOf(count)); - } - - /** - * Construct a new {@code FileHandler}. The given name pattern is used as - * output filename, the maximum file size is set to {@code limit}, the file - * count is initialized to {@code count} and the append mode is set to - * {@code append}. The remaining configuration is done using - * {@code LogManager} properties. This handler is configured to write to a - * rotating set of count files, when the limit of bytes has been written to - * one output file, another file will be opened instead. - * - * @param pattern - * the name pattern for the output file. - * @param limit - * the data amount limit in bytes of one output file, can not be - * negative. - * @param count - * the maximum number of files to use, can not be less than one. - * @param append - * the append mode. - * @throws IOException - * if any I/O error occurs. - * @throws SecurityException - * if a security manager exists and it determines that the - * caller does not have the required permissions to control this - * handler; required permissions include - * {@code LogPermission("control")}, - * {@code FilePermission("write")} etc. - * @throws IllegalArgumentException - * if {@code pattern} is empty, {@code limit < 0} or - * {@code count < 1}. - * @throws NullPointerException - * if {@code pattern} is {@code null}. - */ - public FileHandler(String pattern, int limit, int count, boolean append) - throws IOException { - if (pattern.equals("")) { //$NON-NLS-1$ - throw new IllegalArgumentException(Messages.getString("logging.19")); //$NON-NLS-1$ - } - if (limit < 0 || count < 1) { - // logging.1B=The limit and count property must be larger than 0 and - // 1, respectively - throw new IllegalArgumentException(Messages.getString("logging.1B")); //$NON-NLS-1$ - } - init(pattern, Boolean.valueOf(append), Integer.valueOf(limit), Integer - .valueOf(count)); - } - - /** - * Flushes and closes all opened files. - * - * @throws SecurityException - * if a security manager exists and it determines that the - * caller does not have the required permissions to control this - * handler; required permissions include - * {@code LogPermission("control")}, - * {@code FilePermission("write")} etc. - */ - @Override - public void close() { - // release locks - super.close(); - allLocks.remove(fileName); - try { - FileChannel channel = lock.channel(); - lock.release(); - channel.close(); - File file = new File(fileName + LCK_EXT); - file.delete(); - } catch (IOException e) { - // ignore - } - } - - /** - * Publish a {@code LogRecord}. - * - * @param record - * the log record to publish. - */ - @Override - public void publish(LogRecord record) { - super.publish(record); - flush(); - if (limit > 0 && output.getLength() >= limit) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - findNextGeneration(); - return null; - } - }); - } - } - - /** - * This output stream uses the decorator pattern to add measurement features - * to OutputStream which can detect the total size(in bytes) of output, the - * initial size can be set. - */ - static class MeasureOutputStream extends OutputStream { - - OutputStream wrapped; - - long length; - - public MeasureOutputStream(OutputStream stream, long currentLength) { - wrapped = stream; - length = currentLength; - } - - public MeasureOutputStream(OutputStream stream) { - this(stream, 0); - } - - @Override - public void write(int oneByte) throws IOException { - wrapped.write(oneByte); - length++; - } - - @Override - public void write(byte[] bytes) throws IOException { - wrapped.write(bytes); - length += bytes.length; - } - - @Override - public void write(byte[] b, int off, int len) throws IOException { - wrapped.write(b, off, len); - length += len; - } - - @Override - public void close() throws IOException { - wrapped.close(); - } - - @Override - public void flush() throws IOException { - wrapped.flush(); - } - - public long getLength() { - return length; - } - - public void setLength(long newLength) { - length = newLength; - } - } -} diff --git a/libcore/logging/src/main/java/java/util/logging/Filter.java b/libcore/logging/src/main/java/java/util/logging/Filter.java deleted file mode 100644 index f5dbd9fed..000000000 --- a/libcore/logging/src/main/java/java/util/logging/Filter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.logging; - -/** - * A {@code Filter} provides a mechanism for exercising fine-grained control - * over which records get logged. - */ -public interface Filter { - - /** - * Checks {@code record} to determine if it should be logged. - * - * @param record - * the {@link LogRecord} to be checked. - * @return {@code true} if the supplied log record needs to be logged, - * {@code false} otherwise. - */ - boolean isLoggable(LogRecord record); -} diff --git a/libcore/logging/src/main/java/java/util/logging/Formatter.java b/libcore/logging/src/main/java/java/util/logging/Formatter.java deleted file mode 100644 index f9b0d25b5..000000000 --- a/libcore/logging/src/main/java/java/util/logging/Formatter.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.logging; - -import java.text.MessageFormat; -import java.util.ResourceBundle; - -/** - * {@code Formatter} objects are used to format {@link LogRecord} objects into a - * string representation. Head and tail strings are sometimes used to wrap a set - * of records. The {@code getHead} and {@code getTail} methods are used for this - * purpose. - */ -public abstract class Formatter { - - /** - * Constructs a {@code Formatter} object. - */ - protected Formatter() { - super(); - } - - /** - * Converts a {@link LogRecord} object into a string representation. The - * resulted string is usually localized and includes the message field of - * the record. - * - * @param r - * the log record to be formatted into a string. - * @return the formatted string. - */ - public abstract String format(LogRecord r); - - /** - * Formats a {@code LogRecord} object into a localized string - * representation. This is a convenience method for subclasses of {@code - * Formatter}. - *

- * The message string is firstly localized using the {@code ResourceBundle} - * object associated with the supplied {@code LogRecord}. - *

- * Notice : if message contains "{0", then java.text.MessageFormat is used. - * Otherwise no formatting is performed. - * - * @param r - * the log record to be formatted. - * @return the string resulted from the formatting. - */ - public String formatMessage(LogRecord r) { - String pattern = r.getMessage(); - ResourceBundle rb = null; - // try to localize the message string first - if (null != (rb = r.getResourceBundle())) { - try { - pattern = rb.getString(pattern); - } catch (Exception e) { - pattern = r.getMessage(); - } - } - if (null != pattern) { - Object[] params = r.getParameters(); - /* - * if the message contains "{0", use java.text.MessageFormat to - * format the string - */ - if (pattern.indexOf("{0") >= 0 && null != params //$NON-NLS-1$ - && params.length > 0) { - try { - pattern = MessageFormat.format(pattern, params); - } catch (IllegalArgumentException e) { - pattern = r.getMessage(); - } - } - } - return pattern; - } - - /** - * Gets the head string used to wrap a set of log records. This base class - * always returns an empty string. - * - * @param h - * the target handler. - * @return the head string used to wrap a set of log records, empty in this - * implementation. - */ - public String getHead(Handler h) { - return ""; //$NON-NLS-1$ - } - - /** - * Gets the tail string used to wrap a set of log records. This base class - * always returns the empty string. - * - * @param h - * the target handler. - * @return the tail string used to wrap a set of log records, empty in this - * implementation. - */ - public String getTail(Handler h) { - return ""; //$NON-NLS-1$ - } -} diff --git a/libcore/logging/src/main/java/java/util/logging/Handler.java b/libcore/logging/src/main/java/java/util/logging/Handler.java deleted file mode 100644 index a5b92a0c7..000000000 --- a/libcore/logging/src/main/java/java/util/logging/Handler.java +++ /dev/null @@ -1,407 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.logging; - -import java.io.UnsupportedEncodingException; -import java.nio.charset.Charset; -import java.security.AccessController; -import java.security.PrivilegedExceptionAction; - -import org.apache.harmony.logging.internal.nls.Messages; - -/** - * A {@code Handler} object accepts a logging request and exports the desired - * messages to a target, for example, a file, the console, etc. It can be - * disabled by setting its logging level to {@code Level.OFF}. - */ -public abstract class Handler { - - private static final Level DEFAULT_LEVEL = Level.ALL; - - // the error manager to report errors during logging - private ErrorManager errorMan; - - // the character encoding used by this handler - private String encoding; - - // the logging level - private Level level; - - // the formatter used to export messages - private Formatter formatter; - - // the filter used to filter undesired messages - private Filter filter; - - // class name, used for property reading - private String prefix; - - /** - * Constructs a {@code Handler} object with a default error manager instance - * {@code ErrorManager}, the default encoding, and the default logging - * level {@code Level.ALL}. It has no filter and no formatter. - */ - protected Handler() { - this.errorMan = new ErrorManager(); - this.level = DEFAULT_LEVEL; - this.encoding = null; - this.filter = null; - this.formatter = null; - this.prefix = this.getClass().getName(); - } - - // get a instance from given class name, using Class.forName() - private Object getDefaultInstance(String className) { - Object result = null; - if (null == className) { - return result; - } - try { - result = Class.forName(className).newInstance(); - } catch (Exception e) { - // ignore - } - return result; - } - - // get a instance from given class name, using context classloader - private Object getCustomizeInstance(final String className) - throws Exception { - Class c = AccessController - .doPrivileged(new PrivilegedExceptionAction>() { - public Class run() throws Exception { - ClassLoader loader = Thread.currentThread() - .getContextClassLoader(); - if (null == loader) { - loader = ClassLoader.getSystemClassLoader(); - } - return loader.loadClass(className); - } - }); - return c.newInstance(); - } - - // print error message in some format - void printInvalidPropMessage(String key, String value, Exception e) { - // logging.12=Invalid property value for - String msg = new StringBuilder().append( - Messages.getString("logging.12")) //$NON-NLS-1$ - .append(prefix).append(":").append(key).append("/").append( //$NON-NLS-1$//$NON-NLS-2$ - value).toString(); - errorMan.error(msg, e, ErrorManager.GENERIC_FAILURE); - } - - /** - * init the common properties, including filter, level, formatter, and - * encoding - */ - void initProperties(String defaultLevel, String defaultFilter, - String defaultFormatter, String defaultEncoding) { - LogManager manager = LogManager.getLogManager(); - - // set filter - final String filterName = manager.getProperty(prefix + ".filter"); //$NON-NLS-1$ - if (null != filterName) { - try { - filter = (Filter) getCustomizeInstance(filterName); - } catch (Exception e1) { - printInvalidPropMessage("filter", filterName, e1); //$NON-NLS-1$ - filter = (Filter) getDefaultInstance(defaultFilter); - } - } else { - filter = (Filter) getDefaultInstance(defaultFilter); - } - - // set level - String levelName = manager.getProperty(prefix + ".level"); //$NON-NLS-1$ - if (null != levelName) { - try { - level = Level.parse(levelName); - } catch (Exception e) { - printInvalidPropMessage("level", levelName, e); //$NON-NLS-1$ - level = Level.parse(defaultLevel); - } - } else { - level = Level.parse(defaultLevel); - } - - // set formatter - final String formatterName = manager.getProperty(prefix + ".formatter"); //$NON-NLS-1$ - if (null != formatterName) { - try { - formatter = (Formatter) getCustomizeInstance(formatterName); - } catch (Exception e) { - printInvalidPropMessage("formatter", formatterName, e); //$NON-NLS-1$ - formatter = (Formatter) getDefaultInstance(defaultFormatter); - } - } else { - formatter = (Formatter) getDefaultInstance(defaultFormatter); - } - - // set encoding - final String encodingName = manager.getProperty(prefix + ".encoding"); //$NON-NLS-1$ - try { - internalSetEncoding(encodingName); - } catch (UnsupportedEncodingException e) { - printInvalidPropMessage("encoding", encodingName, e); //$NON-NLS-1$ - } - } - - /** - * Closes this handler. A flush operation will be performed and all the - * associated resources will be freed. Client applications should not use - * this handler after closing it. - * - * @throws SecurityException - * if a security manager determines that the caller does not - * have the required permission. - */ - public abstract void close(); - - /** - * Flushes any buffered output. - */ - public abstract void flush(); - - /** - * Accepts a logging request and sends it to the the target. - * - * @param record - * the log record to be logged; {@code null} records are ignored. - */ - public abstract void publish(LogRecord record); - - /** - * Gets the character encoding used by this handler, {@code null} for - * default encoding. - * - * @return the character encoding used by this handler. - */ - public String getEncoding() { - return this.encoding; - } - - /** - * Gets the error manager used by this handler to report errors during - * logging. - * - * @return the error manager used by this handler. - * @throws SecurityException - * if a security manager determines that the caller does not - * have the required permission. - */ - public ErrorManager getErrorManager() { - LogManager.getLogManager().checkAccess(); - return this.errorMan; - } - - /** - * Gets the filter used by this handler. - * - * @return the filter used by this handler (possibly {@code null}). - */ - public Filter getFilter() { - return this.filter; - } - - /** - * Gets the formatter used by this handler to format the logging messages. - * - * @return the formatter used by this handler (possibly {@code null}). - */ - public Formatter getFormatter() { - return this.formatter; - } - - /** - * Gets the logging level of this handler, records with levels lower than - * this value will be dropped. - * - * @return the logging level of this handler. - */ - public Level getLevel() { - return this.level; - } - - /** - * Determines whether the supplied log record needs to be logged. The - * logging levels will be checked as well as the filter. - * - * @param record - * the log record to be checked. - * @return {@code true} if the supplied log record needs to be logged, - * otherwise {@code false}. - */ - public boolean isLoggable(LogRecord record) { - if (null == record) { - throw new NullPointerException(); - } - if (this.level.intValue() == Level.OFF.intValue()) { - return false; - } else if (record.getLevel().intValue() >= this.level.intValue()) { - return null == this.filter || this.filter.isLoggable(record); - } - return false; - } - - /** - * Reports an error to the error manager associated with this handler, - * {@code ErrorManager} is used for that purpose. No security checks are - * done, therefore this is compatible with environments where the caller - * is non-privileged. - * - * @param msg - * the error message, may be {@code null}. - * @param ex - * the associated exception, may be {@code null}. - * @param code - * an {@code ErrorManager} error code. - */ - protected void reportError(String msg, Exception ex, int code) { - this.errorMan.error(msg, ex, code); - } - - /** - * Sets the character encoding used by this handler. A {@code null} value - * indicates the use of the default encoding. This internal method does - * not check security. - * - * @param newEncoding - * the character encoding to set. - * @throws UnsupportedEncodingException - * if the specified encoding is not supported by the runtime. - */ - void internalSetEncoding(String newEncoding) - throws UnsupportedEncodingException { - // accepts "null" because it indicates using default encoding - if (null == newEncoding) { - this.encoding = null; - } else { - if (Charset.isSupported(newEncoding)) { - this.encoding = newEncoding; - } else { - // logging.13=The encoding "{0}" is not supported. - throw new UnsupportedEncodingException(Messages.getString( - "logging.13", //$NON-NLS-1$ - newEncoding)); - } - - } - } - - /** - * Sets the character encoding used by this handler, {@code null} indicates - * a default encoding. - * - * @param encoding - * the character encoding to set. - * @throws SecurityException - * if a security manager determines that the caller does not - * have the required permission. - * @throws UnsupportedEncodingException - * if the specified encoding is not supported by the runtime. - */ - public void setEncoding(String encoding) throws SecurityException, - UnsupportedEncodingException { - LogManager.getLogManager().checkAccess(); - internalSetEncoding(encoding); - } - - /** - * Sets the error manager for this handler. - * - * @param em - * the error manager to set. - * @throws NullPointerException - * if {@code em} is {@code null}. - * @throws SecurityException - * if a security manager determines that the caller does not - * have the required permission. - */ - public void setErrorManager(ErrorManager em) { - LogManager.getLogManager().checkAccess(); - if (null == em) { - throw new NullPointerException(); - } - this.errorMan = em; - } - - /** - * Sets the filter to be used by this handler. - * - * @param newFilter - * the filter to set, may be {@code null}. - * @throws SecurityException - * if a security manager determines that the caller does not - * have the required permission. - */ - public void setFilter(Filter newFilter) { - LogManager.getLogManager().checkAccess(); - this.filter = newFilter; - } - - /** - * Sets the formatter to be used by this handler. This internal method does - * not check security. - * - * @param newFormatter - * the formatter to set. - */ - void internalSetFormatter(Formatter newFormatter) { - if (null == newFormatter) { - throw new NullPointerException(); - } - this.formatter = newFormatter; - } - - /** - * Sets the formatter to be used by this handler. - * - * @param newFormatter - * the formatter to set. - * @throws NullPointerException - * if {@code newFormatter} is {@code null}. - * @throws SecurityException - * if a security manager determines that the caller does not - * have the required permission. - */ - public void setFormatter(Formatter newFormatter) { - LogManager.getLogManager().checkAccess(); - internalSetFormatter(newFormatter); - } - - /** - * Sets the logging level of the messages logged by this handler, levels - * lower than this value will be dropped. - * - * @param newLevel - * the logging level to set. - * @throws NullPointerException - * if {@code newLevel} is {@code null}. - * @throws SecurityException - * if a security manager determines that the caller does not - * have the required permission. - */ - public void setLevel(Level newLevel) { - if (null == newLevel) { - throw new NullPointerException(); - } - LogManager.getLogManager().checkAccess(); - this.level = newLevel; - } -} diff --git a/libcore/logging/src/main/java/java/util/logging/Level.java b/libcore/logging/src/main/java/java/util/logging/Level.java deleted file mode 100644 index f98812739..000000000 --- a/libcore/logging/src/main/java/java/util/logging/Level.java +++ /dev/null @@ -1,369 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.logging; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.apache.harmony.logging.internal.nls.Messages; -// BEGIN android-changed -import dalvik.system.VMStack; -// END android-changed - -/** - * {@code Level} objects are used to indicate the level of logging. There are a - * set of predefined logging levels, each associated with an integer value. - * Enabling a certain logging level also enables all logging levels with larger - * values. - *

- * The predefined levels in ascending order are FINEST, FINER, FINE, CONFIG, - * INFO, WARNING, SEVERE. There are two additional predefined levels, which are - * ALL and OFF. ALL indicates logging all messages, and OFF indicates logging no - * messages. - */ -public class Level implements Serializable { - - private static final long serialVersionUID = -8176160795706313070L; - - private static final List levels = new ArrayList(9); - - /** - * The OFF level provides no logging messages. - */ - public static final Level OFF = new Level("OFF", Integer.MAX_VALUE); //$NON-NLS-1$ - - /** - * The SEVERE level provides severe failure messages. - */ - public static final Level SEVERE = new Level("SEVERE", 1000); //$NON-NLS-1$ - - /** - * The WARNING level provides warnings. - */ - public static final Level WARNING = new Level("WARNING", 900); //$NON-NLS-1$ - - /** - * The INFO level provides informative messages. - */ - public static final Level INFO = new Level("INFO", 800); //$NON-NLS-1$ - - /** - * The CONFIG level provides static configuration messages. - */ - public static final Level CONFIG = new Level("CONFIG", 700); //$NON-NLS-1$ - - /** - * The FINE level provides tracing messages. - */ - public static final Level FINE = new Level("FINE", 500); //$NON-NLS-1$ - - /** - * The FINER level provides more detailed tracing messages. - */ - public static final Level FINER = new Level("FINER", 400); //$NON-NLS-1$ - - /** - * The FINEST level provides highly detailed tracing messages. - */ - public static final Level FINEST = new Level("FINEST", 300); //$NON-NLS-1$ - - /** - * The ALL level provides all logging messages. - */ - public static final Level ALL = new Level("ALL", Integer.MIN_VALUE); //$NON-NLS-1$ - - /** - * Parses a level name into a {@code Level} object. - * - * @param name - * the name of the desired {@code level}, which cannot be - * {@code null}. - * @return the level with the specified name. - * @throws NullPointerException - * if {@code name} is {@code null}. - * @throws IllegalArgumentException - * if {@code name} is not valid. - */ - public static Level parse(String name) throws IllegalArgumentException { - if (name == null) { - // logging.1C=The 'name' parameter is null. - throw new NullPointerException(Messages.getString("logging.1C")); //$NON-NLS-1$ - } - - boolean isNameAnInt; - int nameAsInt; - try { - nameAsInt = Integer.parseInt(name); - isNameAnInt = true; - } catch (NumberFormatException e) { - nameAsInt = 0; - isNameAnInt = false; - } - - synchronized (levels) { - for (Level level : levels) { - if (name.equals(level.getName())) { - return level; - } - } - - if (isNameAnInt) { - /* - * Loop through levels a second time, so that the returned - * instance will be passed on the order of construction. - */ - for (Level level : levels) { - if (nameAsInt == level.intValue()) { - return level; - } - } - } - } - - if (!isNameAnInt) { - // logging.1D=Cannot parse this name: {0} - throw new IllegalArgumentException(Messages.getString( - "logging.1D", name)); //$NON-NLS-1$ - } - - return new Level(name, nameAsInt); - } - - /** - * The name of this Level. - * - * @serial - */ - private final String name; - - /** - * The integer value indicating the level. - * - * @serial - */ - private final int value; - - /** - * The name of the resource bundle used to localize the level name. - * - * @serial - */ - private final String resourceBundleName; - - /** - * The resource bundle associated with this level, used to localize the - * level name. - */ - private transient ResourceBundle rb; - - /** - * Constructs an instance of {@code Level} taking the supplied name and - * level value. - * - * @param name - * the name of the level. - * @param level - * an integer value indicating the level. - * @throws NullPointerException - * if {@code name} is {@code null}. - */ - protected Level(String name, int level) { - this(name, level, null); - } - - /** - * Constructs an instance of {@code Level} taking the supplied name, level - * value and resource bundle name. - * - * @param name - * the name of the level. - * @param level - * an integer value indicating the level. - * @param resourceBundleName - * the name of the resource bundle to use. - * @throws NullPointerException - * if {@code name} is {@code null}. - */ - protected Level(String name, int level, String resourceBundleName) { - if (name == null) { - // logging.1C=The 'name' parameter is null. - throw new NullPointerException(Messages.getString("logging.1C")); //$NON-NLS-1$ - } - this.name = name; - this.value = level; - this.resourceBundleName = resourceBundleName; - if (resourceBundleName != null) { - try { - rb = ResourceBundle.getBundle(resourceBundleName, - // BEGIN android-changed - Locale.getDefault(), VMStack.getCallingClassLoader()); - // BEGIN android-changed - } catch (MissingResourceException e) { - rb = null; - } - } - synchronized (levels) { - levels.add(this); - } - } - - /** - * Gets the name of this level. - * - * @return this level's name. - */ - public String getName() { - return this.name; - } - - /** - * Gets the name of the resource bundle associated with this level. - * - * @return the name of this level's resource bundle. - */ - public String getResourceBundleName() { - return this.resourceBundleName; - } - - /** - * Gets the integer value indicating this level. - * - * @return this level's integer value. - */ - public final int intValue() { - return this.value; - } - - /** - * Serialization helper method to maintain singletons and add any new - * levels. - * - * @return the resolved instance. - */ - private Object readResolve() { - synchronized (levels) { - for (Level level : levels) { - if (value != level.value) { - continue; - } - if (!name.equals(level.name)) { - continue; - } - if (resourceBundleName == level.resourceBundleName) { - return level; - } else if (resourceBundleName != null - && resourceBundleName.equals(level.resourceBundleName)) { - return level; - } - } - // This is a new value, so add it. - levels.add(this); - return this; - } - } - - /** - * Serialization helper to setup transient resource bundle instance. - * - * @param in - * the input stream to read the instance data from. - * @throws IOException - * if an IO error occurs. - * @throws ClassNotFoundException - * if a class is not found. - */ - private void readObject(ObjectInputStream in) throws IOException, - ClassNotFoundException { - in.defaultReadObject(); - if (resourceBundleName != null) { - try { - rb = ResourceBundle.getBundle(resourceBundleName); - } catch (MissingResourceException e) { - rb = null; - } - } - } - - /** - * Gets the localized name of this level. The default locale is used. If no - * resource bundle is associated with this level then the original level - * name is returned. - * - * @return the localized name of this level. - */ - public String getLocalizedName() { - if (rb == null) { - return name; - } - - try { - return rb.getString(name); - } catch (MissingResourceException e) { - return name; - } - } - - /** - * Compares two {@code Level} objects for equality. They are considered to - * be equal if they have the same level value. - * - * @param o - * the other object to compare this level to. - * @return {@code true} if this object equals to the supplied object, - * {@code false} otherwise. - */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof Level)) { - return false; - } - - return ((Level) o).intValue() == this.value; - } - - /** - * Returns the hash code of this {@code Level} object. - * - * @return this level's hash code. - */ - @Override - public int hashCode() { - return this.value; - } - - /** - * Returns the string representation of this {@code Level} object. In - * this case, it is the level's name. - * - * @return the string representation of this level. - */ - @Override - public final String toString() { - return this.name; - } -} diff --git a/libcore/logging/src/main/java/java/util/logging/LogManager.java b/libcore/logging/src/main/java/java/util/logging/LogManager.java deleted file mode 100644 index 308daafa5..000000000 --- a/libcore/logging/src/main/java/java/util/logging/LogManager.java +++ /dev/null @@ -1,596 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.logging; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -// BEGIN android-removed -//import java.lang.management.ManagementFactory; -//import java.lang.reflect.Method; -// END android-removed -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.Collection; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Properties; -import java.util.Set; -import java.util.StringTokenizer; - -// BEGIN android-removed -//import javax.management.MBeanServer; -//import javax.management.ObjectInstance; -//import javax.management.ObjectName; -// END android-removed - -import org.apache.harmony.logging.internal.nls.Messages; - -/** - * {@code LogManager} is used to maintain configuration properties of the - * logging framework, and to manage a hierarchical namespace of all named - * {@code Logger} objects. - *

- * There is only one global {@code LogManager} instance in the - * application, which can be get by calling static method - * {@link #getLogManager()}. This instance is created and - * initialized during class initialization and cannot be changed. - *

- * The {@code LogManager} class can be specified by - * java.util.logging.manager system property, if the property is unavailable or - * invalid, the default class {@link java.util.logging.LogManager} will - * be used. - *

- * On initialization, {@code LogManager} reads its configuration from a - * properties file, which by default is the "lib/logging.properties" in the JRE - * directory. - *

- * However, two optional system properties can be used to customize the initial - * configuration process of {@code LogManager}. - *

    - *
  • "java.util.logging.config.class"
  • - *
  • "java.util.logging.config.file"
  • - *
- *

- * These two properties can be set in three ways, by the Preferences API, by the - * "java" command line property definitions, or by system property definitions - * passed to JNI_CreateJavaVM. - *

- * The "java.util.logging.config.class" should specifies a class name. If it is - * set, this given class will be loaded and instantiated during - * {@code LogManager} initialization, so that this object's default - * constructor can read the initial configuration and define properties for - * {@code LogManager}. - *

- * If "java.util.logging.config.class" property is not set, or it is invalid, or - * some exception is thrown during the instantiation, then the - * "java.util.logging.config.file" system property can be used to specify a - * properties file. The {@code LogManager} will read initial - * configuration from this file. - *

- * If neither of these properties is defined, or some exception is thrown - * during these two properties using, the {@code LogManager} will read - * its initial configuration from default properties file, as described above. - *

- * The global logging properties may include: - *

    - *
  • "handlers". This property's values should be a list of class names for - * handler classes separated by whitespace, these classes must be subclasses of - * {@code Handler} and each must have a default constructor, these - * classes will be loaded, instantiated and registered as handlers on the root - * {@code Logger} (the {@code Logger} named ""). These - * {@code Handler}s maybe initialized lazily.
  • - *
  • "config". The property defines a list of class names separated by - * whitespace. Each class must have a default constructor, in which it can - * update the logging configuration, such as levels, handlers, or filters for - * some logger, etc. These classes will be loaded and instantiated during - * {@code LogManager} configuration
  • - *
- *

- * This class, together with any handler and configuration classes associated - * with it, must be loaded from the system classpath when - * {@code LogManager} configuration occurs. - *

- * Besides global properties, the properties for loggers and Handlers can be - * specified in the property files. The names of these properties will start - * with the complete dot separated names for the handlers or loggers. - *

- * In the {@code LogManager}'s hierarchical namespace, - * {@code Loggers} are organized based on their dot separated names. For - * example, "x.y.z" is child of "x.y". - *

- * Levels for {@code Loggers} can be defined by properties whose name end - * with ".level". Thus "alogger.level" defines a level for the logger named as - * "alogger" and for all its children in the naming hierarchy. Log levels - * properties are read and applied in the same order as they are specified in - * the property file. The root logger's level can be defined by the property - * named as ".level". - *

- * All methods on this type can be taken as being thread safe. - * - */ -public class LogManager { - - // The line separator of the underlying OS - // Use privileged code to read the line.separator system property - private static final String lineSeparator = getPrivilegedSystemProperty("line.separator"); //$NON-NLS-1$ - - // The shared logging permission - private static final LoggingPermission perm = new LoggingPermission( - "control", null); //$NON-NLS-1$ - - // the singleton instance - static LogManager manager; - - /** - * The {@code String} value of the {@link LoggingMXBean}'s ObjectName. - */ - public static final String LOGGING_MXBEAN_NAME = "java.util.logging:type=Logging"; //$NON-NLS-1$ - - /** - * Get the {@code LoggingMXBean} instance. this implementation always throws - * an UnsupportedOperationException. - * - * @return the {@code LoggingMXBean} instance - */ - public static LoggingMXBean getLoggingMXBean() { - // BEGIN android-added - throw new UnsupportedOperationException(); - // END android-added - // BEGIN android-removed - // try { - // ObjectName loggingMXBeanName = new ObjectName(LOGGING_MXBEAN_NAME); - // MBeanServer platformBeanServer = ManagementFactory - // .getPlatformMBeanServer(); - // Set loggingMXBeanSet = platformBeanServer.queryMBeans( - // loggingMXBeanName, null); - // - // if (loggingMXBeanSet.size() != 1) { - // // logging.21=There Can Be Only One logging MX bean. - // throw new AssertionError(Messages.getString("logging.21")); //$NON-NLS-1$ - // } - // - // Iterator i = loggingMXBeanSet.iterator(); - // ObjectInstance loggingMXBeanOI = (ObjectInstance) i.next(); - // String lmxbcn = loggingMXBeanOI.getClassName(); - // Class lmxbc = Class.forName(lmxbcn); - // Method giMethod = lmxbc.getDeclaredMethod("getInstance"); //$NON-NLS-1$ - // giMethod.setAccessible(true); - // LoggingMXBean lmxb = (LoggingMXBean) giMethod.invoke(null, - // new Object[] {}); - // - // return lmxb; - // } catch (Exception e) { - // // TODO - // // e.printStackTrace(); - // } - // // logging.22=Exception occurred while getting the logging MX bean. - // throw new AssertionError(Messages.getString("logging.22")); //$NON-NLS-1$ - // END android-removed - } - - // FIXME: use weak reference to avoid heap memory leak - private Hashtable loggers; - - // the configuration properties - private Properties props; - - // the property change listener - private PropertyChangeSupport listeners; - - static { - // init LogManager singleton instance - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - String className = System - .getProperty("java.util.logging.manager"); //$NON-NLS-1$ - - if (null != className) { - manager = (LogManager) getInstanceByClass(className); - } - if (null == manager) { - manager = new LogManager(); - } - - // read configuration - try { - manager.readConfiguration(); - } catch (Exception e) { - e.printStackTrace(); - } - - // if global logger has been initialized, set root as its parent - Logger root = new Logger("", null); //$NON-NLS-1$ - root.setLevel(Level.INFO); - Logger.global.setParent(root); - - manager.addLogger(root); - manager.addLogger(Logger.global); - return null; - } - }); - } - - /** - * Default constructor. This is not public because there should be only one - * {@code LogManager} instance, which can be get by - * {@code LogManager.getLogManager(}. This is protected so that - * application can subclass the object. - */ - protected LogManager() { - loggers = new Hashtable(); - props = new Properties(); - listeners = new PropertyChangeSupport(this); - // add shutdown hook to ensure that the associated resource will be - // freed when JVM exits - AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - reset(); - } - }); - return null; - } - }); - } - - /* - * Package private utilities Returns the line separator of the underlying - * OS. - */ - static String getSystemLineSeparator() { - return lineSeparator; - } - - /** - * Check that the caller has {@code LoggingPermission("control")} so - * that it is trusted to modify the configuration for logging framework. If - * the check passes, just return, otherwise {@code SecurityException} - * will be thrown. - * - * @throws SecurityException - * if there is a security manager in operation and the invoker - * of this method does not have the required security permission - * {@code LoggingPermission("control")} - */ - public void checkAccess() { - if (null != System.getSecurityManager()) { - System.getSecurityManager().checkPermission(perm); - } - } - - /** - * Add a given logger into the hierarchical namespace. The - * {@code Logger.addLogger()} factory methods call this method to add newly - * created Logger. This returns false if a logger with the given name has - * existed in the namespace - *

- * Note that the {@code LogManager} may only retain weak references to - * registered loggers. In order to prevent {@code Logger} objects from being - * unexpectedly garbage collected it is necessary for applications - * to maintain references to them. - *

- * - * @param logger - * the logger to be added. - * @return true if the given logger is added into the namespace - * successfully, false if the given logger exists in the namespace. - */ - public synchronized boolean addLogger(Logger logger) { - String name = logger.getName(); - if (null != loggers.get(name)) { - return false; - } - addToFamilyTree(logger, name); - loggers.put(name, logger); - logger.setManager(this); - return true; - } - - private void addToFamilyTree(Logger logger, String name) { - Logger parent = null; - // find parent - int lastSeparator; - String parentName = name; - while ((lastSeparator = parentName.lastIndexOf('.')) != -1) { - parentName = parentName.substring(0, lastSeparator); - parent = loggers.get(parentName); - if (parent != null) { - logger.internalSetParent(parent); - break; - } else if (getProperty(parentName + ".level") != null || //$NON-NLS-1$ - getProperty(parentName + ".handlers") != null) { //$NON-NLS-1$ - parent = Logger.getLogger(parentName); - logger.internalSetParent(parent); - break; - } - } - if (parent == null && null != (parent = loggers.get(""))) { //$NON-NLS-1$ - logger.internalSetParent(parent); - } - - // find children - // TODO: performance can be improved here? - Collection allLoggers = loggers.values(); - for (final Logger child : allLoggers) { - Logger oldParent = child.getParent(); - if (parent == oldParent - && (name.length() == 0 || child.getName().startsWith( - name + '.'))) { - final Logger thisLogger = logger; - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - child.setParent(thisLogger); - return null; - } - }); - if (null != oldParent) { - // -- remove from old parent as the parent has been changed - oldParent.removeChild(child); - } - } - } - } - - /** - * Get the logger with the given name. - * - * @param name - * name of logger - * @return logger with given name, or {@code null} if nothing is found. - */ - public synchronized Logger getLogger(String name) { - return loggers.get(name); - } - - /** - * Get a {@code Enumeration} of all registered logger names. - * - * @return enumeration of registered logger names - */ - public synchronized Enumeration getLoggerNames() { - return loggers.keys(); - } - - /** - * Get the global {@code LogManager} instance. - * - * @return the global {@code LogManager} instance - */ - public static LogManager getLogManager() { - return manager; - } - - /** - * Get the value of property with given name. - * - * @param name - * the name of property - * @return the value of property - */ - public String getProperty(String name) { - return props.getProperty(name); - } - - /** - * Re-initialize the properties and configuration. The initialization - * process is same as the {@code LogManager} instantiation. - *

- * Notice : No {@code PropertyChangeEvent} are fired. - *

- * - * @throws IOException - * if any IO related problems happened. - * @throws SecurityException - * if security manager exists and it determines that caller does - * not have the required permissions to perform this action. - */ - public void readConfiguration() throws IOException { - checkAccess(); - // check config class - String configClassName = System - .getProperty("java.util.logging.config.class"); //$NON-NLS-1$ - if (null == configClassName - || null == getInstanceByClass(configClassName)) { - // if config class failed, check config file - String configFile = System - .getProperty("java.util.logging.config.file"); //$NON-NLS-1$ - - if (null == configFile) { - // if cannot find configFile, use default logging.properties - configFile = new StringBuilder().append( - System.getProperty("java.home")).append(File.separator) //$NON-NLS-1$ - .append("lib").append(File.separator).append( //$NON-NLS-1$ - "logging.properties").toString(); //$NON-NLS-1$ - } - - InputStream input = null; - try { - // BEGIN android-removed - // input = new BufferedInputStream(new FileInputStream(configFile)); - // END android-removed - - // BEGIN android-added - try { - input = new BufferedInputStream( - new FileInputStream(configFile), 8192); - } catch (Exception ex) { - // consult fixed resource as a last resort - input = new BufferedInputStream( - getClass().getResourceAsStream( - "logging.properties"), 8192); - } - // END android-added - readConfigurationImpl(input); - } finally { - if (input != null) { - try { - input.close(); - } catch (Exception e) {// ignore - } - } - } - } - } - - // use privilege code to get system property - static String getPrivilegedSystemProperty(final String key) { - return AccessController.doPrivileged(new PrivilegedAction() { - public String run() { - return System.getProperty(key); - } - }); - } - - // use SystemClassLoader to load class from system classpath - static Object getInstanceByClass(final String className) { - try { - Class clazz = ClassLoader.getSystemClassLoader().loadClass( - className); - return clazz.newInstance(); - } catch (Exception e) { - try { - Class clazz = Thread.currentThread().getContextClassLoader() - .loadClass(className); - return clazz.newInstance(); - } catch (Exception innerE) { - // logging.20=Loading class "{0}" failed - System.err.println(Messages.getString("logging.20", className)); //$NON-NLS-1$ - System.err.println(innerE); - return null; - } - } - - } - - // actual initialization process from a given input stream - private synchronized void readConfigurationImpl(InputStream ins) - throws IOException { - reset(); - props.load(ins); - - // parse property "config" and apply setting - String configs = props.getProperty("config"); //$NON-NLS-1$ - if (null != configs) { - StringTokenizer st = new StringTokenizer(configs, " "); //$NON-NLS-1$ - while (st.hasMoreTokens()) { - String configerName = st.nextToken(); - getInstanceByClass(configerName); - } - } - - // set levels for logger - Collection allLoggers = loggers.values(); - for (Logger logger : allLoggers) { - String property = props.getProperty(logger.getName() + ".level"); //$NON-NLS-1$ - if (null != property) { - logger.setLevel(Level.parse(property)); - } - } - listeners.firePropertyChange(null, null, null); - } - - /** - * Re-initialize the properties and configuration from the given - * {@code InputStream} - *

- * Notice : No {@code PropertyChangeEvent} are fired. - *

- * - * @param ins - * the input stream - * @throws IOException - * if any IO related problems happened. - * @throws SecurityException - * if security manager exists and it determines that caller does - * not have the required permissions to perform this action. - */ - public void readConfiguration(InputStream ins) throws IOException { - checkAccess(); - readConfigurationImpl(ins); - } - - /** - * Reset configuration. - *

- * All handlers are closed and removed from any named loggers. All loggers' - * level is set to null, except the root logger's level is set to - * {@code Level.INFO}. - *

- * - * @throws SecurityException - * if security manager exists and it determines that caller does - * not have the required permissions to perform this action. - */ - public void reset() { - checkAccess(); - props = new Properties(); - Enumeration names = getLoggerNames(); - while (names.hasMoreElements()) { - String name = names.nextElement(); - Logger logger = getLogger(name); - if (logger != null) { - logger.reset(); - } - } - Logger root = loggers.get(""); //$NON-NLS-1$ - if (null != root) { - root.setLevel(Level.INFO); - } - } - - /** - * Add a {@code PropertyChangeListener}, which will be invoked when - * the properties are reread. - * - * @param l - * the {@code PropertyChangeListener} to be added. - * @throws SecurityException - * if security manager exists and it determines that caller does - * not have the required permissions to perform this action. - */ - public void addPropertyChangeListener(PropertyChangeListener l) { - if (l == null) { - throw new NullPointerException(); - } - checkAccess(); - listeners.addPropertyChangeListener(l); - } - - /** - * Remove a {@code PropertyChangeListener}, do nothing if the given - * listener is not found. - * - * @param l - * the {@code PropertyChangeListener} to be removed. - * @throws SecurityException - * if security manager exists and it determines that caller does - * not have the required permissions to perform this action. - */ - public void removePropertyChangeListener(PropertyChangeListener l) { - checkAccess(); - listeners.removePropertyChangeListener(l); - } -} diff --git a/libcore/logging/src/main/java/java/util/logging/LogRecord.java b/libcore/logging/src/main/java/java/util/logging/LogRecord.java deleted file mode 100644 index 0a8e257a4..000000000 --- a/libcore/logging/src/main/java/java/util/logging/LogRecord.java +++ /dev/null @@ -1,514 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.logging; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.apache.harmony.logging.internal.nls.Messages; - -/** - * A {@code LogRecord} object represents a logging request. It is passed between - * the logging framework and individual logging handlers. Client applications - * should not modify a {@code LogRecord} object that has been passed into the - * logging framework. - *

- * The {@code LogRecord} class will infer the source method name and source - * class name the first time they are accessed if the client application didn't - * specify them explicitly. This automatic inference is based on the analysis of - * the call stack and is not guaranteed to be precise. Client applications - * should force the initialization of these two fields by calling - * {@code getSourceClassName} or {@code getSourceMethodName} if they expect to - * use them after passing the {@code LogRecord} object to another thread or - * transmitting it over RMI. - */ -public class LogRecord implements Serializable { - - private static final long serialVersionUID = 5372048053134512534L; - - // The major byte used in serialization. - private static final int MAJOR = 1; - - // The minor byte used in serialization. - private static final int MINOR = 4; - - // Store the current value for the sequence number. - private static long currentSequenceNumber = 0; - - // Store the id for each thread. - private static ThreadLocal currentThreadId = new ThreadLocal(); - - // The base id as the starting point for thread ID allocation. - private static int initThreadId = 0; - - /** - * The logging level. - * - * @serial - */ - private Level level; - - /** - * The sequence number. - * - * @serial - */ - private long sequenceNumber; - - /** - * The name of the class that issued the logging call. - * - * @serial - */ - private String sourceClassName; - - /** - * The name of the method that issued the logging call. - * - * @serial - */ - private String sourceMethodName; - - /** - * The original message text. - * - * @serial - */ - private String message; - - /** - * The ID of the thread that issued the logging call. - * - * @serial - */ - private int threadID; - - /** - * The time that the event occurred, in milliseconds since 1970. - * - * @serial - */ - private long millis; - - /** - * The associated {@code Throwable} object if any. - * - * @serial - */ - private Throwable thrown; - - /** - * The name of the source logger. - * - * @serial - */ - private String loggerName; - - /** - * The name of the resource bundle used to localize the log message. - * - * @serial - */ - private String resourceBundleName; - - // The associated resource bundle if any. - private transient ResourceBundle resourceBundle; - - // The parameters. - private transient Object[] parameters; - - // If the source method and source class has been initialized - private transient boolean sourceInited; - - /** - * Constructs a {@code LogRecord} object using the supplied the logging - * level and message. The millis property is set to the current time. The - * sequence property is set to a new unique value, allocated in increasing - * order within the virtual machine. The thread ID is set to a unique value - * for the current thread. All other properties are set to {@code null}. - * - * @param level - * the logging level, may not be {@code null}. - * @param msg - * the raw message. - * @throws NullPointerException - * if {@code level} is {@code null}. - */ - public LogRecord(Level level, String msg) { - if (null == level) { - // logging.4=The 'level' parameter is null. - throw new NullPointerException(Messages.getString("logging.4")); //$NON-NLS-1$ - } - this.level = level; - this.message = msg; - this.millis = System.currentTimeMillis(); - - synchronized (LogRecord.class) { - this.sequenceNumber = currentSequenceNumber++; - Integer id = currentThreadId.get(); - if (null == id) { - this.threadID = initThreadId; - currentThreadId.set(Integer.valueOf(initThreadId++)); - } else { - this.threadID = id.intValue(); - } - } - - this.sourceClassName = null; - this.sourceMethodName = null; - this.loggerName = null; - this.parameters = null; - this.resourceBundle = null; - this.resourceBundleName = null; - this.thrown = null; - } - - /** - * Gets the logging level. - * - * @return the logging level. - */ - public Level getLevel() { - return level; - } - - /** - * Sets the logging level. - * - * @param level - * the level to set. - * @throws NullPointerException - * if {@code level} is {@code null}. - */ - public void setLevel(Level level) { - if (null == level) { - // logging.4=The 'level' parameter is null. - throw new NullPointerException(Messages.getString("logging.4")); //$NON-NLS-1$ - } - this.level = level; - } - - /** - * Gets the name of the logger. - * - * @return the logger name. - */ - public String getLoggerName() { - return loggerName; - } - - /** - * Sets the name of the logger. - * - * @param loggerName - * the logger name to set. - */ - public void setLoggerName(String loggerName) { - this.loggerName = loggerName; - } - - /** - * Gets the raw message. - * - * @return the raw message, may be {@code null}. - */ - public String getMessage() { - return message; - } - - /** - * Sets the raw message. When this record is formatted by a logger that has - * a localization resource bundle that contains an entry for {@code message}, - * then the raw message is replaced with its localized version. - * - * @param message - * the raw message to set, may be {@code null}. - */ - public void setMessage(String message) { - this.message = message; - } - - /** - * Gets the time when this event occurred, in milliseconds since 1970. - * - * @return the time when this event occurred, in milliseconds since 1970. - */ - public long getMillis() { - return millis; - } - - /** - * Sets the time when this event occurred, in milliseconds since 1970. - * - * @param millis - * the time when this event occurred, in milliseconds since 1970. - */ - public void setMillis(long millis) { - this.millis = millis; - } - - /** - * Gets the parameters. - * - * @return the array of parameters or {@code null} if there are no - * parameters. - */ - public Object[] getParameters() { - return parameters; - } - - /** - * Sets the parameters. - * - * @param parameters - * the array of parameters to set, may be {@code null}. - */ - public void setParameters(Object[] parameters) { - this.parameters = parameters; - } - - /** - * Gets the resource bundle used to localize the raw message during - * formatting. - * - * @return the associated resource bundle, {@code null} if none is - * available or the message is not localizable. - */ - public ResourceBundle getResourceBundle() { - return resourceBundle; - } - - /** - * Sets the resource bundle used to localize the raw message during - * formatting. - * - * @param resourceBundle - * the resource bundle to set, may be {@code null}. - */ - public void setResourceBundle(ResourceBundle resourceBundle) { - this.resourceBundle = resourceBundle; - } - - /** - * Gets the name of the resource bundle. - * - * @return the name of the resource bundle, {@code null} if none is - * available or the message is not localizable. - */ - public String getResourceBundleName() { - return resourceBundleName; - } - - /** - * Sets the name of the resource bundle. - * - * @param resourceBundleName - * the name of the resource bundle to set. - */ - public void setResourceBundleName(String resourceBundleName) { - this.resourceBundleName = resourceBundleName; - } - - /** - * Gets the sequence number. - * - * @return the sequence number. - */ - public long getSequenceNumber() { - return sequenceNumber; - } - - /** - * Sets the sequence number. It is usually not necessary to call this method - * to change the sequence number because the number is allocated when this - * instance is constructed. - * - * @param sequenceNumber - * the sequence number to set. - */ - public void setSequenceNumber(long sequenceNumber) { - this.sequenceNumber = sequenceNumber; - } - - /** - * Gets the name of the class that is the source of this log record. This - * information can be changed, may be {@code null} and is untrusted. - * - * @return the name of the source class of this log record (possiblity {@code null}) - */ - public String getSourceClassName() { - initSource(); - return sourceClassName; - } - - /* - * Init the sourceClass and sourceMethod fields. - */ - private void initSource() { - if (!sourceInited) { - StackTraceElement[] elements = (new Throwable()).getStackTrace(); - int i = 0; - String current = null; - FINDLOG: for (; i < elements.length; i++) { - current = elements[i].getClassName(); - if (current.equals(Logger.class.getName())) { - break FINDLOG; - } - } - while (++i < elements.length - && elements[i].getClassName().equals(current)) { - // do nothing - } - if (i < elements.length) { - this.sourceClassName = elements[i].getClassName(); - this.sourceMethodName = elements[i].getMethodName(); - } - sourceInited = true; - } - } - - /** - * Sets the name of the class that is the source of this log record. - * - * @param sourceClassName - * the name of the source class of this log record, may be - * {@code null}. - */ - public void setSourceClassName(String sourceClassName) { - sourceInited = true; - this.sourceClassName = sourceClassName; - } - - /** - * Gets the name of the method that is the source of this log record. - * - * @return the name of the source method of this log record. - */ - public String getSourceMethodName() { - initSource(); - return sourceMethodName; - } - - /** - * Sets the name of the method that is the source of this log record. - * - * @param sourceMethodName - * the name of the source method of this log record, may be - * {@code null}. - */ - public void setSourceMethodName(String sourceMethodName) { - sourceInited = true; - this.sourceMethodName = sourceMethodName; - } - - /** - * Gets a unique ID of the thread originating the log record. Every thread - * becomes a different ID. - *

- * Notice : the ID doesn't necessary map the OS thread ID - *

- * - * @return the ID of the thread originating this log record. - */ - public int getThreadID() { - return threadID; - } - - /** - * Sets the ID of the thread originating this log record. - * - * @param threadID - * the new ID of the thread originating this log record. - */ - public void setThreadID(int threadID) { - this.threadID = threadID; - } - - /** - * Gets the {@code Throwable} object associated with this log record. - * - * @return the {@code Throwable} object associated with this log record. - */ - public Throwable getThrown() { - return thrown; - } - - /** - * Sets the {@code Throwable} object associated with this log record. - * - * @param thrown - * the new {@code Throwable} object to associate with this log - * record. - */ - public void setThrown(Throwable thrown) { - this.thrown = thrown; - } - - /* - * Customized serialization. - */ - private void writeObject(ObjectOutputStream out) throws IOException { - out.defaultWriteObject(); - out.writeByte(MAJOR); - out.writeByte(MINOR); - if (null == parameters) { - out.writeInt(-1); - } else { - out.writeInt(parameters.length); - for (Object element : parameters) { - out.writeObject(null == element ? null : element.toString()); - } - } - } - - /* - * Customized deserialization. - */ - private void readObject(ObjectInputStream in) throws IOException, - ClassNotFoundException { - in.defaultReadObject(); - byte major = in.readByte(); - byte minor = in.readByte(); - // only check MAJOR version - if (major != MAJOR) { - // logging.5=Different version - {0}.{1} - throw new IOException(Messages.getString("logging.5", //$NON-NLS-1$ - Byte.valueOf(major), Byte.valueOf(minor))); - } - - int length = in.readInt(); - if (length >= 0) { - parameters = new Object[length]; - for (int i = 0; i < parameters.length; i++) { - parameters[i] = in.readObject(); - } - } - if (null != resourceBundleName) { - try { - resourceBundle = Logger.loadResourceBundle(resourceBundleName); - } catch (MissingResourceException e) { - // Cannot find the specified resource bundle - resourceBundle = null; - } - } - } -} diff --git a/libcore/logging/src/main/java/java/util/logging/Logger.java b/libcore/logging/src/main/java/java/util/logging/Logger.java deleted file mode 100644 index fe124d392..000000000 --- a/libcore/logging/src/main/java/java/util/logging/Logger.java +++ /dev/null @@ -1,1425 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.logging; - -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.apache.harmony.logging.internal.nls.Messages; - -/** - * Loggers are used to log records to certain outputs, including file, console, - * etc. They use various handlers to actually do the output-dependent - * operations. - *

- * Client applications can get named loggers by calling the {@code getLogger} - * methods. They can also get anonymous loggers by calling the - * {@code getAnonymousLogger} methods. Named loggers are organized in a - * namespace hierarchy managed by a log manager. The naming convention is - * usually the same as java package's naming convention, that is using - * dot-separated strings. Anonymous loggers do not belong to any namespace. - *

- * Loggers "inherit" log level setting from their parent if their own level is - * set to {@code null}. This is also true for the resource bundle. The logger's - * resource bundle is used to localize the log messages if no resource bundle - * name is given when a log method is called. If {@code getUseParentHandlers()} - * returns {@code true}, loggers also inherit their parent's handlers. In this - * context, "inherit" only means that "behavior" is inherited. The internal - * field values will not change, for example, {@code getLevel()} still returns - * {@code null}. - *

- * When loading a given resource bundle, the logger first tries to use the - * context classloader. If that fails, it tries the system classloader. And if - * that still fails, it searches up the class stack and uses each class's - * classloader to try to locate the resource bundle. - *

- * Some log methods accept log requests that do not specify the source class and - * source method. In these cases, the logging framework will automatically infer - * the calling class and method, but this is not guaranteed to be accurate. - *

- * Once a {@code LogRecord} object has been passed into the logging framework, - * it is owned by the logging framework and the client applications should not - * use it any longer. - *

- * All methods of this class are thread-safe. - * - * @see LogManager - */ -public class Logger { - - /** - * The global logger is provided as convenience for casual use. - */ - public final static Logger global = new Logger("global", null); //$NON-NLS-1$ - - // the name of this logger - private volatile String name; - - // the parent logger of this logger - private Logger parent; - - // the logging level of this logger - private volatile Level levelObjVal; - - // the logging level as int of this logger - private volatile int levelIntVal; - - // the filter - private Filter filter; - - // the name of the resource bundle used to localize logging messages - private String resBundleName; - - // the loaded resource bundle according to the specified name - private ResourceBundle resBundle; - - // the handlers attached to this logger - private List handlers; - - /* - * flag indicating whether to notify parent's handlers on receiving a log - * request - */ - private boolean notifyParentHandlers; - - // flag indicating whether this logger is named or anonymous - private boolean isNamed; - - private List childs; - - private LogManager manager; - - // BEGIN android-changed - private volatile boolean handlerInited; - // END android-changed - - /** - * Constructs a {@code Logger} object with the supplied name and resource - * bundle name; {@code notifiyParentHandlers} is set to {@code true}. - *

- * Notice : Loggers use a naming hierarchy. Thus "z.x.y" is a child of "z.x". - * - * @param name - * the name of this logger, may be {@code null} for anonymous - * loggers. - * @param resourceBundleName - * the name of the resource bundle used to localize logging - * messages, may be {@code null}. - * @throws MissingResourceException - * if the specified resource bundle can not be loaded. - */ - protected Logger(String name, String resourceBundleName) { - // try to load the specified resource bundle first - if (null == resourceBundleName) { - this.resBundleName = null; - this.resBundle = null; - } else { - this.resBundle = loadResourceBundle(resourceBundleName); - this.resBundleName = resourceBundleName; - } - this.name = name; - this.parent = null; - this.filter = null; - this.childs = new ArrayList(); - this.notifyParentHandlers = true; - // any logger is not anonymous by default - this.isNamed = true; - - // -- 'null' means that level will be inherited from parent (see - // getLevel) - // -- Level.INFO is default level if we don't set it. It will be - // -- changed to parent level or to configLevel after adding to the - // -- family tree. As of this, actually, setting to Level.INFO is - // -- not needed here. - this.levelObjVal = null; - this.levelIntVal = Level.INFO.intValue(); - } - - // -- should be called under the lm lock - private void setLevelImpl(Level newLevel) { - // update levels for the whole hierarchy - int oldVal = levelIntVal; - levelObjVal = newLevel; - if (null == newLevel) { - levelIntVal = null != parent ? parent.levelIntVal : Level.INFO - .intValue(); - } else { - levelIntVal = newLevel.intValue(); - } - if (oldVal != levelIntVal) { - forceChildsToInherit(); - } - } - - // -- should be called under the lm lock - private void forceChildsToInherit() { - for (Logger child : childs) { - if (null == child.levelObjVal) { // should inherit - child.setLevelImpl(null); - } - } - } - - /** - * Load the specified resource bundle, use privileged code. - * - * @param resourceBundleName - * the name of the resource bundle to load, cannot be {@code null}. - * @return the loaded resource bundle. - * @throws MissingResourceException - * if the specified resource bundle can not be loaded. - */ - static ResourceBundle loadResourceBundle(String resourceBundleName) { - // try context class loader to load the resource - ClassLoader cl = AccessController - .doPrivileged(new PrivilegedAction() { - public ClassLoader run() { - return Thread.currentThread().getContextClassLoader(); - } - }); - if (null != cl) { - try { - return ResourceBundle.getBundle(resourceBundleName, Locale - .getDefault(), cl); - } catch (MissingResourceException e) { - // Failed to load using context classloader, ignore - } - } - // try system class loader to load the resource - cl = AccessController.doPrivileged(new PrivilegedAction() { - public ClassLoader run() { - return ClassLoader.getSystemClassLoader(); - } - }); - if (null != cl) { - try { - return ResourceBundle.getBundle(resourceBundleName, Locale - .getDefault(), cl); - } catch (MissingResourceException e) { - // Failed to load using system classloader, ignore - } - } - // try all class loaders up the class stack - final Class[] classes = AccessController - .doPrivileged(new PrivilegedAction[]>() { - public Class[] run() { - return (new PrivateSecurityManager()) - .privateGetClassContext(); - } - }); - // the first class, which is PrivateSecurityManager, is skipped - for (int i = 1; i < classes.length; i++) { - final int index = i; - try { - cl = AccessController - .doPrivileged(new PrivilegedAction() { - public ClassLoader run() { - return classes[index].getClassLoader(); - } - }); - if (null == cl) { - continue; - } - return ResourceBundle.getBundle(resourceBundleName, Locale - .getDefault(), cl); - } catch (MissingResourceException e) { - // Failed to load using the current class's classloader, ignore - } - } - // logging.8=Failed to load the specified resource bundle "{0}". - throw new MissingResourceException(Messages.getString("logging.8", //$NON-NLS-1$ - resourceBundleName), resourceBundleName, null); - } - - /** - * Gets an anonymous logger to use internally in a thread. Anonymous loggers - * are not registered in the log manager's namespace. No security checks - * will be performed when updating an anonymous logger's control settings. - *

- * The anonymous loggers' parent is set to be the root logger. This way it - * inherits the default logging level and handlers from the root logger. - * - * @return a new instance of anonymous logger. - */ - public static Logger getAnonymousLogger() { - return getAnonymousLogger(null); - } - - /** - * Gets an anonymous logger to use internally in a thread. Anonymous loggers - * are not registered in the log manager's namespace. No security checks - * will be performed when updating an anonymous logger's control settings. - *

- * The anonymous loggers' parent is set to be the root logger. This way it - * inherits default logging level and handlers from the root logger. - * - * @param resourceBundleName - * the name of the resource bundle used to localize log messages. - * @return a new instance of anonymous logger. - * @throws MissingResourceException - * if the specified resource bundle can not be loaded. - */ - public static Logger getAnonymousLogger(String resourceBundleName) { - final Logger l = new Logger(null, resourceBundleName); - l.isNamed = false; - l.internalSetParent(LogManager.getLogManager().getLogger("")); //$NON-NLS-1$ - return l; - } - - /* - * Check whether the same resource bundle has been specified. - * Synchronize to ensure the consistency between resource bundle - * and its name. - */ - private static void updateResourceBundle(Logger l, String resourceBundleName) { - synchronized (l) { - if (null == l.getResourceBundleName()) { - if (null == resourceBundleName) { - return; - } - /* - * load the resource bundle if none is specified before - */ - l.resBundle = loadResourceBundle(resourceBundleName); - l.resBundleName = resourceBundleName; - } else if (!l.getResourceBundleName().equals(resourceBundleName)) { - /* - * throw exception if the specified resource bundles are - * inconsistent with each other, i.e., different names - */ - // logging.9=The specified resource bundle name "{0}" is - // inconsistent with the existing one "{1}". - throw new IllegalArgumentException(Messages.getString( - "logging.9", //$NON-NLS-1$ - resourceBundleName, l.getResourceBundleName())); - } - } - } - - /* - * Gets a named logger associated with the supplied resource bundle. This - * method accepts null resource bundle name. The method body is synchronized - * on the instance of the LogManager to insure the consistency of the whole - * operation. - */ - private static Logger getLoggerWithRes(String name, - String resourceBundleName, boolean hasResourceName) { - LogManager man = LogManager.getLogManager(); - Logger l = null; - synchronized (man) { - // Try to find an existing logger with the specified name - l = man.getLogger(name); - // If no existing logger with the same name, create a new one - if (null == l) { - l = new Logger(name, resourceBundleName); - man.addLogger(l); - return l; - } - } - if (hasResourceName) { - updateResourceBundle(l, resourceBundleName); - } - return l; - } - - /** - * Gets a named logger. The returned logger may already exist or may be - * newly created. In the latter case, its level will be set to the - * configured level according to the {@code LogManager}'s properties. - * - * @param name - * the name of the logger to get, cannot be {@code null}. - * @return a named logger. - * @throws MissingResourceException - * If the specified resource bundle can not be loaded. - */ - public static Logger getLogger(String name) { - return getLoggerWithRes(name, null, false); - } - - /** - * Gets a named logger associated with the supplied resource bundle. The - * resource bundle will be used to localize logging messages. - * - * @param name - * the name of the logger to get, cannot be {@code null}. - * @param resourceBundleName - * the name of the resource bundle, may be {@code null}. - * @throws IllegalArgumentException - * if the logger identified by {@code name} is associated with a - * resource bundle and its name is not equal to - * {@code resourceBundleName}. - * @throws MissingResourceException - * if the name of the resource bundle cannot be found. - * @return a named logger. - */ - public static Logger getLogger(String name, String resourceBundleName) { - return getLoggerWithRes(name, resourceBundleName, true); - } - - /** - * Adds a handler to this logger. The {@code name} will be fed with log - * records received by this logger. - * - * @param handler - * the handler object to add, cannot be {@code null}. - * @throws SecurityException - * if a security manager determines that the caller does not - * have the required permission. - */ - public void addHandler(Handler handler) { - if (null == handler) { - // logging.A=The 'handler' parameter is null. - throw new NullPointerException(Messages.getString("logging.A")); //$NON-NLS-1$ - } - // Anonymous loggers can always add handlers - if (this.isNamed) { - LogManager.getLogManager().checkAccess(); - } - initHandler(); - synchronized (this) { - this.handlers.add(handler); - } - } - - /* - * Be cautious to avoid deadlock when using this method, it gets lock on manager - * at first, and then gets lock on this Logger, so any methods should not hold - * lock on this Logger when invoking this method. - */ - private void initHandler() { - if (!handlerInited) { - synchronized (this) { - if (!handlerInited) { - // BEGIN android-added - /* - * Force LogManager to be initialized, since its - * class init code performs necessary one-time setup. - */ - LogManager.getLogManager(); - // END android-added - if (handlers == null) { - handlers = new ArrayList(); - } - if (manager == null) { - return; - } - - String handlerStr = manager - .getProperty("".equals(name) ? "handlers" : name + ".handlers"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (null == handlerStr) { - return; - } - String[] strs = handlerStr.split(",|\\s"); //$NON-NLS-1$ - for (int i = 0; i < strs.length; i++) { - String handlerName = strs[i]; - if (handlerName.equals("")) { //$NON-NLS-1$ - continue; - } - // BEGIN android-changed - // deal with non-existing handler - try { - Handler handler = (Handler) LogManager.getInstanceByClass(handlerName); - handlers.add(handler); - String level = manager.getProperty(handlerName + ".level"); //$NON-NLS-1$ - if (null != level) { - handler.setLevel(Level.parse(level)); - } - } catch (Exception ex) { - ex.printStackTrace(); - } - // END android-changed - } - handlerInited = true; - } - } - } - } - - /** - * Gets all the handlers associated with this logger. - * - * @return an array of all the handlers associated with this logger. - */ - public Handler[] getHandlers() { - initHandler(); - synchronized (this) { - return handlers.toArray(new Handler[handlers.size()]); - } - } - - /** - * Removes a handler from this logger. If the specified handler does not - * exist then this method has no effect. - * - * @param handler - * the handler to be removed. - * @throws SecurityException - * if a security manager determines that the caller does not - * have the required permission. - */ - public void removeHandler(Handler handler) { - // Anonymous loggers can always remove handlers - if (this.isNamed) { - LogManager.getLogManager().checkAccess(); - } - if (null == handler) { - return; - } - initHandler(); - synchronized (this) { - this.handlers.remove(handler); - } - } - - /** - * Gets the filter used by this logger. - * - * @return the filter used by this logger, may be {@code null}. - */ - public Filter getFilter() { - return this.filter; - } - - /** - * Sets the filter used by this logger. - * - * @param newFilter - * the filter to set, may be {@code null}. - * @throws SecurityException - * if a security manager determines that the caller does not - * have the required permission. - */ - public void setFilter(Filter newFilter) { - // Anonymous loggers can always set the filter - if (this.isNamed) { - LogManager.getLogManager().checkAccess(); - } - filter = newFilter; - } - - /** - * Gets the logging level of this logger. A {@code null} level indicates - * that this logger inherits its parent's level. - * - * @return the logging level of this logger. - */ - public Level getLevel() { - return levelObjVal; - } - - /** - * Sets the logging level for this logger. A {@code null} level indicates - * that this logger will inherit its parent's level. - * - * @param newLevel - * the logging level to set. - * @throws SecurityException - * if a security manager determines that the caller does not - * have the required permission. - */ - public void setLevel(Level newLevel) { - // Anonymous loggers can always set the level - if (this.isNamed) { - LogManager.getLogManager().checkAccess(); - } - synchronized (LogManager.getLogManager()) { - setLevelImpl(newLevel); - } - } - - /** - * Gets the flag which indicates whether to use the handlers of this - * logger's parent to publish incoming log records, potentially recursively - * up the namespace. - * - * @return {@code true} if set to use parent's handlers, {@code false} - * otherwise. - */ - public boolean getUseParentHandlers() { - return this.notifyParentHandlers; - } - - /** - * Sets the flag which indicates whether to use the handlers of this - * logger's parent, potentially recursively up the namespace. - * - * @param notifyParentHandlers - * the new flag indicating whether to use the parent's handlers. - * @throws SecurityException - * if a security manager determines that the caller does not - * have the required permission. - */ - public void setUseParentHandlers(boolean notifyParentHandlers) { - // Anonymous loggers can always set the useParentHandlers flag - if (this.isNamed) { - LogManager.getLogManager().checkAccess(); - } - this.notifyParentHandlers = notifyParentHandlers; - } - - /** - * Gets the nearest parent of this logger in the namespace, a {@code null} - * value will be returned if called on the root logger. - * - * @return the parent of this logger in the namespace. - */ - public Logger getParent() { - return parent; - } - - /** - * Sets the parent of this logger in the namespace. This method should - * usually be used by the {@code LogManager} object only. This method does - * not check security. - * - * @param newParent - * the parent logger to set. - */ - void internalSetParent(Logger newParent) { - // All hierarchy related modifications should get LogManager lock at - // first - synchronized (LogManager.getLogManager()) { - parent = newParent; - // -- update level after setting a parent. - // -- if level == null we should inherit the parent's level - if (null == levelObjVal) { - setLevelImpl(levelObjVal); - } - newParent.addChild(this); - } - } - - /** - * Sets the parent of this logger in the namespace. This method should be - * used by the {@code LogManager} object only. - * - * @param parent - * the parent logger to set. - * @throws SecurityException - * if a security manager determines that the caller does not - * have the required permission. - */ - public void setParent(Logger parent) { - if (null == parent) { - // logging.B=The 'parent' parameter is null. - throw new NullPointerException(Messages.getString("logging.B")); //$NON-NLS-1$ - } - // even anonymous loggers are checked - LogManager.getLogManager().checkAccess(); - internalSetParent(parent); - } - - final void addChild(Logger logger) { - childs.add(logger); - } - - final void removeChild(Logger child) { - childs.remove(child); - } - - /** - * Gets the name of this logger, {@code null} for anonymous loggers. - * - * @return the name of this logger. - */ - public String getName() { - return this.name; - } - - /** - * Gets the loaded resource bundle used by this logger to localize logging - * messages. If the value is {@code null}, the parent's resource bundle will be - * inherited. - * - * @return the loaded resource bundle used by this logger. - */ - public ResourceBundle getResourceBundle() { - return this.resBundle; - } - - /** - * Gets the name of the loaded resource bundle used by this logger to - * localize logging messages. If the value is {@code null}, the parent's resource - * bundle name will be inherited. - * - * @return the name of the loaded resource bundle used by this logger. - */ - public String getResourceBundleName() { - return this.resBundleName; - } - - /** - * This method is for compatibility. Tests written to the reference - * implementation API imply that the isLoggable() method is not called - * directly. This behavior is important because subclass may override - * isLoggable() method, so that affect the result of log methods. - */ - private boolean internalIsLoggable(Level l) { - int effectiveLevel = levelIntVal; - if (effectiveLevel == Level.OFF.intValue()) { - // always return false if the effective level is off - return false; - } - return l.intValue() >= effectiveLevel; - } - - /** - * Determines whether this logger will actually log messages of the - * specified level. The effective level used to do the determination may be - * inherited from its parent. The default level is {@code Level.INFO}. - * - * @param l - * the level to check. - * @return {@code true} if this logger will actually log this level, - * otherwise {@code false}. - */ - public boolean isLoggable(Level l) { - return internalIsLoggable(l); - } - - /* - * Sets the resource bundle and its name for a supplied LogRecord object. - * This method first tries to use this logger's resource bundle if any, - * otherwise try to inherit from this logger's parent, recursively up the - * namespace. Synchronize to ensure the consistency between resource bundle - * and its name. - */ - private void setResourceBundle(LogRecord record) { - if (null != this.resBundleName) { - record.setResourceBundle(this.resBundle); - record.setResourceBundleName(this.resBundleName); - } else { - Logger anyParent = this.parent; - // no need to synchronize here, because if resBundleName - // is not null, there is no chance to modify it - while (null != anyParent) { - if (null != anyParent.resBundleName) { - record.setResourceBundle(anyParent.resBundle); - record.setResourceBundleName(anyParent.resBundleName); - return; - } - anyParent = anyParent.parent; - } - } - } - - /** - * Logs a message indicating that a method has been entered. A log record - * with log level {@code Level.FINER}, log message "ENTRY", the specified - * source class name and source method name is submitted for logging. - * - * @param sourceClass - * the calling class name. - * @param sourceMethod - * the method name. - */ - public void entering(String sourceClass, String sourceMethod) { - if (internalIsLoggable(Level.FINER)) { - LogRecord record = new LogRecord(Level.FINER, "ENTRY"); //$NON-NLS-1$ - record.setLoggerName(this.name); - record.setSourceClassName(sourceClass); - record.setSourceMethodName(sourceMethod); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message indicating that a method has been entered. A log record - * with log level {@code Level.FINER}, log message "ENTRY", the specified - * source class name, source method name and one parameter is submitted for - * logging. - * - * @param sourceClass - * the source class name. - * @param sourceMethod - * the source method name. - * @param param - * the parameter for the method call. - */ - public void entering(String sourceClass, String sourceMethod, Object param) { - if (internalIsLoggable(Level.FINER)) { - LogRecord record = new LogRecord(Level.FINER, "ENTRY" + " {0}"); //$NON-NLS-1$ //$NON-NLS-2$ - record.setLoggerName(this.name); - record.setSourceClassName(sourceClass); - record.setSourceMethodName(sourceMethod); - record.setParameters(new Object[] { param }); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message indicating that a method has been entered. A log record - * with log level {@code Level.FINER}, log message "ENTRY", the specified - * source class name, source method name and array of parameters is - * submitted for logging. - * - * @param sourceClass - * the source class name. - * @param sourceMethod - * the source method name. - * @param params - * an array of parameters for the method call. - */ - public void entering(String sourceClass, String sourceMethod, - Object[] params) { - if (internalIsLoggable(Level.FINER)) { - String msg = "ENTRY"; //$NON-NLS-1$ - if (null != params) { - StringBuilder msgBuffer = new StringBuilder("ENTRY"); //$NON-NLS-1$ - for (int i = 0; i < params.length; i++) { - msgBuffer.append(" {" + i + "}"); //$NON-NLS-1$ //$NON-NLS-2$ - } - msg = msgBuffer.toString(); - } - LogRecord record = new LogRecord(Level.FINER, msg); - record.setLoggerName(this.name); - record.setSourceClassName(sourceClass); - record.setSourceMethodName(sourceMethod); - record.setParameters(params); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message indicating that a method is exited. A log record with log - * level {@code Level.FINER}, log message "RETURN", the specified source - * class name and source method name is submitted for logging. - * - * @param sourceClass - * the calling class name. - * @param sourceMethod - * the method name. - */ - public void exiting(String sourceClass, String sourceMethod) { - if (internalIsLoggable(Level.FINER)) { - LogRecord record = new LogRecord(Level.FINER, "RETURN"); //$NON-NLS-1$ - record.setLoggerName(this.name); - record.setSourceClassName(sourceClass); - record.setSourceMethodName(sourceMethod); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message indicating that a method is exited. A log record with log - * level {@code Level.FINER}, log message "RETURN", the specified source - * class name, source method name and return value is submitted for logging. - * - * @param sourceClass - * the source class name. - * @param sourceMethod - * the source method name. - * @param result - * the return value of the method call. - */ - public void exiting(String sourceClass, String sourceMethod, Object result) { - if (internalIsLoggable(Level.FINER)) { - LogRecord record = new LogRecord(Level.FINER, "RETURN" + " {0}"); //$NON-NLS-1$ //$NON-NLS-2$ - record.setLoggerName(this.name); - record.setSourceClassName(sourceClass); - record.setSourceMethodName(sourceMethod); - record.setParameters(new Object[] { result }); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message indicating that an exception is thrown. A log record with - * log level {@code Level.FINER}, log message "THROW", the specified source - * class name, source method name and the {@code Throwable} object is - * submitted for logging. - * - * @param sourceClass - * the source class name. - * @param sourceMethod - * the source method name. - * @param thrown - * the {@code Throwable} object. - */ - public void throwing(String sourceClass, String sourceMethod, - Throwable thrown) { - if (internalIsLoggable(Level.FINER)) { - LogRecord record = new LogRecord(Level.FINER, "THROW"); //$NON-NLS-1$ - record.setLoggerName(this.name); - record.setSourceClassName(sourceClass); - record.setSourceMethodName(sourceMethod); - record.setThrown(thrown); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message of level {@code Level.SEVERE}; the message is transmitted - * to all subscribed handlers. - * - * @param msg - * the message to log. - */ - public void severe(String msg) { - if (internalIsLoggable(Level.SEVERE)) { - LogRecord record = new LogRecord(Level.SEVERE, msg); - record.setLoggerName(this.name); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message of level {@code Level.WARNING}; the message is - * transmitted to all subscribed handlers. - * - * @param msg - * the message to log. - */ - public void warning(String msg) { - if (internalIsLoggable(Level.WARNING)) { - LogRecord record = new LogRecord(Level.WARNING, msg); - record.setLoggerName(this.name); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message of level {@code Level.INFO}; the message is transmitted - * to all subscribed handlers. - * - * @param msg - * the message to log. - */ - public void info(String msg) { - if (internalIsLoggable(Level.INFO)) { - LogRecord record = new LogRecord(Level.INFO, msg); - record.setLoggerName(this.name); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message of level {@code Level.CONFIG}; the message is transmitted - * to all subscribed handlers. - * - * @param msg - * the message to log. - */ - public void config(String msg) { - if (internalIsLoggable(Level.CONFIG)) { - LogRecord record = new LogRecord(Level.CONFIG, msg); - record.setLoggerName(this.name); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message of level {@code Level.FINE}; the message is transmitted - * to all subscribed handlers. - * - * @param msg - * the message to log. - */ - public void fine(String msg) { - if (internalIsLoggable(Level.FINE)) { - LogRecord record = new LogRecord(Level.FINE, msg); - record.setLoggerName(this.name); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message of level {@code Level.FINER}; the message is transmitted - * to all subscribed handlers. - * - * @param msg - * the message to log. - */ - public void finer(String msg) { - if (internalIsLoggable(Level.FINER)) { - LogRecord record = new LogRecord(Level.FINER, msg); - record.setLoggerName(this.name); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message of level {@code Level.FINEST}; the message is transmitted - * to all subscribed handlers. - * - * @param msg - * the message to log. - */ - public void finest(String msg) { - if (internalIsLoggable(Level.FINEST)) { - LogRecord record = new LogRecord(Level.FINEST, msg); - record.setLoggerName(this.name); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message of the specified level. The message is transmitted to all - * subscribed handlers. - * - * @param logLevel - * the level of the specified message. - * @param msg - * the message to log. - */ - public void log(Level logLevel, String msg) { - if (internalIsLoggable(logLevel)) { - LogRecord record = new LogRecord(logLevel, msg); - record.setLoggerName(this.name); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message of the specified level with the supplied parameter. The - * message is then transmitted to all subscribed handlers. - * - * @param logLevel - * the level of the given message. - * @param msg - * the message to log. - * @param param - * the parameter associated with the event that is logged. - */ - public void log(Level logLevel, String msg, Object param) { - if (internalIsLoggable(logLevel)) { - LogRecord record = new LogRecord(logLevel, msg); - record.setLoggerName(this.name); - record.setParameters(new Object[] { param }); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message of the specified level with the supplied parameter array. - * The message is then transmitted to all subscribed handlers. - * - * @param logLevel - * the level of the given message - * @param msg - * the message to log. - * @param params - * the parameter array associated with the event that is logged. - */ - public void log(Level logLevel, String msg, Object[] params) { - if (internalIsLoggable(logLevel)) { - LogRecord record = new LogRecord(logLevel, msg); - record.setLoggerName(this.name); - record.setParameters(params); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message of the specified level with the supplied {@code Throwable} - * object. The message is then transmitted to all subscribed handlers. - * - * @param logLevel - * the level of the given message. - * @param msg - * the message to log. - * @param thrown - * the {@code Throwable} object associated with the event that is - * logged. - */ - public void log(Level logLevel, String msg, Throwable thrown) { - if (internalIsLoggable(logLevel)) { - LogRecord record = new LogRecord(logLevel, msg); - record.setLoggerName(this.name); - record.setThrown(thrown); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a given log record. Only records with a logging level that is equal - * or greater than this logger's level will be submitted to this logger's - * handlers for logging. If {@code getUseParentHandlers()} returns {@code - * true}, the log record will also be submitted to the handlers of this - * logger's parent, potentially recursively up the namespace. - *

- * Since all other log methods call this method to actually perform the - * logging action, subclasses of this class can override this method to - * catch all logging activities. - *

- * - * @param record - * the log record to be logged. - */ - public void log(LogRecord record) { - if (internalIsLoggable(record.getLevel())) { - // apply the filter if any - Filter f = filter; - if (null != f && !f.isLoggable(record)) { - return; - } - initHandler(); - /* - * call the handlers of this logger, throw any exception that occurs - */ - Handler[] allHandlers = getHandlers(); - for (Handler element : allHandlers) { - element.publish(record); - } - // call the parent's handlers if set useParentHandlers - Logger temp = this; - Logger theParent = temp.parent; - while (theParent != null && temp.getUseParentHandlers()) { - Handler[] ha = theParent.getHandlers(); - for (Handler element : ha) { - element.publish(record); - } - temp = theParent; - theParent = temp.parent; - } - } - } - - /** - * Logs a message of the given level with the specified source class name - * and source method name. - * - * @param logLevel - * the level of the given message. - * @param sourceClass - * the source class name. - * @param sourceMethod - * the source method name. - * @param msg - * the message to be logged. - */ - public void logp(Level logLevel, String sourceClass, String sourceMethod, - String msg) { - if (internalIsLoggable(logLevel)) { - LogRecord record = new LogRecord(logLevel, msg); - record.setLoggerName(this.name); - record.setSourceClassName(sourceClass); - record.setSourceMethodName(sourceMethod); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message of the given level with the specified source class name, - * source method name and parameter. - * - * @param logLevel - * the level of the given message - * @param sourceClass - * the source class name - * @param sourceMethod - * the source method name - * @param msg - * the message to be logged - * @param param - * the parameter associated with the event that is logged. - */ - public void logp(Level logLevel, String sourceClass, String sourceMethod, - String msg, Object param) { - if (internalIsLoggable(logLevel)) { - LogRecord record = new LogRecord(logLevel, msg); - record.setLoggerName(this.name); - record.setSourceClassName(sourceClass); - record.setSourceMethodName(sourceMethod); - record.setParameters(new Object[] { param }); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message of the given level with the specified source class name, - * source method name and parameter array. - * - * @param logLevel - * the level of the given message. - * @param sourceClass - * the source class name. - * @param sourceMethod - * the source method name. - * @param msg - * the message to be logged. - * @param params - * the parameter array associated with the event that is logged. - */ - public void logp(Level logLevel, String sourceClass, String sourceMethod, - String msg, Object[] params) { - if (internalIsLoggable(logLevel)) { - LogRecord record = new LogRecord(logLevel, msg); - record.setLoggerName(this.name); - record.setSourceClassName(sourceClass); - record.setSourceMethodName(sourceMethod); - record.setParameters(params); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message of the given level with the specified source class name, - * source method name and {@code Throwable} object. - * - * @param logLevel - * the level of the given message. - * @param sourceClass - * the source class name. - * @param sourceMethod - * the source method name. - * @param msg - * the message to be logged. - * @param thrown - * the {@code Throwable} object. - */ - public void logp(Level logLevel, String sourceClass, String sourceMethod, - String msg, Throwable thrown) { - if (internalIsLoggable(logLevel)) { - LogRecord record = new LogRecord(logLevel, msg); - record.setLoggerName(this.name); - record.setSourceClassName(sourceClass); - record.setSourceMethodName(sourceMethod); - record.setThrown(thrown); - setResourceBundle(record); - log(record); - } - } - - /** - * Logs a message of the given level with the specified source class name - * and source method name, using the given resource bundle to localize the - * message. If {@code bundleName} is null, the empty string or not valid then - * the message is not localized. - * - * @param logLevel - * the level of the given message. - * @param sourceClass - * the source class name. - * @param sourceMethod - * the source method name. - * @param bundleName - * the name of the resource bundle used to localize the message. - * @param msg - * the message to be logged. - */ - public void logrb(Level logLevel, String sourceClass, String sourceMethod, - String bundleName, String msg) { - if (internalIsLoggable(logLevel)) { - LogRecord record = new LogRecord(logLevel, msg); - if (null != bundleName) { - try { - record.setResourceBundle(loadResourceBundle(bundleName)); - } catch (MissingResourceException e) { - // ignore - } - record.setResourceBundleName(bundleName); - } - record.setLoggerName(this.name); - record.setSourceClassName(sourceClass); - record.setSourceMethodName(sourceMethod); - log(record); - } - } - - /** - * Logs a message of the given level with the specified source class name, - * source method name and parameter, using the given resource bundle to - * localize the message. If {@code bundleName} is null, the empty string - * or not valid then the message is not localized. - * - * @param logLevel - * the level of the given message. - * @param sourceClass - * the source class name. - * @param sourceMethod - * the source method name. - * @param bundleName - * the name of the resource bundle used to localize the message. - * @param msg - * the message to be logged. - * @param param - * the parameter associated with the event that is logged. - */ - public void logrb(Level logLevel, String sourceClass, String sourceMethod, - String bundleName, String msg, Object param) { - if (internalIsLoggable(logLevel)) { - LogRecord record = new LogRecord(logLevel, msg); - if (null != bundleName) { - try { - record.setResourceBundle(loadResourceBundle(bundleName)); - } catch (MissingResourceException e) { - // ignore - } - record.setResourceBundleName(bundleName); - } - record.setLoggerName(this.name); - record.setSourceClassName(sourceClass); - record.setSourceMethodName(sourceMethod); - record.setParameters(new Object[] { param }); - log(record); - } - } - - /** - * Logs a message of the given level with the specified source class name, - * source method name and parameter array, using the given resource bundle - * to localize the message. If {@code bundleName} is null, the empty string - * or not valid then the message is not localized. - * - * @param logLevel - * the level of the given message. - * @param sourceClass - * the source class name. - * @param sourceMethod - * the source method name. - * @param bundleName - * the name of the resource bundle used to localize the message. - * @param msg - * the message to be logged. - * @param params - * the parameter array associated with the event that is logged. - */ - public void logrb(Level logLevel, String sourceClass, String sourceMethod, - String bundleName, String msg, Object[] params) { - if (internalIsLoggable(logLevel)) { - LogRecord record = new LogRecord(logLevel, msg); - if (null != bundleName) { - try { - record.setResourceBundle(loadResourceBundle(bundleName)); - } catch (MissingResourceException e) { - // ignore - } - record.setResourceBundleName(bundleName); - } - record.setLoggerName(this.name); - record.setSourceClassName(sourceClass); - record.setSourceMethodName(sourceMethod); - record.setParameters(params); - log(record); - } - } - - /** - * Logs a message of the given level with the specified source class name, - * source method name and {@code Throwable} object, using the given resource - * bundle to localize the message. If {@code bundleName} is null, the empty - * string or not valid then the message is not localized. - * - * @param logLevel - * the level of the given message - * @param sourceClass - * the source class name - * @param sourceMethod - * the source method name - * @param bundleName - * the name of the resource bundle used to localize the message. - * @param msg - * the message to be logged. - * @param thrown - * the {@code Throwable} object. - */ - public void logrb(Level logLevel, String sourceClass, String sourceMethod, - String bundleName, String msg, Throwable thrown) { - if (internalIsLoggable(logLevel)) { - LogRecord record = new LogRecord(logLevel, msg); - if (null != bundleName) { - try { - record.setResourceBundle(loadResourceBundle(bundleName)); - } catch (MissingResourceException e) { - // ignore - } - record.setResourceBundleName(bundleName); - } - record.setLoggerName(this.name); - record.setSourceClassName(sourceClass); - record.setSourceMethodName(sourceMethod); - record.setThrown(thrown); - log(record); - } - } - - /* - * This security manager is used to access the class context. - */ - static class PrivateSecurityManager extends SecurityManager { - public Class[] privateGetClassContext() { - return super.getClassContext(); - } - } - - void setManager(LogManager manager) { - if (this.manager != manager) { - this.manager = manager; - handlerInited = false; - } - // init level here, but let handlers be for lazy loading - final String configedLevel = manager.getProperty(name + ".level"); //$NON-NLS-1$ - if (null != configedLevel) { - try { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - setLevel(Level.parse(configedLevel)); - return null; - } - }); - } catch (IllegalArgumentException e) { - // ignore - } - } - } - - synchronized void reset() { - levelObjVal = null; - levelIntVal = Level.INFO.intValue(); - if (handlers != null) { - for (Handler element : handlers) { - // close all handlers, when unknown exceptions happen, - // ignore them and go on - try { - element.close(); - } catch (Exception e) { - // Ignored. - } - } - handlers.clear(); - } - handlerInited = false; - } -} diff --git a/libcore/logging/src/main/java/java/util/logging/LoggingMXBean.java b/libcore/logging/src/main/java/java/util/logging/LoggingMXBean.java deleted file mode 100644 index 18cc4cc58..000000000 --- a/libcore/logging/src/main/java/java/util/logging/LoggingMXBean.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.logging; - -import java.util.List; - -/** - * {@code LoggingMXBean} is the management interface for the logging sub-system. - *

- * The ObjectName for identifying the {@code LoggingMXBean} in a bean server is - * {@link LogManager#LOGGING_MXBEAN_NAME}. - *

- * - * @since 1.5 - */ -public interface LoggingMXBean { - - /** - * Gets the string value of the logging level of a logger. An empty string - * is returned when the logger's level is defined by its parent. A - * {@code null} is returned if the specified logger does not exist. - * - * @param loggerName - * the name of the logger lookup. - * @return a {@code String} if the logger is found, otherwise {@code null}. - * @see Level#getName() - */ - String getLoggerLevel(String loggerName); - - /** - * Gets a list of all currently registered logger names. This is performed - * using the {@link LogManager#getLoggerNames()}. - * - * @return a list of logger names. - */ - List getLoggerNames(); - - /** - * Gets the name of the parent logger of a logger. If the logger doesn't - * exist then {@code null} is returned. If the logger is the root logger, - * then an empty {@code String} is returned. - * - * @param loggerName - * the name of the logger to lookup. - * @return a {@code String} if the logger was found, otherwise {@code null}. - */ - String getParentLoggerName(String loggerName); - - /** - * Sets the log level of a logger. LevelName set to {@code null} means the - * level is inherited from the nearest non-null ancestor. - * - * @param loggerName - * the name of the logger to set the level on, which must not be - * {@code null}. - * @param levelName - * the level to set on the logger, which may be {@code null}. - * @throws IllegalArgumentException - * if {@code loggerName} is not a registered logger or if - * {@code levelName} is not null and not valid. - * @throws SecurityException - * if a security manager exists and the caller doesn't have - * LoggingPermission("control"). - * @see Level#parse(String) - */ - void setLoggerLevel(String loggerName, String levelName); -} diff --git a/libcore/logging/src/main/java/java/util/logging/LoggingPermission.java b/libcore/logging/src/main/java/java/util/logging/LoggingPermission.java deleted file mode 100644 index aa41a2cfb..000000000 --- a/libcore/logging/src/main/java/java/util/logging/LoggingPermission.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.logging; - -import java.io.Serializable; -import java.security.BasicPermission; -import java.security.Guard; - -import org.apache.harmony.logging.internal.nls.Messages; - -/** - * The permission required to control the logging when run with a - * {@code SecurityManager}. - */ -public final class LoggingPermission extends BasicPermission implements Guard, - Serializable { - - // for serialization compatibility with J2SE 1.4.2 - private static final long serialVersionUID = 63564341580231582L; - - /** - * Constructs a {@code LoggingPermission} object required to control the - * logging. The {@code SecurityManager} checks the permissions. - *

- * {@code LoggingPermission} objects are created by the security policy code - * and depends on the security policy file, therefore programmers shouldn't - * normally use them directly. - *

- * - * @param name - * currently must be "control". - * @param actions - * currently must be either {@code null} or the empty string. - * @throws IllegalArgumentException - * if name null or different from {@code string} control. - */ - public LoggingPermission(String name, String actions) { - super(name, actions); - if (!"control".equals(name)) { //$NON-NLS-1$ - // logging.6=Name must be "control". - throw new IllegalArgumentException(Messages.getString("logging.6")); //$NON-NLS-1$ - } - if (null != actions && !"".equals(actions)) { //$NON-NLS-1$ - // logging.7=Actions must be either null or the empty string. - throw new IllegalArgumentException(Messages.getString("logging.7")); //$NON-NLS-1$ - } - } - -} diff --git a/libcore/logging/src/main/java/java/util/logging/MemoryHandler.java b/libcore/logging/src/main/java/java/util/logging/MemoryHandler.java deleted file mode 100644 index 33120831c..000000000 --- a/libcore/logging/src/main/java/java/util/logging/MemoryHandler.java +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.logging; - -import java.security.AccessController; -import java.security.PrivilegedExceptionAction; - -import org.apache.harmony.logging.internal.nls.Messages; - -/** - * A {@code Handler} put the description of log events into a cycled memory - * buffer. - *

- * Mostly this {@code MemoryHandler} just puts the given {@code LogRecord} into - * the internal buffer and doesn't perform any formatting or any other process. - * When the buffer is full, the earliest buffered records will be discarded. - *

- * Every {@code MemoryHandler} has a target handler, and push action can be - * triggered so that all buffered records will be output to the target handler - * and normally the latter will publish the records. After the push action, the - * buffer will be cleared. - *

- * The push method can be called directly, but will also be called automatically - * if a new LogRecord is added that has a level greater than or - * equal to than the value defined for the property - * java.util.logging.MemoryHandler.push. - *

- * {@code MemoryHandler} will read following {@code LogManager} properties for - * initialization, if given properties are not defined or has invalid values, - * default value will be used. - *

    - *
  • java.util.logging.MemoryHandler.filter specifies the {@code Filter} - * class name, defaults to no {@code Filter}.
  • - *
  • java.util.logging.MemoryHandler.level specifies the level for this - * {@code Handler}, defaults to {@code Level.ALL}.
  • - *
  • java.util.logging.MemoryHandler.push specifies the push level, defaults - * to level.SEVERE.
  • - *
  • java.util.logging.MemoryHandler.size specifies the buffer size in number - * of {@code LogRecord}, defaults to 1000.
  • - *
  • java.util.logging.MemoryHandler.target specifies the class of the target - * {@code Handler}, no default value, which means this property must be - * specified either by property setting or by constructor.
  • - *
- */ -public class MemoryHandler extends Handler { - - // default maximum buffered number of LogRecord - private static final int DEFAULT_SIZE = 1000; - - // target handler - private Handler target; - - // buffer size - private int size = DEFAULT_SIZE; - - // push level - private Level push = Level.SEVERE; - - // LogManager instance for convenience - private final LogManager manager = LogManager.getLogManager(); - - // buffer - private LogRecord[] buffer; - - // current position in buffer - private int cursor; - - /** - * Default constructor, construct and init a {@code MemoryHandler} using - * {@code LogManager} properties or default values. - * - * @throws RuntimeException - * if property value are invalid and no default value could be - * used. - */ - public MemoryHandler() { - super(); - String className = this.getClass().getName(); - // init target - final String targetName = manager.getProperty(className + ".target"); //$NON-NLS-1$ - try { - Class targetClass = AccessController - .doPrivileged(new PrivilegedExceptionAction>() { - public Class run() throws Exception { - ClassLoader loader = Thread.currentThread() - .getContextClassLoader(); - if (loader == null) { - loader = ClassLoader.getSystemClassLoader(); - } - return loader.loadClass(targetName); - } - }); - target = (Handler) targetClass.newInstance(); - } catch (Exception e) { - // logging.10=Cannot load target handler:{0} - throw new RuntimeException(Messages.getString("logging.10", //$NON-NLS-1$ - targetName)); - } - // init size - String sizeString = manager.getProperty(className + ".size"); //$NON-NLS-1$ - if (null != sizeString) { - try { - size = Integer.parseInt(sizeString); - if (size <= 0) { - size = DEFAULT_SIZE; - } - } catch (Exception e) { - printInvalidPropMessage(className + ".size", sizeString, e); //$NON-NLS-1$ - } - } - // init push level - String pushName = manager.getProperty(className + ".push"); //$NON-NLS-1$ - if (null != pushName) { - try { - push = Level.parse(pushName); - } catch (Exception e) { - printInvalidPropMessage(className + ".push", pushName, e); //$NON-NLS-1$ - } - } - // init other properties which are common for all Handler - initProperties("ALL", null, "java.util.logging.SimpleFormatter", null); //$NON-NLS-1$//$NON-NLS-2$ - buffer = new LogRecord[size]; - } - - /** - * Construct and init a {@code MemoryHandler} using given target, size and - * push level, other properties using {@code LogManager} properties or - * default values. - * - * @param target - * the given {@code Handler} to output - * @param size - * the maximum number of buffered {@code LogRecord}, greater than - * zero - * @param pushLevel - * the push level - * @throws IllegalArgumentException - * if {@code size <= 0} - * @throws RuntimeException - * if property value are invalid and no default value could be - * used. - */ - public MemoryHandler(Handler target, int size, Level pushLevel) { - if (size <= 0) { - // logging.11=Size must be positive. - throw new IllegalArgumentException(Messages.getString("logging.11")); //$NON-NLS-1$ - } - target.getLevel(); - pushLevel.intValue(); - this.target = target; - this.size = size; - this.push = pushLevel; - initProperties("ALL", null, "java.util.logging.SimpleFormatter", null); //$NON-NLS-1$//$NON-NLS-2$ - buffer = new LogRecord[size]; - } - - /** - * Close this handler and target handler, free all associated resources. - * - * @throws SecurityException - * if security manager exists and it determines that caller does - * not have the required permissions to control this handler. - */ - @Override - public void close() { - manager.checkAccess(); - target.close(); - setLevel(Level.OFF); - } - - /** - * Call target handler to flush any buffered output. Note that this doesn't - * cause this {@code MemoryHandler} to push. - */ - @Override - public void flush() { - target.flush(); - } - - /** - * Put a given {@code LogRecord} into internal buffer. If given record is - * not loggable, just return. Otherwise it is stored in the buffer. - * Furthermore if the record's level is not less than the push level, the - * push action is triggered to output all the buffered records to the target - * handler, and the target handler will publish them. - * - * @param record - * the log record - */ - @Override - public synchronized void publish(LogRecord record) { - if (!isLoggable(record)) { - return; - } - if (cursor >= size) { - cursor = 0; - } - buffer[cursor++] = record; - if (record.getLevel().intValue() >= push.intValue()) { - push(); - } - return; - } - - /** - * Return the push level. - * - * @return the push level - */ - public Level getPushLevel() { - return push; - } - - /** - * Check if given {@code LogRecord} would be put into this - * {@code MemoryHandler}'s internal buffer. - *

- * The given {@code LogRecord} is loggable if and only if it has appropriate - * level and it pass any associated filter's check. - *

- * Note that the push level is not used for this check. - * - * @param record - * the given {@code LogRecord} - * @return the given {@code LogRecord} if it should be logged, {@code false} - * if {@code LogRecord} is {@code null}. - */ - @Override - public boolean isLoggable(LogRecord record) { - return super.isLoggable(record); - } - - /** - * Triggers a push action to output all buffered records to the target handler, - * and the target handler will publish them. Then the buffer is cleared. - */ - public void push() { - for (int i = cursor; i < size; i++) { - if (null != buffer[i]) { - target.publish(buffer[i]); - } - buffer[i] = null; - } - for (int i = 0; i < cursor; i++) { - if (null != buffer[i]) { - target.publish(buffer[i]); - } - buffer[i] = null; - } - cursor = 0; - } - - /** - * Set the push level. The push level is used to check the push action - * triggering. When a new {@code LogRecord} is put into the internal - * buffer and its level is not less than the push level, the push action - * will be triggered. Note that set new push level won't trigger push action. - * - * @param newLevel - * the new level to set. - * @throws SecurityException - * if security manager exists and it determines that caller - * does not have the required permissions to control this handler. - */ - public void setPushLevel(Level newLevel) { - manager.checkAccess(); - newLevel.intValue(); - this.push = newLevel; - } -} diff --git a/libcore/logging/src/main/java/java/util/logging/SimpleFormatter.java b/libcore/logging/src/main/java/java/util/logging/SimpleFormatter.java deleted file mode 100644 index def4ad3cd..000000000 --- a/libcore/logging/src/main/java/java/util/logging/SimpleFormatter.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.logging; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.text.MessageFormat; -import java.util.Date; - -/** - * {@code SimpleFormatter} can be used to print a summary of the information - * contained in a {@code LogRecord} object in a human readable format. - */ -public class SimpleFormatter extends Formatter { - /** - * Constructs a new {@code SimpleFormatter}. - */ - public SimpleFormatter() { - super(); - } - - /** - * Converts a {@link LogRecord} object into a human readable string - * representation. - * - * @param r - * the log record to be formatted into a string. - * @return the formatted string. - */ - @Override - public String format(LogRecord r) { - StringBuilder sb = new StringBuilder(); - sb.append(MessageFormat.format("{0, date} {0, time} ", //$NON-NLS-1$ - new Object[] { new Date(r.getMillis()) })); - sb.append(r.getSourceClassName()).append(" "); //$NON-NLS-1$ - sb.append(r.getSourceMethodName()).append( - LogManager.getSystemLineSeparator()); - sb.append(r.getLevel().getName()).append(": "); //$NON-NLS-1$ - sb.append(formatMessage(r)).append(LogManager.getSystemLineSeparator()); - if (null != r.getThrown()) { - sb.append("Throwable occurred: "); //$NON-NLS-1$ - Throwable t = r.getThrown(); - PrintWriter pw = null; - try { - StringWriter sw = new StringWriter(); - pw = new PrintWriter(sw); - t.printStackTrace(pw); - sb.append(sw.toString()); - } finally { - if (pw != null) { - try { - pw.close(); - } catch (Exception e) { - // ignore - } - } - } - } - return sb.toString(); - } -} diff --git a/libcore/logging/src/main/java/java/util/logging/SocketHandler.java b/libcore/logging/src/main/java/java/util/logging/SocketHandler.java deleted file mode 100644 index 38cfd649c..000000000 --- a/libcore/logging/src/main/java/java/util/logging/SocketHandler.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.logging; - -import java.io.BufferedOutputStream; -import java.io.IOException; -import java.net.Socket; - -import org.apache.harmony.logging.internal.nls.Messages; - -/** - * A handler that writes log messages to a socket connection. - *

- * This handler reads the following properties from the log manager to - * initialize itself: - *

    - *
  • java.util.logging.ConsoleHandler.level specifies the logging level, - * defaults to {@code Level.ALL} if this property is not found or has an invalid - * value. - *
  • java.util.logging.SocketHandler.filter specifies the name of the filter - * class to be associated with this handler, defaults to {@code null} if this - * property is not found or has an invalid value. - *
  • java.util.logging.SocketHandler.formatter specifies the name of the - * formatter class to be associated with this handler, defaults to - * {@code java.util.logging.XMLFormatter} if this property is not found or has - * an invalid value. - *
  • java.util.logging.SocketHandler.encoding specifies the encoding this - * handler will use to encode log messages, defaults to {@code null} if this - * property is not found or has an invalid value. - *
  • java.util.logging.SocketHandler.host specifies the name of the host that - * this handler should connect to. There's no default value for this property. - *
  • java.util.logging.SocketHandler.encoding specifies the port number that - * this handler should connect to. There's no default value for this property. - *
- *

- * This handler buffers the outgoing messages, but flushes each time a log - * record has been published. - *

- * This class is not thread-safe. - */ -public class SocketHandler extends StreamHandler { - - // default level - private static final String DEFAULT_LEVEL = "ALL"; //$NON-NLS-1$ - - // default formatter - private static final String DEFAULT_FORMATTER = "java.util.logging.XMLFormatter"; //$NON-NLS-1$ - - // the socket connection - private Socket socket; - - /** - * Constructs a {@code SocketHandler} object using the properties read by - * the log manager, including the host name and port number. Default - * formatting uses the XMLFormatter class and level is set to ALL. - * - * @throws IOException - * if failed to connect to the specified host and port. - * @throws IllegalArgumentException - * if the host name or port number is illegal. - * @throws SecurityException - * if a security manager determines that the caller does not - * have the required permission to control this handler. - */ - public SocketHandler() throws IOException { - super(DEFAULT_LEVEL, null, DEFAULT_FORMATTER, null); - initSocket(LogManager.getLogManager().getProperty( - "java.util.logging.SocketHandler.host"), LogManager //$NON-NLS-1$ - .getLogManager().getProperty( - "java.util.logging.SocketHandler.port")); //$NON-NLS-1$ - } - - /** - * Constructs a {@code SocketHandler} object using the specified host name - * and port number together with other properties read by the log manager. - * Default formatting uses the XMLFormatter class and level is set to ALL. - * - * @param host - * the host name - * @param port - * the port number - * @throws IOException - * if failed to connect to the specified host and port. - * @throws IllegalArgumentException - * if the host name or port number is illegal. - * @throws SecurityException - * if a security manager determines that the caller does not - * have the required permission to control this handler. - */ - public SocketHandler(String host, int port) throws IOException { - super(DEFAULT_LEVEL, null, DEFAULT_FORMATTER, null); - initSocket(host, String.valueOf(port)); - } - - // Initialize the socket connection and prepare the output stream - private void initSocket(String host, String port) throws IOException { - // check the validity of the host name - if (null == host || "".equals(host)) { //$NON-NLS-1$ - // logging.C=Illegal host argument. - throw new IllegalArgumentException(Messages.getString("logging.C")); //$NON-NLS-1$ - } - // check the validity of the port number - int p = 0; - try { - p = Integer.parseInt(port); - } catch (NumberFormatException e) { - // logging.D=Illegal port argument. - throw new IllegalArgumentException(Messages.getString("logging.D")); //$NON-NLS-1$ - } - if (p <= 0) { - // logging.D=Illegal port argument. - throw new IllegalArgumentException(Messages.getString("logging.D")); //$NON-NLS-1$ - } - // establish the network connection - try { - this.socket = new Socket(host, p); - } catch (IOException e) { - // logging.E=Failed to establish the network connection. - getErrorManager().error(Messages.getString("logging.E"), e, //$NON-NLS-1$ - ErrorManager.OPEN_FAILURE); - throw e; - } - // BEGIN android-modified - super.internalSetOutputStream(new BufferedOutputStream(this.socket - .getOutputStream(), 8192)); - // END android-modified - } - - /** - * Closes this handler. The network connection to the host is also closed. - * - * @throws SecurityException - * If a security manager determines that the caller does not - * have the required permission to control this handler. - */ - @Override - public void close() { - try { - super.close(); - if (null != this.socket) { - this.socket.close(); - this.socket = null; - } - } catch (Exception e) { - // logging.F=Exception occurred when closing the socket handler. - getErrorManager().error(Messages.getString("logging.F"), e, //$NON-NLS-1$ - ErrorManager.CLOSE_FAILURE); - } - } - - /** - * Logs a record if necessary. A flush operation will be done afterwards. - * - * @param record - * the log record to be logged. - */ - @Override - public void publish(LogRecord record) { - super.publish(record); - super.flush(); - } -} diff --git a/libcore/logging/src/main/java/java/util/logging/StreamHandler.java b/libcore/logging/src/main/java/java/util/logging/StreamHandler.java deleted file mode 100644 index 7049d45c2..000000000 --- a/libcore/logging/src/main/java/java/util/logging/StreamHandler.java +++ /dev/null @@ -1,352 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.logging; - -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; -import java.io.Writer; - -import org.apache.harmony.logging.internal.nls.Messages; - -/** - * A {@code StreamHandler} object writes log messages to an output stream, that - * is, objects of the class {@link java.io.OutputStream}. - *

- * A {@code StreamHandler} object reads the following properties from the log - * manager to initialize itself. A default value will be used if a property is - * not found or has an invalid value. - *

    - *
  • java.util.logging.StreamHandler.encoding specifies the encoding this - * handler will use to encode log messages. Default is the encoding used by the - * current platform. - *
  • java.util.logging.StreamHandler.filter specifies the name of the filter - * class to be associated with this handler. No Filter is used by - * default. - *
  • java.util.logging.StreamHandler.formatter specifies the name of the - * formatter class to be associated with this handler. Default is - * {@code java.util.logging.SimpleFormatter}. - *
  • java.util.logging.StreamHandler.level specifies the logging level. - * Defaults is {@code Level.INFO}. - *
- *

- * This class is not thread-safe. - */ -public class StreamHandler extends Handler { - - // the output stream this handler writes to - private OutputStream os; - - // the writer that writes to the output stream - private Writer writer; - - // the flag indicating whether the writer has been initialized - private boolean writerNotInitialized; - - /** - * Constructs a {@code StreamHandler} object. The new stream handler - * does not have an associated output stream. - */ - public StreamHandler() { - initProperties("INFO", null, "java.util.logging.SimpleFormatter", //$NON-NLS-1$//$NON-NLS-2$ - null); - this.os = null; - this.writer = null; - this.writerNotInitialized = true; - } - - /** - * Constructs a {@code StreamHandler} object with the supplied output - * stream. Default properties are read. - * - * @param os - * the output stream this handler writes to. - */ - StreamHandler(OutputStream os) { - this(); - this.os = os; - } - - /** - * Constructs a {@code StreamHandler} object. The specified default values - * will be used if the corresponding properties are not found in the log - * manager's properties. - */ - StreamHandler(String defaultLevel, String defaultFilter, - String defaultFormatter, String defaultEncoding) { - initProperties(defaultLevel, defaultFilter, defaultFormatter, - defaultEncoding); - this.os = null; - this.writer = null; - this.writerNotInitialized = true; - } - - /** - * Constructs a {@code StreamHandler} object with the supplied output stream - * and formatter. - * - * @param os - * the output stream this handler writes to. - * @param formatter - * the formatter this handler uses to format the output. - * @throws NullPointerException - * if {@code os} or {@code formatter} is {@code null}. - */ - public StreamHandler(OutputStream os, Formatter formatter) { - this(); - if (os == null) { - // logging.2=The OutputStream parameter is null - throw new NullPointerException(Messages.getString("logging.2")); //$NON-NLS-1$ - } - if (formatter == null) { - // logging.3=The Formatter parameter is null. - throw new NullPointerException(Messages.getString("logging.3")); //$NON-NLS-1$ - } - this.os = os; - internalSetFormatter(formatter); - } - - // initialize the writer - private void initializeWritter() { - this.writerNotInitialized = false; - if (null == getEncoding()) { - this.writer = new OutputStreamWriter(this.os); - } else { - try { - this.writer = new OutputStreamWriter(this.os, getEncoding()); - } catch (UnsupportedEncodingException e) { - /* - * Should not happen because it's checked in - * super.initProperties(). - */ - } - } - write(getFormatter().getHead(this)); - } - - // Write a string to the output stream. - private void write(String s) { - try { - this.writer.write(s); - } catch (Exception e) { - // logging.14=Exception occurred when writing to the output stream. - getErrorManager().error(Messages.getString("logging.14"), e, //$NON-NLS-1$ - ErrorManager.WRITE_FAILURE); - } - } - - /** - * Sets the output stream this handler writes to. Note it does nothing else. - * - * @param newOs - * the new output stream - */ - void internalSetOutputStream(OutputStream newOs) { - this.os = newOs; - } - - /** - * Sets the output stream this handler writes to. If there's an existing - * output stream, the tail string of the associated formatter will be - * written to it. Then it will be flushed, closed and replaced with - * {@code os}. - * - * @param os - * the new output stream. - * @throws SecurityException - * if a security manager determines that the caller does not - * have the required permission. - * @throws NullPointerException - * if {@code os} is {@code null}. - */ - protected void setOutputStream(OutputStream os) { - if (null == os) { - throw new NullPointerException(); - } - LogManager.getLogManager().checkAccess(); - close(true); - this.writer = null; - this.os = os; - this.writerNotInitialized = true; - } - - /** - * Sets the character encoding used by this handler. A {@code null} value - * indicates that the default encoding should be used. - * - * @param encoding - * the character encoding to set. - * @throws SecurityException - * if a security manager determines that the caller does not - * have the required permission. - * @throws UnsupportedEncodingException - * if the specified encoding is not supported by the runtime. - */ - @Override - public void setEncoding(String encoding) throws SecurityException, - UnsupportedEncodingException { - // flush first before set new encoding - this.flush(); - super.setEncoding(encoding); - // renew writer only if the writer exists - if (null != this.writer) { - if (null == getEncoding()) { - this.writer = new OutputStreamWriter(this.os); - } else { - try { - this.writer = new OutputStreamWriter(this.os, getEncoding()); - } catch (UnsupportedEncodingException e) { - /* - * Should not happen because it's checked in - * super.initProperties(). - */ - throw new AssertionError(e); - } - } - } - } - - /** - * Closes this handler, but the underlying output stream is only closed if - * {@code closeStream} is {@code true}. Security is not checked. - * - * @param closeStream - * whether to close the underlying output stream. - */ - void close(boolean closeStream) { - if (null != this.os) { - if (this.writerNotInitialized) { - initializeWritter(); - } - write(getFormatter().getTail(this)); - try { - this.writer.flush(); - if (closeStream) { - this.writer.close(); - this.writer = null; - this.os = null; - } - } catch (Exception e) { - // logging.15=Exception occurred when closing the output stream. - getErrorManager().error(Messages.getString("logging.15"), e, //$NON-NLS-1$ - ErrorManager.CLOSE_FAILURE); - } - } - } - - /** - * Closes this handler. The tail string of the formatter associated with - * this handler is written out. A flush operation and a subsequent close - * operation is then performed upon the output stream. Client applications - * should not use a handler after closing it. - * - * @throws SecurityException - * if a security manager determines that the caller does not - * have the required permission. - */ - @Override - public void close() { - LogManager.getLogManager().checkAccess(); - close(true); - } - - /** - * Flushes any buffered output. - */ - @Override - public void flush() { - if (null != this.os) { - try { - if (null != this.writer) { - this.writer.flush(); - } else { - this.os.flush(); - } - } catch (Exception e) { - // logging.16=Exception occurred while flushing the output - // stream. - getErrorManager().error(Messages.getString("logging.16"), //$NON-NLS-1$ - e, ErrorManager.FLUSH_FAILURE); - } - } - } - - /** - * Accepts a logging request. The log record is formatted and written to the - * output stream if the following three conditions are met: - *

    - *
  • the supplied log record has at least the required logging level; - *
  • the supplied log record passes the filter associated with this - * handler, if any; - *
  • the output stream associated with this handler is not {@code null}. - *
- * If it is the first time a log record is written out, the head string of - * the formatter associated with this handler is written out first. - * - * @param record - * the log record to be logged. - */ - @Override - public synchronized void publish(LogRecord record) { - try { - if (this.isLoggable(record)) { - if (this.writerNotInitialized) { - initializeWritter(); - } - String msg = null; - try { - msg = getFormatter().format(record); - } catch (Exception e) { - // logging.17=Exception occurred while formatting the log - // record. - getErrorManager().error(Messages.getString("logging.17"), //$NON-NLS-1$ - e, ErrorManager.FORMAT_FAILURE); - } - write(msg); - } - } catch (Exception e) { - // logging.18=Exception occurred while logging the record. - getErrorManager().error(Messages.getString("logging.18"), e, //$NON-NLS-1$ - ErrorManager.GENERIC_FAILURE); - } - } - - /** - * Determines whether the supplied log record needs to be logged. The - * logging levels are checked as well as the filter. The output stream of - * this handler is also checked. If it is {@code null}, this method returns - * {@code false}. - *

- * Notice : Case of no output stream will return {@code false}. - * - * @param record - * the log record to be checked. - * @return {@code true} if {@code record} needs to be logged, {@code false} - * otherwise. - */ - @Override - public boolean isLoggable(LogRecord record) { - if (null == record) { - return false; - } - if (null != this.os && super.isLoggable(record)) { - return true; - } - return false; - } -} diff --git a/libcore/logging/src/main/java/java/util/logging/XMLFormatter.java b/libcore/logging/src/main/java/java/util/logging/XMLFormatter.java deleted file mode 100644 index ff9681381..000000000 --- a/libcore/logging/src/main/java/java/util/logging/XMLFormatter.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util.logging; - -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.text.MessageFormat; -import java.util.Date; -import java.util.ResourceBundle; - -/** - * Formatter to convert a {@link LogRecord} into an XML string. The DTD - * specified in Appendix A to the Java Logging APIs specification is used. - * {@code XMLFormatter} uses the output handler's encoding if it is specified, - * otherwise the default platform encoding is used instead. UTF-8 is the - * recommended encoding. - */ -public class XMLFormatter extends Formatter { - - private static final String lineSeperator = LogManager - .getSystemLineSeparator(); - - private static final String indent = " "; //$NON-NLS-1$ - - /** - * Constructs a new {@code XMLFormatter}. - */ - public XMLFormatter() { - super(); - } - - /** - * Converts a {@code LogRecord} into an XML string. - * - * @param r - * the log record to be formatted. - * @return the log record formatted as an XML string. - */ - @SuppressWarnings("nls") - @Override - public String format(LogRecord r) { - // call a method of LogRecord to ensure not null - long time = r.getMillis(); - // format to date - String date = MessageFormat.format("{0, date} {0, time}", - new Object[] { new Date(time) }); - - StringBuilder sb = new StringBuilder(); - sb.append(("")).append(lineSeperator); - sb.append(indent).append(("")).append(date).append(("")) - .append(lineSeperator); - sb.append(indent).append(("")).append(time).append( - ("")).append(lineSeperator); - sb.append(indent).append(("")).append(r.getSequenceNumber()) - .append(("")).append(lineSeperator); - if (null != r.getLoggerName()) { - sb.append(indent).append(("")).append(r.getLoggerName()) - .append(("")).append(lineSeperator); - } - sb.append(indent).append(("")).append(r.getLevel().getName()) - .append(("")).append(lineSeperator); - if (null != r.getSourceClassName()) { - sb.append(indent).append(("")) - .append(r.getSourceClassName()).append(("")) - .append(lineSeperator); - } - if (null != r.getSourceMethodName()) { - sb.append(indent).append(("")).append( - r.getSourceMethodName()).append(("")).append( - lineSeperator); - } - sb.append(indent).append(("")).append(r.getThreadID()).append( - ("")).append(lineSeperator); - formatMessages(r, sb); - Object[] params; - if ((params = r.getParameters()) != null) { - for (Object element : params) { - sb.append(indent).append(("")).append(element).append( - ("")).append(lineSeperator); - } - } - formatThrowable(r, sb); - sb.append(("")).append(lineSeperator); - return sb.toString(); - } - - @SuppressWarnings("nls") - private void formatMessages(LogRecord r, StringBuilder sb) { - // get localized message if has, but don't call Formatter.formatMessage - // to parse pattern string - ResourceBundle rb = r.getResourceBundle(); - String pattern = r.getMessage(); - if (null != rb && null != pattern) { - String message; - try { - message = rb.getString(pattern); - } catch (Exception e) { - message = null; - } - - if (message == null) { - message = pattern; - sb.append(indent).append(("")).append(message).append( - ("")).append(lineSeperator); - } else { - sb.append(indent).append(("")).append(message).append( - ("")).append(lineSeperator); - sb.append(indent).append(("")).append(pattern).append( - ("")).append(lineSeperator); - sb.append(indent).append(("")).append( - r.getResourceBundleName()).append(("")) - .append(lineSeperator); - } - } else if (null != pattern) { - sb.append(indent).append(("")).append(pattern).append( - ("")).append(lineSeperator); - } else { - sb.append(indent).append(("")); - } - } - - @SuppressWarnings("nls") - private void formatThrowable(LogRecord r, StringBuilder sb) { - Throwable t; - if ((t = r.getThrown()) != null) { - sb.append(indent).append("").append(lineSeperator); - sb.append(indent).append(indent).append("").append( - t.toString()).append("").append(lineSeperator); - // format throwable's stack trace - StackTraceElement[] elements = t.getStackTrace(); - for (StackTraceElement e : elements) { - sb.append(indent).append(indent).append("").append( - lineSeperator); - sb.append(indent).append(indent).append(indent).append( - "").append(e.getClassName()).append("") - .append(lineSeperator); - sb.append(indent).append(indent).append(indent).append( - "").append(e.getMethodName()).append( - "").append(lineSeperator); - sb.append(indent).append(indent).append(indent) - .append("").append(e.getLineNumber()).append( - "").append(lineSeperator); - sb.append(indent).append(indent).append("").append( - lineSeperator); - } - sb.append(indent).append("").append(lineSeperator); - } - } - - /** - * Returns the header string for a set of log records formatted as XML - * strings, using the output handler's encoding if it is defined, otherwise - * using the default platform encoding. - * - * @param h - * the output handler, may be {@code null}. - * @return the header string for log records formatted as XML strings. - */ - @SuppressWarnings("nls") - @Override - public String getHead(Handler h) { - String encoding = null; - if (null != h) { - encoding = h.getEncoding(); - } - if (null == encoding) { - encoding = getSystemProperty("file.encoding"); - } - StringBuilder sb = new StringBuilder(); - sb.append("").append(lineSeperator); - sb.append("").append(lineSeperator); - sb.append(("")); - return sb.toString(); - } - - /** - * Returns the tail string for a set of log records formatted as XML - * strings. - * - * @param h - * the output handler, may be {@code null}. - * @return the tail string for log records formatted as XML strings. - */ - @Override - public String getTail(Handler h) { - return ""; //$NON-NLS-1$ - } - - // use privilege code to get system property - private static String getSystemProperty(final String key) { - return AccessController.doPrivileged(new PrivilegedAction() { - public String run() { - return System.getProperty(key); - } - }); - } -} diff --git a/libcore/logging/src/main/java/java/util/logging/logging.properties b/libcore/logging/src/main/java/java/util/logging/logging.properties deleted file mode 100644 index f99fe3f05..000000000 --- a/libcore/logging/src/main/java/java/util/logging/logging.properties +++ /dev/null @@ -1,65 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -#------------------------------------------------------------------------------ -# Default logging property file. -# This file is used by java.util.logging package as default settings, users can -# specify another file instead with java.util.logging.config.file system -# property, this property can be set via the Preference API, or as VM arguments -# passed to "java" command, or as property definition passed to JNI_CreateJavaVM. -# You can refer to JavaDoc of java.util.logging package for more information -# about this file. -#------------------------------------------------------------------------------ - -#------------------------------------------------------------------------------ -# Global settings -#------------------------------------------------------------------------------ - -# Specify default level for global logger, the event whose level is below won't -# be logged. You can specify level for every logger, otherwise the level of parent -# logger will be used. You can also set the level for every handler, as below for -# java.util.logging.ConsoleHandler. -.level=INFO - -# Specify handler classes list, these classes will be instantiated during the -# logging framework initialization. The list should be white space separated. -# For example, use the line below to add SocketHandler. Note that the handler -# classes must be in the classpath. -# -# handlers=java.util.logging.ConsoleHandler java.util.logging.SocketHandler -# -handlers=java.util.logging.ConsoleHandler - -# Specify a class names list, these classes' default constructor will be executed -# during logging package initialization, which may contain some code to set the -# logging configuration. The list should be white space separated, and the -# classes must be in the classpath. -# -# config= - - -#------------------------------------------------------------------------------ -# Handler settings -#------------------------------------------------------------------------------ - -# The properties below are samples for handler settings. -#java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter -#java.util.logging.ConsoleHandler.level=INFO -#java.util.logging.FileHandler.limit=100000 -#java.util.logging.FileHandler.count=1 -#java.util.logging.FileHandler.formatter=java.util.logging.XMLFormatter -#java.util.logging.FileHandler.pattern=%h/java%u.log - diff --git a/libcore/logging/src/main/java/java/util/logging/package.html b/libcore/logging/src/main/java/java/util/logging/package.html deleted file mode 100644 index c523c7a44..000000000 --- a/libcore/logging/src/main/java/java/util/logging/package.html +++ /dev/null @@ -1,10 +0,0 @@ - - -

- This package allows to add logging to any application. It - supports different levels of importance of a message that needs to be - logged. The output written to the target can be filtered by this level. -

- @since Android 1.0 - - diff --git a/libcore/logging/src/main/java/org/apache/harmony/logging/internal/nls/Messages.java b/libcore/logging/src/main/java/org/apache/harmony/logging/internal/nls/Messages.java deleted file mode 100644 index 87535aebd..000000000 --- a/libcore/logging/src/main/java/org/apache/harmony/logging/internal/nls/Messages.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL. - * All changes made to this file manually will be overwritten - * if this tool runs again. Better make changes in the template file. - */ - -// BEGIN android-note -// Redundant code has been removed and is now called from MsgHelp. -// END android-note - -package org.apache.harmony.logging.internal.nls; - - -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -// BEGIN android-changed -import org.apache.harmony.luni.util.MsgHelp; -// END android-changed - -/** - * This class retrieves strings from a resource bundle and returns them, - * formatting them with MessageFormat when required. - *

- * It is used by the system classes to provide national language support, by - * looking up messages in the - * org.apache.harmony.logging.internal.nls.messages - * - * resource bundle. Note that if this file is not available, or an invalid key - * is looked up, or resource bundle support is not available, the key itself - * will be returned as the associated message. This means that the KEY - * should a reasonable human-readable (english) string. - * - */ -public class Messages { - - // BEGIN android-changed - private static final String sResource = - "org.apache.harmony.logging.internal.nls.messages"; //$NON-NLS-1$ - // END android-changed - - /** - * Retrieves a message which has no arguments. - * - * @param msg - * String the key to look up. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg) { - // BEGIN android-changed - return MsgHelp.getString(sResource, msg); - // END android-changed - } - - /** - * Retrieves a message which takes 1 argument. - * - * @param msg - * String the key to look up. - * @param arg - * Object the object to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, Object arg) { - return getString(msg, new Object[] { arg }); - } - - /** - * Retrieves a message which takes 1 integer argument. - * - * @param msg - * String the key to look up. - * @param arg - * int the integer to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, int arg) { - return getString(msg, new Object[] { Integer.toString(arg) }); - } - - /** - * Retrieves a message which takes 1 character argument. - * - * @param msg - * String the key to look up. - * @param arg - * char the character to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, char arg) { - return getString(msg, new Object[] { String.valueOf(arg) }); - } - - /** - * Retrieves a message which takes 2 arguments. - * - * @param msg - * String the key to look up. - * @param arg1 - * Object an object to insert in the formatted output. - * @param arg2 - * Object another object to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, Object arg1, Object arg2) { - return getString(msg, new Object[] { arg1, arg2 }); - } - - /** - * Retrieves a message which takes several arguments. - * - * @param msg - * String the key to look up. - * @param args - * Object[] the objects to insert in the formatted output. - * @return String the message for that key in the system message bundle. - */ - static public String getString(String msg, Object[] args) { - // BEGIN android-changed - return MsgHelp.getString(sResource, msg, args); - // END android-changed - } - - // BEGIN android-note - // Duplicate code was dropped in favor of using MsgHelp. - // END android-note -} diff --git a/libcore/logging/src/main/java/org/apache/harmony/logging/internal/nls/messages.properties b/libcore/logging/src/main/java/org/apache/harmony/logging/internal/nls/messages.properties deleted file mode 100644 index da3945ecd..000000000 --- a/libcore/logging/src/main/java/org/apache/harmony/logging/internal/nls/messages.properties +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# messages for EN locale -logging.0=This method is not currently implemented. -logging.1=Invalid level name: {0}. -logging.10=Cannot load target handler:{0} -logging.11=Size must be positive. -logging.12=Invalid property value for -logging.13=The encoding "{0}" is not supported. -logging.14=Exception occurred when writing to the output stream. -logging.15=Exception occurred when closing the output stream. -logging.16=Exception occurred while flushing the output stream. -logging.17=Exception occurred while formatting the log record. -logging.18=Exception occurred while logging the record. -logging.19=Pattern cannot be empty -logging.1A=Error happened when open log file. -logging.1B=The limit and count property must be larger than 0 and 1, respectively -logging.1C=The 'name' parameter is null. -logging.1D=Cannot parse this name: {0} -logging.1E=Error message - {0} -logging.1F=Exception - {0} -logging.2=The OutputStream parameter is null -logging.20=Loading class "{0}" failed -logging.21=There Can Be Only One logging MX bean. -logging.22=Exception occurred while getting the logging MX bean. -logging.3=The Formatter parameter is null. -logging.4=The 'level' parameter is null. -logging.5=Different version - {0}.{1} -logging.6=Name must be "control". -logging.7=Actions must be either null or the empty string. -logging.8=Failed to load the specified resource bundle "{0}". -logging.9=The specified resource bundle name "{0}" is inconsistent with the existing one "{1}". -logging.A=The 'handler' parameter is null. -logging.B=The 'parent' parameter is null. -logging.C=Illegal host argument. -logging.D=Illegal port argument. -logging.E=Failed to establish the network connection. -logging.F=Exception occured when closing the socket handler. diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/AllTests.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/AllTests.java deleted file mode 100644 index 1094f25fa..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/AllTests.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.logging.tests.java.util.logging; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - */ -public class AllTests { - - public static Test suite() { - TestSuite suite = tests.TestSuiteFactory.createTestSuite( - "Suite for org.apache.harmony.logging.tests.java.util.logging"); - // $JUnit-BEGIN$ - suite.addTestSuite(ConsoleHandlerTest.class); - suite.addTestSuite(ErrorManagerTest.class); - suite.addTestSuite(FileHandlerTest.class); - suite.addTestSuite(FilterTest.class); - suite.addTestSuite(FormatterTest.class); - suite.addTestSuite(HandlerTest.class); - suite.addTestSuite(LevelTest.class); - suite.addTestSuite(LoggerTest.class); - suite.addTestSuite(LoggingMXBeanTest.class); - suite.addTestSuite(LoggingPermissionTest.class); - suite.addTestSuite(LogManagerTest.class); - suite.addTestSuite(LogRecordTest.class); - suite.addTestSuite(MemoryHandlerTest.class); - suite.addTestSuite(SimpleFormatterTest.class); - suite.addTestSuite(SocketHandlerTest.class); - suite.addTestSuite(StreamHandlerTest.class); - suite.addTestSuite(XMLFormatterTest.class); - suite.addTestSuite(MessagesTest.class); - // $JUnit-END$ - return suite; - } -} diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/ConsoleHandlerTest.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/ConsoleHandlerTest.java deleted file mode 100644 index 91de2a525..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/ConsoleHandlerTest.java +++ /dev/null @@ -1,685 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.logging.tests.java.util.logging; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargets; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; -import java.security.Permission; -import java.util.Currency; -import java.util.Properties; -import java.util.logging.ConsoleHandler; -import java.util.logging.Filter; -import java.util.logging.Formatter; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogManager; -import java.util.logging.LogRecord; -import java.util.logging.LoggingPermission; -import java.util.logging.SimpleFormatter; - -import junit.framework.TestCase; - -import org.apache.harmony.logging.tests.java.util.logging.util.EnvironmentHelper; - -import tests.util.CallVerificationStack; - -/** - * Test class java.util.logging.ConsoleHandler - */ -@TestTargetClass(ConsoleHandler.class) -public class ConsoleHandlerTest extends TestCase { - - private final static String INVALID_LEVEL = "impossible_level"; - - private final PrintStream err = System.err; - - private OutputStream errSubstituteStream = null; - - private static String className = ConsoleHandlerTest.class.getName(); - - /* - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - errSubstituteStream = new MockOutputStream(); - System.setErr(new PrintStream(errSubstituteStream)); - LogManager.getLogManager().reset(); - } - - /* - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - LogManager.getLogManager().reset(); - CallVerificationStack.getInstance().clear(); - System.setErr(err); - } - - /* - * Test the constructor with no relevant log manager properties are set. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with no relevant log manager properties are set.", - method = "ConsoleHandler", - args = {} - ) - public void testConstructor_NoProperties() { - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.ConsoleHandler.level")); - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.ConsoleHandler.filter")); - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.ConsoleHandler.formatter")); - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.ConsoleHandler.encoding")); - - ConsoleHandler h = new ConsoleHandler(); - assertSame(h.getLevel(), Level.INFO); - assertTrue(h.getFormatter() instanceof SimpleFormatter); - assertNull(h.getFilter()); - assertSame(h.getEncoding(), null); - } - - /* - * Test the constructor with insufficient privilege. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with insufficient privilege.", - method = "ConsoleHandler", - args = {} - ) - public void testConstructor_InsufficientPrivilege() { - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.ConsoleHandler.level")); - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.ConsoleHandler.filter")); - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.ConsoleHandler.formatter")); - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.ConsoleHandler.encoding")); - - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - // set a normal value - try { - ConsoleHandler h = new ConsoleHandler(); - assertSame(h.getLevel(), Level.INFO); - assertTrue(h.getFormatter() instanceof SimpleFormatter); - assertNull(h.getFilter()); - assertSame(h.getEncoding(), null); - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test the constructor with valid relevant log manager properties are set. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with valid relevant log manager properties are set.", - method = "ConsoleHandler", - args = {} - ) - public void testConstructor_ValidProperties() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.ConsoleHandler.level", "FINE"); - p.put("java.util.logging.ConsoleHandler.filter", className - + "$MockFilter"); - p.put("java.util.logging.ConsoleHandler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.ConsoleHandler.encoding", "iso-8859-1"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - assertEquals(LogManager.getLogManager().getProperty( - "java.util.logging.ConsoleHandler.level"), "FINE"); - assertEquals(LogManager.getLogManager().getProperty( - "java.util.logging.ConsoleHandler.encoding"), "iso-8859-1"); - ConsoleHandler h = new ConsoleHandler(); - assertSame(h.getLevel(), Level.parse("FINE")); - assertTrue(h.getFormatter() instanceof MockFormatter); - assertTrue(h.getFilter() instanceof MockFilter); - assertEquals(h.getEncoding(), "iso-8859-1"); - } - - /* - * Test the constructor with invalid relevant log manager properties are - * set. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with invalid relevant log manager properties are set.", - method = "ConsoleHandler", - args = {} - ) - public void testConstructor_InvalidProperties() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.ConsoleHandler.level", INVALID_LEVEL); - p.put("java.util.logging.ConsoleHandler.filter", className); - p.put("java.util.logging.ConsoleHandler.formatter", className); - p.put("java.util.logging.ConsoleHandler.encoding", "XXXX"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - assertEquals(LogManager.getLogManager().getProperty( - "java.util.logging.ConsoleHandler.level"), INVALID_LEVEL); - assertEquals(LogManager.getLogManager().getProperty( - "java.util.logging.ConsoleHandler.encoding"), "XXXX"); - ConsoleHandler h = new ConsoleHandler(); - assertSame(h.getLevel(), Level.INFO); - assertTrue(h.getFormatter() instanceof SimpleFormatter); - assertNull(h.getFilter()); - assertNull(h.getEncoding()); - h.publish(new LogRecord(Level.SEVERE, "test")); - assertNull(h.getEncoding()); - } - - /* - * Test close() when having sufficient privilege, and a record has been - * written to the output stream. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies close() when having sufficient privilege, and a record has been written to the output stream.", - method = "close", - args = {} - ) - public void testClose_SufficientPrivilege_NormalClose() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.ConsoleHandler.formatter", className - + "$MockFormatter"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - ConsoleHandler h = new ConsoleHandler(); - h.publish(new LogRecord(Level.SEVERE, - "testClose_SufficientPrivilege_NormalClose msg")); - h.close(); - assertEquals("flush", CallVerificationStack.getInstance() - .getCurrentSourceMethod()); - assertNull(CallVerificationStack.getInstance().pop()); - h.close(); - } - - /* - * Test close() when having sufficient privilege, and an output stream that - * always throws exceptions. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies close() when having sufficient privilege, and an output stream that always throws exceptions", - method = "close", - args = {} - ) - public void testClose_SufficientPrivilege_Exception() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.ConsoleHandler.formatter", className - + "$MockFormatter"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - ConsoleHandler h = new ConsoleHandler(); - - h.publish(new LogRecord(Level.SEVERE, - "testClose_SufficientPrivilege_Exception msg")); - h.flush(); - h.close(); - } - - /* - * Test close() when having sufficient privilege, and no record has been - * written to the output stream. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks close() when having sufficient privilege, and no record has been written to the output stream", - method = "close", - args = {} - ) - public void testClose_SufficientPrivilege_DirectClose() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.ConsoleHandler.formatter", className - + "$MockFormatter"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - ConsoleHandler h = new ConsoleHandler(); - - h.close(); - assertEquals("flush", CallVerificationStack.getInstance() - .getCurrentSourceMethod()); - assertNull(CallVerificationStack.getInstance().pop()); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test close() when having insufficient privilege. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies close() when insufficient privilege is set up.", - method = "close", - args = {} - ) - public void testClose_InsufficientPrivilege() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.ConsoleHandler.formatter", className - + "$MockFormatter"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - ConsoleHandler h = new ConsoleHandler(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - try { - h.close(); - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test publish(), use no filter, having output stream, normal log record. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish(), use no filter, having output stream, normal log record.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_NoFilter() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.ConsoleHandler.formatter", className - + "$MockFormatter"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - ConsoleHandler h = new ConsoleHandler(); - - LogRecord r = new LogRecord(Level.INFO, "testPublish_NoFilter"); - h.setLevel(Level.INFO); - h.publish(r); - h.flush(); - assertEquals("MockFormatter_Head" + "testPublish_NoFilter", - this.errSubstituteStream.toString()); - - h.setLevel(Level.WARNING); - h.publish(r); - h.flush(); - assertEquals("MockFormatter_Head" + "testPublish_NoFilter", - this.errSubstituteStream.toString()); - - h.setLevel(Level.CONFIG); - h.publish(r); - h.flush(); - assertEquals("MockFormatter_Head" + "testPublish_NoFilter" - + "testPublish_NoFilter", this.errSubstituteStream.toString()); - - r.setLevel(Level.OFF); - h.setLevel(Level.OFF); - h.publish(r); - h.flush(); - assertEquals("MockFormatter_Head" + "testPublish_NoFilter" - + "testPublish_NoFilter", this.errSubstituteStream.toString()); - } - - /* - * Test publish(), after system err is reset. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish(), after system err is reset.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_AfterResetSystemErr() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.ConsoleHandler.formatter", className - + "$MockFormatter"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - ConsoleHandler h = new ConsoleHandler(); - h.setFilter(new MockFilter()); - - System.setErr(new PrintStream(new ByteArrayOutputStream())); - - LogRecord r = new LogRecord(Level.INFO, "testPublish_WithFilter"); - h.setLevel(Level.INFO); - h.publish(r); - assertNull(CallVerificationStack.getInstance().pop()); - assertSame(r, CallVerificationStack.getInstance().pop()); - assertEquals("", this.errSubstituteStream.toString()); - } - - /* - * Test publish(), use a filter, having output stream, normal log record. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish(), use a filter, having output stream, normal log record.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_WithFilter() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.ConsoleHandler.formatter", className - + "$MockFormatter"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - ConsoleHandler h = new ConsoleHandler(); - h.setFilter(new MockFilter()); - - LogRecord r = new LogRecord(Level.INFO, "testPublish_WithFilter"); - h.setLevel(Level.INFO); - h.publish(r); - assertNull(CallVerificationStack.getInstance().pop()); - assertSame(r, CallVerificationStack.getInstance().pop()); - assertEquals("", this.errSubstituteStream.toString()); - - h.setLevel(Level.WARNING); - h.publish(r); - assertNull(CallVerificationStack.getInstance().pop()); - assertTrue(CallVerificationStack.getInstance().empty()); - assertEquals("", this.errSubstituteStream.toString()); - - h.setLevel(Level.CONFIG); - h.publish(r); - assertNull(CallVerificationStack.getInstance().pop()); - assertSame(r, CallVerificationStack.getInstance().pop()); - assertEquals("", this.errSubstituteStream.toString()); - - r.setLevel(Level.OFF); - h.setLevel(Level.OFF); - h.publish(r); - assertNull(CallVerificationStack.getInstance().pop()); - assertEquals("", this.errSubstituteStream.toString()); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test publish(), null log record, having output stream, spec said - * rather than throw exception, handler should call errormanager to handle - * exception case, so NullPointerException shouldn't be thrown. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish(), null log record, having output stream, spec said rather than throw exception, handler should call errormanager to handle exception case, so NullPointerException shouldn't be thrown.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_Null() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.ConsoleHandler.formatter", className - + "$MockFormatter"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - ConsoleHandler h = new ConsoleHandler(); - h.publish(null); - } - - /* - * Test publish(), a log record with empty msg, having output stream - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish(), a log record with empty msg, having output stream.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_EmptyMsg() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.ConsoleHandler.formatter", className - + "$MockFormatter"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - ConsoleHandler h = new ConsoleHandler(); - LogRecord r = new LogRecord(Level.INFO, ""); - h.publish(r); - h.flush(); - assertEquals("MockFormatter_Head", this.errSubstituteStream.toString()); - } - - /* - * Test publish(), a log record with null msg, having output stream - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish(), a log record with null msg, having output stream.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_NullMsg() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.ConsoleHandler.formatter", className - + "$MockFormatter"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - ConsoleHandler h = new ConsoleHandler(); - LogRecord r = new LogRecord(Level.INFO, null); - h.publish(r); - h.flush(); - // assertEquals("MockFormatter_Head", - // this.errSubstituteStream.toString()); - } - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish method after close.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_AfterClose() throws Exception { - PrintStream backup = System.err; - try { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - System.setErr(new PrintStream(bos)); - Properties p = new Properties(); - p.put("java.util.logging.ConsoleHandler.level", "FINE"); - p.put("java.util.logging.ConsoleHandler.formatter", className - + "$MockFormatter"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - ConsoleHandler h = new ConsoleHandler(); - assertSame(h.getLevel(), Level.FINE); - LogRecord r1 = new LogRecord(Level.INFO, "testPublish_Record1"); - LogRecord r2 = new LogRecord(Level.INFO, "testPublish_Record2"); - assertTrue(h.isLoggable(r1)); - h.publish(r1); - assertTrue(bos.toString().indexOf("testPublish_Record1") >= 0); - h.close(); - // assertFalse(h.isLoggable(r)); - assertTrue(h.isLoggable(r2)); - h.publish(r2); - assertTrue(bos.toString().indexOf("testPublish_Record2") >= 0); - h.flush(); - // assertEquals("MockFormatter_Head", - // this.errSubstituteStream.toString()); - } catch (IOException e) { - e.printStackTrace(); - } finally { - System.setErr(backup); - } - } - - /* - * Test setOutputStream() under normal condition. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Verifies setOutputStream() under normal condition.", - method = "setOutputStream", - args = {java.io.OutputStream.class} - ) - public void testSetOutputStream_Normal() { - MockStreamHandler h = new MockStreamHandler(); - h.setFormatter(new MockFormatter()); - - LogRecord r = new LogRecord(Level.INFO, "testSetOutputStream_Normal"); - h.publish(r); - assertNull(CallVerificationStack.getInstance().pop()); - assertSame(r, CallVerificationStack.getInstance().pop()); - assertTrue(CallVerificationStack.getInstance().empty()); - assertEquals("MockFormatter_Head" + "testSetOutputStream_Normal", - this.errSubstituteStream.toString()); - - ByteArrayOutputStream aos2 = new ByteArrayOutputStream(); - h.setOutputStream(aos2); - - // assertEquals("close", DelegationParameterStack.getInstance() - // .getCurrentSourceMethod()); - // assertNull(DelegationParameterStack.getInstance().pop()); - // assertEquals("flush", DelegationParameterStack.getInstance() - // .getCurrentSourceMethod()); - // assertNull(DelegationParameterStack.getInstance().pop()); - // assertEquals("MockFormatter_Head" + "testSetOutputStream_Normal" - // + "MockFormatter_Tail", this.errSubstituteStream.toString()); - // r = new LogRecord(Level.INFO, "testSetOutputStream_Normal2"); - // h.publish(r); - // assertSame(r, DelegationParameterStack.getInstance().pop()); - // assertTrue(DelegationParameterStack.getInstance().empty()); - // assertEquals("MockFormatter_Head" + "testSetOutputStream_Normal2", - // aos2 - // .toString()); - // assertEquals("MockFormatter_Head" + "testSetOutputStream_Normal" - // + "MockFormatter_Tail", this.errSubstituteStream.toString()); - } - - /* - * A mock filter, always return false. - */ - public static class MockFilter implements Filter { - - public boolean isLoggable(LogRecord record) { - CallVerificationStack.getInstance().push(record); - // System.out.println("filter called..."); - return false; - } - } - - /* - * A mock formatter. - */ - public static class MockFormatter extends Formatter { - public String format(LogRecord r) { - // System.out.println("formatter called..."); - return super.formatMessage(r); - } - - /* - * (non-Javadoc) - * - * @see java.util.logging.Formatter#getHead(java.util.logging.Handler) - */ - public String getHead(Handler h) { - return "MockFormatter_Head"; - } - - /* - * (non-Javadoc) - * - * @see java.util.logging.Formatter#getTail(java.util.logging.Handler) - */ - public String getTail(Handler h) { - return "MockFormatter_Tail"; - } - } - - /* - * A mock output stream. - */ - public static class MockOutputStream extends ByteArrayOutputStream { - - /* - * (non-Javadoc) - * - * @see java.io.OutputStream#close() - */ - public void close() throws IOException { - CallVerificationStack.getInstance().push(null); - super.close(); - } - - /* - * (non-Javadoc) - * - * @see java.io.OutputStream#flush() - */ - public void flush() throws IOException { - CallVerificationStack.getInstance().push(null); - super.flush(); - } - - /* - * (non-Javadoc) - * - * @see java.io.OutputStream#write(int) - */ - public void write(int oneByte) { - // TODO Auto-generated method stub - super.write(oneByte); - } - } - - /* - * Used to grant all permissions except logging control. - */ - public static class MockSecurityManager extends SecurityManager { - - public MockSecurityManager() { - } - - public void checkPermission(Permission perm) { - // grant all permissions except logging control - if (perm instanceof LoggingPermission) { - throw new SecurityException(); - } - } - - public void checkPermission(Permission perm, Object context) { - // grant all permissions except logging control - if (perm instanceof LoggingPermission) { - throw new SecurityException(); - } - } - } - - /* - * A mock stream handler, expose setOutputStream. - */ - public static class MockStreamHandler extends ConsoleHandler { - public MockStreamHandler() { - super(); - } - - public void setOutputStream(OutputStream out) { - super.setOutputStream(out); - } - - public boolean isLoggable(LogRecord r) { - CallVerificationStack.getInstance().push(r); - return super.isLoggable(r); - } - } - -} diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/ErrorManagerTest.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/ErrorManagerTest.java deleted file mode 100644 index 318535171..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/ErrorManagerTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.logging.tests.java.util.logging; - -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import junit.framework.TestCase; - -import org.apache.harmony.logging.tests.java.util.logging.HandlerTest.NullOutputStream; - -import java.io.ByteArrayOutputStream; -import java.io.OutputStream; -import java.io.PrintStream; -import java.util.logging.ErrorManager; - -@TestTargetClass(ErrorManager.class) -public class ErrorManagerTest extends TestCase { - - - private final PrintStream err = System.err; - private final PrintStream out = System.out; - - private OutputStream errSubstituteStream = null; - - public void setUp() throws Exception{ - super.setUp(); - errSubstituteStream = new NullOutputStream(); - System.setErr(new PrintStream(errSubstituteStream)); - } - - public void tearDown() throws Exception{ - System.setErr(err); - System.setOut(out); - super.tearDown(); - } - - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies positive case only with ErrorManager.GENERIC_FAILURE, impove MockStream", - method = "error", - args = {java.lang.String.class, java.lang.Exception.class, int.class} - ) - public void test_errorCheck() { - ErrorManager em = new ErrorManager(); - MockStream aos = new MockStream(); - PrintStream st = new PrintStream(aos); - System.setErr(st); - System.setOut(st); - em.error("supertest", null, ErrorManager.GENERIC_FAILURE); - st.flush(); - - assertTrue("message appears (supertest)", aos.getWrittenData().indexOf("supertest") != -1); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies positive case only with ErrorManager.GENERIC_FAILURE", - method = "error", - args = {java.lang.String.class, java.lang.Exception.class, int.class} - ) - public void test_errorStringStringint() { - ErrorManager em = new ErrorManager(); - em.error(null, new NullPointerException(), - ErrorManager.GENERIC_FAILURE); - em.error("An error message.", null, ErrorManager.GENERIC_FAILURE); - em.error(null, null, ErrorManager.GENERIC_FAILURE); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "ErrorManager", - args = {} - ) - public void test_constants() { - assertEquals(3, ErrorManager.CLOSE_FAILURE); - assertEquals(2, ErrorManager.FLUSH_FAILURE); - assertEquals(5, ErrorManager.FORMAT_FAILURE); - assertEquals(0, ErrorManager.GENERIC_FAILURE); - assertEquals(4, ErrorManager.OPEN_FAILURE); - assertEquals(1, ErrorManager.WRITE_FAILURE); - } - - public class MockStream extends ByteArrayOutputStream { - - private StringBuffer linesWritten = new StringBuffer(); - - public void flush() {} - public void close() {} - - @Override - public void write(byte[] buffer) { - linesWritten.append(new String(buffer)); - } - - @Override - public synchronized void write(byte[] buffer, int offset, int len) { - linesWritten.append(new String(buffer, offset, len)); - } - - public String getWrittenData() {return linesWritten.toString();} - - } - - -} diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java deleted file mode 100644 index 3ff1fc920..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java +++ /dev/null @@ -1,1176 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.logging.tests.java.util.logging; - -import dalvik.annotation.AndroidOnly; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.io.BufferedReader; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FilePermission; -import java.io.FileReader; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; -import java.io.Reader; -import java.io.StringWriter; -import java.security.Permission; -import java.util.Properties; -import java.util.logging.FileHandler; -import java.util.logging.Filter; -import java.util.logging.Formatter; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogManager; -import java.util.logging.LogRecord; -import java.util.logging.LoggingPermission; -import java.util.logging.XMLFormatter; - -import junit.framework.TestCase; - -import org.apache.harmony.logging.tests.java.util.logging.HandlerTest.NullOutputStream; -import org.apache.harmony.logging.tests.java.util.logging.util.EnvironmentHelper; - -/** - */ -@TestTargetClass(FileHandler.class) -public class FileHandlerTest extends TestCase { - - static LogManager manager = LogManager.getLogManager(); - - final static Properties props = new Properties(); - - final static String className = FileHandlerTest.class.getName(); - - final static StringWriter writer = new StringWriter(); - - final static SecurityManager securityManager = new MockLogSecurityManager(); - - final static String SEP = File.separator; - - private String oldHomePath = System.getProperty("user.home"); - - // The HOMEPATH can't be used in android. - final static String HOMEPATH = System.getProperty("java.io.tmpdir") + SEP + "home"; - - final static String TEMPPATH = System.getProperty("java.io.tmpdir"); - - private final PrintStream err = System.err; - - private OutputStream errSubstituteStream = null; - - FileHandler handler; - - LogRecord r; - - /* - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - manager.reset(); - - //initProp - props.clear(); - props.put("java.util.logging.FileHandler.level", "FINE"); - props.put("java.util.logging.FileHandler.filter", className - + "$MockFilter"); - props.put("java.util.logging.FileHandler.formatter", className - + "$MockFormatter"); - props.put("java.util.logging.FileHandler.encoding", "iso-8859-1"); - // limit to only two message - props.put("java.util.logging.FileHandler.limit", "1000"); - // rotation count is 2 - props.put("java.util.logging.FileHandler.count", "2"); - // using append mode - props.put("java.util.logging.FileHandler.append", "true"); - props.put("java.util.logging.FileHandler.pattern", - "%t/log/java%u.test"); - - File home = new File(HOMEPATH); - if (!home.exists()) { - home.mkdirs(); - } else if (!home.isDirectory()) { - home.delete(); - home.mkdirs(); - } - if(!home.isDirectory()) { - fail("unable to create temp path"); - } - System.setProperty("user.home", HOMEPATH); - - File file = new File(TEMPPATH + SEP + "log"); - file.mkdir(); - manager.readConfiguration(EnvironmentHelper - .PropertiesToInputStream(props)); - handler = new FileHandler(); - r = new LogRecord(Level.CONFIG, "msg"); - errSubstituteStream = new NullOutputStream(); - System.setErr(new PrintStream(errSubstituteStream)); - } - - - /* - * @see TestCase#tearDown() - */ - - protected void tearDown() throws Exception { - if (null != handler) { - handler.close(); - } - reset(TEMPPATH + SEP + "log", ""); - System.setErr(err); - System.setProperty("user.home", oldHomePath); - new File(HOMEPATH).delete(); - super.tearDown(); - } - - /* - * test for constructor void FileHandler() - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Doesn't verify exceptions.", - method = "FileHandler", - args = {} - ) - public void testFileHandler() throws Exception { - assertEquals("character encoding is non equal to actual value", - "iso-8859-1", handler.getEncoding()); - assertNotNull("Filter is null", handler.getFilter()); - assertNotNull("Formatter is null", handler.getFormatter()); - assertEquals("is non equal to actual value", Level.FINE, handler - .getLevel()); - assertNotNull("ErrorManager is null", handler.getErrorManager()); - handler.publish(r); - handler.close(); - // output 3 times, and all records left - // append mode is true - for (int i = 0; i < 3; i++) { - handler = new FileHandler(); - handler.publish(r); - handler.close(); - } - assertFileContent(TEMPPATH + SEP + "log", "java0.test.0", - new LogRecord[] { r, null, r, null, r, null, r }, - new MockFormatter()); - } - - /* - * test for constructor void FileHandler(String) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Doesn't verify security exception.", - method = "FileHandler", - args = {java.lang.String.class} - ) - public void testFileHandler_1params() throws Exception { - - handler = new FileHandler("%t/log/string"); - assertEquals("character encoding is non equal to actual value", - "iso-8859-1", handler.getEncoding()); - assertNotNull("Filter is null", handler.getFilter()); - assertNotNull("Formatter is null", handler.getFormatter()); - assertEquals("is non equal to actual value", Level.FINE, handler - .getLevel()); - assertNotNull("ErrorManager is null", handler.getErrorManager()); - handler.publish(r); - handler.close(); - - // output 3 times, and all records left - // append mode is true - for (int i = 0; i < 3; i++) { - handler = new FileHandler("%t/log/string"); - handler.publish(r); - handler.close(); - } - assertFileContent(TEMPPATH + SEP + "log", "/string", new LogRecord[] { - r, null, r, null, r, null, r }, new MockFormatter()); - - // test if unique ids not specified, it will append at the end - // no generation number is used - FileHandler h = new FileHandler("%t/log/string"); - FileHandler h2 = new FileHandler("%t/log/string"); - FileHandler h3 = new FileHandler("%t/log/string"); - FileHandler h4 = new FileHandler("%t/log/string"); - h.publish(r); - h2.publish(r); - h3.publish(r); - h4.publish(r); - h.close(); - h2.close(); - h3.close(); - h4.close(); - assertFileContent(TEMPPATH + SEP + "log", "string", h.getFormatter()); - assertFileContent(TEMPPATH + SEP + "log", "string.1", h.getFormatter()); - assertFileContent(TEMPPATH + SEP + "log", "string.2", h.getFormatter()); - assertFileContent(TEMPPATH + SEP + "log", "string.3", h.getFormatter()); - - // default is append mode - FileHandler h6 = new FileHandler("%t/log/string%u.log"); - h6.publish(r); - h6.close(); - FileHandler h7 = new FileHandler("%t/log/string%u.log"); - h7.publish(r); - h7.close(); - try { - assertFileContent(TEMPPATH + SEP + "log", "string0.log", h - .getFormatter()); - fail("should assertion failed"); - } catch (Error e) { - } - File file = new File(TEMPPATH + SEP + "log"); - assertTrue("length list of file is incorrect", file.list().length <= 2); - - // test unique ids - FileHandler h8 = new FileHandler("%t/log/%ustring%u.log"); - h8.publish(r); - FileHandler h9 = new FileHandler("%t/log/%ustring%u.log"); - h9.publish(r); - h9.close(); - h8.close(); - assertFileContent(TEMPPATH + SEP + "log", "0string0.log", h - .getFormatter()); - assertFileContent(TEMPPATH + SEP + "log", "1string1.log", h - .getFormatter()); - file = new File(TEMPPATH + SEP + "log"); - assertTrue("length list of file is incorrect", file.list().length <= 2); - - try { - new FileHandler(""); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException e) { - //expected - } - } - - /* - * test for constructor void FileHandler(String pattern, boolean append) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Doesn't verify security exception.", - method = "FileHandler", - args = {java.lang.String.class, boolean.class} - ) - public void testFileHandler_2params() throws Exception { - boolean append = false; - do { - append = !append; - handler = new FileHandler("%t/log/string", append); - assertEquals("character encoding is non equal to actual value", - "iso-8859-1", handler.getEncoding()); - assertNotNull("Filter is null", handler.getFilter()); - assertNotNull("Formatter is null", handler.getFormatter()); - assertEquals("is non equal to actual value", Level.FINE, handler - .getLevel()); - assertNotNull("ErrorManager is null", handler.getErrorManager()); - handler.publish(r); - handler.close(); - // output 3 times, and all records left - // append mode is true - for (int i = 0; i < 3; i++) { - handler = new FileHandler("%t/log/string", append); - handler.publish(r); - handler.close(); - } - if (append) { - assertFileContent(TEMPPATH + SEP + "log", "/string", - new LogRecord[] { r, null, r, null, r, null, r }, - new MockFormatter()); - } else { - assertFileContent(TEMPPATH + SEP + "log", "/string", - new LogRecord[] { r }, new MockFormatter()); - } - } while (append); - - try { - new FileHandler("", true); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException e) { - //expected - } - } - - /* - * test for constructor void FileHandler(String pattern, int limit, int - * count) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Doesn't verifysecurity exception.", - method = "FileHandler", - args = {java.lang.String.class, int.class, int.class} - ) - public void testFileHandler_3params() throws Exception { - int limit = 120; - int count = 1; - handler = new FileHandler("%t/log/string", limit, count); - assertEquals("character encoding is non equal to actual value", - "iso-8859-1", handler.getEncoding()); - assertNotNull("Filter is null", handler.getFilter()); - assertNotNull("Formatter is null", handler.getFormatter()); - assertEquals("is non equal to actual value", Level.FINE, handler - .getLevel()); - assertNotNull("ErrorManager is null", handler.getErrorManager()); - handler.publish(r); - handler.close(); - // output 3 times, and all records left - // append mode is true - for (int i = 0; i < 3; i++) { - handler = new FileHandler("%t/log/string", limit, count); - handler.publish(r); - handler.close(); - } - assertFileContent(TEMPPATH + SEP + "log", "/string", new LogRecord[] { - r, null, r, null, r, null, r }, new MockFormatter()); - - try { - new FileHandler("", limit, count); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException e) { - //expected - } - - try { - new FileHandler("%t/log/string", -1, count); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException e) { - //expected - } - - try { - new FileHandler("%t/log/string", limit, 0); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException e) { - //expected - } - } - - /* - * test for constructor public FileHandler(String pattern, int limit, int - * count, boolean append) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Doesn't verify security exception.", - method = "FileHandler", - args = {java.lang.String.class, int.class, int.class, boolean.class} - ) - public void testFileHandler_4params() throws Exception { - int limit = 120; - int count = 1; - boolean append = false; - do { - append = !append; - handler = new FileHandler("%t/log/string", limit, count, append); - assertEquals("character encoding is non equal to actual value", - "iso-8859-1", handler.getEncoding()); - assertNotNull("Filter is null", handler.getFilter()); - assertNotNull("Formatter is null", handler.getFormatter()); - assertEquals("is non equal to actual value", Level.FINE, handler - .getLevel()); - assertNotNull("ErrorManager is null", handler.getErrorManager()); - handler.publish(r); - handler.close(); - // output 3 times, and all records left - // append mode is true - for (int i = 0; i < 3; i++) { - handler = new FileHandler("%t/log/string", limit, count, append); - handler.publish(r); - handler.close(); - } - if (append) { - assertFileContent(TEMPPATH + SEP + "log", "/string", - new LogRecord[] { r, null, r, null, r, null, r }, - new MockFormatter()); - } else { - assertFileContent(TEMPPATH + SEP + "log", "/string", - new LogRecord[] { r }, new MockFormatter()); - } - } while (append); - - try { - new FileHandler("", limit, count, true); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException e) { - //expected - } - - try { - new FileHandler("%t/log/string", -1, count, false); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException e) { - //expected - } - - try { - new FileHandler("%t/log/string", limit, 0, true); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException e) { - //expected - } - } - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getEncoding", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getFilter", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getFormatter", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getLevel", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getErrorManager", - args = {} - ) - }) - public void testDefaultValue() throws Exception { - handler.publish(r); - handler.close(); - props.clear(); - manager.readConfiguration(EnvironmentHelper - .PropertiesToInputStream(props)); - handler = new FileHandler(); - assertNull(handler.getEncoding()); - assertNull(handler.getFilter()); - assertTrue(handler.getFormatter() instanceof XMLFormatter); - assertEquals(handler.getLevel(), Level.ALL); - assertNotNull(handler.getErrorManager()); - handler.publish(r); - handler.close(); - // output 3 times, and only one record left - // default append mode is false - for (int i = 0; i < 3; i++) { - handler = new FileHandler(); - handler.publish(r); - handler.close(); - } - assertFileContent(HOMEPATH, "java0.log", new XMLFormatter()); - } - - private void assertFileContent(String homepath, String filename, - Formatter formatter) throws Exception { - assertFileContent(homepath, filename, new LogRecord[] { r }, formatter); - } - - private void assertFileContent(String homepath, String filename, - LogRecord[] lr, Formatter formatter) throws Exception { - handler.close(); - String msg = ""; - // if formatter is null, the file content should be empty - // else the message should be formatted given records - if (null != formatter) { - StringBuffer sb = new StringBuffer(); - sb.append(formatter.getHead(handler)); - for (int i = 0; i < lr.length; i++) { - if (null == lr[i] && i < lr.length - 1) { - // if one record is null and is not the last record, means - // here is - // output completion point, should output tail, then output - // head - // (ready for next output) - sb.append(formatter.getTail(handler)); - sb.append(formatter.getHead(handler)); - } else { - sb.append(formatter.format(lr[i])); - } - } - sb.append(formatter.getTail(handler)); - msg = sb.toString(); - } - char[] chars = new char[msg.length()]; - Reader reader = null; - try { - reader = new BufferedReader(new FileReader(homepath + SEP - + filename)); - reader.read(chars); - assertEquals(msg, new String(chars)); - // assert has reached the end of the file - assertEquals(-1, reader.read()); - } finally { - try { - if (reader != null) { - reader.close(); - } - } catch (Exception e) { - // don't care - } - reset(homepath, filename); - } - } - - /** - * Does a cleanup of given file - * - * @param homepath - * @param filename - */ - private void reset(String homepath, String filename) { - File file = null; - try { - file = new File(homepath + SEP + filename); - if (file.isFile()) { - file.delete(); - } else if (file.isDirectory()) { - File[] files = file.listFiles(); - for (int i = 0; i < files.length; i++) { - files[i].delete(); - } - file.delete(); - } - } catch (Exception e) { - e.printStackTrace(); - } - try { - file = new File(homepath + SEP + filename + ".lck"); - file.delete(); - } catch (Exception e) { - e.printStackTrace(); - } - } - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "FileHandler", - args = {java.lang.String.class, int.class, int.class, boolean.class} - ) - public void testLimitAndCount() throws Exception { - handler.close(); - // very small limit value, count=2 - // output, rename current output file to the second generation file - // close it and open a new file as rotation output - handler = new FileHandler("%t/testLimitCount%g", 1, 2, false); - handler.publish(r); - handler.close(); - assertFileContent(TEMPPATH, "testLimitCount1", handler.getFormatter()); - - // very small limit value, count=1 - // output once, rotate(equals to nothing output) - handler = new FileHandler("%t/testLimitCount%g", 1, 1, false); - handler.publish(r); - handler.close(); - assertFileContent(TEMPPATH, "testLimitCount0", new LogRecord[0], - handler.getFormatter()); - - // normal case, limit is 60(>2*msg length <3*msg length), append is - // false - handler = new FileHandler("%t/testLimitCount%u", 60, 3, false); - LogRecord[] rs = new LogRecord[10]; - // batch output twice to test the append mode - for (int i = 0; i < 5; i++) { - rs[i] = new LogRecord(Level.SEVERE, "msg" + i); - handler.publish(rs[i]); - } - handler.close(); - handler = new FileHandler("%t/testLimitCount%u", 60, 3, false); - for (int i = 5; i < 10; i++) { - rs[i] = new LogRecord(Level.SEVERE, "msg" + i); - handler.publish(rs[i]); - } - - assertFileContent(TEMPPATH, "testLimitCount0.1", new LogRecord[] { - rs[5], rs[6], rs[7] }, handler.getFormatter()); - assertFileContent(TEMPPATH, "testLimitCount0.0", new LogRecord[] { - rs[8], rs[9] }, handler.getFormatter()); - - // normal case, limit is 60(>2*msg length <3*msg length), append is true - handler = new FileHandler("%t/testLimitCount%u", 60, 3, false); - // batch output twice to test the append mode - for (int i = 0; i < 5; i++) { - rs[i] = new LogRecord(Level.SEVERE, "msg" + i); - handler.publish(rs[i]); - } - handler.close(); - handler = new FileHandler("%t/testLimitCount%u", 60, 3, true); - for (int i = 5; i < 10; i++) { - rs[i] = new LogRecord(Level.SEVERE, "msg" + i); - handler.publish(rs[i]); - } - handler.close(); - assertFileContent(TEMPPATH, "testLimitCount0.2", new LogRecord[] { - rs[3], rs[4], null, rs[5] }, handler.getFormatter()); - assertFileContent(TEMPPATH, "testLimitCount0.1", new LogRecord[] { - rs[6], rs[7], rs[8] }, handler.getFormatter()); - assertFileContent(TEMPPATH, "testLimitCount0.0", - new LogRecord[] { rs[9] }, handler.getFormatter()); - - String oldUserDir = System.getProperty("user.dir"); - System.setProperty("user.dir", System.getProperty("java.io.tmpdir")); - FileHandler h1 = null; - FileHandler h2 = null; - try { - File logDir = new File("log"); - reset("log", ""); - logDir.mkdir(); - h1 = new FileHandler("log/a", 0, 1); - assertNotNull(h1); - h2 = new FileHandler("log/a", 0, 1, false); - assertNotNull(h2); - } finally { - try { - h1.close(); - } catch (Exception e) { - } - try { - h2.close(); - } catch (Exception e) { - } - reset("log", ""); - System.setProperty("user.dir", oldUserDir); - } - } - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "close", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "FileHandler", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "FileHandler", - args = {java.lang.String.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "FileHandler", - args = {java.lang.String.class, boolean.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "FileHandler", - args = {java.lang.String.class, int.class, int.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "FileHandler", - args = {java.lang.String.class, int.class, int.class, boolean.class} - ) - }) - public void testSecurity() throws IOException { - SecurityManager currentManager = System.getSecurityManager(); - - try { - System.setSecurityManager(new MockLogSecurityManager()); - try { - handler.close(); - fail("should throw security exception"); - } catch (SecurityException e) { - } - handler.publish(new LogRecord(Level.SEVERE, "msg")); - - try { - handler = new FileHandler(); - fail("should throw security exception"); - } catch (SecurityException e) { - } - - try { - handler = new FileHandler("pattern1"); - fail("should throw security exception"); - } catch (SecurityException e) { - } - try { - handler = new FileHandler("pattern2", true); - fail("should throw security exception"); - } catch (SecurityException e) { - } - try { - handler = new FileHandler("pattern3", 1000, 1); - fail("should throw security exception"); - } catch (SecurityException e) { - } - try { - handler = new FileHandler("pattern4", 1000, 1, true); - fail("should throw security exception"); - } catch (SecurityException e) { - } - } finally { - System.setSecurityManager(currentManager); - } - - } - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies SecurityException.", - method = "close", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies SecurityException.", - method = "FileHandler", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies SecurityException.", - method = "FileHandler", - args = {java.lang.String.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies SecurityException.", - method = "FileHandler", - args = {java.lang.String.class, boolean.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies SecurityException.", - method = "FileHandler", - args = {java.lang.String.class, int.class, int.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies SecurityException.", - method = "FileHandler", - args = {java.lang.String.class, int.class, int.class, boolean.class} - ) - }) - public void testFileSecurity() throws IOException { - SecurityManager currentManager = System.getSecurityManager(); - - try { - System.setSecurityManager(new MockFileSecurityManager()); - handler.publish(new LogRecord(Level.SEVERE, "msg")); - try { - handler.close(); - fail("should throw security exception"); - } catch (SecurityException e) { - } - - try { - handler = new FileHandler(); - fail("should throw security exception"); - } catch (SecurityException e) { - } - - try { - handler = new FileHandler("pattern1"); - fail("should throw security exception"); - } catch (SecurityException e) { - } - try { - handler = new FileHandler("pattern2", true); - fail("should throw security exception"); - } catch (SecurityException e) { - } - try { - handler = new FileHandler("pattern3", 1000, 1); - fail("should throw security exception"); - } catch (SecurityException e) { - } - try { - handler = new FileHandler("pattern4", 1000, 1, true); - fail("should throw security exception"); - } catch (SecurityException e) { - } - } finally { - System.setSecurityManager(currentManager); - } - } - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies FileHandler when configuration file is invalid.", - method = "FileHandler", - args = {} - ) - public void testInvalidProperty() throws Exception { - props.put("java.util.logging.FileHandler.level", "null"); - props.put("java.util.logging.FileHandler.filter", className - + "$MockFilte"); - props.put("java.util.logging.FileHandler.formatter", className - + "$MockFormatte"); - props.put("java.util.logging.FileHandler.encoding", "ut"); - // limit to only two message - props.put("java.util.logging.FileHandler.limit", "-1"); - // rotation count is 2 - props.put("java.util.logging.FileHandler.count", "-1"); - // using append mode - props.put("java.util.logging.FileHandler.append", "bad"); - - handler.close(); - - manager.readConfiguration(EnvironmentHelper - .PropertiesToInputStream(props)); - handler = new FileHandler(); - assertEquals(Level.ALL, handler.getLevel()); - assertNull(handler.getFilter()); - assertTrue(handler.getFormatter() instanceof XMLFormatter); - assertNull(handler.getEncoding()); - handler.close(); - - props.put("java.util.logging.FileHandler.pattern", ""); - manager.readConfiguration(EnvironmentHelper - .PropertiesToInputStream(props)); - try { - handler = new FileHandler(); - fail("shouldn't open file with empty name"); - } catch (NullPointerException e) { - } - } - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies illegal parameters and exceptions: IOException, NullPointerException, IllegalArgumentException.", - method = "FileHandler", - args = {java.lang.String.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies illegal parameters and exceptions: IOException, NullPointerException, IllegalArgumentException.", - method = "FileHandler", - args = {java.lang.String.class, boolean.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies illegal parameters and exceptions: IOException, NullPointerException, IllegalArgumentException.", - method = "FileHandler", - args = {java.lang.String.class, int.class, int.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies illegal parameters and exceptions: IOException, NullPointerException, IllegalArgumentException.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - }) - @AndroidOnly("This test fails on RI. Doesn't parse special pattern \"%t/%h.") - public void testInvalidParams() throws IOException { - - // %t and %p parsing can add file separator automatically - FileHandler h1 = new FileHandler("%taaa"); - h1.close(); - File file = new File(TEMPPATH + SEP + "aaa"); - assertTrue(file.exists()); - reset(TEMPPATH, "aaa"); - - h1 = new FileHandler("%t%g"); - h1.close(); - file = new File(TEMPPATH + SEP + "0"); - assertTrue(file.exists()); - reset(TEMPPATH, "0"); - h1 = new FileHandler("%t%u%g"); - h1.close(); - file = new File(TEMPPATH + SEP + "00"); - assertTrue(file.exists()); - reset(TEMPPATH, "00"); - - // this is normal case - h1 = new FileHandler("%t/%u%g%%g"); - h1.close(); - file = new File(TEMPPATH + SEP + "00%g"); - assertTrue(file.exists()); - reset(TEMPPATH, "00%g"); - - // multi separator has no effect - h1 = new FileHandler("//%t//multi%g"); - h1.close(); - file = new File(TEMPPATH + SEP + "multi0"); - assertTrue(file.exists()); - reset(TEMPPATH, "multi0"); - - // bad directory, IOException - try { - h1 = new FileHandler("%t/baddir/multi%g"); - fail("should throw IO exception"); - } catch (IOException e) { - } - file = new File(TEMPPATH + SEP + "baddir" + SEP + "multi0"); - assertFalse(file.exists()); - - // bad directory, IOException, append - try { - h1 = new FileHandler("%t/baddir/multi%g", true); - fail("should throw IO exception"); - } catch (IOException e) { - } - file = new File(TEMPPATH + SEP + "baddir" + SEP + "multi0"); - assertFalse(file.exists()); - try { - h1 = new FileHandler("%t/baddir/multi%g", false); - fail("should throw IO exception"); - } catch (IOException e) { - } - file = new File(TEMPPATH + SEP + "baddir" + SEP + "multi0"); - assertFalse(file.exists()); - - try { - h1 = new FileHandler("%t/baddir/multi%g", 12, 4); - fail("should throw IO exception"); - } catch (IOException e) { - } - file = new File(TEMPPATH + SEP + "baddir" + SEP + "multi0"); - assertFalse(file.exists()); - - try { - h1 = new FileHandler("%t/baddir/multi%g", 12, 4, true); - fail("should throw IO exception"); - } catch (IOException e) { - } - file = new File(TEMPPATH + SEP + "baddir" + SEP + "multi0"); - assertFalse(file.exists()); - - - try { - new FileHandler(null); - fail("should throw null exception"); - } catch (NullPointerException e) { - } - try { - handler.publish(null); - } catch (NullPointerException e) { - fail("should not throw NPE"); - } - try { - new FileHandler(null, false); - fail("should throw null exception"); - } catch (NullPointerException e) { - } - try { - new FileHandler(""); - fail("should throw IllegalArgumentException"); - } catch (IllegalArgumentException e) { - // expected - } - try { - new FileHandler("%t/java%u", 0, 0); - fail("should throw IllegalArgumentException"); - } catch (IllegalArgumentException e) { - } - try { - new FileHandler("%t/java%u", -1, 1); - fail("should throw IllegalArgumentException"); - } catch (IllegalArgumentException e) { - } - - try { - new FileHandler("%t/java%u", -1, -1); - fail("should throw IllegalArgumentException"); - } catch (IllegalArgumentException e) { - } - - // always parse special pattern - System.setProperty("user.home", "home"); - try { - h1 = new FileHandler("%t/%h.txt"); - } catch (Exception e) { - fail("Unexpected exception " + e.toString()); - } - } - - /* - * test for method public void publish(LogRecord record) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish() throws Exception { - LogRecord[] r = new LogRecord[] { new LogRecord(Level.CONFIG, "msg__"), - new LogRecord(Level.WARNING, "message"), - new LogRecord(Level.INFO, "message for"), - new LogRecord(Level.FINE, "message for test") }; - for (int i = 0; i < r.length; i++) { - handler = new FileHandler("%t/log/stringPublish"); - handler.publish(r[i]); - handler.close(); - assertFileContent(TEMPPATH + SEP + "log", "stringPublish", - new LogRecord[] { r[i] }, handler.getFormatter()); - } - } - - /* - * test for method public void close() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "close", - args = {} - ) - public void testClose() throws Exception { - FileHandler h = new FileHandler("%t/log/stringPublish"); - h.publish(r); - h.close(); - assertFileContent(TEMPPATH + SEP + "log", "stringPublish", h - .getFormatter()); - } - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Doesn't verify SecurityException.", - method = "setOutputStream", - args = {java.io.OutputStream.class} - ) - // set output stream still works, just like super StreamHandler - public void testSetOutputStream() throws Exception { - MockFileHandler handler = new MockFileHandler("%h/setoutput.log"); - handler.setFormatter(new MockFormatter()); - handler.publish(r); - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - handler.publicSetOutputStream(out); - handler.publish(r); - handler.close(); - String msg = new String(out.toByteArray()); - Formatter f = handler.getFormatter(); - assertEquals(msg, f.getHead(handler) + f.format(r) + f.getTail(handler)); - assertFileContent(HOMEPATH, "setoutput.log", handler.getFormatter()); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies IllegalArgumentException.", - method = "FileHandler", - args = {java.lang.String.class, int.class, int.class} - ) - public void testEmptyPattern_3params() throws SecurityException, - IOException { - try { - new FileHandler(new String(), 1, 1); - fail("Expected an IllegalArgumentException"); - } catch (IllegalArgumentException e) { - // Expected - } - } - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies IllegalArgumentException.", - method = "FileHandler", - args = {java.lang.String.class, boolean.class} - ) - public void testEmptyPattern_2params() throws SecurityException, - IOException { - try { - new FileHandler(new String(), true); - fail("Expected an IllegalArgumentException"); - } catch (IllegalArgumentException e) { - // Expected - } - } - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies IllegalArgumentException.", - method = "FileHandler", - args = {java.lang.String.class, int.class, int.class, boolean.class} - ) - public void testEmptyPattern_4params() throws SecurityException, - IOException { - try { - new FileHandler(new String(), 1, 1, true); - fail("Expected an IllegalArgumentException"); - } catch (IllegalArgumentException e) { - // Expected - } - } - - /* - * mock classes - */ - public static class MockFilter implements Filter { - public boolean isLoggable(LogRecord record) { - return !record.getMessage().equals("false"); - } - } - - public static class MockFormatter extends Formatter { - public String format(LogRecord r) { - if (null == r) { - return ""; - } - return r.getMessage() + " by MockFormatter\n"; - } - - public String getTail(Handler h) { - return "tail\n"; - } - - public String getHead(Handler h) { - return "head\n"; - } - } - - public static class MockLogSecurityManager extends SecurityManager { - public void checkPermission(Permission perm) { - if (perm instanceof LoggingPermission) { - throw new SecurityException(); - } - return; - } - } - - public static class MockFileSecurityManager extends SecurityManager { - public void checkPermission(Permission perm) { - if (perm instanceof FilePermission) { - throw new SecurityException(); - } - } - } - - public static class MockFileHandler extends FileHandler { - public MockFileHandler() throws IOException { - super(); - } - - public MockFileHandler(String pattern) throws IOException { - super(pattern); - } - - public void publicSetOutputStream(OutputStream stream) { - super.setOutputStream(stream); - } - } -} diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FilterTest.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FilterTest.java deleted file mode 100644 index d7ce84323..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FilterTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -//TODO : -/* - * 1. Don't forget to write tests for org.apache.harmony.logging.internal.nls/Messages.java this file is in logging/src/main/java folder - * 2. inrteface filter / LoggingMXBean tests machen - * 3. XMLFormatter.java should be finish for Monday (not a lot to do) but as I beginn want to finish. - * 3. In my case - * I didn't use the PARTIAL_OK, so I believe that 98% of COMPLETE are PARTIAL_OK - * COMPLETE = Tests finish and should be working. If error check the test before to make a ticket. - * PARTIAL = Tests finish, but need special reviewing - * TODO = A test to do (or not). Mostly a test to complete - * 4. For questions christian.wiederseiner - */ - -package org.apache.harmony.logging.tests.java.util.logging; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.util.logging.Filter; -import java.util.logging.LogRecord; - -import junit.framework.TestCase; - -/** - * This testcase verifies the signature of the interface Filter. - * - */ -@TestTargetClass(Filter.class) -public class FilterTest extends TestCase { - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Verifies interface.", - method = "isLoggable", - args = {java.util.logging.LogRecord.class} - ) - public void testFilter() { - MockFilter f = new MockFilter(); - assertFalse(f.isLoggable(null)); - } - - /* - * This inner class implements the interface Filter to verify the signature. - */ - private class MockFilter implements Filter { - - public boolean isLoggable(LogRecord record) { - return false; - } - } -} diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FormatterTest.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FormatterTest.java deleted file mode 100644 index ba2345d8a..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FormatterTest.java +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.logging.tests.java.util.logging; - -import dalvik.annotation.AndroidOnly; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestLevel; - -import java.io.File; -import java.text.MessageFormat; -import java.util.Locale; -import java.util.Properties; -import java.util.ResourceBundle; -import java.util.logging.FileHandler; -import java.util.logging.Formatter; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.logging.LogManager; -import java.util.logging.LogRecord; - -import junit.framework.TestCase; - -import org.apache.harmony.logging.tests.java.util.logging.util.EnvironmentHelper; - -@TestTargetClass(Formatter.class) -public class FormatterTest extends TestCase { - Formatter f; - - LogRecord r; - - FileHandler h; - - static String MSG = "msg, pls. ignore it"; - - static LogManager manager = LogManager.getLogManager(); - - final static Properties props = new Properties(); - - final static String className = FormatterTest.class.getName(); - - final static String TEMPPATH = System.getProperty("java.io.tmpdir"); - - final static String SEP = File.separator; - - /* - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - manager.reset(); - - //initProp - props.clear(); - props.put("java.util.logging.FileHandler.level", "FINE"); - props.put("java.util.logging.FileHandler.filter", className - + "$MockFilter"); - props.put("java.util.logging.FileHandler.formatter", className - + "$MockFormatter"); - props.put("java.util.logging.FileHandler.encoding", "iso-8859-1"); - // limit to only two message - props.put("java.util.logging.FileHandler.limit", "1000"); - // rotation count is 2 - props.put("java.util.logging.FileHandler.count", "2"); - // using append mode - props.put("java.util.logging.FileHandler.append", "true"); - props.put("java.util.logging.FileHandler.pattern", - "%t/log/java%u.test"); - - File file = new File(TEMPPATH + SEP + "log"); - file.mkdir(); - manager.readConfiguration(EnvironmentHelper - .PropertiesToInputStream(props)); - - f = new MockFormatter(); - r = new LogRecord(Level.FINE, MSG); - h = new FileHandler(); - } - - /* - * test for constructor protected Formatter() - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "Formatter", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getHead", - args = {java.util.logging.Handler.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getTail", - args = {java.util.logging.Handler.class} - ) - }) - public void testFormatter() { - assertEquals("head string is not empty", "", f.getHead(null)); - assertEquals("tail string is not empty", "", f.getTail(null)); - - } - - /* - * test for method public String getHead(Handler h) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getHead", - args = {Handler.class} - ) - public void testGetHead() { - assertEquals("head string is not empty", "", f.getHead(null)); - assertEquals("head string is not empty", "", f.getHead(h)); - h.publish(r); - assertEquals("head string is not empty", "", f.getHead(h)); - } - - /* - * test for method public String getTail(Handler h) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getTail", - args = {Handler.class} - ) - public void testGetTail() { - assertEquals("tail string is not empty", "", f.getTail(null)); - assertEquals("tail string is not empty", "", f.getTail(h)); - h.publish(r); - assertEquals("tail string is not empty", "", f.getTail(h)); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "formatMessage", - args = {LogRecord.class} - ) - @AndroidOnly("The RI fails in this test because it uses a MessageFormat " + - "to format the message even though it doesn't contain \"{0\". " + - "The spec says that this would indicate that a MessageFormat " + - "should be used and else no formatting should be done.") - public void testFormatMessage() { - assertEquals(MSG, f.formatMessage(r)); - - String pattern = "test formatter {0, number}"; - r.setMessage(pattern); - assertEquals(pattern, f.formatMessage(r)); - - Object[] oa = new Object[0]; - r.setParameters(oa); - assertEquals(pattern, f.formatMessage(r)); - - oa = new Object[] { new Integer(100), new Float(1.2), new Float(2.2) }; - r.setParameters(oa); - assertEquals(MessageFormat.format(pattern, oa), f.formatMessage(r)); - - r.setMessage(MSG); - assertEquals(MSG, f.formatMessage(r)); - - pattern = "wrong pattern {0, asdfasfd}"; - r.setMessage(pattern); - assertEquals(pattern, f.formatMessage(r)); - - pattern = null; - r.setMessage(pattern); - assertNull(f.formatMessage(r)); - - // The RI fails in this test because it uses a MessageFormat to format - // the message even though it doesn't contain "{0". The spec says that - // this would indicate that a MessageFormat should be used and else no - // formatting should be done. - pattern = "pattern without 0 {1, number}"; - r.setMessage(pattern); - assertEquals(pattern, f.formatMessage(r)); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "formatMessage", - args = {LogRecord.class} - ) - public void testLocalizedFormatMessage() { - // normal case - r.setMessage("msg"); - ResourceBundle rb = ResourceBundle - .getBundle("bundles/java/util/logging/res"); - r.setResourceBundle(rb); - assertEquals(rb.getString("msg"), f.formatMessage(r)); - - // local message is a pattern - r.setMessage("pattern"); - Object[] oa = new Object[] { new Integer(3) }; - r.setParameters(oa); - assertEquals(MessageFormat.format(rb.getString("pattern"), oa), f - .formatMessage(r)); - - // key is a pattern, but local message is not - r.setMessage("pattern{0,number}"); - oa = new Object[] { new Integer(3) }; - r.setParameters(oa); - assertEquals(rb.getString("pattern{0,number}"), f.formatMessage(r)); - - // another bundle - rb = ResourceBundle.getBundle("bundles/java/util/logging/res", - Locale.US); - r.setMessage("msg"); - r.setResourceBundle(rb); - assertEquals(rb.getString("msg"), f.formatMessage(r)); - - // cannot find local message in bundle - r.setMessage("msg without locale"); - assertEquals("msg without locale", f.formatMessage(r)); - - // set bundle name but not bundle - r.setResourceBundle(null); - r.setResourceBundleName("bundles/java/util/logging/res"); - r.setMessage("msg"); - assertEquals("msg", f.formatMessage(r)); - } - - public static class MockFormatter extends Formatter { - - public String format(LogRecord arg0) { - return "format"; - } - } -} diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/HandlerTest.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/HandlerTest.java deleted file mode 100644 index 5868b1fc0..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/HandlerTest.java +++ /dev/null @@ -1,780 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.logging.tests.java.util.logging; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestLevel; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.security.Permission; -import java.util.EmptyStackException; -import java.util.Properties; -import java.util.logging.ErrorManager; -import java.util.logging.Filter; -import java.util.logging.Formatter; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogManager; -import java.util.logging.LogRecord; -import java.util.logging.LoggingPermission; -import java.util.logging.SimpleFormatter; - -import junit.framework.TestCase; -import org.apache.harmony.logging.tests.java.util.logging.util.EnvironmentHelper; -import tests.util.CallVerificationStack; - -/** - * Test suite for the class java.util.logging.Handler. - * - */ -@TestTargetClass(Handler.class) -public class HandlerTest extends TestCase { - private static String className = HandlerTest.class.getName(); - - /* - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - CallVerificationStack.getInstance().clear(); - } - - /* - * Test the constructor. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "Handler", - args = {} - ) - public void testConstructor() { - MockHandler h = new MockHandler(); - assertSame(h.getLevel(), Level.ALL); - assertNull(h.getFormatter()); - assertNull(h.getFilter()); - assertNull(h.getEncoding()); - assertTrue(h.getErrorManager() instanceof ErrorManager); - } - - /* - * Test the constructor, with properties set - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "Handler", - args = {} - ) - public void testConstructor_Properties() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.MockHandler.level", "FINE"); - p.put("java.util.logging.MockHandler.filter", className - + "$MockFilter"); - p.put("java.util.logging.Handler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.MockHandler.encoding", "utf-8"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - assertEquals(LogManager.getLogManager().getProperty( - "java.util.logging.MockHandler.level"), "FINE"); - assertEquals(LogManager.getLogManager().getProperty( - "java.util.logging.MockHandler.encoding"), "utf-8"); - MockHandler h = new MockHandler(); - assertSame(h.getLevel(), Level.ALL); - assertNull(h.getFormatter()); - assertNull(h.getFilter()); - assertNull(h.getEncoding()); - assertTrue(h.getErrorManager() instanceof ErrorManager); - LogManager.getLogManager().reset(); - } - - /* - * Test getEncoding & setEncoding methods with supported encoding. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Doesn't verify exceptions.", - method = "getEncoding", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Doesn't verify exceptions.", - method = "setEncoding", - args = {java.lang.String.class} - ) - }) - public void testGetSetEncoding_Normal() throws Exception { - MockHandler h = new MockHandler(); - h.setEncoding("iso-8859-1"); - assertEquals("iso-8859-1", h.getEncoding()); - } - - /* - * Test getEncoding & setEncoding methods with null. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies null as a parameter.", - method = "getEncoding", - args = {} - ) - public void testGetSetEncoding_Null() throws Exception { - MockHandler h = new MockHandler(); - h.setEncoding(null); - assertNull(h.getEncoding()); - } - - /* - * Test getEncoding & setEncoding methods with unsupported encoding. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies UnsupportedEncodingException.", - method = "setEncoding", - args = {java.lang.String.class} - ) - public void testGetSetEncoding_Unsupported() { - MockHandler h = new MockHandler(); - try { - h.setEncoding("impossible"); - fail("Should throw UnsupportedEncodingException!"); - } catch (UnsupportedEncodingException e) { - } - assertNull(h.getEncoding()); - } - - /* - * Test setEncoding with insufficient privilege. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Doesn't verify UnsupportedEncodingException.", - method = "setEncoding", - args = {java.lang.String.class} - ) - public void testSetEncoding_InsufficientPrivilege() throws Exception { - MockHandler h = new MockHandler(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - // set a normal value - try { - h.setEncoding("iso-8859-1"); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - assertNull(h.getEncoding()); - System.setSecurityManager(new MockSecurityManager()); - // set an invalid value - try { - - h.setEncoding("impossible"); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - assertNull(h.getEncoding()); - } - - /* - * Test getErrorManager & setErrorManager methods with non-null value. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "setErrorManager", - args = {java.util.logging.ErrorManager.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getErrorManager", - args = {} - ) - }) - public void testGetSetErrorManager_Normal() throws Exception { - MockHandler h = new MockHandler(); - ErrorManager man = new ErrorManager(); - h.setErrorManager(man); - assertSame(man, h.getErrorManager()); - } - - /* - * Test getErrorManager & setErrorManager methods with null. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies null as a parameter.", - method = "getErrorManager", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies null as a parameter.", - method = "setErrorManager", - args = {java.util.logging.ErrorManager.class} - ) - }) - public void testGetSetErrorManager_Null() throws Exception { - MockHandler h = new MockHandler(); - // test set null - try { - h.setErrorManager(null); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - - // test reset null - try { - h.setErrorManager(new ErrorManager()); - h.setErrorManager(null); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - } - - /* - * Test getErrorManager with insufficient privilege. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies SecurityException.", - method = "getErrorManager", - args = {} - ) - public void testGetErrorManager_InsufficientPrivilege() throws Exception { - MockHandler h = new MockHandler(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - - try { - h.getErrorManager(); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test setErrorManager with insufficient privilege. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies setErrorManager with insufficient privilege.", - method = "setErrorManager", - args = {java.util.logging.ErrorManager.class} - ) - public void testSetErrorManager_InsufficientPrivilege() throws Exception { - MockHandler h = new MockHandler(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - - // set null - try { - - h.setErrorManager(null); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - // set a normal value - System.setSecurityManager(new MockSecurityManager()); - try { - - h.setErrorManager(new ErrorManager()); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test getFilter & setFilter methods with non-null value. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Doesn't verify SecurityException.", - method = "setFilter", - args = {java.util.logging.Filter.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Doesn't verify SecurityException.", - method = "getFilter", - args = {} - ) - }) - public void testGetSetFilter_Normal() throws Exception { - MockHandler h = new MockHandler(); - Filter f = new MockFilter(); - h.setFilter(f); - assertSame(f, h.getFilter()); - } - - /* - * Test getFilter & setFilter methods with null. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies null as a parameter.", - method = "getFilter", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies null as a parameter.", - method = "setFilter", - args = {java.util.logging.Filter.class} - ) - }) - public void testGetSetFilter_Null() throws Exception { - MockHandler h = new MockHandler(); - // test set null - h.setFilter(null); - - // test reset null - h.setFilter(new MockFilter()); - h.setFilter(null); - } - - /* - * Test setFilter with insufficient privilege. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies SecurityException.", - method = "setFilter", - args = {java.util.logging.Filter.class} - ) - public void testSetFilter_InsufficientPrivilege() throws Exception { - MockHandler h = new MockHandler(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - - // set null - try { - - h.setFilter(null); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - // set a normal value - System.setSecurityManager(new MockSecurityManager()); - try { - - h.setFilter(new MockFilter()); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test getFormatter & setFormatter methods with non-null value. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Doesn't verify SecurityException.", - method = "getFormatter", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Doesn't verify SecurityException.", - method = "setFormatter", - args = {java.util.logging.Formatter.class} - ) - }) - public void testGetSetFormatter_Normal() throws Exception { - MockHandler h = new MockHandler(); - Formatter f = new SimpleFormatter(); - h.setFormatter(f); - assertSame(f, h.getFormatter()); - } - - /* - * Test getFormatter & setFormatter methods with null. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies null as a parameter.", - method = "getFormatter", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies null as a parameter.", - method = "setFormatter", - args = {java.util.logging.Formatter.class} - ) - }) - public void testGetSetFormatter_Null() throws Exception { - MockHandler h = new MockHandler(); - // test set null - try { - h.setFormatter(null); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - - // test reset null - try { - h.setFormatter(new SimpleFormatter()); - h.setFormatter(null); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - } - - /* - * Test setFormatter with insufficient privilege. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies SecurityException.", - method = "getFormatter", - args = {} - ) - public void testSetFormatter_InsufficientPrivilege() throws Exception { - MockHandler h = new MockHandler(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - - // set null - try { - - h.setFormatter(null); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - // set a normal value - System.setSecurityManager(new MockSecurityManager()); - try { - - h.setFormatter(new SimpleFormatter()); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test getLevel & setLevel methods with non-null value. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Doesn't verify SecurityException.", - method = "getLevel", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Doesn't verify SecurityException.", - method = "setLevel", - args = {java.util.logging.Level.class} - ) - }) - public void testGetSetLevel_Normal() throws Exception { - MockHandler h = new MockHandler(); - Level f = Level.CONFIG; - h.setLevel(f); - assertSame(f, h.getLevel()); - } - - /* - * Test getLevel & setLevel methods with null. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getLevel & setLevel methods with null.", - method = "getLevel", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getLevel & setLevel methods with null.", - method = "setLevel", - args = {java.util.logging.Level.class} - ) - }) - public void testGetSetLevel_Null() throws Exception { - MockHandler h = new MockHandler(); - // test set null - try { - h.setLevel(null); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - - // test reset null - try { - h.setLevel(Level.CONFIG); - h.setLevel(null); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - } - - /* - * Test setLevel with insufficient privilege. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies NullPointerException, SecurityException.", - method = "setLevel", - args = {java.util.logging.Level.class} - ) - public void testSetLevel_InsufficientPrivilege() throws Exception { - MockHandler h = new MockHandler(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - - // set null - try { - - h.setLevel(null); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } finally { - System.setSecurityManager(oldMan); - } - // set a normal value - System.setSecurityManager(new MockSecurityManager()); - try { - - h.setLevel(Level.CONFIG); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Use no filter - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "isLoggable", - args = {java.util.logging.LogRecord.class} - ) - public void testIsLoggable_NoFilter() { - MockHandler h = new MockHandler(); - LogRecord r = new LogRecord(Level.CONFIG, null); - assertTrue(h.isLoggable(r)); - - h.setLevel(Level.CONFIG); - assertTrue(h.isLoggable(r)); - - h.setLevel(Level.SEVERE); - assertFalse(h.isLoggable(r)); - - r.setLevel(Level.OFF); - h.setLevel(Level.OFF); - assertFalse(h.isLoggable(r)); - } - - /* - * Use a filter - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Verifies isLoggable method with filter.", - method = "isLoggable", - args = {java.util.logging.LogRecord.class} - ) - public void testIsLoggable_WithFilter() { - MockHandler h = new MockHandler(); - LogRecord r = new LogRecord(Level.CONFIG, null); - LogRecord r1 = new LogRecord(Level.CONFIG, null); - LogRecord r2 = new LogRecord(Level.CONFIG, null); - - h.setFilter(new MockFilter()); - assertFalse(h.isLoggable(r)); - assertSame(r,CallVerificationStack.getInstance().pop()); - - h.setLevel(Level.CONFIG); - assertFalse(h.isLoggable(r1)); - assertSame(r1, CallVerificationStack.getInstance().pop()); - - h.setLevel(Level.SEVERE); - assertFalse(h.isLoggable(r2)); - - try{ - CallVerificationStack.getInstance().pop(); - }catch(EmptyStackException e){ - //normal - } - } - - /** - * @tests java.util.logging.Handler#isLoggable(LogRecord) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies null as a parameter.", - method = "isLoggable", - args = {java.util.logging.LogRecord.class} - ) - public void testIsLoggable_Null() { - MockHandler h = new MockHandler(); - try { - h.isLoggable(null); - fail("should throw NullPointerException"); - } catch (NullPointerException e) { - // expected - } - } - - /* - * Test whether the error manager is actually called with expected - * parameters. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "reportError", - args = {java.lang.String.class, java.lang.Exception.class, int.class} - ) - public void testReportError() { - MockHandler h = new MockHandler(); - h.setErrorManager(new MockErrorManager()); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - - try { - Exception ex = new Exception("test exception"); - // with non-null parameters - h.reportError("test msg", ex, -1); - assertEquals(-1, CallVerificationStack.getInstance().popInt()); - assertSame(ex, CallVerificationStack.getInstance().pop()); - assertEquals("test msg", CallVerificationStack.getInstance().pop()); - // with null parameters - h.reportError(null, null, 0); - assertEquals(0, CallVerificationStack.getInstance().popInt()); - assertSame(null, CallVerificationStack.getInstance().pop()); - assertNull(CallVerificationStack.getInstance().pop()); - } catch (SecurityException e) { - fail("Should not throw SecurityException!"); - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Used to enable the testing of Handler because Handler is an abstract - * class. - */ - public static class MockHandler extends Handler { - - public void close() { - } - - public void flush() { - } - - public void publish(LogRecord record) { - } - - public void reportError(String msg, Exception ex, int code) { - super.reportError(msg, ex, code); - } - } - - /* - * Used to grant all permissions except logging control. - */ - public static class MockSecurityManager extends SecurityManager { - - public MockSecurityManager() { - } - - public void checkPermission(Permission perm) { - // grant all permissions except logging control - if (perm instanceof LoggingPermission) { - throw new SecurityException(); - } - } - - public void checkPermission(Permission perm, Object context) { - // grant all permissions except logging control - if (perm instanceof LoggingPermission) { - throw new SecurityException(); - } - } - } - - /* - * A mock filter, always return false. - */ - public static class MockFilter implements Filter { - - public boolean isLoggable(LogRecord record) { - CallVerificationStack.getInstance().push(record); - return false; - } - } - - /* - * A mock error manager, used to validate the expected method is called with - * the expected parameters. - */ - public static class MockErrorManager extends ErrorManager { - - public void error(String msg, Exception ex, int errorCode) { - CallVerificationStack.getInstance().push(msg); - CallVerificationStack.getInstance().push(ex); - CallVerificationStack.getInstance().push(errorCode); - } - } - - public static class NullOutputStream extends OutputStream{ - @Override - public void write(int arg0) throws IOException { - } - } - -} diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LevelTest.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LevelTest.java deleted file mode 100644 index 1fee1babb..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LevelTest.java +++ /dev/null @@ -1,645 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.logging.tests.java.util.logging; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestLevel; - -import java.io.Serializable; -import java.util.ResourceBundle; -import java.util.logging.Handler; -import java.util.logging.Level; - -import junit.framework.TestCase; - -import org.apache.harmony.testframework.serialization.SerializationTest; -import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert; - -/* - * This class implements Serializable, so that the non-static inner class - * MockLevel can be Serializable. - */ -@TestTargetClass(Level.class) -public class LevelTest extends TestCase implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * Test the constructor without resource bundle parameter using normal - * values. As byproducts, getName & intValue are also tested. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks the constructor without resource bundle parameter using normal values.", - method = "Level", - args = {java.lang.String.class, int.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks the constructor without resource bundle parameter using normal values.", - method = "getName", - args = {} - ) - }) - public void testConstructorNoResBundle_Normal() { - MockLevel l = new MockLevel("level1", 1); - assertEquals("level1", l.getName()); - assertEquals(1, l.intValue()); - assertNull(l.getResourceBundleName()); - } - - /** - * Test the constructor without resource bundle parameter using null name. - * As byproducts, getName & intValue are also tested. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks the constructor without resource bundle parameter using null name.", - method = "Level", - args = {java.lang.String.class, int.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks the constructor without resource bundle parameter using null name.", - method = "getName", - args = {} - ) - }) - public void testConstructorNoResBundle_NullName() { - try { - new MockLevel(null, -2); - fail("No expected NullPointerException"); - } catch (NullPointerException ignore) { - // expected - } - } - - /* - * Test the constructor without resource bundle parameter using empty name. - * As byproducts, getName & intValue are also tested. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks the constructor without resource bundle parameter using empty name.", - method = "Level", - args = {java.lang.String.class, int.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks the constructor without resource bundle parameter using empty name.", - method = "getName", - args = {} - ) - }) - public void testConstructorNoResBundle_EmptyName() { - MockLevel l = new MockLevel("", -3); - assertEquals("", l.getName()); - assertEquals(-3, l.intValue()); - assertNull(l.getResourceBundleName()); - } - - /* - * Test the constructor having resource bundle parameter using normal - * values. As byproducts, getName & intValue are also tested. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "Level", - args = {java.lang.String.class, int.class, java.lang.String.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getName", - args = {} - ) - }) - public void testConstructorHavingResBundle_Normal() { - MockLevel l = new MockLevel("level1", 1, "resourceBundle"); - assertEquals("level1", l.getName()); - assertEquals(1, l.intValue()); - assertEquals("resourceBundle", l.getResourceBundleName()); - } - - /* - * Test the constructor having resource bundle parameter using null names. - * As byproducts, getName & intValue are also tested. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks NullPointerException.", - method = "Level", - args = {java.lang.String.class, int.class, java.lang.String.class} - ) - public void testConstructorHavingResBundle_NullName() { - try { - new MockLevel(null, -123, "qwe"); - fail("No expected NullPointerException"); - } catch (NullPointerException ignore) { - // expected - } - } - - /* - * Test the constructor having resource bundle parameter using empty - names. - * As byproducts, getName & intValue are also tested. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor having resource bundle parameter using empty names.", - method = "Level", - args = {java.lang.String.class, int.class, java.lang.String.class} - ) - public void testConstructorHavingResBundle_EmptyName() { - MockLevel l = new MockLevel("", -1000, ""); - assertEquals("", l.getName()); - assertEquals(-1000, l.intValue()); - assertEquals("", l.getResourceBundleName()); - } - - /* - * Test method parse, with the pre-defined string consts. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies parse, with the pre-defined string consts.", - method = "parse", - args = {java.lang.String.class} - ) - public void testParse_PredefinedConstStrings() { - assertSame(Level.SEVERE, Level.parse("SEVERE")); - assertSame(Level.WARNING, Level.parse("WARNING")); - assertSame(Level.INFO, Level.parse("INFO")); - assertSame(Level.CONFIG, Level.parse("CONFIG")); - assertSame(Level.FINE, Level.parse("FINE")); - assertSame(Level.FINER, Level.parse("FINER")); - assertSame(Level.FINEST, Level.parse("FINEST")); - assertSame(Level.OFF, Level.parse("OFF")); - assertSame(Level.ALL, Level.parse("ALL")); - } - - /* - * Test method parse, with an undefined string. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "IllegalArgumentException is verified.", - method = "parse", - args = {java.lang.String.class} - ) - public void testParse_IllegalConstString() { - try { - Level.parse("SEVERe"); - fail("Should throw IllegalArgumentException if undefined string."); - } catch (IllegalArgumentException e) { - // expected - } - } - - /* - * Test method parse, with a null string. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies null as a parameter.", - method = "parse", - args = {java.lang.String.class} - ) - public void testParse_NullString() { - try { - Level.parse(null); - fail("Should throw NullPointerException."); - } catch (NullPointerException e) { - // expected - } - } - - /* - * Test method parse, with pre-defined valid number strings. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies parse, with pre-defined valid number strings.", - method = "parse", - args = {java.lang.String.class} - ) - public void testParse_PredefinedNumber() { - assertSame(Level.SEVERE, Level.parse("SEVERE")); - assertSame(Level.WARNING, Level.parse("WARNING")); - assertSame(Level.INFO, Level.parse("INFO")); - assertSame(Level.CONFIG, Level.parse("CONFIG")); - assertSame(Level.FINE, Level.parse("FINE")); - assertSame(Level.FINER, Level.parse("FINER")); - assertSame(Level.FINEST, Level.parse("FINEST")); - assertSame(Level.OFF, Level.parse("OFF")); - assertSame(Level.ALL, Level.parse("ALL")); - assertSame(Level.SEVERE, Level.parse("1000")); - assertSame(Level.WARNING, Level.parse("900")); - assertSame(Level.INFO, Level.parse("800")); - assertSame(Level.CONFIG, Level.parse("700")); - assertSame(Level.FINE, Level.parse("500")); - assertSame(Level.FINER, Level.parse("400")); - assertSame(Level.FINEST, Level.parse("300")); - assertSame(Level.OFF, Level.parse(String.valueOf(Integer.MAX_VALUE))); - assertSame(Level.ALL, Level.parse(String.valueOf(Integer.MIN_VALUE))); - } - - /* - * Test method parse, with an undefined valid number strings. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies parse, with an undefined valid number strings.", - method = "parse", - args = {java.lang.String.class} - ) - public void testParse_UndefinedNumber() { - Level l = Level.parse("0"); - assertEquals(0, l.intValue()); - assertEquals("0", l.getName()); - assertNull(l.getResourceBundleName()); - } - - /* - * Test method parse, with an undefined valid number strings with spaces. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies parse, with an undefined valid number strings with spaces.", - method = "parse", - args = {java.lang.String.class} - ) - public void testParse_UndefinedNumberWithSpaces() { - try { - Level.parse(" 0"); - } catch (IllegalArgumentException e) { - // expected - } - } - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies negative number.", - method = "parse", - args = {java.lang.String.class} - ) - public void testParse_NegativeNumber() { - Level l = Level.parse("-4"); - assertEquals(-4, l.intValue()); - assertEquals("-4", l.getName()); - assertNull(l.getResourceBundleName()); - } - - /* - * Test method parse, expecting the same objects will be returned given the - * same name, even for non-predefined levels. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies parse, expecting the same objects will be returned given the same name, even for non-predefined levels.", - method = "parse", - args = {java.lang.String.class} - ) - public void testParse_SameObject() { - Level l = Level.parse("-100"); - assertSame(l, Level.parse("-100")); - } - - /* - * Test method hashCode, with normal fields. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "hashCode", - args = {} - ) - public void testHashCode_Normal() { - assertEquals(100, Level.parse("100").hashCode()); - assertEquals(-1, Level.parse("-1").hashCode()); - assertEquals(0, Level.parse("0").hashCode()); - assertEquals(Integer.MIN_VALUE, Level.parse("ALL").hashCode()); - } - - /* - * Test equals when two objects are equal. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Doesn't check negative case.", - method = "equals", - args = {java.lang.Object.class} - ) - public void testEquals_Equal() { - MockLevel l1 = new MockLevel("level1", 1); - MockLevel l2 = new MockLevel("level2", 1); - assertEquals(l1, l2); - assertEquals(l2, l1); - } - - /* - * Test equals when two objects are not equal. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks negative case.", - method = "equals", - args = {java.lang.Object.class} - ) - public void testEquals_NotEqual() { - MockLevel l1 = new MockLevel("level1", 1); - MockLevel l2 = new MockLevel("level1", 2); - assertFalse(l1.equals(l2)); - assertFalse(l2.equals(l1)); - } - - /* - * Test equals when the other object is null. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks null as a parameter.", - method = "equals", - args = {java.lang.Object.class} - ) - public void testEquals_Null() { - assertFalse(Level.ALL.equals(null)); - } - - /* - * Test equals when the other object is not an instance of Level. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks negative case.", - method = "equals", - args = {java.lang.Object.class} - ) - public void testEquals_NotLevel() { - assertFalse(Level.ALL.equals(new Object())); - } - - /* - * Test equals when the other object is itself. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Checks equals when the other object is itself.", - method = "equals", - args = {java.lang.Object.class} - ) - public void testEquals_Itself() { - assertTrue(Level.ALL.equals(Level.ALL)); - } - - /* - * Test toString of a normal Level. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "toString", - args = {} - ) - public void testToString_Normal() { - assertEquals("ALL", Level.ALL.toString()); - - MockLevel l = new MockLevel("name", 2); - assertEquals("name", l.toString()); - - MockLevel emptyLevel = new MockLevel("", 3); - assertEquals("", emptyLevel.toString()); - } - - // comparator for Level objects: - // is used because Level.equals() method only takes into account - // 'level' value but ignores 'name' and 'resourceBundleName' values - private static final SerializableAssert LEVEL_COMPARATOR = new SerializableAssert() { - public void assertDeserialized(Serializable initial, - Serializable deserialized) { - - Level init = (Level) initial; - Level dser = (Level) deserialized; - - assertEquals("Class", init.getClass(), dser.getClass()); - assertEquals("Name", init.getName(), dser.getName()); - assertEquals("Value", init.intValue(), dser.intValue()); - assertEquals("ResourceBundleName", init.getResourceBundleName(), - dser.getResourceBundleName()); - } - }; - - /** - * @tests serialization/deserialization compatibility. - * - * Test serialization of pre-defined const levels. It is expected that the - * deserialized cost level should be the same instance as the existing one. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Serialization of pre-defined const levels. ", - method = "!SerializationSelf", - args = {} - ) - public void testSerialization_ConstLevel() throws Exception { - - SerializationTest.verifySelf(Level.ALL, - SerializationTest.SAME_COMPARATOR); - } - - /** - * @tests serialization/deserialization compatibility. - * - * Test serialization of normal instance of Level. It is expected that the - * deserialized level object should be equal to the original one. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Test serialization of normal instance of Level.", - method = "!SerializationSelf", - args = {} - ) - public void testSerialization_InstanceLevel() throws Exception { - - // tests that objects are the same - Level[] objectsToTest = new Level[] { Level.parse("550")}; - - SerializationTest.verifySelf(objectsToTest, - SerializationTest.SAME_COMPARATOR); - - // tests that objects are the equals - objectsToTest = new Level[] { - new MockLevel("123", 123, "bundle"), - new MockLevel("123", 123, null) }; - - SerializationTest.verifySelf(objectsToTest, LEVEL_COMPARATOR); - } - - /** - * @tests serialization/deserialization compatibility with RI. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Serialization/deserialization compatibility", - method = "!SerializationGolden", - args = {} - ) - public void testSerializationCompatibility() throws Exception { - - SerializationTest.verifyGolden(this, - new MockLevel("123", 123, "bundle"), LEVEL_COMPARATOR); - } - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getLocalizedName", - args = {} - ) - public void testGetLocalName() { - ResourceBundle rb = ResourceBundle.getBundle("bundles/java/util/logging/res"); - Level l = new MockLevel("level1", 120, - "bundles/java/util/logging/res"); - assertEquals(rb.getString("level1"), l.getLocalizedName()); - - // regression test for HARMONY-2415 - rb = ResourceBundle.getBundle( - "org.apache.harmony.logging.tests.java.util.logging.LevelTestResource"); - l = new MockLevel("Level_error", 120, - "org.apache.harmony.logging.tests.java.util.logging.LevelTestResource"); - assertEquals(rb.getString("Level_error"), l.getLocalizedName()); - - l = new MockLevel("bad name", 120, "res"); - assertEquals("bad name", l.getLocalizedName()); - - l = new MockLevel("level1", 11120, "bad name"); - assertEquals("level1", l.getLocalizedName()); - - l = new MockLevel("level1", 1120); - assertEquals("level1", l.getLocalizedName()); - } - - /* - * test for method public String getResourceBundleName() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getResourceBundleName", - args = {} - ) - public void testGetResourceBundleName() { - String bundleName = "bundles/java/util/logging/res"; - Level l = new MockLevel("level1", 120); - assertNull("level's localization resource bundle name is not null", l - .getResourceBundleName()); - l = new MockLevel("level1", 120, bundleName); - assertEquals("bundleName is non equal to actual value", bundleName, l - .getResourceBundleName()); - l = new MockLevel("level1", 120, bundleName + "+abcdef"); - assertEquals("bundleName is non equal to actual value", bundleName - + "+abcdef", l.getResourceBundleName()); - } - - /* - * test for method public final int intValue() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "intValue", - args = {} - ) - public void testIntValue() { - int value1 = 120; - Level l = new MockLevel("level1", value1); - assertEquals( - "integer value for this level is non equal to actual value", - value1, l.intValue()); - } - - /* - * Test defining new levels in subclasses of Level - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Test defining new levels in subclasses of Level", - method = "parse", - args = {java.lang.String.class} - ) - public void testSubclassNewLevel() { - MyLevel.DUPLICATENAME.getName();// just to load MyLevel class - - // test duplicated name and num - assertEquals("INFO", MyLevel.parse("800").getName()); - assertEquals(800, MyLevel.parse("INFO").intValue()); - // test duplicated name - assertEquals("FINE", MyLevel.parse("499").getName()); - assertEquals("FINE", MyLevel.parse("500").getName()); - assertEquals(500, MyLevel.parse("FINE").intValue()); - // test duplicated number - assertEquals("FINEST", MyLevel.parse("300").getName()); - assertEquals(300, MyLevel.parse("FINEST").intValue()); - assertEquals(300, MyLevel.parse("MYLEVEL1").intValue()); - // test a normal new level, without duplicated elements - assertEquals("MYLEVEL2", MyLevel.parse("299").getName()); - assertEquals(299, MyLevel.parse("MYLEVEL2").intValue()); - } - - /* - * This subclass is to test whether subclasses of Level can add new defined - * levels. - */ - static class MyLevel extends Level implements Serializable { - private static final long serialVersionUID = 1L; - - public MyLevel(String name, int value) { - super(name, value); - } - - public static final Level DUPLICATENAMENUM = new MyLevel("INFO", 800); - - public static final Level DUPLICATENAME = new MyLevel("FINE", 499); - - public static final Level DUPLICATENUM = new MyLevel("MYLEVEL1", 300); - - public static final Level NORMAL = new MyLevel("MYLEVEL2", 299); - } - - /* - * This Mock is used to expose the protected constructors. - */ - public class MockLevel extends Level implements Serializable { - - private static final long serialVersionUID = 1L; - - public MockLevel(String name, int value) { - super(name, value); - } - - public MockLevel(String name, int value, String resourceBundleName) { - super(name, value, resourceBundleName); - } - } -} diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LevelTestResource.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LevelTestResource.java deleted file mode 100644 index 9b41a9ddb..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LevelTestResource.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.logging.tests.java.util.logging; - -import dalvik.annotation.TestTargetClass; - -import java.util.ListResourceBundle; -import java.util.logging.Level; - -//@TestTargetClass = No test needed, just test class helper -public class LevelTestResource extends ListResourceBundle { - public Object[][] getContents() { - return contents; - } - - @SuppressWarnings("nls") - static final Object[][] contents = { { "Level_error", "Name" }, - { "Localized", "Localized message" }, }; -} \ No newline at end of file diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java deleted file mode 100644 index cf608bca3..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java +++ /dev/null @@ -1,1560 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.logging.tests.java.util.logging; - - - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintStream; -import java.security.Permission; -import java.util.Enumeration; -import java.util.Properties; -import java.util.logging.ConsoleHandler; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogManager; -import java.util.logging.LogRecord; -import java.util.logging.Logger; -import java.util.logging.LoggingPermission; - -import junit.framework.TestCase; - -import org.apache.harmony.logging.tests.java.util.logging.HandlerTest.NullOutputStream; -import org.apache.harmony.logging.tests.java.util.logging.util.EnvironmentHelper; - -import dalvik.annotation.SideEffect; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargets; - -/** - * - * add/get logger(dot) - * - */ -@TestTargetClass(LogManager.class) -public class LogManagerTest extends TestCase { - - private static final String FOO = "LogManagerTestFoo"; - - LogManager mockManager; - - LogManager manager = LogManager.getLogManager(); - - MockPropertyChangeListener listener; - - Properties props; - - private static String className = LogManagerTest.class.getName(); - - static Handler handler = null; - - static final String CONFIG_CLASS = "java.util.logging.config.class"; - - static final String CONFIG_FILE = "java.util.logging.config.file"; - - static final String MANAGER_CLASS = "java.util.logging.config.manager"; - - static final SecurityManager securityManager = System.getSecurityManager(); - - static final String clearPath = System.getProperty("clearpath"); - - /* - * @see TestCase#setUp() - */ - @Override - protected void setUp() throws Exception { - super.setUp(); - mockManager = new MockLogManager(); - // listener = new MockPropertyChangeListener(); - handler = new MockHandler(); - props = new Properties(); - props.put("handlers", className + "$MockHandler " + className + "$MockHandler"); - props.put("java.util.logging.FileHandler.pattern", "%h/java%u.log"); - props.put("java.util.logging.FileHandler.limit", "50000"); - props.put("java.util.logging.FileHandler.count", "5"); - props.put("java.util.logging.FileHandler.formatter", "java.util.logging.XMLFormatter"); - props.put(".level", "FINE"); - props.put("java.util.logging.ConsoleHandler.level", "OFF"); - props.put("java.util.logging.ConsoleHandler.formatter","java.util.logging.SimpleFormatter"); - props.put("LogManagerTestFoo.handlers", "java.util.logging.ConsoleHandler"); - props.put("LogManagerTestFoo.level", "WARNING"); - } - - - - /* - * @see TestCase#tearDown() - */ - @Override - protected void tearDown() throws Exception { - super.tearDown(); - handler = null; - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "LogManager", - args = {} - ) - public void testLogManager() { - class TestLogManager extends LogManager { - public TestLogManager() { - super(); - } - } - TestLogManager tlm = new TestLogManager(); - assertNotNull(tlm.toString()); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies NullPointerException.", - method = "addLogger", - args = {java.util.logging.Logger.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies NullPointerException.", - method = "getLogger", - args = {java.lang.String.class} - ) - }) - public void testAddGetLogger() { - Logger log = new MockLogger(FOO, null); - Logger foo = mockManager.getLogger(FOO); - assertNull(foo); - assertTrue(mockManager.addLogger(log)); - foo = mockManager.getLogger(FOO); - assertSame(foo, log); - assertNull(foo.getParent()); - - try { - mockManager.addLogger(null); - fail("add null should throw NullPointerException"); - } catch (NullPointerException e) { - } - - try { - mockManager.getLogger(null); - fail("get null should throw NullPointerException"); - } catch (NullPointerException e) { - } - - assertNull(mockManager.getLogger("bad name")); - - Enumeration enumar = mockManager.getLoggerNames(); - int i = 0; - while (enumar.hasMoreElements()) { - String name = enumar.nextElement(); - i++; - assertEquals(FOO, name); - } - assertEquals(i, 1); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "addLogger", - args = {java.util.logging.Logger.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getLogger", - args = {java.lang.String.class} - ) - }) - public void testAddGetLogger_duplicateName() { - // add logger with duplicate name has no effect - Logger foo = new MockLogger(FOO, null); - Logger foo2 = new MockLogger(FOO, null); - assertTrue(mockManager.addLogger(foo)); - assertSame(foo, mockManager.getLogger(FOO)); - assertFalse(mockManager.addLogger(foo2)); - assertSame(foo, mockManager.getLogger(FOO)); - Enumeration enumar = mockManager.getLoggerNames(); - int i = 0; - while (enumar.hasMoreElements()) { - enumar.nextElement(); - i++; - } - assertEquals(1, i); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "addLogger", - args = {java.util.logging.Logger.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getLogger", - args = {java.lang.String.class} - ) - }) - public void testAddGetLogger_Hierachy() { - Logger foo = new MockLogger("testAddGetLogger_Hierachy.foo", null); - Logger child = new MockLogger("testAddGetLogger_Hierachy.foo.child", null); - Logger fakeChild = new MockLogger("testAddGetLogger_Hierachy.foo2.child", null); - Logger grandson = new MockLogger("testAddGetLogger_Hierachy.foo.child.grandson", null); - Logger otherChild = new MockLogger("testAddGetLogger_Hierachy.foo.child", null); - assertNull(foo.getParent()); - assertNull(child.getParent()); - assertNull(grandson.getParent()); - assertNull(otherChild.getParent()); - - // whenever a logger is added to a LogManager, hierarchy will be updated - // accordingly - assertTrue(mockManager.addLogger(child)); - assertNull(child.getParent()); - - assertTrue(mockManager.addLogger(fakeChild)); - assertNull(fakeChild.getParent()); - - assertTrue(mockManager.addLogger(grandson)); - assertSame(child, grandson.getParent()); - - assertTrue(mockManager.addLogger(foo)); - assertSame(foo, child.getParent()); - assertNull(foo.getParent()); - assertNull(fakeChild.getParent()); - - // but for non-mock LogManager, foo's parent should be root - assertTrue(manager.addLogger(foo)); - assertSame(manager.getLogger(""), manager.getLogger("testAddGetLogger_Hierachy.foo") - .getParent()); - - // if we add one logger to two LogManager, parent will changed - assertTrue(manager.addLogger(otherChild)); - assertTrue(manager.addLogger(grandson)); - assertSame(foo, otherChild.getParent()); - assertSame(otherChild, grandson.getParent()); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "addLogger", - args = {java.util.logging.Logger.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getLogger", - args = {java.lang.String.class} - ) - }) - public void testAddLoggerReverseOrder() { - Logger root = new MockLogger("testAddLoggerReverseOrder", null); - Logger foo = new MockLogger("testAddLoggerReverseOrder.foo", null); - Logger fooChild = new MockLogger("testAddLoggerReverseOrder.foo.child", null); - Logger fooGrandChild = new MockLogger("testAddLoggerReverseOrder.foo.child.grand", null); - Logger fooGrandChild2 = new MockLogger("testAddLoggerReverseOrder.foo.child.grand2", null); - - Logger realRoot = manager.getLogger(""); - - manager.addLogger(fooGrandChild); - assertEquals(realRoot, fooGrandChild.getParent()); - - manager.addLogger(root); - assertSame(root, fooGrandChild.getParent()); - assertSame(realRoot, root.getParent()); - - manager.addLogger(foo); - assertSame(root, foo.getParent()); - assertSame(foo, fooGrandChild.getParent()); - - manager.addLogger(fooGrandChild2); - assertSame(foo, fooGrandChild2.getParent()); - assertSame(foo, fooGrandChild.getParent()); - - manager.addLogger(fooChild); - assertSame(fooChild, fooGrandChild2.getParent()); - assertSame(fooChild, fooGrandChild.getParent()); - assertSame(foo, fooChild.getParent()); - assertSame(root, foo.getParent()); - assertSame(realRoot, root.getParent()); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "addLogger", - args = {java.util.logging.Logger.class} - ) - public void testAddSimiliarLogger() { - Logger root = new MockLogger("testAddSimiliarLogger", null); - Logger foo = new MockLogger("testAddSimiliarLogger.foo", null); - Logger similiarFoo = new MockLogger("testAddSimiliarLogger.fop", null); - Logger fooo = new MockLogger("testAddSimiliarLogger.fooo", null); - Logger fooChild = new MockLogger("testAddSimiliarLogger.foo.child", null); - Logger similiarFooChild = new MockLogger("testAddSimiliarLogger.fop.child", null); - Logger foooChild = new MockLogger("testAddSimiliarLogger.fooo.child", null); - - manager.addLogger(root); - manager.addLogger(fooChild); - manager.addLogger(similiarFooChild); - manager.addLogger(foooChild); - assertSame(root, fooChild.getParent()); - assertSame(root, similiarFooChild.getParent()); - assertSame(root, foooChild.getParent()); - - manager.addLogger(foo); - assertSame(foo, fooChild.getParent()); - assertSame(root, similiarFooChild.getParent()); - assertSame(root, foooChild.getParent()); - - manager.addLogger(similiarFoo); - assertSame(foo, fooChild.getParent()); - assertSame(similiarFoo, similiarFooChild.getParent()); - assertSame(root, foooChild.getParent()); - - manager.addLogger(fooo); - assertSame(fooo, foooChild.getParent()); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "addLogger", - args = {java.util.logging.Logger.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getLogger", - args = {java.lang.String.class} - ) - }) - public void testAddGetLogger_nameWithSpace() { - Logger foo = new MockLogger(FOO, null); - Logger fooBeforeSpace = new MockLogger(FOO + " ", null); - Logger fooAfterSpace = new MockLogger(" " + FOO, null); - Logger fooWithBothSpace = new MockLogger(" " + FOO + " ", null); - assertTrue(mockManager.addLogger(foo)); - assertTrue(mockManager.addLogger(fooBeforeSpace)); - assertTrue(mockManager.addLogger(fooAfterSpace)); - assertTrue(mockManager.addLogger(fooWithBothSpace)); - - assertSame(foo, mockManager.getLogger(FOO)); - assertSame(fooBeforeSpace, mockManager.getLogger(FOO + " ")); - assertSame(fooAfterSpace, mockManager.getLogger(" " + FOO)); - assertSame(fooWithBothSpace, mockManager.getLogger(" " + FOO + " ")); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Doesn't verify NullPointerException", - method = "addLogger", - args = {java.util.logging.Logger.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getLogger", - args = {java.lang.String.class} - ) - }) - public void testAddGetLogger_addRoot() { - Logger foo = new MockLogger(FOO, null); - Logger fooChild = new MockLogger(FOO + ".child", null); - Logger other = new MockLogger("other", null); - Logger root = new MockLogger("", null); - assertNull(foo.getParent()); - assertNull(root.getParent()); - assertNull(other.getParent()); - - // add root to mock logmanager and it works as "root" logger - assertTrue(mockManager.addLogger(foo)); - assertTrue(mockManager.addLogger(other)); - assertTrue(mockManager.addLogger(fooChild)); - assertNull(foo.getParent()); - assertNull(other.getParent()); - assertSame(foo, fooChild.getParent()); - - assertTrue(mockManager.addLogger(root)); - assertSame(root, foo.getParent()); - assertSame(root, other.getParent()); - assertNull(root.getParent()); - - // try to add root logger to non-mock LogManager, no effect - assertFalse(manager.addLogger(root)); - assertNotSame(root, manager.getLogger("")); - } - - /** - * @tests java.util.logging.LogManager#addLogger(Logger) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "addLogger", - args = {java.util.logging.Logger.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getLogManager", - args = {} - ) - }) - public void test_addLoggerLLogger_Security() throws Exception { - // regression test for Harmony-1286 - SecurityManager originalSecurityManager = System.getSecurityManager(); - System.setSecurityManager(new SecurityManager() { - @Override - public void checkPermission(Permission perm) { - - } - }); - try { - LogManager manager = LogManager.getLogManager(); - manager.addLogger(new MockLogger("mock", null)); - manager.addLogger(new MockLogger("mock.child", null)); - } finally { - System.setSecurityManager(originalSecurityManager); - } - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "readConfiguration", - args = {java.io.InputStream.class} - ) - public void testDefaultLoggerProperties() throws Exception { - // mock LogManager has no default logger - assertNull(mockManager.getLogger("")); - assertNull(mockManager.getLogger("global")); - - // non-mock LogManager has two default logger - Logger global = manager.getLogger("global"); - Logger root = manager.getLogger(""); - - assertSame(global, Logger.global); - assertSame(root, global.getParent()); - - Logger oldGlobal = global; - Logger oldRoot = root; - - // root properties - manager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - - global = manager.getLogger("global"); - root = manager.getLogger(""); - - assertSame(oldGlobal, global); - assertSame(oldRoot, root); - - assertNull(root.getFilter()); - assertEquals(2, root.getHandlers().length); - assertEquals(Level.FINE, root.getLevel()); - assertEquals("", root.getName()); - assertSame(root.getParent(), null); - assertTrue(root.getUseParentHandlers()); - - // The following two fail if other tests are run before this one. - assertNull(root.getResourceBundle()); - assertNull(root.getResourceBundleName()); - } - - /* - * test for method public Logger getLogger(String name) - * test covers following usecases: - * case 1: test default and valid value - * case 2: test throw NullPointerException - * case 3: test bad name - * case 4: check correct tested value - */ - - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getLogger", - args = {java.lang.String.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getLoggerNames", - args = {} - ) - }) - public void testGetLogger() throws Exception { - - // case 1: test default and valid value - Logger log = new MockLogger(FOO, null); - Logger foo = mockManager.getLogger(FOO); - assertNull("Logger should be null", foo); - assertTrue("logger was't registered successfully", mockManager.addLogger(log)); - foo = mockManager.getLogger(FOO); - assertSame("two loggers not refer to the same object", foo, log); - assertNull("logger foo should not haven parent", foo.getParent()); - - // case 2: test throw NullPointerException - try { - mockManager.getLogger(null); - fail("get null should throw NullPointerException"); - } catch (NullPointerException e) { - } - - // case 3: test bad name - assertNull("LogManager should not have logger with unforeseen name", mockManager - .getLogger("bad name")); - - // case 4: check correct tested value - Enumeration enumar = mockManager.getLoggerNames(); - int i = 0; - while (enumar.hasMoreElements()) { - String name = enumar.nextElement(); - i++; - assertEquals("name logger should be equal to foreseen name", FOO, name); - } - assertEquals("LogManager should contain one element", 1, i); - } - - /* - * test for method public Logger getLogger(String name) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getLogger", - args = {java.lang.String.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "", - method = "getLoggerNames", - args = {} - ) - }) - public void testGetLogger_duplicateName() throws Exception { - // test duplicate name - // add logger with duplicate name has no effect - mockManager.reset(); - Logger foo2 = new MockLogger(FOO, null); - Logger foo3 = new MockLogger(FOO, null); - mockManager.addLogger(foo2); - assertSame(foo2, mockManager.getLogger(FOO)); - mockManager.addLogger(foo3); - assertSame(foo2, mockManager.getLogger(FOO)); - - Enumeration enumar2 = mockManager.getLoggerNames(); - int i = 0; - while (enumar2.hasMoreElements()) { - enumar2.nextElement(); - i++; - } - assertEquals(1, i); - } - - /* - * test for method public Logger getLogger(String name) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getLogger", - args = {java.lang.String.class} - ) - public void testGetLogger_hierachy() throws Exception { - // test hierachy - Logger foo = new MockLogger("testGetLogger_hierachy.foo", null); - // but for non-mock LogManager, foo's parent should be root - assertTrue(manager.addLogger(foo)); - assertSame(manager.getLogger(""), manager.getLogger("testGetLogger_hierachy.foo") - .getParent()); - } - - /* - * test for method public Logger getLogger(String name) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getLogger", - args = {java.lang.String.class} - ) - public void testGetLogger_nameSpace() throws Exception { - // test name with space - Logger foo = new MockLogger(FOO, null); - Logger fooBeforeSpace = new MockLogger(FOO + " ", null); - Logger fooAfterSpace = new MockLogger(" " + FOO, null); - Logger fooWithBothSpace = new MockLogger(" " + FOO + " ", null); - assertTrue(mockManager.addLogger(foo)); - assertTrue(mockManager.addLogger(fooBeforeSpace)); - assertTrue(mockManager.addLogger(fooAfterSpace)); - assertTrue(mockManager.addLogger(fooWithBothSpace)); - - assertSame(foo, mockManager.getLogger(FOO)); - assertSame(fooBeforeSpace, mockManager.getLogger(FOO + " ")); - assertSame(fooAfterSpace, mockManager.getLogger(" " + FOO)); - assertSame(fooWithBothSpace, mockManager.getLogger(" " + FOO + " ")); - } - - /* - * test for method public void checkAccess() throws SecurityException - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "checkAccess", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getLogManager", - args = {} - ) - }) - public void testCheckAccess() { - try { - manager.checkAccess(); - } catch (SecurityException e) { - fail("securityException should not be thrown"); - } - System.setSecurityManager(new MockSecurityManagerLogPermission()); - mockManager.addLogger(new MockLogger("abc", null)); - mockManager.getLogger(""); - mockManager.getLoggerNames(); - mockManager.getProperty(".level"); - LogManager.getLogManager(); - try { - manager.checkAccess(); - fail("should throw securityException"); - } catch (SecurityException e) { - } - - System.setSecurityManager(securityManager); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies SecurityException.", - method = "readConfiguration", - args = {java.io.InputStream.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies SecurityException.", - method = "readConfiguration", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies SecurityException.", - method = "checkAccess", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies SecurityException.", - method = "reset", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies SecurityException.", - method = "getLogManager", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies SecurityException.", - method = "addPropertyChangeListener", - args = {java.beans.PropertyChangeListener.class} - ) - }) - public void testLoggingPermission() throws IOException { - System.setSecurityManager(new MockSecurityManagerLogPermission()); - mockManager.addLogger(new MockLogger("abc", null)); - mockManager.getLogger(""); - mockManager.getLoggerNames(); - mockManager.getProperty(".level"); - LogManager.getLogManager(); - try { - manager.checkAccess(); - fail("should throw securityException"); - } catch (SecurityException e) { - } - try { - mockManager.readConfiguration(); - fail("should throw SecurityException"); - } catch (SecurityException e) { - } - try { - mockManager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - fail("should throw SecurityException"); - } catch (SecurityException e) { - } - try { - mockManager.readConfiguration(null); - fail("should throw SecurityException"); - } catch (SecurityException e) { - } - try { - mockManager - .addPropertyChangeListener(new MockPropertyChangeListener()); - fail("should throw SecurityException"); - } catch (SecurityException e) { - } - try { - mockManager.addPropertyChangeListener(null); - fail("should throw NPE"); - } catch (NullPointerException e) { - } - try { - mockManager.removePropertyChangeListener(null); - fail("should throw SecurityException"); - } catch (SecurityException e) { - } - try { - mockManager.reset(); - fail("should throw SecurityException"); - } catch (SecurityException e) { - } - System.setSecurityManager(securityManager); - } - - - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "readConfiguration", - args = {java.io.InputStream.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getProperty", - args = {java.lang.String.class} - ) - }) - public void testMockGetProperty() throws Exception { - // mock manager doesn't read configuration until you call - // readConfiguration() - Logger root = new MockLogger("", null); - assertTrue(mockManager.addLogger(root)); - root = mockManager.getLogger(""); - checkPropertyNull(mockManager); - assertEquals(0, root.getHandlers().length); - assertNull(root.getLevel()); - mockManager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - assertEquals(Level.FINE, root.getLevel()); - checkProperty(mockManager); - mockManager.reset(); - checkPropertyNull(mockManager); - assertEquals(Level.INFO, root.getLevel()); - assertEquals(0, mockManager.getLogger("").getHandlers().length); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getProperty", - args = {java.lang.String.class} - ) - public void testGetProperty() throws SecurityException, IOException { - - Logger root = manager.getLogger(""); - manager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - checkProperty(manager); - assertEquals(2, root.getHandlers().length); - assertEquals(Level.FINE, root.getLevel()); - - manager.reset(); - checkPropertyNull(manager); - assertEquals(0, root.getHandlers().length); - assertEquals(Level.INFO, root.getLevel()); - manager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - manager.reset(); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies NullPointerException.", - method = "readConfiguration", - args = {java.io.InputStream.class} - ) - public void testReadConfiguration_null() throws SecurityException, IOException { - try { - manager.readConfiguration(null); - fail("should throw null pointer exception"); - } catch (NullPointerException e) { - } - - } - - private static void checkPropertyNull(LogManager m) { - // assertNull(m.getProperty(".level")); - assertNull(m.getProperty("java.util.logging.FileHandler.limit")); - assertNull(m.getProperty("java.util.logging.ConsoleHandler.formatter")); - // assertNull(m.getProperty("handlers")); - assertNull(m.getProperty("java.util.logging.FileHandler.count")); - assertNull(m.getProperty("com.xyz.foo.level")); - assertNull(m.getProperty("java.util.logging.FileHandler.formatter")); - assertNull(m.getProperty("java.util.logging.ConsoleHandler.level")); - assertNull(m.getProperty("java.util.logging.FileHandler.pattern")); - } - - private static void checkProperty(LogManager m) { - // assertEquals(m.getProperty(".level"), "INFO"); - assertEquals(m.getProperty("java.util.logging.FileHandler.limit"), "50000"); - assertEquals(m.getProperty("java.util.logging.ConsoleHandler.formatter"), - "java.util.logging.SimpleFormatter"); - // assertEquals(m.getProperty("handlers"), - // "java.util.logging.ConsoleHandler"); - assertEquals(m.getProperty("java.util.logging.FileHandler.count"), "5"); - assertEquals(m.getProperty("LogManagerTestFoo.level"), "WARNING"); - assertEquals(m.getProperty("java.util.logging.FileHandler.formatter"), - "java.util.logging.XMLFormatter"); - assertEquals(m.getProperty("java.util.logging.ConsoleHandler.level"), "OFF"); - assertEquals(m.getProperty("java.util.logging.FileHandler.pattern"), "%h/java%u.log"); - } - - // public void testReadConfiguration() throws SecurityException, IOException { - // FIXME: move the support_exec - // Logger foo = new MockLogger("foo", null); - // assertNull(foo.getLevel()); - // assertTrue(mockManager.addLogger(foo)); - // - // Logger fo = new MockLogger("foo2", null); - // fo.setLevel(Level.ALL); - // assertTrue(mockManager.addLogger(fo)); - // - // Handler h = new ConsoleHandler(); - // Level l = h.getLevel(); - // assertNotSame(Level.OFF, h.getLevel()); - // - // // read configuration - // mockManager.readConfiguration(); - // // level DO has effect - // assertEquals(Level.WARNING, foo.getLevel()); - // // for non specified logger, level is reset to null - // assertNull(fo.getLevel()); - // - // // read properties don't affect handler - // assertNotSame(Level.OFF, h.getLevel()); - // assertSame(l, h.getLevel()); - // - // } - - /* - * Class under test for void readConfiguration(InputStream) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "readConfiguration", - args = {java.io.InputStream.class} - ) - public void testReadConfigurationInputStream() throws IOException { - - Logger foo = new MockLogger(FOO, null); - assertNull(foo.getLevel()); - assertTrue(mockManager.addLogger(foo)); - - Logger fo = new MockLogger(FOO + "2", null); - fo.setLevel(Level.ALL); - assertTrue(mockManager.addLogger(fo)); - - Handler h = new ConsoleHandler(); - Level l = h.getLevel(); - assertSame(Level.INFO, h.getLevel()); - - // read configuration from stream - InputStream stream = EnvironmentHelper.PropertiesToInputStream(props); - mockManager.readConfiguration(stream); - stream.close(); - - // level DOES have an effect on LogManagerTestFoo - assertEquals(Level.WARNING, foo.getLevel()); - - // for non specified logger, level is reset to null - assertNull(fo.getLevel()); - - // read properties don't affect handler - assertSame(Level.INFO, h.getLevel()); - assertSame(l, h.getLevel()); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies NullPointerException.", - method = "readConfiguration", - args = {java.io.InputStream.class} - ) - public void testReadConfigurationInputStream_null() throws SecurityException, IOException { - try { - mockManager.readConfiguration(null); - fail("should throw null pointer exception"); - } catch (NullPointerException e) { - } - - } - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies IOException.", - method = "readConfiguration", - args = {java.io.InputStream.class} - ) - public void testReadConfigurationInputStream_IOException_1parm() throws SecurityException { - try { - mockManager.readConfiguration(new MockInputStream()); - fail("should throw IOException"); - } catch (IOException e) { - //ignore - } - - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "readConfiguration", - args = {java.io.InputStream.class} - ) - public void testReadConfigurationInputStream_root() throws IOException { - manager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - - Logger logger = new MockLogger("testReadConfigurationInputStream_root.foo", null); - Logger root = manager.getLogger(""); - Logger logger2 = Logger.getLogger("testReadConfigurationInputStream_root.foo2"); - - manager.addLogger(logger); - assertNull(logger.getLevel()); - assertEquals(0, logger.getHandlers().length); - assertSame(root, logger.getParent()); - - assertNull(logger2.getLevel()); - assertEquals(0, logger2.getHandlers().length); - assertSame(root, logger2.getParent()); - // if (!hasConfigClass) { - assertEquals(Level.FINE, root.getLevel()); - assertEquals(2, root.getHandlers().length); - // } - - // after read stream - InputStream stream = EnvironmentHelper.PropertiesToInputStream(props); - manager.readConfiguration(stream); - stream.close(); - assertEquals(Level.FINE, root.getLevel()); - assertEquals(2, root.getHandlers().length); - assertNull(logger.getLevel()); - assertEquals(0, logger.getHandlers().length); - manager.reset(); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "addPropertyChangeListener", - args = {java.beans.PropertyChangeListener.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "removePropertyChangeListener", - args = {java.beans.PropertyChangeListener.class} - ) - }) - public void testAddRemovePropertyChangeListener() throws Exception { - MockPropertyChangeListener listener1 = new MockPropertyChangeListener(); - MockPropertyChangeListener listener2 = new MockPropertyChangeListener(); - // add same listener1 two times - mockManager.addPropertyChangeListener(listener1); - mockManager.addPropertyChangeListener(listener1); - mockManager.addPropertyChangeListener(listener2); - - assertNull(listener1.getEvent()); - assertNull(listener2.getEvent()); - mockManager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - // if (!hasConfigClass) { - assertNotNull(listener1.getEvent()); - assertNotNull(listener2.getEvent()); - // } - - listener1.reset(); - listener2.reset(); - - // remove listener1, no effect - mockManager.removePropertyChangeListener(listener1); - mockManager.readConfiguration(EnvironmentHelper - .PropertiesToInputStream(props)); - assertNotNull(listener1.getEvent()); - assertNotNull(listener2.getEvent()); - listener1.reset(); - listener2.reset(); - - // remove listener1 again and it works - mockManager.removePropertyChangeListener(listener1); - mockManager.readConfiguration(EnvironmentHelper - .PropertiesToInputStream(props)); - assertNull(listener1.getEvent()); - assertNotNull(listener2.getEvent()); - listener2.reset(); - - // reset don't produce event - mockManager.reset(); - assertNull(listener2.getEvent()); - - mockManager.removePropertyChangeListener(listener2); - mockManager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - assertNull(listener1.getEvent()); - assertNull(listener2.getEvent()); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "addPropertyChangeListener", - args = {java.beans.PropertyChangeListener.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "removePropertyChangeListener", - args = {java.beans.PropertyChangeListener.class} - ) - }) - public void testAddRemovePropertyChangeListener_null() { - // seems nothing happened - try{ - mockManager.addPropertyChangeListener(null); - fail("Should throw NPE"); - }catch(NullPointerException e){ - } - mockManager.removePropertyChangeListener(null); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Doesn't verify SecurityException.", - method = "reset", - args = {} - ) - public void testReset() throws SecurityException, IOException { - // mock LogManager - mockManager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - assertNotNull(mockManager.getProperty("handlers")); - Logger foo = new MockLogger(FOO, null); - assertNull(foo.getLevel()); - assertEquals(0, foo.getHandlers().length); - foo.setLevel(Level.ALL); - foo.addHandler(new ConsoleHandler()); - assertTrue(mockManager.addLogger(foo)); - assertEquals(Level.WARNING, foo.getLevel()); - assertEquals(2, foo.getHandlers().length); - - // reset - mockManager.reset(); - - // properties is cleared - assertNull(mockManager.getProperty("handlers")); - - // level is null - assertNull(foo.getLevel()); - // handlers are all closed - assertEquals(0, foo.getHandlers().length); - - // for root logger - manager.reset(); - assertNull(manager.getProperty("handlers")); - Logger root = manager.getLogger(""); - // level reset to info - assertEquals(Level.INFO, root.getLevel()); - // also close root's handler - assertEquals(0, root.getHandlers().length); - } - - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Doesn't verify SecurityException.", - method = "readConfiguration", - args = {java.io.InputStream.class} - ) - public void testGlobalPropertyConfig() throws Exception { - PrintStream err = System.err; - try { - System.setErr(new PrintStream(new NullOutputStream())); - // before add config property, root has two handler - manager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - assertEquals(2, manager.getLogger("").getHandlers().length); - - // one valid config class - props.setProperty("config", className + "$MockValidConfig"); - manager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - assertEquals(3, manager.getLogger("").getHandlers().length); - - // two config class take effect orderly - props.setProperty("config", className + "$MockValidConfig " + className - + "$MockValidConfig2"); - manager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - assertEquals(2, manager.getLogger("").getHandlers().length); - - props.setProperty("config", className + "$MockValidConfig2 " + className - + "$MockValidConfig"); - manager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - assertEquals(3, manager.getLogger("").getHandlers().length); - - // invalid config class which throw exception, just print exception - // and - // message - props.setProperty("config", className + "$MockInvalidConfigException"); - manager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - - // invalid config class without default constructor, just print - // exception and message - props.setProperty("config", className + "$MockInvalidConfigNoDefaultConstructor"); - manager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - - // bad config class name, just print exception and message - props.setProperty("config", "badname"); - manager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - - // invalid separator, nothing happened - props.setProperty("config", className + "$MockValidConfig2;" + className - + "$MockValidConfig"); - manager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - assertEquals(2, manager.getLogger("").getHandlers().length); - props.setProperty("config", className + "$MockValidConfig2;" + className - + "$MockValidConfig " + className + "$MockValidConfig"); - manager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - assertEquals(3, manager.getLogger("").getHandlers().length); - - // duplicate config class, take effect twice - props.setProperty("config", className + "$MockValidConfig " + className - + "$MockValidConfig"); - manager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - assertEquals(4, manager.getLogger("").getHandlers().length); - - // invalid config classes mixed with valid config classes, valid - // config - // classes take effect - props.setProperty("config", "badname " + className + "$MockValidConfig " + className - + "$MockInvalidConfigNoDefaultConstructor " + className + "$MockValidConfig"); - manager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - assertEquals(4, manager.getLogger("").getHandlers().length); - - // global property take effect before logger specified property - props.setProperty("config", className + "$MockValidConfig"); - manager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props)); - assertEquals(Level.FINE, manager.getLogger("").getLevel()); - } finally { - System.setErr(err); - manager.reset(); - } - - } - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "readConfiguration", - args = {} - ) - public void testValidConfigClass() throws Exception { - String oldProperty = System.getProperty("java.util.logging.config.class"); - try { - // System.setProperty("java.util.logging.config.class", "org.apache.harmony.logging.tests.java.util.logging.LogManagerTest$ConfigClass"); - System.setProperty("java.util.logging.config.class", this.getClass().getName() - + "$ConfigClass"); - assertNull(manager.getLogger("testConfigClass.foo")); - - manager.readConfiguration(); - assertNull(manager.getLogger("testConfigClass.foo")); - Logger l = Logger.getLogger("testConfigClass.foo.child"); - assertSame(Level.FINEST, manager.getLogger("").getLevel()); - assertEquals(0, manager.getLogger("").getHandlers().length); - assertEquals("testConfigClass.foo", l.getParent().getName()); - } finally { - if (oldProperty != null) { - System.setProperty("java.util.logging.config.class", oldProperty); - } - } - } - - /* - * ---------------------------------------------------- - * mock classes - * ---------------------------------------------------- - */ - - - public static class ConfigClass { - public ConfigClass() throws Exception { - LogManager man = LogManager.getLogManager(); - Properties props = new Properties(); - props.put("handlers", className + "$MockHandler " + className + "$MockHandler"); - props.put("java.util.logging.FileHandler.pattern", "%h/java%u.log"); - props.put("java.util.logging.FileHandler.limit", "50000"); - props.put("java.util.logging.FileHandler.count", "5"); - props.put("java.util.logging.FileHandler.formatter", "java.util.logging.XMLFormatter"); - props.put(".level", "FINE"); - props.put("java.util.logging.ConsoleHandler.level", "OFF"); - props.put("java.util.logging.ConsoleHandler.formatter","java.util.logging.SimpleFormatter"); - props.put("LogManagerTestFoo.handlers", "java.util.logging.ConsoleHandler"); - props.put("LogManagerTestFoo.level", "WARNING"); - props.put("testConfigClass.foo.level", "OFF"); - props.put("testConfigClass.foo.handlers", "java.util.logging.ConsoleHandler"); - props.put(".level", "FINEST"); - props.remove("handlers"); - InputStream in = EnvironmentHelper.PropertiesToInputStream(props); - man.readConfiguration(in); - } - } - - public static class MockInvalidInitClass { - public MockInvalidInitClass() { - throw new RuntimeException(); - } - } - - public static class TestInvalidConfigFile { - public static void main(String[] args) { - LogManager manager = LogManager.getLogManager(); - Logger root = manager.getLogger(""); - checkPropertyNull(manager); - assertEquals(0, root.getHandlers().length); - assertEquals(Level.INFO, root.getLevel()); - - try { - manager.readConfiguration(); - } catch (Exception e) { - e.printStackTrace(); - } - checkProperty(manager); - assertNull(root.getHandlers()[0].getLevel()); - assertEquals(1, root.getHandlers().length); - assertEquals(Level.INFO, root.getLevel()); - - manager.reset(); - checkProperty(manager); - assertEquals(0, root.getHandlers().length); - assertEquals(Level.INFO, root.getLevel()); - try { - manager.readConfiguration(); - } catch (Exception e) { - e.printStackTrace(); - } - manager.reset(); - } - } - - public static class TestValidConfigFile { - public static void main(String[] args) { - LogManager manager = LogManager.getLogManager(); - Logger root = manager.getLogger(""); - checkPropertyNull(manager); - assertEquals(2, root.getHandlers().length); - assertEquals(root.getHandlers()[0].getLevel(), Level.OFF); - assertEquals(Level.ALL, root.getLevel()); - - try { - manager.readConfiguration(); - } catch (Exception e) { - e.printStackTrace(); - } - checkPropertyNull(manager); - assertEquals(root.getHandlers()[0].getLevel(), Level.OFF); - assertEquals(2, root.getHandlers().length); - assertEquals(Level.ALL, root.getLevel()); - - manager.reset(); - checkPropertyNull(manager); - assertEquals(0, root.getHandlers().length); - assertEquals(Level.INFO, root.getLevel()); - try { - manager.readConfiguration(); - } catch (Exception e) { - e.printStackTrace(); - } - manager.reset(); - } - } - - public static class TestMockLogManager { - public static void main(String[] args) { - LogManager manager = LogManager.getLogManager(); - assertTrue(manager instanceof MockLogManager); - } - } - - public static class TestValidConfigClass { - public static void main(String[] args) { - LogManager manager = LogManager.getLogManager(); - Logger root = manager.getLogger(""); - checkPropertyNull(manager); - assertEquals(1, root.getHandlers().length); - assertEquals(Level.OFF, root.getLevel()); - - try { - manager.readConfiguration(); - } catch (Exception e) { - e.printStackTrace(); - } - checkPropertyNull(manager); - assertEquals(1, root.getHandlers().length); - assertEquals(Level.OFF, root.getLevel()); - - try { - manager.readConfiguration(); - } catch (Exception e) { - e.printStackTrace(); - } - checkPropertyNull(manager); - assertEquals(1, root.getHandlers().length); - assertEquals(Level.OFF, root.getLevel()); - - manager.reset(); - checkPropertyNull(manager); - assertEquals(0, root.getHandlers().length); - assertEquals(Level.INFO, root.getLevel()); - try { - manager.readConfiguration(); - } catch (Exception e) { - e.printStackTrace(); - } - manager.reset(); - } - } - - public static class MockLogger extends Logger { - public MockLogger(String name, String rbName) { - super(name, rbName); - } - } - - public static class MockLogManager extends LogManager { - } - - public static class MockHandler extends Handler { - static int number = 0; - - public MockHandler() { - addNumber(); - // System.out.println(this + ":start:" + number); - } - - private synchronized void addNumber() { - number++; - } - - public void close() { - minusNumber(); - // System.out.println(this + ":close:" + number); - } - - private synchronized void minusNumber() { - number--; - } - - public void flush() { - // System.out.println(this + ":flush"); - } - - public void publish(LogRecord record) { - } - - } - - public static class MockValidInitClass { - public MockValidInitClass() { - Properties p = new Properties(); - p.put("handlers", className + "$MockHandler"); - p.put(".level", "OFF"); - InputStream in = null; - try { - in = EnvironmentHelper.PropertiesToInputStream(p); - LogManager manager = LogManager.getLogManager(); - manager.readConfiguration(in); - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - in.close(); - } catch (Exception e) { - } - } - } - } - - public static class MockValidConfig { - public MockValidConfig() { - handler = new MockHandler(); - LogManager manager = LogManager.getLogManager(); - Logger root = null; - if (null != manager) { - root = manager.getLogger(""); - } else { - System.out.println("null manager"); - } - if (null != root) { - root.addHandler(handler); - root.setLevel(Level.OFF); - } - } - } - - public static class MockValidConfig2 { - - static Logger root = null; - - public MockValidConfig2() { - root = LogManager.getLogManager().getLogger(""); - root.removeHandler(handler); - } - } - - public static class MockInvalidConfigException { - public MockInvalidConfigException() { - throw new RuntimeException("invalid config class - throw exception"); - } - } - - public static class MockInvalidConfigNoDefaultConstructor { - public MockInvalidConfigNoDefaultConstructor(int i) { - throw new RuntimeException("invalid config class - no default constructor"); - } - } - - public static class MockPropertyChangeListener implements - PropertyChangeListener { - - PropertyChangeEvent event = null; - - public void propertyChange(PropertyChangeEvent event) { - this.event = event; - } - - public PropertyChangeEvent getEvent() { - return event; - } - - public void reset() { - event = null; - } - - } - - public static class MockSecurityManagerLogPermission extends SecurityManager { - - public void checkPermission(Permission permission, Object context) { - if (permission instanceof LoggingPermission) { - throw new SecurityException(); - } - } - - public void checkPermission(Permission permission) { - if (permission instanceof LoggingPermission) { - StackTraceElement[] stack = (new Throwable()).getStackTrace(); - for (int i = 0; i < stack.length; i++) { - if (stack[i].getClassName().equals("java.util.logging.Logger")) { - return; - } - } - throw new SecurityException("Found LogManager checkAccess()"); - } - } - } - - public static class MockSecurityManagerOtherPermission extends SecurityManager { - - public void checkPermission(Permission permission, Object context) { - if (permission instanceof LoggingPermission) { - return; - } - if (permission.getName().equals("setSecurityManager")) { - return; - } - // throw new SecurityException(); - super.checkPermission(permission, context); - } - - public void checkPermission(Permission permission) { - if (permission instanceof LoggingPermission) { - return; - } - if (permission.getName().equals("setSecurityManager")) { - return; - } - super.checkPermission(permission); - } - } - - /* - * Test config class loading - * java -Djava.util.logging.config.class=badConfigClassName ClassLoadingTest - */ - public static class ClassLoadingTest { - public static void main(String[] args) { - Thread.currentThread().setContextClassLoader(new MockErrorClassLoader()); - try { - LogManager.getLogManager(); - fail("Should throw mock error"); - } catch (MockError e) { - } - } - - static class MockErrorClassLoader extends ClassLoader { - public Class loadClass(String name) { - throw new MockError(); - } - } - - static class MockError extends Error { - } - } - - public static class MockInputStream extends InputStream { - - @Override - public int read() throws IOException { - throw new IOException(); - } - - - } - - -} diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogRecordTest.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogRecordTest.java deleted file mode 100644 index 5b21099e1..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogRecordTest.java +++ /dev/null @@ -1,777 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.logging.tests.java.util.logging; - -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import java.io.Serializable; -import java.util.Locale; -import java.util.ResourceBundle; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogRecord; -import java.util.logging.Logger; - - -import junit.framework.TestCase; - -import org.apache.harmony.testframework.serialization.SerializationTest; -import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert; - -@TestTargetClass(LogRecord.class) -public class LogRecordTest extends TestCase { - - static final String MSG = "test msg, pls. ignore itb"; - - private LogRecord lr; - - private static String className = LogRecordTest.class.getName(); - - protected void setUp() throws Exception { - super.setUp(); - lr = new LogRecord(Level.CONFIG, MSG); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "LogRecord", - args = {java.util.logging.Level.class, java.lang.String.class} - ) - public void testLogRecordWithNullPointers() { - try { - new LogRecord(null, null); - fail("should throw NullPointerException"); - } catch (NullPointerException e) { - } - try { - new LogRecord(null, MSG); - fail("should throw NullPointerException"); - } catch (NullPointerException e) { - } - LogRecord r = new LogRecord(Level.WARNING, null); - assertSame(r.getLevel(), Level.WARNING); - assertNull(r.getMessage()); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "normally set/get don't need to be tested", - method = "getLoggerName", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "normally set/get don't need to be tested", - method = "setLoggerName", - args = {java.lang.String.class} - ) - }) - public void testGetSetLoggerName() { - assertNull(lr.getLoggerName()); - lr.setLoggerName(null); - assertNull(lr.getLoggerName()); - lr.setLoggerName("test logger name"); - assertEquals("test logger name", lr.getLoggerName()); - } - - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getResourceBundle", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setResourceBundle", - args = {java.util.ResourceBundle.class} - ) - }) - public void testGetSetResourceBundle() { - assertNull(lr.getResourceBundleName()); - assertNull(lr.getResourceBundle()); - - lr.setResourceBundle(null); - assertNull(lr.getResourceBundle()); - - lr.setResourceBundleName("bundles/java/util/logging/res"); - assertNull(lr.getResourceBundle()); - - lr.setResourceBundleName(null); - ResourceBundle rb = ResourceBundle - .getBundle("bundles/java/util/logging/res"); - lr.setResourceBundle(rb); - assertEquals(rb, lr.getResourceBundle()); - assertNull(lr.getResourceBundleName()); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getResourceBundleName", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setResourceBundleName", - args = {java.lang.String.class} - ) - }) - public void testGetSetResourceBundleName() { - assertNull(lr.getResourceBundleName()); - lr.setResourceBundleName(null); - assertNull(lr.getResourceBundleName()); - lr.setResourceBundleName("test"); - assertEquals("test", lr.getResourceBundleName()); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "normal behavior of getter/setter don't need to be tested (normally)", - method = "getLevel", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "normal behavior of getter/setter don't need to be tested (normally)", - method = "setLevel", - args = {java.util.logging.Level.class} - ) - }) - public void testGetSetLevelNormal() { - assertSame(lr.getLevel(), Level.CONFIG); - lr.setLevel(Level.ALL); - assertSame(lr.getLevel(), Level.ALL); - lr.setLevel(Level.FINEST); - assertSame(lr.getLevel(), Level.FINEST); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getLevel", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setLevel", - args = {java.util.logging.Level.class} - ) - }) - public void testGetSetLevelNullPointerException() { - try { - lr.setLevel(null); - fail("should throw NullPointerException"); - } catch (NullPointerException e) { - } - assertSame(lr.getLevel(), Level.CONFIG); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getSequenceNumber", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setSequenceNumber", - args = {long.class} - ) - }) - public void testGetSetSequenceNumber() { - long l = lr.getSequenceNumber(); - lr.setSequenceNumber(-111); - assertEquals(lr.getSequenceNumber(), -111L); - lr.setSequenceNumber(0); - assertEquals(lr.getSequenceNumber(), 0L); - lr = new LogRecord(Level.ALL, null); //sequenceNumber is updated to a private static counter - assertEquals(lr.getSequenceNumber(), l + 1); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getSourceClassName", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setSourceClassName", - args = {java.lang.String.class} - ) - }) - public void testGetSetSourceClassName() { - lr.setSourceClassName(null); - assertNull(lr.getSourceClassName()); - lr.setSourceClassName("bad class name"); - assertEquals("bad class name", lr.getSourceClassName()); - lr.setSourceClassName(this.getClass().getName()); - assertEquals(this.getClass().getName(), lr.getSourceClassName()); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getSourceMethodName", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "setSourceMethodName", - args = {java.lang.String.class} - ) - }) - public void testGetSetSourceMethodName() { - lr.setSourceMethodName(null); - assertNull(lr.getSourceMethodName()); - lr.setSourceMethodName("bad class name"); - assertEquals("bad class name", lr.getSourceMethodName()); - lr.setSourceMethodName(this.getClass().getName()); - assertEquals(this.getClass().getName(), lr.getSourceMethodName()); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getSourceMethodName", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "setSourceMethodName", - args = {java.lang.String.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getSourceClassName", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "setSourceClassName", - args = {java.lang.String.class} - ) - }) - public void testGetSourceDefaultValue() { - assertNull(lr.getSourceMethodName()); - assertNull(lr.getSourceClassName()); - - // find class and method who called logger - Logger logger = Logger.global; - MockHandler handler = new MockHandler(); - logger.addHandler(handler); - logger.log(Level.SEVERE, MSG); - assertEquals(this.getClass().getName(), handler.getSourceClassName()); - assertEquals("testGetSourceDefaultValue", handler.getSourceMethodName()); - - // only set source method to null - lr = new LogRecord(Level.SEVERE, MSG); - lr.setSourceMethodName(null); - logger.log(lr); - assertNull(handler.getSourceClassName()); - assertNull(handler.getSourceMethodName()); - - // only set source class to null - lr = new LogRecord(Level.SEVERE, MSG); - lr.setSourceClassName(null); - logger.log(lr); - assertNull(handler.getSourceClassName()); - assertNull(handler.getSourceMethodName()); - - // set both - lr = new LogRecord(Level.SEVERE, MSG); - lr.setSourceClassName("className"); - lr.setSourceMethodName("methodName"); - logger.log(lr); - assertEquals("className", handler.getSourceClassName()); - assertEquals("methodName", handler.getSourceMethodName()); - - // test if LogRecord is constructed in another class, and is published - // by Logger - logger.log(RecordFactory.getDefaultRecord()); - assertEquals(this.getClass().getName(), handler.getSourceClassName()); - assertEquals("testGetSourceDefaultValue", handler.getSourceMethodName()); - - lr = RecordFactory.getDefaultRecord(); - RecordFactory.log(logger, lr); - assertEquals(RecordFactory.class.getName(), handler - .getSourceClassName()); - assertEquals("log", handler.getSourceMethodName()); - - // only try once to get the default value - lr = RecordFactory.getDefaultRecord(); - assertNull(lr.getSourceClassName()); - assertNull(lr.getSourceMethodName()); - RecordFactory.log(logger, lr); - assertNull(handler.getSourceClassName()); - assertNull(handler.getSourceMethodName()); - - MockLogger ml = new MockLogger("foo", null); - ml.addHandler(handler); - ml.info(MSG); - assertEquals(className + "$MockLogger", handler.getSourceClassName()); - assertEquals("info", handler.getSourceMethodName()); - - ml = new MockLogger("foo", null); - ml.addHandler(handler); - ml.log(Level.SEVERE, MSG); - assertNull(handler.getSourceClassName()); - assertNull(handler.getSourceMethodName()); - - lr = new LogRecord(Level.SEVERE, MSG); - handler.publish(lr); - assertNull(handler.getSourceClassName()); - assertNull(handler.getSourceMethodName()); - logger.removeHandler(handler); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getMessage", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setMessage", - args = {java.lang.String.class} - ) - }) - public void testGetSetMessage() { - assertEquals(MSG, lr.getMessage()); - lr.setMessage(null); - assertNull(lr.getMessage()); - lr.setMessage(""); - assertEquals("", lr.getMessage()); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getParameters", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setParameters", - args = {java.lang.Object[].class} - ) - }) - public void testGetSetParameters() { - assertNull(lr.getParameters()); - lr.setParameters(null); - assertNull(lr.getParameters()); - Object[] oa = new Object[0]; - lr.setParameters(oa); - assertEquals(oa, lr.getParameters()); - oa = new Object[] {new Object(), new Object()}; - lr.setParameters(oa); - assertSame(oa, lr.getParameters()); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getMillis", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setMillis", - args = {long.class} - ) - }) - public void testGetSetMillis() { - long milli = lr.getMillis(); - assertTrue(milli > 0); - lr.setMillis(-1); - assertEquals(-1, lr.getMillis()); - lr.setMillis(0); - assertEquals(0, lr.getMillis()); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getMillis", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setMillis", - args = {long.class} - ) - }) - public void testGetSetTimeCheck() { - long before = lr.getMillis(); - try { - Thread.sleep(2); - } catch (InterruptedException e) { - e.printStackTrace(); - } - LogRecord lr2 = new LogRecord(Level.CONFIG, "MSG2"); - long after = lr2.getMillis(); - assertTrue(after-before>0); - } - - - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getThreadID", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setThreadID", - args = {int.class} - ) - }) - public void testGetSetThreadID() { - int id = lr.getThreadID(); - lr = new LogRecord(Level.ALL, "a1"); - assertEquals(id, lr.getThreadID()); - lr.setThreadID(id + 10); - assertEquals(id + 10, lr.getThreadID()); - lr = new LogRecord(Level.ALL, "a1"); - assertEquals(id, lr.getThreadID()); - } - - /* - * Check threadID are different - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getThreadID", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setThreadID", - args = {int.class} - ) - }) - public void testGetSetThreadID_DifferentThread() { - int id = lr.getThreadID(); - // Create and start the thread - MockThread thread = new MockThread(); - thread.start(); - try { - thread.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - // Create and start the thread2 - MockThread thread2 = new MockThread(); - thread2.start(); - try { - thread2.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - //All threadID must be different, based on the ThreadLocal.java ID - assertTrue(lr.getThreadID() != thread.lr.getThreadID()); - assertTrue(lr.getThreadID() != thread2.lr.getThreadID()); - assertTrue(thread.lr.getThreadID() != thread2.lr.getThreadID()); - } - - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getThrown", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setThrown", - args = {java.lang.Throwable.class} - ) - }) - public void testGetSetThrown() { - assertNull(lr.getThrown()); - lr.setThrown(null); - assertNull(lr.getThrown()); - Throwable e = new Exception(); - lr.setThrown(e); - assertEquals(e, lr.getThrown()); - Throwable n = new NullPointerException(); - lr.setThrown(n); - assertEquals(n, lr.getThrown()); - } - - // comparator for LogRecord objects - private static final SerializableAssert LOGRECORD_COMPARATOR = new SerializableAssert() { - public void assertDeserialized(Serializable initial, - Serializable deserialized) { - - LogRecord init = (LogRecord) initial; - LogRecord dser = (LogRecord) deserialized; - - assertEquals("Class", init.getClass(), dser.getClass()); - assertEquals("Level", init.getLevel(), dser.getLevel()); - assertEquals("LoggerName", init.getLoggerName(), dser - .getLoggerName()); - assertEquals("Message", init.getMessage(), dser.getMessage()); - assertEquals("Millis", init.getMillis(), dser.getMillis()); - - // compare parameters - Object[] paramInit = init.getParameters(); - Object[] paramDser = dser.getParameters(); - assertEquals("Parameters length", paramInit.length, - paramDser.length); - for (int i = 0; i < paramInit.length; i++) { - assertEquals("Param: " + i, paramInit[i].toString(), - paramDser[i]); - } - - // don't check ResourceBundle object - // verify only bundle's name - assertEquals("ResourceBundleName", init.getResourceBundleName(), - dser.getResourceBundleName()); - assertEquals("SequenceNumber", init.getSequenceNumber(), dser - .getSequenceNumber()); - assertEquals("SourceClassName", init.getSourceClassName(), dser - .getSourceClassName()); - assertEquals("SourceMethodName", init.getSourceMethodName(), dser - .getSourceMethodName()); - assertEquals("ThreadID", init.getThreadID(), dser.getThreadID()); - - SerializationTest.THROWABLE_COMPARATOR.assertDeserialized(init - .getThrown(), dser.getThrown()); - } - }; - - /** - * @tests serialization/deserialization compatibility. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "serialisation/deserialization", - method = "!SerializationSelf", - args = {} - ) - public void testSerializationSelf() throws Exception { - LogRecord r = new LogRecord(Level.ALL, "msg"); - r.setLoggerName("LoggerName"); - r.setMillis(123456789); - r.setResourceBundleName("ResourceBundleName"); - r.setSequenceNumber(987654321); - r.setSourceClassName("SourceClassName"); - r.setSourceMethodName("SourceMethodName"); - r.setParameters(new Object[] {"test string", new Exception("ex-msg")}); - r.setThreadID(3232); - r.setThrown(new Exception("ExceptionMessage")); - - SerializationTest.verifySelf(r, LOGRECORD_COMPARATOR); - } - - /** - * @tests resolution of resource bundle for serialization/deserialization. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "tests resolution of resource bundle during deserialization", - method = "!Serialization", - args = {} - ) - public void testSerializationResourceBundle() throws Exception { - - // test case: valid resource bundle name - lr.setResourceBundleName("bundles/java/util/logging/res2"); - lr.setResourceBundle(ResourceBundle.getBundle( - "bundles/java/util/logging/res", Locale.US)); - - LogRecord result = (LogRecord) SerializationTest.copySerializable(lr); - assertNotNull(result.getResourceBundle()); - - // test case: invalid resource bundle name, it is not resolved during - // deserialization LogRecord object so check for returned null value - lr.setResourceBundleName("bad bundle name"); - lr.setResourceBundle(ResourceBundle.getBundle( - "bundles/java/util/logging/res", Locale.US)); - - result = (LogRecord) SerializationTest.copySerializable(lr); - assertNull(result.getResourceBundle()); - } - - /** - * @tests serialization/deserialization compatibility with RI. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "!SerializationGolden", - args = {} - ) - public void testSerializationCompatibility() throws Exception { - LogRecord r = new LogRecord(Level.ALL, "msg"); - r.setLoggerName("LoggerName"); - r.setMillis(123456789); - r.setResourceBundleName("ResourceBundleName"); - r.setSequenceNumber(987654321); - r.setSourceClassName("SourceClassName"); - r.setSourceMethodName("SourceMethodName"); - r.setParameters(new Object[] {"test string", new Exception("ex-msg")}); - r.setThreadID(3232); - r.setThrown(new Exception("ExceptionMessage")); - - SerializationTest.verifyGolden(this, r, LOGRECORD_COMPARATOR); - } - - public static class MockHandler extends Handler { - private String className; - - private String methodName; - - public void close() { - } - - public void flush() { - } - - public void publish(LogRecord record) { - className = record.getSourceClassName(); - methodName = record.getSourceMethodName(); - } - - public String getSourceMethodName() { - return methodName; - } - - public String getSourceClassName() { - return className; - } - } - - // mock class, try to test when the sourceclass and sourcemethod of - // LogRecord is initiated - public static class RecordFactory { - - public static LogRecord getDefaultRecord() { - return new LogRecord(Level.SEVERE, MSG); - } - - public static void log(Logger logger, LogRecord lr) { - logger.log(lr); - } - } - - public static class MockLogger extends Logger { - - /** - * @param name - * @param resourceBundleName - */ - public MockLogger(String name, String resourceBundleName) { - super(name, resourceBundleName); - } - - public void log(Level l, String s) { - this.log(new LogRecord(l, s)); - } - - public void info(String s) { - super.info(s); - } - - public void log(LogRecord record) { - if (isLoggable(record.getLevel())) { - // call the handlers of this logger - // TODO: What if an exception occurred in handler? - Handler[] ha = this.getHandlers(); - for (int i = 0; i < ha.length; i++) { - ha[i].publish(record); - } - // call the parent's handlers if set useParentHandlers - if (getUseParentHandlers()) { - Logger anyParent = this.getParent(); - while (null != anyParent) { - ha = anyParent.getHandlers(); - for (int i = 0; i < ha.length; i++) { - ha[i].publish(record); - } - if (anyParent.getUseParentHandlers()) { - anyParent = anyParent.getParent(); - } else { - break; - } - } - } - } - } - } - - public class MockThread extends Thread { - - public LogRecord lr = null; //will be update by the thread - - public MockThread(){ - super(); - } - - public void run() { - update(); - } - - public synchronized void update(){ - lr = new LogRecord(Level.CONFIG, "msg thread"); - } - - } -} diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java deleted file mode 100644 index 8a981bbf8..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java +++ /dev/null @@ -1,4792 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.logging.tests.java.util.logging; - -import java.security.Permission; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.Properties; -import java.util.ResourceBundle; -import java.util.logging.Filter; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogManager; -import java.util.logging.LogRecord; -import java.util.logging.Logger; -import java.util.logging.LoggingPermission; -import java.io.File; -import java.io.FileInputStream; - -import junit.framework.TestCase; - -import org.apache.harmony.logging.tests.java.util.logging.util.EnvironmentHelper; - -import tests.util.CallVerificationStack; -import dalvik.annotation.KnownFailure; -import dalvik.annotation.SideEffect; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargets; - -/** - * Test suite for the class java.util.logging.Logger. - */ -@TestTargetClass(Logger.class) -public class LoggerTest extends TestCase { - - private final static String VALID_RESOURCE_BUNDLE = "bundles/java/util/logging/res"; - - private final static String VALID_RESOURCE_BUNDLE2 = "bundles/java/util/logging/res2"; - - private final static String VALID_RESOURCE_BUNDLE3 = "bundles/java/util/logging/res3"; - - private final static String INVALID_RESOURCE_BUNDLE = "impossible_not_existing"; - - private final static String LOGGING_CONFIG_FILE = "src/test/resources/config/java/util/logging/logging.config"; - - private final static String VALID_KEY = "LOGGERTEST"; - - private final static String VALID_VALUE = "Test_ZH_CN"; - - private final static String VALID_VALUE2 = "Test_NoLocale2"; - - private Logger sharedLogger = null; - - private Locale oldLocale = null; - - /* - * @see TestCase#setUp() Notice : Logger constructor is protected => - * MockLogger - */ - protected void setUp() throws Exception { - super.setUp(); - LogManager.getLogManager().reset(); - oldLocale = Locale.getDefault(); - Locale.setDefault(new Locale("zh", "CN")); - sharedLogger = new MockLogger("SharedLogger", VALID_RESOURCE_BUNDLE); - sharedLogger.addHandler(new MockHandler()); - } - - /* - * Reset the log manager. - */ - protected void tearDown() throws Exception { - CallVerificationStack.getInstance().clear(); - Locale.setDefault(oldLocale); - LogManager.getLogManager().reset(); - super.tearDown(); - } - - /* - * Test the global logger - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "Logger", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testGlobalLogger() { - assertNull(Logger.global.getFilter()); - assertEquals(0, Logger.global.getHandlers().length); - assertNull(Logger.global.getLevel()); - assertEquals("global", Logger.global.getName()); - assertNull(Logger.global.getParent().getParent()); - assertNull(Logger.global.getResourceBundle()); - assertNull(Logger.global.getResourceBundleName()); - assertTrue(Logger.global.getUseParentHandlers()); - assertSame(Logger.global, Logger.getLogger("global")); - assertSame(Logger.global, LogManager.getLogManager() - .getLogger("global")); - } - - /* - * Test constructor under normal conditions. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies constructor under normal conditions.", - method = "Logger", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testConstructor_Normal() { - MockLogger mlog = new MockLogger("myname", VALID_RESOURCE_BUNDLE); - assertNull(mlog.getFilter()); - assertEquals(0, mlog.getHandlers().length); - assertNull(mlog.getLevel()); - assertEquals("myname", mlog.getName()); - assertNull(mlog.getParent()); - ResourceBundle rb = mlog.getResourceBundle(); - assertEquals(VALID_VALUE, rb.getString(VALID_KEY)); - assertEquals(mlog.getResourceBundleName(), VALID_RESOURCE_BUNDLE); - assertTrue(mlog.getUseParentHandlers()); - } - - /* - * Test constructor with null parameters. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies constructor with null parameters.", - method = "Logger", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testConstructor_Null() { - MockLogger mlog = new MockLogger(null, null); - assertNull(mlog.getFilter()); - assertEquals(0, mlog.getHandlers().length); - assertNull(mlog.getLevel()); - assertNull(mlog.getName()); - assertNull(mlog.getParent()); - assertNull(mlog.getResourceBundle()); - assertNull(mlog.getResourceBundleName()); - assertTrue(mlog.getUseParentHandlers()); - } - - /* - * Test constructor with invalid name. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies constructor with invalid name.", - method = "Logger", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testConstructor_InvalidName() { - MockLogger mlog = new MockLogger("...#$%%^&&()-_+=!@~./,[]{};:'\\\"?|", - null); - assertEquals("...#$%%^&&()-_+=!@~./,[]{};:'\\\"?|", mlog.getName()); - } - - /* - * Test constructor with empty name. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies constructor with empty name.", - method = "Logger", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testConstructor_EmptyName() { - MockLogger mlog = new MockLogger("", null); - assertEquals("", mlog.getName()); - } - - /* - * Test constructor with invalid resource bundle name. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies MissingResourceException.", - method = "Logger", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testConstructor_InvalidResourceBundle() { - - // try anonymous with invalid resource - try { - new MockLogger(null, INVALID_RESOURCE_BUNDLE); - fail("Should throw MissingResourceException!"); - } catch (MissingResourceException e) { - // ok ! - } - // try named Logger with invalid resource - try { - new MockLogger("testConstructor_InvalidResourceBundle", - INVALID_RESOURCE_BUNDLE); - fail("Should throw MissingResourceException!"); - } catch (MissingResourceException e) { - // ok ! - } - // try empty string - try { - new MockLogger(null, ""); - fail("Should throw MissingResourceException!"); - } catch (MissingResourceException e) { - // ok ! - } - } - - /* - * Test getAnonymousLogger() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getAnonymousLogger", - args = {} - ) - public void testGetAnonymousLogger() { - Logger alog = Logger.getAnonymousLogger(); - assertNotSame(alog, Logger.getAnonymousLogger()); - assertNull(alog.getFilter()); - assertEquals(0, alog.getHandlers().length); - assertNull(alog.getLevel()); - assertNull(alog.getName()); - assertEquals("", alog.getParent().getName()); - assertNull(alog.getParent().getParent()); - assertNull(alog.getResourceBundle()); - assertNull(alog.getResourceBundleName()); - assertTrue(alog.getUseParentHandlers()); - } - - /* - * Test getAnonymousLogger(String resourceBundleName) with valid resource - * bundle. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getAnonymousLogger(String resourceBundleName) with valid resource bundle.", - method = "getAnonymousLogger", - args = {java.lang.String.class} - ) - public void testGetAnonymousLogger_ValidResourceBundle() { - Logger alog = Logger.getAnonymousLogger(VALID_RESOURCE_BUNDLE); - assertNotSame(alog, Logger.getAnonymousLogger(VALID_RESOURCE_BUNDLE)); - assertNull(alog.getFilter()); - assertEquals(0, alog.getHandlers().length); - assertNull(alog.getLevel()); - assertNull(alog.getName()); - assertEquals("", alog.getParent().getName()); - assertNull(alog.getParent().getParent()); - assertEquals(VALID_VALUE, alog.getResourceBundle().getString(VALID_KEY)); - assertEquals(alog.getResourceBundleName(), VALID_RESOURCE_BUNDLE); - assertTrue(alog.getUseParentHandlers()); - } - - /* - * Test getAnonymousLogger(String resourceBundleName) with null resource - * bundle. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getAnonymousLogger(String resourceBundleName) with null resource bundle.", - method = "getAnonymousLogger", - args = {java.lang.String.class} - ) - public void testGetAnonymousLogger_NullResourceBundle() { - Logger alog = Logger.getAnonymousLogger(null); - assertNotSame(alog, Logger.getAnonymousLogger(null)); - assertNull(alog.getFilter()); - assertEquals(0, alog.getHandlers().length); - assertNull(alog.getLevel()); - assertNull(alog.getName()); - assertEquals("", alog.getParent().getName()); - assertNull(alog.getParent().getParent()); - assertNull(alog.getResourceBundle()); - assertNull(alog.getResourceBundleName()); - assertTrue(alog.getUseParentHandlers()); - } - - /* - * Test getAnonymousLogger(String resourceBundleName) with invalid resource - * bundle. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getAnonymousLogger(String resourceBundleName) with invalid resource bundle.", - method = "getAnonymousLogger", - args = {java.lang.String.class} - ) - public void testGetAnonymousLogger_InvalidResourceBundle() { - try { - Logger.getAnonymousLogger(INVALID_RESOURCE_BUNDLE); - fail("Should throw MissingResourceException!"); - } catch (MissingResourceException e) { - } - // try empty name - try { - Logger.getAnonymousLogger(""); - fail("Should throw MissingResourceException!"); - } catch (MissingResourceException e) { - } - } - - /* - * Test getLogger(String), getting a logger with no parent. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getLogger(String), getting a logger with no parent.", - method = "getLogger", - args = {java.lang.String.class} - ) - public void testGetLogger_Normal() throws Exception { - // config the level - Properties p = new Properties(); - p.put("testGetLogger_Normal_ANewLogger.level", "ALL"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - assertNull(LogManager.getLogManager().getLogger( - "testGetLogger_Normal_ANewLogger")); - // create a new logger - Logger log = Logger.getLogger("testGetLogger_Normal_ANewLogger"); - // get an existing logger - assertSame(log, Logger.getLogger("testGetLogger_Normal_ANewLogger")); - // check it has been registered - assertSame(log, LogManager.getLogManager().getLogger( - "testGetLogger_Normal_ANewLogger")); - - assertNull(log.getFilter()); - assertEquals(0, log.getHandlers().length); - // check it's set to the preconfigured level - assertSame(Level.ALL, log.getLevel()); - assertEquals("testGetLogger_Normal_ANewLogger", log.getName()); - assertNull(log.getParent().getParent()); - assertNull(log.getResourceBundle()); - assertNull(log.getResourceBundleName()); - assertTrue(log.getUseParentHandlers()); - - - } - - /* - * Test getLogger(String), getting a logger with invalid level configured. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getLogger(String), getting a logger with invalid level configured.", - method = "getLogger", - args = {java.lang.String.class} - ) - public void testGetLogger_InvalidLevel() throws Exception { - // config the level - Properties p = new Properties(); - p - .put("testGetLogger_InvalidLevel_ANewLogger.level", - "impossible_level"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - assertNull(LogManager.getLogManager().getLogger( - "testGetLogger_InvalidLevel_ANewLogger")); - // create a new logger - Logger log = Logger.getLogger("testGetLogger_InvalidLevel_ANewLogger"); - // get an existing logger - assertSame(log, Logger - .getLogger("testGetLogger_InvalidLevel_ANewLogger")); - // check it has been registered - assertSame(log, LogManager.getLogManager().getLogger( - "testGetLogger_InvalidLevel_ANewLogger")); - assertNull(log.getLevel()); - } - - /* - * Test getLogger(String) with null name. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getLogger(String) with null name.", - method = "getLogger", - args = {java.lang.String.class} - ) - public void testGetLogger_Null() { - try { - Logger.getLogger(null); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - // ok ! - } - try { - Logger.getLogger(null, null); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - // ok ! - } - } - - /* - * Test getLogger(String) with invalid name. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getLogger(String) with invalid name.", - method = "getLogger", - args = {java.lang.String.class} - ) - public void testGetLogger_Invalid() { - Logger log = Logger.getLogger("...#$%%^&&()-_+=!@~./,[]{};:'\\\"?|"); - assertEquals("...#$%%^&&()-_+=!@~./,[]{};:'\\\"?|", log.getName()); - } - - /* - * Test getLogger(String) with empty name. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getLogger(String) with empty name.", - method = "getLogger", - args = {java.lang.String.class} - ) - public void testGetLogger_Empty() { - assertNotNull(LogManager.getLogManager().getLogger("")); - Logger log = Logger.getLogger(""); - assertSame(log, LogManager.getLogManager().getLogger("")); - assertNull(log.getFilter()); - assertEquals(0, log.getHandlers().length); - // check it's set to the preconfigured level - assertSame(Level.INFO, log.getLevel()); - assertEquals("", log.getName()); - assertNull(log.getParent()); - assertTrue(log.getUseParentHandlers()); - assertNull(log.getResourceBundle()); - assertNull(log.getResourceBundleName()); - } - - /* - * Test getLogger(String), getting a logger with existing parent. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getLogger(String), getting a logger with existing parent.", - method = "getLogger", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testGetLogger_WithParent() { - assertNull(LogManager.getLogManager().getLogger( - "testGetLogger_WithParent_ParentLogger")); - - // get root of hierarchy - Logger root = Logger.getLogger(""); - // create the parent logger - Logger pLog = Logger.getLogger("testGetLogger_WithParent_ParentLogger", - VALID_RESOURCE_BUNDLE); - pLog.setLevel(Level.CONFIG); - pLog.addHandler(new MockHandler()); - pLog.setFilter(new MockFilter()); - pLog.setUseParentHandlers(false); - // check root parent - assertEquals("testGetLogger_WithParent_ParentLogger", pLog.getName()); - assertSame(pLog.getParent(), root); - - // child part - assertNull(LogManager.getLogManager().getLogger( - "testGetLogger_WithParent_ParentLogger.child")); - // create the child logger - Logger child = Logger - .getLogger("testGetLogger_WithParent_ParentLogger.child"); - assertNull(child.getFilter()); - assertEquals(0, child.getHandlers().length); - assertNull(child.getLevel()); - assertEquals("testGetLogger_WithParent_ParentLogger.child", child - .getName()); - assertSame(child.getParent(), pLog); - assertNull(child.getResourceBundle()); - assertNull(child.getResourceBundleName()); - assertTrue(child.getUseParentHandlers()); - - // create not valid child - Logger notChild = Logger - .getLogger("testGetLogger_WithParent_ParentLogger1.child"); - assertNull(notChild.getFilter()); - assertEquals(0, notChild.getHandlers().length); - assertNull(notChild.getLevel()); - assertEquals("testGetLogger_WithParent_ParentLogger1.child", notChild - .getName()); - assertNotSame(notChild.getParent(), pLog); - assertNull(notChild.getResourceBundle()); - assertNull(notChild.getResourceBundleName()); - assertTrue(notChild.getUseParentHandlers()); - // verify two level root.parent - assertEquals("testGetLogger_WithParent_ParentLogger.child", child - .getName()); - assertSame(child.getParent().getParent(), root); - - - // create three level child - Logger childOfChild = Logger - .getLogger("testGetLogger_WithParent_ParentLogger.child.child"); - assertNull(childOfChild.getFilter()); - assertEquals(0, childOfChild.getHandlers().length); - assertSame(child.getParent().getParent(), root); - assertNull(childOfChild.getLevel()); - assertEquals("testGetLogger_WithParent_ParentLogger.child.child", - childOfChild.getName()); - - assertSame(childOfChild.getParent(), child); - assertSame(childOfChild.getParent().getParent(), pLog); - assertSame(childOfChild.getParent().getParent().getParent(), root); - assertNull(childOfChild.getResourceBundle()); - assertNull(childOfChild.getResourceBundleName()); - assertTrue(childOfChild.getUseParentHandlers()); - - // abnormal case : lookup to root parent in a hierarchy without a logger - // parent created between - assertEquals("testGetLogger_WithParent_ParentLogger1.child", notChild - .getName()); - assertSame(child.getParent().getParent(), root); - assertNotSame(child.getParent(), root); - - // abnormal cases - assertNotSame(root.getParent(), root); - Logger twoDot = Logger.getLogger(".."); - assertSame(twoDot.getParent(), root); - - } - - - /* - * Test getLogger(String, String), getting a logger with no parent. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getLogger(String, String), getting a logger with no parent.", - method = "getLogger", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testGetLoggerWithRes_Normal() throws Exception { - // config the level - Properties p = new Properties(); - p.put("testGetLoggerWithRes_Normal_ANewLogger.level", "ALL"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - assertNull(LogManager.getLogManager().getLogger( - "testGetLoggerWithRes_Normal_ANewLogger")); - // create a new logger - Logger log = Logger.getLogger("testGetLoggerWithRes_Normal_ANewLogger", - VALID_RESOURCE_BUNDLE); - // get an existing logger - assertSame(log, Logger - .getLogger("testGetLoggerWithRes_Normal_ANewLogger")); - // check it has been registered - assertSame(log, LogManager.getLogManager().getLogger( - "testGetLoggerWithRes_Normal_ANewLogger")); - - assertNull(log.getFilter()); - assertEquals(0, log.getHandlers().length); - // check it's set to the preconfigured level - assertSame(Level.ALL, log.getLevel()); - assertEquals("testGetLoggerWithRes_Normal_ANewLogger", log.getName()); - assertNull(log.getParent().getParent()); - assertEquals(VALID_VALUE, log.getResourceBundle().getString(VALID_KEY)); - assertEquals(log.getResourceBundleName(), VALID_RESOURCE_BUNDLE); - assertTrue(log.getUseParentHandlers()); - } - - /* - * Test getLogger(String, String) with null parameters. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getLogger(String, String) with null parameters.", - method = "getLogger", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testGetLoggerWithRes_Null() { - Logger.getLogger("testGetLoggerWithRes_Null_ANewLogger", null); - try { - Logger.getLogger(null, VALID_RESOURCE_BUNDLE); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - } - - - /* - * Test getLogger(String, String) with invalid resource bundle. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getLogger(String, String) with invalid resource bundle.", - method = "getLogger", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testGetLoggerWithRes_InvalidResourceBundle() { - - assertNull(LogManager.getLogManager().getLogger( - "testMissingResourceException")); - - try { - Logger.getLogger("testMissingResourceException", - INVALID_RESOURCE_BUNDLE); - fail("Should throw MissingResourceException!"); - } catch (MissingResourceException e) { - // correct - } - assertNull(Logger.getLogger("testMissingResourceException") - .getResourceBundle()); - assertNull(Logger.getLogger("testMissingResourceException") - .getResourceBundleName()); - // try empty string - try { - Logger.getLogger("testMissingResourceException", ""); - fail("Should throw MissingResourceException!"); - } catch (MissingResourceException e) { - // correct - } - - assertNotNull(LogManager.getLogManager().getLogger("")); - // The root logger always exists TODO - try { - Logger.getLogger("", INVALID_RESOURCE_BUNDLE); - } catch (MissingResourceException e) { - //correct - } - } - - /* - * Test getLogger(String, String) with valid resource bundle, to get an - * existing logger with no associated resource bundle. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getLogger(String, String) with valid resource bundle, to get an existing logger with no associated resource bundle.", - method = "getLogger", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testGetLoggerWithRes_ExistingLoggerWithNoRes() { - assertNull(LogManager.getLogManager().getLogger( - "testGetLoggerWithRes_ExistingLoggerWithNoRes_ANewLogger")); - // create a new logger - Logger log1 = Logger - .getLogger("testGetLoggerWithRes_ExistingLoggerWithNoRes_ANewLogger"); - // get an existing logger - Logger log2 = Logger.getLogger( - "testGetLoggerWithRes_ExistingLoggerWithNoRes_ANewLogger", - VALID_RESOURCE_BUNDLE); - assertSame(log1, log2); - assertEquals(VALID_VALUE, log1.getResourceBundle().getString(VALID_KEY)); - assertEquals(log1.getResourceBundleName(), VALID_RESOURCE_BUNDLE); - - } - - /* - * Test getLogger(String, String) with valid resource bundle, to get an - * existing logger with the same associated resource bundle. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getLogger(String, String) with valid resource bundle, to get an existing logger with the same associated resource bundle.", - method = "getLogger", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testGetLoggerWithRes_ExistingLoggerWithSameRes() { - assertNull(LogManager.getLogManager().getLogger( - "testGetLoggerWithRes_ExistingLoggerWithSameRes_ANewLogger")); - // create a new logger - Logger log1 = Logger.getLogger( - "testGetLoggerWithRes_ExistingLoggerWithSameRes_ANewLogger", - VALID_RESOURCE_BUNDLE); - // get an existing logger - Logger log2 = Logger.getLogger( - "testGetLoggerWithRes_ExistingLoggerWithSameRes_ANewLogger", - VALID_RESOURCE_BUNDLE); - assertSame(log1, log2); - assertEquals(VALID_VALUE, log1.getResourceBundle().getString(VALID_KEY)); - assertEquals(log1.getResourceBundleName(), VALID_RESOURCE_BUNDLE); - } - - /* - * Test getLogger(String, String) with valid resource bundle, to get an - * existing logger with different associated resource bundle. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getLogger(String, String) with valid resource bundle, to get an existing logger with different associated resource bundle.", - method = "getLogger", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testGetLoggerWithRes_ExistingLoggerWithDiffRes() { - assertNull(LogManager.getLogManager().getLogger( - "testGetLoggerWithRes_ExistingLoggerWithDiffRes_ANewLogger")); - // create a new logger - Logger log1 = Logger.getLogger( - "testGetLoggerWithRes_ExistingLoggerWithDiffRes_ANewLogger", - VALID_RESOURCE_BUNDLE); - assertNotNull(log1); - // get an existing logger - try { - Logger - .getLogger( - "testGetLoggerWithRes_ExistingLoggerWithDiffRes_ANewLogger", - VALID_RESOURCE_BUNDLE2); - fail("Should throw IllegalArgumentException!"); - } catch (IllegalArgumentException e) { - } - - try { - Logger - .getLogger( - "testGetLoggerWithRes_ExistingLoggerWithDiffRes_ANewLogger", - null); - fail("Should throw IllegalArgumentException!"); - } catch (IllegalArgumentException e) { - } - } - - /* - * Test getLogger(String, String) with invalid name. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getLogger(String, String) with invalid name.", - method = "getLogger", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testGetLoggerWithRes_InvalidName() { - Logger log = Logger.getLogger( - "...#$%%^&&()-_+=!@~./,[]{};:'\\\"?|WithRes", - VALID_RESOURCE_BUNDLE); - assertEquals("...#$%%^&&()-_+=!@~./,[]{};:'\\\"?|WithRes", log - .getName()); - } - - /* - * Test getLogger(String, String) with empty name. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getLogger(String, String) with empty name.", - method = "getLogger", - args = {java.lang.String.class, java.lang.String.class} - ) - @SideEffect("Attaches ResourceBundle to anonymous logger; irreversible") - public void testGetLoggerWithRes_Empty() { - Logger log = Logger.getLogger("", VALID_RESOURCE_BUNDLE); - assertSame(log, LogManager.getLogManager().getLogger("")); - assertNull(log.getFilter()); - assertEquals(0, log.getHandlers().length); - // check it's set to the preconfigured level - assertSame(Level.INFO, log.getLevel()); - assertEquals("", log.getName()); - assertNull(log.getParent()); - assertEquals(VALID_VALUE, log.getResourceBundle().getString(VALID_KEY)); - assertEquals(log.getResourceBundleName(), VALID_RESOURCE_BUNDLE); - assertTrue(log.getUseParentHandlers()); - } - - /* - * Test getLogger(String, String), getting a logger with existing parent. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getLogger(String, String), getting a logger with existing parent.", - method = "getLogger", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testGetLoggerWithRes_WithParentNormal() { - assertNull(LogManager.getLogManager().getLogger( - "testGetLoggerWithRes_WithParent_ParentLogger")); - // create the parent logger - Logger pLog = Logger - .getLogger("testGetLoggerWithRes_WithParent_ParentLogger"); - pLog.setLevel(Level.CONFIG); - pLog.addHandler(new MockHandler()); - pLog.setFilter(new MockFilter()); - pLog.setUseParentHandlers(false); - - assertNull(LogManager.getLogManager().getLogger( - "testGetLoggerWithRes_WithParent_ParentLogger.child")); - // create the child logger - Logger log = Logger.getLogger( - "testGetLoggerWithRes_WithParent_ParentLogger.child", - VALID_RESOURCE_BUNDLE); - assertNull(log.getFilter()); - assertEquals(0, log.getHandlers().length); - assertNull(log.getLevel()); - assertEquals("testGetLoggerWithRes_WithParent_ParentLogger.child", log - .getName()); - assertSame(log.getParent(), pLog); - assertEquals(VALID_VALUE, log.getResourceBundle().getString(VALID_KEY)); - assertEquals(log.getResourceBundleName(), VALID_RESOURCE_BUNDLE); - assertTrue(log.getUseParentHandlers()); - } - - /* - * Test addHandler(Handler) for a named logger with sufficient privilege. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "addHandler", - args = {java.util.logging.Handler.class} - ) - public void testAddHandler_NamedLoggerSufficientPrivilege() { - Logger log = Logger - .getLogger("testAddHandler_NamedLoggerSufficientPrivilege"); - MockHandler h = new MockHandler(); - assertEquals(log.getHandlers().length, 0); - log.addHandler(h); - assertEquals(log.getHandlers().length, 1); - - } - - /* - * Test addHandler(Handler) for a named logger with sufficient privilege, - * add duplicate handlers. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "addHandler", - args = {java.util.logging.Handler.class} - ) - public void testAddHandler_NamedLoggerSufficientPrivilegeDuplicate() { - Logger log = Logger - .getLogger("testAddHandler_NamedLoggerSufficientPrivilegeDuplicate"); - MockHandler h = new MockHandler(); - assertEquals(log.getHandlers().length, 0); - for (int i = 0; i < 12; i++) { - log.addHandler(h); - } - assertEquals(log.getHandlers().length, 12); - assertSame(log.getHandlers()[0], h); - assertSame(log.getHandlers()[5], h); - assertSame(log.getHandlers()[11], h); - } - - /* - * Test addHandler(Handler) with a null handler. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies NullPointerException.", - method = "addHandler", - args = {java.util.logging.Handler.class} - ) - public void testAddHandler_Null() { - Logger log = Logger.getLogger("testAddHandler_Null"); - try { - log.addHandler(null); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - assertEquals(log.getHandlers().length, 0); - } - - /* - * Test addHandler(Handler) for a named logger with insufficient privilege. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "addHandler", - args = {java.util.logging.Handler.class} - ) - public void testAddHandler_NamedLoggerInsufficientPrivilege() { - Logger log = Logger - .getLogger("testAddHandler_NamedLoggerInsufficientPrivilege"); - MockHandler h = new MockHandler(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - - try { - log.addHandler(h); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test addHandler(Handler) for a named logger with insufficient privilege, - * using a null handler. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "addHandler", - args = {java.util.logging.Handler.class} - ) - public void testAddHandler_NamedLoggerInsufficientPrivilegeNull() { - Logger log = Logger - .getLogger("testAddHandler_NamedLoggerInsufficientPrivilege"); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - - try { - log.addHandler(null); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test addHandler(Handler) for an anonymous logger with sufficient - * privilege. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "addHandler", - args = {java.util.logging.Handler.class} - ) - public void testAddHandler_AnonyLoggerSufficientPrivilege() { - Logger log = Logger.getAnonymousLogger(); - MockHandler h = new MockHandler(); - assertEquals(log.getHandlers().length, 0); - log.addHandler(h); - assertEquals(log.getHandlers().length, 1); - assertSame(log.getHandlers()[0], h); - } - - /* - * Test addHandler(Handler) for an anonymous logger with insufficient - * privilege. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "addHandler", - args = {java.util.logging.Handler.class} - ) - public void testAddHandler_AnonyLoggerInsufficientPrivilege() { - Logger log = Logger.getAnonymousLogger(); - MockHandler h = new MockHandler(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - try { - assertEquals(log.getHandlers().length, 0); - log.addHandler(h); - assertEquals(log.getHandlers().length, 1); - assertSame(log.getHandlers()[0], h); - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test addHandler(Handler) for a null-named mock logger with insufficient - * privilege. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies addHandler(Handler) for a null-named mock logger with insufficient privilege, SecurityException.", - method = "addHandler", - args = {java.util.logging.Handler.class} - ) - public void testAddHandler_NullNamedMockLoggerInsufficientPrivilege() { - MockLogger mlog = new MockLogger(null, null); - MockHandler h = new MockHandler(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - try { - mlog.addHandler(h); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test removeHandler(Handler) for a named logger with sufficient privilege, - * remove an existing handler. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "addHandler", - args = {java.util.logging.Handler.class} - ) - public void testRemoveHandler_NamedLoggerSufficientPrivilege() { - Logger log = Logger - .getLogger("testRemoveHandler_NamedLoggerSufficientPrivilege"); - MockHandler h = new MockHandler(); - log.addHandler(h); - assertEquals(log.getHandlers().length, 1); - log.removeHandler(h); - assertEquals(log.getHandlers().length, 0); - } - - /* - * Test removeHandler(Handler) for a named logger with sufficient privilege, - * remove a non-existing handler. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "removeHandler", - args = {java.util.logging.Handler.class} - ) - public void testRemoveHandler_NamedLoggerSufficientPrivilegeNotExisting() { - Logger log = Logger - .getLogger("testRemoveHandler_NamedLoggerSufficientPrivilegeNotExisting"); - MockHandler h = new MockHandler(); - assertEquals(log.getHandlers().length, 0); - log.removeHandler(h); - assertEquals(log.getHandlers().length, 0); - } - - /* - * Test removeHandler(Handler) with a null handler. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "removeHandler", - args = {java.util.logging.Handler.class} - ) - public void testRemoveHandler_Null() { - Logger log = Logger.getLogger("testRemoveHandler_Null"); - log.removeHandler(null); - assertEquals(log.getHandlers().length, 0); - } - - /* - * Test removeHandler(Handler) for a named logger with insufficient - * privilege. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "removeHandler", - args = {java.util.logging.Handler.class} - ) - public void testRemoveHandler_NamedLoggerInsufficientPrivilege() { - Logger log = Logger - .getLogger("testRemoveHandler_NamedLoggerInsufficientPrivilege"); - MockHandler h = new MockHandler(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - - try { - log.removeHandler(h); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test removeHandler(Handler) for a named logger with insufficient - * privilege, using a null handler. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "removeHandler", - args = {java.util.logging.Handler.class} - ) - public void testRemoveHandler_NamedLoggerInsufficientPrivilegeNull() { - Logger log = Logger - .getLogger("testRemoveHandler_NamedLoggerInsufficientPrivilege"); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - - try { - log.removeHandler(null); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test removeHandler(Handler) for an anonymous logger with sufficient - * privilege. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "removeHandler", - args = {java.util.logging.Handler.class} - ) - public void testRemoveHandler_AnonyLoggerSufficientPrivilege() { - Logger log = Logger.getAnonymousLogger(); - MockHandler h = new MockHandler(); - log.addHandler(h); - assertEquals(log.getHandlers().length, 1); - log.removeHandler(h); - assertEquals(log.getHandlers().length, 0); - } - - /* - * Test removeHandler(Handler) for an anonymous logger with insufficient - * privilege. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "removeHandler", - args = {java.util.logging.Handler.class} - ) - public void testRemoveHandler_AnonyLoggerInsufficientPrivilege() { - Logger log = Logger.getAnonymousLogger(); - MockHandler h = new MockHandler(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - try { - log.addHandler(h); - assertEquals(log.getHandlers().length, 1); - log.removeHandler(h); - assertEquals(log.getHandlers().length, 0); - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test removeHandler(Handler) for a null-named mock logger with - * insufficient privilege. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "removeHandler", - args = {java.util.logging.Handler.class} - ) - public void testRemoveHandler_NullNamedMockLoggerInsufficientPrivilege() { - MockLogger mlog = new MockLogger(null, null); - MockHandler h = new MockHandler(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - try { - mlog.removeHandler(h); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test getHandlers() when there's no handler. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getHandlers() when there's no handler.", - method = "getHandlers", - args = {} - ) - public void testGetHandlers_None() { - Logger log = Logger.getLogger("testGetHandlers_None"); - assertEquals(log.getHandlers().length, 0); - } - - /* - * Test getHandlers() when there are several handlers. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getHandlers() when there are several handlers.", - method = "getHandlers", - args = {} - ) - public void testGetHandlers_Several() { - Logger log = Logger.getLogger("testGetHandlers_None"); - assertEquals(log.getHandlers().length, 0); - MockHandler h1 = new MockHandler(); - MockHandler h2 = new MockHandler(); - MockHandler h3 = new MockHandler(); - log.addHandler(h1); - log.addHandler(h2); - log.addHandler(h3); - assertEquals(log.getHandlers().length, 3); - assertSame(log.getHandlers()[0], h1); - assertSame(log.getHandlers()[1], h2); - assertSame(log.getHandlers()[2], h3); - // remove one - log.removeHandler(h2); - assertEquals(log.getHandlers().length, 2); - assertSame(log.getHandlers()[0], h1); - assertSame(log.getHandlers()[1], h3); - - } - - /* - * Test getFilter & setFilter with normal value for a named logger, having - * sufficient privilege. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verifies getFilter & setFilter with normal value for a named logger, having sufficient privilege.", - method = "getFilter", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verifies getFilter & setFilter with normal value for a named logger, having sufficient privilege.", - method = "setFilter", - args = {java.util.logging.Filter.class} - ) - }) - public void testGetSetFilter_NamedLoggerSufficientPrivilege() { - Logger log = Logger - .getLogger("testGetSetFilter_NamedLoggerSufficientPrivilege"); - Filter f = new MockFilter(); - - assertNull(log.getFilter()); - log.setFilter(f); - assertSame(f, log.getFilter()); - } - - /* - * Test getFilter & setFilter with null value, having sufficient privilege. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verifies getFilter & setFilter with null value, having sufficient privilege.", - method = "getFilter", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verifies getFilter & setFilter with null value, having sufficient privilege.", - method = "setFilter", - args = {java.util.logging.Filter.class} - ) - }) - public void testGetSetFilter_Null() { - Logger log = Logger.getLogger("testGetSetFilter_Null"); - - assertNull(log.getFilter()); - log.setFilter(null); - assertNull(log.getFilter()); - log.setFilter(new MockFilter()); - log.setFilter(null); - assertNull(log.getFilter()); - } - - /* - * Test setFilter with normal value for a named logger, having insufficient - * privilege. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verifies setFilter with normal value for a named logger, having insufficient privilege.", - method = "getFilter", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verifies setFilter with normal value for a named logger, having insufficient privilege.", - method = "setFilter", - args = {java.util.logging.Filter.class} - ) - }) - public void testGetSetFilter_NamedLoggerInsufficientPrivilege() { - Logger log = Logger - .getLogger("testGetSetFilter_NamedLoggerInsufficientPrivilege"); - Filter f = new MockFilter(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - try { - log.setFilter(f); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test setFilter for an anonymous logger with sufficient privilege. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getFilter", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setFilter", - args = {java.util.logging.Filter.class} - ) - }) - public void testSetFilter_AnonyLoggerSufficientPrivilege() { - Logger log = Logger.getAnonymousLogger(); - Filter f = new MockFilter(); - assertNull(log.getFilter()); - log.setFilter(f); - assertSame(f, log.getFilter()); - } - - /* - * Test setFilter for an anonymous logger with insufficient privilege. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getFilter", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setFilter", - args = {java.util.logging.Filter.class} - ) - }) - public void testSetFilter_AnonyLoggerInsufficientPrivilege() { - Logger log = Logger.getAnonymousLogger(); - Filter f = new MockFilter(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - try { - assertNull(log.getFilter()); - log.setFilter(f); - assertSame(f, log.getFilter()); - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test setFilter for a null-named mock logger with insufficient privilege. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getFilter", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setFilter", - args = {java.util.logging.Filter.class} - ) - }) - public void testSetFilter_NullNamedMockLoggerInsufficientPrivilege() { - MockLogger mlog = new MockLogger(null, null); - Filter f = new MockFilter(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - try { - mlog.setFilter(f); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test getLevel & setLevel with normal value for a named logger, having - * sufficient privilege. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verifies getLevel & setLevel with normal value for a named logger, having sufficient privilege.", - method = "setLevel", - args = {java.util.logging.Level.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verifies getLevel & setLevel with normal value for a named logger, having sufficient privilege.", - method = "getLevel", - args = {} - ) - }) - public void testGetSetLevel_NamedLoggerSufficientPrivilege() { - Logger log = Logger - .getLogger("testGetSetLevel_NamedLoggerSufficientPrivilege"); - - assertNull(log.getLevel()); - log.setLevel(Level.CONFIG); - assertSame(Level.CONFIG, log.getLevel()); - } - - /* - * Test getLevel & setLevel with null value, having sufficient privilege. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verifies getLevel & setLevel with null value, having sufficient privilege.", - method = "getLevel", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verifies getLevel & setLevel with null value, having sufficient privilege.", - method = "setLevel", - args = {java.util.logging.Level.class} - ) - }) - public void testGetSetLevel_Null() { - Logger log = Logger.getLogger("testGetSetLevel_Null"); - - assertNull(log.getLevel()); - log.setLevel(null); - assertNull(log.getLevel()); - log.setLevel(Level.CONFIG); - log.setLevel(null); - assertNull(log.getLevel()); - } - - /* - * Test setLevel with normal value for a named logger, having insufficient - * privilege. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verifies setLevel with normal value for a named logger, having insufficient privilege.", - method = "setLevel", - args = {java.util.logging.Level.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verifies setLevel with normal value for a named logger, having insufficient privilege.", - method = "getLevel", - args = {} - ) - }) - public void testGetSetLevel_NamedLoggerInsufficientPrivilege() { - Logger log = Logger - .getLogger("testGetSetLevel_NamedLoggerInsufficientPrivilege"); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - try { - log.setLevel(Level.CONFIG); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test setLevel for an anonymous logger with sufficient privilege. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getLevel", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setLevel", - args = {java.util.logging.Level.class} - ) - }) - public void testSetLevel_AnonyLoggerSufficientPrivilege() { - Logger log = Logger.getAnonymousLogger(); - assertNull(log.getLevel()); - log.setLevel(Level.CONFIG); - assertSame(Level.CONFIG, log.getLevel()); - } - - /* - * Test setLevel for an anonymous logger with insufficient privilege. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getLevel", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setLevel", - args = {java.util.logging.Level.class} - ) - }) - public void testSetLevel_AnonyLoggerInsufficientPrivilege() { - Logger log = Logger.getAnonymousLogger(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - try { - assertNull(log.getLevel()); - log.setLevel(Level.CONFIG); - assertSame(Level.CONFIG, log.getLevel()); - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test setLevel for a null-named mock logger with insufficient privilege. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getLevel", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setLevel", - args = {java.util.logging.Level.class} - ) - }) - public void testSetLevel_NullNamedMockLoggerInsufficientPrivilege() { - MockLogger mlog = new MockLogger(null, null); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - try { - mlog.setLevel(Level.CONFIG); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test getUseParentHandlers & setUseParentHandlers with normal value for a - * named logger, having sufficient privilege. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getUseParentHandlers", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setUseParentHandlers", - args = {boolean.class} - ) - }) - public void testGetSetUseParentHandlers_NamedLoggerSufficientPrivilege() { - Logger log = Logger - .getLogger("testGetSetUseParentHandlers_NamedLoggerSufficientPrivilege"); - - assertTrue(log.getUseParentHandlers()); - log.setUseParentHandlers(false); - assertFalse(log.getUseParentHandlers()); - } - - /* - * Test setUseParentHandlers with normal value for a named logger, having - * insufficient privilege. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getUseParentHandlers", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setUseParentHandlers", - args = {boolean.class} - ) - }) - public void testGetSetUseParentHandlers_NamedLoggerInsufficientPrivilege() { - Logger log = Logger - .getLogger("testGetSetUseParentHandlers_NamedLoggerInsufficientPrivilege"); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - try { - log.setUseParentHandlers(true); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test setUseParentHandlers for an anonymous logger with sufficient - * privilege. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getUseParentHandlers", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setUseParentHandlers", - args = {boolean.class} - ) - }) - public void testSetUseParentHandlers_AnonyLoggerSufficientPrivilege() { - Logger log = Logger.getAnonymousLogger(); - assertTrue(log.getUseParentHandlers()); - log.setUseParentHandlers(false); - assertFalse(log.getUseParentHandlers()); - } - - /* - * Test setUseParentHandlers for an anonymous logger with insufficient - * privilege. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getUseParentHandlers", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setUseParentHandlers", - args = {boolean.class} - ) - }) - public void testSetUseParentHandlers_AnonyLoggerInsufficientPrivilege() { - Logger log = Logger.getAnonymousLogger(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - try { - assertTrue(log.getUseParentHandlers()); - log.setUseParentHandlers(false); - assertFalse(log.getUseParentHandlers()); - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test setUseParentHandlers for a null-named mock logger with insufficient - * privilege. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getUseParentHandlers", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setUseParentHandlers", - args = {boolean.class} - ) - }) - public void testSetUseParentHandlers_NullNamedMockLoggerInsufficientPrivilege() { - MockLogger mlog = new MockLogger(null, null); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - try { - mlog.setUseParentHandlers(true); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test getParent() for root logger. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getParent() for root logger.", - method = "getParent", - args = {} - ) - public void testGetParent_Root() { - assertNull(Logger.getLogger("").getParent()); - } - - /* - * Test getParent() for normal named loggers. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getParent() for normal named loggers.", - method = "getParent", - args = {} - ) - public void testGetParent_NormalNamed() { - Logger log = Logger.getLogger("testGetParent_NormalNamed"); - assertSame(log.getParent(), Logger.getLogger("")); - Logger child = Logger.getLogger("testGetParent_NormalNamed.child"); - assertSame(child.getParent(), log); - Logger child2 = Logger.getLogger("testGetParent_NormalNamed.a.b.c"); - assertSame(child2.getParent(), log); - } - - /* - * Test getParent() for anonymous loggers. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getParent() for anonymous loggers.", - method = "getParent", - args = {} - ) - public void testGetParent_Anonymous() { - assertSame(Logger.getAnonymousLogger().getParent(), Logger - .getLogger("")); - } - - /* - * Test setParent(Logger) for the mock logger since it is advised not to - * call this method on named loggers. Test normal conditions. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setParent", - args = {java.util.logging.Logger.class} - ) - public void testSetParent_Normal() { - Logger log = new MockLogger(null, null); - Logger parent = new MockLogger(null, null); - assertNull(log.getParent()); - log.setParent(parent); - assertSame(log.getParent(), parent); - } - - /* - * Test setParent(Logger) with null. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setParent", - args = {java.util.logging.Logger.class} - ) - public void testSetParent_Null() { - try { - (new MockLogger(null, null)).setParent(null); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - } - - /* - * Test setParent(Logger), having insufficient privilege. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setParent", - args = {java.util.logging.Logger.class} - ) - public void testSetParent_InsufficientPrivilege() { - MockLogger log = new MockLogger(null, null); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - try { - log.setParent(log); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test setParent(Logger) with null, having insufficient privilege. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setParent", - args = {java.util.logging.Logger.class} - ) - public void testSetParent_InsufficientPrivilegeNull() { - MockLogger log = new MockLogger(null, null); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - try { - log.setParent(null); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test setParent(Logger) for an anonymous logger with insufficient - * privilege. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setParent", - args = {java.util.logging.Logger.class} - ) - public void testSetParent_AnonyLoggerInsufficientPrivilege() { - Logger log = Logger.getAnonymousLogger(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - try { - log.setParent(log); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test getName() for normal names. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getName() for normal names.", - method = "getName", - args = {} - ) - public void testGetName_Normal() { - Logger log = Logger.getLogger("testGetName_Normal"); - assertEquals("testGetName_Normal", log.getName()); - - Logger mlog = new MockLogger("testGetName_Normal", null); - assertEquals("testGetName_Normal", mlog.getName()); - } - - /* - * Test getName() for empty name. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getName() for empty name.", - method = "getName", - args = {} - ) - public void testGetName_Empty() { - Logger log = Logger.getLogger(""); - assertEquals("", log.getName()); - - Logger mlog = new MockLogger("", null); - assertEquals("", mlog.getName()); - } - - /* - * Test getName() for null name. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getName() for null name.", - method = "getName", - args = {} - ) - public void testGetName_Null() { - Logger log = Logger.getAnonymousLogger(); - assertNull(log.getName()); - - Logger mlog = new MockLogger(null, null); - assertNull(mlog.getName()); - } - - /* - * Test getResourceBundle() when it it not null. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getResourceBundle() when it it not null.", - method = "getResourceBundle", - args = {} - ) - public void testGetResourceBundle_Normal() { - Logger log = Logger.getLogger("testGetResourceBundle_Normal", - VALID_RESOURCE_BUNDLE); - assertEquals(VALID_VALUE, log.getResourceBundle().getString(VALID_KEY)); - - Logger mlog = new MockLogger(null, VALID_RESOURCE_BUNDLE); - assertEquals(VALID_VALUE, mlog.getResourceBundle().getString(VALID_KEY)); - } - - /* - * Test getResourceBundle() when it it null. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getResourceBundle() when it it null.", - method = "getResourceBundle", - args = {} - ) - public void testGetResourceBundle_Null() { - Logger log = Logger.getLogger("testGetResourceBundle_Null", null); - assertNull(log.getResourceBundle()); - - Logger mlog = new MockLogger(null, null); - assertNull(mlog.getResourceBundle()); - } - - - /* - * Test getResourceBundleName() when it it not null. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getResourceBundleName() when it it not null.", - method = "getResourceBundleName", - args = {} - ) - public void testGetResourceBundleName_Normal() { - Logger log = Logger.getLogger("testGetResourceBundleName_Normal", - VALID_RESOURCE_BUNDLE); - assertEquals(VALID_RESOURCE_BUNDLE, log.getResourceBundleName()); - - Logger mlog = new MockLogger(null, null); - assertNull(mlog.getResourceBundleName()); - } - - /* - * Test getResourceBundleName() when it it null. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies getResourceBundleName() when it it null.", - method = "getResourceBundleName", - args = {} - ) - public void testGetResourceBundleName_Null() { - Logger log = Logger.getLogger("testGetResourceBundleName_Null", null); - assertNull(log.getResourceBundleName()); - - Logger mlog = new MockLogger(null, null); - assertNull(mlog.getResourceBundleName()); - } - - - /* - * Test isLoggable(Level). - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "isLoggable", - args = {java.util.logging.Level.class} - ) - public void testIsLoggable() { - MockLogger mlog = new MockLogger(null, null); - assertNull(mlog.getLevel()); - assertNull(mlog.getParent()); - - assertTrue(mlog.isLoggable(Level.SEVERE)); - assertTrue(mlog.isLoggable(Level.WARNING)); - assertTrue(mlog.isLoggable(Level.INFO)); - assertFalse(mlog.isLoggable(Level.CONFIG)); - assertFalse(mlog.isLoggable(Level.FINE)); - assertFalse(mlog.isLoggable(Level.ALL)); - assertTrue(mlog.isLoggable(Level.OFF)); - - mlog.setLevel(Level.CONFIG); - assertTrue(mlog.isLoggable(Level.SEVERE)); - assertTrue(mlog.isLoggable(Level.CONFIG)); - assertFalse(mlog.isLoggable(Level.ALL)); - assertTrue(mlog.isLoggable(Level.OFF)); - - mlog.setLevel(Level.ALL); - assertTrue(mlog.isLoggable(Level.ALL)); - assertTrue(mlog.isLoggable(Level.SEVERE)); - assertTrue(mlog.isLoggable(Level.OFF)); - - mlog.setLevel(Level.OFF); - assertFalse(mlog.isLoggable(Level.ALL)); - assertFalse(mlog.isLoggable(Level.SEVERE)); - assertFalse(mlog.isLoggable(Level.OFF)); - } - - /* - * Test throwing(String, String, Throwable) with normal values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "throwing", - args = {java.lang.String.class, java.lang.String.class, java.lang.Throwable.class} - ) - public void testThrowing_Normal() { - Throwable t = new Throwable(); - this.sharedLogger.setLevel(Level.FINER); - this.sharedLogger.throwing("sourceClass", "sourceMethod", t); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), "THROW"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), "sourceClass"); - assertSame(r.getSourceMethodName(), "sourceMethod"); - assertSame(r.getLevel(), Level.FINER); - assertSame(r.getParameters(), null); - assertSame(r.getThrown(), t); - - - this.sharedLogger.setLevel(Level.FINE); - this.sharedLogger.throwing("sourceClass", "sourceMethod", t); - - // FINE is a level too low, message will be lost => empty - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test throwing(String, String, Throwable) with null values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "throwing", - args = {java.lang.String.class, java.lang.String.class, java.lang.Throwable.class} - ) - public void testThrowing_Null() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.FINER); - child.throwing(null, null, null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertEquals(r.getMessage(), "THROW"); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.FINER); - assertSame(r.getParameters(), null); - assertSame(r.getThrown(), null); - } - - /* - * Test entering(String, String) with normal values. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies entering(String, String) with normal values.", - method = "entering", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testEntering_StringString_Normal() { - this.sharedLogger.setLevel(Level.FINER); - this.sharedLogger.entering("sourceClass", "sourceMethod"); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), "ENTRY"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), "sourceClass"); - assertSame(r.getSourceMethodName(), "sourceMethod"); - assertSame(r.getLevel(), Level.FINER); - assertSame(r.getParameters(), null); - assertSame(r.getThrown(), null); - - this.sharedLogger.setLevel(Level.FINE); - this.sharedLogger.entering("sourceClass", "sourceMethod"); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test entering(String, String) with null values. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies entering(String, String) with null values.", - method = "entering", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testEntering_StringString_Null() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.FINER); - child.entering(null, null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertEquals(r.getMessage(), "ENTRY"); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.FINER); - assertSame(r.getParameters(), null); - assertSame(r.getThrown(), null); - } - - /* - * Test entering(String, String, Object) with normal values. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies entering(String, String, Object) with normal values.", - method = "entering", - args = {java.lang.String.class, java.lang.String.class, java.lang.Object.class} - ) - public void testEntering_StringStringObject_Normal() { - Object param = new Object(); - this.sharedLogger.setLevel(Level.FINER); - this.sharedLogger.entering("sourceClass", "sourceMethod", param); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), "ENTRY {0}"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), "sourceClass"); - assertSame(r.getSourceMethodName(), "sourceMethod"); - assertSame(r.getLevel(), Level.FINER); - assertSame(r.getParameters()[0], param); - assertEquals(1, r.getParameters().length); - assertSame(r.getThrown(), null); - - this.sharedLogger.setLevel(Level.FINE); - this.sharedLogger.entering("sourceClass", "sourceMethod", param); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test entering(String, String, Object) with null values. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies entering(String, String, Object) with null values.", - method = "entering", - args = {java.lang.String.class, java.lang.String.class, java.lang.Object.class} - ) - public void testEntering_StringStringObject_Null() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.FINER); - child.entering(null, null, (Object) null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertEquals(r.getMessage(), "ENTRY {0}"); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.FINER); - assertEquals(r.getParameters().length, 1); - assertNull(r.getParameters()[0]); - assertSame(r.getThrown(), null); - } - - /* - * Test entering(String, String, Object[]) with normal values. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies entering(String, String, Object[]) with normal values.", - method = "entering", - args = {java.lang.String.class, java.lang.String.class, java.lang.Object[].class} - ) - public void testEntering_StringStringObjects_Normal() { - Object[] params = new Object[2]; - params[0] = new Object(); - params[1] = new Object(); - this.sharedLogger.setLevel(Level.FINER); - this.sharedLogger.entering("sourceClass", "sourceMethod", params); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), "ENTRY {0} {1}"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), "sourceClass"); - assertSame(r.getSourceMethodName(), "sourceMethod"); - assertSame(r.getLevel(), Level.FINER); - assertSame(r.getParameters()[0], params[0]); - assertSame(r.getParameters()[1], params[1]); - assertEquals(2, r.getParameters().length); - assertSame(r.getThrown(), null); - - this.sharedLogger.setLevel(Level.FINE); - this.sharedLogger.entering("sourceClass", "sourceMethod", params); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test entering(String, String, Object[]) with null class name and method - * name and empty parameter array. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies entering(String, String, Object[]) with null class name and method name and empty parameter array.", - method = "entering", - args = {java.lang.String.class, java.lang.String.class, java.lang.Object[].class} - ) - public void testEntering_StringStringObjects_NullEmpty() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.FINER); - child.entering(null, null, new Object[0]); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertEquals(r.getMessage(), "ENTRY"); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.FINER); - assertEquals(0, r.getParameters().length); - assertSame(r.getThrown(), null); - } - - /* - * Test entering(String, String, Object[]) with null values with appropriate - * logging level set. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies entering(String, String, Object[]) with null values with appropriate logging level set.", - method = "entering", - args = {java.lang.String.class, java.lang.String.class, java.lang.Object[].class} - ) - public void testEntering_StringStringObjects_Null() { - sharedLogger.setLevel(Level.FINER); - sharedLogger.entering(null, null, (Object[]) null); - // regression test for Harmony-1265 - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(sharedLogger.getName(), r.getLoggerName()); - assertEquals("ENTRY", r.getMessage()); - assertSame(sharedLogger.getResourceBundleName(), r - .getResourceBundleName()); - assertSame(sharedLogger.getResourceBundle(), r.getResourceBundle()); - assertNull(r.getSourceClassName()); - assertNull(r.getSourceMethodName()); - assertSame(Level.FINER, r.getLevel()); - assertNull(r.getParameters()); - assertNull(r.getThrown()); - } - - /* - * Test entering(String, String, Object[]) with null values with - * inappropriate logging level set. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies entering(String, String, Object[]) with null values with inappropriate logging level set.", - method = "entering", - args = {java.lang.String.class, java.lang.String.class, java.lang.Object[].class} - ) - public void testEntering_StringStringObjects_NullDisabled() { - this.sharedLogger.setLevel(Level.FINE); - this.sharedLogger.entering(null, null, (Object[]) null); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test exiting(String, String) with normal values. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies exiting(String, String) with normal values.", - method = "exiting", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testExiting_StringString_Normal() { - this.sharedLogger.setLevel(Level.FINER); - this.sharedLogger.exiting("sourceClass", "sourceMethod"); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), "RETURN"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), "sourceClass"); - assertSame(r.getSourceMethodName(), "sourceMethod"); - assertSame(r.getLevel(), Level.FINER); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - - this.sharedLogger.setLevel(Level.FINE); - this.sharedLogger.exiting("sourceClass", "sourceMethod"); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test exiting(String, String) with null values. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies exiting(String, String) with null values.", - method = "exiting", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testExiting_StringString_Null() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.FINER); - child.exiting(null, null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertEquals(r.getMessage(), "RETURN"); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.FINER); - assertSame(r.getParameters(), null); - assertSame(r.getThrown(), null); - } - - /* - * Test exiting(String, String, Object) with normal values. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies exiting(String, String, Object) with normal values.", - method = "exiting", - args = {java.lang.String.class, java.lang.String.class, java.lang.Object.class} - ) - public void testExiting_StringStringObject_Normal() { - Object param = new Object(); - this.sharedLogger.setLevel(Level.FINER); - this.sharedLogger.exiting("sourceClass", "sourceMethod", param); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), "RETURN {0}"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), "sourceClass"); - assertSame(r.getSourceMethodName(), "sourceMethod"); - assertSame(r.getLevel(), Level.FINER); - assertSame(r.getParameters()[0], param); - assertEquals(1, r.getParameters().length); - assertSame(r.getThrown(), null); - - this.sharedLogger.setLevel(Level.FINE); - this.sharedLogger.exiting("sourceClass", "sourceMethod", param); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test exiting(String, String, Object) with null values. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies exiting(String, String, Object) with null values.", - method = "exiting", - args = {java.lang.String.class, java.lang.String.class, java.lang.Object.class} - ) - public void testExiting_StringStringObject_Null() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.FINER); - child.exiting(null, null, (Object) null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertEquals(r.getMessage(), "RETURN {0}"); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.FINER); - assertEquals(r.getParameters().length, 1); - assertNull(r.getParameters()[0]); - assertSame(r.getThrown(), null); - } - - /* - * Test config(String) with normal values. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "config", - args = {java.lang.String.class} - ) - public void testConfig_Normal() { - this.sharedLogger.setLevel(Level.CONFIG); - this.sharedLogger.config("config msg"); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), "config msg"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.CONFIG); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.config("config again"); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test config(String) with null values. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies null as a parameter.", - method = "config", - args = {java.lang.String.class} - ) - public void testConfig_Null() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.CONFIG); - child.config(null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertNull(r.getMessage()); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.CONFIG); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.config(null); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test fine(String) with normal values. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "fine", - args = {java.lang.String.class} - ) - public void testFine_Normal() { - this.sharedLogger.setLevel(Level.FINE); - this.sharedLogger.fine("fine msg"); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertEquals(r.getMessage(), "fine msg"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.FINE); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - - this.sharedLogger.setLevel(Level.CONFIG); - this.sharedLogger.fine("fine again"); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test fine(String) with null values. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies fine(String) with null values.", - method = "fine", - args = {java.lang.String.class} - ) - public void testFine_Null() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.FINE); - child.fine(null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertNull(r.getMessage()); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.FINE); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - - this.sharedLogger.setLevel(Level.CONFIG); - this.sharedLogger.fine(null); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test finer(String) with normal values. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies finer(String) with normal values.", - method = "finer", - args = {java.lang.String.class} - ) - public void testFiner_Normal() { - this.sharedLogger.setLevel(Level.FINER); - this.sharedLogger.finer("finer msg"); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), "finer msg"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.FINER); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - - this.sharedLogger.setLevel(Level.FINE); - this.sharedLogger.finer("finer again"); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test finer(String) with null values. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies finer(String) with null values.", - method = "finer", - args = {java.lang.String.class} - ) - public void testFiner_Null() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.FINER); - child.finer(null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertNull(r.getMessage()); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.FINER); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - - this.sharedLogger.setLevel(Level.FINE); - this.sharedLogger.finer(null); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test finest(String) with normal values. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies finest(String) with normal values.", - method = "finest", - args = {java.lang.String.class} - ) - public void testFinest_Normal() { - this.sharedLogger.setLevel(Level.FINEST); - this.sharedLogger.finest("finest msg"); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), "finest msg"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.FINEST); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - - this.sharedLogger.setLevel(Level.FINER); - this.sharedLogger.finest("finest again"); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test finest(String) with null values. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies finest(String) with null values.", - method = "finest", - args = {java.lang.String.class} - ) - public void testFinest_Null() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.FINEST); - child.finest(null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertNull(r.getMessage()); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.FINEST); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - - this.sharedLogger.setLevel(Level.FINER); - this.sharedLogger.finest(null); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test info(String) with normal values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "info", - args = {java.lang.String.class} - ) - public void testInfo_Normal() { - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.info("info msg"); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), "info msg"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - - this.sharedLogger.setLevel(Level.WARNING); - this.sharedLogger.info("info again"); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test info(String) with null values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "info", - args = {java.lang.String.class} - ) - public void testInfo_Null() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.INFO); - child.info(null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertNull(r.getMessage()); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - - this.sharedLogger.setLevel(Level.WARNING); - this.sharedLogger.info(null); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test warning(String) with normal values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "warning", - args = {java.lang.String.class} - ) - public void testWarning_Normal() { - this.sharedLogger.setLevel(Level.WARNING); - this.sharedLogger.warning("warning msg"); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), "warning msg"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.WARNING); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - - this.sharedLogger.setLevel(Level.SEVERE); - this.sharedLogger.warning("warning again"); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test warning(String) with null values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "warning", - args = {java.lang.String.class} - ) - public void testWarning_Null() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.WARNING); - child.warning(null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertNull(r.getMessage()); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.WARNING); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - - this.sharedLogger.setLevel(Level.SEVERE); - this.sharedLogger.warning(null); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test severe(String) with normal values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "severe", - args = {java.lang.String.class} - ) - public void testSevere_Normal() { - this.sharedLogger.setLevel(Level.SEVERE); - this.sharedLogger.severe("severe msg"); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), "severe msg"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.SEVERE); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - - this.sharedLogger.setLevel(Level.OFF); - this.sharedLogger.severe("severe again"); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test severe(String) with null values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "severe", - args = {java.lang.String.class} - ) - public void testSevere_Null() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.SEVERE); - child.severe(null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertNull(r.getMessage()); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.SEVERE); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - - this.sharedLogger.setLevel(Level.OFF); - this.sharedLogger.severe(null); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test log(Level, String) with normal values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.Level.class, java.lang.String.class} - ) - public void testLog_LevelString_Normal() { - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.log(Level.INFO, "log(Level, String) msg"); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), "log(Level, String) msg"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - - this.sharedLogger.log(Level.CONFIG, "log(Level, String) msg"); - assertTrue(CallVerificationStack.getInstance().empty()); - this.sharedLogger.setLevel(Level.OFF); - this.sharedLogger.log(Level.OFF, "log(Level, String) msg"); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test log(Level, String) with null message. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.Level.class, java.lang.String.class} - ) - public void testLog_LevelString_NullMsg() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.INFO); - child.log(Level.INFO, null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertNull(r.getMessage()); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - } - - /* - * Test log(Level, String) with null level. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.Level.class, java.lang.String.class} - ) - public void testLog_LevelString_NullLevel() { - // this.sharedLogger.setLevel(Level.OFF); - try { - this.sharedLogger.log(null, "log(Level, String) msg"); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - } - - /* - * Test log(Level, String, Object) with normal values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.Object.class} - ) - public void testLog_LevelStringObject_Normal() { - Object param = new Object(); - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.log(Level.INFO, "log(Level, String, Object) msg", - param); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), "log(Level, String, Object) msg"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertEquals(1, r.getParameters().length); - assertSame(param, r.getParameters()[0]); - assertSame(r.getThrown(), null); - - this.sharedLogger.log(Level.CONFIG, "log(Level, String, Object) msg", - param); - assertTrue(CallVerificationStack.getInstance().empty()); - this.sharedLogger.setLevel(Level.OFF); - this.sharedLogger.log(Level.OFF, "log(Level, String, Object) msg", - param); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test log(Level, String, Object) with null message and object. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.Object.class} - ) - public void testLog_LevelStringObject_NullMsgObj() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.INFO); - child.log(Level.INFO, null, (Object) null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertNull(r.getMessage()); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertEquals(1, r.getParameters().length); - assertNull(r.getParameters()[0]); - assertSame(r.getThrown(), null); - } - - /* - * Test log(Level, String, Object) with null level. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.Object.class} - ) - public void testLog_LevelStringObject_NullLevel() { - // this.sharedLogger.setLevel(Level.OFF); - try { - this.sharedLogger.log(null, "log(Level, String, Object) msg", - new Object()); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - } - - /* - * Test log(Level, String, Object[]) with normal values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.Object[].class} - ) - - public void testLog_LevelStringObjects_Normal() { - Object[] params = new Object[2]; - params[0] = new Object(); - params[1] = new Object(); - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.log(Level.INFO, "log(Level, String, Object[]) msg", - params); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), "log(Level, String, Object[]) msg"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertEquals(2, r.getParameters().length); - assertSame(params[0], r.getParameters()[0]); - assertSame(params[1], r.getParameters()[1]); - assertSame(r.getThrown(), null); - - this.sharedLogger.log(Level.CONFIG, "log(Level, String, Object[]) msg", - params); - assertTrue(CallVerificationStack.getInstance().empty()); - this.sharedLogger.setLevel(Level.OFF); - this.sharedLogger.log(Level.OFF, "log(Level, String, Object[]) msg", - params); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test log(Level, String, Object[]) with null message and object. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.Object[].class} - ) - public void testLog_LevelStringObjects_NullMsgObj() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.INFO); - child.log(Level.INFO, null, (Object[]) null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertNull(r.getMessage()); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - } - - /* - * Test log(Level, String, Object[]) with null level. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.Object[].class} - ) - public void testLog_LevelStringObjects_NullLevel() { - try { - this.sharedLogger.log(null, "log(Level, String, Object[]) msg", - new Object[0]); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - } - - /* - * Test log(Level, String, Throwable) with normal values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.Throwable.class} - ) - public void testLog_LevelStringThrowable_Normal() { - Throwable t = new Throwable(); - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.log(Level.INFO, "log(Level, String, Throwable) msg", - t); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), "log(Level, String, Throwable) msg"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), t); - - this.sharedLogger.log(Level.CONFIG, - "log(Level, String, Throwable) msg", t); - assertTrue(CallVerificationStack.getInstance().empty()); - this.sharedLogger.setLevel(Level.OFF); - this.sharedLogger - .log(Level.OFF, "log(Level, String, Throwable) msg", t); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test log(Level, String, Throwable) with null message and throwable. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.Throwable.class} - ) - public void testLog_LevelStringThrowable_Null() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.INFO); - child.log(Level.INFO, null, (Throwable) null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertNull(r.getMessage()); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - } - - /* - * Test log(Level, String, Throwable) with null level. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.Throwable.class} - ) - public void testLog_LevelStringThrowable_NullLevel() { - // this.sharedLogger.setLevel(Level.OFF); - try { - this.sharedLogger.log(null, "log(Level, String, Throwable) msg", - new Throwable()); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - } - - /* - * Test logp(Level, String, String, String) with normal values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logp", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class} - ) - public void testLogp_LevelStringStringString_Normal() { - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.logp(Level.INFO, "sourceClass", "sourceMethod", - "logp(Level, String, String, String) msg"); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), "logp(Level, String, String, String) msg"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), "sourceClass"); - assertSame(r.getSourceMethodName(), "sourceMethod"); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - - this.sharedLogger.logp(Level.CONFIG, "sourceClass", "sourceMethod", - "logp(Level, String, String, String) msg"); - assertTrue(CallVerificationStack.getInstance().empty()); - this.sharedLogger.setLevel(Level.OFF); - this.sharedLogger.logp(Level.OFF, "sourceClass", "sourceMethod", - "logp(Level, String, String, String) msg"); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test logp(Level, String, String, String) with null message. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logp", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class} - ) - public void testLogp_LevelStringStringString_NullMsg() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.INFO); - child.logp(Level.INFO, null, null, null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertNull(r.getMessage()); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - } - - /* - * Test logp(Level, String, String, String) with null level. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logp", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class} - ) - public void testLogp_LevelStringStringString_NullLevel() { - // this.sharedLogger.setLevel(Level.OFF); - try { - this.sharedLogger.logp(null, "sourceClass", "sourceMethod", - "logp(Level, String, String, String) msg"); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - } - - /* - * Test logp(Level, String, String, String, Object) with normal values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logp", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class} - ) - public void testLogp_LevelStringStringStringObject_Normal() { - Object param = new Object(); - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.logp(Level.INFO, "sourceClass", "sourceMethod", - "logp(Level, String, String, String, Object) msg", param); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), - "logp(Level, String, String, String, Object) msg"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), "sourceClass"); - assertSame(r.getSourceMethodName(), "sourceMethod"); - assertSame(r.getLevel(), Level.INFO); - assertEquals(1, r.getParameters().length); - assertSame(param, r.getParameters()[0]); - assertSame(r.getThrown(), null); - - this.sharedLogger.logp(Level.CONFIG, "sourceClass", "sourceMethod", - "logp(Level, String, String, String, Object) msg", param); - assertTrue(CallVerificationStack.getInstance().empty()); - this.sharedLogger.setLevel(Level.OFF); - this.sharedLogger.logp(Level.OFF, "sourceClass", "sourceMethod", - "logp(Level, String, String, String, Object) msg", param); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test logp(Level, String, String, String, Object) with null message and - * object. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logp", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class} - ) - public void testLogp_LevelStringStringStringObject_NullMsgObj() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.INFO); - child.logp(Level.INFO, null, null, null, (Object) null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertNull(r.getMessage()); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertEquals(1, r.getParameters().length); - assertNull(r.getParameters()[0]); - assertSame(r.getThrown(), null); - } - - /* - * Test logp(Level, String, String, String, Object) with null level. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logp", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class} - ) - - public void testLogp_LevelStringStringStringObject_NullLevel() { - // this.sharedLogger.setLevel(Level.OFF); - try { - this.sharedLogger.logp(null, "sourceClass", "sourceMethod", - "logp(Level, String, String, String, Object) msg", - new Object()); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - } - - /* - * Test logp(Level, String, String, String, Object[]) with normal values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logp", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object[].class} - ) - - public void testLogp_LevelStringStringStringObjects_Normal() { - Object[] params = new Object[2]; - params[0] = new Object(); - params[1] = new Object(); - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.logp(Level.INFO, "sourceClass", "sourceMethod", - "logp(Level, String, String, String, Object[]) msg", params); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), - "logp(Level, String, String, String, Object[]) msg"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), "sourceClass"); - assertSame(r.getSourceMethodName(), "sourceMethod"); - assertSame(r.getLevel(), Level.INFO); - assertEquals(2, r.getParameters().length); - assertSame(params[0], r.getParameters()[0]); - assertSame(params[1], r.getParameters()[1]); - assertSame(r.getThrown(), null); - - this.sharedLogger.logp(Level.CONFIG, "sourceClass", "sourceMethod", - "logp(Level, String, String, String, Object[]) msg", params); - assertTrue(CallVerificationStack.getInstance().empty()); - this.sharedLogger.setLevel(Level.OFF); - this.sharedLogger.logp(Level.OFF, "sourceClass", "sourceMethod", - "logp(Level, String, String, String, Object[]) msg", params); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test logp(Level, String, String, String, Object[]) with null message and - * object. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logp", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object[].class} - ) - public void testLogp_LevelStringStringStringObjects_NullMsgObj() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.INFO); - child.logp(Level.INFO, null, null, null, (Object[]) null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertNull(r.getMessage()); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - } - - /* - * Test logp(Level, String, String, String, Object[]) with null level. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logp", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object[].class} - ) - public void testLogp_LevelStringStringStringObjects_NullLevel() { - // this.sharedLogger.setLevel(Level.OFF); - try { - this.sharedLogger.logp(null, "sourceClass", "sourceMethod", - "logp(Level, String, String, String, Object[]) msg", - new Object[0]); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - } - - /* - * Test logp(Level, String, String, String, Throwable) with normal values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logp", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Throwable.class} - ) - public void testLogp_LevelStringStringStringThrowable_Normal() { - Throwable t = new Throwable(); - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.logp(Level.INFO, "sourceClass", "sourceMethod", - "logp(Level, String, String, String, Throwable) msg", t); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), - "logp(Level, String, String, String, Throwable) msg"); - assertSame(r.getResourceBundleName(), this.sharedLogger - .getResourceBundleName()); - assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle()); - assertSame(r.getSourceClassName(), "sourceClass"); - assertSame(r.getSourceMethodName(), "sourceMethod"); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), t); - - this.sharedLogger.logp(Level.CONFIG, "sourceClass", "sourceMethod", - "logp(Level, String, String, String, Throwable) msg", t); - assertTrue(CallVerificationStack.getInstance().empty()); - this.sharedLogger.setLevel(Level.OFF); - this.sharedLogger.logp(Level.OFF, "sourceClass", "sourceMethod", - "logp(Level, String, String, String, Throwable) msg", t); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test logp(Level, String, String, String, Throwable) with null message and - * throwable. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logp", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Throwable.class} - ) - public void testLogp_LevelStringStringStringThrowable_Null() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - - child.setLevel(Level.INFO); - child.logp(Level.INFO, null, null, null, (Throwable) null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), child.getName()); - assertNull(r.getMessage()); - assertSame(r.getResourceBundleName(), parent.getResourceBundleName()); - assertSame(r.getResourceBundle(), parent.getResourceBundle()); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - } - - /* - * Test logp(Level, String, String, String, Throwable) with null level. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logp", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Throwable.class} - ) - public void testLogp_LevelStringStringStringThrowable_NullLevel() { - // this.sharedLogger.setLevel(Level.OFF); - try { - this.sharedLogger.logp(null, "sourceClass", "sourceMethod", - "log(Level, String, String, String, Throwable) msg", - new Throwable()); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - } - - /* - * Test logrb(Level, String, String, String, String) with normal values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logrb", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class} - ) - public void testLogrb_LevelStringStringString_Normal() { - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.logrb(Level.INFO, "sourceClass", "sourceMethod", - VALID_RESOURCE_BUNDLE2, - "logrb(Level, String, String, String, String) msg"); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), - "logrb(Level, String, String, String, String) msg"); - assertSame(r.getResourceBundleName(), VALID_RESOURCE_BUNDLE2); - assertEquals(VALID_VALUE2, r.getResourceBundle().getString(VALID_KEY)); - assertSame(r.getSourceClassName(), "sourceClass"); - assertSame(r.getSourceMethodName(), "sourceMethod"); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - - this.sharedLogger.logrb(Level.CONFIG, "sourceClass", "sourceMethod", - VALID_RESOURCE_BUNDLE2, - "logrb(Level, String, String, String, String) msg"); - assertTrue(CallVerificationStack.getInstance().empty()); - this.sharedLogger.setLevel(Level.OFF); - this.sharedLogger.logrb(Level.OFF, "sourceClass", "sourceMethod", - VALID_RESOURCE_BUNDLE2, - "logrb(Level, String, String, String, String) msg"); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test logrb(Level, String, String, String, String) with null message. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logrb", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class} - ) - public void testLogrb_LevelStringStringString_NullMsg() { - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.logrb(Level.INFO, null, null, null, null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertNull(r.getMessage()); - assertSame(r.getResourceBundleName(), null); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - } - - /* - * Test logrb(Level, String, String, String) with null level. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logrb", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class} - ) - public void testLogrb_LevelStringStringString_NullLevel() { - try { - this.sharedLogger.logrb(null, "sourceClass", "sourceMethod", - VALID_RESOURCE_BUNDLE2, - "logrb(Level, String, String, String, String) msg"); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - } - - /* - * Test logrb(Level, String, String, String, String) with invalid resource - * bundle. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logrb", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class} - ) - public void testLogrb_LevelStringStringString_InvalidRes() { - this.sharedLogger.setLevel(Level.ALL); - this.sharedLogger.logrb(Level.ALL, "sourceClass", "sourceMethod", - INVALID_RESOURCE_BUNDLE, - "logrb(Level, String, String, String, String) msg"); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), - "logrb(Level, String, String, String, String) msg"); - assertSame(r.getResourceBundleName(), INVALID_RESOURCE_BUNDLE); - assertSame(r.getResourceBundle(), null); - assertSame(r.getSourceClassName(), "sourceClass"); - assertSame(r.getSourceMethodName(), "sourceMethod"); - assertSame(r.getLevel(), Level.ALL); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - } - - /* - * Test logrb(Level, String, String, String, String, Object) with normal - * values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logrb", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class} - ) - public void testLogrb_LevelStringStringStringObject_Normal() { - Object param = new Object(); - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.logrb(Level.INFO, "sourceClass", "sourceMethod", - VALID_RESOURCE_BUNDLE2, - "logrb(Level, String, String, String, String, Object) msg", - param); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), - "logrb(Level, String, String, String, String, Object) msg"); - assertSame(r.getResourceBundleName(), VALID_RESOURCE_BUNDLE2); - assertSame(r.getSourceClassName(), "sourceClass"); - assertSame(r.getSourceMethodName(), "sourceMethod"); - assertSame(r.getLevel(), Level.INFO); - assertEquals(1, r.getParameters().length); - assertSame(param, r.getParameters()[0]); - assertSame(r.getThrown(), null); - - this.sharedLogger.logrb(Level.CONFIG, "sourceClass", "sourceMethod", - VALID_RESOURCE_BUNDLE2, - "logrb(Level, String, String, String, String, Object) msg", - param); - assertTrue(CallVerificationStack.getInstance().empty()); - this.sharedLogger.setLevel(Level.OFF); - this.sharedLogger.logrb(Level.OFF, "sourceClass", "sourceMethod", - VALID_RESOURCE_BUNDLE2, - "logrb(Level, String, String, String, String, Object) msg", - param); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test logrb(Level, String, String, String, String, Object) with null - * message and object. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logrb", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class} - ) - public void testLogrb_LevelStringStringStringObject_NullMsgObj() { - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.logrb(Level.INFO, null, null, null, null, - (Object) null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertNull(r.getMessage()); - assertSame(r.getResourceBundleName(), null); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertEquals(1, r.getParameters().length); - assertNull(r.getParameters()[0]); - assertSame(r.getThrown(), null); - } - - /** - * java.util.logging.Logger#logrb(Level, String, String, String, String, - * Object) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Regression test.", - method = "logrb", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class} - ) - public void test_logrbLLevel_LString_LString_LObject_Security() - throws Exception { - // regression test for Harmony-1290 - SecurityManager originalSecurityManager = System.getSecurityManager(); - try { - System.setSecurityManager(new MockSecurityManager()); - Logger.global.logrb(Level.OFF, null, null, "abc", "def"); - } finally { - System.setSecurityManager(originalSecurityManager); - } - } - - /* - * Test logrb(Level, String, String, String, String, Object) with null - * level. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logrb", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class} - ) - public void testLogrb_LevelStringStringStringObject_NullLevel() { - // this.sharedLogger.setLevel(Level.OFF); - try { - this.sharedLogger.logrb(null, "sourceClass", "sourceMethod", - VALID_RESOURCE_BUNDLE2, - "logrb(Level, String, String, String, String, Object) msg", - new Object()); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - } - - /* - * Test logrb(Level, String, String, String, String, Object) with invalid - * resource bundle. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logrb", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class} - ) - public void testLogrb_LevelStringStringStringObject_InvalidRes() { - Object param = new Object(); - this.sharedLogger.setLevel(Level.ALL); - this.sharedLogger.logrb(Level.ALL, "sourceClass", "sourceMethod", - INVALID_RESOURCE_BUNDLE, - "logrb(Level, String, String, String, String) msg", param); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), - "logrb(Level, String, String, String, String) msg"); - assertSame(r.getResourceBundleName(), INVALID_RESOURCE_BUNDLE); - assertSame(r.getResourceBundle(), null); - assertSame(r.getSourceClassName(), "sourceClass"); - assertSame(r.getSourceMethodName(), "sourceMethod"); - assertSame(r.getLevel(), Level.ALL); - assertEquals(1, r.getParameters().length); - assertSame(param, r.getParameters()[0]); - assertSame(r.getThrown(), null); - } - - /* - * Test logrb(Level, String, String, String, String, Object[]) with normal - * values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logrb", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object[].class} - ) - public void testLogrb_LevelStringStringStringObjects_Normal() { - Object[] params = new Object[2]; - params[0] = new Object(); - params[1] = new Object(); - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.logrb(Level.INFO, "sourceClass", "sourceMethod", - VALID_RESOURCE_BUNDLE2, - "logrb(Level, String, String, String, String, Object[]) msg", - params); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), - "logrb(Level, String, String, String, String, Object[]) msg"); - assertSame(r.getResourceBundleName(), VALID_RESOURCE_BUNDLE2); - assertSame(r.getSourceClassName(), "sourceClass"); - assertSame(r.getSourceMethodName(), "sourceMethod"); - assertSame(r.getLevel(), Level.INFO); - assertEquals(2, r.getParameters().length); - assertSame(params[0], r.getParameters()[0]); - assertSame(params[1], r.getParameters()[1]); - assertSame(r.getThrown(), null); - - this.sharedLogger.logrb(Level.CONFIG, "sourceClass", "sourceMethod", - VALID_RESOURCE_BUNDLE2, - "logrb(Level, String, String, String, String, Object[]) msg", - params); - assertTrue(CallVerificationStack.getInstance().empty()); - this.sharedLogger.setLevel(Level.OFF); - this.sharedLogger.logrb(Level.OFF, "sourceClass", "sourceMethod", - VALID_RESOURCE_BUNDLE2, - "logrb(Level, String, String, String, String, Object[]) msg", - params); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test logrb(Level, String, String, String, String, Object[]) with null - * message and object. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logrb", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object[].class} - ) - public void testLogrb_LevelStringStringStringObjects_NullMsgObj() { - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.logrb(Level.INFO, null, null, null, null, - (Object[]) null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertNull(r.getMessage()); - assertSame(r.getResourceBundleName(), null); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - } - - /* - * Test logrb(Level, String, String, String, String, Object[]) with null - * level. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logrb", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object[].class} - ) - public void testLogrb_LevelStringStringStringObjects_NullLevel() { - try { - this.sharedLogger.logrb( - null, - "sourceClass", - "sourceMethod", - VALID_RESOURCE_BUNDLE2, - "logrb(Level, String, String, String, String, Object[]) msg", - new Object[0]); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - } - - /* - * Test logrb(Level, String, String, String, String, Object[]) with invalid - * resource bundle. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logrb", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object[].class} - ) - public void testLogrb_LevelStringStringStringObjects_InvalidRes() { - Object[] params = new Object[2]; - params[0] = new Object(); - params[1] = new Object(); - this.sharedLogger.setLevel(Level.ALL); - this.sharedLogger.logrb(Level.ALL, "sourceClass", "sourceMethod", - INVALID_RESOURCE_BUNDLE, - "logrb(Level, String, String, String, String) msg", params); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), - "logrb(Level, String, String, String, String) msg"); - assertSame(r.getResourceBundleName(), INVALID_RESOURCE_BUNDLE); - assertSame(r.getResourceBundle(), null); - assertSame(r.getSourceClassName(), "sourceClass"); - assertSame(r.getSourceMethodName(), "sourceMethod"); - assertSame(r.getLevel(), Level.ALL); - assertEquals(2, r.getParameters().length); - assertSame(params[0], r.getParameters()[0]); - assertSame(params[1], r.getParameters()[1]); - assertSame(r.getThrown(), null); - } - - /* - * Test logrb(Level, String, String, String, String, Throwable) with normal - * values. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logrb", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Throwable.class} - ) - public void testLogrb_LevelStringStringStringThrowable_Normal() { - Throwable t = new Throwable(); - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.logrb(Level.parse("1611"), "sourceClass", - "sourceMethod", VALID_RESOURCE_BUNDLE2, - "logrb(Level, String, String, String, String, Throwable) msg", - t); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), - "logrb(Level, String, String, String, String, Throwable) msg"); - assertSame(r.getResourceBundleName(), VALID_RESOURCE_BUNDLE2); - assertSame(r.getSourceClassName(), "sourceClass"); - assertSame(r.getSourceMethodName(), "sourceMethod"); - assertSame(r.getLevel(), Level.parse("1611")); - assertNull(r.getParameters()); - assertSame(r.getThrown(), t); - assertNull(Level.parse("1611").getResourceBundleName()); - - this.sharedLogger.logrb(Level.CONFIG, "sourceClass", "sourceMethod", - VALID_RESOURCE_BUNDLE2, - "logrb(Level, String, String, String, String, Throwable) msg", - t); - assertTrue(CallVerificationStack.getInstance().empty()); - this.sharedLogger.setLevel(Level.OFF); - this.sharedLogger.logrb(Level.OFF, "sourceClass", "sourceMethod", - VALID_RESOURCE_BUNDLE2, - "logrb(Level, String, String, String, String, Throwable) msg", - t); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test logrb(Level, String, String, String, String, Throwable) with null - * message and throwable. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logrb", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Throwable.class} - ) - public void testLogrb_LevelStringTStringStringhrowable_NullMsgObj() { - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.logrb(Level.INFO, null, null, null, null, - (Throwable) null); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertNull(r.getMessage()); - assertSame(r.getResourceBundleName(), null); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - } - - /* - * Test logrb(Level, String, String, String, String, Throwable) with null - * level. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logrb", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Throwable.class} - ) - public void testLogrb_LevelStringStringStringThrowable_NullLevel() { - // this.sharedLogger.setLevel(Level.OFF); - try { - this.sharedLogger.logrb( - null, - "sourceClass", - "sourceMethod", - VALID_RESOURCE_BUNDLE2, - "log(Level, String, String, String, String, Throwable) msg", - new Throwable()); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - } - - /* - * Test logrb(Level, String, String, String, String, Throwable) with invalid - * resource bundle. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "logrb", - args = {java.util.logging.Level.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Throwable.class} - ) - public void testLogrb_LevelStringStringStringThrowable_InvalidRes() { - Throwable t = new Throwable(); - this.sharedLogger.setLevel(Level.ALL); - this.sharedLogger.logrb(Level.ALL, "sourceClass", "sourceMethod", - INVALID_RESOURCE_BUNDLE, - "logrb(Level, String, String, String, String) msg", t); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), this.sharedLogger.getName()); - assertEquals(r.getMessage(), - "logrb(Level, String, String, String, String) msg"); - assertSame(r.getResourceBundleName(), INVALID_RESOURCE_BUNDLE); - assertSame(r.getResourceBundle(), null); - assertSame(r.getSourceClassName(), "sourceClass"); - assertSame(r.getSourceMethodName(), "sourceMethod"); - assertSame(r.getLevel(), Level.ALL); - assertNull(r.getParameters()); - assertSame(r.getThrown(), t); - } - - /* - * Test log(LogRecord) for a normal log record. Meanwhile the logger has an - * appropriate level, no filter, no parent. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.LogRecord.class} - ) - public void testLog_LogRecord_AppropriateLevelNoFilterNoParent() { - LogRecord r = new LogRecord(Level.INFO, - "testLog_LogRecord_AppropriateLevelNoFilterNoParent"); - - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.log(r); - - assertSame(r, CallVerificationStack.getInstance().pop()); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), null); - assertEquals(r.getMessage(), - "testLog_LogRecord_AppropriateLevelNoFilterNoParent"); - assertSame(r.getResourceBundleName(), null); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - } - - /* - * Test log(LogRecord) with null log record. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.LogRecord.class} - ) - public void testLog_LogRecord_Null() { - this.sharedLogger.setLevel(Level.INFO); - try { - this.sharedLogger.log(null); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - } - } - - /* - * Test log(LogRecord) for a normal log record. Meanwhile the logger has an - * inappropriate level, no filter, no parent. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.LogRecord.class} - ) - public void testLog_LogRecord_InppropriateLevelNoFilterNoParent() { - LogRecord r = new LogRecord(Level.INFO, - "testLog_LogRecord_InppropriateLevelNoFilterNoParent"); - - this.sharedLogger.setLevel(Level.WARNING); - this.sharedLogger.log(r); - assertTrue(CallVerificationStack.getInstance().empty()); - - r.setLevel(Level.OFF); - this.sharedLogger.setLevel(Level.OFF); - this.sharedLogger.log(r); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test log(LogRecord) for a normal log record. Meanwhile the logger has an - * appropriate level, a filter that accepts the fed log record, no parent. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.LogRecord.class} - ) - public void testLog_LogRecord_AppropriateLevelTrueFilterNoParent() { - LogRecord r = new LogRecord(Level.INFO, - "testLog_LogRecord_AppropriateLevelTrueFilterNoParent"); - - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.setFilter(new MockTrueFilter()); - this.sharedLogger.log(r); - - // pop twice, one pushed by mock handler, one by true mock filter - assertSame(r, CallVerificationStack.getInstance().pop()); - assertSame(r, CallVerificationStack.getInstance().pop()); - assertTrue(CallVerificationStack.getInstance().empty()); - - assertSame(r.getLoggerName(), null); - assertEquals(r.getMessage(), - "testLog_LogRecord_AppropriateLevelTrueFilterNoParent"); - assertSame(r.getResourceBundleName(), null); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - } - - /* - * Test log(LogRecord) for a normal log record. Meanwhile the logger has an - * appropriate level, a filter that rejects the fed log record, no parent. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.LogRecord.class} - ) - public void testLog_LogRecord_AppropriateLevelFalseFilterNoParent() { - LogRecord r = new LogRecord(Level.INFO, - "testLog_LogRecord_AppropriateLevelFalseFilterNoParent"); - - this.sharedLogger.setLevel(Level.INFO); - this.sharedLogger.setFilter(new MockFilter()); - this.sharedLogger.log(r); - - // pop only once, pushed by mock filter - assertSame(r, CallVerificationStack.getInstance().pop()); - assertTrue(CallVerificationStack.getInstance().empty()); - - assertSame(r.getLoggerName(), null); - assertEquals(r.getMessage(), - "testLog_LogRecord_AppropriateLevelFalseFilterNoParent"); - assertSame(r.getResourceBundleName(), null); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - } - - /* - * Test that the parent's handler is notified for a new log record when - * getUseParentHandlers() is true. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.LogRecord.class} - ) - public void testLog_ParentInformed() { - Logger child = new MockLogger("childLogger", VALID_RESOURCE_BUNDLE); - Logger parent = new MockParentLogger("parentLogger", - VALID_RESOURCE_BUNDLE2); - - child.setParent(parent); - child.setLevel(Level.INFO); - parent.setLevel(Level.INFO); - parent.addHandler(new MockHandler()); - LogRecord r = new LogRecord(Level.INFO, "testLog_ParentInformed"); - child.log(r); - assertTrue(child.getUseParentHandlers()); - // pop only once, pushed by the parent logger's handler, not by the - // parent itself! - assertSame(r, CallVerificationStack.getInstance().pop()); - assertTrue(CallVerificationStack.getInstance().empty()); - assertSame(r.getLoggerName(), null); - assertEquals(r.getMessage(), "testLog_ParentInformed"); - assertSame(r.getResourceBundleName(), null); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.INFO); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - - // set the child logger to disabling level - child.setLevel(Level.SEVERE); - child.log(r); - assertTrue(CallVerificationStack.getInstance().empty()); - - // set the parent logger to disabling level - child.setLevel(Level.INFO); - parent.setLevel(Level.SEVERE); - child.log(r); - assertSame(r, CallVerificationStack.getInstance().pop()); - assertTrue(CallVerificationStack.getInstance().empty()); - - // set the child logger off - child.setLevel(Level.OFF); - child.log(r); - assertTrue(CallVerificationStack.getInstance().empty()); - - // set the record off - r.setLevel(Level.OFF); - child.log(r); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test that the ancestor's handler is notified for a new log record when - * getUseParentHandlers() is true. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.LogRecord.class} - ) - public void testLog_AncestorInformed() { - Logger child = new MockLogger("childLogger", VALID_RESOURCE_BUNDLE); - Logger parent = new MockParentLogger("parentLogger", - VALID_RESOURCE_BUNDLE2); - Logger ancestor = new MockParentLogger("ancestorLogger", - VALID_RESOURCE_BUNDLE3); - - child.setParent(parent); - parent.setParent(ancestor); - child.setLevel(Level.INFO); - parent.setLevel(Level.INFO); - ancestor.setLevel(Level.OFF); - ancestor.addHandler(new MockHandler()); - LogRecord r = new LogRecord(Level.INFO, "testLog_AncestorInformed"); - child.log(r); - assertTrue(child.getUseParentHandlers()); - assertTrue(parent.getUseParentHandlers()); - // pop only once, pushed by the ancestor's logger's handler, not by the - // parent itself! - assertSame(r, CallVerificationStack.getInstance().pop()); - assertTrue(CallVerificationStack.getInstance().empty()); - - // set parent's level to a disabling one - parent.setLevel(Level.WARNING); - child.log(r); - assertSame(r, CallVerificationStack.getInstance().pop()); - assertTrue(CallVerificationStack.getInstance().empty()); - - // set child's level to a disabling one - parent.setLevel(Level.INFO); - child.setLevel(Level.WARNING); - child.log(r); - assertTrue(CallVerificationStack.getInstance().empty()); - - // set parent's useParentHandlers to false - parent.setLevel(Level.INFO); - child.setLevel(Level.INFO); - parent.setUseParentHandlers(false); - child.log(r); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test that the parent's handler is notified for a new log record when - * getUseParentHandlers() is false. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.LogRecord.class} - ) - public void testLog_ParentNotInformed() { - Logger child = new MockLogger("childLogger", VALID_RESOURCE_BUNDLE); - Logger parent = new MockParentLogger("parentLogger", - VALID_RESOURCE_BUNDLE2); - - child.setParent(parent); - child.setLevel(Level.INFO); - parent.setLevel(Level.INFO); - parent.addHandler(new MockHandler()); - LogRecord r = new LogRecord(Level.INFO, "testLog_ParentInformed"); - child.setUseParentHandlers(false); - child.log(r); - assertFalse(child.getUseParentHandlers()); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test that a logger with null level and no parent. Defaulted to - * Level.INFO. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.LogRecord.class} - ) - public void testLog_NullLevelNoParent() { - LogRecord r = new LogRecord(Level.INFO, "testLog_NullLevelNoParent"); - assertNull(this.sharedLogger.getLevel()); - assertNull(this.sharedLogger.getParent()); - assertTrue(this.sharedLogger.isLoggable(r.getLevel())); - this.sharedLogger.log(r); - assertSame(r, CallVerificationStack.getInstance().pop()); - assertTrue(CallVerificationStack.getInstance().empty()); - assertNull(this.sharedLogger.getLevel()); - - r.setLevel(Level.WARNING); - assertTrue(this.sharedLogger.isLoggable(r.getLevel())); - this.sharedLogger.log(r); - assertSame(r, CallVerificationStack.getInstance().pop()); - assertTrue(CallVerificationStack.getInstance().empty()); - - r.setLevel(Level.CONFIG); - this.sharedLogger.log(r); - assertFalse(this.sharedLogger.isLoggable(r.getLevel())); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test that a logger inherits its parent level when its level is null. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.LogRecord.class} - ) - public void testLog_NullLevelHasParent() { - Logger child = new MockLogger("childLogger", VALID_RESOURCE_BUNDLE); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - parent.setLevel(Level.FINER); - - assertNull(child.getLevel()); - - LogRecord r = new LogRecord(Level.FINE, "testLog_NullLevelHasParent"); - child.log(r); - assertTrue(child.isLoggable(r.getLevel())); - // pop only once, pushed by the child logger's handler - assertSame(r, CallVerificationStack.getInstance().pop()); - assertTrue(CallVerificationStack.getInstance().empty()); - - assertSame(r.getLoggerName(), null); - assertEquals(r.getMessage(), "testLog_NullLevelHasParent"); - assertSame(r.getResourceBundleName(), null); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.FINE); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - assertNull(child.getLevel()); - - // set the parent logger to disabling level - parent.setLevel(Level.CONFIG); - assertFalse(child.isLoggable(r.getLevel())); - child.log(r); - assertTrue(CallVerificationStack.getInstance().empty()); - assertNull(child.getLevel()); - - // test ancestor - Logger ancestor = new MockLogger("ancestorLogger", - VALID_RESOURCE_BUNDLE3); - parent.setParent(ancestor); - parent.setLevel(null); - parent.setUseParentHandlers(false); - ancestor.setLevel(Level.ALL); - child.log(r); - assertTrue(child.isLoggable(r.getLevel())); - assertSame(r, CallVerificationStack.getInstance().pop()); - assertTrue(CallVerificationStack.getInstance().empty()); - assertNull(child.getLevel()); - assertNull(parent.getLevel()); - } - - /* - * Test that a logger with null resource bundle and no parent. Defaulted to - * null. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.LogRecord.class} - ) - public void testLog_NullResNoParent() { - Logger log = new MockLogger("Logger", null); - log.addHandler(new MockHandler()); - log.setLevel(Level.FINE); - - assertNull(log.getResourceBundle()); - assertNull(log.getResourceBundleName()); - assertNull(log.getParent()); - log.log(Level.INFO, "testLog_NullResNoParent"); - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - assertNull(log.getResourceBundle()); - assertNull(log.getResourceBundleName()); - assertNull(r.getResourceBundle()); - assertNull(r.getResourceBundleName()); - } - - /* - * Test that a logger inherits its parent resource bundle when its resource - * bundle is null. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.LogRecord.class} - ) - public void testLog_NullResHasParent() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2); - child.addHandler(new MockHandler()); - child.setParent(parent); - parent.setLevel(Level.FINER); - assertNull(child.getResourceBundle()); - assertNull(child.getResourceBundleName()); - - child.log(Level.FINE, "testLog_NullResHasParent"); - // pop only once, pushed by the child logger's handler - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - - assertSame(r.getLoggerName(), "childLogger"); - assertEquals(r.getMessage(), "testLog_NullResHasParent"); - assertSame(r.getResourceBundleName(), VALID_RESOURCE_BUNDLE2); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.FINE); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - assertNull(child.getResourceBundle()); - assertNull(child.getResourceBundleName()); - } - - /* - * Test that a logger inherits its ancestor's resource bundle when its - * resource bundle and its parent's resource bundle are both null. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.LogRecord.class} - ) - public void testLog_NullResHasAncestor() { - Logger child = new MockLogger("childLogger", null); - Logger parent = new MockLogger("parentLogger", null); - Logger ancestor = new MockLogger("ancestorLogger", - VALID_RESOURCE_BUNDLE3); - child.addHandler(new MockHandler()); - child.setParent(parent); - parent.setParent(ancestor); - parent.setLevel(Level.FINER); - assertNull(child.getResourceBundle()); - assertNull(child.getResourceBundleName()); - - child.log(Level.FINE, "testLog_NullResHasAncestor"); - // pop only once, pushed by the child logger's handler - LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop(); - assertTrue(CallVerificationStack.getInstance().empty()); - - assertSame(r.getLoggerName(), "childLogger"); - assertEquals(r.getMessage(), "testLog_NullResHasAncestor"); - assertSame(r.getResourceBundleName(), VALID_RESOURCE_BUNDLE3); - assertSame(r.getSourceClassName(), null); - assertSame(r.getSourceMethodName(), null); - assertSame(r.getLevel(), Level.FINE); - assertNull(r.getParameters()); - assertSame(r.getThrown(), null); - assertNull(child.getResourceBundle()); - assertNull(child.getResourceBundleName()); - } - - /* - * Test when one handler throws an exception. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "log", - args = {java.util.logging.LogRecord.class} - ) - public void testLog_ExceptionalHandler() { - MockLogger l = new MockLogger("testLog_ExceptionalHandler", null); - l.addHandler(new MockExceptionalHandler()); - l.addHandler(new MockHandler()); - try { - l.severe("testLog_ExceptionalHandler"); - fail("Should throw RuntimeException!"); - } catch (RuntimeException e) { - } - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test whether privileged code is used to load resource bundles. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getAnonymousLogger", - args = {java.lang.String.class} - ) - public void testLoadResourceBundle() { - // - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockNoLoadingClassSecurityManager()); - try { - Logger.getAnonymousLogger(VALID_RESOURCE_BUNDLE); - } finally { - System.setSecurityManager(oldMan); - } - } - - - /** - * java.util.logging.Logger#logrb(Level, String, String, String, String, - * Object) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getLogger", - args = {java.lang.String.class} - ) - public void test_init_logger() throws Exception { - Properties p = new Properties(); - p.put("testGetLogger_Normal_ANewLogger2.level", "ALL"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - assertNull(LogManager.getLogManager().getLogger( - "testGetLogger_Normal_ANewLogger2")); - SecurityManager originalSecurityManager = System.getSecurityManager(); - try { - Logger logger = Logger - .getLogger("testGetLogger_Normal_ANewLogger2"); - System.setSecurityManager(new MockSecurityManager()); - try { - logger.setLevel(Level.ALL); - fail("should throw SecurityException"); - } catch (SecurityException e) { - // expected - } - try { - logger.setParent(Logger.getLogger("")); - fail("should throw SecurityException"); - } catch (SecurityException e) { - // expected - } - } finally { - System.setSecurityManager(originalSecurityManager); - } - } - - /* - * test initHandler - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "initHandler", - args = {} - ) - @KnownFailure(value="bug 2002061O") - public void test_initHandler() throws Exception { - File logProps = new File(LOGGING_CONFIG_FILE); - LogManager lm = LogManager.getLogManager(); - lm.readConfiguration(new FileInputStream(logProps)); - - Logger log = Logger.getLogger(""); - // can log properly - Handler[] handlers = log.getHandlers(); - assertEquals(2, handlers.length); - } - - - /* - * A mock logger, used to test the protected constructors and fields. - */ - public static class MockLogger extends Logger { - - public MockLogger(String name, String resourceBundleName) { - super(name, resourceBundleName); - } - } - - /* - * A mock logger, used to test inheritance. - */ - public static class MockParentLogger extends Logger { - - public MockParentLogger(String name, String resourceBundleName) { - super(name, resourceBundleName); - } - - public void log(LogRecord record) { - CallVerificationStack.getInstance().push(record); - super.log(record); - } - - } - - /* - * A mock handler, used to validate the expected method is called with the - * expected parameters. - */ - public static class MockHandler extends Handler { - - public void close() { - // System.out.println("close!"); - } - - public void flush() { - // System.out.println("flushed!"); - } - - public void publish(LogRecord record) { - // System.out.println("publish!"); - CallVerificationStack.getInstance().push(record); - } - } - - /* - * A mock handler that throws an exception when publishing a log record. - */ - public static class MockExceptionalHandler extends Handler { - - public void close() { - // System.out.println("close!"); - } - - public void flush() { - // System.out.println("flushed!"); - } - - public void publish(LogRecord record) { - // System.out.println("publish!"); - throw new RuntimeException(); - } - } - - /* - * Used to grant all permissions except logging control. - */ - public static class MockSecurityManager extends SecurityManager { - - public MockSecurityManager() { - } - - public void checkPermission(Permission perm) { - // grant all permissions except logging control - if (perm instanceof LoggingPermission) { - throw new SecurityException(); - } - } - - public void checkPermission(Permission perm, Object context) { - // grant all permissions except logging control - if (perm instanceof LoggingPermission) { - throw new SecurityException(); - } - } - } - - /* - * Used to grant all permissions except getting class loader. - */ - public static class MockNoLoadingClassSecurityManager extends - SecurityManager { - - public MockNoLoadingClassSecurityManager() { - } - - public void checkPermission(Permission perm) { - // grant all permissions except getting class loader - if (perm instanceof RuntimePermission) { - if ("getClassLoader".equals(perm.getName())) { - throw new SecurityException(); - } - } - } - - public void checkPermission(Permission perm, Object context) { - // grant all permissions except logging control - if (perm instanceof LoggingPermission) { - throw new SecurityException(); - } - } - } - - - /* - * A mock filter, always return false. - */ - public static class MockFilter implements Filter { - - public boolean isLoggable(LogRecord record) { - CallVerificationStack.getInstance().push(record); - return false; - } - } - - /* - * A mock filter, always return true. - */ - public static class MockTrueFilter implements Filter { - - public boolean isLoggable(LogRecord record) { - CallVerificationStack.getInstance().push(record); - return true; - } - } -} diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggingMXBeanTest.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggingMXBeanTest.java deleted file mode 100644 index c9b7d5047..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggingMXBeanTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.harmony.logging.tests.java.util.logging; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestLevel; - -import junit.framework.TestCase; - -import tests.util.CallVerificationStack; - -import java.util.List; -import java.util.logging.LoggingMXBean; -/** - * This testcase verifies the signature of the interface Filter. - * - */ -@TestTargetClass(LoggingMXBean.class) -public class LoggingMXBeanTest extends TestCase { - - private MockLoggingMXBean m = null; - - /* - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - m = new MockLoggingMXBean(); - } - - /* - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - } - - - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getLoggerLevel", - args = {java.lang.String.class} - ) - public void testGetLoggerLevel() { - assertNull(m.getLoggerLevel(null)); - } - - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getLoggerNames", - args = {} - ) - public void testGetLoggerNames() { - assertNull(m.getLoggerNames()); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getParentLoggerName", - args = {java.lang.String.class} - ) - public void testGetParentLoggerName() { - assertNull(m.getParentLoggerName(null)); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setLoggerLevel", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testSetLoggerLevel() { - try{ - m.setLoggerLevel(null,null); - } - catch (Exception e){ - throw new AssertionError(); - } - } - - /* - * This inner class implements the interface Filter to verify the signature. - */ - private class MockLoggingMXBean implements LoggingMXBean { - - public String getLoggerLevel(String loggerName) { - return null; - } - - public List getLoggerNames() { - return null; - } - - public String getParentLoggerName(String loggerName) { - return null; - } - - public void setLoggerLevel(String loggerName, String levelName) { - - } - - - } -} diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggingPermissionTest.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggingPermissionTest.java deleted file mode 100644 index 9507bbd7d..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggingPermissionTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.logging.tests.java.util.logging; - -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import java.util.logging.LoggingPermission; - -import junit.framework.TestCase; - -import org.apache.harmony.testframework.serialization.SerializationTest; - -@TestTargetClass(LoggingPermission.class) -public class LoggingPermissionTest extends TestCase { - - /** - * @tests serialization/deserialization compatibility. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "!SerializationSelf", - args = {} - ) - public void testSerializationSelf() throws Exception { - SerializationTest.verifySelf(new LoggingPermission("control", "")); - } - - /** - * @tests serialization/deserialization compatibility with RI. - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "!SerializationGolden", - args = {} - ) - public void testSerializationCompatibility() throws Exception { - - SerializationTest.verifyGolden(this, new LoggingPermission("control", - "")); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "LoggingPermission", - args = {java.lang.String.class, java.lang.String.class} - ) - public void testLoggingPermission() { - try { - new LoggingPermission(null, null); - fail("should throw IllegalArgumentException"); - } catch (NullPointerException e) { - } - try { - new LoggingPermission("", null); - fail("should throw IllegalArgumentException"); - } catch (IllegalArgumentException e) { - } - try { - new LoggingPermission("bad name", null); - fail("should throw IllegalArgumentException"); - } catch (IllegalArgumentException e) { - } - try { - new LoggingPermission("Control", null); - fail("should throw IllegalArgumentException"); - } catch (IllegalArgumentException e) { - } - try { - new LoggingPermission("control", - "bad action"); - fail("should throw IllegalArgumentException"); - } catch (IllegalArgumentException e) { - } - - new LoggingPermission("control", ""); - - new LoggingPermission("control", null); - } - -} diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MemoryHandlerTest.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MemoryHandlerTest.java deleted file mode 100644 index 9aa344a5d..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MemoryHandlerTest.java +++ /dev/null @@ -1,554 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.logging.tests.java.util.logging; - -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; -import java.io.StringWriter; -import java.security.Permission; -import java.util.Properties; -import java.util.ResourceBundle; -import java.util.logging.Filter; -import java.util.logging.Formatter; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogManager; -import java.util.logging.LogRecord; -import java.util.logging.LoggingPermission; -import java.util.logging.MemoryHandler; -import java.util.logging.SimpleFormatter; - -import junit.framework.TestCase; - -import org.apache.harmony.logging.tests.java.util.logging.HandlerTest.NullOutputStream; -import org.apache.harmony.logging.tests.java.util.logging.util.EnvironmentHelper; - -/** - * - */ -@TestTargetClass(MemoryHandler.class) -public class MemoryHandlerTest extends TestCase { - - final static LogManager manager = LogManager.getLogManager(); - - final static Properties props = new Properties(); - - final static String baseClassName = MemoryHandlerTest.class.getName(); - - final static StringWriter writer = new StringWriter(); - - final static SecurityManager securityManager = new MockSecurityManager(); - - private final PrintStream err = System.err; - - private OutputStream errSubstituteStream = null; - - MemoryHandler handler; - - Handler target = new MockHandler(); - - /* - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - manager.reset(); - initProps(); - manager.readConfiguration(EnvironmentHelper - .PropertiesToInputStream(props)); - handler = new MemoryHandler(); - errSubstituteStream = new NullOutputStream(); - System.setErr(new PrintStream(errSubstituteStream)); - } - - /** - * - */ - private void initProps() { - props.put("java.util.logging.MemoryHandler.level", "FINE"); - props.put("java.util.logging.MemoryHandler.filter", baseClassName - + "$MockFilter"); - props.put("java.util.logging.MemoryHandler.size", "2"); - props.put("java.util.logging.MemoryHandler.push", "WARNING"); - props.put("java.util.logging.MemoryHandler.target", baseClassName - + "$MockHandler"); - props.put("java.util.logging.MemoryHandler.formatter", baseClassName - + "$MockFormatter"); - } - - /* - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - manager.readConfiguration(); - props.clear(); - System.setErr(err); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "SecurityException", - method = "close", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "SecurityException", - method = "setPushLevel", - args = {java.util.logging.Level.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "SecurityException", - method = "flush", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "SecurityException", - method = "push", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "SecurityException", - method = "getPushLevel", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "SecurityException", - method = "isLoggable", - args = {java.util.logging.LogRecord.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "SecurityException", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - }) - public void testGlobalSecurity() { - SecurityManager currentManager = System.getSecurityManager(); - System.setSecurityManager(securityManager); - try { - try { - handler.close(); - fail("should throw security exception"); - } catch (SecurityException e) { - } - try { - handler.setPushLevel(Level.CONFIG); - fail("should throw security exception"); - } catch (SecurityException e) { - } - handler.flush(); - handler.push(); - handler.getPushLevel(); - handler.isLoggable(new LogRecord(Level.ALL, "message")); - handler.publish(new LogRecord(Level.ALL, "message")); - } finally { - System.setSecurityManager(currentManager); - } - - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "close", - args = {} - ) - public void testClose() { - Filter filter = handler.getFilter(); - Formatter formatter = handler.getFormatter(); - writer.getBuffer().setLength(0); - handler.close(); - assertEquals(writer.toString(), "close"); - assertEquals(handler.getFilter(), filter); - assertEquals(handler.getFormatter(), formatter); - assertNull(handler.getEncoding()); - assertNotNull(handler.getErrorManager()); - assertEquals(handler.getLevel(), Level.OFF); - assertEquals(handler.getPushLevel(), Level.WARNING); - assertFalse(handler.isLoggable(new LogRecord(Level.SEVERE, "test"))); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "flush", - args = {} - ) - public void testFlush() { - Filter filter = handler.getFilter(); - Formatter formatter = handler.getFormatter(); - writer.getBuffer().setLength(0); - handler.flush(); - assertEquals(writer.toString(), "flush"); - assertEquals(handler.getFilter(), filter); - assertEquals(handler.getFormatter(), formatter); - assertNull(handler.getEncoding()); - assertNotNull(handler.getErrorManager()); - assertEquals(handler.getLevel(), Level.FINE); - assertEquals(handler.getPushLevel(), Level.WARNING); - assertTrue(handler.isLoggable(new LogRecord(Level.SEVERE, "test"))); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "isLoggable", - args = {java.util.logging.LogRecord.class} - ) - public void testIsLoggable() { - try { - handler.isLoggable(null); - fail("should throw NullPointerException"); - } catch (NullPointerException e) { - // expected - } - LogRecord record = new LogRecord(Level.FINER, "MSG1"); - assertFalse(handler.isLoggable(record)); - - - record = new LogRecord(Level.FINE, "MSG2"); - assertTrue(handler.isLoggable(record)); - assertTrue(handler.isLoggable(new LogRecord(Level.INFO, "1"))); - assertTrue(handler.isLoggable(new LogRecord(Level.WARNING, "2"))); - assertTrue(handler.isLoggable(new LogRecord(Level.SEVERE, "3"))); - - record = new LogRecord(Level.CONFIG, "MSG3"); - assertTrue(handler.isLoggable(record)); - - record = new LogRecord(Level.CONFIG, "false"); - assertFalse(handler.isLoggable(record)); - - handler.setFilter(null); - record = new LogRecord(Level.CONFIG, "false"); - assertTrue(handler.isLoggable(record)); - } - - /* - * Class under test for void MemoryHandler() - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "check errors", - method = "MemoryHandler", - args = {} - ) - public void testMemoryHandler() throws IOException { - assertNotNull("Filter should not be null", handler.getFilter()); - assertNotNull("Formatter should not be null", handler.getFormatter()); - assertNull("character encoding should be null", handler.getEncoding()); - assertNotNull("ErrorManager should not be null", handler - .getErrorManager()); - assertEquals("Level should be FINE", Level.FINE, handler.getLevel()); - assertEquals("Level should be WARNING", Level.WARNING, handler - .getPushLevel()); - - props.clear(); - props.put("java.util.logging.MemoryHandler.target", baseClassName - + "$MockHandler"); - - manager.readConfiguration(EnvironmentHelper - .PropertiesToInputStream(props)); - handler = new MemoryHandler(); - assertNull(handler.getFilter()); - assertTrue(handler.getFormatter() instanceof SimpleFormatter); - assertNull(handler.getEncoding()); - assertNotNull(handler.getErrorManager()); - assertEquals(handler.getLevel(), Level.ALL); - assertEquals(handler.getPushLevel(), Level.SEVERE); - - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "MemoryHandler", - args = {} - ) - public void testMemoryHandlerInvalidProps() throws IOException { - // null target - try { - props.remove("java.util.logging.MemoryHandler.target"); - manager.readConfiguration(EnvironmentHelper - .PropertiesToInputStream(props)); - handler = new MemoryHandler(); - fail("should throw RuntimeException: target must be set"); - } catch (RuntimeException e) { - } - - // invalid target - try { - props.put("java.util.logging.MemoryHandler.target", "badname"); - manager.readConfiguration(EnvironmentHelper - .PropertiesToInputStream(props)); - handler = new MemoryHandler(); - fail("should throw RuntimeException: target must be valid"); - } catch (RuntimeException e) { - } - - // invalid formatter - initProps(); - props.put("java.util.logging.MemoryHandler.formatter", "badname"); - manager.readConfiguration(EnvironmentHelper - .PropertiesToInputStream(props)); - handler = new MemoryHandler(); - assertTrue(handler.getFormatter() instanceof SimpleFormatter); - - // invalid level - initProps(); - props.put("java.util.logging.MemoryHandler.level", "badname"); - manager.readConfiguration(EnvironmentHelper - .PropertiesToInputStream(props)); - handler = new MemoryHandler(); - assertEquals(handler.getLevel(), Level.ALL); - - // invalid pushlevel - initProps(); - props.put("java.util.logging.MemoryHandler.push", "badname"); - manager.readConfiguration(EnvironmentHelper - .PropertiesToInputStream(props)); - handler = new MemoryHandler(); - assertEquals(handler.getPushLevel(), Level.SEVERE); - - // invalid filter - initProps(); - props.put("java.util.logging.MemoryHandler.filter", "badname"); - manager.readConfiguration(EnvironmentHelper - .PropertiesToInputStream(props)); - handler = new MemoryHandler(); - assertNull(handler.getFilter()); - - // invalid size - initProps(); - props.put("java.util.logging.MemoryHandler.size", "-1"); - manager.readConfiguration(EnvironmentHelper - .PropertiesToInputStream(props)); - handler = new MemoryHandler(); - initProps(); - props.put("java.util.logging.MemoryHandler.size", "badsize"); - manager.readConfiguration(EnvironmentHelper - .PropertiesToInputStream(props)); - handler = new MemoryHandler(); - - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "MemoryHandler", - args = {} - ) - public void testMemoryHandlerDefaultValue() throws SecurityException, - IOException { - props.clear(); - props.put("java.util.logging.MemoryHandler.target", baseClassName - + "$MockHandler"); - - manager.readConfiguration(EnvironmentHelper - .PropertiesToInputStream(props)); - handler = new MemoryHandler(); - assertNull(handler.getFilter()); - assertTrue(handler.getFormatter() instanceof SimpleFormatter); - assertNull(handler.getEncoding()); - assertNotNull(handler.getErrorManager()); - assertEquals(handler.getLevel(), Level.ALL); - assertEquals(handler.getPushLevel(), Level.SEVERE); - } - - /* - * Class under test for void MemoryHandler(Handler, int, Level) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "MemoryHandler", - args = {java.util.logging.Handler.class, int.class, java.util.logging.Level.class} - ) - public void testMemoryHandlerHandlerintLevel() { - handler = new MemoryHandler(target, 2, Level.FINEST); - assertNotNull("Filter should not be null", handler.getFilter()); - assertNotNull("Formatter should not be null", handler.getFormatter()); - assertNull("character encoding should be null", handler.getEncoding()); - assertNotNull("ErrorManager should not be null", handler - .getErrorManager()); - assertEquals("Level should be FINE", Level.FINE, handler.getLevel()); - assertEquals("Level should be FINEST", Level.FINEST, handler - .getPushLevel()); - - try { - new MemoryHandler(null, 2, Level.FINEST); - fail("should throw NullPointerException"); - } catch (NullPointerException e) { - } - try { - new MemoryHandler(target, 2, null); - fail("should throw NullPointerException"); - } catch (NullPointerException e) { - } - try { - new MemoryHandler(target, 0, Level.FINEST); - fail("should throw IllegalArgumentException"); - } catch (IllegalArgumentException e) { - } - try { - new MemoryHandler(target, -1, Level.FINEST); - fail("should throw IllegalArgumentException"); - } catch (IllegalArgumentException e) { - } - - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getPushLevel", - args = {} - ) - public void testGetPushLevel() { - try { - handler.setPushLevel(null); - fail("should throw NullPointerException"); - } catch (NullPointerException e) { - } - handler.setPushLevel(Level.parse("123")); - assertEquals(handler.getPushLevel(), Level.parse("123")); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setPushLevel", - args = {java.util.logging.Level.class} - ) - public void testSetPushLevel() { - // change push level don't trigger push action - writer.getBuffer().setLength(0); - LogRecord lr = new LogRecord(Level.CONFIG, "lr"); - assertTrue(handler.isLoggable(lr)); - handler.publish(lr); - assertEquals(writer.toString(), ""); - writer.getBuffer().setLength(0); - handler.setPushLevel(Level.FINE); - assertEquals(writer.toString(), ""); - handler.publish(lr); - assertEquals(writer.toString(), lr.getMessage() + lr.getMessage()); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "push", - args = {} - ) - public void testPushPublic() { - writer.getBuffer().setLength(0); - // loggable but don't trig push - handler.publish(new LogRecord(Level.CONFIG, "MSG1")); - assertEquals("", writer.toString()); - // trig push - handler.publish(new LogRecord(Level.SEVERE, "MSG2")); - assertEquals(writer.toString(), "MSG1MSG2"); - writer.getBuffer().setLength(0); - - // regression test for Harmony-1292 - handler.publish(new LogRecord(Level.WARNING, "MSG")); - assertEquals("MSG",writer.toString()); - - writer.getBuffer().setLength(0); - // push nothing - handler.push(); - assertEquals("", writer.toString()); - // loggable but not push - handler.publish(new LogRecord(Level.CONFIG, "MSG3")); - assertEquals("", writer.toString()); - // not loggable - handler.publish(new LogRecord(Level.FINEST, "MSG4")); - assertEquals("", writer.toString()); - // loggable but not push - handler.publish(new LogRecord(Level.CONFIG, "MSG5")); - assertEquals("", writer.toString()); - // not loggable - handler.publish(new LogRecord(Level.FINER, "MSG6")); - assertEquals("", writer.toString()); - // not loggable - handler.publish(new LogRecord(Level.FINER, "false")); - assertEquals("", writer.toString()); - // loggable but not push - handler.publish(new LogRecord(Level.CONFIG, "MSG8")); - assertEquals("", writer.toString()); - // push all - handler.push(); - assertEquals(writer.toString(), "MSG5MSG8"); - writer.getBuffer().setLength(0); - handler.push(); - assertEquals("", writer.toString()); - } - - /* - * mock classes - */ - public static class MockFilter implements Filter { - public boolean isLoggable(LogRecord record) { - return !record.getMessage().equals("false"); - } - } - - public static class MockHandler extends Handler { - public void close() { - writer.write("close"); - } - - public void flush() { - writer.write("flush"); - } - - public void publish(LogRecord record) { - writer.write(record.getMessage()); - } - - } - - public static class MockFormatter extends Formatter { - public String format(LogRecord r) { - return r.getMessage(); - } - } - - public static class MockSecurityManager extends SecurityManager { - public void checkPermission(Permission perm) { - if (perm instanceof LoggingPermission) { - throw new SecurityException(); - } - return; - } - } - -} diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MessagesTest.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MessagesTest.java deleted file mode 100644 index 74edbcb09..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/MessagesTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.harmony.logging.tests.java.util.logging; - -import junit.framework.TestCase; - -import org.apache.harmony.logging.internal.nls.Messages; - -import java.io.OutputStream; -import java.io.PrintStream; -import java.util.logging.ErrorManager; - -import dalvik.annotation.AndroidOnly; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - - - -@TestTargetClass(Messages.class) -public class MessagesTest extends TestCase{ - - - private Messages m = null; - - public void setUp() throws Exception{ - super.setUp(); - m = new Messages(); - - } - - public void tearDown() throws Exception{ - super.tearDown(); - } - - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Just check signature, cannot make use of mock, method depend on luni", - method = "getString", - args = {java.lang.String.class} - ) - @AndroidOnly("harmony specific") - public void testGetString_String() { - m.getString(new String()); - } - - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "Juste check signature, cannot make use of mock, depend on luni", - method = "getString", - args = {java.lang.String.class, java.lang.Object.class} - ) - @AndroidOnly("harmony specific") - public void testGetString_StringObject() { - m.getString(new String(), new Object()); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Juste check signature, cannot make use of mock, depend on luni", - method = "getString", - args = {java.lang.String.class, int.class} - ) - @AndroidOnly("harmony specific") - public void testGetString_StringInt() { - m.getString(new String(), 0); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Juste check signature, cannot make use of mock, depend on luni", - method = "getString", - args = {java.lang.String.class, char.class} - ) - @AndroidOnly("harmony specific") - public void testGetString_StringChar() { - m.getString(new String(), 'a'); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Juste check signature, cannot make use of mock, depend on luni", - method = "getString", - args = {java.lang.String.class, java.lang.Object.class, java.lang.Object.class} - ) - @AndroidOnly("harmony specific") - public void testGetString_StringObjectObject() { - m.getString(new String(), new Object(), new Object() ); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Juste check signature, cannot make use of mock, depend on luni", - method = "getString", - args = {java.lang.String.class, java.lang.Object[].class} - ) - @AndroidOnly("harmony specific") - public void testGetString_StringObjectArray() { - m.getString(new String(), new Object[1]); - } - - -} diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/SimpleFormatterTest.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/SimpleFormatterTest.java deleted file mode 100644 index 79e37e8a2..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/SimpleFormatterTest.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.logging.tests.java.util.logging; - -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import java.util.Calendar; -import java.util.ResourceBundle; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogRecord; -import java.util.logging.MemoryHandler; -import java.util.logging.SimpleFormatter; - -import junit.framework.TestCase; - -/** - * - */ -@TestTargetClass(SimpleFormatter.class) -public class SimpleFormatterTest extends TestCase { - - SimpleFormatter sf; - - LogRecord lr; - - private static String MSG = "test msg. pls. ignore it\nadaadasfdasfd\nadfafdadfsa"; - - /* - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - sf = new SimpleFormatter(); - lr = new LogRecord(Level.FINE, MSG); - } - - /* - * test for constructor protected SimpleFormatter - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "SimpleFormatter", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getHead", - args = {java.util.logging.Handler.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getTail", - args = {java.util.logging.Handler.class} - ) - }) - public void testSimpleFormatter() { - assertEquals("Head for this SimpleFormatter should be empty", "", sf - .getHead(null)); - assertEquals("Tail for this SimpleFormatter should be empty", "", sf - .getTail(null)); - } - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "format", - args = {java.util.logging.LogRecord.class} - ) - public void testFormatNull() { - try { - sf.format(null); - fail("should throw nullpointer exception"); - } catch (NullPointerException e) { - } - sf.format(new LogRecord(Level.SEVERE, null)); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "format", - args = {java.util.logging.LogRecord.class} - ) - public void testLocalizedFormat() { - // if bundle set, should use localized message - ResourceBundle rb = ResourceBundle - .getBundle("bundles/java/util/logging/res"); - lr.setResourceBundle(rb); - lr.setMessage("msg"); - String localeMsg = rb.getString("msg"); - String str = sf.format(lr); - assertTrue(str.indexOf(localeMsg) > 0); - - // if bundle not set but bundle name set, should use original message - lr.setResourceBundle(null); - lr.setResourceBundleName("bundles/java/util/logging/res"); - lr.setMessage("msg"); - str = sf.format(lr); - localeMsg = rb.getString("msg"); - assertTrue(str.indexOf(localeMsg) < 0); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "format", - args = {java.util.logging.LogRecord.class} - ) - public void testFormat() { - String str = sf.format(lr); - Throwable t; - - lr.setMessage(MSG + " {0,number}"); - lr.setLoggerName("logger"); - lr.setResourceBundleName("rb name"); - lr.setSourceClassName("class"); - lr.setSourceMethodName("method"); - lr.setParameters(new Object[] { new Integer(100), new Object() }); - lr.setThreadID(1000); - lr.setThrown(t = new Exception("exception") { - private static final long serialVersionUID = 1L; - - public String getLocalizedMessage() { - return "locale"; - } - }); - lr.setSequenceNumber(12321312); - lr.setMillis(0); - str = sf.format(lr); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(12321312); - assertTrue(str.indexOf(String.valueOf(cal.get(Calendar.YEAR))) >= 0); - assertTrue(str.indexOf("class") > 0); - assertTrue(str.indexOf("method") > 0); - assertTrue(str.indexOf("100") > 0); - assertTrue(str.indexOf(t.toString()) > 0); - assertTrue(str.indexOf(Level.FINE.getLocalizedName()) > 0); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getHead", - args = {java.util.logging.Handler.class} - ) - public void testGetHead() { - assertEquals("", sf.getHead(null)); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getTail", - args = {java.util.logging.Handler.class} - ) - public void testGetTail() { - assertEquals("", sf.getTail(null)); - } -} diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/SocketHandlerTest.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/SocketHandlerTest.java deleted file mode 100644 index cc3b16566..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/SocketHandlerTest.java +++ /dev/null @@ -1,1059 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.logging.tests.java.util.logging; - -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.PrintStream; -import java.net.ServerSocket; -import java.net.Socket; -import java.security.Permission; -import java.util.Properties; -import java.util.logging.Filter; -import java.util.logging.Formatter; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogManager; -import java.util.logging.LogRecord; -import java.util.logging.LoggingPermission; -import java.util.logging.SimpleFormatter; -import java.util.logging.SocketHandler; -import java.util.logging.XMLFormatter; - -import junit.framework.TestCase; - -import org.apache.harmony.logging.tests.java.util.logging.HandlerTest.NullOutputStream; -import org.apache.harmony.logging.tests.java.util.logging.util.EnvironmentHelper; - -import tests.util.CallVerificationStack; - -/** - * Test class java.util.logging.ConsoleHandler - */ -@TestTargetClass(SocketHandler.class) -public class SocketHandlerTest extends TestCase { - - private static final LogManager LOG_MANAGER = LogManager.getLogManager(); - - private final static String INVALID_LEVEL = "impossible_level"; - - private final PrintStream err = System.err; - - private OutputStream errSubstituteStream = null; - - private static String className = SocketHandlerTest.class.getName(); - - private SocketHandler h = null; - - private Properties props; - - /* - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - errSubstituteStream = new NullOutputStream(); - System.setErr(new PrintStream(errSubstituteStream)); - } - - /* - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - //initProps - props = new Properties(); - props.put("handlers", className + "$MockHandler " + className - + "$MockHandler"); - props.put("java.util.logging.FileHandler.pattern", "%h/java%u.log"); - props.put("java.util.logging.FileHandler.limit", "50000"); - props.put("java.util.logging.FileHandler.count", "5"); - props.put("java.util.logging.FileHandler.formatter", - "java.util.logging.XMLFormatter"); - props.put(".level", "FINE"); - props.put("java.util.logging.ConsoleHandler.level", "OFF"); - props.put("java.util.logging.ConsoleHandler.formatter", - "java.util.logging.SimpleFormatter"); - props.put("foo.handlers", "java.util.logging.ConsoleHandler"); - props.put("foo.level", "WARNING"); - props.put("com.xyz.foo.level", "SEVERE"); - - - LOG_MANAGER.reset(); - LOG_MANAGER.readConfiguration(EnvironmentHelper - .PropertiesToInputStream(props)); - CallVerificationStack.getInstance().clear(); - if (null != h) { - h.close(); - h = null; - } - System.setErr(err); - super.tearDown(); - } - - - /* - * Test the constructor with no relevant log manager properties are set. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with no relevant log manager properties are set.", - method = "SocketHandler", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with no relevant log manager properties are set.", - method = "SocketHandler", - args = {java.lang.String.class, int.class} - ) - }) - public void testConstructor_NoProperties() throws Exception { - assertNull(LOG_MANAGER.getProperty( - "java.util.logging.SocketHandler.level")); - assertNull(LOG_MANAGER.getProperty( - "java.util.logging.SocketHandler.filter")); - assertNull(LOG_MANAGER.getProperty( - "java.util.logging.SocketHandler.formatter")); - assertNull(LOG_MANAGER.getProperty( - "java.util.logging.SocketHandler.encoding")); - assertNull(LOG_MANAGER.getProperty( - "java.util.logging.SocketHandler.host")); - assertNull(LOG_MANAGER.getProperty( - "java.util.logging.SocketHandler.port")); - - try { - h = new SocketHandler(); - fail("Should throw IllegalArgumentException!"); - } catch (IllegalArgumentException e) { - } - - try { - h = new SocketHandler(null, 0); - fail("Should throw IllegalArgumentException!"); - } catch (IllegalArgumentException e) { - } - - try { - h = new SocketHandler("", 0); - fail("Should throw IllegalArgumentException!"); - } catch (IllegalArgumentException e) { - } - - try { - h = new SocketHandler("127.0.0.1", -1); - fail("Should throw IllegalArgumentException!"); - } catch (IllegalArgumentException e) { - } - - try { - h = new SocketHandler("127.0.0.1", Integer.MAX_VALUE); - fail("Should throw IllegalArgumentException!"); - } catch (IllegalArgumentException e) { - } - - try { - h = new SocketHandler("127.0.0.1", 66666); - fail("Should throw IllegalArgumentException!"); - } catch (IllegalArgumentException e) { - } - - try { - h = new SocketHandler("127.0.0.1", 0); - fail("Should throw IllegalArgumentException!"); - } catch (IllegalArgumentException e) { - } - - // start the server to be ready to accept log messages - ServerThread thread = new ServerThread(); - thread.start(); - Thread.sleep(2000); - - h = new SocketHandler("127.0.0.1", 6666); - assertSame(h.getLevel(), Level.ALL); - assertTrue(h.getFormatter() instanceof XMLFormatter); - assertNull(h.getFilter()); - assertNull(h.getEncoding()); - h.close(); - // ensure the thread exits and the port becomes available again - thread.getReadString(); - } - - /* - * Test the constructor with no relevant log manager properties are set - * except host and port. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with no relevant log manager properties are set except host and port.", - method = "SocketHandler", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with no relevant log manager properties are set except host and port.", - method = "SocketHandler", - args = {java.lang.String.class, int.class} - ) - }) - public void testConstructor_NoBasicProperties() throws Exception { - assertNull(LOG_MANAGER.getProperty( - "java.util.logging.SocketHandler.level")); - assertNull(LOG_MANAGER.getProperty( - "java.util.logging.SocketHandler.filter")); - assertNull(LOG_MANAGER.getProperty( - "java.util.logging.SocketHandler.formatter")); - assertNull(LOG_MANAGER.getProperty( - "java.util.logging.SocketHandler.encoding")); - Properties p = new Properties(); - p.put("java.util.logging.SocketHandler.host", "127.0.0.1"); - p.put("java.util.logging.SocketHandler.port", "6666"); - LOG_MANAGER.readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - // start the server to be ready to accept log messages - ServerThread thread = new ServerThread(); - thread.start(); - Thread.sleep(2000); - - h = new SocketHandler(); - assertSame(h.getLevel(), Level.ALL); - assertTrue(h.getFormatter() instanceof XMLFormatter); - assertNull(h.getFilter()); - assertNull(h.getEncoding()); - h.close(); - // ensure the thread exits and the port becomes available again - thread.getReadString(); - - try { - h = new SocketHandler("127.0.sdfcdsfsa%%&&^0.1", 6665); - fail("Should throw IOException!"); - } catch (IOException e) { - } - } - - /* - * Test the constructor with insufficient privilege for connection. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies SecurityException.", - method = "SocketHandler", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies SecurityException.", - method = "SocketHandler", - args = {java.lang.String.class, int.class} - ) - }) - public void testConstructor_InsufficientPrivilege() throws Exception { - SecurityManager oldMan = null; - Properties p = new Properties(); - p.put("java.util.logging.SocketHandler.level", "FINE"); - p.put("java.util.logging.SocketHandler.filter", className - + "$MockFilter"); - p.put("java.util.logging.SocketHandler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.SocketHandler.encoding", "utf-8"); - p.put("java.util.logging.SocketHandler.host", "127.0.0.1"); - p.put("java.util.logging.SocketHandler.port", "6666"); - LOG_MANAGER.readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockNoSocketSecurityManager()); - try { - new SocketHandler(); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - System.setSecurityManager(new MockNoSocketSecurityManager()); - try { - new SocketHandler("127.0.0.1", 6666); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test the constructor with valid relevant log manager properties are set. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with valid relevant log manager properties are set.", - method = "SocketHandler", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with valid relevant log manager properties are set.", - method = "SocketHandler", - args = {java.lang.String.class, int.class} - ) - }) - public void testConstructor_ValidProperties() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.SocketHandler.level", "FINE"); - p.put("java.util.logging.SocketHandler.filter", className - + "$MockFilter"); - p.put("java.util.logging.SocketHandler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.SocketHandler.encoding", "iso-8859-1"); - p.put("java.util.logging.SocketHandler.host", "127.0.0.1"); - p.put("java.util.logging.SocketHandler.port", "6666"); - LOG_MANAGER.readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - // start the server to be ready to accept log messages - ServerThread thread = new ServerThread(); - thread.start(); - Thread.sleep(2000); - - h = new SocketHandler(); - assertSame(h.getLevel(), Level.parse("FINE")); - assertTrue(h.getFormatter() instanceof MockFormatter); - assertTrue(h.getFilter() instanceof MockFilter); - assertEquals(h.getEncoding(), "iso-8859-1"); - h.close(); - // ensure the thread exits and the port becomes available again - thread.getReadString(); - - // start the server to be ready to accept log messages - thread = new ServerThread(); - thread.start(); - Thread.sleep(2000); - - h = new SocketHandler("127.0.0.1", 6666); - assertSame(h.getLevel(), Level.parse("FINE")); - assertTrue(h.getFormatter() instanceof MockFormatter); - assertTrue(h.getFilter() instanceof MockFilter); - assertEquals(h.getEncoding(), "iso-8859-1"); - h.close(); - // ensure the thread exits and the port becomes available again - thread.getReadString(); - } - - /* - * Test the constructor with invalid relevant log manager properties are set - * except host and port. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with invalid relevant log manager properties are set except host and port.", - method = "SocketHandler", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with invalid relevant log manager properties are set except host and port.", - method = "SocketHandler", - args = {java.lang.String.class, int.class} - ) - }) - public void testConstructor_InvalidBasicProperties() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.SocketHandler.level", INVALID_LEVEL); - p.put("java.util.logging.SocketHandler.filter", className + ""); - p.put("java.util.logging.SocketHandler.formatter", className + ""); - p.put("java.util.logging.SocketHandler.encoding", "XXXX"); - p.put("java.util.logging.SocketHandler.host", "127.0.0.1"); - p.put("java.util.logging.SocketHandler.port", "6666"); - LOG_MANAGER.readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - // start the server to be ready to accept log messages - ServerThread thread = new ServerThread(); - thread.start(); - Thread.sleep(2000); - - h = new SocketHandler(); - assertSame(h.getLevel(), Level.ALL); - assertTrue(h.getFormatter() instanceof XMLFormatter); - assertNull(h.getFilter()); - assertNull(h.getEncoding()); - h.publish(new LogRecord(Level.SEVERE, "test")); - assertNull(h.getEncoding()); - h.close(); - // ensure the thread exits and the port becomes available again - thread.getReadString(); - - // start the server to be ready to accept log messages - thread = new ServerThread(); - thread.start(); - Thread.sleep(2000); - - h = new SocketHandler("127.0.0.1", 6666); - assertSame(h.getLevel(), Level.ALL); - assertTrue(h.getFormatter() instanceof XMLFormatter); - assertNull(h.getFilter()); - assertNull(h.getEncoding()); - h.publish(new LogRecord(Level.SEVERE, "test")); - assertNull(h.getEncoding()); - h.close(); - // ensure the thread exits and the port becomes available again - thread.getReadString(); - } - - /* - * Test the constructor with valid relevant log manager properties are set - * except port. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies IllegalArgumentException.", - method = "SocketHandler", - args = {} - ) - public void testConstructor_InvalidPort() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.SocketHandler.level", "FINE"); - p.put("java.util.logging.SocketHandler.filter", className - + "$MockFilter"); - p.put("java.util.logging.SocketHandler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.SocketHandler.encoding", "iso-8859-1"); - p.put("java.util.logging.SocketHandler.host", "127.0.0.1"); - p.put("java.util.logging.SocketHandler.port", "6666i"); - LOG_MANAGER.readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - try { - h = new SocketHandler(); - fail("Should throw IllegalArgumentException!"); - } catch (IllegalArgumentException e) { - - } - } - - /* - * Test the constructor with valid relevant log manager properties are set, - * but the port is not open. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies that the constructor with valid relevant log manager properties are set, but the port is not open.", - method = "SocketHandler", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies that the constructor with valid relevant log manager properties are set, but the port is not open.", - method = "SocketHandler", - args = {java.lang.String.class, int.class} - ) - }) - public void testConstructor_NotOpenPort() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.SocketHandler.level", "FINE"); - p.put("java.util.logging.SocketHandler.filter", className - + "$MockFilter"); - p.put("java.util.logging.SocketHandler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.SocketHandler.encoding", "iso-8859-1"); - p.put("java.util.logging.SocketHandler.host", "127.0.0.1"); - p.put("java.util.logging.SocketHandler.port", "6665"); - LOG_MANAGER.readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - try { - h = new SocketHandler(); - fail("Should throw IOException!"); - } catch (IOException e) { - - } - - try { - h = new SocketHandler("127.0.0.1", 6665); - fail("Should throw IOException!"); - } catch (IOException e) { - - } - } - - /* - * Test the constructor with valid relevant log manager properties are set - * except port. - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies IOException.", - method = "SocketHandler", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies IOException.", - method = "SocketHandler", - args = {java.lang.String.class, int.class} - ) - }) - public void testConstructor_InvalidHost() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.SocketHandler.level", "FINE"); - p.put("java.util.logging.SocketHandler.filter", className - + "$MockFilter"); - p.put("java.util.logging.SocketHandler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.SocketHandler.encoding", "iso-8859-1"); - p.put("java.util.logging.SocketHandler.host", " 34345 #$#%$%$"); - p.put("java.util.logging.SocketHandler.port", "6666"); - LOG_MANAGER.readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - try { - h = new SocketHandler(); - fail("Should throw IOException!"); - } catch (IOException e) { - - } - - try { - h = new SocketHandler(" 34345 #$#%$%$", 6666); - fail("Should throw IOException!"); - } catch (IOException e) { - - } - } - - /* - * Test close() when having sufficient privilege, and a record has been - * written to the output stream. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies close() when having sufficient privilege, and a record has been written to the output stream.", - method = "close", - args = {} - ) - public void testClose_SufficientPrivilege_NormalClose() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.SocketHandler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.SocketHandler.host", "127.0.0.1"); - p.put("java.util.logging.SocketHandler.port", "6666"); - LOG_MANAGER.readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - // start the server to be ready to accept log messages - ServerThread thread = new ServerThread(); - thread.start(); - Thread.sleep(2000); - - h = new SocketHandler(); - h.publish(new LogRecord(Level.SEVERE, - "testClose_SufficientPrivilege_NormalClose msg")); - h.close(); - assertEquals("MockFormatter_Head" - + "testClose_SufficientPrivilege_NormalClose msg" - + "MockFormatter_Tail", thread.getReadString()); - h.close(); - } - - /* - * Test close() when having sufficient privilege, and no record has been - * written to the output stream. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies close() when having sufficient privilege, and no record has been written to the output stream.", - method = "close", - args = {} - ) - public void testClose_SufficientPrivilege_DirectClose() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.SocketHandler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.SocketHandler.host", "127.0.0.1"); - p.put("java.util.logging.SocketHandler.port", "6666"); - LOG_MANAGER.readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - // start the server to be ready to accept log messages - ServerThread thread = new ServerThread(); - thread.start(); - Thread.sleep(2000); - - h = new SocketHandler(); - h.setLevel(Level.INFO); - - h.close(); - assertEquals("MockFormatter_Head" + "MockFormatter_Tail", thread - .getReadString()); - } - - /* - * Test close() when having insufficient privilege. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies close() when having insufficient privilege.", - method = "close", - args = {} - ) - public void testClose_InsufficientPrivilege() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.SocketHandler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.SocketHandler.host", "127.0.0.1"); - p.put("java.util.logging.SocketHandler.port", "6666"); - LOG_MANAGER.readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - // start the server to be ready to accept log messages - ServerThread thread = new ServerThread(); - thread.start(); - Thread.sleep(2000); - - h = new SocketHandler(); - h.setLevel(Level.INFO); - - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - try { - h.close(); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - } finally { - System.setSecurityManager(oldMan); - h.close(); - // ensure the thread exits and the port becomes available again - thread.getReadString(); - } - } - - /* - * Test publish(), use no filter, having output stream, normal log record. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish(), use no filter, having output stream, normal log record.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_NoFilter() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.SocketHandler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.SocketHandler.host", "127.0.0.1"); - p.put("java.util.logging.SocketHandler.port", "6666"); - LOG_MANAGER.readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - // start the server to be ready to accept log messages - ServerThread thread = new ServerThread(); - thread.start(); - Thread.sleep(2000); - - h = new SocketHandler(); - h.setLevel(Level.INFO); - - LogRecord r = new LogRecord(Level.INFO, "testPublish_NoFilter"); - h.setLevel(Level.INFO); - h.publish(r); - - h.setLevel(Level.WARNING); - h.publish(r); - - h.setLevel(Level.CONFIG); - h.publish(r); - - r.setLevel(Level.OFF); - h.setLevel(Level.OFF); - h.publish(r); - h.close(); - assertEquals("MockFormatter_Head" + "testPublish_NoFilter" - + "testPublish_NoFilter" + "MockFormatter_Tail", thread - .getReadString()); - } - - /* - * Test publish(), use a filter, having output stream, normal log record. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish(), use a filter, having output stream, normal log record.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_WithFilter() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.SocketHandler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.SocketHandler.host", "127.0.0.1"); - p.put("java.util.logging.SocketHandler.port", "6666"); - LOG_MANAGER.readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - // start the server to be ready to accept log messages - ServerThread thread = new ServerThread(); - thread.start(); - Thread.sleep(2000); - h = new SocketHandler(); - h.setLevel(Level.INFO); - h.setFilter(new MockFilter()); - - System.setErr(new PrintStream(new ByteArrayOutputStream())); - - LogRecord r = new LogRecord(Level.INFO, "testPublish_WithFilter"); - h.setLevel(Level.INFO); - h.publish(r); - h.close(); - assertEquals("MockFormatter_Head" + "MockFormatter_Tail", thread - .getReadString()); - } - - /* - * Test publish(), null log record, having output stream - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish(), null log record, having output stream.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_Null() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.SocketHandler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.SocketHandler.host", "127.0.0.1"); - p.put("java.util.logging.SocketHandler.port", "6666"); - LOG_MANAGER.readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - // start the server to be ready to accept log messages - ServerThread thread = new ServerThread(); - thread.start(); - Thread.sleep(2000); - h = new SocketHandler(); - h.setLevel(Level.INFO); - try { - h.publish(null); - } finally { - h.close(); - // ensure the thread exits and the port becomes available again - thread.getReadString(); - } - } - - /* - * Test publish(), a log record with empty msg, having output stream - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish() method, a log record with empty msg, having output stream.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_EmptyMsg() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.SocketHandler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.SocketHandler.host", "127.0.0.1"); - p.put("java.util.logging.SocketHandler.port", "6666"); - LOG_MANAGER.readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - // start the server to be ready to accept log messages - ServerThread thread = new ServerThread(); - thread.start(); - Thread.sleep(2000); - h = new SocketHandler(); - h.setLevel(Level.INFO); - LogRecord r = new LogRecord(Level.INFO, ""); - h.publish(r); - h.close(); - assertEquals("MockFormatter_Head" + "MockFormatter_Tail", thread - .getReadString()); - } - - /* - * Test publish(), a log record with null msg, having output stream - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish(), a log record with null msg, having output stream.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_NullMsg() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.SocketHandler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.SocketHandler.host", "127.0.0.1"); - p.put("java.util.logging.SocketHandler.port", "6666"); - LOG_MANAGER.readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - // start the server to be ready to accept log messages - ServerThread thread = new ServerThread(); - thread.start(); - Thread.sleep(2000); - h = new SocketHandler(); - h.setLevel(Level.INFO); - LogRecord r = new LogRecord(Level.INFO, null); - h.publish(r); - h.close(); - assertEquals("MockFormatter_Head" + "MockFormatter_Tail", thread - .getReadString()); - } - - /* - * Test publish(), after close. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish() method after close.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_AfterClose() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.SocketHandler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.SocketHandler.host", "127.0.0.1"); - p.put("java.util.logging.SocketHandler.port", "6666"); - LOG_MANAGER.readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - // start the server to be ready to accept log messages - ServerThread thread = new ServerThread(); - thread.start(); - Thread.sleep(2000); - h = new SocketHandler(); - h.setLevel(Level.FINE); - - assertSame(h.getLevel(), Level.FINE); - LogRecord r = new LogRecord(Level.INFO, "testPublish_NoFormatter"); - assertTrue(h.isLoggable(r)); - h.close(); - // ensure the thread exits and the port becomes available again - thread.getReadString(); - // assertFalse(h.isLoggable(r)); - h.publish(r); - h.flush(); - // assertEquals("MockFormatter_Head", - // this.errSubstituteStream.toString()); - } - - /* - * A mock filter, always return false. - */ - public static class MockFilter implements Filter { - - public boolean isLoggable(LogRecord record) { - CallVerificationStack.getInstance().push(record); - // System.out.println("filter called..."); - return false; - } - } - - /* - * A mock formatter. - */ - public static class MockFormatter extends Formatter { - public String format(LogRecord r) { - // System.out.println("formatter called..."); - return super.formatMessage(r); - } - - /* - * (non-Javadoc) - * - * @see java.util.logging.Formatter#getHead(java.util.logging.Handler) - */ - public String getHead(Handler h) { - return "MockFormatter_Head"; - } - - /* - * (non-Javadoc) - * - * @see java.util.logging.Formatter#getTail(java.util.logging.Handler) - */ - public String getTail(Handler h) { - return "MockFormatter_Tail"; - } - } - - /* - * Used to grant all permissions except logging control. - */ - public static class MockSecurityManager extends SecurityManager { - - public MockSecurityManager() { - } - - public void checkPermission(Permission perm) { - // grant all permissions except logging control - if (perm instanceof LoggingPermission) { - throw new SecurityException(); - } - } - - public void checkPermission(Permission perm, Object context) { - // grant all permissions except logging control - if (perm instanceof LoggingPermission) { - throw new SecurityException(); - } - } - } - - /* - * Used to grant all permissions except logging control. - */ - public static class MockNoSocketSecurityManager extends SecurityManager { - - public MockNoSocketSecurityManager() { - } - - public void checkPermission(Permission perm) { - } - - public void checkPermission(Permission perm, Object context) { - } - - public void checkConnect(String host, int port) { - throw new SecurityException(); - } - } - - /* - * A mock stream handler, expose setOutputStream. - */ - public static class MockSocketHandler extends SocketHandler { - public MockSocketHandler() throws Exception { - super(); - } - - public void setOutputStream(OutputStream out) { - super.setOutputStream(out); - } - - public boolean isLoggable(LogRecord r) { - CallVerificationStack.getInstance().push(r); - return super.isLoggable(r); - } - } - - /* - * A mock stream handler, expose setOutputStream. - */ - public static class MockHandler extends Handler { - public MockHandler() throws Exception { - } - - @Override - public void close() { - } - - @Override - public void flush() { - } - - @Override - public void publish(LogRecord record) { - } - } - - /* - * A server thread that accepts an incoming connection request and reads any - * incoming data into an byte array. - */ - public static class ServerThread extends Thread { - - private volatile StringBuffer sb = new StringBuffer(); - - private volatile boolean finished = false; - - public boolean finished() { - return this.finished; - } - - public String getReadString() throws Exception { - int i = 0; - while (!this.finished) { - sleep(100); - if (++i > 100) { - // connect to port 6666 to stop the listening. - try { - Socket s = new Socket("127.0.0.1", 6666); - OutputStream os = s.getOutputStream(); - os.write(1); - os.close(); - s.close(); - } catch (Exception e) { - // ignore - } - } - } - return this.sb.toString(); - } - - public void run() { - ServerSocket ss = null; - Socket s = null; - InputStreamReader reader = null; - try { - char[] buffer = new char[32]; - ss = new ServerSocket(6666); - s = ss.accept(); - reader = new InputStreamReader(s.getInputStream()); - while (true) { - int length = reader.read(buffer); - if (-1 == length) { - break; - } - this.sb.append(buffer, 0, length); - } - } catch (Exception e) { - e.printStackTrace(System.err); - } finally { - try { - if (null != reader) { - reader.close(); - s.close(); - ss.close(); - } - } catch (Exception e) { - e.printStackTrace(System.err); - } - this.finished = true; - } - } - } - -} diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/StreamHandlerTest.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/StreamHandlerTest.java deleted file mode 100644 index 72270e5b8..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/StreamHandlerTest.java +++ /dev/null @@ -1,1324 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.logging.tests.java.util.logging; - -import dalvik.annotation.*; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; -import java.io.UnsupportedEncodingException; -import java.nio.CharBuffer; -import java.nio.charset.Charset; -import java.nio.charset.CharsetEncoder; -import java.nio.charset.CodingErrorAction; -import java.security.Permission; -import java.util.Arrays; -import java.util.Properties; -import java.util.logging.Filter; -import java.util.logging.Formatter; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogManager; -import java.util.logging.LogRecord; -import java.util.logging.LoggingPermission; -import java.util.logging.SimpleFormatter; -import java.util.logging.SocketHandler; -import java.util.logging.StreamHandler; - -import junit.framework.TestCase; - -import org.apache.harmony.logging.tests.java.util.logging.HandlerTest.NullOutputStream; -import org.apache.harmony.logging.tests.java.util.logging.util.EnvironmentHelper; -import tests.util.CallVerificationStack; - -/** - * Test the class StreamHandler. - */ -@TestTargetClass(StreamHandler.class) -public class StreamHandlerTest extends TestCase { - - private final static String INVALID_LEVEL = "impossible_level"; - - private final PrintStream err = System.err; - - private OutputStream errSubstituteStream = null; - - private static String className = StreamHandlerTest.class.getName(); - - private static CharsetEncoder encoder; - - static { - encoder = Charset.forName("iso-8859-1").newEncoder(); - encoder.onMalformedInput(CodingErrorAction.REPLACE); - encoder.onUnmappableCharacter(CodingErrorAction.REPLACE); - } - - /* - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - errSubstituteStream = new NullOutputStream(); - System.setErr(new PrintStream(errSubstituteStream)); - } - - /* - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - LogManager.getLogManager().reset(); - CallVerificationStack.getInstance().clear(); - System.setErr(err); - super.tearDown(); - } - - /* - * Test the constructor with no parameter, and no relevant log manager - * properties are set. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with no parameter, and no relevant log manager properties are set.", - method = "StreamHandler", - args = {} - ) - public void testConstructor_NoParameter_NoProperties() { - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.level")); - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.filter")); - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.formatter")); - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.encoding")); - - StreamHandler h = new StreamHandler(); - assertSame(Level.INFO, h.getLevel()); - assertTrue(h.getFormatter() instanceof SimpleFormatter); - assertNull(h.getFilter()); - assertNull(h.getEncoding()); - } - - /* - * Test the constructor with insufficient privilege. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with insufficient privilege.", - method = "StreamHandler", - args = {java.io.OutputStream.class, java.util.logging.Formatter.class} - ) - public void testConstructor_NoParameter_InsufficientPrivilege() { - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.level")); - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.filter")); - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.formatter")); - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.encoding")); - - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - // set a normal value - try { - StreamHandler h = new StreamHandler(); - assertSame(Level.INFO, h.getLevel()); - assertTrue(h.getFormatter() instanceof SimpleFormatter); - assertNull(h.getFilter()); - assertNull(h.getEncoding()); - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test the constructor with no parameter, and valid relevant log manager - * properties are set. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with no parameter, and valid relevant log manager properties are set.", - method = "StreamHandler", - args = {} - ) - public void testConstructor_NoParameter_ValidProperties() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.StreamHandler.level", "FINE"); - p.put("java.util.logging.StreamHandler.filter", className - + "$MockFilter"); - p.put("java.util.logging.StreamHandler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.StreamHandler.encoding", "iso-8859-1"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - assertEquals("FINE", LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.level")); - assertEquals("iso-8859-1", LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.encoding")); - StreamHandler h = new StreamHandler(); - assertSame(h.getLevel(), Level.parse("FINE")); - assertTrue(h.getFormatter() instanceof MockFormatter); - assertTrue(h.getFilter() instanceof MockFilter); - assertEquals("iso-8859-1", h.getEncoding()); - } - - /* - * Test the constructor with no parameter, and invalid relevant log manager - * properties are set. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with no parameter, and invalid relevant log manager properties are set.", - method = "StreamHandler", - args = {} - ) - public void testConstructor_NoParameter_InvalidProperties() - throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.StreamHandler.level", INVALID_LEVEL); - p.put("java.util.logging.StreamHandler.filter", className + ""); - p.put("java.util.logging.StreamHandler.formatter", className + ""); - p.put("java.util.logging.StreamHandler.encoding", "XXXX"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - assertEquals(INVALID_LEVEL, LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.level")); - assertEquals("XXXX", LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.encoding")); - StreamHandler h = new StreamHandler(); - assertSame(Level.INFO, h.getLevel()); - assertTrue(h.getFormatter() instanceof SimpleFormatter); - assertNull(h.getFilter()); - assertNull(h.getEncoding()); - h.publish(new LogRecord(Level.SEVERE, "test")); - assertTrue(CallVerificationStack.getInstance().empty()); - assertNull(h.getEncoding()); - } - - /* - * Test the constructor with normal parameter values, and no relevant log - * manager properties are set. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with normal parameter values, and no relevant log manager properties are set.", - method = "StreamHandler", - args = {java.io.OutputStream.class, java.util.logging.Formatter.class} - ) - public void testConstructor_HasParameters_NoProperties() { - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.level")); - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.filter")); - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.formatter")); - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.encoding")); - - StreamHandler h = new StreamHandler(new ByteArrayOutputStream(), - new MockFormatter2()); - assertSame(Level.INFO, h.getLevel()); - assertTrue(h.getFormatter() instanceof MockFormatter2); - assertNull(h.getFilter()); - assertNull(h.getEncoding()); - } - - /* - * Test the constructor with insufficient privilege. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with insufficient privilege.", - method = "StreamHandler", - args = {java.io.OutputStream.class, java.util.logging.Formatter.class} - ) - public void testConstructor_HasParameter_InsufficientPrivilege() { - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.level")); - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.filter")); - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.formatter")); - assertNull(LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.encoding")); - - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - // set a normal value - try { - StreamHandler h = new StreamHandler(new ByteArrayOutputStream(), - new MockFormatter2()); - assertSame(Level.INFO, h.getLevel()); - assertTrue(h.getFormatter() instanceof MockFormatter2); - assertNull(h.getFilter()); - assertNull(h.getEncoding()); - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test the constructor with normal parameter values, and valid relevant log - * manager properties are set. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with normal parameter values, and valid relevant log manager properties are set.", - method = "StreamHandler", - args = {java.io.OutputStream.class, java.util.logging.Formatter.class} - ) - public void testConstructor_HasParameters_ValidProperties() - throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.StreamHandler.level", "FINE"); - p.put("java.util.logging.StreamHandler.filter", className - + "$MockFilter"); - p.put("java.util.logging.StreamHandler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.StreamHandler.encoding", "iso-8859-1"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - assertEquals("FINE", LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.level")); - assertEquals("iso-8859-1", LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.encoding")); - StreamHandler h = new StreamHandler(new ByteArrayOutputStream(), - new MockFormatter2()); - assertSame(h.getLevel(), Level.parse("FINE")); - assertTrue(h.getFormatter() instanceof MockFormatter2); - assertTrue(h.getFilter() instanceof MockFilter); - assertEquals("iso-8859-1", h.getEncoding()); - } - - /* - * Test the constructor with normal parameter, and invalid relevant log - * manager properties are set. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with normal parameter, and invalid relevant log manager properties are set.", - method = "StreamHandler", - args = {java.io.OutputStream.class, java.util.logging.Formatter.class} - ) - public void testConstructor_HasParameters_InvalidProperties() - throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.StreamHandler.level", INVALID_LEVEL); - p.put("java.util.logging.StreamHandler.filter", className + ""); - p.put("java.util.logging.StreamHandler.formatter", className + ""); - p.put("java.util.logging.StreamHandler.encoding", "XXXX"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - assertEquals(INVALID_LEVEL, LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.level")); - assertEquals("XXXX", LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.encoding")); - StreamHandler h = new StreamHandler(new ByteArrayOutputStream(), - new MockFormatter2()); - assertSame(Level.INFO, h.getLevel()); - assertTrue(h.getFormatter() instanceof MockFormatter2); - assertNull(h.getFilter()); - assertNull(h.getEncoding()); - } - - /* - * Test the constructor with null formatter, and invalid relevant log manager - * properties are set. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with null formatter, and invalid relevant log manager properties are set.", - method = "StreamHandler", - args = {java.io.OutputStream.class, java.util.logging.Formatter.class} - ) - public void testConstructor_HasParameters_ValidPropertiesNullStream() - throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.StreamHandler.level", "FINE"); - p.put("java.util.logging.StreamHandler.filter", className - + "$MockFilter"); - p.put("java.util.logging.StreamHandler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.StreamHandler.encoding", "iso-8859-1"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - assertEquals("FINE", LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.level")); - assertEquals("iso-8859-1", LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.encoding")); - try { - new StreamHandler(new ByteArrayOutputStream(), null); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - // expected - } - } - - /* - * Test the constructor with null output stream, and invalid relevant log - * manager properties are set. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies the constructor with null output stream, and invalid relevant log manager properties are set.", - method = "StreamHandler", - args = {java.io.OutputStream.class, java.util.logging.Formatter.class} - ) - public void testConstructor_HasParameters_ValidPropertiesNullFormatter() - throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.StreamHandler.level", "FINE"); - p.put("java.util.logging.StreamHandler.filter", className - + "$MockFilter"); - p.put("java.util.logging.StreamHandler.formatter", className - + "$MockFormatter"); - p.put("java.util.logging.StreamHandler.encoding", "iso-8859-1"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - assertEquals("FINE", LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.level")); - assertEquals("iso-8859-1", LogManager.getLogManager().getProperty( - "java.util.logging.StreamHandler.encoding")); - try { - new StreamHandler(null, new MockFormatter2()); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - // expected - } - } - - /* - * Test close() when having sufficient privilege, and a record has been - * written to the output stream. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies close() when having sufficient privilege, and a record has been written to the output stream.", - method = "close", - args = {} - ) - public void testClose_SufficientPrivilege_NormalClose() { - ByteArrayOutputStream aos = new MockOutputStream(); - StreamHandler h = new StreamHandler(aos, new MockFormatter()); - h.publish(new LogRecord(Level.SEVERE, - "testClose_SufficientPrivilege_NormalClose msg")); - h.close(); - assertEquals("close", CallVerificationStack.getInstance() - .getCurrentSourceMethod()); - assertNull(CallVerificationStack.getInstance().pop()); - assertEquals("flush", CallVerificationStack.getInstance() - .getCurrentSourceMethod()); - CallVerificationStack.getInstance().clear(); - assertTrue(aos.toString().endsWith("MockFormatter_Tail")); - h.close(); - } - - /* - * Test close() when having sufficient privilege, and an output stream that - * always throws exceptions. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies close() when having sufficient privilege, and an output stream that always throws exceptions.", - method = "close", - args = {} - ) - public void testClose_SufficientPrivilege_Exception() { - ByteArrayOutputStream aos = new MockExceptionOutputStream(); - StreamHandler h = new StreamHandler(aos, new MockFormatter()); - h.publish(new LogRecord(Level.SEVERE, - "testClose_SufficientPrivilege_Exception msg")); - h.flush(); - h.close(); - } - - /* - * Test close() when having sufficient privilege, and no record has been - * written to the output stream. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies close() method when having sufficient privilege, and no record has been written to the output stream.", - method = "close", - args = {} - ) - public void testClose_SufficientPrivilege_DirectClose() { - ByteArrayOutputStream aos = new MockOutputStream(); - StreamHandler h = new StreamHandler(aos, new MockFormatter()); - h.close(); - assertEquals("close", CallVerificationStack.getInstance() - .getCurrentSourceMethod()); - assertNull(CallVerificationStack.getInstance().pop()); - assertEquals("flush", CallVerificationStack.getInstance() - .getCurrentSourceMethod()); - CallVerificationStack.getInstance().clear(); - assertEquals("MockFormatter_HeadMockFormatter_Tail", aos.toString()); - } - - /* - * Test close() when having insufficient privilege. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies SecurityException.", - method = "close", - args = {} - ) - public void testClose_InsufficientPrivilege() { - StreamHandler h = new StreamHandler(new ByteArrayOutputStream(), - new MockFormatter()); - - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - try { - h.close(); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - // expected - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * Test close() when having no output stream. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies close() method when having no output stream.", - method = "close", - args = {} - ) - public void testClose_NoOutputStream() { - StreamHandler h = new StreamHandler(); - h.close(); - } - - /* - * Test flush(). - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies flush() method.", - method = "flush", - args = {} - ) - public void testFlush_Normal() { - ByteArrayOutputStream aos = new MockOutputStream(); - StreamHandler h = new StreamHandler(aos, new MockFormatter()); - h.flush(); - assertEquals("flush", CallVerificationStack.getInstance().getCurrentSourceMethod()); - assertNull(CallVerificationStack.getInstance().pop()); - CallVerificationStack.getInstance().clear(); - } - - /* - * Test flush() when having no output stream. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies flush() when having no output stream.", - method = "flush", - args = {} - ) - public void testFlush_NoOutputStream() { - StreamHandler h = new StreamHandler(); - h.flush(); - } - - /* - * Test isLoggable(), use no filter, having no output stream - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies isLoggable(), use no filter, having no output stream.", - method = "isLoggable", - args = {java.util.logging.LogRecord.class} - ) - public void testIsLoggable_NoOutputStream() { - StreamHandler h = new StreamHandler(); - LogRecord r = new LogRecord(Level.INFO, null); - assertFalse(h.isLoggable(r)); - - h.setLevel(Level.WARNING); - assertFalse(h.isLoggable(r)); - - h.setLevel(Level.CONFIG); - assertFalse(h.isLoggable(r)); - - r.setLevel(Level.OFF); - h.setLevel(Level.OFF); - assertFalse(h.isLoggable(r)); - } - - /* - * Test isLoggable(), use no filter, having output stream - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies isLoggable(), use no filter, having output stream.", - method = "isLoggable", - args = {java.util.logging.LogRecord.class} - ) - public void testIsLoggable_NoFilter() { - StreamHandler h = new StreamHandler(new ByteArrayOutputStream(), - new SimpleFormatter()); - LogRecord r = new LogRecord(Level.INFO, null); - assertTrue(h.isLoggable(r)); - - h.setLevel(Level.WARNING); - assertFalse(h.isLoggable(r)); - - h.setLevel(Level.CONFIG); - assertTrue(h.isLoggable(r)); - - r.setLevel(Level.OFF); - h.setLevel(Level.OFF); - assertFalse(h.isLoggable(r)); - } - - /* - * Test isLoggable(), use a filter, having output stream - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies isLoggable(), use a filter, having output stream.", - method = "isLoggable", - args = {java.util.logging.LogRecord.class} - ) - public void testIsLoggable_WithFilter() { - StreamHandler h = new StreamHandler(new ByteArrayOutputStream(), - new SimpleFormatter()); - LogRecord r = new LogRecord(Level.INFO, null); - h.setFilter(new MockFilter()); - assertFalse(h.isLoggable(r)); - assertSame(r, CallVerificationStack.getInstance().pop()); - - h.setLevel(Level.CONFIG); - assertFalse(h.isLoggable(r)); - assertSame(r, CallVerificationStack.getInstance().pop()); - - h.setLevel(Level.WARNING); - assertFalse(h.isLoggable(r)); //level to high, data will not reach the filter - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test isLoggable(), null log record, having output stream. Handler should - * call ErrorManager to handle exceptional case - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies isLoggable(), null log record, having output stream. Handler should call ErrorManager to handle exceptional case.", - method = "isLoggable", - args = {java.util.logging.LogRecord.class} - ) - public void testIsLoggable_Null() { - StreamHandler h = new StreamHandler(new ByteArrayOutputStream(), - new SimpleFormatter()); - assertFalse(h.isLoggable(null)); - } - - /* - * Test isLoggable(), null log record, without output stream - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies isLoggable(), null log record, without output stream.", - method = "isLoggable", - args = {java.util.logging.LogRecord.class} - ) - public void testIsLoggable_Null_NoOutputStream() { - StreamHandler h = new StreamHandler(); - assertFalse(h.isLoggable(null)); - } - - /* - * Test publish(), use no filter, having output stream, normal log record. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish(), use no filter, having output stream, normal log record.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_NoOutputStream() { - StreamHandler h = new StreamHandler(); - LogRecord r = new LogRecord(Level.INFO, "testPublish_NoOutputStream"); - h.publish(r); - - h.setLevel(Level.WARNING); - h.publish(r); - - h.setLevel(Level.CONFIG); - h.publish(r); - - r.setLevel(Level.OFF); - h.setLevel(Level.OFF); - h.publish(r); - } - - /* - * Test publish(), use no filter, having output stream, normal log record. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish(), use no filter, having output stream, normal log record.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_NoFilter() { - ByteArrayOutputStream aos = new ByteArrayOutputStream(); - StreamHandler h = new StreamHandler(aos, new MockFormatter()); - - LogRecord r = new LogRecord(Level.INFO, "testPublish_NoFilter"); - h.setLevel(Level.INFO); - h.publish(r); - h.flush(); - assertEquals("MockFormatter_Head" + "testPublish_NoFilter", aos - .toString()); - - h.setLevel(Level.WARNING); - h.publish(r); - h.flush(); - assertEquals("MockFormatter_Head" + "testPublish_NoFilter", aos - .toString()); - - h.setLevel(Level.CONFIG); - h.publish(r); - h.flush(); - assertEquals("MockFormatter_Head" + "testPublish_NoFilter" - + "testPublish_NoFilter", aos.toString()); - - r.setLevel(Level.OFF); - h.setLevel(Level.OFF); - h.publish(r); - h.flush(); - assertEquals("MockFormatter_Head" + "testPublish_NoFilter" - + "testPublish_NoFilter", aos.toString()); - } - - /* - * Test publish(), use a filter, having output stream, normal log record. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish(), use a filter, having output stream, normal log record.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_WithFilter() { - ByteArrayOutputStream aos = new ByteArrayOutputStream(); - StreamHandler h = new StreamHandler(aos, new MockFormatter()); - h.setFilter(new MockFilter()); - - LogRecord r = new LogRecord(Level.INFO, "testPublish_WithFilter"); - h.setLevel(Level.INFO); - h.publish(r); - h.flush(); - assertEquals("", aos.toString()); - assertSame(r, CallVerificationStack.getInstance().pop()); - - h.setLevel(Level.WARNING); - h.publish(r); - h.flush(); - assertEquals("", aos.toString()); - assertTrue(CallVerificationStack.getInstance().empty()); - - h.setLevel(Level.CONFIG); - h.publish(r); - h.flush(); - assertEquals("", aos.toString()); - assertSame(r, CallVerificationStack.getInstance().pop()); - - r.setLevel(Level.OFF); - h.setLevel(Level.OFF); - h.publish(r); - h.flush(); - assertEquals("", aos.toString()); - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test publish(), null log record, handler should call ErrorManager to - * handle exceptional case - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish(), null log record, handler should call ErrorManager to handle exceptional case.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_Null() { - StreamHandler h = new StreamHandler(new ByteArrayOutputStream(), - new SimpleFormatter()); - h.publish(null); - } - - /* - * Test publish(), null log record, without output stream - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish(), null log record, without output stream.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_Null_NoOutputStream() { - StreamHandler h = new StreamHandler(); - h.publish(null); - // regression test for Harmony-1279 - MockFilter filter = new MockFilter(); - h.setLevel(Level.FINER); - h.setFilter(filter); - LogRecord record = new LogRecord(Level.FINE, "abc"); - h.publish(record); - // verify that filter.isLoggable is not called, because there's no - // associated output stream. - assertTrue(CallVerificationStack.getInstance().empty()); - } - - /* - * Test publish(), a log record with empty msg, having output stream - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish(), a log record with empty msg, having output stream.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_EmptyMsg() { - ByteArrayOutputStream aos = new ByteArrayOutputStream(); - StreamHandler h = new StreamHandler(aos, new MockFormatter()); - LogRecord r = new LogRecord(Level.INFO, ""); - h.publish(r); - h.flush(); - assertEquals("MockFormatter_Head", aos.toString()); - } - - /* - * Test publish(), a log record with null msg, having output stream - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish(), a log record with null msg, having output stream.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_NullMsg() { - ByteArrayOutputStream aos = new ByteArrayOutputStream(); - StreamHandler h = new StreamHandler(aos, new MockFormatter()); - LogRecord r = new LogRecord(Level.INFO, null); - h.publish(r); - h.flush(); - assertEquals("MockFormatter_Head", aos.toString()); - } - - /* - * Test publish(), after close. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies publish(), after close.", - method = "publish", - args = {java.util.logging.LogRecord.class} - ) - public void testPublish_AfterClose() throws Exception { - Properties p = new Properties(); - p.put("java.util.logging.StreamHandler.level", "FINE"); - LogManager.getLogManager().readConfiguration( - EnvironmentHelper.PropertiesToInputStream(p)); - - ByteArrayOutputStream aos = new ByteArrayOutputStream(); - StreamHandler h = new StreamHandler(aos, new MockFormatter()); - assertSame(h.getLevel(), Level.FINE); - LogRecord r = new LogRecord(Level.INFO, "testPublish_NoFormatter"); - assertTrue(h.isLoggable(r)); - h.close(); - assertFalse(h.isLoggable(r)); - h.publish(r); - h.flush(); - assertEquals("MockFormatter_HeadMockFormatter_Tail", aos.toString()); - } - - /* - * Test setEncoding() method with supported encoding. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies setEncoding() method with supported encoding.", - method = "setEncoding", - args = {java.lang.String.class} - ) - public void testSetEncoding_Normal() throws Exception { - ByteArrayOutputStream aos = new ByteArrayOutputStream(); - StreamHandler h = new StreamHandler(aos, new MockFormatter()); - h.setEncoding("iso-8859-1"); - assertEquals("iso-8859-1", h.getEncoding()); - LogRecord r = new LogRecord(Level.INFO, "\u6881\u884D\u8F69"); - h.publish(r); - h.flush(); - - byte[] bytes = encoder.encode( - CharBuffer.wrap("MockFormatter_Head" + "\u6881\u884D\u8F69")) - .array(); - assertTrue(Arrays.equals(bytes, aos.toByteArray())); - } - - /* - * Test setEncoding() method with supported encoding, after a log record - * has been written. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies setEncoding() method with supported encoding, after a log record has been written.", - method = "setEncoding", - args = {java.lang.String.class} - ) - public void testSetEncoding_AfterPublish() throws Exception { - ByteArrayOutputStream aos = new ByteArrayOutputStream(); - StreamHandler h = new StreamHandler(aos, new MockFormatter()); - h.setEncoding("iso-8859-1"); - assertEquals("iso-8859-1", h.getEncoding()); - LogRecord r = new LogRecord(Level.INFO, "\u6881\u884D\u8F69"); - h.publish(r); - h.flush(); - assertTrue(Arrays.equals(aos.toByteArray(), encoder.encode( - CharBuffer.wrap("MockFormatter_Head" + "\u6881\u884D\u8F69")) - .array())); - - h.setEncoding("iso8859-1"); - assertEquals("iso8859-1", h.getEncoding()); - r = new LogRecord(Level.INFO, "\u6881\u884D\u8F69"); - h.publish(r); - h.flush(); - assertFalse(Arrays.equals(aos.toByteArray(), encoder.encode( - CharBuffer.wrap("MockFormatter_Head" + "\u6881\u884D\u8F69" - + "testSetEncoding_Normal2")).array())); - byte[] b0 = aos.toByteArray(); - byte[] b1 = encoder.encode( - CharBuffer.wrap("MockFormatter_Head" + "\u6881\u884D\u8F69")) - .array(); - byte[] b2 = encoder.encode(CharBuffer.wrap("\u6881\u884D\u8F69")) - .array(); - byte[] b3 = new byte[b1.length + b2.length]; - System.arraycopy(b1, 0, b3, 0, b1.length); - System.arraycopy(b2, 0, b3, b1.length, b2.length); - assertTrue(Arrays.equals(b0, b3)); - } - - /* - * Test setEncoding() methods with null. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies setEncoding() methods with null.", - method = "setEncoding", - args = {java.lang.String.class} - ) - public void testSetEncoding_Null() throws Exception { - StreamHandler h = new StreamHandler(); - h.setEncoding(null); - assertNull(h.getEncoding()); - } - - /* - * Test setEncoding() methods with unsupported encoding. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies setEncoding() methods with unsupported encoding.", - method = "setEncoding", - args = {java.lang.String.class} - ) - public void testSetEncoding_Unsupported() { - StreamHandler h = new StreamHandler(); - try { - h.setEncoding("impossible"); - fail("Should throw UnsupportedEncodingException!"); - } catch (UnsupportedEncodingException e) { - // expected - } - assertNull(h.getEncoding()); - } - - /* - * Test setEncoding() with insufficient privilege. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies setEncoding() method with insufficient privilege.", - method = "setEncoding", - args = {java.lang.String.class} - ) - public void testSetEncoding_InsufficientPrivilege() throws Exception { - StreamHandler h = new StreamHandler(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - // set a normal value - try { - h.setEncoding("iso-8859-1"); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - // expected - } finally { - System.setSecurityManager(oldMan); - } - assertNull(h.getEncoding()); - System.setSecurityManager(new MockSecurityManager()); - // set an invalid value - try { - - h.setEncoding("impossible"); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - // expected - } finally { - System.setSecurityManager(oldMan); - } - assertNull(h.getEncoding()); - } - - /* - * Test setEncoding() methods will flush a stream before setting. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies that setEncoding() method will flush a stream before setting.", - method = "setEncoding", - args = {java.lang.String.class} - ) - public void testSetEncoding_FlushBeforeSetting() throws Exception { - ByteArrayOutputStream aos = new ByteArrayOutputStream(); - StreamHandler h = new StreamHandler(aos, new MockFormatter()); - LogRecord r = new LogRecord(Level.INFO, "abcd"); - h.publish(r); - assertFalse(aos.toString().indexOf("abcd") > 0); - h.setEncoding("iso-8859-1"); - assertTrue(aos.toString().indexOf("abcd") > 0); - } - - /* - * Test setOutputStream() with null. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies setOutputStream() method with null.", - method = "setOutputStream", - args = {java.io.OutputStream.class} - ) - public void testSetOutputStream_null() { - MockStreamHandler h = new MockStreamHandler( - new ByteArrayOutputStream(), new SimpleFormatter()); - try { - h.setOutputStream(null); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - // expected - } - } - - /* - * Test setOutputStream() under normal condition. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies setOutputStream() method under normal condition.", - method = "setOutputStream", - args = {java.io.OutputStream.class} - ) - public void testSetOutputStream_Normal() { - ByteArrayOutputStream aos = new ByteArrayOutputStream(); - MockStreamHandler h = new MockStreamHandler(aos, new MockFormatter()); - - LogRecord r = new LogRecord(Level.INFO, "testSetOutputStream_Normal"); - h.publish(r); - assertSame(r, CallVerificationStack.getInstance().pop()); - assertTrue(CallVerificationStack.getInstance().empty()); - h.flush(); - assertEquals("MockFormatter_Head" + "testSetOutputStream_Normal", aos - .toString()); - - ByteArrayOutputStream aos2 = new ByteArrayOutputStream(); - h.setOutputStream(aos2); - assertEquals("MockFormatter_Head" + "testSetOutputStream_Normal" - + "MockFormatter_Tail", aos.toString()); - r = new LogRecord(Level.INFO, "testSetOutputStream_Normal2"); - h.publish(r); - assertSame(r, CallVerificationStack.getInstance().pop()); - assertTrue(CallVerificationStack.getInstance().empty()); - h.flush(); - assertEquals("MockFormatter_Head" + "testSetOutputStream_Normal2", aos2 - .toString()); - assertEquals("MockFormatter_Head" + "testSetOutputStream_Normal" - + "MockFormatter_Tail", aos.toString()); - } - - /* - * Test setOutputStream() after close. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies setOutputStream() method after close.", - method = "setOutputStream", - args = {java.io.OutputStream.class} - ) - public void testSetOutputStream_AfterClose() { - ByteArrayOutputStream aos = new ByteArrayOutputStream(); - MockStreamHandler h = new MockStreamHandler(aos, new MockFormatter()); - - LogRecord r = new LogRecord(Level.INFO, "testSetOutputStream_Normal"); - h.publish(r); - assertSame(r, CallVerificationStack.getInstance().pop()); - assertTrue(CallVerificationStack.getInstance().empty()); - h.flush(); - assertEquals("MockFormatter_Head" + "testSetOutputStream_Normal", aos - .toString()); - h.close(); - - ByteArrayOutputStream aos2 = new ByteArrayOutputStream(); - h.setOutputStream(aos2); - assertEquals("MockFormatter_Head" + "testSetOutputStream_Normal" - + "MockFormatter_Tail", aos.toString()); - r = new LogRecord(Level.INFO, "testSetOutputStream_Normal2"); - h.publish(r); - assertSame(r, CallVerificationStack.getInstance().pop()); - assertTrue(CallVerificationStack.getInstance().empty()); - h.flush(); - assertEquals("MockFormatter_Head" + "testSetOutputStream_Normal2", aos2 - .toString()); - assertEquals("MockFormatter_Head" + "testSetOutputStream_Normal" - + "MockFormatter_Tail", aos.toString()); - } - - /* - * Test setOutputStream() when having insufficient privilege. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Verifies setOutputStream() method when having insufficient privilege.", - method = "setOutputStream", - args = {java.io.OutputStream.class} - ) - public void testSetOutputStream_InsufficientPrivilege() { - MockStreamHandler h = new MockStreamHandler(); - SecurityManager oldMan = System.getSecurityManager(); - System.setSecurityManager(new MockSecurityManager()); - - try { - h.setOutputStream(new ByteArrayOutputStream()); - fail("Should throw SecurityException!"); - } catch (SecurityException e) { - // expected - } finally { - System.setSecurityManager(oldMan); - } - - h = new MockStreamHandler(); - System.setSecurityManager(new MockSecurityManager()); - try { - h.setOutputStream(null); - fail("Should throw NullPointerException!"); - } catch (NullPointerException e) { - // expected - } finally { - System.setSecurityManager(oldMan); - } - } - - /* - * A mock stream handler, expose setOutputStream. - */ - public static class MockStreamHandler extends StreamHandler { - public MockStreamHandler() { - super(); - } - - public MockStreamHandler(OutputStream out, Formatter formatter) { - super(out, formatter); - } - - public void setOutputStream(OutputStream out) { - super.setOutputStream(out); - } - - public boolean isLoggable(LogRecord r) { - CallVerificationStack.getInstance().push(r); - return super.isLoggable(r); - } - } - - /* - * A mock filter, always return false. - */ - public static class MockFilter implements Filter { - - public boolean isLoggable(LogRecord record) { - CallVerificationStack.getInstance().push(record); - return false; - } - } - - /* - * A mock formatter. - */ - public static class MockFormatter extends java.util.logging.Formatter { - public String format(LogRecord r) { - // System.out.println("formatter called..."); - return super.formatMessage(r); - } - - /* - * (non-Javadoc) - * - * @see java.util.logging.Formatter#getHead(java.util.logging.Handler) - */ - public String getHead(Handler h) { - return "MockFormatter_Head"; - } - - /* - * (non-Javadoc) - * - * @see java.util.logging.Formatter#getTail(java.util.logging.Handler) - */ - public String getTail(Handler h) { - return "MockFormatter_Tail"; - } - } - - /* - * Another mock formatter. - */ - public static class MockFormatter2 extends java.util.logging.Formatter { - public String format(LogRecord r) { - // System.out.println("formatter2 called..."); - return r.getMessage(); - } - } - - /* - * A mock output stream. - */ - public static class MockOutputStream extends ByteArrayOutputStream { - - /* - * (non-Javadoc) - * - * @see java.io.OutputStream#close() - */ - public void close() throws IOException { - CallVerificationStack.getInstance().push(null); - super.close(); - } - - /* - * (non-Javadoc) - * - * @see java.io.OutputStream#flush() - */ - public void flush() throws IOException { - CallVerificationStack.getInstance().push(null); - super.flush(); - } - - /* - * (non-Javadoc) - * - * @see java.io.OutputStream#write(int) - */ - public void write(int oneByte) { - super.write(oneByte); - } - } - - /* - * A mock output stream that always throw exception. - */ - public static class MockExceptionOutputStream extends ByteArrayOutputStream { - - /* - * (non-Javadoc) - * - * @see java.io.OutputStream#close() - */ - public void close() throws IOException { - throw new IOException(); - } - - /* - * (non-Javadoc) - * - * @see java.io.OutputStream#flush() - */ - public void flush() throws IOException { - throw new IOException(); - } - - /* - * (non-Javadoc) - * - * @see java.io.OutputStream#write(byte[], int, int) - */ - public synchronized void write(byte[] buffer, int offset, int count) { - throw new NullPointerException(); - } - - /* - * (non-Javadoc) - * - * @see java.io.OutputStream#write(int) - */ - public synchronized void write(int oneByte) { - throw new NullPointerException(); - } - } - - /* - * Used to grant all permissions except logging control. - */ - public static class MockSecurityManager extends SecurityManager { - - public MockSecurityManager() { - } - - public void checkPermission(Permission perm) { - // grant all permissions except logging control - if (perm instanceof LoggingPermission) { - throw new SecurityException(); - } - } - - public void checkPermission(Permission perm, Object context) { - // grant all permissions except logging control - if (perm instanceof LoggingPermission) { - throw new SecurityException(); - } - } - } - -} diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/XMLFormatterTest.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/XMLFormatterTest.java deleted file mode 100644 index 90c93c98c..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/XMLFormatterTest.java +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.logging.tests.java.util.logging; - -import dalvik.annotation.AndroidOnly; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import junit.framework.TestCase; - -import java.io.UnsupportedEncodingException; -import java.util.ResourceBundle; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogRecord; -import java.util.logging.XMLFormatter; - -@TestTargetClass(XMLFormatter.class) -public class XMLFormatterTest extends TestCase { - - XMLFormatter formatter = null; - - MockHandler handler = null; - - LogRecord lr = null; - - protected void setUp() throws Exception { - super.setUp(); - formatter = new XMLFormatter(); - handler = new MockHandler(); - lr = new LogRecord(Level.SEVERE, "pattern"); - } - - /* - * test for constructor public XMLFormatter() - * - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "XMLFormatter", - args = {} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getHead", - args = {java.util.logging.Handler.class} - ), - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getTail", - args = {java.util.logging.Handler.class} - ) - }) - public void testXMLFormatter() throws SecurityException, - UnsupportedEncodingException { - - handler.setEncoding("UTF-8"); - - String result = formatter.getHead(handler); - int headPos = result - .indexOf(""); - int dtdPos = result.indexOf(""); - int rootPos = result.indexOf(""); - assertTrue("head string position should be more or equal zero", - headPos >= 0); - assertTrue("dtd string position should be more head string position", - dtdPos > headPos); - assertTrue("root string position should be more dtd string position", - rootPos > dtdPos); - - assertTrue("Tail string position should be more zero", formatter - .getTail(handler).indexOf("/log>") > 0); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "format", - args = {java.util.logging.LogRecord.class} - ) - public void testLocalFormat() { - // if set resource bundle, output will use localized message, - // but put the original message into the key element - // further more, if message pattern has no effect - ResourceBundle rb = ResourceBundle - .getBundle("bundles/java/util/logging/res"); - lr.setResourceBundle(rb); - lr.setMessage("pattern"); - String result = formatter.format(lr); - assertTrue(result.indexOf("" + rb.getString("pattern") - + "") > 0); - assertTrue(result.indexOf("pattern") > 0); - - lr.setMessage("msg"); - result = formatter.format(lr); - assertTrue(result.indexOf("" + rb.getString("msg") - + "") > 0); - assertTrue(result.indexOf("msg") > 0); - - lr.setMessage("pattern {0, number}"); - result = formatter.format(lr); - assertTrue(result.indexOf("pattern {0, number}") > 0); - assertTrue(result.indexOf("") < 0); - - // if message has no relevant localized message, use the original - lr.setMessage("bad key"); - result = formatter.format(lr); - assertTrue(result.indexOf("bad key") > 0); - assertTrue(result.indexOf("") < 0); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "format", - args = {java.util.logging.LogRecord.class} - ) - public void testFullFormat() { - lr.setSourceClassName("source class"); - lr.setSourceMethodName("source method"); - lr.setLoggerName("logger name"); - lr.setMillis(0); - lr.setThrown(new Throwable("message")); - lr.setParameters(new Object[] { "100", "200" }); - lr.setSequenceNumber(1); - ResourceBundle rb = ResourceBundle - .getBundle("bundles/java/util/logging/res"); - lr.setResourceBundle(rb); - lr.setResourceBundleName("rbname"); - String output = formatter.format(lr); - // System.out.println(output); - assertTrue(output.indexOf("") >= 0); - assertTrue(output.indexOf("") >= 0); - assertTrue(output.indexOf("0") >= 0); - assertTrue(output.indexOf("") >= 0); - assertTrue(output.indexOf("SEVERE") >= 0); - assertTrue(output.indexOf("") >= 0); - assertTrue(output.indexOf("" + rb.getString("pattern") - + "") >= 0); - assertTrue(output.indexOf("logger name") > 0); - assertTrue(output.indexOf("source class") > 0); - assertTrue(output.indexOf("source method") > 0); - assertTrue(output.indexOf("rbname") > 0); - assertTrue(output.indexOf("100") > 0); - assertTrue(output.indexOf("200") > 0); - assertTrue(output.indexOf("") > 0); - assertTrue(output.indexOf("pattern") > 0); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "format", - args = {java.util.logging.LogRecord.class} - ) - public void testFormat() { - String output = formatter.format(lr); - // System.out.println(output); - assertTrue(output.indexOf("") >= 0); - assertTrue(output.indexOf("") >= 0); - assertTrue(output.indexOf("") >= 0); - assertTrue(output.indexOf("") >= 0); - assertTrue(output.indexOf("SEVERE") >= 0); - assertTrue(output.indexOf("") >= 0); - assertTrue(output.indexOf("pattern") >= 0); - assertTrue(output.indexOf("") < 0); - assertTrue(output.indexOf("") < 0); - assertTrue(output.indexOf("") < 0); - assertTrue(output.indexOf("") < 0); - assertTrue(output.indexOf("") < 0); - assertTrue(output.indexOf("") < 0); - assertTrue(output.indexOf("") < 0); - } - - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getHead", - args = {java.util.logging.Handler.class} - ) - public void testGetHead() throws SecurityException, - UnsupportedEncodingException { - String result = formatter.getHead(handler); - assertNull(handler.getEncoding()); - // TODO: where do we get the default encoding from? - // assertTrue(result.indexOf(defaultEncoding)>0); - - handler.setEncoding("ISO-8859-1"); - String head = ""; - String dtd = ""; - String rootELement = ""; - result = formatter.getHead(handler); - int headPos = result.indexOf(head); - int dtdPos = result.indexOf(dtd); - int rootPos = result.indexOf(rootELement); - assertTrue(headPos >= 0); - assertTrue(dtdPos > headPos); - assertTrue(rootPos > dtdPos); - - handler.setEncoding(null); - result = formatter.getHead(handler); - assertNull(handler.getEncoding()); - - // make sure no NPE is thrown - formatter.getHead(null); - - } - - /* - * test for method public String getTail(Handler h) - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "getTail", - args = {java.util.logging.Handler.class} - ) - public void testGetTail() { - assertEquals( - "Tail string with null handler should be equal expected value", - "", formatter.getTail(null).trim()); - assertEquals("Tail string should be equal expected value", "", - formatter.getTail(handler).trim()); - handler.publish(lr); - assertEquals( - "Tail string after publish() should be equal expected value", - "", formatter.getTail(handler).trim()); - } - - @TestTargets({ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "format", - args = {java.util.logging.LogRecord.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getTail", - args = {java.util.logging.Handler.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "XMLFormatter", - args = {} - ) - }) - @AndroidOnly("This test fails on RI. Output doesn't contain " + - ".") - public void testInvalidParameter() { - formatter.getTail(null); - try { - formatter.format(null); - fail(); - } catch (NullPointerException e) { - } - - formatter = new XMLFormatter(); - lr = new LogRecord(Level.SEVERE, null); - String output = formatter.format(lr); - assertTrue(output.indexOf("") != -1); - } - - public static class MockHandler extends Handler { - public void close() { - } - - public void flush() { - } - - public void publish(LogRecord record) { - } - - } -} diff --git a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/util/EnvironmentHelper.java b/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/util/EnvironmentHelper.java deleted file mode 100644 index 0dafe68a3..000000000 --- a/libcore/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/util/EnvironmentHelper.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.logging.tests.java.util.logging.util; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.util.Properties; - -/** - * Helper to prepare testing environment, for example, configuration files. - */ -public class EnvironmentHelper { - - /** - * Can't be instantiated. - */ - private EnvironmentHelper() { - } - - public static InputStream PropertiesToInputStream(Properties p) { - ByteArrayOutputStream bos = null; - try { - bos = new ByteArrayOutputStream(); - p.store(bos, ""); - return new ByteArrayInputStream(bos.toByteArray()); - } catch (Exception e) { - e.printStackTrace(); - return null; - } finally { - try { - bos.close(); - } catch (Exception ex) { - } - } - } - -} diff --git a/libcore/logging/src/test/java/tests/logging/AllTests.java b/libcore/logging/src/test/java/tests/logging/AllTests.java deleted file mode 100644 index c6032df9d..000000000 --- a/libcore/logging/src/test/java/tests/logging/AllTests.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package tests.logging; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Test suite that includes all tests for the Logging project. - */ -public class AllTests { - - public static void main(String[] args) { - junit.textui.TestRunner.run(AllTests.suite()); - } - - public static Test suite() { - TestSuite suite = tests.TestSuiteFactory.createTestSuite("All Logging test suites"); - // $JUnit-BEGIN$ - suite.addTest(org.apache.harmony.logging.tests.java.util.logging.AllTests.suite()); - // $JUnit-END$ - return suite; - } -} \ No newline at end of file diff --git a/libcore/logging/src/test/resources/bundles/java/util/logging/res.properties b/libcore/logging/src/test/resources/bundles/java/util/logging/res.properties deleted file mode 100644 index db455b096..000000000 --- a/libcore/logging/src/test/resources/bundles/java/util/logging/res.properties +++ /dev/null @@ -1,12 +0,0 @@ -level1=en_US_level1 -SEVERE=US_SEVERE -WARNING=US_WARNING -CONFIG=US_CONFIG -FINE=US_FINE -FINER=US_FINER -FINEST=US_FINEST -ALL=US_ALL -OFF=US_OFF -msg=US_MSG -pattern=US_pattern {0, number} -pattern{0,number}=US \ No newline at end of file diff --git a/libcore/logging/src/test/resources/bundles/java/util/logging/res2.properties b/libcore/logging/src/test/resources/bundles/java/util/logging/res2.properties deleted file mode 100644 index 66f02ebf8..000000000 --- a/libcore/logging/src/test/resources/bundles/java/util/logging/res2.properties +++ /dev/null @@ -1,13 +0,0 @@ -level1=level1 -SEVERE=SEVERE2 -WARNING=WARNING2 -CONFIG=CONFIG2 -FINE=FINE2 -FINER=FINER2 -FINEST=FINEST2 -ALL=ALL2 -OFF=OFF2 -msg=MSG2 -pattern=pattern {0, number}2 -pattern{0,number}=NOLOCALE2 -LOGGERTEST=Test_NoLocale2 \ No newline at end of file diff --git a/libcore/logging/src/test/resources/bundles/java/util/logging/res3.properties b/libcore/logging/src/test/resources/bundles/java/util/logging/res3.properties deleted file mode 100644 index f7b4b29f7..000000000 --- a/libcore/logging/src/test/resources/bundles/java/util/logging/res3.properties +++ /dev/null @@ -1,13 +0,0 @@ -level1=level13 -SEVERE=SEVERE3 -WARNING=WARNING3 -CONFIG=CONFIG3 -FINE=FINE3 -FINER=FINER3 -FINEST=FINEST3 -ALL=ALL3 -OFF=OFF3 -msg=MSG3 -pattern=pattern {0, number}3 -pattern{0,number}=NOLOCALE3 -LOGGERTEST=Test_NoLocale3 \ No newline at end of file diff --git a/libcore/logging/src/test/resources/bundles/java/util/logging/res_en_US.properties b/libcore/logging/src/test/resources/bundles/java/util/logging/res_en_US.properties deleted file mode 100644 index db455b096..000000000 --- a/libcore/logging/src/test/resources/bundles/java/util/logging/res_en_US.properties +++ /dev/null @@ -1,12 +0,0 @@ -level1=en_US_level1 -SEVERE=US_SEVERE -WARNING=US_WARNING -CONFIG=US_CONFIG -FINE=US_FINE -FINER=US_FINER -FINEST=US_FINEST -ALL=US_ALL -OFF=US_OFF -msg=US_MSG -pattern=US_pattern {0, number} -pattern{0,number}=US \ No newline at end of file diff --git a/libcore/logging/src/test/resources/bundles/java/util/logging/res_zh_CN.properties b/libcore/logging/src/test/resources/bundles/java/util/logging/res_zh_CN.properties deleted file mode 100644 index e96803d44..000000000 --- a/libcore/logging/src/test/resources/bundles/java/util/logging/res_zh_CN.properties +++ /dev/null @@ -1,13 +0,0 @@ -level1=zh_CN_level1 -SEVERE=zh_CN_SEVERE -WARNING=zh_CN_WARNING -CONFIG=ZH_CN_CONFIG -FINE=ZH_CN_FINE -FINER=ZH_CN_FINER -FINEST=ZH_CN_FINEST -ALL=ZH_CN_ALL -OFF=ZH_CN_OFF -msg=ZH_CN_MSG -pattern=ZH_CN_pattern {0, number} -pattern{0,number}=ZH_CN -LOGGERTEST=Test_ZH_CN \ No newline at end of file diff --git a/libcore/logging/src/test/resources/config/java/util/logging/logging.config b/libcore/logging/src/test/resources/config/java/util/logging/logging.config deleted file mode 100644 index 6e7394b3e..000000000 --- a/libcore/logging/src/test/resources/config/java/util/logging/logging.config +++ /dev/null @@ -1,3 +0,0 @@ -handlers=org.apache.harmony.logging.tests.java.util.logging.LogManagerTest$MockHandler , java.util.logging.ConsoleHandler -.level=ALL -org.apache.harmony.logging.tests.java.util.logging.LogManagerTest$MockHandler.level=OFF \ No newline at end of file diff --git a/libcore/logging/src/test/resources/config/java/util/logging/logging.properties b/libcore/logging/src/test/resources/config/java/util/logging/logging.properties deleted file mode 100644 index f4c5146b5..000000000 --- a/libcore/logging/src/test/resources/config/java/util/logging/logging.properties +++ /dev/null @@ -1,3 +0,0 @@ -handlers=org.apache.harmony.logging.tests.java.util.logging.LogManagerTest$MockHandler java.util.logging.ConsoleHandler -.level=ALL -org.apache.harmony.logging.tests.java.util.logging.LogManagerTest$MockHandler.level=OFF \ No newline at end of file diff --git a/libcore/logging/src/test/resources/serialization/org/apache/harmony/logging/tests/java/util/logging/LevelTest.golden.ser b/libcore/logging/src/test/resources/serialization/org/apache/harmony/logging/tests/java/util/logging/LevelTest.golden.ser deleted file mode 100644 index 721a3680ed6292c5009b926a313236ae4d27cc89..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 377 zcmZ4UmVvdnh`}wtC|xhHATc>3RWBp4C^tW^QZFYzJv}ooU9TjyxTIJwE3qt5ue2mH z2QKcDT9%paBP}B9n zrt5=D*9Vyn7YCaMGTpkOh(R1AkHz-BjzZzUVzWt149uPktYwKgrKvs)EP08!sU-|T zJ|Io{If;4c`oSednR)5fJ`6%dsm1xFMaij7rFkhiseZUrRunKWFjSW?FdG^fmoTs; XfmIh5G1yQNPLRN1U}R!os3-sc2UdOb diff --git a/libcore/logging/src/test/resources/serialization/org/apache/harmony/logging/tests/java/util/logging/LogRecordTest.golden.ser b/libcore/logging/src/test/resources/serialization/org/apache/harmony/logging/tests/java/util/logging/LogRecordTest.golden.ser deleted file mode 100644 index 955c6fb1cfb0421c75a72544b4843737d4458cec..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2139 zcmZ4UmVvdnh(S6lu`E%qv?Mb}FDE}eJu@#|&nG`UC^b31D8;Kc()M#^;523iE-wbQ z+{~Pu%wjJFzT(uv($u`Pq|_o$29A=9qSV9`PZu8s)|}L`)SMCqNgt50`XFQV zp~mX_fTXN_7`Q+JsYQN?xv3=#LJ);HiFxVz!6ikRdFj?Z4D7k7#l?x~xTJ-OQj7CT zi;`2FO7l{3Qt=qX4^iiwlUQ7gN0|UbnQv-IMt%w&b!;UWMfv4FfcH%N1qi1(N^~|HZm~qEGRBw5C;VYS{Q=@qpzb-II!4k5)%WnCj)C)VoqtQ z4+Bdc?tmfI=M@DF3=9k<49t!`J|zrF#ie>FKaoVa_d1FJTZ0 z!V=E>!Qh}r3Q_@x2qN@~ix`B#J_g0Ao@+&NYC%b6e%^(@@^(_zGDnyg7%EUyz(err zF;jKR@*Ss{8JK+-Sd$Y=i&JrhwGRVtN@_`BW{xkOq!P`*Ra}yooE=h>n4DU|AQz1k zZNYE}*PPVc)Vvbwih@FhItIxS1_8K}p@x?h!Sw2Zy@aWk$xX|~=C6_^$Zw!jzz5G+ z*fk__9-XCTcDI#@fyI-7DUL`C^=#``vmlW%PBNCL4;o|V(Atbf91mr$gaRK6k z)t4~HfiwrF7G);pWL71DV&6GGw;-`3GbuACv!t>Z6wkrWgtS}&9^NMiFraA{^qY6$}$C=9@CSP-B`!)X!?K(?JxvxLD0 zDb<(c=jRmbCFYgrl_VBtr=+G8>*a%stHc~Vh$Fp1^D;|7ZVD>R%S$aPVGuzRfjSe} z7N!NXvV|=tu{19^0~QZVO0=?wB{wlMucDld5mcEml`wFFva~`mxQ;G?HXFd14qjSX NDWq2D<`$<{002@G;<^9; diff --git a/libcore/logging/src/test/resources/serialization/org/apache/harmony/logging/tests/java/util/logging/LoggingPermissionTest.golden.ser b/libcore/logging/src/test/resources/serialization/org/apache/harmony/logging/tests/java/util/logging/LoggingPermissionTest.golden.ser deleted file mode 100644 index f4cdced36bbcbd3ca88507956c039989824269c7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 177 zcmZ4UmVvdnh(S3ku`E%qv?Mb}FDE}eJu@#|&j&&Wq!#6778hsc=P^9IoHxO>cpei2 zLq!pTELcZzYI12&W=W- diff --git a/libcore/luni-kernel/MODULE_LICENSE_APACHE2 b/libcore/luni-kernel/MODULE_LICENSE_APACHE2 deleted file mode 100644 index e69de29bb..000000000 diff --git a/libcore/luni-kernel/src/main/java/java/lang/Class.java b/libcore/luni-kernel/src/main/java/java/lang/Class.java deleted file mode 100644 index b8e39032a..000000000 --- a/libcore/luni-kernel/src/main/java/java/lang/Class.java +++ /dev/null @@ -1,1634 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Copyright (C) 2006-2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.lang; - -import dalvik.system.VMStack; - -import org.apache.harmony.kernel.vm.StringUtils; -import org.apache.harmony.luni.lang.reflect.GenericSignatureParser; -import org.apache.harmony.luni.lang.reflect.Types; - -import java.io.InputStream; -import java.io.Serializable; -import java.lang.annotation.Annotation; -import java.lang.annotation.Inherited; -import java.lang.ref.SoftReference; -import java.lang.reflect.AccessibleObject; -import java.lang.reflect.AnnotatedElement; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.GenericDeclaration; -import java.lang.reflect.Member; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; -import java.util.Collection; -import java.util.HashMap; -import java.net.URL; -import java.security.ProtectionDomain; - -import static java.lang.ClassCache.REFLECT; -import static java.lang.ClassCache.compareClassLists; -import static java.lang.ClassCache.findMethodByName; -import static java.lang.ClassCache.findFieldByName; - -/** - * The in-memory representation of a Java class. This representation serves as - * the starting point for querying class-related information, a process usually - * called "reflection". There are basically three types of {@code Class} - * instances: those representing real classes and interfaces, those representing - * primitive types, and those representing array classes. - * - *

Class instances representing object types (classes or interfaces)

- *

- * These represent an ordinary class or interface as found in the class - * hierarchy. The name associated with these {@code Class} instances is simply - * the fully qualified class name of the class or interface that it represents. - * In addition to this human-readable name, each class is also associated by a - * so-called signature, which is the letter "L", followed by the - * class name and a semicolon (";"). The signature is what the runtime system - * uses internally for identifying the class (for example in a DEX file). - *

- *

Classes representing primitive types

- *

- * These represent the standard Java primitive types and hence share their - * names (for example "int" for the {@code int} primitive type). Although it is - * not possible to create new instances based on these {@code Class} instances, - * they are still useful for providing reflection information, and as the - * component type of array classes. There is one {@code Class} instance for each - * primitive type, and their signatures are: - *

- *
    - *
  • {@code B} representing the {@code byte} primitive type
  • - *
  • {@code S} representing the {@code short} primitive type
  • - *
  • {@code I} representing the {@code int} primitive type
  • - *
  • {@code J} representing the {@code long} primitive type
  • - *
  • {@code F} representing the {@code float} primitive type
  • - *
  • {@code D} representing the {@code double} primitive type
  • - *
  • {@code C} representing the {@code char} primitive type
  • - *
  • {@code Z} representing the {@code boolean} primitive type
  • - *
  • {@code V} representing void function return values
  • - *
- *

- *

Classes representing array classes

- *

- * These represent the classes of Java arrays. There is one such {@code Class} - * instance per combination of array leaf component type and arity (number of - * dimensions). In this case, the name associated with the {@code Class} - * consists of one or more left square brackets (one per dimension in the array) - * followed by the signature of the class representing the leaf component type, - * which can be either an object type or a primitive type. The signature of a - * {@code Class} representing an array type is the same as its name. Examples - * of array class signatures are: - *

- *
    - *
  • {@code [I} representing the {@code int[]} type
  • - *
  • {@code [Ljava/lang/String;} representing the {@code String[]} type
  • - *
  • {@code [[[C} representing the {@code char[][][]} type (three dimensions!)
  • - *
- * - * @since Android 1.0 - */ -public final class Class implements Serializable, AnnotatedElement, GenericDeclaration, Type { - - private static final long serialVersionUID = 3206093459760846163L; - - // TODO How is this field being initialized? What's it being used for? - private ProtectionDomain pd; - - /** - * null-ok; cache of reflective information, wrapped in a soft - * reference - */ - private volatile SoftReference> cacheRef; - - private Class() { - // Prevent this class to be instantiated, instance - // should be created by JVM only - } - - /** - * Get the Signature attribute for this class. Returns null if not found. - */ - private String getSignatureAttribute() { - Object[] annotation = getSignatureAnnotation(); - - if (annotation == null) { - return null; - } - - return StringUtils.combineStrings(annotation); - } - - /** - * Get the Signature annotation for this class. Returns null if not found. - */ - native private Object[] getSignatureAnnotation(); - - /** - * Returns a {@code Class} object which represents the class with the - * specified name. The name should be the name of a class as described in - * the {@link Class class definition}; however, {@code Class}es representing - * primitive types can not be found using this method. - *

- * If the class has not been loaded so far, it is being loaded and linked - * first. This is done through either the class loader of the calling class - * or one of its parent class loaders. The class is also being initialized, - * which means that a possible static initializer block is executed. - * - * @param className - * the name of the non-primitive-type class to find. - * @return the named {@code Class} instance. - * @throws ClassNotFoundException - * if the requested class can not be found. - * @throws LinkageError - * if an error occurs during linkage - * @throws ExceptionInInitializerError - * if an exception occurs during static initialization of a - * class. - * @since Android 1.0 - */ - public static Class forName(String className) throws ClassNotFoundException { - return forName(className, true, VMStack.getCallingClassLoader()); - } - - /** - * Returns a {@code Class} object which represents the class with the - * specified name. The name should be the name of a class as described in - * the {@link Class class definition}, however {@code Class}es representing - * primitive types can not be found using this method. Security rules will - * be obeyed. - *

- * If the class has not been loaded so far, it is being loaded and linked - * first. This is done through either the specified class loader or one of - * its parent class loaders. The caller can also request the class to be - * initialized, which means that a possible static initializer block is - * executed. - * - * @param className - * the name of the non-primitive-type class to find. - * @param initializeBoolean - * indicates whether the class should be initialized. - * @param classLoader - * the class loader to use to load the class. - * @return the named {@code Class} instance. - * @throws ClassNotFoundException - * if the requested class can not be found. - * @throws LinkageError - * if an error occurs during linkage - * @throws ExceptionInInitializerError - * if an exception occurs during static initialization of a - * class. - * @since Android 1.0 - */ - public static Class forName(String className, boolean initializeBoolean, - ClassLoader classLoader) throws ClassNotFoundException { - - if (classLoader == null) { - SecurityManager smgr = System.getSecurityManager(); - if (smgr != null) { - ClassLoader calling = VMStack.getCallingClassLoader(); - if (calling != null) { - smgr.checkPermission(new RuntimePermission("getClassLoader")); - } - } - - classLoader = ClassLoader.getSystemClassLoader(); - } - // Catch an Exception thrown by the underlying native code. It wraps - // up everything inside a ClassNotFoundException, even if e.g. an - // Error occurred during initialization. This as a workaround for - // an ExceptionInInitilaizerError that's also wrapped. It is actually - // expected to be thrown. Maybe the same goes for other errors. - // Not wrapping up all the errors will break android though. - Class result; - try { - result = classForName(className, initializeBoolean, - classLoader); - } catch (ClassNotFoundException e) { - Throwable cause = e.getCause(); - if (cause instanceof ExceptionInInitializerError) { - throw (ExceptionInInitializerError) cause; - } - throw e; - } - return result; - } - - /* - * Returns a class by name without any security checks. - * - * @param className The name of the non-primitive type class to find - * @param initializeBoolean A boolean indicating whether the class should be - * initialized - * @param classLoader The class loader to use to load the class - * @return the named class. - * @throws ClassNotFoundException If the class could not be found - */ - static native Class classForName(String className, boolean initializeBoolean, - ClassLoader classLoader) throws ClassNotFoundException; - - /** - * Returns an array containing {@code Class} objects for all public classes - * and interfaces that are members of this class. This includes public - * members inherited from super classes and interfaces. If there are no such - * class members or if this object represents a primitive type then an array - * of length 0 is returned. - * - * @return the public class members of the class represented by this object. - * @throws SecurityException - * if a security manager exists and it does not allow member - * access. - * @since Android 1.0 - */ - public Class[] getClasses() { - // BEGIN android-note - // trying to get closer to the RI which returns a raw class array. - // copied from newer version of harmony - // END android-note - checkPublicMemberAccess(); - return getFullListOfClasses(true); - } - - /** - * Returns the annotation of the given type. If there is no such annotation - * then the method returns {@code null}. - * - * @param annotationClass - * the annotation type. - * @return the annotation of the given type, or {@code null} if there is no - * such annotation. - * @since Android 1.0 - */ - @SuppressWarnings("unchecked") - public A getAnnotation(Class annotationClass) { - Annotation[] list = getAnnotations(); - for (int i = 0; i < list.length; i++) { - if (annotationClass.isInstance(list[i])) { - return (A)list[i]; - } - } - - return null; - } - - /** - * Returns all the annotations of this class. If there are no annotations - * then an empty array is returned. - * - * @return a copy of the array containing this class' annotations. - * @see #getDeclaredAnnotations() - * @since Android 1.0 - */ - public Annotation[] getAnnotations() { - /* - * We need to get the annotations declared on this class, plus the - * annotations from superclasses that have the "@Inherited" annotation - * set. We create a temporary map to use while we accumulate the - * annotations and convert it to an array at the end. - * - * It's possible to have duplicates when annotations are inherited. - * We use a Map to filter those out. - * - * HashMap might be overkill here. - */ - HashMap map = new HashMap(); - Annotation[] annos = getDeclaredAnnotations(); - - for (int i = annos.length-1; i >= 0; --i) - map.put(annos[i].annotationType(), annos[i]); - - for (Class sup = getSuperclass(); sup != null; - sup = sup.getSuperclass()) { - annos = sup.getDeclaredAnnotations(); - for (int i = annos.length-1; i >= 0; --i) { - Class clazz = annos[i].annotationType(); - if (!map.containsKey(clazz) && - clazz.isAnnotationPresent(Inherited.class)) { - map.put(clazz, annos[i]); - } - } - } - - /* convert annotation values from HashMap to array */ - Collection coll = map.values(); - return coll.toArray(new Annotation[coll.size()]); - } - - /** - * Returns the canonical name of this class. If this class does not have a - * canonical name as defined in the Java Language Specification, then the - * method returns {@code null}. - * - * @return this class' canonical name, or {@code null} if it does not have a - * canonical name. - * @since Android 1.0 - */ - public String getCanonicalName() { - if (isLocalClass() || isAnonymousClass()) - return null; - - if (isArray()) { - /* - * The canonical name of an array type depends on the (existence of) - * the component type's canonical name. - */ - String name = getComponentType().getCanonicalName(); - if (name != null) { - return name + "[]"; - } - } else if (isMemberClass()) { - /* - * The canonical name of an inner class depends on the (existence - * of) the declaring class' canonical name. - */ - String name = getDeclaringClass().getCanonicalName(); - if (name != null) { - return name + "." + getSimpleName(); - } - } else { - /* - * The canonical name of a top-level class or primitive type is - * equal to the fully qualified name. - */ - return getName(); - } - - /* - * Other classes don't have a canonical name. - */ - return null; - } - - /** - * Returns the class loader which was used to load the class represented by - * this {@code Class}. Implementations are free to return {@code null} for - * classes that were loaded by the bootstrap class loader. The Android - * reference implementation, though, returns a reference to an actual - * representation of the bootstrap class loader. - * - * @return the class loader for the represented class. - * @throws SecurityException - * if a security manager exists and it does not allow accessing - * the class loader. - * @see ClassLoader - * @since Android 1.0 - */ - public ClassLoader getClassLoader() { - SecurityManager smgr = System.getSecurityManager(); - ClassLoader loader = getClassLoaderImpl(); - if (smgr != null && loader != null) { - ClassLoader calling = VMStack.getCallingClassLoader(); - - if (calling != null && !calling.isAncestorOf(loader)) { - smgr.checkPermission(new RuntimePermission("getClassLoader")); - } - } - - if (this.isPrimitive()) { - return null; - } - - if (loader == null) { - loader = BootClassLoader.getInstance(); - } - - return loader; - } - - /** - * This must be provided by the VM vendor, as it is used by other provided - * class implementations in this package. Outside of this class, it is used - * by SecurityManager.checkMemberAccess(), classLoaderDepth(), - * currentClassLoader() and currentLoadedClass(). Return the ClassLoader for - * this Class without doing any security checks. The bootstrap ClassLoader - * is returned, unlike getClassLoader() which returns null in place of the - * bootstrap ClassLoader. - * - * @return the ClassLoader - * @see ClassLoader#isSystemClassLoader() - */ - ClassLoader getClassLoaderImpl() { - ClassLoader loader = getClassLoader(this); - return loader == null ? BootClassLoader.getInstance() : loader; - } - - /* - * Returns the defining class loader for the given class. - * - * @param clazz the class the class loader of which we want - * @return the class loader - */ - private static native ClassLoader getClassLoader(Class clazz); - - /** - * Returns a {@code Class} object which represents the component type if - * this class represents an array type. Returns {@code null} if this class - * does not represent an array type. The component type of an array type is - * the type of the elements of the array. - * - * @return the component type of this class. - * @since Android 1.0 - */ - public native Class getComponentType(); - - /** - * Returns a {@code Constructor} object which represents the public - * constructor matching the specified parameter types. - * - * @param parameterTypes - * the parameter types of the requested constructor. - * {@code (Class[]) null} is equivalent to the empty array. - * @return the constructor described by {@code parameterTypes}. - * @throws NoSuchMethodException - * if the constructor can not be found. - * @throws SecurityException - * if a security manager exists and it does not allow member - * access. - * @see #getDeclaredConstructor(Class...) - * @since Android 1.0 - */ - @SuppressWarnings("unchecked") - public Constructor getConstructor(Class... parameterTypes) throws NoSuchMethodException, - SecurityException { - checkPublicMemberAccess(); - return getMatchingConstructor(getDeclaredConstructors(this, true), parameterTypes); - } - - /** - * Returns an array containing {@code Constructor} objects for all public - * constructors for the class represented by this {@code Class}. If there - * are no public constructors or if this {@code Class} represents an array - * class, a primitive type or void then an empty array is returned. - * - * @return an array with the public constructors of the class represented by - * this {@code Class}. - * @throws SecurityException - * if a security manager exists and it does not allow member - * access. - * @see #getDeclaredConstructors() - * @since Android 1.0 - */ - public Constructor[] getConstructors() throws SecurityException { - // BEGIN android-note - // trying to get closer to the RI which returns a raw constructor array. - // copied from newer version of harmony - // END android-note - checkPublicMemberAccess(); - return getDeclaredConstructors(this, true); - } - - /** - * Returns the annotations that are directly defined on the class - * represented by this {@code Class}. Annotations that are inherited are not - * included in the result. If there are no annotations at all, an empty - * array is returned. - * - * @return a copy of the array containing the annotations defined for the - * class that this {@code Class} represents. - * @see #getAnnotations() - * @since Android 1.0 - */ - native public Annotation[] getDeclaredAnnotations(); - - /** - * Returns an array containing {@code Class} objects for all classes and - * interfaces that are declared as members of the class which this {@code - * Class} represents. If there are no classes or interfaces declared or if - * this class represents an array class, a primitive type or void, then an - * empty array is returned. - * - * @return an array with {@code Class} objects for all the classes and - * interfaces that are used in member declarations. - * @throws SecurityException - * if a security manager exists and it does not allow member - * access. - * @since Android 1.0 - */ - public Class[] getDeclaredClasses() throws SecurityException { - // BEGIN android-note - // trying to get closer to the RI which returns a raw class array. - // copied from newer version of harmony - // END android-note - checkDeclaredMemberAccess(); - return getDeclaredClasses(this, false); - } - - /* - * Returns the list of member classes without performing any security checks - * first. This includes the member classes inherited from superclasses. If no - * member classes exist at all, an empty array is returned. - * - * @param publicOnly reflects whether we want only public members or all of them - * @return the list of classes - */ - private Class[] getFullListOfClasses(boolean publicOnly) { - Class[] result = getDeclaredClasses(this, publicOnly); - - // Traverse all superclasses - Class clazz = this.getSuperclass(); - while (clazz != null) { - Class[] temp = getDeclaredClasses(clazz, publicOnly); - if (temp.length != 0) { - result = arraycopy(new Class[result.length + temp.length], result, temp); - } - - clazz = clazz.getSuperclass(); - } - - return result; - } - - /* - * Returns the list of member classes of the given class. No security checks - * are performed. If no members exist, an empty array is returned. - * - * @param clazz the class the members of which we want - * @param publicOnly reflects whether we want only public member or all of them - * @return the class' class members - */ - native private static Class[] getDeclaredClasses(Class clazz, - boolean publicOnly); - - /** - * Returns a {@code Constructor} object which represents the constructor - * matching the specified parameter types that is declared by the class - * represented by this {@code Class}. - * - * @param parameterTypes - * the parameter types of the requested constructor. - * {@code (Class[]) null} is equivalent to the empty array. - * @return the constructor described by {@code parameterTypes}. - * @throws NoSuchMethodException - * if the requested constructor can not be found. - * @throws SecurityException - * if a security manager exists and it does not allow member - * access. - * @see #getConstructor(Class...) - * @since Android 1.0 - */ - @SuppressWarnings("unchecked") - public Constructor getDeclaredConstructor(Class... parameterTypes) - throws NoSuchMethodException, SecurityException { - checkDeclaredMemberAccess(); - return getMatchingConstructor(getDeclaredConstructors(this, false), parameterTypes); - } - - /** - * Returns an array containing {@code Constructor} objects for all - * constructors declared in the class represented by this {@code Class}. If - * there are no constructors or if this {@code Class} represents an array - * class, a primitive type or void then an empty array is returned. - * - * @return an array with the constructors declared in the class represented - * by this {@code Class}. - * - * @throws SecurityException - * if a security manager exists and it does not allow member - * access. - * @see #getConstructors() - * @since Android 1.0 - */ - public Constructor[] getDeclaredConstructors() throws SecurityException { - // BEGIN android-note - // trying to get closer to the RI which returns a raw constructor array. - // copied from newer version of harmony - // END android-note - checkDeclaredMemberAccess(); - return getDeclaredConstructors(this, false); - } - - /* - * Returns the list of constructors without performing any security checks - * first. If no constructors exist, an empty array is returned. - * - * @param clazz the class of interest - * @param publicOnly reflects whether we want only public constructors or all of them - * @return the list of constructors - */ - private static native Constructor[] getDeclaredConstructors(Class clazz, boolean publicOnly); - - /* - * Finds a constructor with a given signature. - * - * @param list the list of constructors to search through - * @param parameterTypes the formal parameter list - * @return the matching constructor - * @throws NoSuchMethodException if the constructor does not exist. - */ - private Constructor getMatchingConstructor( - Constructor[] list, Class[] parameterTypes) - throws NoSuchMethodException { - for (int i = 0; i < list.length; i++) { - if (compareClassLists(list[i].getParameterTypes(), parameterTypes)) { - return list[i]; - } - } - - // BEGIN android-changed - StringBuilder sb = new StringBuilder(); - sb.append(getSimpleName()); - sb.append('('); - boolean first = true; - if (parameterTypes != null) { - for (Class p : parameterTypes) { - if (!first) { - sb.append(','); - } - first = false; - sb.append(p.getSimpleName()); - } - } - sb.append(')'); - throw new NoSuchMethodException(sb.toString()); - // END android-changed - } - - /** - * Returns a {@code Field} object for the field with the specified name - * which is declared in the class represented by this {@code Class}. - * - * @param name - * the name of the requested field. - * @return the requested field in the class represented by this class. - * @throws NoSuchFieldException - * if the requested field can not be found. - * @throws SecurityException - * if a security manager exists and it does not allow member - * access. - * @see #getField(String) - * @since Android 1.0 - */ - public Field getDeclaredField(String name) - throws NoSuchFieldException, SecurityException { - checkDeclaredMemberAccess(); - - Field[] fields = getClassCache().getDeclaredFields(); - Field field = findFieldByName(fields, name); - - /* - * Make a copy of the private (to the package) object, so that - * setAccessible() won't alter the private instance. - */ - return REFLECT.clone(field); - } - - /** - * Returns an array containing {@code Field} objects for all fields declared - * in the class represented by this {@code Class}. If there are no fields or - * if this {@code Class} represents an array class, a primitive type or void - * then an empty array is returned. - * - * @return an array with the fields declared in the class represented by - * this class. - * @throws SecurityException - * if a security manager exists and it does not allow member - * access. - * @see #getFields() - * @since Android 1.0 - */ - public Field[] getDeclaredFields() throws SecurityException { - checkDeclaredMemberAccess(); - - // Return a copy of the private (to the package) array. - Field[] fields = getClassCache().getDeclaredFields(); - return ClassCache.deepCopy(fields); - } - - /* - * Returns the list of fields without performing any security checks - * first. If no fields exist at all, an empty array is returned. - * - * @param clazz the class of interest - * @param publicOnly reflects whether we want only public fields or all of them - * @return the list of fields - */ - static native Field[] getDeclaredFields(Class clazz, boolean publicOnly); - - /** - * Returns a {@code Method} object which represents the method matching the - * specified name and parameter types that is declared by the class - * represented by this {@code Class}. - * - * @param name - * the requested method's name. - * @param parameterTypes - * the parameter types of the requested method. - * {@code (Class[]) null} is equivalent to the empty array. - * @return the method described by {@code name} and {@code parameterTypes}. - * @throws NoSuchMethodException - * if the requested constructor can not be found. - * @throws NullPointerException - * if {@code name} is {@code null}. - * @throws SecurityException - * if a security manager exists and it does not allow member - * access. - * @see #getMethod(String, Class...) - * @since Android 1.0 - */ - public Method getDeclaredMethod(String name, Class... parameterTypes) - throws NoSuchMethodException, SecurityException { - checkDeclaredMemberAccess(); - - Method[] methods = getClassCache().getDeclaredMethods(); - Method method = findMethodByName(methods, name, parameterTypes); - - /* - * Make a copy of the private (to the package) object, so that - * setAccessible() won't alter the private instance. - */ - return REFLECT.clone(method); - } - - /** - * Returns an array containing {@code Method} objects for all methods - * declared in the class represented by this {@code Class}. If there are no - * methods or if this {@code Class} represents an array class, a primitive - * type or void then an empty array is returned. - * - * @return an array with the methods declared in the class represented by - * this {@code Class}. - * @throws SecurityException - * if a security manager exists and it does not allow member - * access. - * @see #getMethods() - * @since Android 1.0 - */ - public Method[] getDeclaredMethods() throws SecurityException { - checkDeclaredMemberAccess(); - - // Return a copy of the private (to the package) array. - Method[] methods = getClassCache().getDeclaredMethods(); - return ClassCache.deepCopy(methods); - } - - /** - * Returns the list of methods without performing any security checks - * first. If no methods exist, an empty array is returned. - */ - static native Method[] getDeclaredMethods(Class clazz, boolean publicOnly); - - /** - * Gets the {@link ClassCache} for this instance. - * - * @return non-null; the cache object - */ - /*package*/ ClassCache getClassCache() { - /* - * Note: It is innocuous if two threads try to simultaneously - * create the cache, so we don't bother protecting against that. - */ - ClassCache cache = null; - - if (cacheRef != null) { - cache = cacheRef.get(); - } - - if (cache == null) { - cache = new ClassCache(this); - cacheRef = new SoftReference>(cache); - } - - return cache; - } - - /** - * Returns the declaring {@code Class} of this {@code Class}. Returns - * {@code null} if the class is not a member of another class or if this - * {@code Class} represents an array class, a primitive type or void. - * - * @return the declaring {@code Class} or {@code null}. - * @since Android 1.0 - */ - native public Class getDeclaringClass(); - - /** - * Returns the enclosing {@code Class} of this {@code Class}. If there is no - * enclosing class the method returns {@code null}. - * - * @return the enclosing {@code Class} or {@code null}. - * @since Android 1.0 - */ - native public Class getEnclosingClass(); - - /** - * Gets the enclosing {@code Constructor} of this {@code Class}, if it is an - * anonymous or local/automatic class; otherwise {@code null}. - * - * @return the enclosing {@code Constructor} instance or {@code null}. - * @since Android 1.0 - */ - native public Constructor getEnclosingConstructor(); - - /** - * Gets the enclosing {@code Method} of this {@code Class}, if it is an - * anonymous or local/automatic class; otherwise {@code null}. - * - * @return the enclosing {@code Method} instance or {@code null}. - * @since Android 1.0 - */ - native public Method getEnclosingMethod(); - - /** - * Gets the {@code enum} constants associated with this {@code Class}. - * Returns {@code null} if this {@code Class} does not represent an {@code - * enum} type. - * - * @return an array with the {@code enum} constants or {@code null}. - * @since Android 1.0 - */ - @SuppressWarnings("unchecked") - public T[] getEnumConstants() { - if (isEnum()) { - checkPublicMemberAccess(); - T[] values = getClassCache().getEnumValuesInOrder(); - - // Copy the private (to the package) array. - return (T[]) values.clone(); - } - - return null; - } - - /** - * Returns a {@code Field} object which represents the public field with the - * specified name. This method first searches the class C represented by - * this {@code Class}, then the interfaces implemented by C and finally the - * superclasses of C. - * - * @param name - * the name of the requested field. - * @return the public field specified by {@code name}. - * @throws NoSuchFieldException - * if the field can not be found. - * @throws SecurityException - * if a security manager exists and it does not allow member - * access. - * @see #getDeclaredField(String) - * @since Android 1.0 - */ - public Field getField(String name) throws NoSuchFieldException, SecurityException { - checkPublicMemberAccess(); - - Field[] fields = getClassCache().getAllPublicFields(); - Field field = findFieldByName(fields, name); - - /* - * Make a copy of the private (to the package) object, so that - * setAccessible() won't alter the private instance. - */ - return REFLECT.clone(field); - } - - /** - * Returns an array containing {@code Field} objects for all public fields - * for the class C represented by this {@code Class}. Fields may be declared - * in C, the interfaces it implements or in the superclasses of C. The - * elements in the returned array are in no particular order. - *

- * If there are no public fields or if this class represents an array class, - * a primitive type or {@code void} then an empty array is returned. - *

- * - * @return an array with the public fields of the class represented by this - * {@code Class}. - * @throws SecurityException - * if a security manager exists and it does not allow member - * access. - * @see #getDeclaredFields() - * @since Android 1.0 - */ - public Field[] getFields() throws SecurityException { - checkPublicMemberAccess(); - - // Return a copy of the private (to the package) array. - Field[] fields = getClassCache().getAllPublicFields(); - return ClassCache.deepCopy(fields); - } - - /** - * Gets the {@link Type}s of the interfaces that this {@code Class} directly - * implements. If the {@code Class} represents a primitive type or {@code - * void} then an empty array is returned. - * - * @return an array of {@link Type} instances directly implemented by the - * class represented by this {@code class}. - * @since Android 1.0 - */ - public Type[] getGenericInterfaces() { - GenericSignatureParser parser = new GenericSignatureParser( - VMStack.getCallingClassLoader2()); - parser.parseForClass(this, getSignatureAttribute()); - return Types.getClonedTypeArray(parser.interfaceTypes); - } - - /** - * Gets the {@code Type} that represents the superclass of this {@code - * class}. - * - * @return an instance of {@code Type} representing the superclass. - * @since Android 1.0 - */ - public Type getGenericSuperclass() { - GenericSignatureParser parser = new GenericSignatureParser( - VMStack.getCallingClassLoader2()); - parser.parseForClass(this, getSignatureAttribute()); - return Types.getType(parser.superclassType); - } - - /** - * Returns an array of {@code Class} objects that match the interfaces - * specified in the {@code implements} declaration of the class represented - * by this {@code Class}. The order of the elements in the array is - * identical to the order in the original class declaration. If the class - * does not implement any interfaces, an empty array is returned. - * - * @return an array with the interfaces of the class represented by this - * class. - * @since Android 1.0 - */ - public native Class[] getInterfaces(); - // BEGIN android-note - // trying to get closer to the RI which returns a raw class array. - // copied from newer version of harmony - // END android-note - - // Changed to raw type to be closer to the RI - /** - * Returns a {@code Method} object which represents the public method with - * the specified name and parameter types. This method first searches the - * class C represented by this {@code Class}, then the superclasses of C and - * finally the interfaces implemented by C and finally the superclasses of C - * for a method with matching name. - * - * @param name - * the requested method's name. - * @param parameterTypes - * the parameter types of the requested method. - * {@code (Class[]) null} is equivalent to the empty array. - * @return the public field specified by {@code name}. - * @throws NoSuchMethodException - * if the method can not be found. - * @throws SecurityException - * if a security manager exists and it does not allow member - * access. - * @see #getDeclaredMethod(String, Class...) - * @since Android 1.0 - */ - public Method getMethod(String name, Class... parameterTypes) throws NoSuchMethodException, - SecurityException { - checkPublicMemberAccess(); - - Method[] methods = getClassCache().getAllPublicMethods(); - Method method = findMethodByName(methods, name, parameterTypes); - - /* - * Make a copy of the private (to the package) object, so that - * setAccessible() won't alter the private instance. - */ - return REFLECT.clone(method); - } - - /** - * Returns an array containing {@code Method} objects for all public methods - * for the class C represented by this {@code Class}. Methods may be - * declared in C, the interfaces it implements or in the superclasses of C. - * The elements in the returned array are in no particular order. - *

- * If there are no public methods or if this {@code Class} represents a - * primitive type or {@code void} then an empty array is returned. - *

- * - * @return an array with the methods of the class represented by this - * {@code Class}. - * @throws SecurityException - * if a security manager exists and it does not allow member - * access. - * @see #getDeclaredMethods() - * @since Android 1.0 - */ - public Method[] getMethods() throws SecurityException { - checkPublicMemberAccess(); - - // Return a copy of the private (to the package) array. - Method[] methods = getClassCache().getAllPublicMethods(); - return ClassCache.deepCopy(methods); - } - - /** - * Performs the security checks regarding the access of a public - * member of this {@code Class}. - * - *

Note: Because of the {@code getCallingClassLoader2()} - * check, this method must be called exactly one level deep into a - * public method on this instance.

- */ - /*package*/ void checkPublicMemberAccess() { - SecurityManager smgr = System.getSecurityManager(); - - if (smgr != null) { - smgr.checkMemberAccess(this, Member.PUBLIC); - - ClassLoader calling = VMStack.getCallingClassLoader2(); - ClassLoader current = getClassLoader(); - - if (calling != null && !calling.isAncestorOf(current)) { - smgr.checkPackageAccess(this.getPackage().getName()); - } - } - } - - /** - * Performs the security checks regarding the access of a declared - * member of this {@code Class}. - * - *

Note: Because of the {@code getCallingClassLoader2()} - * check, this method must be called exactly one level deep into a - * public method on this instance.

- */ - private void checkDeclaredMemberAccess() { - SecurityManager smgr = System.getSecurityManager(); - if (smgr != null) { - smgr.checkMemberAccess(this, Member.DECLARED); - - ClassLoader calling = VMStack.getCallingClassLoader2(); - ClassLoader current = getClassLoader(); - - if (calling != null && !calling.isAncestorOf(current)) { - smgr.checkPackageAccess(this.getPackage().getName()); - } - } - } - - /** - * Returns an integer that represents the modifiers of the class represented - * by this {@code Class}. The returned value is a combination of bits - * defined by constants in the {@link Modifier} class. - * - * @return the modifiers of the class represented by this {@code Class}. - * @since Android 1.0 - */ - public int getModifiers() { - return getModifiers(this, false); - } - - /* - * Return the modifiers for the given class. - * - * @param clazz the class of interest - * @ignoreInnerClassesAttrib determines whether we look for and use the - * flags from an "inner class" attribute - */ - private static native int getModifiers(Class clazz, boolean ignoreInnerClassesAttrib); - - /** - * Returns the name of the class represented by this {@code Class}. For a - * description of the format which is used, see the class definition of - * {@link Class}. - * - * @return the name of the class represented by this {@code Class}. - * @since Android 1.0 - */ - public native String getName(); - - /** - * Returns the simple name of the class represented by this {@code Class} as - * defined in the source code. If there is no name (that is, the class is - * anonymous) then an empty string is returned. If the receiver is an array - * then the name of the underlying type with square braces appended (for - * example {@code "Integer[]"}) is returned. - * - * @return the simple name of the class represented by this {@code Class}. - * @since Android 1.0 - */ - public String getSimpleName() { - if (isArray()) { - return getComponentType().getSimpleName() + "[]"; - } - - String name = getName(); - - if (isAnonymousClass()) { - return ""; - } - - if (isMemberClass() || isLocalClass()) { - return getInnerClassName(); - } - - int dot = name.lastIndexOf('.'); - if (dot != -1) { - return name.substring(dot + 1); - } - - return name; - } - - /* - * Returns the simple name of a member or local class, or null otherwise. - * - * @return The name. - */ - private native String getInnerClassName(); - - /** - * Returns the {@code ProtectionDomain} of the class represented by this - * class. - *

- * Note: In order to conserve space in an embedded target like Android, we - * allow this method to return {@code null} for classes in the system - * protection domain (that is, for system classes). System classes are - * always given full permissions (that is, AllPermission). This can not be - * changed through the {@link java.security.Policy} class. - *

- * - * @return the {@code ProtectionDomain} of the class represented by this - * class. - * @throws SecurityException - * if a security manager exists and it does not allow member - * access. - */ - public ProtectionDomain getProtectionDomain() { - SecurityManager smgr = System.getSecurityManager(); - if (smgr != null) { - // Security check is independent of calling class loader. - smgr.checkPermission(new RuntimePermission("getProtectionDomain")); - } - - return pd; - } - - /** - * Returns the URL of the resource specified by {@code resName}. The mapping - * between the resource name and the URL is managed by the class' class - * loader. - * - * @param resName - * the name of the resource. - * @return the requested resource's {@code URL} object or {@code null} if - * the resource can not be found. - * @see ClassLoader - * @since Android 1.0 - */ - public URL getResource(String resName) { - // Get absolute resource name, but without the leading slash - if (resName.startsWith("/")) { - resName = resName.substring(1); - } else { - String pkg = getName(); - int dot = pkg.lastIndexOf('.'); - if (dot != -1) { - pkg = pkg.substring(0, dot).replace('.', '/'); - } else { - pkg = ""; - } - - resName = pkg + "/" + resName; - } - - // Delegate to proper class loader - ClassLoader loader = getClassLoader(); - if (loader != null) { - return loader.getResource(resName); - } else { - return ClassLoader.getSystemResource(resName); - } - } - - /** - * Returns a read-only stream for the contents of the resource specified by - * {@code resName}. The mapping between the resource name and the stream is - * managed by the class' class loader. - * - * @param resName - * the name of the resource. - * @return a stream for the requested resource or {@code null} if no - * resource with the specified name can be found. - * @see ClassLoader - * @since Android 1.0 - */ - public InputStream getResourceAsStream(String resName) { - // Get absolute resource name, but without the leading slash - if (resName.startsWith("/")) { - resName = resName.substring(1); - } else { - String pkg = getName(); - int dot = pkg.lastIndexOf('.'); - if (dot != -1) { - pkg = pkg.substring(0, dot).replace('.', '/'); - } else { - pkg = ""; - } - - resName = pkg + "/" + resName; - } - - // Delegate to proper class loader - ClassLoader loader = getClassLoader(); - if (loader != null) { - return loader.getResourceAsStream(resName); - } else { - return ClassLoader.getSystemResourceAsStream(resName); - } - } - - /** - * Returns the signers for the class represented by this {@code Class} or - * {@code null} if either there are no signers or this {@code Class} - * represents a primitive type or void. - * - * @return the signers of the class represented by this {@code Class}. - * @since Android 1.0 - */ - public Object[] getSigners() { - // TODO Delegate this to class loader somehow? What are these signers? - return null; - } - - /** - * Returns the {@code Class} object which represents the superclass of the - * class represented by this {@code Class}. If this {@code Class} represents - * the {@code Object} class, a primitive type, an interface or void then the - * method returns {@code null}. If this {@code Class} represents an array - * class then the {@code Object} class is returned. - * - * @return the superclass of the class represented by this {@code Class}. - * @since Android 1.0 - */ - public native Class getSuperclass(); - - /** - * Returns an array containing {@code TypeVariable} objects for type - * variables declared by the generic class represented by this {@code - * Class}. Returns an empty array if the class is not generic. - * - * @return an array with the type variables of the class represented by this - * class. - * @since Android 1.0 - */ - @SuppressWarnings("unchecked") - public synchronized TypeVariable>[] getTypeParameters() { - GenericSignatureParser parser = new GenericSignatureParser( - VMStack.getCallingClassLoader2()); - parser.parseForClass(this, getSignatureAttribute()); - return parser.formalTypeParameters.clone(); - } - - /** - * Indicates whether this {@code Class} represents an annotation class. - * - * @return {@code true} if this {@code Class} represents an annotation - * class; {@code false} otherwise. - * @since Android 1.0 - */ - public boolean isAnnotation() { - final int ACC_ANNOTATION = 0x2000; // not public in reflect.Modifiers - int mod = getModifiers(this, true); - return (mod & ACC_ANNOTATION) != 0; - } - - /** - * Indicates whether the specified annotation is present for the class - * represented by this {@code Class}. - * - * @param annotationClass - * the annotation to look for. - * @return {@code true} if the class represented by this {@code Class} is - * annotated with {@code annotationClass}; {@code false} otherwise. - * @since Android 1.0 - */ - public boolean isAnnotationPresent(Class annotationClass) { - return getAnnotation(annotationClass) != null; - } - - /** - * Indicates whether the class represented by this {@code Class} is - * anonymously declared. - * - * @return {@code true} if the class represented by this {@code Class} is - * anonymous; {@code false} otherwise. - * @since Android 1.0 - */ - native public boolean isAnonymousClass(); - - /** - * Indicates whether the class represented by this {@code Class} is an array - * class. - * - * @return {@code true} if the class represented by this {@code Class} is an - * array class; {@code false} otherwise. - * @since Android 1.0 - */ - public boolean isArray() { - return getComponentType() != null; - } - - /** - * Indicates whether the specified class type can be converted to the class - * represented by this {@code Class}. Conversion may be done via an identity - * conversion or a widening reference conversion (if either the receiver or - * the argument represent primitive types, only the identity conversion - * applies). - * - * @param cls - * the class to check. - * @return {@code true} if {@code cls} can be converted to the class - * represented by this {@code Class}; {@code false} otherwise. - * @throws NullPointerException - * if {@code cls} is {@code null}. - * @since Android 1.0 - */ - public native boolean isAssignableFrom(Class cls); - - /** - * Indicates whether the class represented by this {@code Class} is an - * {@code enum}. - * - * @return {@code true} if the class represented by this {@code Class} is an - * {@code enum}; {@code false} otherwise. - * @since Android 1.0 - */ - public boolean isEnum() { - return ((getModifiers() & 0x4000) != 0) && (getSuperclass() == Enum.class); - } - - /** - * Indicates whether the specified object can be cast to the class - * represented by this {@code Class}. This is the runtime version of the - * {@code instanceof} operator. - * - * @param object - * the object to check. - * @return {@code true} if {@code object} can be cast to the type - * represented by this {@code Class}; {@code false} if {@code - * object} is {@code null} or cannot be cast. - * @since Android 1.0 - */ - public native boolean isInstance(Object object); - - /** - * Indicates whether this {@code Class} represents an interface. - * - * @return {@code true} if this {@code Class} represents an interface; - * {@code false} otherwise. - * @since Android 1.0 - */ - public native boolean isInterface(); - - /** - * Indicates whether the class represented by this {@code Class} is defined - * locally. - * - * @return {@code true} if the class represented by this {@code Class} is - * defined locally; {@code false} otherwise. - * @since Android 1.0 - */ - public boolean isLocalClass() { - boolean enclosed = (getEnclosingMethod() != null || - getEnclosingConstructor() != null); - return enclosed && !isAnonymousClass(); - } - - /** - * Indicates whether the class represented by this {@code Class} is a member - * class. - * - * @return {@code true} if the class represented by this {@code Class} is a - * member class; {@code false} otherwise. - * @since Android 1.0 - */ - public boolean isMemberClass() { - return getDeclaringClass() != null; - } - - /** - * Indicates whether this {@code Class} represents a primitive type. - * - * @return {@code true} if this {@code Class} represents a primitive type; - * {@code false} otherwise. - * @since Android 1.0 - */ - public native boolean isPrimitive(); - - /** - * Indicates whether this {@code Class} represents a synthetic type. - * - * @return {@code true} if this {@code Class} represents a synthetic type; - * {@code false} otherwise. - * @since Android 1.0 - */ - public boolean isSynthetic() { - final int ACC_SYNTHETIC = 0x1000; // not public in reflect.Modifiers - int mod = getModifiers(this, true); - return (mod & ACC_SYNTHETIC) != 0; - } - - /** - * Returns a new instance of the class represented by this {@code Class}, - * created by invoking the default (that is, zero-argument) constructor. If - * there is no such constructor, or if the creation fails (either because of - * a lack of available memory or because an exception is thrown by the - * constructor), an {@code InstantiationException} is thrown. If the default - * constructor exists but is not accessible from the context where this - * method is invoked, an {@code IllegalAccessException} is thrown. - * - * @return a new instance of the class represented by this {@code Class}. - * @throws IllegalAccessException - * if the default constructor is not visible. - * @throws InstantiationException - * if the instance can not be created. - * @throws SecurityException - * if a security manager exists and it does not allow creating - * new instances. - * @since Android 1.0 - */ - public T newInstance() throws IllegalAccessException, - InstantiationException { - checkPublicMemberAccess(); - return newInstanceImpl(); - } - - private native T newInstanceImpl() throws IllegalAccessException, - InstantiationException; - - @Override - public String toString() { - if (isPrimitive()) { - return getSimpleName().toLowerCase(); - } else { - return (isInterface() ? "interface " : "class ") + getName(); - } - } - - /** - * Returns the {@code Package} of which the class represented by this - * {@code Class} is a member. Returns {@code null} if no {@code Package} - * object was created by the class loader of the class. - * - * @return Package the {@code Package} of which this {@code Class} is a - * member or {@code null}. - * @since Android 1.0 - */ - public Package getPackage() { - // TODO This might be a hack, but the VM doesn't have the necessary info. - ClassLoader loader = getClassLoader(); - if (loader != null) { - String name = getName(); - int dot = name.lastIndexOf('.'); - return (dot != -1 ? ClassLoader.getPackage(loader, name.substring(0, dot)) : null); - } - - return null; - } - - /** - * Returns the assertion status for the class represented by this {@code - * Class}. Assertion is enabled / disabled based on the class loader, - * package or class default at runtime. - * - * @return the assertion status for the class represented by this {@code - * Class}. - * @since Android 1.0 - */ - public native boolean desiredAssertionStatus(); - - /** - * Casts this {@code Class} to represent a subclass of the specified class. - * If successful, this {@code Class} is returned; otherwise a {@code - * ClassCastException} is thrown. - * - * @param clazz - * the required type. - * @return this {@code Class} cast as a subclass of the given type. - * @throws ClassCastException - * if this {@code Class} cannot be cast to the specified type. - * @since Android 1.0 - */ - @SuppressWarnings("unchecked") - public Class asSubclass(Class clazz) { - if (clazz.isAssignableFrom(this)) { - return (Class)this; - } - throw new ClassCastException(); - } - - /** - * Casts the specified object to the type represented by this {@code Class}. - * If the object is {@code null} then the result is also {@code null}. - * - * @param obj - * the object to cast. - * @return the object that has been cast. - * @throws ClassCastException - * if the object cannot be cast to the specified type. - * @since Android 1.0 - */ - @SuppressWarnings("unchecked") - public T cast(Object obj) { - if (obj == null) { - return null; - } else if (this.isInstance(obj)) { - return (T)obj; - } - throw new ClassCastException(); - } - - /** - * Set the "accessible" flag of the given object, without doing any - * access checks. - * - *

Note: This method is implemented in native code, and, - * as such, is less efficient than using {@link ClassCache#REFLECT} - * to achieve the same goal. This method exists solely to help - * bootstrap the reflection bridge.

- * - * @param ao non-null; the object to modify - * @param flag the new value for the accessible flag - */ - /*package*/ static native void setAccessibleNoCheck(AccessibleObject ao, - boolean flag); - - /** - * Copies two arrays into one. Assumes that the destination array is large - * enough. - * - * @param result the destination array - * @param head the first source array - * @param tail the second source array - * @return the destination array, that is, result - */ - private static T[] arraycopy(T[] result, T[] head, T[] tail) { - System.arraycopy(head, 0, result, 0, head.length); - System.arraycopy(tail, 0, result, head.length, tail.length); - return result; - } - - /** - * This must be provided by the vm vendor, as it is used by other provided - * class implementations in this package. This method is used by - * SecurityManager.classDepth(), and getClassContext() which use the - * parameters (-1, false) and SecurityManager.classLoaderDepth(), - * currentClassLoader(), and currentLoadedClass() which use the parameters - * (-1, true). Walk the stack and answer an array containing the maxDepth - * most recent classes on the stack of the calling thread. Starting with the - * caller of the caller of getStackClasses(), return an array of not more - * than maxDepth Classes representing the classes of running methods on the - * stack (including native methods). Frames representing the VM - * implementation of java.lang.reflect are not included in the list. If - * stopAtPrivileged is true, the walk will terminate at any frame running - * one of the following methods:
    - *
  • java/security/AccessController.doPrivileged(Ljava/security/PrivilegedAction;)Ljava/lang/Object;
  • - *
  • java/security/AccessController.doPrivileged(Ljava/security/PrivilegedExceptionAction;)Ljava/lang/Object;
  • - *
  • java/security/AccessController.doPrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;
  • - *
  • java/security/AccessController.doPrivileged(Ljava/security/PrivilegedExceptionAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;
  • - *
If one of the doPrivileged methods is found, the walk terminate - * and that frame is NOT included in the returned array. Notes: - *
    - *
  • This method operates on the defining classes of methods on stack. - * NOT the classes of receivers.
  • - *
  • The item at index zero in the result array describes the caller of - * the caller of this method.
  • - *
- * - * @param maxDepth - * maximum depth to walk the stack, -1 for the entire stack - * @param stopAtPrivileged - * stop at privileged classes - * @return the array of the most recent classes on the stack - */ - static final Class[] getStackClasses(int maxDepth, boolean stopAtPrivileged) { - return VMStack.getClasses(maxDepth, stopAtPrivileged); - } - -} diff --git a/libcore/luni-kernel/src/main/java/java/lang/ClassCache.java b/libcore/luni-kernel/src/main/java/java/lang/ClassCache.java deleted file mode 100644 index 5ea6992d4..000000000 --- a/libcore/luni-kernel/src/main/java/java/lang/ClassCache.java +++ /dev/null @@ -1,702 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.lang; - -import org.apache.harmony.kernel.vm.LangAccess; -import org.apache.harmony.kernel.vm.ReflectionAccess; - -import java.lang.reflect.AccessibleObject; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.EnumSet; -import java.util.HashSet; - -/** - * Cache of per-class data, meant to help the performance of reflection - * methods. - * - *

Note: None of the methods perform access checks. It is up - * to the (package internal) clients of this code to perform such - * checks as necessary.

- * - *

Also Note: None of the returned array values are - * protected in any way. It is up to the (again, package internal) - * clients of this code to protect the arrays if they should ever - * escape the package.

- */ -/*package*/ class ClassCache { - // TODO: Add caching for constructors and fields. - - /** non-null; comparator used for enumerated values */ - private static final EnumComparator ENUM_COMPARATOR = - new EnumComparator(); - - /** non-null; reflection access bridge */ - /*package*/ static final ReflectionAccess REFLECT = getReflectionAccess(); - - /** non-null; class that this instance represents */ - private final Class clazz; - - /** null-ok; list of all declared methods */ - private volatile Method[] declaredMethods; - - /** null-ok; list of all public declared methods */ - private volatile Method[] declaredPublicMethods; - - /** null-ok; list of all methods, both direct and inherited */ - private volatile Method[] allMethods; - - /** null-ok; list of all public methods, both direct and inherited */ - private volatile Method[] allPublicMethods; - - /** null-ok; list of all declared fields */ - private volatile Field[] declaredFields; - - /** null-ok; list of all public declared fields */ - private volatile Field[] declaredPublicFields; - - /** null-ok; list of all fields, both direct and inherited */ - private volatile Field[] allFields; - - /** null-ok; list of all public fields, both direct and inherited */ - private volatile Field[] allPublicFields; - - /** - * null-ok; array of enumerated values in their original order, if this - * instance's class is an enumeration - */ - private volatile T[] enumValuesInOrder; - - /** - * null-ok; array of enumerated values sorted by name, if this - * instance's class is an enumeration - */ - private volatile T[] enumValuesByName; - - static { - /* - * Provide access to this package from java.util as part of - * bootstrap. TODO: See if this can be removed in favor of the - * simpler mechanism below. (That is, see if EnumSet will be - * happy calling LangAccess.getInstance().) - */ - Field field; - - try { - field = EnumSet.class.getDeclaredField("LANG_BOOTSTRAP"); - REFLECT.setAccessibleNoCheck(field, true); - } catch (NoSuchFieldException ex) { - // This shouldn't happen because the field is in fact defined. - throw new AssertionError(ex); - } - - try { - field.set(null, LangAccessImpl.THE_ONE); - } catch (IllegalAccessException ex) { - // This shouldn't happen because we made the field accessible. - throw new AssertionError(ex); - } - - // Also set up the bootstrap-classpath-wide access mechanism. - LangAccess.setInstance(LangAccessImpl.THE_ONE); - } - - /** - * Constructs an instance. - * - * @param clazz non-null; class that this instance represents - */ - /*package*/ ClassCache(Class clazz) { - if (clazz == null) { - throw new NullPointerException("clazz == null"); - } - - this.clazz = clazz; - this.declaredMethods = null; - this.declaredPublicMethods = null; - this.allMethods = null; - this.allPublicMethods = null; - this.enumValuesInOrder = null; - this.enumValuesByName = null; - this.declaredFields = null; - this.declaredPublicFields = null; - this.allFields = null; - this.allPublicFields = null; - } - - /** - * Gets the list of all declared methods. - * - * @return non-null; the list of all declared methods - */ - public Method[] getDeclaredMethods() { - if (declaredMethods == null) { - declaredMethods = Class.getDeclaredMethods(clazz, false); - } - - return declaredMethods; - } - - /** - * Gets the list of all declared public methods. - * - * @return non-null; the list of all declared public methods - */ - public Method[] getDeclaredPublicMethods() { - if (declaredPublicMethods == null) { - declaredPublicMethods = Class.getDeclaredMethods(clazz, true); - } - - return declaredPublicMethods; - } - - /** - * Gets either the list of declared methods or the list of declared - * public methods. - * - * @param publicOnly whether to only return public methods - */ - public Method[] getDeclaredMethods(boolean publicOnly) { - return publicOnly ? getDeclaredPublicMethods() : getDeclaredMethods(); - } - - /** - * Gets the list of all methods, both directly - * declared and inherited. - * - * @return non-null; the list of all methods - */ - public Method[] getAllMethods() { - if (allMethods == null) { - allMethods = getFullListOfMethods(false); - } - - return allMethods; - } - - /** - * Gets the list of all public methods, both directly - * declared and inherited. - * - * @return non-null; the list of all public methods - */ - public Method[] getAllPublicMethods() { - if (allPublicMethods == null) { - allPublicMethods = getFullListOfMethods(true); - } - - return allPublicMethods; - } - - /* - * Returns the list of methods without performing any security checks - * first. This includes the methods inherited from superclasses. If no - * methods exist at all, an empty array is returned. - * - * @param publicOnly reflects whether we want only public methods - * or all of them - * @return the list of methods - */ - private Method[] getFullListOfMethods(boolean publicOnly) { - ArrayList methods = new ArrayList(); - HashSet seen = new HashSet(); - - findAllMethods(clazz, methods, seen, publicOnly); - - return methods.toArray(new Method[methods.size()]); - } - - /** - * Collects the list of methods without performing any security checks - * first. This includes the methods inherited from superclasses and from - * all implemented interfaces. The latter may also implement multiple - * interfaces, so we (potentially) recursively walk through a whole tree of - * classes. If no methods exist at all, an empty array is returned. - * - * @param clazz non-null; class to inspect - * @param methods non-null; the target list to add the results to - * @param seen non-null; a set of signatures we've already seen - * @param publicOnly reflects whether we want only public methods - * or all of them - */ - private static void findAllMethods(Class clazz, - ArrayList methods, HashSet seen, - boolean publicOnly) { - StringBuilder builder = new StringBuilder(); - Class origClass = clazz; - - // Traverse class and superclasses, get rid of dupes by signature - while (clazz != null) { - Method[] declaredMethods = - clazz.getClassCache().getDeclaredMethods(publicOnly); - int length = declaredMethods.length; - if (length != 0) { - for (Method method : declaredMethods) { - builder.setLength(0); - builder.append(method.getName()); - builder.append('('); - Class[] types = method.getParameterTypes(); - if (types.length != 0) { - builder.append(types[0].getName()); - for (int j = 1; j < types.length; j++) { - builder.append(','); - builder.append(types[j].getName()); - } - } - builder.append(')'); - - String signature = builder.toString(); - if (!seen.contains(signature)) { - methods.add(method); - seen.add(signature); - } - } - } - - clazz = clazz.getSuperclass(); - } - - // Traverse all interfaces, and do the same recursively. - Class[] interfaces = origClass.getInterfaces(); - for (Class intf : interfaces) { - findAllMethods(intf, methods, seen, publicOnly); - } - } - - /** - * Finds and returns a method with a given name and signature. Use - * this with one of the method lists returned by instances of this class. - * - * @param list non-null; the list of methods to search through - * @param parameterTypes non-null; the formal parameter list - * @return non-null; the matching method - * @throws NoSuchMethodException thrown if the method does not exist - */ - public static Method findMethodByName(Method[] list, String name, - Class[] parameterTypes) throws NoSuchMethodException { - if (name == null) { - throw new NullPointerException("Method name must not be null."); - } - for (int i = list.length - 1; i >= 0; i--) { - Method method = list[i]; - if (method.getName().equals(name) - && compareClassLists( - method.getParameterTypes(), parameterTypes)) { - return method; - } - } - - throw new NoSuchMethodException(name); - } - - /** - * Compares two class lists for equality. Empty and - * null lists are considered equal. This is useful - * for matching methods and constructors. - * - *

TODO: Take into account assignment compatibility?

- * - * @param a null-ok; the first list of types - * @param b null-ok; the second list of types - * @return true if and only if the lists are equal - */ - public static boolean compareClassLists(Class[] a, Class[] b) { - if (a == null) { - return (b == null) || (b.length == 0); - } - - int length = a.length; - - if (b == null) { - return (length == 0); - } - - if (length != b.length) { - return false; - } - - for (int i = length - 1; i >= 0; i--) { - if (a[i] != b[i]) { - return false; - } - } - - return true; - } - - /** - * Makes a deep copy of the given array of methods. This is useful - * when handing out arrays from the public API. - * - *

Note: In such cases, it is insufficient to just make - * a shallow copy of the array, since method objects aren't - * immutable due to the existence of {@link - * AccessibleObject#setAccessible}.

- * - * @param orig non-null; array to copy - * @return non-null; a deep copy of the given array - */ - public static Method[] deepCopy(Method[] orig) { - int length = orig.length; - Method[] result = new Method[length]; - - for (int i = length - 1; i >= 0; i--) { - result[i] = REFLECT.clone(orig[i]); - } - - return result; - } - - /** - * Gets the list of all declared fields. - * - * @return non-null; the list of all declared fields - */ - public Field[] getDeclaredFields() { - if (declaredFields == null) { - declaredFields = Class.getDeclaredFields(clazz, false); - } - - return declaredFields; - } - - /** - * Gets the list of all declared public fields. - * - * @return non-null; the list of all declared public fields - */ - public Field[] getDeclaredPublicFields() { - if (declaredPublicFields == null) { - declaredPublicFields = Class.getDeclaredFields(clazz, true); - } - - return declaredPublicFields; - } - - /** - * Gets either the list of declared fields or the list of declared - * public fields. - * - * @param publicOnly whether to only return public fields - */ - public Field[] getDeclaredFields(boolean publicOnly) { - return publicOnly ? getDeclaredPublicFields() : getDeclaredFields(); - } - - /** - * Gets the list of all fields, both directly - * declared and inherited. - * - * @return non-null; the list of all fields - */ - public Field[] getAllFields() { - if (allFields == null) { - allFields = getFullListOfFields(false); - } - - return allFields; - } - - /** - * Gets the list of all public fields, both directly - * declared and inherited. - * - * @return non-null; the list of all public fields - */ - public Field[] getAllPublicFields() { - if (allPublicFields == null) { - allPublicFields = getFullListOfFields(true); - } - - return allPublicFields; - } - - /* - * Returns the list of fields without performing any security checks - * first. This includes the fields inherited from superclasses. If no - * fields exist at all, an empty array is returned. - * - * @param publicOnly reflects whether we want only public fields - * or all of them - * @return the list of fields - */ - private Field[] getFullListOfFields(boolean publicOnly) { - ArrayList fields = new ArrayList(); - HashSet seen = new HashSet(); - - findAllfields(clazz, fields, seen, publicOnly); - - return fields.toArray(new Field[fields.size()]); - } - - /** - * Collects the list of fields without performing any security checks - * first. This includes the fields inherited from superclasses and from - * all implemented interfaces. The latter may also implement multiple - * interfaces, so we (potentially) recursively walk through a whole tree of - * classes. If no fields exist at all, an empty array is returned. - * - * @param clazz non-null; class to inspect - * @param fields non-null; the target list to add the results to - * @param seen non-null; a set of signatures we've already seen - * @param publicOnly reflects whether we want only public fields - * or all of them - */ - private static void findAllfields(Class clazz, - ArrayList fields, HashSet seen, - boolean publicOnly) { - - // Traverse class and superclasses, get rid of dupes by signature - while (clazz != null) { - Field[] declaredFields = - clazz.getClassCache().getDeclaredFields(publicOnly); - for (Field field : declaredFields) { - String signature = field.toString(); - if (!seen.contains(signature)) { - fields.add(field); - seen.add(signature); - } - } - - // Traverse all interfaces, and do the same recursively. - Class[] interfaces = clazz.getInterfaces(); - for (Class intf : interfaces) { - findAllfields(intf, fields, seen, publicOnly); - } - - clazz = clazz.getSuperclass(); - } - } - - /** - * Finds and returns a field with a given name and signature. Use - * this with one of the field lists returned by instances of this class. - * - * @param list non-null; the list of fields to search through - * @return non-null; the matching field - * @throws NoSuchFieldException thrown if the field does not exist - */ - public static Field findFieldByName(Field[] list, String name) - throws NoSuchFieldException { - if (name == null) { - throw new NullPointerException("Field name must not be null."); - } - for (int i = 0; i < list.length; i++) { - Field field = list[i]; - if (field.getName().equals(name)) { - return field; - } - } - - throw new NoSuchFieldException(name); - } - - /** - * Makes a deep copy of the given array of fields. This is useful - * when handing out arrays from the public API. - * - *

Note: In such cases, it is insufficient to just make - * a shallow copy of the array, since field objects aren't - * immutable due to the existence of {@link - * AccessibleObject#setAccessible}.

- * - * @param orig non-null; array to copy - * @return non-null; a deep copy of the given array - */ - public static Field[] deepCopy(Field[] orig) { - int length = orig.length; - Field[] result = new Field[length]; - - for (int i = length - 1; i >= 0; i--) { - result[i] = REFLECT.clone(orig[i]); - } - - return result; - } - - /** - * Gets the enumerated value with a given name. - * - * @param name non-null; name of the value - * @return null-ok; the named enumerated value or null - * if this instance's class doesn't have such a value (including - * if this instance isn't in fact an enumeration) - */ - @SuppressWarnings("unchecked") - public T getEnumValue(String name) { - Enum[] values = (Enum[]) getEnumValuesByName(); - - if (values == null) { - return null; - } - - // Binary search. - - int min = 0; - int max = values.length - 1; - - while (min <= max) { - /* - * The guessIdx calculation is equivalent to ((min + max) - * / 2) but won't go wonky when min and max are close to - * Integer.MAX_VALUE. - */ - int guessIdx = min + ((max - min) >> 1); - Enum guess = values[guessIdx]; - int cmp = name.compareTo(guess.name()); - - if (cmp < 0) { - max = guessIdx - 1; - } else if (cmp > 0) { - min = guessIdx + 1; - } else { - return (T) guess; - } - } - - return null; - } - - /** - * Gets the array of enumerated values, sorted by name. - * - * @return null-ok; the value array, or null if this - * instance's class isn't in fact an enumeration - */ - public T[] getEnumValuesByName() { - if (enumValuesByName == null) { - T[] values = getEnumValuesInOrder(); - - if (values != null) { - values = (T[]) values.clone(); - Arrays.sort((Enum[]) values, ENUM_COMPARATOR); - - /* - * Note: It's only safe (concurrency-wise) to set the - * instance variable after the array is properly sorted. - */ - enumValuesByName = values; - } - } - - return enumValuesByName; - } - - /** - * Gets the array of enumerated values, in their original declared - * order. - * - * @return null-ok; the value array, or null if this - * instance's class isn't in fact an enumeration - */ - public T[] getEnumValuesInOrder() { - if ((enumValuesInOrder == null) && clazz.isEnum()) { - enumValuesInOrder = callEnumValues(); - } - - return enumValuesInOrder; - } - - /** - * Calls the static method values() on this - * instance's class, which is presumed to be a properly-formed - * enumeration class, using proper privilege hygiene. - * - * @return non-null; the array of values as reported by - * value() - */ - @SuppressWarnings("unchecked") - private T[] callEnumValues() { - Method method; - - try { - Method[] methods = getDeclaredPublicMethods(); - method = findMethodByName(methods, "values", (Class[]) null); - method = REFLECT.accessibleClone(method); - } catch (NoSuchMethodException ex) { - // This shouldn't happen if the class is a well-formed enum. - throw new UnsupportedOperationException(ex); - } - - try { - return (T[]) method.invoke((Object[]) null); - } catch (IllegalAccessException ex) { - // This shouldn't happen because the method is "accessible." - throw new Error(ex); - } catch (InvocationTargetException ex) { - Throwable te = ex.getTargetException(); - if (te instanceof RuntimeException) { - throw (RuntimeException) te; - } else if (te instanceof Error) { - throw (Error) te; - } else { - throw new Error(te); - } - } - } - - /** - * Gets the reflection access object. This uses reflection to do - * so. My head is spinning. - * - * @return non-null; the reflection access object - */ - private static ReflectionAccess getReflectionAccess() { - /* - * Note: We can't do AccessibleObject.class.getCache() to - * get the cache, since that would cause a circularity in - * initialization. So instead, we do a direct call into the - * native side. - */ - Method[] methods = - Class.getDeclaredMethods(AccessibleObject.class, false); - - try { - Method method = findMethodByName(methods, "getReflectionAccess", - (Class[]) null); - Class.setAccessibleNoCheck(method, true); - return (ReflectionAccess) method.invoke((Object[]) null); - } catch (NoSuchMethodException ex) { - /* - * This shouldn't happen because the method - * AccessibleObject.getReflectionAccess() really is defined - * in this module. - */ - throw new Error(ex); - } catch (IllegalAccessException ex) { - // This shouldn't happen because the method is "accessible." - throw new Error(ex); - } catch (InvocationTargetException ex) { - throw new Error(ex); - } - } - - /** - * Comparator class for enumerated values. It compares strictly - * by name. - */ - private static class EnumComparator implements Comparator> { - public int compare(Enum e1, Enum e2) { - return e1.name().compareTo(e2.name()); - } - } -} diff --git a/libcore/luni-kernel/src/main/java/java/lang/ClassLoader.java b/libcore/luni-kernel/src/main/java/java/lang/ClassLoader.java deleted file mode 100644 index 3c2e911c2..000000000 --- a/libcore/luni-kernel/src/main/java/java/lang/ClassLoader.java +++ /dev/null @@ -1,1139 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.lang; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.nio.ByteBuffer; -import java.security.ProtectionDomain; -import java.util.Collection; -import java.util.Enumeration; -import java.util.Map; -import java.util.HashMap; - -import dalvik.system.PathClassLoader; -import dalvik.system.VMStack; - -/** - * Loads classes and resources from a repository. One or more class loaders are - * installed at runtime. These are consulted whenever the runtime system needs a - * specific class that is not yet available in-memory. Typically, class loaders - * are grouped into a tree where child class loaders delegate all requests to - * parent class loaders. Only if the parent class loader cannot satisfy the - * request, the child class loader itself tries to handle it. - *

- * {@code ClassLoader} is an abstract class that implements the common - * infrastructure required by all class loaders. Android provides several - * concrete implementations of the class, with - * {@link dalvik.system.PathClassLoader} being the one typically used. Other - * applications may implement subclasses of {@code ClassLoader} to provide - * special ways for loading classes. - *

- * - * @since Android 1.0 - * @see Class - */ -public abstract class ClassLoader { - - // BEGIN android-note - /* - * Because of a potential class initialization race between ClassLoader and - * java.lang.System, reproducible when using JDWP with "suspend=y", we defer - * creation of the system class loader until first use. We use a static - * inner class to get synchronization at init time without having to sync on - * every access. - */ - // END android-note - /** - * The 'System' ClassLoader - the one that is responsible for loading - * classes from the classpath. It is not equal to the bootstrap class loader - - * that one handles the built-in classes. - * - * @see #getSystemClassLoader() - */ - static private class SystemClassLoader { - public static ClassLoader loader = ClassLoader.createSystemClassLoader(); - } - - /** - * The parent ClassLoader. - */ - private ClassLoader parent; - - /** - * The packages known to the class loader. - */ - private Map packages = new HashMap(); - - /** - * Create the system class loader. Note this is NOT the bootstrap class - * loader (which is managed by the VM). We use a null value for the parent - * to indicate that the bootstrap loader is our parent. - */ - private static ClassLoader createSystemClassLoader() { - String classPath = System.getProperty("java.class.path", "."); - - // String[] paths = classPath.split(":"); - // URL[] urls = new URL[paths.length]; - // for (int i = 0; i < paths.length; i++) { - // try { - // urls[i] = new URL("file://" + paths[i]); - // } - // catch (Exception ex) { - // ex.printStackTrace(); - // } - // } - // - // return new java.net.URLClassLoader(urls, null); - - // TODO Make this a java.net.URLClassLoader once we have those? - return new PathClassLoader(classPath, BootClassLoader.getInstance()); - } - - /** - * Returns the system class loader. This is the parent for new - * {@code ClassLoader} instances and is typically the class loader used to - * start the application. If a security manager is present and the caller's - * class loader is neither {@code null} nor the same as or an ancestor of - * the system class loader, then this method calls the security manager's - * checkPermission method with a RuntimePermission("getClassLoader") - * permission to ensure that it is ok to access the system class loader. If - * not, a {@code SecurityException} is thrown. - * - * @return the system class loader. - * @throws SecurityException - * if a security manager exists and it does not allow access to - * the system class loader. - * @since Android 1.0 - */ - public static ClassLoader getSystemClassLoader() { - SecurityManager smgr = System.getSecurityManager(); - if (smgr != null) { - ClassLoader caller = VMStack.getCallingClassLoader(); - if (caller != null && !caller.isAncestorOf(SystemClassLoader.loader)) { - smgr.checkPermission(new RuntimePermission("getClassLoader")); - } - } - - return SystemClassLoader.loader; - } - - /** - * Finds the URL of the resource with the specified name. The system class - * loader's resource lookup algorithm is used to find the resource. - * - * @return the {@code URL} object for the requested resource or {@code null} - * if the resource can not be found. - * @param resName - * the name of the resource to find. - * @see Class#getResource - * @since Android 1.0 - */ - public static URL getSystemResource(String resName) { - return SystemClassLoader.loader.getResource(resName); - } - - /** - * Returns an enumeration of URLs for the resource with the specified name. - * The system class loader's resource lookup algorithm is used to find the - * resource. - * - * @return an enumeration of {@code URL} objects containing the requested - * resources. - * @param resName - * the name of the resource to find. - * @throws IOException - * if an I/O error occurs. - * @since Android 1.0 - */ - public static Enumeration getSystemResources(String resName) throws IOException { - return SystemClassLoader.loader.getResources(resName); - } - - /** - * Returns a stream for the resource with the specified name. The system - * class loader's resource lookup algorithm is used to find the resource. - * Basically, the contents of the java.class.path are searched in order, - * looking for a path which matches the specified resource. - * - * @return a stream for the resource or {@code null}. - * @param resName - * the name of the resource to find. - * @see Class#getResourceAsStream - * @since Android 1.0 - */ - public static InputStream getSystemResourceAsStream(String resName) { - return SystemClassLoader.loader.getResourceAsStream(resName); - } - - /** - * Constructs a new instance of this class with the system class loader as - * its parent. - * - * @throws SecurityException - * if a security manager exists and it does not allow the - * creation of a new {@code ClassLoader}. - * @since Android 1.0 - */ - protected ClassLoader() { - this(getSystemClassLoader(), false); - } - - /** - * Constructs a new instance of this class with the specified class loader - * as its parent. - * - * @param parentLoader - * The {@code ClassLoader} to use as the new class loader's - * parent. - * @throws SecurityException - * if a security manager exists and it does not allow the - * creation of new a new {@code ClassLoader}. - * @since Android 1.0 - */ - protected ClassLoader(ClassLoader parentLoader) { - this(parentLoader, false); - } - - /* - * constructor for the BootClassLoader which needs parent to be null. - */ - ClassLoader(ClassLoader parentLoader, boolean nullAllowed) { - SecurityManager smgr = System.getSecurityManager(); - if (smgr != null) { - smgr.checkCreateClassLoader(); - } - - if (parentLoader == null && !nullAllowed) { - throw new NullPointerException( - "Parent ClassLoader may not be null"); - } - - parent = parentLoader; - } - - /** - * Constructs a new class from an array of bytes containing a class - * definition in class file format. - * - * @param classRep - * the memory image of a class file. - * @param offset - * the offset into {@code classRep}. - * @param length - * the length of the class file. - * @return the {@code Class} object created from the specified subset of - * data in {@code classRep}. - * @throws ClassFormatError - * if {@code classRep} does not contain a valid class. - * @throws IndexOutOfBoundsException - * if {@code offset < 0}, {@code length < 0} or if - * {@code offset + length} is greater than the length of - * {@code classRep}. - * @deprecated Use {@link #defineClass(String, byte[], int, int)} - * @since Android 1.0 - */ - @Deprecated - protected final Class defineClass(byte[] classRep, int offset, int length) - throws ClassFormatError { - - return VMClassLoader.defineClass(this, classRep, offset, length, null); - } - - /** - * Constructs a new class from an array of bytes containing a class - * definition in class file format. - * - * @param className - * the expected name of the new class, may be {@code null} if not - * known. - * @param classRep - * the memory image of a class file. - * @param offset - * the offset into {@code classRep}. - * @param length - * the length of the class file. - * @return the {@code Class} object created from the specified subset of - * data in {@code classRep}. - * @throws ClassFormatError - * if {@code classRep} does not contain a valid class. - * @throws IndexOutOfBoundsException - * if {@code offset < 0}, {@code length < 0} or if - * {@code offset + length} is greater than the length of - * {@code classRep}. - * @since Android 1.0 - */ - protected final Class defineClass(String className, byte[] classRep, int offset, int length) - throws ClassFormatError { - - // TODO Define a default ProtectionDomain on first use - return defineClass(className, classRep, offset, length, null); - } - - /** - * Constructs a new class from an array of bytes containing a class - * definition in class file format and assigns the specified protection - * domain to the new class. If the provided protection domain is - * {@code null} then a default protection domain is assigned to the class. - * - * @param className - * the expected name of the new class, may be {@code null} if not - * known. - * @param classRep - * the memory image of a class file. - * @param offset - * the offset into {@code classRep}. - * @param length - * the length of the class file. - * @param protectionDomain - * the protection domain to assign to the loaded class, may be - * {@code null}. - * @return the {@code Class} object created from the specified subset of - * data in {@code classRep}. - * @throws ClassFormatError - * if {@code classRep} does not contain a valid class. - * @throws IndexOutOfBoundsException - * if {@code offset < 0}, {@code length < 0} or if - * {@code offset + length} is greater than the length of - * {@code classRep}. - * @throws NoClassDefFoundError - * if {@code className} is not equal to the name of the class - * contained in {@code classRep}. - * @since Android 1.0 - */ - protected final Class defineClass(String className, byte[] classRep, int offset, int length, - ProtectionDomain protectionDomain) throws java.lang.ClassFormatError { - - return VMClassLoader.defineClass(this, className, classRep, offset, length, - protectionDomain); - } - - /** - * Defines a new class with the specified name, byte code from the byte - * buffer and the optional protection domain. If the provided protection - * domain is {@code null} then a default protection domain is assigned to - * the class. - * - * @param name - * the expected name of the new class, may be {@code null} if not - * known. - * @param b - * the byte buffer containing the byte code of the new class. - * @param protectionDomain - * the protection domain to assign to the loaded class, may be - * {@code null}. - * @return the {@code Class} object created from the data in {@code b}. - * @throws ClassFormatError - * if {@code b} does not contain a valid class. - * @throws NoClassDefFoundError - * if {@code className} is not equal to the name of the class - * contained in {@code b}. - * @since Android 1.0 - */ - protected final Class defineClass(String name, ByteBuffer b, - ProtectionDomain protectionDomain) throws ClassFormatError { - - byte[] temp = new byte[b.remaining()]; - b.get(temp); - return defineClass(name, temp, 0, temp.length, protectionDomain); - } - - /** - * Overridden by subclasses, throws a {@code ClassNotFoundException} by - * default. This method is called by {@code loadClass} after the parent - * {@code ClassLoader} has failed to find a loaded class of the same name. - * - * @param className - * the name of the class to look for. - * @return the {@code Class} object that is found. - * @throws ClassNotFoundException - * if the class cannot be found. - * @since Android 1.0 - */ - protected Class findClass(String className) throws ClassNotFoundException { - throw new ClassNotFoundException(className); - } - - /** - * Returns the class with the specified name if it has already been loaded - * by the virtual machine or {@code null} if it has not yet been loaded. - * - * @param className - * the name of the class to look for. - * @return the {@code Class} object or {@code null} if the requested class - * has not been loaded. - * @since Android 1.0 - */ - protected final Class findLoadedClass(String className) { - ClassLoader loader; - if (this == BootClassLoader.getInstance()) - loader = null; - else - loader = this; - return VMClassLoader.findLoadedClass(loader, className); - } - - /** - * Finds the class with the specified name, loading it using the system - * class loader if necessary. - * - * @param className - * the name of the class to look for. - * @return the {@code Class} object with the requested {@code className}. - * @throws ClassNotFoundException - * if the class can not be found. - * @since Android 1.0 - */ - protected final Class findSystemClass(String className) throws ClassNotFoundException { - return Class.forName(className, false, getSystemClassLoader()); - } - - /** - * Returns this class loader's parent. - * - * @return this class loader's parent or {@code null}. - * @throws SecurityException - * if a security manager exists and it does not allow to - * retrieve the parent class loader. - * @since Android 1.0 - */ - public final ClassLoader getParent() { - SecurityManager smgr = System.getSecurityManager(); - if (smgr != null) { - smgr.checkPermission(new RuntimePermission("getClassLoader")); - } - - return parent; - } - - /** - * Returns the URL of the resource with the specified name. This - * implementation first tries to use the parent class loader to find the - * resource; if this fails then {@link #findResource(String)} is called to - * find the requested resource. - * - * @param resName - * the name of the resource to find. - * @return the {@code URL} object for the requested resource or {@code null} - * if either the resource can not be found or a security manager - * does not allow to access the resource. - * @see Class#getResource - * @since Android 1.0 - */ - public URL getResource(String resName) { - URL resource = null; - - resource = parent.getResource(resName); - - if (resource == null) { - resource = findResource(resName); - } - - return resource; - } - - /** - * Returns an enumeration of URLs for the resource with the specified name. - * This implementation first uses this class loader's parent to find the - * resource, then it calls {@link #findResources(String)} to get additional - * URLs. The returned enumeration contains the {@code URL} objects of both - * find operations. - * - * @return an enumeration of {@code URL} objects for the requested resource. - * @param resName - * the name of the resource to find. - * @throws IOException - * if an I/O error occurs. - * @since Android 1.0 - */ - @SuppressWarnings("unchecked") - public Enumeration getResources(String resName) throws IOException { - - Enumeration first = parent.getResources(resName); - Enumeration second = findResources(resName); - - return new TwoEnumerationsInOne(first, second); - } - - /** - * Returns a stream for the resource with the specified name. See - * {@link #getResource(String)} for a description of the lookup algorithm - * used to find the resource. - * - * @return a stream for the resource or {@code null} if either the resource - * can not be found or a security manager does not allow to access - * the resource. - * @param resName - * the name of the resource to find. - * @see Class#getResourceAsStream - * @since Android 1.0 - */ - public InputStream getResourceAsStream(String resName) { - try { - URL url = getResource(resName); - if (url != null) { - return url.openStream(); - } - } catch (IOException ex) { - // Don't want to see the exception. - } - - return null; - } - - /** - * Loads the class with the specified name. Invoking this method is - * equivalent to calling {@code loadClass(className, false)}. - *

- * Note: In the Android reference implementation, the - * second parameter of {@link #loadClass(String, boolean)} is ignored - * anyway. - *

- * - * @return the {@code Class} object. - * @param className - * the name of the class to look for. - * @throws ClassNotFoundException - * if the class can not be found. - * @since Android 1.0 - */ - public Class loadClass(String className) throws ClassNotFoundException { - return loadClass(className, false); - } - - /** - * Loads the class with the specified name, optionally linking it after - * loading. The following steps are performed: - *
    - *
  1. Call {@link #findLoadedClass(String)} to determine if the requested - * class has already been loaded.
  2. - *
  3. If the class has not yet been loaded: Invoke this method on the - * parent class loader.
  4. - *
  5. If the class has still not been loaded: Call - * {@link #findClass(String)} to find the class.
  6. - *
- *

- * Note: In the Android reference implementation, the - * {@code resolve} parameter is ignored; classes are never linked. - *

- * - * @return the {@code Class} object. - * @param className - * the name of the class to look for. - * @param resolve - * Indicates if the class should be resolved after loading. This - * parameter is ignored on the Android reference implementation; - * classes are not resolved. - * @throws ClassNotFoundException - * if the class can not be found. - * @since Android 1.0 - */ - protected Class loadClass(String className, boolean resolve) throws ClassNotFoundException { - Class clazz = findLoadedClass(className); - - if (clazz == null) { - try { - clazz = parent.loadClass(className, false); - } catch (ClassNotFoundException e) { - // Don't want to see this. - } - - if (clazz == null) { - clazz = findClass(className); - } - } - - return clazz; - } - - /** - * Forces a class to be linked (initialized). If the class has already been - * linked this operation has no effect. - *

- * Note: In the Android reference implementation, this - * method has no effect. - *

- * - * @param clazz - * the class to link. - * @since Android 1.0 - */ - protected final void resolveClass(Class clazz) { - // no-op, doesn't make sense on android. - } - - /** - * Indicates whether this class loader is the system class loader. This - * method must be provided by the virtual machine vendor, as it is used by - * other provided class implementations in this package. A sample - * implementation of this method is provided by the reference - * implementation. This method is used by - * SecurityManager.classLoaderDepth(), currentClassLoader() and - * currentLoadedClass(). Returns true if the receiver is a system class - * loader. - *

- * Note that this method has package visibility only. It is defined here to - * avoid the security manager check in getSystemClassLoader, which would be - * required to implement this method anywhere else. - *

- * - * @return {@code true} if the receiver is a system class loader - * @see Class#getClassLoaderImpl() - */ - final boolean isSystemClassLoader() { - return false; - } - - /** - *

- * Returns true if the receiver is ancestor of another class loader. It also - * returns true if the two class loader are equal. - *

- *

- * Note that this method has package visibility only. It is defined here to - * avoid the security manager check in getParent, which would be required to - * implement this method anywhere else. The method is also required in other - * places where class loaders are accesses. - *

- * - * @param child - * A child candidate - * @return {@code true} if the receiver is ancestor of, or equal to, - * the parameter - */ - final boolean isAncestorOf(ClassLoader child) { - for (ClassLoader current = child; current != null; - current = current.parent) { - if (current == this) { - return true; - } - } - return false; - } - - /** - * Finds the URL of the resource with the specified name. This - * implementation just returns {@code null}; it should be overridden in - * subclasses. - * - * @param resName - * the name of the resource to find. - * @return the {@code URL} object for the requested resource. - * @since Android 1.0 - */ - protected URL findResource(String resName) { - return null; - } - - /** - * Finds an enumeration of URLs for the resource with the specified name. - * This implementation just returns an empty {@code Enumeration}; it should - * be overridden in subclasses. - * - * @param resName - * the name of the resource to find. - * @return an enumeration of {@code URL} objects for the requested resource. - * @throws IOException - * if an I/O error occurs. - * @since Android 1.0 - */ - @SuppressWarnings( { - "unchecked", "unused" - }) - protected Enumeration findResources(String resName) throws IOException { - return EmptyEnumeration.getInstance(); - } - - /** - * Returns the absolute path of the native library with the specified name, - * or {@code null}. If this method returns {@code null} then the virtual - * machine searches the directories specified by the system property - * "java.library.path". - *

- * This implementation always returns {@code null}. - *

- * - * @param libName - * the name of the library to find. - * @return the absolute path of the library. - * @since Android 1.0 - */ - protected String findLibrary(String libName) { - return null; - } - - /** - * Returns the package with the specified name. Package information is - * searched in this class loader. - * - * @param name - * the name of the package to find. - * @return the package with the requested name; {@code null} if the package - * can not be found. - * @since Android 1.0 - */ - protected Package getPackage(String name) { - synchronized (packages) { - Package p = packages.get(name); - return p; - } - } - - /** - * Gets the package with the specified name, searching it in the specified - * class loader. - * - * @param loader - * the class loader to search the package in. - * @param name - * the name of the package to find. - * @return the package with the requested name; {@code null} if the package - * can not be found. - * @since Android 1.0 - */ - static Package getPackage(ClassLoader loader, String name) { - return loader.getPackage(name); - } - - /** - * Returns all the packages known to this class loader. - * - * @return an array with all packages known to this class loader. - * @since Android 1.0 - */ - protected Package[] getPackages() { - synchronized (packages) { - Collection col = packages.values(); - Package[] result = new Package[col.size()]; - col.toArray(result); - return result; - } - } - - /** - * Defines and returns a new {@code Package} using the specified - * information. If {@code sealBase} is {@code null}, the package is left - * unsealed. Otherwise, the package is sealed using this URL. - * - * @param name - * the name of the package. - * @param specTitle - * the title of the specification. - * @param specVersion - * the version of the specification. - * @param specVendor - * the vendor of the specification. - * @param implTitle - * the implementation title. - * @param implVersion - * the implementation version. - * @param implVendor - * the specification vendor. - * @param sealBase - * the URL used to seal this package or {@code null} to leave the - * package unsealed. - * @return the {@code Package} object that has been created. - * @throws IllegalArgumentException - * if a package with the specified name already exists. - * @since Android 1.0 - */ - protected Package definePackage(String name, String specTitle, String specVersion, - String specVendor, String implTitle, String implVersion, String implVendor, URL sealBase) - throws IllegalArgumentException { - - synchronized (packages) { - if (packages.containsKey(name)) { - throw new IllegalArgumentException("Package " + name + " already defined"); - } - - Package newPackage = new Package(name, specTitle, specVersion, specVendor, implTitle, - implVersion, implVendor, sealBase); - - packages.put(name, newPackage); - - return newPackage; - } - } - - /** - * Gets the signers of the specified class. This implementation returns - * {@code null}. - * - * @param c - * the {@code Class} object for which to get the signers. - * @return signers the signers of {@code c}. - * @since Android 1.0 - */ - final Object[] getSigners(Class c) { - return null; - } - - /** - * Sets the signers of the specified class. This implementation does - * nothing. - * - * @param c - * the {@code Class} object for which to set the signers. - * @param signers - * the signers for {@code c}. - * @since Android 1.0 - */ - protected final void setSigners(Class c, Object[] signers) { - return; - } - - /** - *

- * This must be provided by the VM vendor. It is used by - * SecurityManager.checkMemberAccess() with depth = 3. Note that - * checkMemberAccess() assumes the following stack when called:
- *

- * - *
-     *          < user code &gt; <- want this class
-     *          Class.getDeclared*();
-     *          Class.checkMemberAccess();
-     *          SecurityManager.checkMemberAccess(); <- current frame
-     * 
- * - *

- * Returns the ClassLoader of the method (including natives) at the - * specified depth on the stack of the calling thread. Frames representing - * the VM implementation of java.lang.reflect are not included in the list. - *

- * Notes: - *
    - *
  • This method operates on the defining classes of methods on stack. - * NOT the classes of receivers.
  • - *
  • The item at depth zero is the caller of this method
  • - *
- * - * @param depth - * the stack depth of the requested ClassLoader - * @return the ClassLoader at the specified depth - */ - static final ClassLoader getStackClassLoader(int depth) { - Class[] stack = VMStack.getClasses(depth + 1, false); - if(stack.length < depth + 1) { - return null; - } - return stack[depth].getClassLoader(); - } - - /** - * This method must be provided by the VM vendor, as it is called by - * java.lang.System.loadLibrary(). System.loadLibrary() cannot call - * Runtime.loadLibrary() because this method loads the library using the - * ClassLoader of the calling method. Loads and links the library specified - * by the argument. - * - * @param libName - * the name of the library to load - * @param loader - * the classloader in which to load the library - * @throws UnsatisfiedLinkError - * if the library could not be loaded - * @throws SecurityException - * if the library was not allowed to be loaded - *

- * Note: This method does nothing in the Android reference - * implementation. - *

- */ - static void loadLibraryWithClassLoader(String libName, ClassLoader loader) { - return; - } - - /** - * This method must be provided by the VM vendor, as it is called by - * java.lang.System.load(). System.load() cannot call Runtime.load() because - * the library is loaded using the ClassLoader of the calling method. Loads - * and links the library specified by the argument. No security check is - * done. - *

- * Note: This method does nothing in the Android reference - * implementation. - *

- * - * @param libName - * the name of the library to load - * @param loader - * the classloader in which to load the library - * @param libraryPath - * the library path to search, or null - * @throws UnsatisfiedLinkError - * if the library could not be loaded - */ - static void loadLibraryWithPath(String libName, ClassLoader loader, String libraryPath) { - return; - } - - /** - * Sets the assertion status of the class with the specified name. - *

- * Note: This method does nothing in the Android reference - * implementation. - *

- * - * @param cname - * the name of the class for which to set the assertion status. - * @param enable - * the new assertion status. - * @since Android 1.0 - */ - public void setClassAssertionStatus(String cname, boolean enable) { - return; - } - - /** - * Sets the assertion status of the package with the specified name. - *

- * Note: This method does nothing in the Android reference - * implementation. - *

- * - * @param pname - * the name of the package for which to set the assertion status. - * @param enable - * the new assertion status. - * @since Android 1.0 - */ - public void setPackageAssertionStatus(String pname, boolean enable) { - return; - } - - /** - * Sets the default assertion status for this class loader. - *

- * Note: This method does nothing in the Android reference - * implementation. - *

- * - * @param enable - * the new assertion status. - * @since Android 1.0 - */ - public void setDefaultAssertionStatus(boolean enable) { - return; - } - - /** - * Sets the default assertion status for this class loader to {@code false} - * and removes any package default and class assertion status settings. - *

- * Note: This method does nothing in the Android reference - * implementation. - *

- * - * @since Android 1.0 - */ - public void clearAssertionStatus() { - return; - } - - /** - * Returns the assertion status of the named class Returns the assertion - * status of the class or nested class if it has been set. Otherwise returns - * the assertion status of its package or superpackage if that has been set. - * Otherwise returns the default assertion status. Returns 1 for enabled and - * 0 for disabled. - * - * @return the assertion status. - * @param cname - * the name of class. - */ - boolean getClassAssertionStatus(String cname) { - return false; - } - - /** - * Returns the assertion status of the named package Returns the assertion - * status of the named package or superpackage if that has been set. - * Otherwise returns the default assertion status. Returns 1 for enabled and - * 0 for disabled. - * - * @return the assertion status. - * @param pname - * the name of package. - */ - boolean getPackageAssertionStatus(String pname) { - return false; - } - - /** - * Returns the default assertion status - * - * @return the default assertion status. - */ - boolean getDefaultAssertionStatus() { - return false; - } -} - -/* - * Provides a helper class that combines two existing URL enumerations into one. - * It is required for the getResources() methods. Items are fetched from the - * first enumeration until it's empty, then from the second one. - */ -class TwoEnumerationsInOne implements Enumeration { - - private Enumeration first; - - private Enumeration second; - - public TwoEnumerationsInOne(Enumeration first, Enumeration second) { - this.first = first; - this.second = second; - } - - public boolean hasMoreElements() { - return first.hasMoreElements() || second.hasMoreElements(); - } - - public URL nextElement() { - if (first.hasMoreElements()) { - return first.nextElement(); - } else { - return second.nextElement(); - } - } - -} - -/** - * Provides an explicit representation of the boot class loader. It sits at the - * head of the class loader chain and delegates requests to the VM's internal - * class loading mechanism. - */ -class BootClassLoader extends ClassLoader { - - static BootClassLoader instance; - - public static BootClassLoader getInstance() { - if (instance == null) { - instance = new BootClassLoader(); - } - - return instance; - } - - public BootClassLoader() { - super(null, true); - } - - @Override - protected Class findClass(String name) throws ClassNotFoundException { - return VMClassLoader.loadClass(name, false); - } - - @Override - protected URL findResource(String name) { - return VMClassLoader.getResource(name); - } - - @SuppressWarnings("unused") - @Override - protected Enumeration findResources(String resName) throws IOException { - Enumeration result = VMClassLoader.getResources(resName); - - // VMClassLoader doesn't keep the contract for getResources() - if (result == null) { - result = EmptyEnumeration.getInstance(); - } - - return result; - } - - /** - * Returns package information for the given package. Unfortunately, the - * Android BootClassLoader doesn't really have this information, and as a - * non-secure ClassLoader, it isn't even required to, according to the spec. - * Yet, we want to provide it, in order to make all those hopeful callers of - * {@code myClass.getPackage().getName()} happy. Thus we construct a Package - * object the first time it is being requested and fill most of the fields - * with dummy values. The Package object is then put into the ClassLoader's - * Package cache, so we see the same one next time. We don't create Package - * objects for null arguments or for the default package. - *

- * There a limited chance that we end up with multiple Package objects - * representing the same package: It can happen when when a package is - * scattered across different JAR files being loaded by different - * ClassLoaders. Rather unlikely, and given that this whole thing is more or - * less a workaround, probably not worth the effort. - */ - @Override - protected Package getPackage(String name) { - if (name != null && !"".equals(name)) { - synchronized (this) { - Package pack = super.getPackage(name); - - if (pack == null) { - pack = definePackage(name, "Unknown", "0.0", "Unknown", "Unknown", "0.0", - "Unknown", null); - } - - return pack; - } - } - - return null; - } - - @Override - public URL getResource(String resName) { - return findResource(resName); - } - - @Override - protected Class loadClass(String className, boolean resolve) - throws ClassNotFoundException { - Class clazz = findLoadedClass(className); - - if (clazz == null) { - clazz = findClass(className); - } - - return clazz; - } - - @Override - public Enumeration getResources(String resName) throws IOException { - return findResources(resName); - } -} - -/** - * TODO Open issues - Missing / empty methods - Signer stuff - Protection - * domains - Assertions - */ diff --git a/libcore/luni-kernel/src/main/java/java/lang/Compiler.java b/libcore/luni-kernel/src/main/java/java/lang/Compiler.java deleted file mode 100644 index cf41f064c..000000000 --- a/libcore/luni-kernel/src/main/java/java/lang/Compiler.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.lang; - -/** - * Placeholder class for environments which explicitly manage the action of a - * Just In Time (JIT) compiler. This class is usually implemented by - * the virtual machine vendor. The Android reference implementation does not - * (yet) contain such a JIT compiler, though other implementations may choose to - * provide one. - * - * @since Android 1.0 - */ -public final class Compiler { - - /** - * Prevent this class from being instantiated. - */ - private Compiler(){ - //do nothing - } - - /** - * Executes an operation according to the specified command object. This - * method is the low-level interface to the JIT compiler. It may return any - * object or {@code null} if no JIT compiler is available. - * - * @param cmd - * the command object for the JIT compiler. - * @return the result of executing command or {@code null}. - * @since Android 1.0 - */ - public static Object command(Object cmd) { - return null; - } - - /** - * Compiles the specified class using the JIT compiler and indicates if - * compilation has been successful. - * - * @param classToCompile - * java.lang.Class the class to JIT compile - * @return {@code true} if the compilation has been successful; - * {@code false} if it has failed or if there is no JIT compiler - * available. - * @since Android 1.0 - */ - public static boolean compileClass(Class classToCompile) { - return false; - } - - /** - * Compiles all classes whose name matches the specified name using the JIT - * compiler and indicates if compilation has been successful. - * - * @param nameRoot - * the string to match class names with. - * @return {@code true} if the compilation has been successful; - * {@code false} if it has failed or if there is no JIT compiler - * available. - * @since Android 1.0 - */ - public static boolean compileClasses(String nameRoot) { - return false; - } - - /** - * Disables the JIT compiler. - * - * @since Android 1.0 - */ - public static void disable() { - return; - } - - /** - * Enables the JIT compiler. - * - * @since Android 1.0 - */ - public static void enable() { - return; - } - -} diff --git a/libcore/luni-kernel/src/main/java/java/lang/LangAccessImpl.java b/libcore/luni-kernel/src/main/java/java/lang/LangAccessImpl.java deleted file mode 100644 index 44d4aac02..000000000 --- a/libcore/luni-kernel/src/main/java/java/lang/LangAccessImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.lang; - -import org.apache.harmony.kernel.vm.LangAccess; - -/** - * Implementation of bridge into java.lang. - */ -/*package*/ final class LangAccessImpl extends LangAccess { - /** non-null; unique instance of this class */ - /*package*/ static final LangAccessImpl THE_ONE = new LangAccessImpl(); - - /** - * This class is not publicly instantiable. Use {@link #THE_ONE}. - */ - private LangAccessImpl() { - // This space intentionally left blank. - } - - /** {@inheritDoc} */ - public T[] getEnumValuesInOrder(Class clazz) { - ClassCache cache = clazz.getClassCache(); - return cache.getEnumValuesInOrder(); - } - - /** {@inheritDoc} */ - public void unpark(Thread thread) { - thread.unpark(); - } - - /** {@inheritDoc} */ - public void parkFor(long nanos) { - Thread.currentThread().parkFor(nanos); - } - - /** {@inheritDoc} */ - public void parkUntil(long time) { - Thread.currentThread().parkUntil(time); - } -} diff --git a/libcore/luni-kernel/src/main/java/java/lang/Object.java b/libcore/luni-kernel/src/main/java/java/lang/Object.java deleted file mode 100644 index 4fef6092d..000000000 --- a/libcore/luni-kernel/src/main/java/java/lang/Object.java +++ /dev/null @@ -1,368 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.lang; - -/** - * The root class of the Java class hierarchy. All non-primitive types - * (including arrays) inherit either directly or indirectly from this class. - *

- * {@code Object} provides some fundamental methods for accessing the - * {@link Class} of an object, getting its {@link #hashCode()}, or checking - * whether one object {@link #equals(Object)} another. The {@link #toString()} - * method can be used to convert an object reference into a printable string and - * is often overridden in subclasses. - *

- * The {@link #wait()} and {@link #notify()} methods provide a foundation for - * synchronization, acquiring and releasing an internal monitor associated with - * each {@code Object}. - * - * @since Android 1.0 - */ -public class Object { - - /** - * Constructs a new instance of {@code Object}. - * - * @since Android 1.0 - */ - public Object() { - } - - /** - * Creates and returns a copy of this {@code Object}. The default - * implementation returns a so-called "shallow" copy: It creates a new - * instance of the same class and then copies the field values (including - * object references) from this instance to the new instance. A "deep" copy, - * in contrast, would also recursively clone nested objects. A subclass that - * needs to implement this kind of cloning should call {@code super.clone()} - * to create the new instance and then create deep copies of the nested, - * mutable objects. - * - * @return a copy of this object. - * @throws CloneNotSupportedException - * if this object's class does not implement the {@code - * Cloneable} interface. - * @since Android 1.0 - */ - protected Object clone() throws CloneNotSupportedException { - if (!(this instanceof Cloneable)) { - throw new CloneNotSupportedException("Class doesn't implement Cloneable"); - } - - return internalClone((Cloneable) this); - } - - /* - * Native helper method for cloning. - */ - private native Object internalClone(Cloneable o); - - /** - * Compares this instance with the specified object and indicates if they - * are equal. In order to be equal, {@code o} must represent the same object - * as this instance using a class-specific comparison. The general contract - * is that this comparison should be both transitive and reflexive. - *

- * The implementation in {@code Object} returns {@code true} only if {@code - * o} is the exact same object as the receiver (using the == operator for - * comparison). Subclasses often implement {@code equals(Object)} so that - * it takes into account the two object's types and states. - *

- *

- * The general contract for the {@code equals(Object)} and {@link - * #hashCode()} methods is that if {@code equals} returns {@code true} for - * any two objects, then {@code hashCode()} must return the same value for - * these objects. This means that subclasses of {@code Object} usually - * override either both methods or none of them. - *

- * - * @param o - * the object to compare this instance with. - * @return {@code true} if the specified object is equal to this {@code - * Object}; {@code false} otherwise. - * @see #hashCode - * @since Android 1.0 - */ - public boolean equals(Object o) { - return this == o; - } - - /** - * Is called before the object's memory is being reclaimed by the VM. This - * can only happen once the VM has detected, during a run of the garbage - * collector, that the object is no longer reachable by any thread of the - * running application. - *

- * The method can be used to free system resources or perform other cleanup - * before the object is garbage collected. The default implementation of the - * method is empty, which is also expected by the VM, but subclasses can - * override {@code finalize()} as required. Uncaught exceptions which are - * thrown during the execution of this method cause it to terminate - * immediately but are otherwise ignored. - *

- * Note that the VM does guarantee that {@code finalize()} is called at most - * once for any object, but it doesn't guarantee when (if at all) {@code - * finalize()} will be called. For example, object B's {@code finalize()} - * can delay the execution of object A's {@code finalize()} method and - * therefore it can delay the reclamation of A's memory. To be safe, use a - * {@link java.lang.ref.ReferenceQueue}, because it provides more control - * over the way the VM deals with references during garbage collection. - *

- * - * @throws Throwable - * any exception which is raised during finalization; these are - * ignored by the virtual machine. - * @since Android 1.0 - */ - protected void finalize() throws Throwable { - } - - /** - * Returns the unique instance of {@link Class} which represents this - * object's class. Note that {@code getClass()} is a special case in that it - * actually returns {@code Class} where {@code Foo} is the - * erasure of the type of expression {@code getClass()} was called upon. - *

- * As an example, the following code actually compiles, although one might - * think it shouldn't: - *

- *

-     * List l = new ArrayList();
-     * Class c = l.getClass();
-     * 
- * - * @return this object's {@code Class} instance. - * @since Android 1.0 - */ - public final native Class getClass(); - - /** - * Returns an integer hash code for this object. By contract, any two - * objects for which {@code equals(Object)} returns {@code true} must return - * the same hash code value. This means that subclasses of {@code Object} - * usually override both methods or neither method. - * - * @return this object's hash code. - * @see #equals - * @since Android 1.0 - */ - public native int hashCode(); - - /** - * Causes a thread which is waiting on this object's monitor (by means of - * calling one of the {@code wait()} methods) to be woken up. If more than - * one thread is waiting, one of them is chosen at the discretion of the - * virtual machine. The chosen thread will not run immediately. The thread - * that called {@code notify()} has to release the object's monitor first. - * Also, the chosen thread still has to compete against other threads that - * try to synchronize on the same object. - *

- * This method can only be invoked by a thread which owns this object's - * monitor. A thread becomes owner of an object's monitor - *

- *
    - *
  • by executing a synchronized method of that object;
  • - *
  • by executing the body of a {@code synchronized} statement that - * synchronizes on the object;
  • - *
  • by executing a synchronized static method if the object is of type - * {@code Class}.
  • - *
- * - * @see #notifyAll - * @see #wait() - * @see #wait(long) - * @see #wait(long,int) - * @see java.lang.Thread - * @since Android 1.0 - */ - public final native void notify(); - - /** - * Causes all threads which are waiting on this object's monitor (by means - * of calling one of the {@code wait()} methods) to be woken up. The threads - * will not run immediately. The thread that called {@code notify()} has to - * release the object's monitor first. Also, the threads still have to - * compete against other threads that try to synchronize on the same object. - *

- * This method can only be invoked by a thread which owns this object's - * monitor. A thread becomes owner of an object's monitor - *

- *
    - *
  • by executing a synchronized method of that object;
  • - *
  • by executing the body of a {@code synchronized} statement that - * synchronizes on the object;
  • - *
  • by executing a synchronized static method if the object is of type - * {@code Class}.
  • - *
- * - * @throws IllegalMonitorStateException - * if the thread calling this method is not the owner of this - * object's monitor. - * @see #notify - * @see #wait() - * @see #wait(long) - * @see #wait(long,int) - * @see java.lang.Thread - */ - public final native void notifyAll(); - - /** - * Returns a string containing a concise, human-readable description of this - * object. Subclasses are encouraged to override this method and provide an - * implementation that takes into account the object's type and data. The - * default implementation simply concatenates the class name, the '@' sign - * and a hexadecimal representation of the object's {@link #hashCode()}, - * that is, it is equivalent to the following expression: - * - *
-     * getClass().getName() + '@' + Integer.toHexString(hashCode())
-     * 
- * - * @return a printable representation of this object. - * @since Android 1.0 - */ - public String toString() { - return getClass().getName() + '@' + Integer.toHexString(hashCode()); - } - - /** - * Causes the calling thread to wait until another thread calls the {@code - * notify()} or {@code notifyAll()} method of this object. This method can - * only be invoked by a thread which owns this object's monitor; see - * {@link #notify()} on how a thread can become the owner of a monitor. - *

- * A waiting thread can be sent {@code interrupt()} to cause it to - * prematurely stop waiting, so {@code wait} should be called in a loop to - * check that the condition that has been waited for has been met before - * continuing. - *

- *

- * While the thread waits, it gives up ownership of this object's monitor. - * When it is notified (or interrupted), it re-acquires the monitor before - * it starts running. - *

- * - * @throws IllegalMonitorStateException - * if the thread calling this method is not the owner of this - * object's monitor. - * @throws InterruptedException - * if another thread interrupts this thread while it is waiting. - * @see #notify - * @see #notifyAll - * @see #wait(long) - * @see #wait(long,int) - * @see java.lang.Thread - * @since Android 1.0 - */ - public final void wait() throws InterruptedException { - wait(0 ,0); - } - - /** - * Causes the calling thread to wait until another thread calls the {@code - * notify()} or {@code notifyAll()} method of this object or until the - * specified timeout expires. This method can only be invoked by a thread - * which owns this object's monitor; see {@link #notify()} on how a thread - * can become the owner of a monitor. - *

- * A waiting thread can be sent {@code interrupt()} to cause it to - * prematurely stop waiting, so {@code wait} should be called in a loop to - * check that the condition that has been waited for has been met before - * continuing. - *

- *

- * While the thread waits, it gives up ownership of this object's monitor. - * When it is notified (or interrupted), it re-acquires the monitor before - * it starts running. - *

- * - * @param millis - * the maximum time to wait in milliseconds. - * @throws IllegalArgumentException - * if {@code millis < 0}. - * @throws IllegalMonitorStateException - * if the thread calling this method is not the owner of this - * object's monitor. - * @throws InterruptedException - * if another thread interrupts this thread while it is waiting. - * @see #notify - * @see #notifyAll - * @see #wait() - * @see #wait(long,int) - * @see java.lang.Thread - * @since Android 1.0 - */ - public final void wait(long millis) throws InterruptedException { - wait(millis, 0); - } - - /** - * Causes the calling thread to wait until another thread calls the {@code - * notify()} or {@code notifyAll()} method of this object or until the - * specified timeout expires. This method can only be invoked by a thread - * that owns this object's monitor; see {@link #notify()} on how a thread - * can become the owner of a monitor. - *

- * A waiting thread can be sent {@code interrupt()} to cause it to - * prematurely stop waiting, so {@code wait} should be called in a loop to - * check that the condition that has been waited for has been met before - * continuing. - *

- *

- * While the thread waits, it gives up ownership of this object's monitor. - * When it is notified (or interrupted), it re-acquires the monitor before - * it starts running. - *

- * - * @param millis - * the maximum time to wait in milliseconds. - * @param nanos - * the fraction of a millisecond to wait, specified in - * nanoseconds. - * @throws IllegalArgumentException - * if {@code millis < 0}, {@code nanos < 0} or {@code nanos > - * 999999}. - * @throws IllegalMonitorStateException - * if the thread calling this method is not the owner of this - * object's monitor. - * @throws InterruptedException - * if another thread interrupts this thread while it is waiting. - * @see #notify - * @see #notifyAll - * @see #wait() - * @see #wait(long,int) - * @see java.lang.Thread - * @since Android 1.0 - */ - public final native void wait(long millis, int nanos) throws InterruptedException; -} diff --git a/libcore/luni-kernel/src/main/java/java/lang/Package.java b/libcore/luni-kernel/src/main/java/java/lang/Package.java deleted file mode 100644 index 281740499..000000000 --- a/libcore/luni-kernel/src/main/java/java/lang/Package.java +++ /dev/null @@ -1,321 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.lang; - -import dalvik.system.VMStack; - -import java.lang.annotation.Annotation; -import java.lang.reflect.AnnotatedElement; -import java.net.URL; - -/** - * Contains information about a Java package. This includes implementation and - * specification versions. Typically this information is retrieved from the - * manifest. - *

- * Packages are managed by class loaders. All classes loaded by the same loader - * from the same package share a {@code Package} instance. - *

- * @since Android 1.0 - * - * @see java.lang.ClassLoader - */ -public class Package implements AnnotatedElement { - - private final String name, specTitle, specVersion, specVendor, implTitle, - implVersion, implVendor; - private final URL sealBase; - - Package(String name, String specTitle, String specVersion, String specVendor, - String implTitle, String implVersion, String implVendor, URL sealBase) { - this.name = name; - this.specTitle = specTitle; - this.specVersion = specVersion; - this.specVendor = specVendor; - this.implTitle = implTitle; - this.implVersion = implVersion; - this.implVendor = implVendor; - this.sealBase = sealBase; - } - - /** - * Gets the annotation associated with the specified annotation type and - * this package, if present. - * - * @param annotationType - * the annotation type to look for. - * @return an instance of {@link Annotation} or {@code null}. - * @see java.lang.reflect.AnnotatedElement#getAnnotation(java.lang.Class) - * @since Android 1.0 - */ - @SuppressWarnings("unchecked") - public T getAnnotation(Class annotationType) { - Annotation[] list = getAnnotations(); - for (int i = 0; i < list.length; i++) { - if (annotationType.isInstance(list[i])) { - return (T)list[i]; - } - } - - return null; - } - - /** - * Gets all annotations associated with this package, if any. - * - * @return an array of {@link Annotation} instances, which may be empty. - * @see java.lang.reflect.AnnotatedElement#getAnnotations() - * @since Android 1.0 - */ - public Annotation[] getAnnotations() { - return getDeclaredAnnotations(this, true); - } - - /** - * Gets all annotations directly declared on this package, if any. - * - * @return an array of {@link Annotation} instances, which may be empty. - * @see java.lang.reflect.AnnotatedElement#getDeclaredAnnotations() - * @since Android 1.0 - */ - public Annotation[] getDeclaredAnnotations() { - return getDeclaredAnnotations(this, false); - } - - /* - * Returns the list of declared annotations of the given package. - * If no annotations exist, an empty array is returned. - * - * @param pkg the package of interest - * @param publicOnly reflects whether we want only public annotation or all - * of them. - * @return the list of annotations - */ - // TODO(Google) Provide proper (native) implementation. - private static native Annotation[] getDeclaredAnnotations(Package pkg, - boolean publicOnly); - - /** - * Indicates whether the specified annotation is present. - * - * @param annotationType - * the annotation type to look for. - * @return {@code true} if the annotation is present; {@code false} - * otherwise. - * @see java.lang.reflect.AnnotatedElement#isAnnotationPresent(java.lang.Class) - * @since Android 1.0 - */ - public boolean isAnnotationPresent( - Class annotationType) { - return getAnnotation(annotationType) != null; - } - - /** - * Returns the title of the implementation of this package, or {@code null} - * if this is unknown. The format of this string is unspecified. - * - * @return the implementation title, may be {@code null}. - * @since Android 1.0 - */ - public String getImplementationTitle() { - return implTitle; - } - - /** - * Returns the name of the vendor or organization that provides this - * implementation of the package, or {@code null} if this is unknown. The - * format of this string is unspecified. - * - * @return the implementation vendor name, may be {@code null}. - * @since Android 1.0 - */ - public String getImplementationVendor() { - return implVendor; - } - - /** - * Returns the version of the implementation of this package, or {@code - * null} if this is unknown. The format of this string is unspecified. - * - * @return the implementation version, may be {@code null}. - * @since Android 1.0 - */ - public String getImplementationVersion() { - return implVersion; - } - - /** - * Returns the name of this package in the standard dot notation; for - * example: "java.lang". - * - * @return the name of this package. - * @since Android 1.0 - */ - public String getName() { - return name; - } - - /** - * Attempts to locate the requested package in the caller's class loader. If - * no package information can be located, {@code null} is returned. - * - * @param packageName - * the name of the package to find. - * @return the requested package, or {@code null}. - * @see ClassLoader#getPackage(java.lang.String) - * @since Android 1.0 - */ - public static Package getPackage(String packageName) { - ClassLoader classloader = VMStack.getCallingClassLoader(); - return classloader.getPackage(packageName); - } - - /** - * Returns all the packages known to the caller's class loader. - * - * @return all the packages known to the caller's class loader. - * @see ClassLoader#getPackages - * @since Android 1.0 - */ - public static Package[] getPackages() { - ClassLoader classloader = VMStack.getCallingClassLoader(); - return classloader.getPackages(); - } - - /** - * Returns the title of the specification this package implements, or - * {@code null} if this is unknown. - * - * @return the specification title, may be {@code null}. - * @since Android 1.0 - */ - public String getSpecificationTitle() { - return specTitle; - } - - /** - * Returns the name of the vendor or organization that owns and maintains - * the specification this package implements, or {@code null} if this is - * unknown. - * - * @return the specification vendor name, may be {@code null}. - * @since Android 1.0 - */ - public String getSpecificationVendor() { - return specVendor; - } - - /** - * Returns the version of the specification this package implements, or - * {@code null} if this is unknown. The version string is a sequence of - * non-negative integers separated by dots; for example: "1.2.3". - * - * @return the specification version string, may be {@code null}. - * @since Android 1.0 - */ - public String getSpecificationVersion() { - return specVersion; - } - - @Override - public int hashCode() { - return name.hashCode(); - } - - /** - * Indicates whether this package's specification version is compatible with - * the specified version string. Version strings are compared by comparing - * each dot separated part of the version as an integer. - * - * @param version - * the version string to compare against. - * @return {@code true} if the package versions are compatible; {@code - * false} otherwise. - * @throws NumberFormatException - * if this package's version string or the one provided are not - * in the correct format. - * @since Android 1.0 - */ - public boolean isCompatibleWith(String version) - throws NumberFormatException { - String[] requested = version.split("."); - String[] provided = specVersion.split("."); - - for (int i = 0; i < Math.min(requested.length, provided.length); i++) { - int reqNum = Integer.parseInt(requested[i]); - int provNum = Integer.parseInt(provided[i]); - - if (reqNum > provNum) { - return false; - } else if (reqNum < provNum) { - return true; - } - } - - if (requested.length > provided.length) { - return false; - } - - return true; - } - - /** - * Indicates whether this package is sealed. - * - * @return {@code true} if this package is sealed; {@code false} otherwise. - * @since Android 1.0 - */ - public boolean isSealed() { - return sealBase != null; - } - - /** - * Indicates whether this package is sealed with respect to the specified - * URL. - * - * @param url - * the URL to check. - * @return {@code true} if this package is sealed with {@code url}; {@code - * false} otherwise - * @since Android 1.0 - */ - public boolean isSealed(URL url) { - return sealBase != null && sealBase.sameFile(url); - } - - @Override - public String toString() { - return "package " + name; - } -} - diff --git a/libcore/luni-kernel/src/main/java/java/lang/ProcessManager.java b/libcore/luni-kernel/src/main/java/java/lang/ProcessManager.java deleted file mode 100644 index 1e21b5748..000000000 --- a/libcore/luni-kernel/src/main/java/java/lang/ProcessManager.java +++ /dev/null @@ -1,384 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.lang; - -import java.io.File; -import java.io.FileDescriptor; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.lang.ref.ReferenceQueue; -import java.lang.ref.WeakReference; -import java.util.HashMap; -import java.util.Map; -import java.util.Arrays; -import java.util.logging.Logger; -import java.util.logging.Level; - -/** - * Manages child processes. - * - *

Harmony's native implementation (for comparison purposes): - * http://tinyurl.com/3ytwuq - */ -final class ProcessManager { - - /** - * constant communicated from native code indicating that a - * child died, but it was unable to determine the status - */ - private static final int WAIT_STATUS_UNKNOWN = -1; - - /** - * constant communicated from native code indicating that there - * are currently no children to wait for - */ - private static final int WAIT_STATUS_NO_CHILDREN = -2; - - /** - * constant communicated from native code indicating that a wait() - * call returned -1 and set an undocumented (and hence unexpected) errno - */ - private static final int WAIT_STATUS_STRANGE_ERRNO = -3; - - /** - * Initializes native static state. - */ - static native void staticInitialize(); - static { - staticInitialize(); - } - - /** - * Map from pid to Process. We keep weak references to the Process objects - * and clean up the entries when no more external references are left. The - * process objects themselves don't require much memory, but file - * descriptors (associated with stdin/out/err in this case) can be - * a scarce resource. - */ - private final Map processReferences - = new HashMap(); - - /** Keeps track of garbage-collected Processes. */ - private final ProcessReferenceQueue referenceQueue - = new ProcessReferenceQueue(); - - private ProcessManager() { - // Spawn a thread to listen for signals from child processes. - Thread processThread = new Thread(ProcessManager.class.getName()) { - @Override - public void run() { - watchChildren(); - } - }; - processThread.setDaemon(true); - processThread.start(); - } - - /** - * Kills the process with the given ID. - * - * @parm pid ID of process to kill - */ - private static native void kill(int pid) throws IOException; - - /** - * Cleans up after garbage collected processes. Requires the lock on the - * map. - */ - void cleanUp() { - ProcessReference reference; - while ((reference = referenceQueue.poll()) != null) { - synchronized (processReferences) { - processReferences.remove(reference.processId); - } - } - } - - /** - * Listens for signals from processes and calls back to - * {@link #onExit(int,int)}. - */ - native void watchChildren(); - - /** - * Called by {@link #watchChildren()} when a child process exits. - * - * @param pid ID of process that exited - * @param exitValue value the process returned upon exit - */ - void onExit(int pid, int exitValue) { - ProcessReference processReference = null; - - synchronized (processReferences) { - cleanUp(); - if (pid >= 0) { - processReference = processReferences.remove(pid); - } else if (exitValue == WAIT_STATUS_NO_CHILDREN) { - if (processReferences.isEmpty()) { - /* - * There are no eligible children; wait for one to be - * added. The wait() will return due to the - * notifyAll() call below. - */ - try { - processReferences.wait(); - } catch (InterruptedException ex) { - // This should never happen. - throw new AssertionError("unexpected interrupt"); - } - } else { - /* - * A new child was spawned just before we entered - * the synchronized block. We can just fall through - * without doing anything special and land back in - * the native wait(). - */ - } - } else { - // Something weird is happening; abort! - throw new AssertionError("unexpected wait() behavior"); - } - } - - if (processReference != null) { - ProcessImpl process = processReference.get(); - if (process != null) { - process.setExitValue(exitValue); - } - } - } - - /** - * Executes a native process. Fills in in, out, and err and returns the - * new process ID upon success. - */ - static native int exec(String[] commands, String[] environment, - String workingDirectory, FileDescriptor in, FileDescriptor out, - FileDescriptor err) throws IOException; - - /** - * Executes a process and returns an object representing it. - */ - Process exec(String[] commands, String[] environment, - File workingDirectory) throws IOException { - FileDescriptor in = new FileDescriptor(); - FileDescriptor out = new FileDescriptor(); - FileDescriptor err = new FileDescriptor(); - - String workingPath = (workingDirectory == null) - ? null - : workingDirectory.getPath(); - - // Ensure onExit() doesn't access the process map before we add our - // entry. - synchronized (processReferences) { - int pid; - try { - pid = exec(commands, environment, workingPath, in, out, err); - } catch (IOException e) { - IOException wrapper = new IOException("Error running exec()." - + " Commands: " + Arrays.toString(commands) - + " Working Directory: " + workingDirectory - + " Environment: " + Arrays.toString(environment)); - wrapper.initCause(e); - throw wrapper; - } - ProcessImpl process = new ProcessImpl(pid, in, out, err); - ProcessReference processReference - = new ProcessReference(process, referenceQueue); - processReferences.put(pid, processReference); - - /* - * This will wake up the child monitor thread in case there - * weren't previously any children to wait on. - */ - processReferences.notifyAll(); - - return process; - } - } - - static class ProcessImpl extends Process { - - /** Process ID. */ - final int id; - - final InputStream errorStream; - - /** Reads output from process. */ - final InputStream inputStream; - - /** Sends output to process. */ - final OutputStream outputStream; - - /** The process's exit value. */ - Integer exitValue = null; - final Object exitValueMutex = new Object(); - - ProcessImpl(int id, FileDescriptor in, FileDescriptor out, - FileDescriptor err) { - this.id = id; - - this.errorStream = new ProcessInputStream(err); - this.inputStream = new ProcessInputStream(in); - this.outputStream = new ProcessOutputStream(out); - } - - public void destroy() { - try { - kill(this.id); - } catch (IOException e) { - Logger.getLogger(Runtime.class.getName()).log(Level.FINE, - "Failed to destroy process " + id + ".", e); - } - } - - public int exitValue() { - synchronized (exitValueMutex) { - if (exitValue == null) { - throw new IllegalThreadStateException( - "Process has not yet terminated."); - } - - return exitValue; - } - } - - public InputStream getErrorStream() { - return this.errorStream; - } - - public InputStream getInputStream() { - return this.inputStream; - } - - public OutputStream getOutputStream() { - return this.outputStream; - } - - public int waitFor() throws InterruptedException { - synchronized (exitValueMutex) { - while (exitValue == null) { - exitValueMutex.wait(); - } - return exitValue; - } - } - - void setExitValue(int exitValue) { - synchronized (exitValueMutex) { - this.exitValue = exitValue; - exitValueMutex.notifyAll(); - } - } - - @Override - public String toString() { - return "Process[id=" + id + "]"; - } - } - - static class ProcessReference extends WeakReference { - - final int processId; - - public ProcessReference(ProcessImpl referent, - ProcessReferenceQueue referenceQueue) { - super(referent, referenceQueue); - this.processId = referent.id; - } - } - - static class ProcessReferenceQueue extends ReferenceQueue { - - @Override - public ProcessReference poll() { - // Why couldn't they get the generics right on ReferenceQueue? :( - Object reference = super.poll(); - return (ProcessReference) reference; - } - } - - static final ProcessManager instance = new ProcessManager(); - - /** Gets the process manager. */ - static ProcessManager getInstance() { - return instance; - } - - /** Automatically closes fd when collected. */ - private static class ProcessInputStream extends FileInputStream { - - private FileDescriptor fd; - - private ProcessInputStream(FileDescriptor fd) { - super(fd); - this.fd = fd; - } - - @Override - public void close() throws IOException { - try { - super.close(); - } finally { - synchronized (this) { - if (fd != null && fd.valid()) { - try { - ProcessManager.close(fd); - } finally { - fd = null; - } - } - } - } - } - } - - /** Automatically closes fd when collected. */ - private static class ProcessOutputStream extends FileOutputStream { - - private FileDescriptor fd; - - private ProcessOutputStream(FileDescriptor fd) { - super(fd); - this.fd = fd; - } - - @Override - public void close() throws IOException { - try { - super.close(); - } finally { - synchronized (this) { - if (fd != null && fd.valid()) { - try { - ProcessManager.close(fd); - } finally { - fd = null; - } - } - } - } - } - } - - /** Closes the given file descriptor. */ - private static native void close(FileDescriptor fd) throws IOException; -} diff --git a/libcore/luni-kernel/src/main/java/java/lang/Runtime.java b/libcore/luni-kernel/src/main/java/java/lang/Runtime.java deleted file mode 100644 index 28cc96f0b..000000000 --- a/libcore/luni-kernel/src/main/java/java/lang/Runtime.java +++ /dev/null @@ -1,889 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.lang; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.PipedInputStream; -import java.io.PipedOutputStream; -import java.io.Reader; -import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; -import java.io.Writer; - -import java.util.StringTokenizer; -import java.util.List; -import java.util.ArrayList; - -import dalvik.system.VMDebug; -import dalvik.system.VMStack; - -/** - * Allows Java applications to interface with the environment in which they are - * running. Applications can not create an instance of this class, but they can - * get a singleton instance by invoking {@link #getRuntime()}. - * - * @see System - * - * @since Android 1.0 - */ -public class Runtime { - - /** - * Holds the Singleton global instance of Runtime. - */ - private static final Runtime mRuntime = new Runtime(); - - /** - * Holds the library paths, used for native library lookup. - */ - private final String[] mLibPaths; - - /** - * Holds the list of threads to run when the VM terminates - */ - private List shutdownHooks = new ArrayList(); - - /** - * Reflects whether finalization should be run for all objects - * when the VM terminates. - */ - private static boolean finalizeOnExit; - - /** - * Reflects whether we are already shutting down the VM. - */ - private boolean shuttingDown; - - /** - * Reflects whether we are tracing method calls. - */ - private boolean tracingMethods; - - /** - * Prevent this class from being instantiated. - */ - private Runtime(){ - String pathList = System.getProperty("java.library.path", "."); - String pathSep = System.getProperty("path.separator", ":"); - String fileSep = System.getProperty("file.separator", "/"); - - mLibPaths = pathList.split(pathSep); - - int i; - - if (false) - System.out.println("Runtime paths:"); - - // Add a '/' to the end so we don't have to do the property lookup - // and concatenation later. - for (i = 0; i < mLibPaths.length; i++) { - if (!mLibPaths[i].endsWith(fileSep)) - mLibPaths[i] += fileSep; - if (false) - System.out.println(" " + mLibPaths[i]); - } - } - - /** - * Executes the specified command and its arguments in a separate native - * process. The new process inherits the environment of the caller. Calling - * this method is equivalent to calling {@code exec(progArray, null, null)}. - * - * @param progArray - * the array containing the program to execute as well as any - * arguments to the program. - * @return the new {@code Process} object that represents the native - * process. - * @throws IOException - * if the requested program can not be executed. - * @throws SecurityException - * if the current {@code SecurityManager} disallows program - * execution. - * @see SecurityManager#checkExec - * @since Android 1.0 - */ - public Process exec(String[] progArray) throws java.io.IOException { - return exec(progArray, null, null); - } - - /** - * Executes the specified command and its arguments in a separate native - * process. The new process uses the environment provided in {@code envp}. - * Calling this method is equivalent to calling - * {@code exec(progArray, envp, null)}. - * - * @param progArray - * the array containing the program to execute as well as any - * arguments to the program. - * @param envp - * the array containing the environment to start the new process - * in. - * @return the new {@code Process} object that represents the native - * process. - * @throws IOException - * if the requested program can not be executed. - * @throws SecurityException - * if the current {@code SecurityManager} disallows program - * execution. - * @see SecurityManager#checkExec - * @since Android 1.0 - */ - public Process exec(String[] progArray, String[] envp) throws java.io.IOException { - return exec(progArray, envp, null); - } - - /** - * Executes the specified command and its arguments in a separate native - * process. The new process uses the environment provided in {@code envp} - * and the working directory specified by {@code directory}. - * - * @param progArray - * the array containing the program to execute as well as any - * arguments to the program. - * @param envp - * the array containing the environment to start the new process - * in. - * @param directory - * the directory in which to execute the program. If {@code null}, - * execute if in the same directory as the parent process. - * @return the new {@code Process} object that represents the native - * process. - * @throws IOException - * if the requested program can not be executed. - * @throws SecurityException - * if the current {@code SecurityManager} disallows program - * execution. - * @see SecurityManager#checkExec - * @since Android 1.0 - */ - public Process exec(String[] progArray, String[] envp, File directory) - throws java.io.IOException { - - // Sanity checks - if (progArray == null) { - throw new NullPointerException(); - } else if (progArray.length == 0) { - throw new IndexOutOfBoundsException(); - } else { - for (int i = 0; i < progArray.length; i++) { - if (progArray[i] == null) { - throw new NullPointerException(); - } - } - } - - if (envp != null) { - for (int i = 0; i < envp.length; i++) { - if (envp[i] == null) { - throw new NullPointerException(); - } - } - } - - // Security checks - SecurityManager smgr = System.getSecurityManager(); - if (smgr != null) { - smgr.checkExec(progArray[0]); - } - - // Delegate the execution - return ProcessManager.getInstance().exec(progArray, envp, directory); - } - - /** - * Executes the specified program in a separate native process. The new - * process inherits the environment of the caller. Calling this method is - * equivalent to calling {@code exec(prog, null, null)}. - * - * @param prog - * the name of the program to execute. - * @return the new {@code Process} object that represents the native - * process. - * @throws IOException - * if the requested program can not be executed. - * @throws SecurityException - * if the current {@code SecurityManager} disallows program - * execution. - * @see SecurityManager#checkExec - * @since Android 1.0 - */ - public Process exec(String prog) throws java.io.IOException { - return exec(prog, null, null); - } - - /** - * Executes the specified program in a separate native process. The new - * process uses the environment provided in {@code envp}. Calling this - * method is equivalent to calling {@code exec(prog, envp, null)}. - * - * @param prog - * the name of the program to execute. - * @param envp - * the array containing the environment to start the new process - * in. - * @return the new {@code Process} object that represents the native - * process. - * @throws IOException - * if the requested program can not be executed. - * @throws SecurityException - * if the current {@code SecurityManager} disallows program - * execution. - * @see SecurityManager#checkExec - * @since Android 1.0 - */ - public Process exec(String prog, String[] envp) throws java.io.IOException { - return exec(prog, envp, null); - } - - /** - * Executes the specified program in a separate native process. The new - * process uses the environment provided in {@code envp} and the working - * directory specified by {@code directory}. - * - * @param prog - * the name of the program to execute. - * @param envp - * the array containing the environment to start the new process - * in. - * @param directory - * the directory in which to execute the program. If {@code null}, - * execute if in the same directory as the parent process. - * @return the new {@code Process} object that represents the native - * process. - * @throws IOException - * if the requested program can not be executed. - * @throws SecurityException - * if the current {@code SecurityManager} disallows program - * execution. - * @see SecurityManager#checkExec - * @since Android 1.0 - */ - public Process exec(String prog, String[] envp, File directory) throws java.io.IOException { - // Sanity checks - if (prog == null) { - throw new NullPointerException(); - } else if (prog.length() == 0) { - throw new IllegalArgumentException(); - } - - // Break down into tokens, as described in Java docs - StringTokenizer tokenizer = new StringTokenizer(prog); - int length = tokenizer.countTokens(); - String[] progArray = new String[length]; - for (int i = 0; i < length; i++) { - progArray[i] = tokenizer.nextToken(); - } - - // Delegate - return exec(progArray, envp, directory); - } - - /** - * Causes the virtual machine to stop running and the program to exit. If - * {@link #runFinalizersOnExit(boolean)} has been previously invoked with a - * {@code true} argument, then all all objects will be properly - * garbage-collected and finalized first. - * - * @param code - * the return code. By convention, non-zero return codes indicate - * abnormal terminations. - * @throws SecurityException - * if the current {@code SecurityManager} does not allow the - * running thread to terminate the virtual machine. - * @see SecurityManager#checkExit - * @since Android 1.0 - */ - public void exit(int code) { - // Security checks - SecurityManager smgr = System.getSecurityManager(); - if (smgr != null) { - smgr.checkExit(code); - } - - // Make sure we don't try this several times - synchronized(this) { - if (!shuttingDown) { - shuttingDown = true; - - Thread[] hooks; - synchronized (shutdownHooks) { - // create a copy of the hooks - hooks = new Thread[shutdownHooks.size()]; - shutdownHooks.toArray(hooks); - } - - // Start all shutdown hooks concurrently - for (int i = 0; i < hooks.length; i++) { - hooks[i].start(); - } - - // Wait for all shutdown hooks to finish - for (Thread hook : hooks) { - try { - hook.join(); - } catch (InterruptedException ex) { - // Ignore, since we are at VM shutdown. - } - } - - // Ensure finalization on exit, if requested - if (finalizeOnExit) { - runFinalization(true); - } - - // Get out of here finally... - nativeExit(code, true); - } - } - } - - /** - * Returns the amount of free memory resources which are available to the - * running program. - * - * @return the approximate amount of free memory, measured in bytes. - * @since Android 1.0 - */ - public native long freeMemory(); - - /** - * Indicates to the virtual machine that it would be a good time to run the - * garbage collector. Note that this is a hint only. There is no guarantee - * that the garbage collector will actually be run. - * - * @since Android 1.0 - */ - public native void gc(); - - /** - * Returns the single {@code Runtime} instance. - * - * @return the {@code Runtime} object for the current application. - * @since Android 1.0 - */ - public static Runtime getRuntime() { - return mRuntime; - } - - /** - * Loads and links the dynamic library that is identified through the - * specified path. This method is similar to {@link #loadLibrary(String)}, - * but it accepts a full path specification whereas {@code loadLibrary} just - * accepts the name of the library to load. - * - * @param pathName - * the absolute (platform dependent) path to the library to load. - * @throws UnsatisfiedLinkError - * if the library can not be loaded. - * @throws SecurityException - * if the current {@code SecurityManager} does not allow to load - * the library. - * @see SecurityManager#checkLink - * @since Android 1.0 - */ - public void load(String pathName) { - // Security checks - SecurityManager smgr = System.getSecurityManager(); - if (smgr != null) { - smgr.checkLink(pathName); - } - - load(pathName, VMStack.getCallingClassLoader()); - } - - /* - * Loads and links a library without security checks. - */ - void load(String filename, ClassLoader loader) { - if (filename == null) { - throw new NullPointerException("library path was null."); - } - if (!nativeLoad(filename, loader)) { - throw new UnsatisfiedLinkError( - "Library " + filename + " not found"); - } - } - - /** - * Loads and links the library with the specified name. The mapping of the - * specified library name to the full path for loading the library is - * implementation-dependent. - * - * @param libName - * the name of the library to load. - * @throws UnsatisfiedLinkError - * if the library can not be loaded. - * @throws SecurityException - * if the current {@code SecurityManager} does not allow to load - * the library. - * @see SecurityManager#checkLink - * @since Android 1.0 - */ - public void loadLibrary(String libName) { - // Security checks - SecurityManager smgr = System.getSecurityManager(); - if (smgr != null) { - smgr.checkLink(libName); - } - - loadLibrary(libName, VMStack.getCallingClassLoader()); - } - - /* - * Loads and links a library without security checks. - */ - void loadLibrary(String libname, ClassLoader loader) { - String filename; - int i; - - if (loader != null) { - filename = loader.findLibrary(libname); - if (filename != null && nativeLoad(filename, loader)) - return; - // else fall through to exception - } else { - filename = System.mapLibraryName(libname); - for (i = 0; i < mLibPaths.length; i++) { - if (false) - System.out.println("Trying " + mLibPaths[i] + filename); - if (nativeLoad(mLibPaths[i] + filename, loader)) - return; - } - } - - throw new UnsatisfiedLinkError("Library " + libname + " not found"); - } - - private static native void nativeExit(int code, boolean isExit); - - private static native boolean nativeLoad(String filename, - ClassLoader loader); - - /** - * Requests proper finalization for all Objects on the heap. - * - * @param forced Decides whether the VM really needs to do this (true) - * or if this is just a suggestion that can safely be ignored - * (false). - */ - private native void runFinalization(boolean forced); - - /** - * Provides a hint to the virtual machine that it would be useful to attempt - * to perform any outstanding object finalizations. - * - * @since Android 1.0 - */ - public void runFinalization() { - runFinalization(false); - } - - /** - * Sets the flag that indicates whether all objects are finalized when the - * virtual machine is about to exit. Note that all finalization which occurs - * when the system is exiting is performed after all running threads have - * been terminated. - * - * @param run - * {@code true} to enable finalization on exit, {@code false} to - * disable it. - * @deprecated This method is unsafe. - * @since Android 1.0 - */ - @Deprecated - public static void runFinalizersOnExit(boolean run) { - SecurityManager smgr = System.getSecurityManager(); - if (smgr != null) { - smgr.checkExit(0); - } - finalizeOnExit = run; - } - - /** - * Returns the total amount of memory which is available to the running - * program. - * - * @return the total amount of memory, measured in bytes. - * @since Android 1.0 - */ - public native long totalMemory(); - - /** - * Switches the output of debug information for instructions on or off. - * For the Android 1.0 reference implementation, this method does nothing. - * - * @param enable - * {@code true} to switch tracing on, {@code false} to switch it - * off. - * @since Android 1.0 - */ - public void traceInstructions(boolean enable) { - // TODO(Google) Provide some implementation for this. - return; - } - - /** - * Switches the output of debug information for methods on or off. - * - * @param enable - * {@code true} to switch tracing on, {@code false} to switch it - * off. - * @since Android 1.0 - */ - public void traceMethodCalls(boolean enable) { - if (enable != tracingMethods) { - if (enable) { - VMDebug.startMethodTracing(); - } else { - VMDebug.stopMethodTracing(); - } - tracingMethods = enable; - } - } - - /** - * Returns the localized version of the specified input stream. The input - * stream that is returned automatically converts all characters from the - * local character set to Unicode after reading them from the underlying - * stream. - * - * @param stream - * the input stream to localize. - * @return the localized input stream. - * @deprecated Use {@link InputStreamReader}. - * @since Android 1.0 - */ - @Deprecated - public InputStream getLocalizedInputStream(InputStream stream) { - if (System.getProperty("file.encoding", "UTF-8").equals("UTF-8")) { - return stream; - } - return new ReaderInputStream(stream); - } - - /** - * Returns the localized version of the specified output stream. The output - * stream that is returned automatically converts all characters from - * Unicode to the local character set before writing them to the underlying - * stream. - * - * @param stream - * the output stream to localize. - * @return the localized output stream. - * @deprecated Use {@link OutputStreamWriter}. - * @since Android 1.0 - */ - @Deprecated - public OutputStream getLocalizedOutputStream(OutputStream stream) { - if (System.getProperty("file.encoding", "UTF-8").equals("UTF-8")) { - return stream; - } - return new WriterOutputStream(stream ); - } - - /** - * Registers a virtual-machine shutdown hook. A shutdown hook is a - * {@code Thread} that is ready to run, but has not yet been started. All - * registered shutdown hooks will be executed once the virtual machine shuts - * down properly. A proper shutdown happens when either the - * {@link #exit(int)} method is called or the surrounding system decides to - * terminate the application, for example in response to a {@code CTRL-C} or - * a system-wide shutdown. A termination of the virtual machine due to the - * {@link #halt(int)} method, an {@link Error} or a {@code SIGKILL}, in - * contrast, is not considered a proper shutdown. In these cases the - * shutdown hooks will not be run. - *

- * Shutdown hooks are run concurrently and in an unspecified order. Hooks - * failing due to an unhandled exception are not a problem, but the stack - * trace might be printed to the console. Once initiated, the whole shutdown - * process can only be terminated by calling {@code halt()}. - *

- * If {@link #runFinalizersOnExit(boolean)} has been called with a {@code - * true} argument, garbage collection and finalization will take place after - * all hooks are either finished or have failed. Then the virtual machine - * terminates. - *

- * It is recommended that shutdown hooks do not do any time-consuming - * activities, in order to not hold up the shutdown process longer than - * necessary. - * - * @param hook - * the shutdown hook to register. - * @throws IllegalArgumentException - * if the hook has already been started or if it has already - * been registered. - * @throws IllegalStateException - * if the virtual machine is already shutting down. - * @throws SecurityException - * if a SecurityManager is registered and the calling code - * doesn't have the RuntimePermission("shutdownHooks"). - */ - public void addShutdownHook(Thread hook) { - // Sanity checks - if (hook == null) { - throw new NullPointerException("Hook may not be null."); - } - - if (shuttingDown) { - throw new IllegalStateException("VM already shutting down"); - } - - if (hook.hasBeenStarted) { - throw new IllegalArgumentException("Hook has already been started"); - } - - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(new RuntimePermission("shutdownHooks")); - } - - synchronized (shutdownHooks) { - if (shutdownHooks.contains(hook)) { - throw new IllegalArgumentException("Hook already registered."); - } - - shutdownHooks.add(hook); - } - } - - /** - * Unregisters a previously registered virtual machine shutdown hook. - * - * @param hook - * the shutdown hook to remove. - * @return {@code true} if the hook has been removed successfully; {@code - * false} otherwise. - * @throws IllegalStateException - * if the virtual machine is already shutting down. - * @throws SecurityException - * if a SecurityManager is registered and the calling code - * doesn't have the RuntimePermission("shutdownHooks"). - */ - public boolean removeShutdownHook(Thread hook) { - // Sanity checks - if (hook == null) { - throw new NullPointerException("Hook may not be null."); - } - - if (shuttingDown) { - throw new IllegalStateException("VM already shutting down"); - } - - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(new RuntimePermission("shutdownHooks")); - } - - synchronized (shutdownHooks) { - return shutdownHooks.remove(hook); - } - } - - /** - * Causes the virtual machine to stop running, and the program to exit. - * Neither shutdown hooks nor finalizers are run before. - * - * @param code - * the return code. By convention, non-zero return codes indicate - * abnormal terminations. - * @throws SecurityException - * if the current {@code SecurityManager} does not allow the - * running thread to terminate the virtual machine. - * @see SecurityManager#checkExit - * @see #addShutdownHook(Thread) - * @see #removeShutdownHook(Thread) - * @see #runFinalizersOnExit(boolean) - * @since Android 1.0 - */ - public void halt(int code) { - // Security checks - SecurityManager smgr = System.getSecurityManager(); - if (smgr != null) { - smgr.checkExit(code); - } - - // Get out of here... - nativeExit(code, false); - } - - /** - * Returns the number of processors available to the virtual machine. The - * Android reference implementation (currently) always returns 1. - * - * @return the number of available processors, at least 1. - * @since Android 1.0 - */ - public int availableProcessors() { - return 1; - } - - /** - * Returns the maximum amount of memory that may be used by the virtual - * machine, or {@code Long.MAX_VALUE} if there is no such limit. - * - * @return the maximum amount of memory that the virtual machine will try to - * allocate, measured in bytes. - * @since Android 1.0 - */ - public native long maxMemory(); - -} - -/* - * Internal helper class for creating a localized InputStream. A reader - * wrapped in an InputStream. - */ -class ReaderInputStream extends InputStream { - - private Reader reader; - - private Writer writer; - - ByteArrayOutputStream out = new ByteArrayOutputStream(256); - - private byte[] bytes; - - private int nextByte; - - private int numBytes; - - String encoding = System.getProperty("file.encoding", "UTF-8"); - - public ReaderInputStream(InputStream stream) { - try { - reader = new InputStreamReader(stream, "UTF-8"); - writer = new OutputStreamWriter(out, encoding); - } catch (UnsupportedEncodingException e) { - // Should never happen, since UTF-8 and platform encoding must be - // supported. - throw new RuntimeException(e); - } - } - - @Override - public int read() throws IOException { - if (nextByte >= numBytes) { - readBuffer(); - } - - return (numBytes < 0) ? -1 : bytes[nextByte++]; - } - - private void readBuffer() throws IOException { - char[] chars = new char[128]; - int read = reader.read(chars); - if (read < 0) { - numBytes = read; - return; - } - - writer.write(chars, 0, read); - writer.flush(); - bytes = out.toByteArray(); - numBytes = bytes.length; - nextByte = 0; - } - -} - -/* - * Internal helper class for creating a localized OutputStream. A writer - * wrapped in an OutputStream. Bytes are written to characters in big-endian - * fashion. - */ -class WriterOutputStream extends OutputStream { - - private Reader reader; - - private Writer writer; - - private PipedOutputStream out; - - private PipedInputStream pipe; - - private int numBytes; - - private String enc = System.getProperty("file.encoding", "UTF-8"); - - public WriterOutputStream(OutputStream stream) { - try { - // sink - this.writer = new OutputStreamWriter(stream, enc); - - // transcriber - out = new PipedOutputStream(); - pipe = new PipedInputStream(out); - this.reader = new InputStreamReader(pipe, "UTF-8"); - - } catch (UnsupportedEncodingException e) { - // Should never happen, since platform encoding must be supported. - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Override - public void write(int b) throws IOException { - out.write(b); - if( ++numBytes > 256) { - flush(); - numBytes = 0; - } - } - - @Override - public void flush() throws IOException { - out.flush(); - char[] chars = new char[128]; - if (pipe.available() > 0) { - int read = reader.read(chars); - if (read > 0) { - writer.write(chars, 0, read); - } - } - writer.flush(); - } - - @Override - public void close() throws IOException { - out.close(); - flush(); - writer.close(); - } -} diff --git a/libcore/luni-kernel/src/main/java/java/lang/StackTraceElement.java b/libcore/luni-kernel/src/main/java/java/lang/StackTraceElement.java deleted file mode 100644 index 5394ae9ca..000000000 --- a/libcore/luni-kernel/src/main/java/java/lang/StackTraceElement.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.lang; - -import java.io.Serializable; - -/** - * A representation of a single stack frame. Arrays of {@code StackTraceElement} - * are stored in {@link Throwable} objects to represent the whole state of the - * call stack at the time a {@code Throwable} gets thrown. - * - * @see Throwable#getStackTrace() - * @since Android 1.0 - */ -public final class StackTraceElement implements Serializable { - - private static final long serialVersionUID = 6992337162326171013L; - - // BEGIN android-added - private static final int NATIVE_LINE_NUMBER = -2; - // END android-added - - String declaringClass; - - String methodName; - - String fileName; - - int lineNumber; - - /** - * Constructs a new {@code StackTraceElement} for a specified execution - * point. - * - * @param cls - * the fully qualified name of the class where execution is at. - * @param method - * the name of the method where execution is at. - * @param file - * The name of the file where execution is at or {@code null}. - * @param line - * the line of the file where execution is at, a negative number - * if unknown or {@code -2} if the execution is in a native - * method. - * @throws NullPointerException - * if {@code cls} or {@code method} is {@code null}. - * @since Android 1.0 - */ - public StackTraceElement(String cls, String method, String file, int line) { - super(); - if (cls == null || method == null) { - throw new NullPointerException(); - } - declaringClass = cls; - methodName = method; - fileName = file; - lineNumber = line; - } - - /** - *

- * Private, nullary constructor for VM use only. - *

- */ - private StackTraceElement() { - super(); - } - - /** - * Compares this instance with the specified object and indicates if they - * are equal. In order to be equal, the following conditions must be - * fulfilled: - *
    - *
  • {@code obj} must be a stack trace element,
  • - *
  • the method names of this stack trace element and of {@code obj} must - * not be {@code null},
  • - *
  • the class, method and file names as well as the line number of this - * stack trace element and of {@code obj} must be equal.
  • - *
- * - * @param obj - * the object to compare this instance with. - * @return {@code true} if the specified object is equal to this - * {@code StackTraceElement}; {@code false} otherwise. - * @see #hashCode - * @since Android 1.0 - */ - @Override - public boolean equals(Object obj) { - if (!(obj instanceof StackTraceElement)) { - return false; - } - StackTraceElement castObj = (StackTraceElement) obj; - - /* - * Unknown methods are never equal to anything (not strictly to spec, - * but spec does not allow null method/class names) - */ - if ((methodName == null) || (castObj.methodName == null)) { - return false; - } - - if (!getMethodName().equals(castObj.getMethodName())) { - return false; - } - if (!getClassName().equals(castObj.getClassName())) { - return false; - } - String localFileName = getFileName(); - if (localFileName == null) { - if (castObj.getFileName() != null) { - return false; - } - } else { - if (!localFileName.equals(castObj.getFileName())) { - return false; - } - } - if (getLineNumber() != castObj.getLineNumber()) { - return false; - } - - return true; - } - - /** - * Returns the fully qualified name of the class belonging to this - * {@code StackTraceElement}. - * - * @return the fully qualified type name of the class - * @since Android 1.0 - */ - public String getClassName() { - return (declaringClass == null) ? "" : declaringClass; - } - - /** - * Returns the name of the Java source file containing class belonging to - * this {@code StackTraceElement}. - * - * @return the name of the file, or {@code null} if this information is not - * available. - * @since Android 1.0 - */ - public String getFileName() { - return fileName; - } - - /** - * Returns the line number in the source for the class belonging to this - * {@code StackTraceElement}. - * - * @return the line number, or a negative number if this information is not - * available. - * @since Android 1.0 - */ - public int getLineNumber() { - return lineNumber; - } - - /** - * Returns the name of the method belonging to this {@code - * StackTraceElement}. - * - * @return the name of the method, or "" if this information - * is not available. - * @since Android 1.0 - */ - public String getMethodName() { - return (methodName == null) ? "" : methodName; - } - - @Override - public int hashCode() { - /* - * Either both methodName and declaringClass are null, or neither are - * null. - */ - if (methodName == null) { - // all unknown methods hash the same - return 0; - } - // declaringClass never null if methodName is non-null - return methodName.hashCode() ^ declaringClass.hashCode(); - } - - /** - * Indicates if the method name returned by {@link #getMethodName()} is - * implemented as a native method. - * - * @return {@code true} if the method in which this stack trace element is - * executing is a native method; {@code false} otherwise. - * @since Android 1.0 - */ - public boolean isNativeMethod() { - // BEGIN android-changed - return lineNumber == NATIVE_LINE_NUMBER; - // END android-changed - } - - @Override - public String toString() { - StringBuilder buf = new StringBuilder(80); - - buf.append(getClassName()); - buf.append('.'); - buf.append(getMethodName()); - - if (isNativeMethod()) { - buf.append("(Native Method)"); - } else { - String fName = getFileName(); - - if (fName == null) { - buf.append("(Unknown Source)"); - } else { - int lineNum = getLineNumber(); - - buf.append('('); - buf.append(fName); - if (lineNum >= 0) { - buf.append(':'); - buf.append(lineNum); - } - buf.append(')'); - } - } - return buf.toString(); - } -} diff --git a/libcore/luni-kernel/src/main/java/java/lang/System.java b/libcore/luni-kernel/src/main/java/java/lang/System.java deleted file mode 100644 index b97a75a65..000000000 --- a/libcore/luni-kernel/src/main/java/java/lang/System.java +++ /dev/null @@ -1,755 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.lang; - -import java.io.FileDescriptor; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintStream; -import java.nio.channels.Channel; -import java.nio.channels.spi.SelectorProvider; -import java.security.SecurityPermission; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.PropertyPermission; -import java.util.Set; - -import dalvik.system.VMStack; - -/** - * Provides access to system-related information and resources including - * standard input and output. Enables clients to dynamically load native - * libraries. All methods of this class are accessed in a static way and the - * class itself can not be instantiated. - * - * @see Runtime - * - * @since Android 1.0 - */ -public final class System { - - /** - * Default input stream. - * - * @since Android 1.0 - */ - public static final InputStream in; - - /** - * Default output stream. - * - * @since Android 1.0 - */ - public static final PrintStream out; - - /** - * Default error output stream. - * - * @since Android 1.0 - */ - public static final PrintStream err; - - /** - * The System Properties table. - */ - private static Properties systemProperties; - - /** - * The System default SecurityManager. - */ - private static SecurityManager securityManager; - - /** - * Initialize all the slots in System on first use. - */ - static { - /* - * Set up standard in, out, and err. TODO err and out are - * String.ConsolePrintStream. All three are buffered in Harmony. Check - * and possibly change this later. - */ - err = new PrintStream(new FileOutputStream(FileDescriptor.err)); - out = new PrintStream(new FileOutputStream(FileDescriptor.out)); - in = new FileInputStream(FileDescriptor.in); - } - - /** - * Sets the standard input stream to the given user defined input stream. - * - * @param newIn - * the user defined input stream to set as the standard input - * stream. - * @throws SecurityException - * if a {@link SecurityManager} is installed and its {@code - * checkPermission()} method does not allow the change of the - * stream. - * @since Android 1.0 - */ - public static void setIn(InputStream newIn) { - SecurityManager secMgr = System.getSecurityManager(); - if(secMgr != null) { - secMgr.checkPermission(RuntimePermission.permissionToSetIO); - } - setFieldImpl("in", "Ljava/io/InputStream;", newIn); - } - - /** - * Sets the standard output stream to the given user defined output stream. - * - * @param newOut - * the user defined output stream to set as the standard output - * stream. - * @throws SecurityException - * if a {@link SecurityManager} is installed and its {@code - * checkPermission()} method does not allow the change of the - * stream. - * @since Android 1.0 - */ - public static void setOut(java.io.PrintStream newOut) { - SecurityManager secMgr = System.getSecurityManager(); - if(secMgr != null) { - secMgr.checkPermission(RuntimePermission.permissionToSetIO); - } - setFieldImpl("out", "Ljava/io/PrintStream;", newOut); - } - - /** - * Sets the standard error output stream to the given user defined output - * stream. - * - * @param newErr - * the user defined output stream to set as the standard error - * output stream. - * @throws SecurityException - * if a {@link SecurityManager} is installed and its {@code - * checkPermission()} method does not allow the change of the - * stream. - * @since Android 1.0 - */ - public static void setErr(java.io.PrintStream newErr) { - SecurityManager secMgr = System.getSecurityManager(); - if(secMgr != null) { - secMgr.checkPermission(RuntimePermission.permissionToSetIO); - } - setFieldImpl("err", "Ljava/io/PrintStream;", newErr); - } - - /** - * Prevents this class from being instantiated. - */ - private System() { - } - - /** - * Copies the number of {@code length} elements of the Array {@code src} - * starting at the offset {@code srcPos} into the Array {@code dest} at - * the position {@code destPos}. - * - * @param src - * the source array to copy the content. - * @param srcPos - * the starting index of the content in {@code src}. - * @param dest - * the destination array to copy the data into. - * @param destPos - * the starting index for the copied content in {@code dest}. - * @param length - * the number of elements of the {@code array1} content they have - * to be copied. - * @since Android 1.0 - */ - public static native void arraycopy(Object src, int srcPos, Object dest, - int destPos, int length); - - /** - * Returns the current system time in milliseconds since January 1, 1970 - * 00:00:00 UTC. This method shouldn't be used for measuring timeouts or - * other elapsed time measurements, as changing the system time can affect - * the results. - * - * @return the local system time in milliseconds. - * @since Android 1.0 - */ - public static native long currentTimeMillis(); - - /** - * Returns the current timestamp of the most precise timer available on the - * local system. This timestamp can only be used to measure an elapsed - * period by comparing it against another timestamp. It cannot be used as a - * very exact system time expression. - * - * @return the current timestamp in nanoseconds. - * @since Android 1.0 - */ - public static native long nanoTime(); - - /** - * Causes the virtual machine to stop running and the program to exit. If - * {@link #runFinalizersOnExit(boolean)} has been previously invoked with a - * {@code true} argument, then all all objects will be properly - * garbage-collected and finalized first. - * - * @param code - * the return code. - * @throws SecurityException - * if the running thread has not enough permission to exit the - * virtual machine. - * @see SecurityManager#checkExit - * @since Android 1.0 - */ - public static void exit(int code) { - Runtime.getRuntime().exit(code); - } - - /** - * Indicates to the virtual machine that it would be a good time to run the - * garbage collector. Note that this is a hint only. There is no guarantee - * that the garbage collector will actually be run. - * - * @since Android 1.0 - */ - public static void gc() { - Runtime.getRuntime().gc(); - } - - /** - * Returns the value of the environment variable with the given name {@code - * var}. - * - * @param name - * the name of the environment variable. - * @return the value of the specified environment variable or {@code null} - * if no variable exists with the given name. - * @throws SecurityException - * if a {@link SecurityManager} is installed and its {@code - * checkPermission()} method does not allow the querying of - * single environment variables. - * - * @since Android 1.0 - */ - public static String getenv(String name) { - if (name == null) { - throw new NullPointerException(); - } - SecurityManager secMgr = System.getSecurityManager(); - if (secMgr != null) { - secMgr.checkPermission(new RuntimePermission("getenv." + name)); - } - - return getEnvByName(name); - } - - /* - * Returns an environment variable. No security checks are performed. - * @param var the name of the environment variable - * @return the value of the specified environment variable - */ - private static native String getEnvByName(String name); - - /** - * Returns an unmodifiable map of all available environment variables. - * - * @return the map representing all environment variables. - * @throws SecurityException - * if a {@link SecurityManager} is installed and its {@code - * checkPermission()} method does not allow the querying of - * all environment variables. - * @since Android 1.0 - */ - public static Map getenv() { - SecurityManager secMgr = System.getSecurityManager(); - if (secMgr != null) { - secMgr.checkPermission(new RuntimePermission("getenv.*")); - } - - Map map = new HashMap(); - - int index = 0; - String entry = getEnvByIndex(index++); - while (entry != null) { - int pos = entry.indexOf('='); - if (pos != -1) { - map.put(entry.substring(0, pos), entry.substring(pos + 1)); - } - - entry = getEnvByIndex(index++); - } - - return new SystemEnvironment(map); - } - - /* - * Returns an environment variable. No security checks are performed. The - * safe way of traversing the environment is to start at index zero and - * count upwards until a null pointer is encountered. This marks the end of - * the Unix environment. - * @param index the index of the environment variable - * @return the value of the specified environment variable - */ - private static native String getEnvByIndex(int index); - - /** - * Returns the inherited channel from the creator of the current virtual - * machine. - * - * @return the inherited {@link Channel} or {@code null} if none exists. - * @throws IOException - * if an I/O error occurred. - * @see SelectorProvider - * @see SelectorProvider#inheritedChannel() - * @since Android 1.0 - */ - public static Channel inheritedChannel() throws IOException { - return SelectorProvider.provider().inheritedChannel(); - } - - /** - * Returns the system properties. Note that this is not a copy, so that - * changes made to the returned Properties object will be reflected in - * subsequent calls to getProperty and getProperties. - * - * @return the system properties. - * @throws SecurityException - * if a {@link SecurityManager} is installed and its {@code - * checkPropertiesAccess()} method does not allow the operation. - * @since Android 1.0 - */ - public static Properties getProperties() { - SecurityManager secMgr = System.getSecurityManager(); - if (secMgr != null) { - secMgr.checkPropertiesAccess(); - } - - return internalGetProperties(); - } - - /** - * Returns the system properties without any security checks. This is used - * for access from within java.lang. - * - * @return the system properties - */ - static Properties internalGetProperties() { - if (System.systemProperties == null) { - SystemProperties props = new SystemProperties(); - props.preInit(); - props.postInit(); - System.systemProperties = props; - } - - return systemProperties; - } - - /** - * Returns the value of a particular system property or {@code null} if no - * such property exists. - *

- * The properties currently provided by the virtual machine are: - * - *

-     *        java.vendor.url
-     *        java.class.path
-     *        user.home
-     *        java.class.version
-     *        os.version
-     *        java.vendor
-     *        user.dir
-     *        user.timezone
-     *        path.separator
-     *        os.name
-     *        os.arch
-     *        line.separator
-     *        file.separator
-     *        user.name
-     *        java.version
-     *        java.home
-     * 
- * - * @param prop - * the name of the system property to look up. - * @return the value of the specified system property or {@code null} if the - * property doesn't exist. - * @throws SecurityException - * if a {@link SecurityManager} is installed and its {@code - * checkPropertyAccess()} method does not allow the operation. - * @since Android 1.0 - */ - public static String getProperty(String prop) { - return getProperty(prop, null); - } - - /** - * Returns the value of a particular system property. The {@code - * defaultValue} will be returned if no such property has been found. - * - * @param prop - * the name of the system property to look up. - * @param defaultValue - * the return value if the system property with the given name - * does not exist. - * @return the value of the specified system property or the {@code - * defaultValue} if the property does not exist. - * @throws SecurityException - * if a {@link SecurityManager} is installed and its {@code - * checkPropertyAccess()} method does not allow the operation. - * @since Android 1.0 - */ - public static String getProperty(String prop, String defaultValue) { - if (prop.length() == 0) { - throw new IllegalArgumentException(); - } - SecurityManager secMgr = System.getSecurityManager(); - if (secMgr != null) { - secMgr.checkPropertyAccess(prop); - } - - return internalGetProperties().getProperty(prop, defaultValue); - } - - /** - * Sets the value of a particular system property. - * - * @param prop - * the name of the system property to be changed. - * @param value - * the value to associate with the given property {@code prop}. - * @return the old value of the property or {@code null} if the property - * didn't exist. - * @throws SecurityException - * if a security manager exists and write access to the - * specified property is not allowed. - * @since Android 1.0 - */ - public static String setProperty(String prop, String value) { - if (prop.length() == 0) { - throw new IllegalArgumentException(); - } - SecurityManager secMgr = System.getSecurityManager(); - if (secMgr != null) { - secMgr.checkPermission(new PropertyPermission(prop, "write")); - } - return (String)internalGetProperties().setProperty(prop, value); - } - - /** - * Removes a specific system property. - * - * @param key - * the name of the system property to be removed. - * @return the property value or {@code null} if the property didn't exist. - * @throws NullPointerException - * if the argument {@code key} is {@code null}. - * @throws IllegalArgumentException - * if the argument {@code key} is empty. - * @throws SecurityException - * if a security manager exists and write access to the - * specified property is not allowed. - * @since Android 1.0 - */ - public static String clearProperty(String key) { - if (key == null) { - throw new NullPointerException(); - } - if (key.length() == 0) { - throw new IllegalArgumentException(); - } - - SecurityManager secMgr = System.getSecurityManager(); - if (secMgr != null) { - secMgr.checkPermission(new PropertyPermission(key, "write")); - } - return (String)internalGetProperties().remove(key); - } - - /** - * Returns the active security manager. - * - * @return the system security manager object. - * @since Android 1.0 - */ - public static SecurityManager getSecurityManager() { - return securityManager; - } - - /** - * Returns an integer hash code for the parameter. The hash code returned is - * the same one that would be returned by the method {@code - * java.lang.Object.hashCode()}, whether or not the object's class has - * overridden hashCode(). The hash code for {@code null} is {@code 0}. - * - * @param anObject - * the object to calculate the hash code. - * @return the hash code for the given object. - * @see java.lang.Object#hashCode - * @since Android 1.0 - */ - public static native int identityHashCode(Object anObject); - - /** - * Loads the specified file as a dynamic library. - * - * @param pathName - * the path of the file to be loaded. - * @throws SecurityException - * if the library was not allowed to be loaded. - * @since Android 1.0 - */ - public static void load(String pathName) { - SecurityManager smngr = System.getSecurityManager(); - if (smngr != null) { - smngr.checkLink(pathName); - } - Runtime.getRuntime().load(pathName, VMStack.getCallingClassLoader()); - } - - /** - * Loads and links the shared library with the given name {@code libName}. - * The file will be searched in the default directory for shared libraries - * of the local system. - * - * @param libName - * the name of the library to load. - * @throws UnsatisfiedLinkError - * if the library could not be loaded. - * @throws SecurityException - * if the library was not allowed to be loaded. - * @since Android 1.0 - */ - public static void loadLibrary(String libName) { - SecurityManager smngr = System.getSecurityManager(); - if (smngr != null) { - smngr.checkLink(libName); - } - Runtime.getRuntime().loadLibrary(libName, VMStack.getCallingClassLoader()); - } - - /** - * Provides a hint to the virtual machine that it would be useful to attempt - * to perform any outstanding object finalizations. - * - * @since Android 1.0 - */ - public static void runFinalization() { - Runtime.getRuntime().runFinalization(); - } - - /** - * Ensures that, when the virtual machine is about to exit, all objects are - * finalized. Note that all finalization which occurs when the system is - * exiting is performed after all running threads have been terminated. - * - * @param flag - * the flag determines if finalization on exit is enabled. - * @deprecated this method is unsafe. - * @since Android 1.0 - */ - @SuppressWarnings("deprecation") - @Deprecated - public static void runFinalizersOnExit(boolean flag) { - Runtime.runFinalizersOnExit(flag); - } - - /** - * Sets all system properties. - * - * @param p - * the new system property. - * @throws SecurityException - * if a {@link SecurityManager} is installed and its {@code - * checkPropertiesAccess()} method does not allow the operation. - * @since Android 1.0 - */ - public static void setProperties(Properties p) { - SecurityManager secMgr = System.getSecurityManager(); - if (secMgr != null) { - secMgr.checkPropertiesAccess(); - } - - systemProperties = p; - } - - /** - * Sets the active security manager. Note that once the security manager has - * been set, it can not be changed. Attempts to do that will cause a - * security exception. - * - * @param sm - * the new security manager. - * @throws SecurityException - * if the security manager has already been set and if its - * checkPermission method does not allow to redefine the - * security manager. - * @since Android 1.0 - */ - public static void setSecurityManager(final SecurityManager sm) { - if (securityManager != null) { - securityManager.checkPermission(new java.lang.RuntimePermission("setSecurityManager")); - } - - if (sm != null) { - // before the new manager assumed office, make a pass through - // the common operations and let it load needed classes (if any), - // to avoid infinite recursion later on - try { - sm.checkPermission(new SecurityPermission("getProperty.package.access")); - } catch (Exception ignore) { - } - try { - sm.checkPackageAccess("java.lang"); - } catch (Exception ignore) { - } - } - - securityManager = sm; - } - - /** - * Returns the platform specific file name format for the shared library - * named by the argument. - * - * @param userLibName - * the name of the library to look up. - * @return the platform specific filename for the library. - * @since Android 1.0 - */ - public static native String mapLibraryName(String userLibName); - - /** - * Sets the value of the named static field in the receiver to the passed in - * argument. - * - * @param fieldName - * the name of the field to set, one of in, out, or err - * @param stream - * the new value of the field - */ - private static native void setFieldImpl(String fieldName, String signature, Object stream); - -} - -/** - * Internal class holding the System properties. Needed by the Dalvik VM for the - * two native methods. Must not be a local class, since we don't have a System - * instance. - */ -class SystemProperties extends Properties { - // Dummy, just to make the compiler happy. - - native void preInit(); - - native void postInit(); -} - -/** - * Internal class holding the System environment variables. The Java spec - * mandates that this map be read-only, so we wrap our real map into this one - * and make sure no one touches the contents. We also check for null parameters - * and do some (seemingly unnecessary) type casts to fulfill the contract layed - * out in the spec. - */ -class SystemEnvironment implements Map { - - private Map map; - - public SystemEnvironment(Map map) { - this.map = map; - } - - public void clear() { - throw new UnsupportedOperationException("Can't modify environment"); - } - - @SuppressWarnings("cast") - public boolean containsKey(Object key) { - if (key == null) { - throw new NullPointerException(); - } - - return map.containsKey((String)key); - } - - @SuppressWarnings("cast") - public boolean containsValue(Object value) { - if (value == null) { - throw new NullPointerException(); - } - - return map.containsValue((String)value); - } - - public Set entrySet() { - return map.entrySet(); - } - - @SuppressWarnings("cast") - public String get(Object key) { - if (key == null) { - throw new NullPointerException(); - } - - return map.get((String)key); - } - - public boolean isEmpty() { - return map.isEmpty(); - } - - public Set keySet() { - return map.keySet(); - } - - public String put(Object key, Object value) { - throw new UnsupportedOperationException("Can't modify environment"); - } - - public void putAll(Map map) { - throw new UnsupportedOperationException("Can't modify environment"); - } - - public String remove(Object key) { - throw new UnsupportedOperationException("Can't modify environment"); - } - - public int size() { - return map.size(); - } - - public Collection values() { - return map.values(); - } - -} diff --git a/libcore/luni-kernel/src/main/java/java/lang/Thread.java b/libcore/luni-kernel/src/main/java/java/lang/Thread.java deleted file mode 100644 index 4f9f98857..000000000 --- a/libcore/luni-kernel/src/main/java/java/lang/Thread.java +++ /dev/null @@ -1,1597 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.lang; - -import dalvik.system.VMStack; - -import java.security.AccessController; -import java.util.Map; -import java.util.HashMap; - -import org.apache.harmony.security.fortress.SecurityUtils; - -/** - * A {@code Thread} is a concurrent unit of execution. It has its own call stack - * for methods being invoked, their arguments and local variables. Each virtual - * machine instance has at least one main {@code Thread} running when it is - * started; typically, there are several others for housekeeping. The - * application might decide to launch additional {@code Thread}s for specific - * purposes. - *

- * {@code Thread}s in the same VM interact and synchronize by the use of shared - * objects and monitors associated with these objects. Synchronized methods and - * part of the API in {@link Object} also allow {@code Thread}s to cooperate. - *

- * There are basically two main ways of having a {@code Thread} execute - * application code. One is providing a new class that extends {@code Thread} - * and overriding its {@link #run()} method. The other is providing a new - * {@code Thread} instance with a {@link Runnable} object during its creation. - * In both cases, the {@link #start()} method must be called to actually execute - * the new {@code Thread}. - *

- * Each {@code Thread} has an integer priority that basically determines the - * amount of CPU time the {@code Thread} gets. It can be set using the - * {@link #setPriority(int)} method. A {@code Thread} can also be made a daemon, - * which makes it run in the background. The latter also affects VM termination - * behavior: the VM does not terminate automatically as long as there are - * non-daemon threads running. - * - * @see java.lang.Object - * @see java.lang.ThreadGroup - * - * @since Android 1.0 - */ -public class Thread implements Runnable { - - private static final int NANOS_PER_MILLI = 1000000; - - /** Park states */ - private static class ParkState { - /** park state indicating unparked */ - private static final int UNPARKED = 1; - - /** park state indicating preemptively unparked */ - private static final int PREEMPTIVELY_UNPARKED = 2; - - /** park state indicating parked */ - private static final int PARKED = 3; - } - - /** - * A representation of a thread's state. A given thread may only be in one - * state at a time. - * - * @since Android 1.0 - */ - public enum State { - /** - * The thread has been created, but has never been started. - */ - NEW, - /** - * The thread may be run. - */ - RUNNABLE, - /** - * The thread is blocked and waiting for a lock. - */ - BLOCKED, - /** - * The thread is waiting. - */ - WAITING, - /** - * The thread is waiting for a specified amount of time. - */ - TIMED_WAITING, - /** - * The thread has been terminated. - */ - TERMINATED - } - - /** - * The maximum priority value allowed for a thread. - * - * @since Android 1.0 - */ - public final static int MAX_PRIORITY = 10; - - /** - * The minimum priority value allowed for a thread. - * - * @since Android 1.0 - */ - public final static int MIN_PRIORITY = 1; - - /** - * The normal (default) priority value assigned to threads. - * - * @since Android 1.0 - */ - public final static int NORM_PRIORITY = 5; - - /* some of these are accessed directly by the VM; do not rename them */ - volatile VMThread vmThread; - volatile ThreadGroup group; - volatile boolean daemon; - volatile String name; - volatile int priority; - volatile long stackSize; - Runnable target; - private static int count = 0; - - /** - * Holds the thread's ID. We simply count upwards, so - * each Thread has a unique ID. - */ - private long id; - - /** - * Normal thread local values. - */ - ThreadLocal.Values localValues; - - /** - * Inheritable thread local values. - */ - ThreadLocal.Values inheritableValues; - - /** - * Holds the interrupt action for this Thread, if any. - *

- * This is required internally by NIO, so even if it looks like it's - * useless, don't delete it! - */ - private Runnable interruptAction; - - /** - * Holds the class loader for this Thread, in case there is one. - */ - private ClassLoader contextClassLoader; - - /** - * Holds the handler for uncaught exceptions in this Thread, - * in case there is one. - */ - private UncaughtExceptionHandler uncaughtHandler; - - /** - * Holds the default handler for uncaught exceptions, in case there is one. - */ - private static UncaughtExceptionHandler defaultUncaughtHandler; - - /** - * Reflects whether this Thread has already been started. A Thread - * can only be started once (no recycling). Also, we need it to deduce - * the proper Thread status. - */ - boolean hasBeenStarted = false; - - /** the park state of the thread */ - private int parkState = ParkState.UNPARKED; - - /** - * Constructs a new {@code Thread} with no {@code Runnable} object and a - * newly generated name. The new {@code Thread} will belong to the same - * {@code ThreadGroup} as the {@code Thread} calling this constructor. - * - * @see java.lang.ThreadGroup - * @see java.lang.Runnable - * - * @since Android 1.0 - */ - public Thread() { - create(null, null, null, 0); - } - - /** - * Constructs a new {@code Thread} with a {@code Runnable} object and a - * newly generated name. The new {@code Thread} will belong to the same - * {@code ThreadGroup} as the {@code Thread} calling this constructor. - * - * @param runnable - * a {@code Runnable} whose method run will be - * executed by the new {@code Thread} - * - * @see java.lang.ThreadGroup - * @see java.lang.Runnable - * - * @since Android 1.0 - */ - public Thread(Runnable runnable) { - create(null, runnable, null, 0); - } - - /** - * Constructs a new {@code Thread} with a {@code Runnable} object and name - * provided. The new {@code Thread} will belong to the same {@code - * ThreadGroup} as the {@code Thread} calling this constructor. - * - * @param runnable - * a {@code Runnable} whose method run will be - * executed by the new {@code Thread} - * @param threadName - * the name for the {@code Thread} being created - * - * @see java.lang.ThreadGroup - * @see java.lang.Runnable - * - * @since Android 1.0 - */ - public Thread(Runnable runnable, String threadName) { - if (threadName == null) { - throw new NullPointerException(); - } - - create(null, runnable, threadName, 0); - } - - /** - * Constructs a new {@code Thread} with no {@code Runnable} object and the - * name provided. The new {@code Thread} will belong to the same {@code - * ThreadGroup} as the {@code Thread} calling this constructor. - * - * @param threadName - * the name for the {@code Thread} being created - * - * @see java.lang.ThreadGroup - * @see java.lang.Runnable - * - * @since Android 1.0 - */ - public Thread(String threadName) { - if (threadName == null) { - throw new NullPointerException(); - } - - create(null, null, threadName, 0); - } - - /** - * Constructs a new {@code Thread} with a {@code Runnable} object and a - * newly generated name. The new {@code Thread} will belong to the {@code - * ThreadGroup} passed as parameter. - * - * @param group - * {@code ThreadGroup} to which the new {@code Thread} will - * belong - * @param runnable - * a {@code Runnable} whose method run will be - * executed by the new {@code Thread} - * @throws SecurityException - * if group.checkAccess() fails with a - * SecurityException - * @throws IllegalThreadStateException - * if group.destroy() has already been done - * @see java.lang.ThreadGroup - * @see java.lang.Runnable - * @see java.lang.SecurityException - * @see java.lang.SecurityManager - * - * @since Android 1.0 - */ - public Thread(ThreadGroup group, Runnable runnable) { - create(group, runnable, null, 0); - } - - /** - * Constructs a new {@code Thread} with a {@code Runnable} object, the given - * name and belonging to the {@code ThreadGroup} passed as parameter. - * - * @param group - * ThreadGroup to which the new {@code Thread} will belong - * @param runnable - * a {@code Runnable} whose method run will be - * executed by the new {@code Thread} - * @param threadName - * the name for the {@code Thread} being created - * @throws SecurityException - * if group.checkAccess() fails with a - * SecurityException - * @throws IllegalThreadStateException - * if group.destroy() has already been done - * @see java.lang.ThreadGroup - * @see java.lang.Runnable - * @see java.lang.SecurityException - * @see java.lang.SecurityManager - * - * @since Android 1.0 - */ - public Thread(ThreadGroup group, Runnable runnable, String threadName) { - if (threadName == null) { - throw new NullPointerException(); - } - - create(group, runnable, threadName, 0); - } - - /** - * Constructs a new {@code Thread} with no {@code Runnable} object, the - * given name and belonging to the {@code ThreadGroup} passed as parameter. - * - * @param group - * {@code ThreadGroup} to which the new {@code Thread} will belong - * @param threadName - * the name for the {@code Thread} being created - * @throws SecurityException - * if group.checkAccess() fails with a - * SecurityException - * @throws IllegalThreadStateException - * if group.destroy() has already been done - * @see java.lang.ThreadGroup - * @see java.lang.Runnable - * @see java.lang.SecurityException - * @see java.lang.SecurityManager - * - * @since Android 1.0 - */ - public Thread(ThreadGroup group, String threadName) { - if (threadName == null) { - throw new NullPointerException(); - } - - create(group, null, threadName, 0); - } - - /** - * Constructs a new {@code Thread} with a {@code Runnable} object, the given - * name and belonging to the {@code ThreadGroup} passed as parameter. - * - * @param group - * {@code ThreadGroup} to which the new {@code Thread} will - * belong - * @param runnable - * a {@code Runnable} whose method run will be - * executed by the new {@code Thread} - * @param threadName - * the name for the {@code Thread} being created - * @param stackSize - * a stack size for the new {@code Thread}. This has a highly - * platform-dependent interpretation. It may even be ignored - * completely. - * @throws SecurityException - * if group.checkAccess() fails with a - * SecurityException - * @throws IllegalThreadStateException - * if group.destroy() has already been done - * @see java.lang.ThreadGroup - * @see java.lang.Runnable - * @see java.lang.SecurityException - * @see java.lang.SecurityManager - * - * @since Android 1.0 - */ - public Thread(ThreadGroup group, Runnable runnable, String threadName, long stackSize) { - if (threadName == null) { - throw new NullPointerException(); - } - create(group, runnable, threadName, stackSize); - } - - /** - * Package-scope method invoked by Dalvik VM to create "internal" - * threads or attach threads created externally. - * - * Don't call Thread.currentThread(), since there may not be such - * a thing (e.g. for Main). - */ - Thread(ThreadGroup group, String name, int priority, boolean daemon) { - synchronized (Thread.class) { - id = ++Thread.count; - } - - if (name == null) { - this.name = "Thread-" + id; - } else - this.name = name; - - if (group == null) { - throw new InternalError("group not specified"); - } - - this.group = group; - - this.target = null; - this.stackSize = 0; - this.priority = priority; - this.daemon = daemon; - - /* add ourselves to our ThreadGroup of choice */ - this.group.addThread(this); - } - - /** - * Initializes a new, existing Thread object with a runnable object, - * the given name and belonging to the ThreadGroup passed as parameter. - * This is the method that the several public constructors delegate their - * work to. - * - * @param group ThreadGroup to which the new Thread will belong - * @param runnable a java.lang.Runnable whose method run will - * be executed by the new Thread - * @param threadName Name for the Thread being created - * @param stackSize Platform dependent stack size - * @throws SecurityException if group.checkAccess() fails - * with a SecurityException - * @throws IllegalThreadStateException if group.destroy() has - * already been done - * @see java.lang.ThreadGroup - * @see java.lang.Runnable - * @see java.lang.SecurityException - * @see java.lang.SecurityManager - */ - private void create(ThreadGroup group, Runnable runnable, String threadName, long stackSize) { - SecurityManager smgr = System.getSecurityManager(); - if (smgr != null) { - if (group == null) { - group = smgr.getThreadGroup(); - } - - /* - * Freaky security requirement: If the Thread's class is actually - * a subclass of Thread and it tries to override either - * getContextClassLoader() or setContextClassLoader(), the - * SecurityManager has to allow this. - */ - if (getClass() != Thread.class) { - Class[] signature = new Class[] { ClassLoader.class }; - - try { - getClass().getDeclaredMethod("getContextClassLoader", signature); - smgr.checkPermission(new RuntimePermission("enableContextClassLoaderOverride")); - } catch (NoSuchMethodException ex) { - // Ignore. Just interested in the method's existence. - } - - try { - getClass().getDeclaredMethod("setContextClassLoader", signature); - smgr.checkPermission(new RuntimePermission("enableContextClassLoaderOverride")); - } catch (NoSuchMethodException ex) { - // Ignore. Just interested in the method's existence. - } - } - } - - Thread currentThread = Thread.currentThread(); - if (group == null) { - group = currentThread.getThreadGroup(); - } - - group.checkAccess(); - if (group.isDestroyed()) { - throw new IllegalThreadStateException("Group already destroyed"); - } - - this.group = group; - - synchronized (Thread.class) { - id = ++Thread.count; - } - - if (threadName == null) { - this.name = "Thread-" + id; - } else { - this.name = threadName; - } - - this.target = runnable; - this.stackSize = stackSize; - - this.priority = currentThread.getPriority(); - - this.contextClassLoader = currentThread.contextClassLoader; - - // Transfer over InheritableThreadLocals. - if (currentThread.inheritableValues != null) { - inheritableValues - = new ThreadLocal.Values(currentThread.inheritableValues); - } - - // store current AccessControlContext as inherited context for this thread - SecurityUtils.putContext(this, AccessController.getContext()); - - // add ourselves to our ThreadGroup of choice - this.group.addThread(this); - } - - /** - * Returns the number of active {@code Thread}s in the running {@code - * Thread}'s group and its subgroups. - * - * @return the number of {@code Thread}s - * - * @since Android 1.0 - */ - public static int activeCount() { - return currentThread().getThreadGroup().activeCount(); - } - - /** - * Is used for operations that require approval from a SecurityManager. If - * there's none installed, this method is a no-op. If there's a - * SecurityManager installed, {@link SecurityManager#checkAccess(Thread)} is - * called for that SecurityManager. - * - * @throws SecurityException - * if a SecurityManager is installed and it does not allow - * access to the Thread. - * - * @see java.lang.SecurityException - * @see java.lang.SecurityManager - * - * @since Android 1.0 - */ - public final void checkAccess() { - // Forwards the message to the SecurityManager (if there's one) passing - // the receiver as parameter - - SecurityManager currentManager = System.getSecurityManager(); - if (currentManager != null) { - currentManager.checkAccess(this); - } - } - - /** - * Returns the number of stack frames in this thread. - * - * @return Number of stack frames - * @deprecated The results of this call were never well defined. To make - * things worse, it would depend on whether the Thread was - * suspended or not, and suspend was deprecated too. - * - * @since Android 1.0 - */ - @Deprecated - public int countStackFrames() { - return getStackTrace().length; - } - - /** - * Returns the Thread of the caller, that is, the current Thread. - * - * @return the current Thread. - * - * @since Android 1.0 - */ - public static Thread currentThread() { - return VMThread.currentThread(); - } - - /** - * Destroys the receiver without any monitor cleanup. - * - * @deprecated Not implemented. - * - * @since Android 1.0 - */ - @Deprecated - public void destroy() { - throw new NoSuchMethodError("Thread.destroy()"); // TODO Externalize??? - } - - /** - * Prints to the standard error stream a text representation of the current - * stack for this Thread. - * - * @see Throwable#printStackTrace() - * - * @since Android 1.0 - */ - public static void dumpStack() { - new Throwable("stack dump").printStackTrace(); - } - - /** - * Copies an array with all Threads which are in the same ThreadGroup as the - * receiver - and subgroups - into the array threads passed as - * parameter. If the array passed as parameter is too small no exception is - * thrown - the extra elements are simply not copied. - * - * @param threads - * array into which the Threads will be copied - * @return How many Threads were copied over - * @throws SecurityException - * if the installed SecurityManager fails - * {@link SecurityManager#checkAccess(Thread)} - * @see java.lang.SecurityException - * @see java.lang.SecurityManager - * - * @since Android 1.0 - */ - public static int enumerate(Thread[] threads) { - Thread thread = Thread.currentThread(); - thread.checkAccess(); - return thread.getThreadGroup().enumerate(threads); - } - - /** - *

- * Returns the stack traces of all the currently live threads and puts them - * into the given map. - *

- * - * @return A Map of current Threads to StackTraceElement arrays. - * @throws SecurityException - * if the current SecurityManager fails the - * {@link SecurityManager#checkPermission(java.security.Permission)} - * call. - * - * @since Android 1.0 - */ - public static Map getAllStackTraces() { - SecurityManager securityManager = System.getSecurityManager(); - if (securityManager != null) { - securityManager.checkPermission(new RuntimePermission("getStackTrace")); - securityManager.checkPermission(new RuntimePermission("modifyThreadGroup")); - } - - Map map = new HashMap(); - - // Find out how many live threads we have. Allocate a bit more - // space than needed, in case new ones are just being created. - int count = ThreadGroup.mSystem.activeCount(); - Thread[] threads = new Thread[count + count / 2]; - - // Enumerate the threads and collect the stacktraces. - count = ThreadGroup.mSystem.enumerate(threads); - for (int i = 0; i < count; i++) { - map.put(threads[i], threads[i].getStackTrace()); - } - - return map; - } - - /** - * Returns the context ClassLoader for this Thread. - *

- * If the conditions - *

    - *
  1. there is a security manager - *
  2. the caller's class loader is not null - *
  3. the caller's class loader is not the same as the requested - * context class loader and not an ancestor thereof - *
- * are satisfied, a security check for - * RuntimePermission("getClassLoader") is performed first. - * - * @return ClassLoader The context ClassLoader - * @see java.lang.ClassLoader - * @see #getContextClassLoader() - * - * @throws SecurityException - * if the aforementioned security check fails. - * - * @since Android 1.0 - */ - public ClassLoader getContextClassLoader() { - // First, if the conditions - // 1) there is a security manager - // 2) the caller's class loader is not null - // 3) the caller's class loader is not the same as the context - // class loader and not an ancestor thereof - // are satisfied we should perform a security check. - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - ClassLoader calling = VMStack.getCallingClassLoader(); - - if (calling != null && !calling.isAncestorOf(contextClassLoader)) { - sm.checkPermission(new RuntimePermission("getClassLoader")); - } - } - - return contextClassLoader; - } - - /** - * Returns the default exception handler that's executed when uncaught - * exception terminates a thread. - * - * @return an {@link UncaughtExceptionHandler} or null if - * none exists. - * - * @since Android 1.0 - */ - public static UncaughtExceptionHandler getDefaultUncaughtExceptionHandler() { - return defaultUncaughtHandler; - } - - /** - * Returns the thread's identifier. The ID is a positive long - * generated on thread creation, is unique to the thread, and doesn't change - * during the lifetime of the thread; the ID may be reused after the thread - * has been terminated. - * - * @return the thread's ID. - * - * @since Android 1.0 - */ - public long getId() { - return id; - } - - /** - * Returns the name of the Thread. - * - * @return the Thread's name - * - * @since Android 1.0 - */ - public final String getName() { - return name; - } - - /** - * Returns the priority of the Thread. - * - * @return the Thread's priority - * @see Thread#setPriority - * - * @since Android 1.0 - */ - public final int getPriority() { - return priority; - } - - /** - * Returns the a stack trace representing the current execution state of - * this Thread. - *

- * The RuntimePermission("getStackTrace") is checked before - * returning a result. - *

- * - * @return an array of StackTraceElements. - * @throws SecurityException - * if the current SecurityManager fails the - * {@link SecurityManager#checkPermission(java.security.Permission)} - * call. - * - * @since Android 1.0 - */ - public StackTraceElement[] getStackTrace() { - SecurityManager securityManager = System.getSecurityManager(); - if (securityManager != null) { - securityManager.checkPermission(new RuntimePermission("getStackTrace")); - } - - StackTraceElement ste[] = VMStack.getThreadStackTrace(this); - return ste != null ? ste : new StackTraceElement[0]; - } - - /** - * Returns the current state of the Thread. This method is useful for - * monitoring purposes. - * - * @return a {@link State} value. - * - * @since Android 1.0 - */ - public State getState() { - // TODO This is ugly and should be implemented better. - VMThread vmt = this.vmThread; - - // Make sure we have a valid reference to an object. If native code - // deletes the reference we won't run into a null reference later. - VMThread thread = vmThread; - if (thread != null) { - // If the Thread Object became invalid or was not yet started, - // getStatus() will return -1. - int state = thread.getStatus(); - if(state != -1) { - return VMThread.STATE_MAP[state]; - } - } - return hasBeenStarted ? Thread.State.TERMINATED : Thread.State.NEW; - } - - /** - * Returns the ThreadGroup to which this Thread belongs. - * - * @return the Thread's ThreadGroup - * - * @since Android 1.0 - */ - public final ThreadGroup getThreadGroup() { - // TODO This should actually be done at native termination. - if (getState() == Thread.State.TERMINATED) { - return null; - } else { - return group; - } - } - - /** - * Returns the thread's uncaught exception handler. If not explicitly set, - * then the ThreadGroup's handler is returned. If the thread is terminated, - * then null is returned. - * - * @return an {@link UncaughtExceptionHandler} instance or {@code null}. - * - * @since Android 1.0 - */ - public UncaughtExceptionHandler getUncaughtExceptionHandler() { - if (uncaughtHandler != null) - return uncaughtHandler; - else - return group; // ThreadGroup is instance of UEH - } - - /** - * Posts an interrupt request to this {@code Thread}. Unless the caller is - * the {@link #currentThread()}, the method {@code checkAccess()} is called - * for the installed {@code SecurityManager}, if any. This may result in a - * {@code SecurityException} being thrown. The further behavior depends on - * the state of this {@code Thread}: - *