You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ps...@apache.org on 2004/02/16 04:35:52 UTC
svn commit: rev 6680 - incubator/directory/naming/trunk/core/src/test/org/apache/naming/resources
Author: psteitz
Date: Sun Feb 15 19:35:52 2004
New Revision: 6680
Modified:
incubator/directory/naming/trunk/core/src/test/org/apache/naming/resources/FileDirContextTest.java
Log:
Added getAttributes, getNameInNamespace tests.
Modified: incubator/directory/naming/trunk/core/src/test/org/apache/naming/resources/FileDirContextTest.java
==============================================================================
--- incubator/directory/naming/trunk/core/src/test/org/apache/naming/resources/FileDirContextTest.java (original)
+++ incubator/directory/naming/trunk/core/src/test/org/apache/naming/resources/FileDirContextTest.java Sun Feb 15 19:35:52 2004
@@ -55,10 +55,18 @@
*/
package org.apache.naming.resources;
+import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NameParser;
+
+import javax.naming.directory.DirContext;
+import javax.naming.directory.Attributes;
+
+import org.apache.naming.resources.ResourceAttributes;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -120,5 +128,34 @@
return true;
}
- // todo: Add better lookup / binding tests for files, directories
+ /**
+ * Verify file attributes
+ */
+ public void testAttributes() throws Exception {
+ super.testAttributes();
+ DirContext context = (DirContext) initialContext.lookup(firstContextName()+ "/" + secondContextName());
+ Attributes attrs = (Attributes) context.getAttributes(firstBoundName());
+ Date creationDate = (Date) attrs.get(ResourceAttributes.CREATION_DATE).get();
+ assertTrue(creationDate.before(new Date()));
+ Date modifiedDate = (Date) attrs.get(ResourceAttributes.LAST_MODIFIED).get();
+ assertTrue(modifiedDate.equals(creationDate));
+ String displayName = (String) attrs.get(ResourceAttributes.NAME).get();
+ assertEquals(displayName, firstBoundName());
+ long contentLength = ((Long) attrs.get(ResourceAttributes.CONTENT_LENGTH).get()).longValue();
+ assertEquals(contentLength, bytes.length);
+ String resourceType = (String) attrs.get(ResourceAttributes.TYPE).get();
+ assertEquals(resourceType, ""); // Present, but empty -- is this the correct?
+ assertNull(attrs.get(ResourceAttributes.CONTENT_TYPE)); // Not present -- is this correct?
+ assertNull(attrs.get(ResourceAttributes.SOURCE)); // "" ""
+ assertNull(attrs.get(ResourceAttributes.ETAG)); // "" ""
+ }
+
+ public void testGetNameInNamespace() throws Exception {
+ super.testGetNameInNamespace();
+ NameParser np = initialContext.getNameParser("");
+ Name name = np.parse(firstContext.getNameInNamespace());
+ assertTrue(name.endsWith(np.parse(firstContextName())));
+ name = np.parse(secondContext.getNameInNamespace());
+ assertTrue(name.endsWith(np.parse(secondContextName())));
+ }
}