Permalink
Browse files

Adding a couple tests. Minor reorg

  • Loading branch information...
1 parent 2ef85ea commit 69d581e255c310e2370eaf25829a008c33bbcfb8 Renzo Sanchez-Silva committed May 1, 2012
View
@@ -42,15 +42,15 @@ def get_workspaces &block
end
# @param [String] workspace name
- # @return [<RGeoServer::Workspace]
+ # @return [RGeoServer::Workspace]
def get_workspace workspace
response = self.search :workspaces => workspace
doc = Nokogiri::XML(response)
name = doc.at_xpath(Workspace.member_xpath)
return Workspace.new self, :name => name.text if name
end
- # @return [<RGeoServer::Workspace]
+ # @return [RGeoServer::Workspace]
def get_default_workspace
dw = Workspace.new self, :name => 'default'
w = Workspace.new self, :name => w.name
@@ -65,7 +65,7 @@ def set_default_workspace
# @param [String] store
# @param [String] workspace
def reassign_workspace store, workspace
- pass
+ raise NotImplementedError
end
@@ -79,7 +79,7 @@ def get_layers &block
end
# @param [String] layer name
- # @return [<RGeoServer::Layer]
+ # @return [RGeoServer::Layer]
def get_layer layer
response = self.search :layers => layer
doc = Nokogiri::XML(response)
@@ -129,17 +129,15 @@ def get_data_store workspace, datastore
# @param [String] datastore
# @return [Array<RGeoServer::FeatureType>]
def get_feature_types workspace, datastore
- pass
-
+ raise NotImplementedError
end
# @param [String] workspace
# @param [String] datastore
# @param [String] featuretype_id
# @return [RGeoServer::FeatureType]
def get_feature_type workspace, datastore, featuretype_id
- pass
-
+ raise NotImplementedError
end
@@ -75,10 +75,10 @@ def profile_xml_to_hash profile_xml
h = {
"coverage_store" => @coverage_store.name,
"workspace" => @workspace.name,
- "name" => doc.at_xpath('//name/text()').text.strip,,
- "nativeName" => doc.at_xpath('//nativeName/text()').to_s,
- "title" => doc.at_xpath('//title/text()').to_s,
- "supportedFormats" => doc.xpath('//supportedFormats/string/text()').collect{ |t| t.to_s }
+ "name" => doc.at_xpath('//name').text.strip,
+ "nativeName" => doc.at_xpath('//nativeName').to_s,
+ "title" => doc.at_xpath('//title').to_s,
+ "supportedFormats" => doc.xpath('//supportedFormats/string').collect{ |t| t.to_s }
}.freeze
h
end
@@ -100,7 +100,7 @@ def profile_xml_to_hash profile_xml
doc.xpath('//featureTypes/atom:link/@href', "xmlns:atom"=>"http://www.w3.org/2005/Atom" ).each{ |l|
h["featureTypes"] = begin
response = @catalog.fetch_url l.text
- Nokogiri::XML(response).xpath('//name/text()').collect{ |a| a.text }
+ Nokogiri::XML(response).xpath('//name/text()').collect{ |a| a.text.strip }
rescue RestClient::ResourceNotFound
[]
end.freeze
View
@@ -76,6 +76,10 @@ def resource
end
end
+ def styles &block
+ self.class.list Style, @catalog, profile['styles'], {:layer => self}, check_remote = true, &block
+ end
+
def profile_xml_to_hash profile_xml
doc = profile_xml_to_ng profile_xml
name = doc.at_xpath('//name/text()').text.strip
@@ -95,7 +99,7 @@ def profile_xml_to_hash profile_xml
},
"resource" => {
"type" => doc.at_xpath('//resource/@class').to_s,
- "name" => doc.at_xpath('//resource/name').to_s,
+ "name" => doc.at_xpath('//resource/name/text()').to_s,
"store" => store,
"workspace" => workspace
},
@@ -82,7 +82,7 @@ def profile_xml_to_hash profile_xml
else
h[l.parent.parent.name.to_s] = begin
response = @catalog.fetch_url l.text
- Nokogiri::XML(response).xpath('//name/text()').collect{ |a| a.text }
+ Nokogiri::XML(response).xpath('//name').collect{ |a| a.text.strip }
rescue RestClient::ResourceNotFound
[]
end.freeze
@@ -93,6 +93,12 @@
end
context "DataStores" do
+ it "should list all available data stores" do
+ @catalog.get_data_stores.each { |d|
+ d.profile.should_not be_empty
+ }
+ end
+
it "should instantiate a datastore" do
obj = RGeoServer::DataStore.new @catalog, :workspace => @ws, :name => 'test_shapefile'
obj.new?.should == true
@@ -125,6 +131,11 @@
end
context "CoverageStores" do
+ it "should list all available coverage stores" do
+ @catalog.get_coverage_stores.each { |c|
+ c.profile.should_not be_empty
+ }
+ end
it "should create a coverage store under existing workspace, update and delete it right after" do
cs = RGeoServer::CoverageStore.new @catalog, :workspace => @ws, :name => 'test_coverage_store'
cs.url = "file:data_dir/sf/raster.tif"

0 comments on commit 69d581e

Please sign in to comment.