You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gh...@apache.org on 2006/04/27 01:26:01 UTC
svn commit: r397337 [1/11] - in
/incubator/harmony/enhanced/classlib/trunk/modules/jndi: make/common/
src/test/java/com/sun/jndi/url/dir2/ src/test/java/com/sun/jndi/url/nntp/
src/test/java/jndiproperties/ src/test/java/org/ src/test/java/org/apache/
s...
Author: gharley
Date: Wed Apr 26 16:25:54 2006
New Revision: 397337
URL: http://svn.apache.org/viewcvs?rev=397337&view=rev
Log:
Merge all JNDI tests into one package whose name meets naming convention. Other modules to follow.
Added:
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/AllTests.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/AllTests.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/BinaryRefAddrTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/BindingTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CannotProceedExceptionTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompositeNameTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/InitialContextAppTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/InitialContextAppletTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/InitialContextEnvTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/InitialContextLibTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/InitialContextMockTest.java
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/InitialContextSPITest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/InitialContextSysTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/InvalidNameExceptionTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/LinkExceptionTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/LinkLoopExceptionTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/LinkRefTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/MalformedLinkExceptionTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/MockNameParser.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/NameClassPairTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/NamingExceptionTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/NamingExceptionsTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/NoInitialContextExceptionTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/NotContextExceptionTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ReferenceTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ReferralExceptionTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/StringRefAddrTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/directory/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/directory/AllTests.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/directory/AttributeInUseExceptionTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/directory/AttributeModificationExceptionTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/directory/BasicAttributeTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/directory/BasicAttributesTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/directory/InitialDirContextTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/directory/ModificationItemTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/directory/SearchControlsTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/directory/SearchResultTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/event/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/event/AllTests.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/event/MockEventDirContext.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/event/NamingEventTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/event/NamingExceptionEventTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/AllTests.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/ControlFactoryTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/InitialLdapContextTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/LdapReferralExceptionTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/MockControl.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/MockControlFactory.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/MockExtendedRequest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/MockExtendedResponse.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/MockHasControls.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/MockUnsolicitedNotification.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/MockUnsolicitedNotificationListener.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/UnsolicitedNotificationEventTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/ctx1/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/ctx1/MockContextOne.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/ctx2/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/ctx2/MockContextTwo.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/AllTests.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/DirStateFactoryResultTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/DirectoryManagerBuilderTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/DirectoryManagerJCKTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/DirectoryManagerTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/MockResolver.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/NamingManagerBuilderTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/NamingManagerExploreTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/NamingManagerTest.java
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/ResolveResultTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/DazzleActionController.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/HTTP2/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/HTTP2/HTTP2URLContextFactory.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/InvokeRecord.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockActionController.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockApplet.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockContext.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockContextFactory.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirContext.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirContext2.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirContext3.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirContextFactory.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirContextObjectFactory.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirObjectFactory.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirObjectFactoryNoException.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockDirStateFactory.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockInitialContextFactoryBuilder.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockLdapContext.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/MockLdapContextFactory.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/SuccessMockDirStateFactory.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/a_b_c/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/a_b_c/a_b_cURLContextFactory.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/abc/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/abc/abcURLContextFactory.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/dire/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/dire/direURLContextFactory.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/ftp/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/ftp/ftpURLContextFactory.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/http/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/http/httpURLContextFactory.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/https/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/https/httpsURLContextFactory.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/news/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/news/newsURLContextFactory.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mocksuccess/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mocksuccess/http/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mocksuccess/http/httpURLContextFactory.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/FileFilter.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/Log.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/Person.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/util/Util.java (with props)
Removed:
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/tests/
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/jndi/make/common/build.xml
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/com/sun/jndi/url/dir2/dir2URLContextFactory.java
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/com/sun/jndi/url/nntp/nntpURLContextFactory.java
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/app1.properties
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/app2.properties
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/app3.properties
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/lib.properties
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/spi1.properties
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/spi2.properties
Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/make/common/build.xml
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/make/common/build.xml?rev=397337&r1=397336&r2=397337&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/make/common/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/make/common/build.xml Wed Apr 26 16:25:54 2006
@@ -99,13 +99,16 @@
<fileset dir="${hy.jndi.src.test.java}">
<include name="**/*Test.java"/>
- <include name="**/Test*.java"/>
+
+ <!-- Requires further investigation -->
+ <exclude name="**/DirectoryManagerTest.java" />
+
<!--
To make the following two test cases pass,
set forkmode="perTest"
-->
- <exclude name="**/TestNamingManagerBuilder.java" />
- <exclude name="**/TestNamingManager.java" />
+ <exclude name="**/NamingManagerBuilderTest.java" />
+ <exclude name="**/NamingManagerTest.java" />
</fileset>
</batchtest>
</junit>
Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/com/sun/jndi/url/dir2/dir2URLContextFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/com/sun/jndi/url/dir2/dir2URLContextFactory.java?rev=397337&r1=397336&r2=397337&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/com/sun/jndi/url/dir2/dir2URLContextFactory.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/com/sun/jndi/url/dir2/dir2URLContextFactory.java Wed Apr 26 16:25:54 2006
@@ -21,8 +21,8 @@
import javax.naming.directory.Attributes;
import javax.naming.spi.DirObjectFactory;
-import tests.api.javax.naming.spi.TestNamingManager;
-import tests.api.javax.naming.util.Log;
+import org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest;
+import org.apache.harmony.jndi.tests.javax.naming.util.Log;
public class dir2URLContextFactory implements DirObjectFactory {
@@ -117,8 +117,8 @@
*/
public Object getObjectInstance(Object o, Name n, Context c, Hashtable h,
Attributes a) throws Exception {
- TestNamingManager.issueIndicatedExceptions(h);
- if (TestNamingManager.returnNullIndicated(h)) {
+ NamingManagerTest.issueIndicatedExceptions(h);
+ if (NamingManagerTest.returnNullIndicated(h)) {
return null;
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/com/sun/jndi/url/nntp/nntpURLContextFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/com/sun/jndi/url/nntp/nntpURLContextFactory.java?rev=397337&r1=397336&r2=397337&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/com/sun/jndi/url/nntp/nntpURLContextFactory.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/com/sun/jndi/url/nntp/nntpURLContextFactory.java Wed Apr 26 16:25:54 2006
@@ -21,7 +21,7 @@
import javax.naming.Name;
import javax.naming.spi.ObjectFactory;
-import tests.api.javax.naming.spi.TestNamingManager;
+import org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest;
public class nntpURLContextFactory implements ObjectFactory {
@@ -34,8 +34,8 @@
public Object getObjectInstance(Object o, Name n, Context c, Hashtable h)
throws Exception {
- TestNamingManager.issueIndicatedExceptions(h);
- if (TestNamingManager.returnNullIndicated(h)) {
+ NamingManagerTest.issueIndicatedExceptions(h);
+ if (NamingManagerTest.returnNullIndicated(h)) {
return null;
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/app1.properties
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/app1.properties?rev=397337&r1=397336&r2=397337&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/app1.properties (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/app1.properties Wed Apr 26 16:25:54 2006
@@ -15,7 +15,7 @@
# type==F
-java.naming.factory.initial=tests.api.javax.naming.mock.MockContextFactory
+java.naming.factory.initial=org.apache.harmony.jndi.tests.javax.naming.spi.mock.MockContextFactory
java.naming.provider.url=java.naming.provider.url.app1
#java.naming.applet=
java.naming.authoritative=java.naming.authoritative.app1
Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/app2.properties
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/app2.properties?rev=397337&r1=397336&r2=397337&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/app2.properties (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/app2.properties Wed Apr 26 16:25:54 2006
@@ -14,7 +14,7 @@
#app2: ext-classes
# type==F
-java.naming.factory.initial=tests.api.javax.naming.mock.MockContextFactory
+java.naming.factory.initial=org.apache.harmony.jndi.tests.javax.naming.spi.mock.MockContextFactory
java.naming.provider.url=java.naming.provider.url.app2
#java.naming.applet=
java.naming.authoritative=java.naming.authoritative.app2
Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/app3.properties
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/app3.properties?rev=397337&r1=397336&r2=397337&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/app3.properties (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/app3.properties Wed Apr 26 16:25:54 2006
@@ -14,7 +14,7 @@
#app1: /temp/cls1
# type==F
-java.naming.factory.initial=tests.api.javax.naming.mock.MockContextFactory
+java.naming.factory.initial=org.apache.harmony.jndi.tests.javax.naming.spi.mock.MockContextFactory
java.naming.provider.url=java.naming.provider.url.app3
#java.naming.applet=
java.naming.authoritative=java.naming.authoritative.app3
Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/lib.properties
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/lib.properties?rev=397337&r1=397336&r2=397337&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/lib.properties (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/lib.properties Wed Apr 26 16:25:54 2006
@@ -14,7 +14,7 @@
#app1: java.home/lib
# type==F
-java.naming.factory.initial=tests.api.javax.naming.mock.MockContextFactory
+java.naming.factory.initial=org.apache.harmony.jndi.tests.javax.naming.spi.mock.MockContextFactory
java.naming.provider.url=java.naming.provider.url.lib
#java.naming.applet=
java.naming.authoritative=java.naming.authoritative.lib
Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/spi1.properties
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/spi1.properties?rev=397337&r1=397336&r2=397337&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/spi1.properties (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/spi1.properties Wed Apr 26 16:25:54 2006
@@ -14,7 +14,7 @@
#app1: classes/test/dazzle/jndi/testing/spi/jndiprovider.properties
# type==F
-java.naming.factory.initial=tests.api.javax.naming.mock.MockFiveContextFactory
+java.naming.factory.initial=org.apache.harmony.jndi.tests.javax.naming.spi.mock.MockFiveContextFactory
java.naming.provider.url=java.naming.provider.url.spi1
#java.naming.applet=
java.naming.authoritative=java.naming.authoritative.spi1
@@ -28,7 +28,7 @@
java.naming.security.protocol=java.naming.security.protocol.spi1
# type==C
-java.naming.factory.control=tests.api.javax.naming.ldap.MockControlFactory$ControlFactorySPI1
+java.naming.factory.control=org.apache.harmony.jndi.tests.javax.naming.ldap.MockControlFactory$ControlFactorySPI1
java.naming.factory.object=java.naming.factory.object.spi1
java.naming.factory.state=java.naming.factory.state.spi1
java.naming.factory.url.pkgs=java.naming.factory.url.pkgs.spi1
Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/spi2.properties
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/spi2.properties?rev=397337&r1=397336&r2=397337&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/spi2.properties (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/jndiproperties/spi2.properties Wed Apr 26 16:25:54 2006
@@ -14,7 +14,7 @@
#app1: ext-classes/dazzle/jndi/testing/spi/jndiprovider.properties
# type==F
-java.naming.factory.initial=tests.api.javax.naming.mock.MockSixContextFactory
+java.naming.factory.initial=org.apache.harmony.jndi.tests.javax.naming.spi.mock.MockSixContextFactory
java.naming.provider.url=java.naming.provider.url.spi2
#java.naming.applet=
java.naming.authoritative=java.naming.authoritative.spi2
@@ -28,7 +28,7 @@
java.naming.security.protocol=java.naming.security.protocol.spi2
# type==C
-java.naming.factory.control=tests.api.javax.naming.ldap.MockControlFactory$ControlFactorySPI2
+java.naming.factory.control=org.apache.harmony.jndi.tests.javax.naming.ldap.MockControlFactory$ControlFactorySPI2
java.naming.factory.object=java.naming.factory.object.spi2
java.naming.factory.state=java.naming.factory.state.spi2
java.naming.factory.url.pkgs=java.naming.factory.url.pkgs.spi2
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/AllTests.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/AllTests.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/AllTests.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,41 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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.jndi.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Test suite that includes all tests for the JNDI project.
+ */
+public class AllTests {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(AllTests.suite());
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("All JNDI test suites");
+ // $JUnit-BEGIN$
+ suite.addTest(org.apache.harmony.jndi.tests.javax.naming.AllTests.suite());
+ suite.addTest(org.apache.harmony.jndi.tests.javax.naming.directory.AllTests.suite());
+ suite.addTest(org.apache.harmony.jndi.tests.javax.naming.event.AllTests.suite());
+ suite.addTest(org.apache.harmony.jndi.tests.javax.naming.ldap.AllTests.suite());
+ suite.addTest(org.apache.harmony.jndi.tests.javax.naming.spi.AllTests.suite());
+ // $JUnit-END$
+ return suite;
+ }
+}
\ No newline at end of file
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/AllTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/AllTests.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/AllTests.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/AllTests.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,49 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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.jndi.tests.javax.naming;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "Suite for org.apache.harmony.jndi.tests.javax.naming");
+ // $JUnit-BEGIN$
+ suite.addTestSuite(InitialContextMockTest.class);
+ suite.addTestSuite(ReferenceTest.class);
+ suite.addTestSuite(CannotProceedExceptionTest.class);
+ suite.addTestSuite(LinkExceptionTest.class);
+ suite.addTestSuite(LinkRefTest.class);
+ suite.addTestSuite(CompositeNameTest.class);
+ suite.addTestSuite(InvalidNameExceptionTest.class);
+ suite.addTestSuite(NamingExceptionTest.class);
+ suite.addTestSuite(BinaryRefAddrTest.class);
+ suite.addTestSuite(MalformedLinkExceptionTest.class);
+ suite.addTestSuite(NamingExceptionsTest.class);
+ suite.addTestSuite(LinkLoopExceptionTest.class);
+ suite.addTestSuite(BindingTest.class);
+ suite.addTestSuite(NoInitialContextExceptionTest.class);
+ suite.addTestSuite(ReferralExceptionTest.class);
+ suite.addTestSuite(NameClassPairTest.class);
+ suite.addTestSuite(CompoundNameTest.class);
+ suite.addTestSuite(StringRefAddrTest.class);
+ suite.addTestSuite(NotContextExceptionTest.class);
+ // $JUnit-END$
+ return suite;
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/AllTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/BinaryRefAddrTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/BinaryRefAddrTest.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/BinaryRefAddrTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/BinaryRefAddrTest.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,379 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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.jndi.tests.javax.naming;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Random;
+
+import javax.naming.BinaryRefAddr;
+import javax.naming.RefAddr;
+
+import junit.framework.TestCase;
+
+public class BinaryRefAddrTest extends TestCase {
+
+ /**
+ * Constructor for BinaryRefAddr.
+ *
+ * @param arg0
+ */
+ public BinaryRefAddrTest(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testBinaryRefAddr_SimpleNormale() {
+ byte[] ab = new byte[] { 1, 2, 3 };
+ byte[] ab2;
+
+ // Test normal condition
+ BinaryRefAddr addr = new BinaryRefAddr("binary", ab);
+ TestCase.assertNotNull(addr);
+ TestCase.assertEquals("binary", addr.getType());
+ ab2 = (byte[]) addr.getContent();
+ TestCase.assertEquals(ab.length, ab2.length);
+ for (int i = ab2.length - 1; i >= 0; i--) {
+ TestCase.assertEquals(ab[i], ab2[i]);
+ }
+ assertNotSame(ab, ab2);
+ }
+
+ public void testBinaryRefAddr_SimpleNullType() {
+ byte[] ab = new byte[] { 1, 2, 3 };
+ byte[] ab2;
+
+ // Test null "type" parameter
+ BinaryRefAddr addr = new BinaryRefAddr(null, ab);
+ TestCase.assertNotNull(addr);
+ TestCase.assertNull(addr.getType());
+ ab2 = (byte[]) addr.getContent();
+ TestCase.assertEquals(ab.length, ab2.length);
+ for (int i = ab2.length - 1; i >= 0; i--) {
+ TestCase.assertEquals(ab[i], ab2[i]);
+ }
+ }
+
+ public void testBinaryRefAddr_SimpleNullAddress() {
+ BinaryRefAddr addr = null;
+
+ // Test null address content
+ try {
+ addr = new BinaryRefAddr("binary", null);
+ fail("Should throw NullPointerException here.");
+ } catch (NullPointerException e) {
+ }
+ TestCase.assertNull(addr);
+ }
+
+ public void testBinaryRefAddr_ComplexNormal() {
+ byte[] ab = new byte[] { 1, 2, 3 };
+ byte[] ab2;
+
+ // Test normal condition
+ BinaryRefAddr addr = new BinaryRefAddr("binary", ab, 1, 1);
+ TestCase.assertNotNull(addr);
+ TestCase.assertEquals("binary", addr.getType());
+ ab2 = (byte[]) addr.getContent();
+ TestCase.assertEquals(ab2.length, 1);
+ for (int i = ab2.length - 1; i >= 0; i--) {
+ TestCase.assertEquals(ab[i + 1], ab2[i]);
+ }
+ assertNotSame(ab, ab2);
+ }
+
+ public void testBinaryRefAddr_ComplexNullType() {
+ byte[] ab = new byte[] { 1, 2, 3 };
+ byte[] ab2;
+
+ // Test null "type" parameter
+ BinaryRefAddr addr = new BinaryRefAddr(null, ab, 1, 1);
+ TestCase.assertNotNull(addr);
+ TestCase.assertNull(addr.getType());
+ ab2 = (byte[]) addr.getContent();
+ TestCase.assertEquals(ab2.length, 1);
+ for (int i = ab2.length - 1; i >= 0; i--) {
+ TestCase.assertEquals(ab[i + 1], ab2[i]);
+ }
+ }
+
+ public void testBinaryRefAddr_ComplexNullAddress() {
+ BinaryRefAddr addr = null;
+
+ // Test null address content
+ try {
+ addr = new BinaryRefAddr("binary", null, 1, 1);
+ fail("Should throw NullPointerException here.");
+ } catch (NullPointerException e) {
+ }
+ TestCase.assertNull(addr);
+ }
+
+ public void testBinaryRefAddr_TooSmallIndex() {
+ BinaryRefAddr addr = null;
+
+ // Test too small index
+ try {
+ addr = new BinaryRefAddr("binary", new byte[] { 2, 3 }, -1, 1);
+ fail("Should throw ArrayIndexOutOfBoundsException here.");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ }
+ TestCase.assertNull(addr);
+ }
+
+ public void testBinaryRefAddr_TooBigIndex() {
+ BinaryRefAddr addr = null;
+
+ // Test too big index
+ try {
+ addr = new BinaryRefAddr("binary", new byte[] { 2, 3 }, 2, 1);
+ fail("Should throw ArrayIndexOutOfBoundsException here.");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ }
+ TestCase.assertNull(addr);
+ }
+
+ public void testBinaryRefAddr_ComplexZeroSize() {
+ byte[] ab;
+ BinaryRefAddr addr = null;
+
+ // Test zero size
+ addr = new BinaryRefAddr("binary", new byte[] { 2, 3 }, 0, 0);
+ ab = (byte[]) addr.getContent();
+ TestCase.assertEquals(ab.length, 0);
+ TestCase.assertNotNull(addr);
+ }
+
+ public void testBinaryRefAddr_TooSmallSize() {
+ BinaryRefAddr addr = null;
+
+ // Test too small size
+ try {
+ addr = new BinaryRefAddr("binary", new byte[] { 2, 3 }, 0, -1);
+ fail("Should throw NegativeArraySizeException here.");
+ } catch (NegativeArraySizeException e) {
+ }
+ TestCase.assertNull(addr);
+ }
+
+ public void testBinaryRefAddr_TooBigSize() {
+ BinaryRefAddr addr = null;
+
+ // Test too big size
+ try {
+ addr = new BinaryRefAddr("binary", new byte[] { 2, 3 }, 0, 3);
+ fail("Should throw ArrayIndexOutOfBoundsException here.");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ }
+ TestCase.assertNull(addr);
+
+ }
+
+ public void testGetType() {
+ // Test empty type
+ BinaryRefAddr addr = new BinaryRefAddr("", new byte[] { 1 });
+ TestCase.assertEquals("", addr.getType());
+
+ // Other conditions are tested in testBinaryRefAddr_XXX
+ }
+
+ public void testEquals_Simple() {
+ String type = "Binary Address";
+ int count = 10;
+ byte[] address0 = new byte[count];
+ byte[] address1 = new byte[count];
+ Random random = new Random(100);
+ for (int i = 0; i < count; i++) {
+ address0[i] = (byte) random.nextInt();
+ address1[i] = address0[i];
+ }
+ BinaryRefAddr addr0 = new BinaryRefAddr(type, address0);
+ BinaryRefAddr addr1 = new BinaryRefAddr(type, address1);
+ assertTrue(addr0.equals(addr0));
+ assertFalse(addr0.equals(null));
+ assertTrue(addr1.equals(addr0));
+ assertTrue(addr0.equals(addr1));
+ }
+
+ public void testEquals_TypeNull() {
+ int count = 10;
+ byte[] address0 = new byte[count];
+ byte[] address1 = new byte[count];
+ Random random = new Random(10);
+ for (int i = 0; i < count; i++) {
+ address0[i] = (byte) random.nextInt();
+ address1[i] = address0[i];
+ }
+
+ BinaryRefAddr addr0 = new BinaryRefAddr(null, address0);
+ BinaryRefAddr addr1 = new BinaryRefAddr(null, address1);
+ try {
+ boolean result = addr0.equals(addr1);
+ fail("Should throw NullPoinerException.");
+ } catch (NullPointerException e) {
+ }
+ }
+
+ public void testtestEquals_refAddr() {
+ String type = "Binary Type";
+ byte[] address = { 1, 2, 3, 4 };
+ BinaryRefAddr addr = new BinaryRefAddr(type, address);
+ MyRefAddr addr2 = new MyRefAddr(type, address);
+
+ assertFalse(addr.equals(addr2));
+ }
+
+ public void testHashcode_Simple() {
+ String type = "Binary Address";
+
+ int count = 10;
+ byte[] address = new byte[count];
+ Random random = new Random(20);
+ for (int i = 0; i < count; i++) {
+ address[i] = (byte) random.nextInt();
+ }
+
+ int hashCode = type.hashCode();
+ for (int i = 0; i < address.length; i++) {
+ hashCode += address[i];
+ }
+ BinaryRefAddr addr = new BinaryRefAddr(type, address);
+ assertEquals(hashCode, addr.hashCode());
+ }
+
+ public void testHashcode_TypeNull() {
+ int count = 10;
+ byte[] address = { 1, 2, 3, };
+
+ BinaryRefAddr addr = new BinaryRefAddr(null, address);
+ try {
+ int hashCode = addr.hashCode();
+ fail("Should throw NullPointerException.");
+ } catch (NullPointerException e) {
+ }
+
+ }
+
+ public void testGetContent_Simple() {
+ String type = "Binary Address";
+ byte[] address = { 1, 2, 3, 4, 5, 6 };
+ BinaryRefAddr addr = new BinaryRefAddr(type, address);
+
+ assertTrue(java.util.Arrays.equals(address, (byte[]) addr.getContent()));
+ }
+
+ public void testToString() {
+ String type = "Binary Address";
+ byte[] address = { 'a', 3, 0x7F, (byte) 0x80, (byte) 90, (byte) 0xFF };
+
+ BinaryRefAddr addr = new BinaryRefAddr(type, address);
+
+ String str = "The type of the address is: " + type
+ + "\nThe content of the address is:";
+ for (int i = 0; i < address.length; i++) {
+ str += " " + Integer.toHexString(address[i]);
+ }
+ str += "\n";
+ // assertEquals(str, addr.toString());
+ assertNotNull(addr.toString());
+ }
+
+ public void testToString_TypeNull() {
+ byte[] address = { 1, 2, 3, };
+ BinaryRefAddr addr = new BinaryRefAddr(null, address);
+ String str = "The type of the address is: null"
+ + "\nThe content of the address is: 1 2 3\n";
+ // assertEquals(str, addr.toString());
+ assertNotNull(addr.toString());
+ }
+
+ public void testSerializable_Simple() throws ClassNotFoundException,
+ IOException {
+ String type = "Binary Address";
+ int count = 10;
+ byte[] address = new byte[count];
+ Random random = new Random(20);
+ for (int i = 0; i < count; i++) {
+ address[i] = (byte) random.nextInt();
+ }
+ BinaryRefAddr addr = new BinaryRefAddr(type, address);
+
+ // write to byte array
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(addr);
+ byte[] buffer = baos.toByteArray();
+ oos.close();
+ baos.close();
+
+ // read from byte array
+ ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ BinaryRefAddr addr2 = (BinaryRefAddr) ois.readObject();
+ ois.close();
+ bais.close();
+
+ assertEquals(addr, addr2);
+ }
+
+ public void testSerializable_compatibility() throws ClassNotFoundException,
+ IOException {
+ // TO DO R: need to implement
+ ObjectInputStream ois = new ObjectInputStream(getClass()
+ .getClassLoader().getResourceAsStream(
+ "/serialization/javax/naming/BinaryRefAddr.ser"));
+ BinaryRefAddr addr = (BinaryRefAddr) ois.readObject();
+ ois.close();
+
+ String type = "Binary Address";
+ int count = 100;
+ byte[] address = new byte[count];
+ for (int i = 0; i < count; i++) {
+ address[i] = (byte) i;
+ }
+ BinaryRefAddr addr2 = new BinaryRefAddr(type, address);
+ assertEquals(addr, addr2);
+ }
+
+ class MyRefAddr extends RefAddr {
+ byte[] address;
+
+ public MyRefAddr(String type, byte[] address) {
+ super(type);
+ this.address = new byte[address.length];
+ System.arraycopy(address, 0, this.address, 0, address.length);
+ }
+
+ public Object getContent() {
+ return address;
+ }
+ }
+}
\ No newline at end of file
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/BinaryRefAddrTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/BindingTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/BindingTest.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/BindingTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/BindingTest.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,134 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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.jndi.tests.javax.naming;
+
+import javax.naming.Binding;
+
+import junit.framework.TestCase;
+import org.apache.harmony.jndi.tests.javax.naming.util.Log;
+
+public class BindingTest extends TestCase {
+
+ private static Log log = new Log(BindingTest.class);
+
+ /**
+ * Constructor for TestBinding.
+ *
+ * @param arg0
+ */
+ public BindingTest(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testConstructor_Simple() {
+ Binding p;
+
+ p = new Binding("name1", new Integer(1));
+ assertEquals("name1", p.getName());
+ assertEquals("java.lang.Integer", p.getClassName());
+ assertEquals(new Integer(1), p.getObject());
+ assertEquals(true, p.isRelative());
+ }
+
+ public void testConstructor_NullValue() {
+ Binding p;
+
+ p = new Binding("name1", null, null);
+ assertEquals("name1", p.getName());
+ assertTrue(null == p.getClassName());
+ assertTrue(null == p.getObject());
+ }
+
+ public void testConstructor_DefaultRelativeValue() {
+ Binding p;
+
+ p = new Binding("name1", null);
+ assertEquals(true, p.isRelative());
+ }
+
+ public void testToString() {
+ log.setMethod("testToString");
+ Binding p;
+
+ p = new Binding("name1", null, false);
+ assertTrue(p.toString().startsWith("(not relative"));
+ p = new Binding("name1", new Integer(3));
+ String str = p.toString();
+ assertTrue(str.indexOf("name1") > -1);
+ assertTrue(str.indexOf("3") > -1);
+ assertTrue(str.indexOf("java.lang.Integer") > -1);
+ }
+
+ public void testGetSetObject() {
+ Binding p;
+ log.setMethod("testGetSetObject");
+ p = new Binding("name", null);
+ p.setObject(new Integer(2));
+ assertEquals(new Integer(2), p.getObject());
+ assertEquals("java.lang.Integer", p.getClassName());
+ p.setObject(null);
+ assertNull(p.getObject());
+ assertNull(p.getClassName());
+ p.setObject(new Float(2));
+ assertEquals(new Float(2), p.getObject());
+ assertEquals(Float.class.getName(), p.getClassName());
+ p.setObject(null);
+ assertNull(p.getObject());
+ assertNull(p.getClassName());
+ }
+
+ public void testGetSetName() {
+ Binding p;
+
+ p = new Binding("name", new Integer(1));
+ assertEquals("name", p.getName());
+ p.setName("name1");
+ assertEquals("name1", p.getName());
+ p.setName("");
+ assertEquals("", p.getName());
+ }
+
+ public void testGetSetClassName() {
+ Binding p;
+
+ p = new Binding("name", new Integer(1));
+ assertEquals(Integer.class.getName(), p.getClassName());
+ p.setClassName(Character.class.getName());
+ assertEquals(Character.class.getName(), p.getClassName());
+ }
+
+ public void testGetSetRelative() {
+ Binding p;
+
+ p = new Binding("name", new Integer(1));
+ assertTrue(p.isRelative());
+ p.setRelative(false);
+ assertFalse(p.isRelative());
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/BindingTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CannotProceedExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CannotProceedExceptionTest.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CannotProceedExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CannotProceedExceptionTest.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,76 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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.jndi.tests.javax.naming;
+
+import java.util.Hashtable;
+
+import javax.naming.CannotProceedException;
+import javax.naming.CompositeName;
+import javax.naming.Context;
+import javax.naming.InvalidNameException;
+import javax.naming.Name;
+
+import org.apache.harmony.jndi.tests.javax.naming.util.Log;
+import junit.framework.TestCase;
+
+public class CannotProceedExceptionTest extends TestCase {
+
+ static private Log log = new Log(CannotProceedExceptionTest.class);
+
+ /**
+ * Constructor for TestCannotProceedException.
+ *
+ * @param arg0
+ */
+ public CannotProceedExceptionTest(String arg0) {
+ super(arg0);
+ }
+
+ public void testConstructorAndGetterSetter() throws InvalidNameException {
+ log.setMethod("testConstructorAndGetterSetter()");
+
+ CannotProceedException cpe = new CannotProceedException();
+ Name altName = new CompositeName("1");
+ Context altContext = null;
+ Hashtable h = new Hashtable();
+ Name newName = new CompositeName("2");
+
+ cpe.setAltName(altName);
+ assertEquals(altName, cpe.getAltName());
+
+ cpe.setAltNameCtx(altContext);
+ assertEquals(altContext, cpe.getAltNameCtx());
+
+ cpe.setEnvironment(h);
+ assertEquals(h, cpe.getEnvironment());
+
+ cpe.setRemainingNewName(newName);
+ assertEquals(newName, cpe.getRemainingNewName());
+ }
+
+ public void testConstructor_defaultValue() {
+ CannotProceedException cpe = new CannotProceedException();
+ assertNull(cpe.getMessage());
+ assertNull(cpe.getAltName());
+ assertNull(cpe.getAltNameCtx());
+ assertNull(cpe.getEnvironment());
+ assertNull(cpe.getRemainingNewName());
+ }
+
+ public void testGetEnvironment() {
+ CannotProceedException exception = new CannotProceedException("Test");
+ assertNull(exception.getEnvironment());
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CannotProceedExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompositeNameTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompositeNameTest.java?rev=397337&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompositeNameTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompositeNameTest.java Wed Apr 26 16:25:54 2006
@@ -0,0 +1,667 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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.jndi.tests.javax.naming;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Enumeration;
+import java.util.Properties;
+
+import javax.naming.CompositeName;
+import javax.naming.CompoundName;
+import javax.naming.InvalidNameException;
+import javax.naming.Name;
+
+import junit.framework.TestCase;
+import org.apache.harmony.jndi.tests.javax.naming.util.Log;
+
+/**
+ * unit test for composite name
+ *
+ */
+public class CompositeNameTest extends TestCase {
+
+ /*
+ * -------------------------------------------------------------------
+ * Constants
+ * -------------------------------------------------------------------
+ */
+ private static Log log = new Log(CompositeNameTest.class);
+
+ private static final char SEPARATOR = '/';
+
+ /*
+ * -------------------------------------------------------------------
+ * Instance variables (Should be private)
+ * -------------------------------------------------------------------
+ */
+ private CompositeName name;
+
+ private String[] elements = { "www.apache.org", "gbank" };
+
+ private String initName;
+
+ private Properties props;
+
+ /**
+ * Constructor for TestCompositeName.
+ *
+ * @param arg0
+ */
+ public CompositeNameTest(String arg0) {
+ super(arg0);
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < elements.length; i++) {
+ sb.append(elements[i]).append(SEPARATOR);
+ }
+ initName = sb.toString();
+ }
+
+ /*
+ * -------------------------------------------------------------------
+ * Methods
+ * -------------------------------------------------------------------
+ */
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ name = new CompositeName(initName);
+ props = new Properties();
+ props.put("jndi.syntax.separator", "/");
+ props.put("jndi.syntax.direction", "left_to_right");
+ props.put("jndi.syntax.escape", "\\");
+ props.put("jndi.syntax.beginquote", "<");
+ props.put("jndi.syntax.endquote", ">");
+ props.put("jndi.syntax.beginquote2", "'");
+ props.put("jndi.syntax.endquote2", "'");
+ props.put("jndi.syntax.ignorecase", "false");
+ props.put("jndi.syntax.trimblanks", "false");
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * test constructor with null string parameter
+ *
+ * @throws InvalidNameException
+ */
+ public void TestConstructorNull() throws InvalidNameException {
+ log.setMethod("TestConstructorNull");
+ try {
+ name = new CompositeName((String) null);
+ log.log("fail: try to construct a compositename with null succeed");
+ fail();
+ } catch (NullPointerException e) {
+ }
+ }
+
+ public void testConstructorSimple() throws InvalidNameException {
+ assertNameEquals(new CompositeName("a/b/c"), new String[] { "a", "b",
+ "c" });
+ }
+
+ public void testConstructorException() throws InvalidNameException {
+ try {
+ name = new CompositeName("'abc'd/ef");
+ fail();
+ } catch (InvalidNameException e) {
+ }
+ name = new CompositeName("abc'abc'/ab");
+ assertNameEquals(name, new String[] { "abc'abc'", "ab" });
+ }
+
+ /**
+ * test toString()
+ *
+ * @throws InvalidNameException
+ */
+ public void testToString() throws InvalidNameException {
+ log.setMethod("testToString()");
+ assertEquals("", new CompositeName("").toString());
+ assertEquals("/", new CompositeName("/").toString());
+ assertEquals("//", new CompositeName("//").toString());
+ assertEquals("/a/", new CompositeName("/a/").toString());
+ name.add("abc\"abc");
+ assertEquals(4, name.size());
+ name.add("abc/abc");
+ assertEquals(5, name.size());
+ name.add("abc\\abc");
+ assertEquals(6, name.size());
+ assertEquals(new CompositeName(name.toString()), name);
+ assertNameEquals(name, new String[] { "www.apache.org", "gbank",
+ "", "abc\"abc", "abc/abc", "abc\\abc" });
+ }
+
+ /**
+ * test getAll()
+ *
+ */
+ public void testGetAll() {
+ log.setMethod("testGetAll()");
+ Enumeration enumeration = name.getAll();
+ for (int j = 0; j < elements.length; j++) {
+ assertTrue(elements[j].equals(enumeration.nextElement()));
+ }
+ assertTrue("".equals(enumeration.nextElement()));
+ }
+
+ /**
+ * test get()
+ *
+ */
+ public void testGet() {
+ log.setMethod("testGet()");
+ for (int j = 0; j < elements.length; j++) {
+ assertEquals(elements[j], name.get(j));
+ }
+ try {
+ name.get(-1);
+ fail();
+ } catch (ArrayIndexOutOfBoundsException e) {
+ }
+ try {
+ name.get(name.size());
+ fail();
+ } catch (ArrayIndexOutOfBoundsException e) {
+ }
+ }
+
+ /**
+ * test getPrefix()
+ *
+ */
+ public void testGetPrefix() {
+ log.setMethod("testGetPrefix()");
+ Name prefix = name.getPrefix(0);
+ assertEquals("", prefix.toString());
+ try {
+ name.getPrefix(elements.length + 2);
+ fail("name.getPrefix(elements.length + 2)");
+ } catch (IndexOutOfBoundsException e) {
+ }
+ try {
+ name.getPrefix(-1);
+ fail("name.getPrefix(-1)");
+ } catch (IndexOutOfBoundsException e) {
+ }
+ prefix = name.getPrefix(1);
+ assertEquals(elements[0], prefix.toString());
+ }
+
+ /**
+ * test getSuffix
+ *
+ */
+ public void testGetSuffix() {
+ log.setMethod("testGetSuffix()");
+ Name suffix = name.getSuffix(elements.length + 1);
+ assertEquals("", suffix.toString());
+ try {
+ name.getSuffix(elements.length + 2);
+ fail("name.getSuffix(elements.length + 2)");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ }
+ try {
+ name.getSuffix(-1);
+ fail("name.getSuffix(-1)");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ }
+ suffix = name.getSuffix(2);
+ assertEquals("/", suffix.toString());
+ }
+
+ /**
+ * Test addAll(Name), include exceptional case
+ */
+ public void testAddAllName() throws InvalidNameException {
+ log.setMethod("testAddAllName()");
+ int oldSize = name.size();
+ name.addAll(new CompositeName(initName));
+ assertEquals(name.size(), oldSize * 2);
+ assertEquals(name.getPrefix(3).toString(), name.getSuffix(3).toString());
+ assertEquals(name.getPrefix(3).toString(), initName);
+ name = new CompositeName("a");
+ try {
+ name.addAll(new CompoundName("b/c", props));
+ fail("name.addAll(new CompoundName(\"b/c\", props));");
+ } catch (InvalidNameException t) {
+ }
+ try {
+ name.addAll(null);
+ fail("Add null should throw NullPointerException");
+ } catch (NullPointerException e) {
+ }
+ }
+
+ /**
+ * test addAll(int), include exceptional case
+ */
+ public void testAddAllintName() throws InvalidNameException {
+ log.setMethod("testAddAllintName()");
+ int oldSize = name.size();
+ name.addAll(1, new CompositeName(initName));
+ assertEquals(name.size(), oldSize * 2);
+ assertEquals(name.getSuffix(1).getPrefix(3).toString(), initName);
+ name = new CompositeName("a");
+ try {
+ name.addAll(0, new CompoundName("b/c", props));
+ fail("name.addAll(0, new CompoundName(\"b/c\", props));");
+ } catch (InvalidNameException t) {
+ }
+ try {
+ name.addAll(0, null);
+ fail("Add null should throw NullPointerException");
+ } catch (NullPointerException e) {
+ }
+ try {
+ name.addAll(-1, new CompositeName(initName));
+ fail("-1 should be out of bound.");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ }
+ try {
+ name.addAll(name.size() + 1, new CompositeName(initName));
+ fail((name.size() + 1) + " should out of bound.");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ }
+ }
+
+ /**
+ * test add(String), include exceptional case of null parameter
+ */
+ public void testAddString() throws InvalidNameException {
+ log.setMethod("testAddString()");
+ int oldSize = name.size();
+ name.add(elements[0]);
+ assertEquals(name.size(), oldSize + 1);
+ assertEquals(elements[0], name.getSuffix(3).toString());
+ name.add(null);
+ assertEquals(name.size(), oldSize + 2);
+ try {
+ assertEquals(null, name.getSuffix(4).toString());
+ fail();
+ } catch (NullPointerException e) {
+ }
+
+ }
+
+ /**
+ * Test add(int, String), include boundary case
+ */
+ public void testAddintString() throws InvalidNameException {
+ log.setMethod("testAddintString()");
+ int oldSize = name.size();
+ name.add(1, elements[0]);
+ assertEquals(name.size(), oldSize + 1);
+ assertEquals(name.getSuffix(1).toString(), initName);
+ try {
+ name.add(oldSize + 2, elements[0]);
+ fail();
+ } catch (ArrayIndexOutOfBoundsException e) {
+ }
+ try {
+ name.add(-1, elements[0]);
+ fail();
+ } catch (ArrayIndexOutOfBoundsException e) {
+ }
+ }
+
+ /**
+ * test remove, include boundary case
+ *
+ * @throws InvalidNameException
+ */
+ public void testRemove() throws InvalidNameException {
+ log.setMethod("testRemove()");
+ int oldSize = name.size();
+ name.remove(1);
+ assertEquals(name.size(), oldSize - 1);
+ assertEquals(name.toString(), elements[0] + "/");
+ try {
+ name.remove(-1);
+ fail();
+ } catch (ArrayIndexOutOfBoundsException e) {
+ }
+ try {
+ name.remove(oldSize - 1);
+ fail();
+ } catch (ArrayIndexOutOfBoundsException e) {
+ }
+
+ }
+
+ /**
+ * test size()
+ *
+ * @throws InvalidNameException
+ */
+ public void testSize() throws InvalidNameException {
+ log.setMethod("testSize()");
+ assertEquals(elements.length + 1, name.size());
+ name = new CompositeName("/");
+ assertEquals(1, name.size());
+ }
+
+ /**
+ * test isEmpty()
+ *
+ * @throws InvalidNameException
+ */
+ public void testIsEmpty() throws InvalidNameException {
+ log.setMethod("testIsEmpty()");
+ assertFalse(name.isEmpty());
+ for (int i = 0; i < elements.length; i++) {
+ name.remove(0);
+ }
+ name.remove(0);
+ assertTrue(name.isEmpty());
+ name = new CompositeName("");
+ assertTrue(name.isEmpty());
+
+ }
+
+ /**
+ * test startWith(), include exceptional case of null and CompoundName
+ *
+ * @throws InvalidNameException
+ */
+ public void testStartsWith() throws InvalidNameException {
+ log.setMethod("testStartsWith()");
+ CompositeName start = new CompositeName(elements[0]);
+ assertTrue(name.startsWith(start));
+ start = new CompositeName(elements[1]);
+ assertFalse(name.startsWith(start));
+ try {
+ assertFalse(name.startsWith(null));
+ } catch (Throwable e) {
+ log.log("start with null?", e);
+ }
+ try {
+ assertFalse(name.startsWith(new CompoundName(elements[0], props)));
+ } catch (Throwable e) {
+ log.log("start with compoundName?", e);
+ }
+ }
+
+ /**
+ * test endsWith(), include exceptional case of null and CompoundName
+ *
+ * @throws InvalidNameException
+ */
+ public void testEndsWith() throws InvalidNameException {
+ log.setMethod("testEndsWith()");
+ CompositeName end = new CompositeName("");
+ assertTrue(name.endsWith(end));
+ end = new CompositeName("12345");
+ assertFalse(name.endsWith(end));
+ try {
+ name.endsWith(null);
+ } catch (Throwable e) {
+ log.log("end with null?", e);
+ }
+ try {
+ assertFalse(name.endsWith(new CompoundName("", props)));
+ } catch (Throwable e) {
+ log.log("end with compoundName?", e);
+ }
+ }
+
+ /**
+ * Special characters are as follows: The separator is / The escape
+ * character is \ Quotes can be used - both single quotes and double quotes
+ * are allowed. This allows you to quote strings which contain chars such as /
+ * which are part of a CompositeName element to avoid them being read as a
+ * separator.
+ *
+ * @throws InvalidNameException
+ */
+ public void testSpecialCharacter() throws InvalidNameException {
+ log.setMethod("testSpecialCharacter()");
+ // The name "a//a" has 3 elements. The middle element is empty and the
+ // first & third elements are both "a".
+ name = new CompositeName("a//a");
+ Enumeration enumeration = name.getAll();
+ assertEquals("a", enumeration.nextElement());
+ assertEquals("", enumeration.nextElement());
+ assertEquals("a", enumeration.nextElement());
+
+ // The name "a/'b/c'/a" has 3 elements. The middle element is b/c.
+ name = new CompositeName("a/'b/c'/a");
+ enumeration = name.getAll();
+ assertEquals("a", enumeration.nextElement());
+ assertEquals("b/c", enumeration.nextElement());
+ assertEquals("a", enumeration.nextElement());
+
+ name = new CompositeName("a/a'b/c'c/a");
+ enumeration = name.getAll();
+ assertEquals("a", enumeration.nextElement());
+ assertEquals("a'b", enumeration.nextElement());
+ assertEquals("c'c", enumeration.nextElement());
+ assertEquals("a", enumeration.nextElement());
+ name = new CompositeName("a/a'b/c'/a/\\abc/ab\\\"c");
+ enumeration = name.getAll();
+ assertEquals("a", enumeration.nextElement());
+ assertEquals("a'b", enumeration.nextElement());
+ assertEquals("c'", enumeration.nextElement());
+ assertEquals("a", enumeration.nextElement());
+ assertEquals("\\abc", enumeration.nextElement());
+ assertEquals("ab\"c", enumeration.nextElement());
+
+ name = new CompositeName("\"ab/c\"/ab");
+ assertNameEquals(name, new String[] { "ab/c", "ab" });
+
+ // The name "a/'b/a" is invalid as there is no closing quote for the '
+ // character.
+ try {
+ name = new CompositeName("a/'b/a");
+ fail("a/'b/a");
+ } catch (InvalidNameException e) {
+ }
+
+ // The name "a/\"b/a" is interpreted as a/"b/a and is invalid as there
+ // is no closing quote for the embedded escaped " character.
+ try {
+ name = new CompositeName("a/\"'b/a");
+ fail("a/\"'b/a");
+ } catch (InvalidNameException e) {
+ }
+ try {
+ name = new CompositeName("a/bcd/a\\");
+ fail("a/bcd/a\\");
+ } catch (InvalidNameException e) {
+ }
+ }
+
+ /**
+ * test equals, include exceptional case, i.e, CompoundName, null, etc.
+ *
+ * @throws InvalidNameException
+ */
+ public void testEquals() throws InvalidNameException {
+ log.setMethod("testEquals()");
+ Name name2 = null;
+ name2 = new CompositeName(initName);
+ assertTrue(name.equals(name2));
+ assertTrue(name2.equals(name));
+ name2.add("abc");
+ assertFalse(name2.equals(name));
+ name2 = new CompoundName("abc", props);
+ name = new CompositeName("abc");
+ assertFalse(name.equals(name2));
+ assertFalse(name.equals(null));
+ assertTrue(name.equals(name));
+ }
+
+ /**
+ * test compareTo(), include exceptional case, i.e, CompoundName, null, etc.
+ *
+ * @throws InvalidNameException
+ */
+ public void testCompareTo() throws InvalidNameException {
+ log.setMethod("testCompareTo()");
+ Name name1 = new CompositeName("a/b/c/d");
+ Name name2 = new CompositeName("ab/b/c/d");
+ Name name3 = new CompositeName("a/b/c/d/e");
+ Name name4 = new CompositeName("b/b/c/d");
+ assertEquals(-1, name1.compareTo(name2));
+ assertEquals(1, name3.compareTo(name1));
+ assertEquals(-1, name1.compareTo(name4));
+ assertEquals(name1.compareTo(name1), 0);
+ try {
+ name1.compareTo(null);
+ fail();
+ } catch (ClassCastException e) {
+ }
+ name2 = new CompoundName("a/b/c/d", props);
+ try {
+ name1.compareTo(name2);
+ fail();
+ } catch (ClassCastException e) {
+ }
+ }
+
+ /**
+ * test hashCode()
+ *
+ * @throws InvalidNameException
+ */
+ public void testHashCode() throws InvalidNameException {
+ log.setMethod("testHashCode()");
+ Name name2 = new CompositeName(initName);
+ assertEquals(name.hashCode(), name2.hashCode());
+ assertEquals(767782430, name2.hashCode());
+ name2 = new CompositeName("a");
+ assertEquals(97, name2.hashCode());
+ }
+
+ /**
+ * test serialization
+ *
+ * @throws Exception
+ */
+ public void testWriteReadObject() throws Exception {
+ log.setMethod("testWriteReadObject()");
+ CompositeName name = new CompositeName("a/b/c/d");
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ ObjectOutputStream stream = new ObjectOutputStream(bout);
+ stream.writeObject(name);
+ stream.close();
+ ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(
+ bout.toByteArray()));
+ CompositeName name2 = (CompositeName) in.readObject();
+ assertTrue(name.equals(name2));
+ in.close();
+ }
+
+ /**
+ * utility method for name assertion
+ *
+ * @param n
+ * @param elems
+ */
+ private void assertNameEquals(Name n, String[] elems) {
+
+ try {
+ // compare
+ assertEquals(elems.length, n.size());
+
+ for (int i = 0; i < n.size(); i++) {
+ assertEquals(elems[i], n.get(i));
+ }
+
+ int i = 0;
+ Enumeration enumeration = n.getAll();
+ while (enumeration.hasMoreElements()) {
+ assertEquals(elems[i++], enumeration.nextElement());
+ }
+ } catch (RuntimeException e) {
+ // log
+ StringBuffer buf = new StringBuffer();
+ buf.append("Assert name ");
+ buf.append(n.toString());
+ buf.append(" has elements [" + elems.length + "]{");
+ for (int i = 0; i < elems.length; i++) {
+ if (i > 0) {
+ buf.append(",");
+ }
+ buf.append(elems[i]);
+ }
+ buf.append("}");
+ log.log(buf.toString());
+
+ throw e;
+ }
+ }
+
+ /**
+ * test serialization compatibility
+ *
+ * @throws Exception
+ */
+ public void testSerializationCompatibility() throws Exception {
+ log.setMethod("testSerializationCompatibility()");
+
+ try {
+ ObjectInputStream in = new ObjectInputStream(getClass()
+ .getResourceAsStream(
+ "/serialization/javax/naming/CompositeName.ser"));
+ CompositeName name = (CompositeName) in.readObject();
+ assertEquals(new CompositeName("a/b/c/d"), name);
+ in.close();
+ } catch (Exception e) {
+ log.log(e);
+ throw e;
+ }
+ }
+
+ /**
+ * test clone
+ *
+ */
+ public void testClone() throws InvalidNameException {
+ CompositeName name = new CompositeName("a/b/c/d");
+ CompositeName name2 = (CompositeName) name.clone();
+ assertEquals(name, name2);
+ name.add(1, elements[0]);
+ assertFalse(name.equals(name2));
+ }
+
+ public void testConstructorEnum() {
+ log.setMethod("testConstructorEnum");
+ CompositeName name2 = new MockCompositeName(name.getAll());
+ assertEquals(name2, name);
+ try {
+ name2 = new MockCompositeName((Enumeration) null);
+ fail();
+ } catch (NullPointerException e) {
+ }
+ }
+
+ // mock class to test protected methods
+ public class MockCompositeName extends CompositeName {
+ public MockCompositeName(Enumeration enumeration) {
+ super(enumeration);
+ }
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompositeNameTest.java
------------------------------------------------------------------------------
svn:eol-style = native