You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by qi...@apache.org on 2008/07/14 11:43:37 UTC
svn commit: r676530 [2/3] - in /harmony/enhanced/classlib/branches/java6:
depends/build/platform/ depends/oss/ modules/awt/src/main/native/lcmm/shared/
modules/awt/src/main/native/oglwrapper/shared/
modules/beans/src/main/java/java/beans/ modules/beans...
Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapContextServerMockedTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapContextServerMockedTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapContextServerMockedTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapContextServerMockedTest.java Mon Jul 14 02:43:27 2008
@@ -26,6 +26,7 @@
import javax.naming.Context;
import javax.naming.InvalidNameException;
import javax.naming.Name;
+import javax.naming.NamingException;
import javax.naming.PartialResultException;
import javax.naming.RefAddr;
import javax.naming.Reference;
@@ -36,6 +37,8 @@
import javax.naming.event.EventDirContext;
import javax.naming.event.NamingExceptionEvent;
import javax.naming.ldap.Control;
+import javax.naming.ldap.ExtendedRequest;
+import javax.naming.ldap.ExtendedResponse;
import javax.naming.ldap.InitialLdapContext;
import javax.naming.ldap.LdapContext;
import javax.naming.ldap.PagedResultsControl;
@@ -54,7 +57,6 @@
import org.apache.harmony.jndi.provider.ldap.mock.EncodableLdapResult;
import org.apache.harmony.jndi.provider.ldap.mock.MockLdapMessage;
import org.apache.harmony.jndi.provider.ldap.mock.MockLdapServer;
-import org.apache.harmony.security.x509.IssuingDistributionPoint;
public class LdapContextServerMockedTest extends TestCase {
private MockLdapServer server;
@@ -645,7 +647,7 @@
eventContext.addNamingListener("", "(objectclass=cn)", new Object[0],
new SearchControls(), listener);
server.disconnectNotify();
- Thread.sleep(5000);
+ Thread.sleep(500);
assertNull(listener.exceptionEvent);
assertNotNull(listener.unsolicatedEvent);
assertTrue(listener.unsolicatedEvent.getSource() instanceof LdapContext);
@@ -659,6 +661,99 @@
assertNull(notification.getEncodedValue());
}
+ public void testExtendedOperation() throws Exception {
+ server.setResponseSeq(new LdapMessage[] { new LdapMessage(
+ LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
+ LdapContext context = new InitialLdapContext(env, null);
+
+ ASN1Encodable encodableResponse = new ASN1Encodable() {
+
+ public void encodeValues(Object[] values) {
+ new EncodableLdapResult().encodeValues(values);
+ values[4] = Utils.getBytes("It's my id");
+ values[5] = new byte[] { 0, 1, 2, 3 };
+ }
+
+ };
+ server
+ .setResponseSeq(new LdapMessage[] { new LdapMessage(
+ LdapASN1Constant.OP_EXTENDED_RESPONSE,
+ encodableResponse, null) });
+
+ ExtendedResponse response = context
+ .extendedOperation(new MockExtendedRequest());
+ assertTrue(response instanceof MockExtendedResponse);
+ assertEquals("It's my id", response.getID());
+ assertEquals(4, response.getEncodedValue().length);
+ assertEquals(0, response.getEncodedValue()[0]);
+ assertEquals(1, response.getEncodedValue()[1]);
+ assertEquals(2, response.getEncodedValue()[2]);
+ assertEquals(3, response.getEncodedValue()[3]);
+
+ // test exception
+ encodableResponse = new ASN1Encodable() {
+ public void encodeValues(Object[] values) {
+ new EncodableLdapResult().encodeValues(values);
+ values[4] = Utils.getBytes("exception");
+ values[5] = new byte[] { 0, 1, 2, 3 };
+ }
+
+ };
+ server
+ .setResponseSeq(new LdapMessage[] { new LdapMessage(
+ LdapASN1Constant.OP_EXTENDED_RESPONSE,
+ encodableResponse, null) });
+
+ try {
+ context.extendedOperation(new MockExtendedRequest());
+ fail("Should throw NamingException");
+ } catch (NamingException e) {
+ // expected
+ assertEquals("exception", e.getMessage());
+ }
+ }
+
+ public class MockExtendedRequest implements ExtendedRequest {
+
+ public ExtendedResponse createExtendedResponse(String s, byte[] value,
+ int offset, int length) throws NamingException {
+ if (s.equalsIgnoreCase("exception")) {
+ throw new NamingException("exception");
+ }
+ return new MockExtendedResponse(s, value);
+ }
+
+ public byte[] getEncodedValue() {
+ return new byte[0];
+ }
+
+ public String getID() {
+ return getClass().getName();
+ }
+
+ }
+
+ public class MockExtendedResponse implements ExtendedResponse {
+
+ private String id;
+
+ private byte[] values;
+
+ public MockExtendedResponse(String id, byte[] values) {
+ this.id = id;
+ this.values = values;
+ }
+
+ public byte[] getEncodedValue() {
+ return values;
+ }
+
+ public String getID() {
+ return id;
+ }
+
+ }
+
public class MockUnsolicitedNotificationListener implements
UnsolicitedNotificationListener {
Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaContextTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaContextTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaContextTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapSchemaContextTest.java Mon Jul 14 02:43:27 2008
@@ -22,6 +22,7 @@
import javax.naming.Binding;
import javax.naming.CompositeName;
+import javax.naming.InvalidNameException;
import javax.naming.Name;
import javax.naming.NameClassPair;
import javax.naming.NameNotFoundException;
@@ -33,18 +34,27 @@
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.BasicAttributes;
import javax.naming.directory.DirContext;
+import javax.naming.directory.InvalidSearchFilterException;
import javax.naming.directory.ModificationItem;
import javax.naming.directory.SchemaViolationException;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
import junit.framework.TestCase;
public class LdapSchemaContextTest extends TestCase {
private LdapSchemaContextImpl schema;
+ private Hashtable<String, Object> schemaTable;
+
+ private LdapContextImpl context;
+
+ Name name;
+
@Override
public void setUp() throws Exception {
// Construct the schema table.
- Hashtable<String, Object> schemaTable = new Hashtable<String, Object>();
+ schemaTable = new Hashtable<String, Object>();
Hashtable<String, Object> subSchema = new Hashtable<String, Object>();
subSchema
@@ -91,9 +101,8 @@
"( 0.9.2342.19200300.100.1.49 name 'dsaquality' desc 'rfc1274: dsa quality' syntax 1.3.6.1.4.1.1466.115.121.1.19 single-value usage userapplications x-schema 'cosine' )");
schemaTable.put("attributetypes", subSchema);
- LdapContextImpl context = new LdapContextImpl(new MockLdapClient(),
- null, "");
- Name name = new CompositeName("");
+ context = new LdapContextImpl(new MockLdapClient(), null, "");
+ name = new CompositeName("");
schema = new LdapSchemaContextImpl(context, null, name, schemaTable,
LdapSchemaContextImpl.SCHEMA_ROOT_LEVEL);
}
@@ -215,6 +224,13 @@
} catch (NameNotFoundException e) {
// Expected.
}
+
+ try {
+ namingEnum = schema.list("objectclasses");
+ fail("Should throw NameNotFoundException.");
+ } catch (NameNotFoundException e) {
+ // Expected.
+ }
}
public void testList_Address() throws Exception {
@@ -1402,4 +1418,799 @@
// expected
}
}
+
+ public void testSimpleSearch() throws NamingException {
+ Attributes matchAttrs = new BasicAttributes();
+
+ // "" as parameter.
+ NamingEnumeration<SearchResult> ne = schema.search("", matchAttrs);
+
+ ArrayList<String> verifyList = new ArrayList<String>();
+ verifyList.add("ClassDefinition");
+ verifyList.add("AttributeDefinition");
+ verifyList.add("MatchingRule");
+ verifyList.add("SyntaxDefinition");
+
+ SearchResult result;
+ int count = 0;
+ int attributeCount = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ assertTrue(verifyList.remove(result.getName()));
+ attributeCount += result.getAttributes().size();
+ }
+ assertEquals(4, count);
+ assertEquals(4, attributeCount);
+
+ ne = schema.search("", null);
+ count = 0;
+ attributeCount = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ attributeCount += result.getAttributes().size();
+ }
+ assertEquals(4, count);
+ assertEquals(4, attributeCount);
+
+ ne = schema.search("classdefinition", matchAttrs);
+
+ count = 0;
+ attributeCount = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ attributeCount += result.getAttributes().size();
+ }
+ assertEquals(3, count);
+ assertEquals(18, attributeCount);
+
+ ne = schema.search("classdefinition/javaClass", matchAttrs);
+ assertFalse(ne.hasMore());
+ }
+
+ public void testSearchException() throws NamingException {
+ String nullString = null;
+ Name nullName = null;
+ try {
+ schema.search(nullString, null);
+ fail("Should throw NullPointerException.");
+ } catch (NullPointerException e) {
+ // Expected.
+ }
+
+ try {
+ schema.search(nullName, null);
+ fail("Should throw NullPointerException.");
+ } catch (NullPointerException e) {
+ // Expected.
+ }
+
+ try {
+ schema.search("invalid", null);
+ fail("Should throw NameNotFoundException.");
+ } catch (NameNotFoundException e) {
+ // Expected.
+ }
+
+ try {
+ schema.search("invalid/invalid/invalid", null);
+ fail("Should throw NameNotFoundException.");
+ } catch (NameNotFoundException e) {
+ // Expected.
+ }
+
+ try {
+ schema.search("invalid/invalid", null);
+ fail("Should throw NameNotFoundException.");
+ } catch (NameNotFoundException e) {
+ // Expected.
+ }
+
+ try {
+ schema.search("classdefinition/invalid", null);
+ fail("Should throw NameNotFoundException.");
+ } catch (NameNotFoundException e) {
+ // Expected.
+ }
+
+ try {
+ schema.search("classdefinition/javaClass/name", null);
+ fail("Should throw NameNotFoundException.");
+ } catch (NameNotFoundException e) {
+ // Expected.
+ }
+
+ try {
+ schema.search("classdefinition/javaClass/invalid", null);
+ fail("Should throw NameNotFoundException.");
+ } catch (NameNotFoundException e) {
+ // Expected.
+ }
+ }
+
+ public void testSearch_Filter() throws NamingException {
+ SearchControls controls = new SearchControls();
+ NamingEnumeration<SearchResult> ne = schema.search("",
+ "(objectclass=classdefinition)", controls);
+
+ SearchResult result;
+ int count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ }
+ assertEquals(1, count);
+
+ ne = schema.search("", "(!(objectclass=classdefinition))", controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ }
+ assertEquals(3, count);
+
+ ne = schema.search("",
+ "(|(objectclass=classdefinition)(objectclass=matchingrule))",
+ controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ }
+ assertEquals(2, count);
+
+ controls.setSearchScope(SearchControls.OBJECT_SCOPE);
+ controls.setCountLimit(5);
+ ne = schema.search("classdefinition", "(objectclass~=classdefinition)",
+ controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ }
+ assertEquals(1, count);
+ }
+
+ public void testSearch_matchAttributes() throws NamingException {
+ Attributes matchAttrs = new BasicAttributes();
+ NamingEnumeration<SearchResult> ne = schema.search("", matchAttrs);
+
+ Attributes returnedAttributes;
+ SearchResult result;
+ int count = 0;
+
+ // TODO
+ // The problem of ldap-jndi conversion
+ // There are too many places to handle the case-sensitive problem.
+ matchAttrs.put("obJectclass", "ClassDefinition");
+ ne = schema.search("", matchAttrs);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ }
+ assertEquals(1, count);
+
+ matchAttrs = new BasicAttributes(true);
+ matchAttrs.put("obJectclass", "ClasSDefinition");
+ ne = schema.search("", matchAttrs);
+ assertFalse(ne.hasMore());
+
+ matchAttrs.put("invalid", "ClassDefinition");
+ ne = schema.search("", matchAttrs);
+ assertFalse(ne.hasMore());
+ }
+
+ public void testSearch_AttributesToReturn() throws NamingException {
+ String[] attributesToReturn = new String[] { "objecTClass" };
+ NamingEnumeration<SearchResult> ne = schema.search("", null,
+ attributesToReturn);
+
+ Attributes returnedAttributes;
+ SearchResult result;
+ int count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ returnedAttributes = result.getAttributes();
+ assertEquals(1, returnedAttributes.size());
+ count++;
+ }
+ assertEquals(4, count);
+
+ attributesToReturn = new String[] { "objecTClass", "invalid" };
+ ne = schema.search("", null, attributesToReturn);
+
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ returnedAttributes = result.getAttributes();
+ assertEquals(1, returnedAttributes.size());
+ count++;
+ }
+ assertEquals(4, count);
+
+ attributesToReturn = new String[] { "invalid", "invalid2" };
+ ne = schema.search("", null, attributesToReturn);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ returnedAttributes = result.getAttributes();
+ assertEquals(0, returnedAttributes.size());
+ // System.out.println(result);
+ count++;
+ }
+ assertEquals(4, count);
+
+ attributesToReturn = new String[] {};
+ ne = schema.search("", null, attributesToReturn);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ returnedAttributes = result.getAttributes();
+ assertEquals(0, returnedAttributes.size());
+ count++;
+ }
+ assertEquals(4, count);
+
+ attributesToReturn = new String[] { "name" };
+ ne = schema.search("classdefinition", null, attributesToReturn);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ returnedAttributes = result.getAttributes();
+ assertEquals(1, returnedAttributes.size());
+ count++;
+ }
+ assertEquals(3, count);
+
+ attributesToReturn = new String[] { "name" };
+ ne = schema.search("classdefinition/javaClass", null,
+ attributesToReturn);
+ assertFalse(ne.hasMore());
+
+ attributesToReturn = new String[] { "objecTClass", "invalid", null };
+ ne = schema.search("", null, attributesToReturn);
+
+ count = 0;
+
+ try {
+ // No-bug difference.
+ // RI will throw NullPointerException.
+ while (ne.hasMore()) {
+ result = ne.next();
+ returnedAttributes = result.getAttributes();
+ assertEquals(1, returnedAttributes.size());
+ count++;
+ }
+ assertEquals(4, count);
+ }
+
+ catch (NullPointerException e) {
+ // Expected.
+ }
+ }
+
+ public void testSearch_Filter2() throws NamingException {
+ ArrayList<String> verifyList = new ArrayList<String>();
+ SearchControls controls = new SearchControls();
+ NamingEnumeration<SearchResult> ne = schema.search("",
+ "(objectclass=classdefinition)", controls);
+
+ SearchResult result;
+ int count = 0;
+ verifyList.add("ClassDefinition");
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ assertTrue(verifyList.remove(result.getName()));
+ }
+ assertEquals(1, count);
+
+ verifyList.add("SyntaxDefinition");
+ verifyList.add("AttributeDefinition");
+ verifyList.add("MatchingRule");
+ ne = schema.search("", "(!(objectclass=classdefinition))", controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ assertTrue(verifyList.remove(result.getName()));
+ }
+ assertEquals(3, count);
+
+ verifyList.add("MatchingRule");
+ verifyList.add("ClassDefinition");
+ ne = schema.search("",
+ "(|(objectclass=classdefinition)(objectclass=matchingrule))",
+ controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ assertTrue(verifyList.remove(result.getName()));
+ }
+ assertEquals(2, count);
+
+ verifyList.add("ClassDefinition");
+ ne = schema
+ .search(
+ "",
+ "(&(objectclass=classdefinition)(!(objectclass=matchingrule)))",
+ controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ assertTrue(verifyList.remove(result.getName()));
+ }
+ assertEquals(1, count);
+
+ ne = schema.search("", "(objectclass=*)", controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ }
+ assertEquals(4, count);
+
+ verifyList.add("SyntaxDefinition");
+ verifyList.add("ClassDefinition");
+ ne = schema.search("", "(objectclass=*s*defi*)", controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ assertTrue(verifyList.remove(result.getName()));
+ }
+ assertEquals(2, count);
+
+ verifyList.add("SyntaxDefinition");
+ ne = schema.search("", "(objectclass=s*defi*)", controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ assertTrue(verifyList.remove(result.getName()));
+ }
+ assertEquals(1, count);
+
+ ne = schema.search("", "(objectclass~=sdefi)", controls);
+ assertFalse(ne.hasMore());
+
+ ne = schema.search("", "(objectclass<=a)", controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ }
+ assertEquals(4, count);
+
+ verifyList.add("MatchingRule");
+ verifyList.add("SyntaxDefinition");
+ ne = schema.search("", "(objectclass>=M)", controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ assertTrue(verifyList.remove(result.getName()));
+ }
+ assertEquals(2, count);
+
+ ne = schema.search("",
+ "(|(!(objectclass=classdefinition))(!(objectclass=matchingrule)))",
+ controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ }
+ assertEquals(4, count);
+ }
+
+ public void testSearch_Subtree() throws NamingException {
+ addMoreSchemaData();
+
+ ArrayList<String> verifyList = new ArrayList<String>();
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
+ NamingEnumeration<SearchResult> ne = schema.search("", "(must=cn)",
+ controls);
+
+ SearchResult result;
+ int count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ assertTrue(result.getName().startsWith("ClassDefinition"));
+ assertTrue(result.getAttributes().get("must").contains("cn"));
+ }
+ assertEquals(3, count);
+
+ ne = schema.search("", "(x-schema=*)", controls);
+
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ assertTrue(result.getName().contains("/"));
+ assertNotNull(result.getAttributes().get("x-schema"));
+ }
+ assertEquals(10, count);
+
+ // Nonexist attributename;
+ ne = schema.search("", "(schema=*)", controls);
+ assertFalse(ne.hasMore());
+ }
+
+ public void testSearch_ReturnAtributes() throws NamingException {
+ addMoreSchemaData();
+ ArrayList<String> verifyList = new ArrayList<String>();
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
+ controls.setReturningAttributes(new String[] {});
+ NamingEnumeration<SearchResult> ne = schema.search("", "(must=cn)",
+ controls);
+
+ SearchResult result;
+ int count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ assertEquals(0, result.getAttributes().size());
+ }
+ assertEquals(3, count);
+
+ controls.setReturningAttributes(new String[] { "may" });
+ ne = schema.search("", "(&(mUst=cn)(maY=*))", controls);
+
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ assertEquals(1, result.getAttributes().size());
+ assertNotNull(result.getAttributes().get("MAY"));
+ }
+ assertEquals(3, count);
+ }
+
+ public void testFilterSearchException() throws NamingException {
+ SearchControls controls = new SearchControls();
+ try {
+ schema.search("", "", controls);
+ fail("Should throw StringIndexOutOfBoundsException");
+ } catch (InvalidSearchFilterException e) {
+ // Excpected.
+ } catch (StringIndexOutOfBoundsException e) {
+ // RI's problem.
+ }
+
+ try {
+ schema.search("invalid", "invalid", controls);
+ fail("Should throw NameNotFoundException.");
+ } catch (NameNotFoundException e) {
+ // Expected.
+ }
+
+ try {
+ schema.search("invalid/invalid/invalid", "invalid", controls);
+ fail("Should throw NameNotFoundException.");
+ } catch (NameNotFoundException e) {
+ // Expected.
+ }
+
+ try {
+ schema.search("invalid/invalid", "invalid", controls);
+ fail("Should throw NameNotFoundException.");
+ } catch (NameNotFoundException e) {
+ // Expected.
+ }
+
+ try {
+ schema.search("classdefinition/invalid", "invalid", controls);
+ fail("Should throw NameNotFoundException.");
+ } catch (NameNotFoundException e) {
+ // Expected.
+ }
+
+ try {
+ schema
+ .search("classdefinition/javaClass/name", "invalid",
+ controls);
+ fail("Should throw NameNotFoundException.");
+ } catch (NameNotFoundException e) {
+ // Expected.
+ }
+
+ try {
+ schema.search("classdefinition/javaClass/invalid", "invalid",
+ controls);
+ fail("Should throw NameNotFoundException.");
+ } catch (NameNotFoundException e) {
+ // Expected.
+ }
+ }
+
+ private void addMoreSchemaData() throws InvalidNameException {
+ // Add more schema data.
+ Hashtable subschemaTable = (Hashtable) schemaTable.get("objectclasses");
+
+ subschemaTable
+ .put(
+ "applicationprocess",
+ "( 2.5.6.11 name 'applicationprocess' "
+ + "desc 'rfc2256: an application process' "
+ + "sup top structural "
+ + "must cn may ( seealso $ ou $ l $ description ) x-schema 'core' )");
+
+ subschemaTable
+ .put(
+ "documentseries",
+ "( 0.9.2342.19200300.100.4.9 name 'documentseries' "
+ + "sup top structural must cn "
+ + "may ( description $ seealso $ telephonenumber $ l $ o $ ou ) "
+ + "x-schema 'cosine' )");
+
+ subschemaTable
+ .put(
+ "groupofuniquenames",
+ "( 2.5.6.17 name 'groupofuniquenames' "
+ + "desc 'rfc2256: a group of unique names (dn and unique identifier)' "
+ + "sup top structural must ( uniquemember $ cn ) "
+ + "may ( businesscategory $ seealso $ owner $ ou $ o $ description ) x-schema 'core' )");
+ schema = new LdapSchemaContextImpl(context, null, name, schemaTable,
+ LdapSchemaContextImpl.SCHEMA_ROOT_LEVEL);
+ }
+
+ public void testSearch_FilterWithArgs() throws NamingException {
+ ArrayList<String> verifyList = new ArrayList<String>();
+ SearchControls controls = new SearchControls();
+ Object[] filterArgs = new Object[] { "ClassDeFInition" };
+ NamingEnumeration<SearchResult> ne = schema.search("",
+ "(objectclass={0})", filterArgs, controls);
+
+ SearchResult result;
+ int count = 0;
+ verifyList.add("ClassDefinition");
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ assertTrue(verifyList.remove(result.getName()));
+ }
+ assertEquals(1, count);
+
+ verifyList.add("SyntaxDefinition");
+ verifyList.add("AttributeDefinition");
+ verifyList.add("MatchingRule");
+ filterArgs = new Object[] { "ClassDeFInition" };
+ ne = schema.search("", "(!(objectclass={0}))", filterArgs, controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ assertTrue(verifyList.remove(result.getName()));
+ }
+ assertEquals(3, count);
+
+ verifyList.add("MatchingRule");
+ verifyList.add("ClassDefinition");
+ filterArgs = new Object[] { "ClassDeFInition", "matchingrule" };
+ ne = schema.search("", "(|(objectclass={0})(objectclass={1}))",
+ filterArgs, controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ assertTrue(verifyList.remove(result.getName()));
+ }
+ assertEquals(2, count);
+
+ verifyList.add("ClassDefinition");
+ filterArgs = new Object[] { "ClassDeFInition", "matchingrule" };
+ ne = schema.search("", "(&(objectclass={0})(!(objectclass={1})))",
+ filterArgs, controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ assertTrue(verifyList.remove(result.getName()));
+ }
+ assertEquals(1, count);
+
+ ne = schema.search("", "(objectclass=*)", controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ }
+ assertEquals(4, count);
+
+ verifyList.add("SyntaxDefinition");
+ verifyList.add("ClassDefinition");
+ filterArgs = new Object[] { "defi" };
+ ne = schema.search("", "(objectclass=*s*{0}*)", filterArgs, controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ assertTrue(verifyList.remove(result.getName()));
+ }
+ assertEquals(2, count);
+
+ verifyList.add("SyntaxDefinition");
+ filterArgs = new Object[] { "defi" };
+ ne = schema.search("", "(objectclass=s*{0}*)", filterArgs, controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ assertTrue(verifyList.remove(result.getName()));
+ }
+ assertEquals(1, count);
+
+ filterArgs = new Object[] { "sdefi" };
+ ne = schema.search("", "(objectclass~={0})", filterArgs, controls);
+ assertFalse(ne.hasMore());
+
+ filterArgs = new Object[] { "a" };
+ ne = schema.search("", "(objectclass<={0})", filterArgs, controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ }
+ assertEquals(4, count);
+
+ verifyList.add("MatchingRule");
+ verifyList.add("SyntaxDefinition");
+ filterArgs = new Object[] { "M" };
+ ne = schema.search("", "(objectclass>={0})", filterArgs, controls);
+ count = 0;
+ while (ne.hasMore()) {
+ result = ne.next();
+ count++;
+ assertTrue(verifyList.remove(result.getName()));
+ }
+ assertEquals(2, count);
+ }
+
+ public void testClassDefinition() throws NamingException {
+ MockLdapSchemaContext mockSchema = new MockLdapSchemaContext(context,
+ null, name, schemaTable,
+ LdapSchemaContextImpl.SCHEMA_ROOT_LEVEL);
+ Attribute attribute = new BasicAttribute("objectClass", "javaClass");
+ attribute.add("extensibleobject");
+ attribute.add("prefNode");
+
+ DirContext classDefSchema = mockSchema.getClassDefinition(attribute);
+ ArrayList<String> verifyList = new ArrayList<String>();
+ verifyList.add("javaclass");
+ verifyList.add("prefnode");
+ verifyList.add("extensibleobject");
+ NamingEnumeration<NameClassPair> ne = classDefSchema.list("");
+ NameClassPair pair;
+ int count = 0;
+ while (ne.hasMore()) {
+ pair = ne.next();
+ count++;
+ assertTrue(verifyList.remove(pair.getName().toLowerCase()));
+ }
+ assertEquals(3, count);
+
+ ne = classDefSchema.list("prefnode");
+ assertFalse(ne.hasMore());
+
+ ne = classDefSchema.list("extensibleobject");
+ assertFalse(ne.hasMore());
+ }
+
+ public void testAttributeDefinition() throws NamingException {
+ addMoreAttributeData();
+ MockLdapContext mockContext = new MockLdapContext(context, null, "");
+ Attribute attr = new LdapAttribute("objectclass", mockContext);
+
+ DirContext attributeDefinition = attr.getAttributeDefinition();
+ NamingEnumeration<NameClassPair> ne = attributeDefinition.list("");
+ assertFalse(ne.hasMore());
+
+ try {
+ ne = attributeDefinition.list("invalid");
+ fail("Should throw NameNotFoundException");
+ } catch (NameNotFoundException e) {
+ // Expected.
+ }
+
+ Attributes schemaAttributes = attributeDefinition.getAttributes("");
+ assertEquals(7, schemaAttributes.size());
+ assertEquals("1.3.6.1.4.1.1466.115.121.1.38", schemaAttributes.get(
+ "syntax").get());
+ assertEquals("objectClass", schemaAttributes.get("name").get());
+ assertEquals("2.5.4.0", schemaAttributes.get("numericoid").get());
+ assertEquals("userApplications", schemaAttributes.get("usage").get());
+ assertEquals("objectIdentifierMatch", schemaAttributes.get("equality")
+ .get());
+ }
+
+ public void testSyntaxDefinition() throws NamingException {
+ addMoreAttributeData();
+ MockLdapContext mockContext = new MockLdapContext(context, null, "");
+ Attribute attr = new LdapAttribute("objectclass", mockContext);
+ DirContext attributeDefinition = attr.getAttributeSyntaxDefinition();
+ NamingEnumeration<NameClassPair> ne = attributeDefinition.list("");
+ assertFalse(ne.hasMore());
+
+ try {
+ ne = attributeDefinition.list("invalid");
+ fail("Should throw NameNotFoundException");
+ } catch (NameNotFoundException e) {
+ // Expected.
+ }
+ Attributes schemaAttributes = attributeDefinition.getAttributes("");
+ assertEquals(3, schemaAttributes.size());
+ assertEquals("system", schemaAttributes.get("x-schema").get());
+ assertEquals("true", schemaAttributes.get("x-is-human-readable").get());
+ assertEquals("1.3.6.1.4.1.1466.115.121.1.38", schemaAttributes.get(
+ "numericoid").get());
+ }
+
+ private void addMoreAttributeData() throws InvalidNameException {
+ // Add more schema data.
+ Hashtable subschemaTable = (Hashtable) schemaTable
+ .get("attributetypes");
+
+ subschemaTable
+ .put(
+ "objectclass",
+ "( 2.5.4.0 NAME 'objectClass' "
+ + "DESC 'RFC2256: object classes of the entity' "
+ + "EQUALITY objectIdentifierMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
+ + "USAGE userApplications X-SCHEMA 'system' )");
+
+ subschemaTable = (Hashtable) schemaTable.get("ldapsyntaxes");
+ subschemaTable
+ .put(
+ "1.3.6.1.4.1.1466.115.121.1.38",
+ "( 1.3.6.1.4.1.1466.115.121.1.38 X-SCHEMA 'system' X-IS-HUMAN-READABLE 'true' )");
+ schema = new LdapSchemaContextImpl(context, null, name, schemaTable,
+ LdapSchemaContextImpl.SCHEMA_ROOT_LEVEL);
+ }
+
+ public class MockLdapContext extends LdapContextImpl {
+ public MockLdapContext(LdapContextImpl context,
+ Hashtable<Object, Object> environment, String dn)
+ throws InvalidNameException {
+ super(context, environment, dn);
+ }
+
+ public DirContext getSchema(String name) {
+ return schema;
+ }
+
+ public Attributes getAttributes(Name name, String returningAttributes[])
+ throws NamingException {
+ Attribute attribute = new BasicAttribute("objectClass", "javaClass");
+ attribute.add("extensibleobject");
+ attribute.add("prefNode");
+ Attributes attributes = new BasicAttributes(true);
+ attributes.put(attribute);
+
+ return attributes;
+ }
+ }
+
+ public class MockLdapSchemaContext extends LdapSchemaContextImpl {
+
+ public MockLdapSchemaContext(LdapContextImpl ctx,
+ Hashtable<Object, Object> env, Name dn,
+ Hashtable<String, Object> schemaTable, int level)
+ throws InvalidNameException {
+ super(ctx, env, dn, schemaTable, level);
+ }
+
+ public DirContext getClassDefinition(Attribute attr)
+ throws NamingException {
+ return super.getClassDefinition(attr);
+ }
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ReferralExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ReferralExceptionTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ReferralExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ReferralExceptionTest.java Mon Jul 14 02:43:27 2008
@@ -20,6 +20,9 @@
import java.util.Hashtable;
import javax.naming.Context;
+import javax.naming.ldap.Control;
+import javax.naming.ldap.PagedResultsControl;
+import javax.naming.ldap.SortControl;
import junit.framework.TestCase;
@@ -124,4 +127,49 @@
assertNull(ex.getReferralInfo());
}
+
+ public void testGetReferralContext3() throws Exception {
+ Hashtable<Object, Object> initialEnv = new Hashtable<Object, Object>();
+
+ initialEnv.put(Context.REFERRAL, "throw");
+ initialEnv.put("test.getReferralContext", "GetReferralContext");
+
+ String[] referrals = new String[] { server.getURL() };
+ ReferralExceptionImpl ex = new ReferralExceptionImpl("cn=dn",
+ referrals, initialEnv);
+
+ Hashtable<Object, Object> env = new Hashtable<Object, Object>();
+
+ env.put(Context.REFERRAL, "follow");
+ env.put("test.getReferralContext", "changed");
+
+ server.setResponseSeq(new LdapMessage[] { new LdapMessage(
+ LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
+
+ assertEquals(referrals[0], ex.getReferralInfo());
+ Context refContext = ex.getReferralContext(env, new Control[] {
+ new PagedResultsControl(1, true),
+ new SortControl("hello", true) });
+
+ Hashtable<Object, Object> refEnv = (Hashtable<Object, Object>) refContext
+ .getEnvironment();
+
+ assertEquals(env.get(Context.REFERRAL), refEnv.get(Context.REFERRAL));
+ assertEquals(env.get("test.getReferralContext"), refEnv
+ .get("test.getReferralContext"));
+ Control[] cs = (Control[]) refEnv
+ .get("java.naming.ldap.control.connect");
+
+ assertNotNull(cs);
+ assertEquals(2, cs.length);
+ assertTrue(cs[0] instanceof PagedResultsControl);
+ assertTrue(cs[1] instanceof SortControl);
+
+ assertFalse(ex.skipReferral());
+
+ assertNull(ex.getReferralInfo());
+
+ // do nothing
+ ex.retryReferral();
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectOutputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectOutputStream.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectOutputStream.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectOutputStream.java Mon Jul 14 02:43:27 2008
@@ -368,7 +368,7 @@
*/
private Integer dumpCycle(Object obj) throws IOException {
// If the object has been saved already, save its handle only
- Integer handle = registeredObjectHandleFor(obj);
+ Integer handle = objectsWritten.get(obj);
if (handle != null) {
writeCyclicReference(handle);
return handle;
@@ -459,20 +459,6 @@
}
/**
- * Return the <code>Integer</code> handle used to tag object
- * <code>obj</code> as an instance that has been dumped already. Return
- * <code>null</code> if object <code>obj</code> has not been saved yet.
- *
- * @param obj
- * the object
- * @return null if object <code>obj</code> has not been saved yet. Integer
- * The handle that this object was assigned when it was saved.
- */
- private Integer registeredObjectHandleFor(Object obj) {
- return objectsWritten.get(obj);
- }
-
- /**
* Assume object <code>obj</code> has not been dumped yet, and assign a
* handle to it
*
@@ -484,7 +470,7 @@
*/
private Integer registerObjectWritten(Object obj) {
Integer handle = Integer.valueOf(nextHandle());
- registerObjectWritten(obj, handle);
+ objectsWritten.put(obj, handle);
return handle;
}
@@ -499,28 +485,13 @@
*/
private void removeUnsharedReference(Object obj, Integer previousHandle) {
if (previousHandle != null) {
- registerObjectWritten(obj, previousHandle);
+ objectsWritten.put(obj, previousHandle);
} else {
objectsWritten.remove(obj);
}
}
/**
- * Assume object <code>obj</code> has not been dumped yet, and assign a
- * handle to it, <code>handle</code>.
- *
- * @param obj
- * Non-null object being dumped.
- * @param handle
- * An Integer, the handle to this object
- *
- * @see #nextHandle
- */
- private void registerObjectWritten(Object obj, Integer handle) {
- objectsWritten.put(obj, handle);
- }
-
- /**
* If <code>enableReplaceObject()</code> was activated, computes the
* replacement object for the original object <code>object</code> and
* returns the replacement. Otherwise returns <code>object</code>.
@@ -763,7 +734,10 @@
}
if (handle == null) {
Class<?> classToWrite = classDesc.forClass();
- Integer previousHandle = objectsWritten.get(classDesc);
+ Integer previousHandle = null;
+ if (unshared) {
+ previousHandle = objectsWritten.get(classDesc);
+ }
// If we got here, it is a new (non-null) classDesc that will have
// to be registered as well
handle = registerObjectWritten(classDesc);
@@ -1207,7 +1181,10 @@
output.writeByte(TC_ARRAY);
writeClassDescForClass(arrayClass);
- Integer previousHandle = objectsWritten.get(array);
+ Integer previousHandle = null;
+ if (unshared) {
+ previousHandle = objectsWritten.get(array);
+ }
Integer handle = registerObjectWritten(array);
if (unshared) {
// remove reference to unshared object
@@ -1315,7 +1292,10 @@
unshared);
}
- Integer previousHandle = objectsWritten.get(object);
+ Integer previousHandle = null;
+ if (unshared) {
+ previousHandle = objectsWritten.get(object);
+ }
Integer handle = registerObjectWritten(object);
if (unshared) {
// remove reference to unshared object
@@ -1449,7 +1429,10 @@
// Either serializable or externalizable, now we can save info
output.writeByte(TC_OBJECT);
writeClassDescForClass(theClass);
- Integer previousHandle = objectsWritten.get(object);
+ Integer previousHandle = null;
+ if (unshared) {
+ previousHandle = objectsWritten.get(object);
+ }
Integer handle = registerObjectWritten(object);
// This is how we know what to do in defaultWriteObject. And it is also
@@ -1521,7 +1504,10 @@
}
output.writeUTFBytes(object, count);
- Integer previousHandle = objectsWritten.get(object);
+ Integer previousHandle = null;
+ if (unshared) {
+ previousHandle = objectsWritten.get(object);
+ }
Integer handle = registerObjectWritten(object);
if (unshared) {
// remove reference to unshared object
@@ -1692,7 +1678,7 @@
// Make the original object also map to the same
// handle.
if (replacementHandle != null) {
- registerObjectWritten(object, replacementHandle);
+ objectsWritten.put(object, replacementHandle);
}
return replacementHandle;
}
@@ -1713,7 +1699,7 @@
computeClassBasedReplacement, false);
// Make the original object also map to the same handle.
if (replacementHandle != null) {
- registerObjectWritten(object, replacementHandle);
+ objectsWritten.put(object, replacementHandle);
}
return replacementHandle;
}
@@ -1760,7 +1746,10 @@
ObjectStreamClass classDesc = ObjectStreamClass.lookup(theClass);
// set flag for enum, the flag is (SC_SERIALIZABLE | SC_ENUM)
classDesc.setFlags((byte) (SC_SERIALIZABLE | SC_ENUM));
- Integer previousHandle = objectsWritten.get(classDesc);
+ Integer previousHandle = null;
+ if (unshared) {
+ previousHandle = objectsWritten.get(classDesc);
+ }
Integer handle = null;
if (!unshared) {
handle = dumpCycle(classDesc);
@@ -1816,7 +1805,10 @@
}
ObjectStreamClass classDesc = writeEnumDesc(theClass, unshared);
- Integer previousHandle = objectsWritten.get(object);
+ Integer previousHandle = null;
+ if (unshared) {
+ previousHandle = objectsWritten.get(object);
+ }
Integer handle = registerObjectWritten(object);
ObjectStreamField[] fields = classDesc.getSuperclass().fields();
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/ArrayList.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/ArrayList.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/ArrayList.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/ArrayList.java Mon Jul 14 02:43:27 2008
@@ -404,20 +404,16 @@
increment = 12;
}
E[] newArray = newElementArray(size + increment);
- if (location < size / 2) {
- int newFirst = newArray.length - (size + required);
- System.arraycopy(array, location, newArray, location + increment,
- size - location);
- System.arraycopy(array, firstIndex, newArray, newFirst, location);
- firstIndex = newFirst;
- lastIndex = newArray.length;
- } else {
- System.arraycopy(array, firstIndex, newArray, 0, location);
- System.arraycopy(array, location, newArray, location + required,
- size - location);
- firstIndex = 0;
- lastIndex += required;
- }
+ int newFirst = increment - required;
+ // Copy elements after location to the new array skipping inserted
+ // elements
+ System.arraycopy(array, location + firstIndex, newArray, newFirst
+ + location + required, size - location);
+ // Copy elements before location to the new array from firstIndex
+ System.arraycopy(array, firstIndex, newArray, newFirst, location);
+ firstIndex = newFirst;
+ lastIndex = size + increment;
+
array = newArray;
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HashMap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HashMap.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HashMap.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HashMap.java Mon Jul 14 02:43:27 2008
@@ -23,25 +23,51 @@
import java.io.Serializable;
/**
- * HashMap is an implementation of Map. All optional operations are supported,
- * adding and removing. Keys and values can be any objects.
+ * HashMap is the hash table based implementation of the Map interface.
+ *
+ * This implementation provides all of the optional map operations, and permits
+ * null values and the null key. (The HashMap class is roughly equivalent to
+ * Hashtable, except that it is unsynchronized and permits nulls.)
*/
public class HashMap<K, V> extends AbstractMap<K, V> implements Map<K, V>,
Cloneable, Serializable {
+
private static final long serialVersionUID = 362498820763181265L;
+ /*
+ * Actual count of entries
+ */
transient int elementCount;
+ /*
+ * The internal data structure to hold Entries
+ */
transient Entry<K, V>[] elementData;
- final float loadFactor;
-
- int threshold;
-
+ /*
+ * modification count, to keep track of structural modifications between the
+ * HashMap and the iterator
+ */
transient int modCount = 0;
+ /*
+ * default size that an HashMap created using the default constructor would
+ * have.
+ */
private static final int DEFAULT_SIZE = 16;
+ /*
+ * maximum ratio of (stored elements)/(storage size) which does not lead to
+ * rehash
+ */
+ final float loadFactor;
+
+ /*
+ * maximum number of elements that can be put in this map before having to
+ * rehash
+ */
+ int threshold;
+
static class Entry<K, V> extends MapEntry<K, V> {
final int origKeyHash;
@@ -54,7 +80,7 @@
Entry(K theKey, V theValue) {
super(theKey, theValue);
- origKeyHash = (theKey == null ? 0 : theKey.hashCode());
+ origKeyHash = (theKey == null ? 0 : computeHashCode(theKey));
}
@Override
@@ -77,7 +103,6 @@
final HashMap<K, V> associatedMap;
-
AbstractMapIterator(HashMap<K, V> hm) {
associatedMap = hm;
expectedModCount = hm.modCount;
@@ -129,7 +154,6 @@
}
if(prevEntry==null){
int index = currentEntry.origKeyHash & (associatedMap.elementData.length - 1);
- //assert associatedMap.elementData[index] == currentEntry;
associatedMap.elementData[index] = associatedMap.elementData[index].next;
} else {
prevEntry.next = currentEntry.next;
@@ -217,7 +241,7 @@
public boolean contains(Object object) {
if (object instanceof Map.Entry) {
Map.Entry<?, ?> oEntry = (Map.Entry<?, ?>) object;
- Entry entry = associatedMap.getEntry(oEntry.getKey());
+ Entry<KT, VT> entry = associatedMap.getEntry(oEntry.getKey());
return valuesEq(entry, oEntry);
}
return false;
@@ -227,7 +251,7 @@
return (entry != null) &&
((entry.value == null) ?
(oEntry.getValue() == null) :
- (entry.value.equals(oEntry.getValue())));
+ (areEqualValues(entry.value, oEntry.getValue())));
}
@Override
@@ -265,17 +289,17 @@
* when the capacity is less than zero
*/
public HashMap(int capacity) {
- if (capacity >= 0) {
- capacity = calculateCapacity(capacity);
- elementCount = 0;
- elementData = newElementArray(capacity);
- loadFactor = 0.75f; // Default load factor of 0.75
- computeMaxSize();
- } else {
- throw new IllegalArgumentException();
+ this(capacity, 0.75f); // default load factor of 0.75
}
- }
+ /**
+ * Calculates the capacity of storage required for storing given number of
+ * elements
+ *
+ * @param x
+ * number of elements
+ * @return storage size
+ */
private static final int calculateCapacity(int x) {
if(x >= 1 << 30){
return 1 << 30;
@@ -310,9 +334,9 @@
if (capacity >= 0 && loadFactor > 0) {
capacity = calculateCapacity(capacity);
elementCount = 0;
- elementData = newElementArray(capacity == 0 ? 1 : capacity);
+ elementData = newElementArray(capacity);
this.loadFactor = loadFactor;
- computeMaxSize();
+ computeThreshold();
} else {
throw new IllegalArgumentException();
}
@@ -326,7 +350,7 @@
* the mappings to add
*/
public HashMap(Map<? extends K, ? extends V> map) {
- this(map.size() < 6 ? 11 : map.size() * 2);
+ this(calculateCapacity(map.size()));
putAllImpl(map);
}
@@ -359,23 +383,18 @@
HashMap<K, V> map = (HashMap<K, V>) super.clone();
map.elementCount = 0;
map.elementData = newElementArray(elementData.length);
- Entry<K, V> entry;
- for (int i = 0; i < elementData.length; i++) {
- if ((entry = elementData[i]) != null){
- map.putImpl(entry.getKey(), entry.getValue());
- while (entry.next != null){
- entry = entry.next;
- map.putImpl(entry.getKey(), entry.getValue());
- }
- }
- }
+ map.putAll(this);
+
return map;
} catch (CloneNotSupportedException e) {
return null;
}
}
- private void computeMaxSize() {
+ /**
+ * Computes the threshold for rehashing
+ */
+ private void computeThreshold() {
threshold = (int) (elementData.length * loadFactor);
}
@@ -404,17 +423,17 @@
@Override
public boolean containsValue(Object value) {
if (value != null) {
- for (int i = elementData.length; --i >= 0;) {
+ for (int i = 0; i < elementData.length; i++) {
Entry<K, V> entry = elementData[i];
while (entry != null) {
- if (value.equals(entry.value)) {
+ if (areEqualValues(value, entry.value)) {
return true;
}
entry = entry.next;
}
}
} else {
- for (int i = elementData.length; --i >= 0;) {
+ for (int i = 0; i < elementData.length; i++) {
Entry<K, V> entry = elementData[i];
while (entry != null) {
if (entry.value == null) {
@@ -460,7 +479,7 @@
if (key == null) {
m = findNullKeyEntry();
} else {
- int hash = key.hashCode();
+ int hash = computeHashCode(key);
int index = hash & (elementData.length - 1);
m = findNonNullKeyEntry(key, index, hash);
}
@@ -469,7 +488,7 @@
final Entry<K,V> findNonNullKeyEntry(Object key, int index, int keyHash) {
Entry<K,V> m = elementData[index];
- while (m != null && (m.origKeyHash != keyHash || !key.equals(m.key))) {
+ while (m != null && (m.origKeyHash != keyHash || !areEqualKeys(key, m.key))) {
m = m.next;
}
return m;
@@ -562,7 +581,7 @@
entry = createHashedEntry(null, 0, 0);
}
} else {
- int hash = key.hashCode();
+ int hash = computeHashCode(key);
int index = hash & (elementData.length - 1);
entry = findNonNullKeyEntry(key, index, hash);
if (entry == null) {
@@ -636,7 +655,7 @@
}
}
elementData = newData;
- computeMaxSize();
+ computeThreshold();
}
void rehash() {
@@ -681,10 +700,10 @@
Entry<K, V> entry;
Entry<K, V> last = null;
if (key != null) {
- int hash = key.hashCode();
+ int hash = computeHashCode(key);
index = hash & (elementData.length - 1);
entry = elementData[index];
- while (entry != null && !(entry.origKeyHash == hash && key.equals(entry.key))) {
+ while (entry != null && !(entry.origKeyHash == hash && areEqualKeys(key, entry.key))) {
last = entry;
entry = entry.next;
}
@@ -775,9 +794,25 @@
elementCount = stream.readInt();
for (int i = elementCount; --i >= 0;) {
K key = (K) stream.readObject();
- int index = (null == key) ? 0 : (key.hashCode() & (length - 1));
+ int index = (null == key) ? 0 : (computeHashCode(key) & (length - 1));
createEntry(key, index, (V) stream.readObject());
}
}
+ /*
+ * Contract-related functionality
+ */
+ static int computeHashCode(Object key) {
+ return key.hashCode();
+}
+
+ static boolean areEqualKeys(Object key1, Object key2) {
+ return key1.equals(key2);
+ }
+
+ static boolean areEqualValues(Object value1, Object value2) {
+ return value1.equals(value2);
+ }
+
+
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/FileURLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/FileURLConnection.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/FileURLConnection.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/FileURLConnection.java Mon Jul 14 02:43:27 2008
@@ -62,10 +62,6 @@
if (fileName == null) {
fileName = ""; //$NON-NLS-1$
}
- String host = url.getHost();
- if (host != null && host.length() > 0) {
- fileName = "//" + host + fileName; //$NON-NLS-1$
- }
fileName = Util.decode(fileName, false);
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/Handler.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/Handler.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/Handler.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/Handler.java Mon Jul 14 02:43:27 2008
@@ -41,8 +41,8 @@
*
*/
@Override
- public URLConnection openConnection(URL url) {
- return new FileURLConnection(url);
+ public URLConnection openConnection(URL url) throws IOException {
+ return openConnection(url, null);
}
/**
@@ -58,18 +58,28 @@
* @throws IOException
* if this handler fails to establish a connection.
* @throws IllegalArgumentException
- * if any argument is null or of an invalid type.
+ * if the url argument is null.
* @throws UnsupportedOperationException
* if the protocol handler doesn't support this method.
*/
@Override
public URLConnection openConnection(URL url, Proxy proxy)
throws IOException {
- if (null == url || null == proxy) {
+ if (null == url) {
// K034b=url and proxy can not be null
throw new IllegalArgumentException(Msg.getString("K034b")); //$NON-NLS-1$
}
- return new FileURLConnection(url);
+
+ String host = url.getHost();
+ if (host == null || host.length() == 0
+ || host.equalsIgnoreCase("localhost")) { //$NON-NLS-1$
+ return new FileURLConnection(url);
+ }
+
+ // If a hostname is specified try to get the resource using FTP
+ URL ftpURL = new URL("ftp", host, url.getFile()); //$NON-NLS-1$
+ return (proxy == null) ? ftpURL.openConnection() : ftpURL
+ .openConnection(proxy);
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/helpers.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/helpers.c?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/helpers.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/helpers.c Mon Jul 14 02:43:27 2008
@@ -299,6 +299,7 @@
struct tm *tmStruct;
char tzInfo[9];
int h, m;
+ jboolean fls;
time(&curTime);
//curTime += 15552000l;
@@ -322,7 +323,7 @@
tzInfo[7] = m % 10 + '0';
tzInfo[8] = 0;
- jboolean fls = JNI_FALSE;
+ fls = JNI_FALSE;
(*env)->SetBooleanArrayRegion(env, isCustomTimeZone, 0, 1, &fls);
return (*env)->NewStringUTF(env, tzInfo);
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/procimpl.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/procimpl.c?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/procimpl.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/procimpl.c Mon Jul 14 02:43:27 2008
@@ -150,6 +150,7 @@
if (grdpid == -1) goto error;
if (grdpid == 0) {
+#ifndef ZOS
/* Close file descriptors that are not used */
close(newFD[0][1]);
close(newFD[1][0]);
@@ -163,6 +164,7 @@
setCloseOnExec(newFD[2][1]);
setCloseOnExec(forkedChildIsRunning[1]);
setCloseOnExec(execvFailure[1]);
+#endif /* ZOS */
/* Redirect pipes so grand-child inherits new pipes */
char dummy = '\0';
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/file/FileURLConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/file/FileURLConnectionTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/file/FileURLConnectionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/file/FileURLConnectionTest.java Mon Jul 14 02:43:27 2008
@@ -55,5 +55,12 @@
FileURLConnection conn = new FileURLConnection(anchorUrl);
assertNotNull(conn.getInputStream());
+
+ // Regression for Harmony-5779
+ String localURLString = "file://localhost/" + url.getFile();
+ URL localURL = new URL(localURLString);
+ conn = new FileURLConnection(localURL);
+ assertNotNull(conn.getInputStream());
+ assertEquals("file",conn.getURL().getProtocol());
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLTest.java Mon Jul 14 02:43:27 2008
@@ -1115,6 +1115,23 @@
}
/**
+ * @tests java.net.URL#openConnection()
+ */
+ public void test_openConnection_FileProtocal() throws Exception {
+ // Regression test for Harmony-5779
+ String basedir = new File("temp.java").getAbsolutePath();
+ String fileUrlString = "file://localhost/" + basedir;
+ URLConnection conn = new URL(fileUrlString).openConnection();
+ assertEquals("file",conn.getURL().getProtocol());
+ assertEquals(new File(basedir),new File(conn.getURL().getFile()));
+
+ String nonLocalUrlString = "file://anything/" + basedir;
+ conn = new URL(nonLocalUrlString).openConnection();
+ assertEquals("ftp",conn.getURL().getProtocol());
+ assertEquals(new File(basedir),new File(conn.getURL().getFile()));
+ }
+
+ /**
* URLStreamHandler implementation class necessary for tests.
*/
private class TestURLStreamHandler extends URLStreamHandler {
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java Mon Jul 14 02:43:27 2008
@@ -146,6 +146,7 @@
/**
* @tests java.util.ArrayList#addAll(int, java.util.Collection)
*/
+ @SuppressWarnings("unchecked")
public void test_addAllILjava_util_Collection_2() {
// Regression for HARMONY-467
ArrayList obj = new ArrayList();
@@ -179,6 +180,32 @@
}
assertTrue("The object list is not the same as orginal list", obj
.containsAll(list1) && list1.containsAll(obj));
+
+ // Regression for Harmony-5799
+ list1 = new ArrayList();
+ list2 = new ArrayList();
+ int location = 2;
+
+ String[] strings = {"0","1","2","3","4","5","6"};
+ int[] integers = {0,1,2,3,4,5,6,7,8,9};
+ for (int i = 0; i < 7; i++){
+ list1.add(strings[i]);
+ }
+ for (int i = 0; i < 10; i++){
+ list2.add(integers[i]);
+ }
+ list1.remove(location);
+ list1.addAll(location,list2);
+
+ // Inserted elements should be equal to integers array
+ for(int i = 0; i < integers.length; i ++){
+ assertEquals(integers[i],list1.get(location+i));
+ }
+ // Elements after inserted location should
+ // be equals to related elements in strings array
+ for(int i = location + 1; i < strings.length; i++){
+ assertEquals(strings[i],list1.get(i+integers.length-1));
+ }
}
public void test_addAllCollectionOfQextendsE() {
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TreeMapTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TreeMapTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TreeMapTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TreeMapTest.java Mon Jul 14 02:43:27 2008
@@ -1714,6 +1714,36 @@
}
/**
+ * Tests entrySet().contains() method behaviour with respect to entries
+ * with null values.
+ * Regression test for HARMONY-5788.
+ */
+ public void test_entrySet_contains() throws Exception {
+ TreeMap master = new TreeMap<String, String>();
+ TreeMap test_map = new TreeMap<String, String>();
+
+ master.put("null", null);
+ Object[] entry = master.entrySet().toArray();
+ assertFalse("Empty map should not contain the null-valued entry",
+ test_map.entrySet().contains(entry[0]));
+
+ Map<String, String> submap = test_map.subMap("a","z");
+ entry = master.entrySet().toArray();
+ assertFalse("Empty submap should not contain the null-valued entry",
+ submap.entrySet().contains(entry[0]));
+
+ test_map.put("null", null);
+ assertTrue("entrySet().containsAll(...) should work with null values",
+ test_map.entrySet().containsAll(master.entrySet()));
+
+ master.clear();
+ master.put("null", '0');
+ entry = master.entrySet().toArray();
+ assertFalse("Null-valued entry should not equal non-null-valued entry",
+ test_map.entrySet().contains(entry[0]));
+ }
+
+ /**
* Sets up the fixture, for example, open a network connection. This method
* is called before a test is executed.
*/
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/AlreadyConnectedExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/AlreadyConnectedExceptionTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/AlreadyConnectedExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/AlreadyConnectedExceptionTest.java Mon Jul 14 02:43:27 2008
@@ -25,6 +25,16 @@
* Tests for AlreadyConnectedException
*/
public class AlreadyConnectedExceptionTest extends TestCase {
+
+ /**
+ * @tests {@link java.nio.channels.AlreadyConnectedException#AlreadyConnectedException()}
+ */
+ public void test_Constructor() {
+ AlreadyConnectedException e = new AlreadyConnectedException();
+ assertNull(e.getMessage());
+ assertNull(e.getLocalizedMessage());
+ assertNull(e.getCause());
+ }
/**
* @tests serialization/deserialization compatibility.
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/AsynchronousCloseExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/AsynchronousCloseExceptionTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/AsynchronousCloseExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/AsynchronousCloseExceptionTest.java Mon Jul 14 02:43:27 2008
@@ -27,6 +27,16 @@
public class AsynchronousCloseExceptionTest extends TestCase {
/**
+ * @tests {@link java.nio.channels.AsynchronousCloseException#AsynchronousCloseException()}
+ */
+ public void test_Constructor() {
+ AsynchronousCloseException e = new AsynchronousCloseException();
+ assertNull(e.getMessage());
+ assertNull(e.getLocalizedMessage());
+ assertNull(e.getCause());
+ }
+
+ /**
* @tests serialization/deserialization compatibility.
*/
public void testSerializationSelf() throws Exception {
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/CancelledKeyExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/CancelledKeyExceptionTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/CancelledKeyExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/CancelledKeyExceptionTest.java Mon Jul 14 02:43:27 2008
@@ -25,6 +25,16 @@
* Tests for CancelledKeyException
*/
public class CancelledKeyExceptionTest extends TestCase {
+
+ /**
+ * @tests {@link java.nio.channels.CancelledKeyException#CancelledKeyException()}
+ */
+ public void test_Constructor() {
+ CancelledKeyException e = new CancelledKeyException();
+ assertNull(e.getMessage());
+ assertNull(e.getLocalizedMessage());
+ assertNull(e.getCause());
+ }
/**
* @tests serialization/deserialization compatibility.
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ClosedByInterruptExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ClosedByInterruptExceptionTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ClosedByInterruptExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ClosedByInterruptExceptionTest.java Mon Jul 14 02:43:27 2008
@@ -25,7 +25,16 @@
* Tests for ClosedByInterruptException
*/
public class ClosedByInterruptExceptionTest extends TestCase {
-
+
+ /**
+ * @tests {@link java.nio.channels.ClosedByInterruptException#ClosedByInterruptException()}
+ */
+ public void test_Constructor() {
+ ClosedByInterruptException e = new ClosedByInterruptException();
+ assertNull(e.getMessage());
+ assertNull(e.getLocalizedMessage());
+ assertNull(e.getCause());
+ }
/**
* @tests serialization/deserialization compatibility.
*/
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ClosedChannelExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ClosedChannelExceptionTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ClosedChannelExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ClosedChannelExceptionTest.java Mon Jul 14 02:43:27 2008
@@ -25,6 +25,16 @@
* Tests for ClosedChannelException
*/
public class ClosedChannelExceptionTest extends TestCase {
+
+ /**
+ * @tests {@link java.nio.channels.ClosedChannelException#ClosedChannelException()}
+ */
+ public void test_Constructor() {
+ ClosedChannelException e = new ClosedChannelException();
+ assertNull(e.getMessage());
+ assertNull(e.getLocalizedMessage());
+ assertNull(e.getCause());
+ }
/**
* @tests serialization/deserialization compatibility.
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ClosedSelectorExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ClosedSelectorExceptionTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ClosedSelectorExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ClosedSelectorExceptionTest.java Mon Jul 14 02:43:27 2008
@@ -25,6 +25,16 @@
* Tests for ClosedSelectorException
*/
public class ClosedSelectorExceptionTest extends TestCase {
+
+ /**
+ * @tests {@link java.nio.channels.ClosedSelectorException#ClosedSelectorException()}
+ */
+ public void test_Constructor() {
+ ClosedSelectorException e = new ClosedSelectorException();
+ assertNull(e.getMessage());
+ assertNull(e.getLocalizedMessage());
+ assertNull(e.getCause());
+ }
/**
* @tests serialization/deserialization compatibility.
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ConnectionPendingExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ConnectionPendingExceptionTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ConnectionPendingExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ConnectionPendingExceptionTest.java Mon Jul 14 02:43:27 2008
@@ -25,6 +25,16 @@
* Tests for ConnectionPendingException
*/
public class ConnectionPendingExceptionTest extends TestCase {
+
+ /**
+ * @tests {@link java.nio.channels.ConnectionPendingException#ConnectionPendingException()}
+ */
+ public void test_Constructor() {
+ ConnectionPendingException e = new ConnectionPendingException();
+ assertNull(e.getMessage());
+ assertNull(e.getLocalizedMessage());
+ assertNull(e.getCause());
+ }
/**
* @tests serialization/deserialization compatibility.
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/FileLockInterruptionExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/FileLockInterruptionExceptionTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/FileLockInterruptionExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/FileLockInterruptionExceptionTest.java Mon Jul 14 02:43:27 2008
@@ -25,6 +25,16 @@
* Tests for FileLockInterruptionException
*/
public class FileLockInterruptionExceptionTest extends TestCase {
+
+ /**
+ * @tests {@link java.nio.channels.FileLockInterruptionException#FileLockInterruptionException()}
+ */
+ public void test_Constructor() {
+ FileLockInterruptionException e = new FileLockInterruptionException();
+ assertNull(e.getMessage());
+ assertNull(e.getLocalizedMessage());
+ assertNull(e.getCause());
+ }
/**
* @tests serialization/deserialization compatibility.
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/IllegalBlockingModeExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/IllegalBlockingModeExceptionTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/IllegalBlockingModeExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/IllegalBlockingModeExceptionTest.java Mon Jul 14 02:43:27 2008
@@ -25,6 +25,16 @@
* Tests for IllegalBlockingModeException
*/
public class IllegalBlockingModeExceptionTest extends TestCase {
+
+ /**
+ * @tests {@link java.nio.channels.IllegalBlockingModeException#IllegalBlockingModeException()}
+ */
+ public void test_Constructor() {
+ IllegalBlockingModeException e = new IllegalBlockingModeException();
+ assertNull(e.getMessage());
+ assertNull(e.getLocalizedMessage());
+ assertNull(e.getCause());
+ }
/**
* @tests serialization/deserialization compatibility.
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/IllegalSelectorExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/IllegalSelectorExceptionTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/IllegalSelectorExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/IllegalSelectorExceptionTest.java Mon Jul 14 02:43:27 2008
@@ -25,6 +25,16 @@
* Tests for IllegalSelectorException
*/
public class IllegalSelectorExceptionTest extends TestCase {
+
+ /**
+ * @tests {@link java.nio.channels.IllegalSelectorException#IllegalSelectorException()}
+ */
+ public void test_Constructor() {
+ IllegalSelectorException e = new IllegalSelectorException();
+ assertNull(e.getMessage());
+ assertNull(e.getLocalizedMessage());
+ assertNull(e.getCause());
+ }
/**
* @tests serialization/deserialization compatibility.
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/NoConnectionPendingExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/NoConnectionPendingExceptionTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/NoConnectionPendingExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/NoConnectionPendingExceptionTest.java Mon Jul 14 02:43:27 2008
@@ -25,6 +25,16 @@
* Tests for NoConnectionPendingException
*/
public class NoConnectionPendingExceptionTest extends TestCase {
+
+ /**
+ * @tests {@link java.nio.channels.NoConnectionPendingException#NoConnectionPendingException()}
+ */
+ public void test_Constructor() {
+ NoConnectionPendingException e = new NoConnectionPendingException();
+ assertNull(e.getMessage());
+ assertNull(e.getLocalizedMessage());
+ assertNull(e.getCause());
+ }
/**
* @tests serialization/deserialization compatibility.
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/NonReadableChannelExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/NonReadableChannelExceptionTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/NonReadableChannelExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/NonReadableChannelExceptionTest.java Mon Jul 14 02:43:27 2008
@@ -25,6 +25,16 @@
* Tests for NonReadableChannelException
*/
public class NonReadableChannelExceptionTest extends TestCase {
+
+ /**
+ * @tests {@link java.nio.channels.NonReadableChannelException#NonReadableChannelException()}
+ */
+ public void test_Constructor() {
+ NonReadableChannelException e = new NonReadableChannelException();
+ assertNull(e.getMessage());
+ assertNull(e.getLocalizedMessage());
+ assertNull(e.getCause());
+ }
/**
* @tests serialization/deserialization compatibility.
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/NonWritableChannelExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/NonWritableChannelExceptionTest.java?rev=676530&r1=676529&r2=676530&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/NonWritableChannelExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/NonWritableChannelExceptionTest.java Mon Jul 14 02:43:27 2008
@@ -25,6 +25,16 @@
* Tests for NonWritableChannelException
*/
public class NonWritableChannelExceptionTest extends TestCase {
+
+ /**
+ * @tests {@link java.nio.channels.NonWritableChannelException#NonWritableChannelException()}
+ */
+ public void test_Constructor() {
+ NonWritableChannelException e = new NonWritableChannelException();
+ assertNull(e.getMessage());
+ assertNull(e.getLocalizedMessage());
+ assertNull(e.getCause());
+ }
/**
* @tests serialization/deserialization compatibility.