mirror of https://github.com/grpc/grpc-java.git
parent
2ea77cce1e
commit
1bb9498ea1
|
|
@ -129,7 +129,18 @@ public final class Attributes {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Attributes that = (Attributes) o;
|
Attributes that = (Attributes) o;
|
||||||
return Objects.equal(data, that.data);
|
if (data.size() != that.data.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (Entry<Key<?>, Object> e : data.entrySet()) {
|
||||||
|
if (!that.data.containsKey(e.getKey())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!Objects.equal(e.getValue(), that.data.get(e.getKey()))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
package io.grpc;
|
package io.grpc;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotSame;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
@ -50,4 +51,20 @@ public class AttributesTest {
|
||||||
public void empty() {
|
public void empty() {
|
||||||
assertEquals(0, Attributes.EMPTY.keys().size());
|
assertEquals(0, Attributes.EMPTY.keys().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("BoxedPrimitiveConstructor")
|
||||||
|
public void valueEquality() {
|
||||||
|
Attributes.Key<Integer> key = Attributes.Key.of("ints");
|
||||||
|
Integer v1 = new Integer(100000);
|
||||||
|
Integer v2 = new Integer(100000);
|
||||||
|
|
||||||
|
assertNotSame(v1, v2);
|
||||||
|
assertEquals(v1, v2);
|
||||||
|
|
||||||
|
Attributes attr1 = Attributes.newBuilder().set(key, v1).build();
|
||||||
|
Attributes attr2 = Attributes.newBuilder().set(key, v2).build();
|
||||||
|
|
||||||
|
assertEquals(attr1, attr2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue