Пример #1
1
  static void serTest(Map s, int size) throws Exception {
    if (!(s instanceof Serializable)) return;
    System.out.print("Serialize              : ");

    for (int i = 0; i < size; i++) {
      s.put(new Integer(i), Boolean.TRUE);
    }

    long startTime = System.currentTimeMillis();

    FileOutputStream fs = new FileOutputStream("MapCheck.dat");
    ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(fs));
    out.writeObject(s);
    out.close();

    FileInputStream is = new FileInputStream("MapCheck.dat");
    ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(is));
    Map m = (Map) in.readObject();

    long endTime = System.currentTimeMillis();
    long time = endTime - startTime;

    System.out.print(time + "ms");

    if (s instanceof IdentityHashMap) return;
    reallyAssert(s.equals(m));
  }
Пример #2
0
  @Override
  public boolean equals(final Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    final JarPluginProviderLoader that = (JarPluginProviderLoader) o;

    if (classCache != null ? !classCache.equals(that.classCache) : that.classCache != null) {
      return false;
    }
    if (!pluginJar.equals(that.pluginJar)) {
      return false;
    }
    if (mainAttributes != null
        ? !mainAttributes.equals(that.mainAttributes)
        : that.mainAttributes != null) {
      return false;
    }
    if (pluginProviderDefs != null
        ? !pluginProviderDefs.equals(that.pluginProviderDefs)
        : that.pluginProviderDefs != null) {
      return false;
    }

    return true;
  }
Пример #3
0
 @Override
 public boolean equals(Object o) {
   if (this == o) return true;
   // TODO: why not allow equality to non-HashIndex indices?
   if (!(o instanceof HashIndex)) return false;
   HashIndex hashIndex = (HashIndex) o;
   return indexes.equals(hashIndex.indexes) && objects.equals(hashIndex.objects);
 }
Пример #4
0
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (!(o instanceof Request)) return false;

    Request request = (Request) o;

    if (saveInCache != request.saveInCache) return false;
    if (archiveResult != request.archiveResult) return false;
    if (withParams != request.withParams) return false;
    if (!url.equals(request.url)) return false;
    if (suffix != null ? !suffix.equals(request.suffix) : request.suffix != null) return false;
    if (!params.equals(request.params)) return false;
    if (encoding != null ? !encoding.equals(request.encoding) : request.encoding != null)
      return false;
    if (content != null ? !content.equals(request.content) : request.content != null) return false;
    if (!headers.equals(request.headers)) return false;
    return method == request.method;
  }
Пример #5
0
  static void twoMapTest2(Map s, Object[] key, Object[] absent) {
    int size = key.length;

    Map s2 = newMap();
    putAllTest("Add    Absent          ", size, s, s2);
    putAllTest("Modify Present         ", size, s, s2);

    Object lastkey = kitTest(s2, size);
    Object hold = s2.get(lastkey);
    int sum = 0;

    timer.start("Traverse entry         ", size * 12); // 12 until finish

    int sh1 = s.hashCode() - s2.hashCode();
    reallyAssert(sh1 == 0);

    boolean eq1 = s2.equals(s);
    boolean eq2 = s.equals(s2);
    reallyAssert(eq1 && eq2);

    Set es2 = s2.entrySet();
    for (Iterator it = s.entrySet().iterator(); it.hasNext(); ) {
      Object entry = it.next();
      if (es2.contains(entry)) ++sum;
    }
    reallyAssert(sum == size);

    s2.put(lastkey, MISSING);

    int sh2 = s.hashCode() - s2.hashCode();
    reallyAssert(sh2 != 0);

    eq1 = s2.equals(s);
    eq2 = s.equals(s2);
    reallyAssert(!eq1 && !eq2);

    sum = 0;
    for (Iterator it = s.entrySet().iterator(); it.hasNext(); ) {
      Map.Entry e = (Map.Entry) it.next();
      e.setValue(absent[sum++]);
    }
    reallyAssert(sum == size);
    for (Iterator it = s2.entrySet().iterator(); it.hasNext(); ) {
      Map.Entry e = (Map.Entry) it.next();
      e.setValue(s.get(e.getKey()));
    }

    timer.finish();

    int rmiss = 0;
    timer.start("Remove Present         ", size * 2);
    Iterator s2i = s2.entrySet().iterator();
    Set es = s.entrySet();
    while (s2i.hasNext()) {
      if (!es.remove(s2i.next())) ++rmiss;
    }
    timer.finish();
    reallyAssert(rmiss == 0);

    clrTest(size, s2);
    reallyAssert(s2.isEmpty() && s.isEmpty());
  }