Permalink
Browse files

[backend] validate schema definitions in BSXML.pm with the examples

  • Loading branch information...
1 parent 90ec053 commit 0329712e2db2c14d432a4d91c4e91c7e20d3f4e0 @adrianschroeter adrianschroeter committed Feb 25, 2013
View
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<package name="kdelibs" project="KDE" created="2005-01-01T00:00:02+01:00" updated="2007-01-19T10:44:45+01:00">
+<package name="kdelibs" project="KDE">
<title>KDE libraries</title>
<description>Base libraries of the KDE framework</description>
<devel project="KDE:UNSTABLE"/>
View
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<platform name="superkde">
- <title>SuperKDE</title>
- <description>
- SuperKDE is a testing area for heavily tuned KDE applications.
- </description>
- <person role="maintainer" userid="ernie"/>
- <person role="developer" userid="bert"/>
- <arch name="i386"/>
- <arch name="ppc"/>
- <projectpath>
- <projectpathelement>
- <project name="khtml_next_generation" />
- </projectpathelement>
- <projectpathelement>
- <project name="KDE-3.99" />
- </projectpathelement>
- <projectpathelement>
- <project name="kernel_on_steroids" />
- </projectpathelement>
- <projectpathelement>
- <project name="suselinux-10.0" />
- </projectpathelement>
- </projectpath>
- <compatible>
- <platform name="megakde"/>
- <platform name="minikde"/>
- </compatible>
-</platform>
View
@@ -1,129 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- elementFormDefault="qualified">
-
- <xs:annotation>
- <xs:documentation>
- This schema describes a format for describing an openSUSE platform.
- </xs:documentation>
- </xs:annotation>
-
- <xs:element name="platform">
- <xs:annotation>
- <xs:documentation>
- Top level element for platform data.
- </xs:documentation>
- </xs:annotation>
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="title"/>
- <xs:element ref="description"/>
- <xs:element ref="person" maxOccurs="unbounded" />
- <xs:element ref="arch" maxOccurs="unbounded"/>
- <xs:element ref="projectpath"/>
- <xs:element ref="compatible" minOccurs="0"/>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="title" type="xs:string">
- <xs:annotation>
- <xs:documentation>
- Title of the project.
- </xs:documentation>
- </xs:annotation>
- </xs:element>
-
- <xs:element name="description" type="xs:string">
- <xs:annotation>
- <xs:documentation>
- Description of the project.
- </xs:documentation>
- </xs:annotation>
- </xs:element>
-
- <xs:element name="person">
- <xs:annotation>
- <xs:documentation>
- A person which is associated with the platform.
- </xs:documentation>
- </xs:annotation>
- <xs:complexType>
- <xs:attribute name="role" type="xs:string"/>
- <xs:attribute name="userid" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="arch">
- <xs:annotation>
- <xs:documentation>
- Hardware architecture.
- </xs:documentation>
- </xs:annotation>
- <xs:complexType>
- <xs:attribute name="name" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="projectpath">
- <xs:annotation>
- <xs:documentation>
- A path of projects providing the platform.
- </xs:documentation>
- </xs:annotation>
- <xs:complexType>
- <xs:sequence>
- <xs:element maxOccurs="unbounded" ref="projectpathelement"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="projectpathelement">
- <xs:annotation>
- <xs:documentation>
- An element of a path of projects providing the platform.
- </xs:documentation>
- </xs:annotation>
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="project"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="project">
- <xs:annotation>
- <xs:documentation>
- Project which is part of the platform.
- </xs:documentation>
- </xs:annotation>
- <xs:complexType>
- <xs:attribute name="name" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="compatible">
- <xs:annotation>
- <xs:documentation>
- Compatible platforms. Packages from a compatible platform also work on
- this platform.
- </xs:documentation>
- </xs:annotation>
- <xs:complexType>
- <xs:sequence>
- <xs:element name="platform" maxOccurs="unbounded">
- <xs:annotation>
- <xs:documentation>
- Platform.
- </xs:documentation>
- </xs:annotation>
- <xs:complexType>
- <xs:attribute name="name" type="xs:string"/>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
-</xs:schema>
View
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project name="superkde" created="2005-01-01T00:00:02+01:00" updated="2007-01-19T10:44:45+01:00">
+<project name="superkde">
<title>SuperKDE</title>
<description>SuperKDE is a heavily tuned version of KDE.</description>
<link project="openSUSE:11.2:Update" />
View
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<status code="ok">
- <summary>Ok</summary>
- <details>Operation successfull.</details>
-</status>
@@ -0,0 +1,56 @@
+require File.expand_path(File.dirname(__FILE__) + "/..") + "/test_helper"
+
+class BackendTests < ActionController::IntegrationTest
+
+ def test_validate_bsxml
+
+ perlopts="-I#{Rails.root}/../backend -I#{Rails.root}/../backend/build"
+ dir = "#{Rails.root}/../../docs/api/api/"
+
+ Dir.entries(dir).each do |f|
+ next unless f =~ /.*.xml\z/
+
+ schema = f.gsub(/.xml$/, '')
+
+ # map schema names
+ if [ "about", "activity", "added_timestamp", "architecture",
+ "attrib", "attrib_type", "attrib_namespace", "attribute_namespace_meta",
+ "collection_objects_by_tag", "collection_objects_with_tags_by_user",
+ "configuration", "directory_view", "download_counter", "download_counter_summary", "download_stats",
+ "highest_rated", "issue_tracker", "latest_added", "latest_updated", "message", "messages",
+ "most_active", "newest_stats", "packageresult", "projectresult", "projects", "rating", "redirect_stats",
+ "status_message", "status_messages", "tagcloud", "taglist", "tags", "updated_timestamp", "distributions"
+ ].include? schema
+ # no backend schema exists
+ next
+ elsif schema == "binarylist"
+ # Urgs, different definition exists
+ next
+ elsif schema == "aggregate"
+ schema = "aggregatelist"
+ elsif schema == "buildhistory"
+ schema = "buildhist"
+ elsif schema == "buildresult"
+ schema = "resultlist"
+ elsif schema == "directory"
+ schema = "dir"
+ elsif schema == "package"
+ schema = "pack"
+ elsif schema == "project"
+ schema = "proj"
+ elsif schema == "service"
+ schema = "services"
+ elsif schema == "status"
+ schema = "opstatus"
+ elsif schema == "user"
+ schema = "person"
+ end
+
+# puts "SCHEMA", schema, f
+
+ r = system("cd #{Rails.root}/tmp/backend_config; exec perl #{perlopts} -mXML::Structured -mBSXML -mBSUtil -e \"use XML::Structured ':bytes'; BSUtil::readxml('#{dir}#{f}', \\\$BSXML::#{schema}, 0);\" 2>&1");
+ assert_equal r, true
+
+ end
+ end
+end

0 comments on commit 0329712

Please sign in to comment.