Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OATS-CADC
ac
Commits
dc963684
Commit
dc963684
authored
Nov 22, 2016
by
Brian Major
Browse files
issue-10 - fix to GroupURI equals()
parent
07f9b1f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
cadc-access-control/src/main/java/ca/nrc/cadc/ac/GroupURI.java
View file @
dc963684
...
...
@@ -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
getServiceID
String
()
{
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
(
serviceID
String
);
}
catch
(
URISyntaxException
e
)
{
...
...
cadc-access-control/src/test/java/ca/nrc/cadc/ac/GroupURITest.java
View file @
dc963684
...
...
@@ -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
()
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment