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
c4ba0ea6
Commit
c4ba0ea6
authored
Nov 22, 2016
by
Patrick Dowler
Committed by
GitHub
Nov 22, 2016
Browse files
Merge pull request #18 from brianmajor/issue-10
issue-10 - fix to GroupURI equals()
parents
07f9b1f1
24b660d1
Changes
3
Hide whitespace changes
Inline
Side-by-side
cadc-access-control/build.gradle
View file @
c4ba0ea6
...
...
@@ -15,7 +15,7 @@ sourceCompatibility = 1.7
group
=
'org.opencadc'
version
=
'1.1.
2
'
version
=
'1.1.
3
'
mainClassName
=
'ca.nrc.cadc.ac.client.Main'
...
...
cadc-access-control/src/main/java/ca/nrc/cadc/ac/GroupURI.java
View file @
c4ba0ea6
...
...
@@ -83,7 +83,6 @@ public class GroupURI
private
static
Logger
log
=
Logger
.
getLogger
(
GroupURI
.
class
);
private
URI
uri
;
private
String
name
;
/**
* Attempts to create a URI using the specified uri.
...
...
@@ -99,8 +98,6 @@ public class GroupURI
throw
new
IllegalArgumentException
(
"Null URI"
);
}
this
.
uri
=
uri
;
// Ensure the scheme is correct
if
(
uri
.
getScheme
()
==
null
)
{
...
...
@@ -117,13 +114,9 @@ public class GroupURI
throw
new
IllegalArgumentException
(
"Missing authority and/or path."
);
}
log
.
debug
(
"URI: "
+
uri
);
log
.
debug
(
" scheme: "
+
uri
.
getScheme
());
log
.
debug
(
" authority: "
+
uri
.
getAuthority
());
log
.
debug
(
" path: "
+
uri
.
getPath
());
String
fragment
=
uri
.
getFragment
();
String
query
=
uri
.
getQuery
();
String
name
=
null
;
if
(
query
==
null
)
{
if
(
fragment
!=
null
)
...
...
@@ -144,6 +137,9 @@ public class GroupURI
}
name
=
query
;
}
this
.
uri
=
URI
.
create
(
uri
.
getScheme
()
+
"://"
+
uri
.
getAuthority
()
+
uri
.
getPath
()
+
"?"
+
name
);
}
/**
...
...
@@ -156,16 +152,16 @@ 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
otherURI
=
(
GroupURI
)
other
;
return
uri
.
equals
(
otherURI
.
getURI
());
}
return
false
;
}
...
...
@@ -180,16 +176,6 @@ public class GroupURI
return
uri
;
}
/**
* Returns the decoded authority component of the URI.
*
* @return authority of the URI, or null if the authority is undefined.
*/
public
String
getAuthority
()
{
return
uri
.
getAuthority
();
}
/**
* Returns the decoded fragment component of the URI.
*
...
...
@@ -197,18 +183,18 @@ public class GroupURI
*/
public
String
getName
()
{
return
name
;
return
uri
.
getQuery
()
;
}
public
URI
getServiceID
()
{
String
serviceID
=
uri
.
getScheme
()
+
String
serviceID
String
=
uri
.
getScheme
()
+
"://"
+
uri
.
getAuthority
()
+
uri
.
getPath
();
try
{
return
new
URI
(
serviceID
);
return
new
URI
(
serviceID
String
);
}
catch
(
URISyntaxException
e
)
{
...
...
@@ -220,7 +206,7 @@ public class GroupURI
@Override
public
String
toString
()
{
return
getServiceID
()
+
"?"
+
name
;
return
uri
.
toString
()
;
}
}
cadc-access-control/src/test/java/ca/nrc/cadc/ac/GroupURITest.java
View file @
c4ba0ea6
...
...
@@ -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
()
{
...
...
@@ -46,7 +58,6 @@ public class GroupURITest
{
GroupURI
g
=
new
GroupURI
(
"ivo://my.authority/gms?name"
);
Assert
.
assertEquals
(
"ivo"
,
g
.
getURI
().
getScheme
());
Assert
.
assertEquals
(
"my.authority"
,
g
.
getAuthority
());
Assert
.
assertEquals
(
"/gms"
,
g
.
getURI
().
getPath
());
Assert
.
assertEquals
(
"name"
,
g
.
getName
());
Assert
.
assertEquals
(
"ivo://my.authority/gms"
,
g
.
getServiceID
().
toString
());
...
...
@@ -65,7 +76,6 @@ public class GroupURITest
{
GroupURI
g
=
new
GroupURI
(
"ivo://my.authority/gms#name"
);
Assert
.
assertEquals
(
"ivo"
,
g
.
getURI
().
getScheme
());
Assert
.
assertEquals
(
"my.authority"
,
g
.
getAuthority
());
Assert
.
assertEquals
(
"/gms"
,
g
.
getURI
().
getPath
());
Assert
.
assertEquals
(
"name"
,
g
.
getName
());
Assert
.
assertEquals
(
"ivo://my.authority/gms"
,
g
.
getServiceID
().
toString
());
...
...
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