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
}
@Override
public boolean equals(Object rhs)
public boolean equals(Object other)
{
if (rhs == null)
if (other == null)
return false;
if (this == rhs)
if (this == other)
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;
}
......@@ -200,15 +203,20 @@ public class GroupURI
return name;
}
public URI getServiceID()
public String getServiceIDString()
{
String serviceID = uri.getScheme() +
return uri.getScheme() +
"://" +
uri.getAuthority() +
uri.getPath();
}
public URI getServiceID()
{
String serviceIDString = getServiceIDString();
try
{
return new URI(serviceID);
return new URI(serviceIDString);
}
catch (URISyntaxException e)
{
......
......@@ -18,6 +18,18 @@ public class GroupURITest
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
public void testMalformed()
{
......
Markdown is supported
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