示例#1
0
 private string maketx(string tx_blob) throws exception {
   map<string, object> data = new hashmap<>();
   data.put("id", 0);
   data.put("command", "submit");
   data.put("tx_blob", tx_blob);
   string postdata = new gson().tojson(data);
   string json = moorecoinwebsocketclient.request(postdata);
   system.out.println("make tx result: " + json);
   return json;
 }
  public void testmakeimmutable() {
    smallsortedmap<integer, integer> map = smallsortedmap.newinstancefortest(3);
    for (int i = 0; i < 6; i++) {
      assertnull(map.put(i, i + 1));
    }
    map.makeimmutable();
    assertequals(new integer(1), map.get(0));
    assertequals(6, map.size());

    try {
      map.put(23, 23);
      fail("expected unsupportedoperationexception");
    } catch (unsupportedoperationexception expected) {
    }

    map<integer, integer> other = new hashmap<integer, integer>();
    other.put(23, 23);
    try {
      map.putall(other);
      fail("expected unsupportedoperationexception");
    } catch (unsupportedoperationexception expected) {
    }

    try {
      map.remove(0);
      fail("expected unsupportedoperationexception");
    } catch (unsupportedoperationexception expected) {
    }

    try {
      map.clear();
      fail("expected unsupportedoperationexception");
    } catch (unsupportedoperationexception expected) {
    }

    set<map.entry<integer, integer>> entryset = map.entryset();
    try {
      entryset.clear();
      fail("expected unsupportedoperationexception");
    } catch (unsupportedoperationexception expected) {
    }

    iterator<map.entry<integer, integer>> it = entryset.iterator();
    while (it.hasnext()) {
      map.entry<integer, integer> entry = it.next();
      try {
        entry.setvalue(0);
        fail("expected unsupportedoperationexception");
      } catch (unsupportedoperationexception expected) {
      }
      try {
        it.remove();
        fail("expected unsupportedoperationexception");
      } catch (unsupportedoperationexception expected) {
      }
    }

    set<integer> keyset = map.keyset();
    try {
      keyset.clear();
      fail("expected unsupportedoperationexception");
    } catch (unsupportedoperationexception expected) {
    }

    iterator<integer> keys = keyset.iterator();
    while (keys.hasnext()) {
      integer key = keys.next();
      try {
        keyset.remove(key);
        fail("expected unsupportedoperationexception");
      } catch (unsupportedoperationexception expected) {
      }
      try {
        keys.remove();
        fail("expected unsupportedoperationexception");
      } catch (unsupportedoperationexception expected) {
      }
    }
  }