use of java.util.IdentityHashMap in project geode by apache.
the class DataTypeJUnitTest method testIdentityHashMap.
@Test
public void testIdentityHashMap() throws IOException {
IdentityHashMap<Object, Object> value = new IdentityHashMap<Object, Object>();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(baos);
DataSerializer.writeObject(value, out);
byte[] bytes = baos.toByteArray();
String type = DataType.getDataType(bytes);
assertEquals("java.util.IdentityHashMap", type);
}
use of java.util.IdentityHashMap in project geode by apache.
the class IntMapCheckJUnitTest method ittest4.
static void ittest4(Map s, int size, int pos) {
IdentityHashMap seen = new IdentityHashMap(size);
reallyAssert(s.size() == size);
int sum = 0;
timer.start("Iter XEntry ", size);
Iterator it = s.entrySet().iterator();
Integer k = null;
Integer v = null;
for (int i = 0; i < size - pos; ++i) {
Map.Entry x = (Map.Entry) (it.next());
k = (Integer) x.getKey();
v = (Integer) x.getValue();
seen.put(k, k);
if (v != MISSING)
++sum;
}
reallyAssert(s.containsKey(k));
it.remove();
reallyAssert(!s.containsKey(k));
while (it.hasNext()) {
Map.Entry x = (Map.Entry) (it.next());
Integer k2 = (Integer) x.getKey();
seen.put(k2, k2);
if (k2 != MISSING)
++sum;
}
reallyAssert(s.size() == size - 1);
s.put(k, v);
reallyAssert(seen.size() == size);
timer.finish();
reallyAssert(sum == size);
reallyAssert(s.size() == size);
}
use of java.util.IdentityHashMap in project geode by apache.
the class MapCheckJUnitTest method ittest4.
static void ittest4(Map s, int size, int pos) {
IdentityHashMap seen = new IdentityHashMap(size);
reallyAssert(s.size() == size);
int sum = 0;
timer.start("Iter XEntry ", size);
Iterator it = s.entrySet().iterator();
Object k = null;
Object v = null;
for (int i = 0; i < size - pos; ++i) {
Map.Entry x = (Map.Entry) (it.next());
k = x.getKey();
v = x.getValue();
seen.put(k, k);
if (x != MISSING)
++sum;
}
reallyAssert(s.containsKey(k));
it.remove();
reallyAssert(!s.containsKey(k));
while (it.hasNext()) {
Map.Entry x = (Map.Entry) (it.next());
Object k2 = x.getKey();
seen.put(k2, k2);
if (x != MISSING)
++sum;
}
reallyAssert(s.size() == size - 1);
s.put(k, v);
reallyAssert(seen.size() == size);
timer.finish();
reallyAssert(sum == size);
reallyAssert(s.size() == size);
}
use of java.util.IdentityHashMap in project sonatype-aether by sonatype.
the class NearestVersionConflictResolverTest method testViolationOfHardConstraintFallsBackToNearestSeenNotFirstSeen.
@Test
public void testViolationOfHardConstraintFallsBackToNearestSeenNotFirstSeen() throws Exception {
// root
// +- x:1
// +- a:1
// | \- b:1
// | \- x:3
// +- c:1
// | \- x:2
// \- d:1
// \- e:1
// \- x:[2,) # forces rejection of x:1, should fallback to nearest and not first-seen, i.e. x:2 and not x:3
DependencyNode x1 = builder.artifactId("x").version("1").build();
DependencyNode x2 = builder.artifactId("x").version("2").build();
DependencyNode x3 = builder.artifactId("x").version("3").build();
DependencyNode x2r = builder.artifactId("x").version("2").range("[2,)").build();
DependencyNode b = builder.artifactId("b").version("1").build();
b.getChildren().add(x3);
DependencyNode a = builder.artifactId("a").build();
a.getChildren().add(b);
DependencyNode c = builder.artifactId("c").build();
c.getChildren().add(x2);
DependencyNode e = builder.artifactId("e").build();
e.getChildren().add(x2r);
DependencyNode d = builder.artifactId("d").build();
d.getChildren().add(e);
DependencyNode root = builder.artifactId(null).build();
root.getChildren().add(x1);
root.getChildren().add(a);
root.getChildren().add(c);
root.getChildren().add(d);
Map<DependencyNode, Object> conflictIds = new IdentityHashMap<DependencyNode, Object>();
conflictIds.put(x1, "x");
conflictIds.put(x2, "x");
conflictIds.put(x3, "x");
conflictIds.put(x2r, "x");
conflictIds.put(a, "a");
conflictIds.put(b, "b");
conflictIds.put(c, "c");
conflictIds.put(d, "d");
conflictIds.put(e, "e");
context.put(TransformationContextKeys.CONFLICT_IDS, conflictIds);
NearestVersionConflictResolver transformer = new NearestVersionConflictResolver();
root = transformer.transformGraph(root, context);
List<DependencyNode> trail = find(root, "x");
assertEquals(3, trail.size());
assertSame(x2, trail.get(0));
}
use of java.util.IdentityHashMap in project sonatype-aether by sonatype.
the class NearestVersionConflictResolverTest method testConflictGroupCompletelyDroppedFromResolvedTree.
@Test
public void testConflictGroupCompletelyDroppedFromResolvedTree() throws Exception {
// root
// +- a:1
// | \- b:1
// | \- c:1 # conflict group c will completely vanish from resolved tree
// \- b:2
DependencyNode a = builder.artifactId("a").version("1").build();
DependencyNode b1 = builder.artifactId("b").version("1").build();
DependencyNode b2 = builder.artifactId("b").version("2").build();
DependencyNode c = builder.artifactId("c").version("1").build();
b1.getChildren().add(c);
a.getChildren().add(b1);
DependencyNode root = builder.artifactId(null).build();
root.getChildren().add(a);
root.getChildren().add(b2);
Map<DependencyNode, Object> conflictIds = new IdentityHashMap<DependencyNode, Object>();
conflictIds.put(a, "a");
conflictIds.put(b1, "b");
conflictIds.put(b2, "b");
conflictIds.put(c, "c");
context.put(TransformationContextKeys.CONFLICT_IDS, conflictIds);
NearestVersionConflictResolver transformer = new NearestVersionConflictResolver();
root = transformer.transformGraph(root, context);
assertEquals(2, root.getChildren().size());
assertSame(a, root.getChildren().get(0));
assertSame(b2, root.getChildren().get(1));
assertTrue(a.getChildren().isEmpty());
assertTrue(b2.getChildren().isEmpty());
}
Aggregations