From f4c63fae0c6d0654ab49e05b3292e218f82f97d8 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Nov 2009 13:51:15 -0800 Subject: [PATCH] SDK Manager support for future schemas. This CL cleans up the v2 test by removing all v2 stuff from the code right now. We only keep the part that handles future schemas and right now the latest version is 1. Change-Id: I31e6aeaf0582e94c67e1cc8317bec479ea7a52e7 --- .../sdklib/internal/repository/RepoSource.java | 2 +- .../android/sdklib/repository/SdkRepository.java | 34 +- .../android/sdklib/repository/sdk-repository-2.xsd | 421 --------------------- .../sdklib/repository/SdkRepositoryTest.java | 47 +-- .../sdklib/testdata/repository_sample_2.xml | 288 -------------- 5 files changed, 22 insertions(+), 770 deletions(-) delete mode 100755 tools/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository-2.xsd delete mode 100755 tools/sdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/repository_sample_2.xml diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/RepoSource.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/RepoSource.java index 6e8d9848..b5a7c8d5 100755 --- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/RepoSource.java +++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/RepoSource.java @@ -322,7 +322,7 @@ public class RepoSource implements IDescription { String lastError = null; String extraError = null; - for (int version = SdkRepository.XSD_LATEST_VERSION; version >= 1; version--) { + for (int version = SdkRepository.NS_LATEST_VERSION; version >= 1; version--) { try { Validator validator = getValidator(version); diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepository.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepository.java index 2cfca6f5..725dcbb6 100755 --- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepository.java +++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepository.java @@ -26,30 +26,24 @@ public class SdkRepository { /** The URL of the official Google sdk-repository site. */ public static final String URL_GOOGLE_SDK_REPO_SITE = - "https://dl-ssl.google.com/android/repository/"; //$NON-NLS-1$ + "https://dl-ssl.google.com/android/repository/"; //$NON-NLS-1$ public static final String URL_DEFAULT_XML_FILE = "repository.xml"; //$NON-NLS-1$ - /** The XML namespace of the sdk-repository XML version 1. - * @deprecated - */ - public static final String NS_SDK_REPOSITORY_1 = getSchemaUri(1); - - /** The XML namespace of the sdk-repository XML version 2. - * @deprecated - */ - public static final String NS_SDK_REPOSITORY_2 = getSchemaUri(2); - - /** The XML namespace of the latest sdk-repository XML. */ - public static final String NS_SDK_REPOSITORY = NS_SDK_REPOSITORY_2; + /** The base of our XML namespace. */ + private static final String NS_SDK_REPOSITORY_BASE = + "http://schemas.android.com/sdk/android/repository/"; //$NON-NLS-1$ /** The pattern of our XML namespace. */ public static final String NS_SDK_REPOSITORY_PATTERN = - "http://schemas.android.com/sdk/android/repository/[1-9][0-9]*"; //$NON-NLS-1$ + NS_SDK_REPOSITORY_BASE + "[1-9][0-9]*"; //$NON-NLS-1$ - /** The latest version of the sdk-repository XML Schema, currently 2. + /** The latest version of the sdk-repository XML Schema. * Valid version numbers are between 1 and this number, included. */ - public static final int XSD_LATEST_VERSION = 2; + public static final int NS_LATEST_VERSION = 1; + + /** The XML namespace of the latest sdk-repository XML. */ + public static final String NS_SDK_REPOSITORY = getSchemaUri(NS_LATEST_VERSION); /** The root sdk-repository element */ public static final String NODE_SDK_REPOSITORY = "sdk-repository"; //$NON-NLS-1$ @@ -135,8 +129,7 @@ public class SdkRepository { /** * Returns a stream to the requested repository XML Schema. * - * @param version 1 for {@link #NS_SDK_REPOSITORY_1}, 2 for {@link #NS_SDK_REPOSITORY_2}. - * You can use {@link #XSD_LATEST_VERSION} to always get the latest version. + * @param version Between 1 and {@link #NS_LATEST_VERSION}, included. * @return An {@link InputStream} object for the local XSD file or * null if there is no schema for the requested version. */ @@ -147,11 +140,10 @@ public class SdkRepository { /** * Returns the URI of the SDK Repository schema for the given version number. - * @param version Between 1 and {@link #XSD_LATEST_VERSION} included. + * @param version Between 1 and {@link #NS_LATEST_VERSION} included. */ public static String getSchemaUri(int version) { - return String.format("http://schemas.android.com/sdk/android/repository/%d", //$NON-NLS-1$ - version); // + return String.format(NS_SDK_REPOSITORY_BASE + "%d", version); //$NON-NLS-1$ } } diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository-2.xsd b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository-2.xsd deleted file mode 100755 index 31b173f4..00000000 --- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository-2.xsd +++ /dev/null @@ -1,421 +0,0 @@ - - - - - - - - - - The repository contains collections of downloadable packages. - - - - - - - - - - - An SDK platform package. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - An SDK add-on package. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - An SDK tool package. - - - - - - - - - - - - - - - - - - - - - - - - - - - An SDK doc package. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - An SDK extra package. This kind of package is for "free" - content and specifies in which fixed root directory it must be - installed. - The paths "add-ons", "platforms", "tools" and "docs" are - reserved and cannot be used. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - An SDK sample package. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - A license definition. Such a license must be used later as a reference - using a uses-license element in one of the package elements. - - - - - - - - - - - - - - - - - - - - - - Describes the license used by a package. The license MUST be defined - using a license node and referenced using the ref attribute of the - license element inside a package. - - - - - - - - - - - - A collection of files that can be downloaded for a given architecture. - The <archives> node is mandatory in the repository packages and the - collection must have at least one <archive> declared. - Each archive is a zip file that will be unzipped in a location that depends - on its package type. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - A SHA1 checksum. - - - - - - - - - A file checksum, currently only SHA1. - - - - - - - - - - diff --git a/tools/sdkmanager/libs/sdklib/tests/com/android/sdklib/repository/SdkRepositoryTest.java b/tools/sdkmanager/libs/sdklib/tests/com/android/sdklib/repository/SdkRepositoryTest.java index 27f881ef..17bbaa16 100755 --- a/tools/sdkmanager/libs/sdklib/tests/com/android/sdklib/repository/SdkRepositoryTest.java +++ b/tools/sdkmanager/libs/sdklib/tests/com/android/sdklib/repository/SdkRepositoryTest.java @@ -146,37 +146,6 @@ public class SdkRepositoryTest extends TestCase { handler.verify(); } - /** Validate a valid sample using namespace version 2 using an InputStream */ - public void testValidateLocalRepositoryFile2() throws Exception { - InputStream xmlStream = this.getClass().getResourceAsStream( - "/com/android/sdklib/testdata/repository_sample_2.xml"); - Source source = new StreamSource(xmlStream); - - CaptureErrorHandler handler = new CaptureErrorHandler(); - Validator validator = getValidator(2, handler); - validator.validate(source); - handler.verify(); - } - - /** Test that validating a v2 file using the v1 schema fails. */ - public void testValidateFile2UsingNs1() throws Exception { - InputStream xmlStream = this.getClass().getResourceAsStream( - "/com/android/sdklib/testdata/repository_sample_2.xml"); - Source source = new StreamSource(xmlStream); - - Validator validator = getValidator(1, null); // validate v2 against v1... fail! - - try { - validator.validate(source); - } catch (SAXParseException e) { - // We expect to get this specific exception message - assertRegex("cvc-elt.1: Cannot find the declaration of element 'sdk:sdk-repository'.*", e.getMessage()); - return; - } - // We shouldn't get here - fail(); - } - /** A document should at least have a root to be valid */ public void testEmptyXml() throws Exception { String document = ""; @@ -184,7 +153,7 @@ public class SdkRepositoryTest extends TestCase { Source source = new StreamSource(new StringReader(document)); CaptureErrorHandler handler = new CaptureErrorHandler(); - Validator validator = getValidator(SdkRepository.XSD_LATEST_VERSION, handler); + Validator validator = getValidator(SdkRepository.NS_LATEST_VERSION, handler); try { validator.validate(source); @@ -200,7 +169,7 @@ public class SdkRepositoryTest extends TestCase { private static String OPEN_TAG = ""; private static String CLOSE_TAG = ""; @@ -214,7 +183,7 @@ public class SdkRepositoryTest extends TestCase { Source source = new StreamSource(new StringReader(document)); CaptureErrorHandler handler = new CaptureErrorHandler(); - Validator validator = getValidator(SdkRepository.XSD_LATEST_VERSION, handler); + Validator validator = getValidator(SdkRepository.NS_LATEST_VERSION, handler); validator.validate(source); handler.verify(); } @@ -229,7 +198,7 @@ public class SdkRepositoryTest extends TestCase { Source source = new StreamSource(new StringReader(document)); // don't capture the validator errors, we want it to fail and catch the exception - Validator validator = getValidator(SdkRepository.XSD_LATEST_VERSION, null); + Validator validator = getValidator(SdkRepository.NS_LATEST_VERSION, null); try { validator.validate(source); } catch (SAXParseException e) { @@ -251,7 +220,7 @@ public class SdkRepositoryTest extends TestCase { Source source = new StreamSource(new StringReader(document)); // don't capture the validator errors, we want it to fail and catch the exception - Validator validator = getValidator(SdkRepository.XSD_LATEST_VERSION, null); + Validator validator = getValidator(SdkRepository.NS_LATEST_VERSION, null); try { validator.validate(source); } catch (SAXParseException e) { @@ -273,7 +242,7 @@ public class SdkRepositoryTest extends TestCase { Source source = new StreamSource(new StringReader(document)); // don't capture the validator errors, we want it to fail and catch the exception - Validator validator = getValidator(SdkRepository.XSD_LATEST_VERSION, null); + Validator validator = getValidator(SdkRepository.NS_LATEST_VERSION, null); try { validator.validate(source); } catch (SAXParseException e) { @@ -300,7 +269,7 @@ public class SdkRepositoryTest extends TestCase { Source source = new StreamSource(new StringReader(document)); // don't capture the validator errors, we want it to fail and catch the exception - Validator validator = getValidator(SdkRepository.XSD_LATEST_VERSION, null); + Validator validator = getValidator(SdkRepository.NS_LATEST_VERSION, null); try { validator.validate(source); } catch (SAXParseException e) { @@ -326,7 +295,7 @@ public class SdkRepositoryTest extends TestCase { Source source = new StreamSource(new StringReader(document)); // don't capture the validator errors, we want it to fail and catch the exception - Validator validator = getValidator(SdkRepository.XSD_LATEST_VERSION, null); + Validator validator = getValidator(SdkRepository.NS_LATEST_VERSION, null); try { validator.validate(source); } catch (SAXParseException e) { diff --git a/tools/sdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/repository_sample_2.xml b/tools/sdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/repository_sample_2.xml deleted file mode 100755 index d5276e56..00000000 --- a/tools/sdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/repository_sample_2.xml +++ /dev/null @@ -1,288 +0,0 @@ - - - - - - - - This is the license - for this platform. - - - - Licenses are only of type 'text' right now, so this is implied. - - - - - - 1.0 - 1 - 3 - - Some optional description - http://www.example.com/platform1.html - This is an optional release note - for this package. It's a free multi-line text. - - http://some/url/for/the/release/note.html - 2 - - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - http://www.example.com/files/plat1.zip - - - - - - 1 - 1 - - Some optional description - http://www.example.com/docs.html - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - http://www.example.com/docs/docs1.zip - - - - - - My First add-on - 1 - John Doe - 1 - - Some optional description - http://www.example.com/myfirstaddon - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - http://www.example.com/add-ons/first.zip - - - - - - android.blah.somelib - The description for this library. - - - - com.android.mymaps - - - - - - 1.1 - 2 - 12 - - - - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - distrib/platform-2-12-win.zip - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - distrib/platform-2-12-mac.zip - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - distrib/platform-2-12-mac.zip - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - distrib/platform-2-12-linux.tar.bz2 - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - distrib/platform-2-12-linux.tar.bz2 - - - - - - My Second add-on - 2 - John Deer - 42 - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - distrib/second-42-win.zip - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - distrib/second-42-linux.tar.bz2 - - - - - android.blah.somelib - The description for this library. - - - com.android.mymaps - - - - - - - Pastry - 5 - Pastry - 3 - - Preview version for Pastry - http://www.example.com/platform1.html - - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - http://www.example.com/files/plat1.zip - - - - - - 1 - Some optional description - http://www.example.com/tools.html - - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - http://www.example.com/files/tools1.zip - - - - - - 2 - 42 - - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - distrib/docs/2.zip - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - distrib/docs2-linux.tar.bz2 - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - distrib/docs2-mac.tar.bz2 - - - - - - 42 - - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - distrib/tools/2.zip - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - distrib/tools2-linux.tar.bz2 - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - distrib/tools2-mac.tar.bz2 - - - - - - - This add-on has no libraries - 4 - Joe Bar - 3 - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - distrib/imnotanarchiveimadoctorjim.zip - - - - - - - - usb_driver - - 43 - - - 65536 - 2822ae37115ebf13412bbef91339ee0d9454525e - distrib/extraduff.zip - - - An Extra package for the USB driver, it will install in $SDK/usb_driver - http://www.example.com/extra.html - 3 - - - - - 1234 - 314153 - - - 123456 - 2822ae37115ebf13412bbef91339ee0d94545228 - archives/samples/dream-1234.zip - - - - - -- 2.11.0