Skip to content
Snippets Groups Projects
Commit 8a93fb5e authored by Steven Murray's avatar Steven Murray
Browse files

Removed the getHier() mthod from the RemotePath because we do not want to...

Removed the getHier() mthod from the RemotePath because we do not want to parse the URI any further at this point
parent d11a82e5
No related branches found
No related tags found
No related merge requests found
......@@ -44,7 +44,7 @@ cta::RemotePath::RemotePath(const std::string &raw):
if(0 >= pos) {
std::ostringstream msg;
msg << "Failed to instantiate RemotePath object for URI " << raw <<
" because the scheme before the colon is an empty string";
" because there is no scheme";
throw exception::Exception(msg.str());
}
......@@ -52,12 +52,11 @@ cta::RemotePath::RemotePath(const std::string &raw):
if(pos == indexOfLastChar) {
std::ostringstream msg;
msg << "Failed to instantiate RemotePath object for URI " << raw <<
" because the hierarchical part after the colon is an empty string";
" because there nothing after the scheme";
throw exception::Exception(msg.str());
}
m_scheme = raw.substr(0, pos);
m_hier = raw.substr(pos + 1, indexOfLastChar - pos);
}
//------------------------------------------------------------------------------
......@@ -80,10 +79,3 @@ const std::string &cta::RemotePath::getRaw() const throw() {
const std::string &cta::RemotePath::getScheme() const throw() {
return m_scheme;
}
//------------------------------------------------------------------------------
// getHier
//------------------------------------------------------------------------------
const std::string &cta::RemotePath::getHier() const throw() {
return m_hier;
}
......@@ -56,16 +56,6 @@ public:
*/
const std::string &getScheme() const throw();
/**
* Returns the hierarchical path part of the remote path. For some examples:
*
* scheme:file1 would return file1
* scheme://abc.com:1234/file2 would return //abc.com:1234/file2
*
* @return The hierarchical path part of the remote path.
*/
const std::string &getHier() const throw();
private:
/**
......@@ -78,14 +68,6 @@ private:
*/
std::string m_scheme;
/**
* The hierarchical path part of the remote path. For some examples:
*
* scheme:file1 would return file1
* scheme://abc.com:1234/file2 would return //abc.com:1234/file2
*/
std::string m_hier;
}; // class RemotePath
} // namespace cta
......@@ -38,11 +38,42 @@ protected:
TEST_F(cta_RemotePathTest, raw_path_constructor) {
using namespace cta;
RemotePath remotePath("xroot://abc.com:1234:the_file");
const RemotePath remotePath("xroot://abc.com:1234:the_file");
ASSERT_EQ(std::string("xroot://abc.com:1234:the_file"), remotePath.getRaw());
ASSERT_EQ(std::string("xroot"), remotePath.getScheme());
ASSERT_EQ(std::string("//abc.com:1234:the_file"), remotePath.getHier());
}
TEST_F(cta_RemotePathTest, raw_path_constructor_empty_string) {
using namespace cta;
RemotePath remotePath;
ASSERT_THROW(remotePath = RemotePath(""), std::exception);
}
TEST_F(cta_RemotePathTest, raw_path_constructor_just_a_colon) {
using namespace cta;
RemotePath remotePath;
ASSERT_THROW(remotePath = RemotePath(":"), std::exception);
}
TEST_F(cta_RemotePathTest, raw_path_constructor_no_scheme) {
using namespace cta;
RemotePath remotePath;
ASSERT_THROW(remotePath = RemotePath("://abc.com:1234:the_file"), std::exception);
}
TEST_F(cta_RemotePathTest, raw_path_constructor_nothing_after_scheme) {
using namespace cta;
RemotePath remotePath;
ASSERT_THROW(remotePath = RemotePath("xroot:"), std::exception);
}
} // namespace unitTests
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment