Commit dc963684 authored by Brian Major's avatar Brian Major
Browse files

issue-10 - fix to GroupURI equals()

parent 07f9b1f1
...@@ -156,16 +156,19 @@ public class GroupURI ...@@ -156,16 +156,19 @@ public class GroupURI
} }
@Override @Override
public boolean equals(Object rhs) public boolean equals(Object other)
{ {
if (rhs == null) if (other == null)
return false; return false;
if (this == rhs) if (this == other)
return true; return true;
if (rhs instanceof GroupURI) if (other instanceof GroupURI)
{ {
GroupURI vu = (GroupURI) rhs;
return uri.toString().equals(vu.uri.toString()); GroupURI oID = (GroupURI) other;
String otherURI = getServiceIDString() + "?" + oID.getName();
String thisURI = getServiceIDString() + "?" + this.getName();
return thisURI.equals(otherURI);
} }
return false; return false;
} }
...@@ -200,15 +203,20 @@ public class GroupURI ...@@ -200,15 +203,20 @@ public class GroupURI
return name; return name;
} }
public URI getServiceID() public String getServiceIDString()
{ {
String serviceID = uri.getScheme() + return uri.getScheme() +
"://" + "://" +
uri.getAuthority() + uri.getAuthority() +
uri.getPath(); uri.getPath();
}
public URI getServiceID()
{
String serviceIDString = getServiceIDString();
try try
{ {
return new URI(serviceID); return new URI(serviceIDString);
} }
catch (URISyntaxException e) catch (URISyntaxException e)
{ {
......
...@@ -18,6 +18,18 @@ public class GroupURITest ...@@ -18,6 +18,18 @@ public class GroupURITest
Log4jInit.setLevel("ca.nrc.cadc.ac", Level.DEBUG); Log4jInit.setLevel("ca.nrc.cadc.ac", Level.DEBUG);
} }
@Test
public void testEquals()
{
GroupURI uri1 = new GroupURI("ivo://example.org/gms?name");
GroupURI uri2 = new GroupURI("ivo://example.org/gms?name");
Assert.assertTrue(uri1.equals(uri2));
uri1 = new GroupURI("ivo://example.org/gms?name");
uri2 = new GroupURI("ivo://example.org/gms#name");
Assert.assertTrue(uri1.equals(uri2));
}
@Test @Test
public void testMalformed() public void testMalformed()
{ {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment