diff options
Diffstat (limited to 'sdkmanager/libs/sdklib/tests/src')
69 files changed, 0 insertions, 12787 deletions
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/AndroidVersionTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/AndroidVersionTest.java deleted file mode 100755 index 5270bd1..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/AndroidVersionTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib; - -import junit.framework.TestCase; - -/** - * Unit tests for {@link AndroidVersion}. - */ -public class AndroidVersionTest extends TestCase { - - public final void testAndroidVersion() { - AndroidVersion v = new AndroidVersion(1, " CODENAME "); - assertEquals(1, v.getApiLevel()); - assertEquals("CODENAME", v.getApiString()); - assertTrue(v.isPreview()); - assertEquals("CODENAME", v.getCodename()); - assertEquals("CODENAME".hashCode(), v.hashCode()); - assertEquals("API 1, CODENAME preview", v.toString()); - - v = new AndroidVersion(15, "REL"); - assertEquals(15, v.getApiLevel()); - assertEquals("15", v.getApiString()); - assertFalse(v.isPreview()); - assertNull(v.getCodename()); - assertTrue(v.equals(15)); - assertEquals(15, v.hashCode()); - assertEquals("API 15", v.toString()); - - v = new AndroidVersion(15, null); - assertEquals(15, v.getApiLevel()); - assertEquals("15", v.getApiString()); - assertFalse(v.isPreview()); - assertNull(v.getCodename()); - assertTrue(v.equals(15)); - assertEquals(15, v.hashCode()); - assertEquals("API 15", v.toString()); - - // An empty codename is like a null codename - v = new AndroidVersion(15, " "); - assertFalse(v.isPreview()); - assertNull(v.getCodename()); - assertEquals("15", v.getApiString()); - - v = new AndroidVersion(15, ""); - assertFalse(v.isPreview()); - assertNull(v.getCodename()); - assertEquals("15", v.getApiString()); - - assertTrue(v.isGreaterOrEqualThan(0)); - assertTrue(v.isGreaterOrEqualThan(14)); - assertTrue(v.isGreaterOrEqualThan(15)); - assertFalse(v.isGreaterOrEqualThan(16)); - assertFalse(v.isGreaterOrEqualThan(Integer.MAX_VALUE)); - } - -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/LayoutlibVersionTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/LayoutlibVersionTest.java deleted file mode 100755 index 0c197aa..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/LayoutlibVersionTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.eclipse.org/org/documents/epl-v10.php - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib; - -import com.android.sdklib.SdkManager.LayoutlibVersion; - -import junit.framework.TestCase; - -/** - * Unit test for {@link LayoutlibVersion}. - */ -public class LayoutlibVersionTest extends TestCase { - - public void testLayoutlibVersion_create() { - LayoutlibVersion lv = new LayoutlibVersion(1, 2); - assertEquals(1, lv.getApi()); - assertEquals(2, lv.getRevision()); - } - - public void testLayoutlibVersion_compare() { - assertTrue(new LayoutlibVersion(1, 1).compareTo(new LayoutlibVersion(1, 1)) == 0); - assertTrue(new LayoutlibVersion(1, 2).compareTo(new LayoutlibVersion(1, 1)) > 0); - assertTrue(new LayoutlibVersion(1, 1).compareTo(new LayoutlibVersion(1, 2)) < 0); - assertTrue(new LayoutlibVersion(2, 2).compareTo(new LayoutlibVersion(1, 3)) > 0); - - // the lack of an API (== 0) naturally sorts as the lowest value possible. - assertTrue(new LayoutlibVersion(0, 1).compareTo(new LayoutlibVersion(0, 2)) < 0); - assertTrue(new LayoutlibVersion(0, 1).compareTo(new LayoutlibVersion(1, 2)) < 0); - assertTrue(new LayoutlibVersion(0, 3).compareTo(new LayoutlibVersion(1, 2)) < 0); - assertTrue(new LayoutlibVersion(1, 2).compareTo(new LayoutlibVersion(0, 3)) > 0); - - // if we lack the revision number, we don't use it in comparison - assertTrue(new LayoutlibVersion(2, 0).compareTo(new LayoutlibVersion(2, 2)) == 0); - assertTrue(new LayoutlibVersion(2, 2).compareTo(new LayoutlibVersion(2, 0)) == 0); - } - -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/SdkManagerTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/SdkManagerTest.java deleted file mode 100755 index 487a96a..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/SdkManagerTest.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib; - - -import com.android.SdkConstants; -import com.android.sdklib.ISystemImage.LocationType; -import com.android.sdklib.SdkManager.LayoutlibVersion; - -import java.util.Arrays; -import java.util.regex.Pattern; - -public class SdkManagerTest extends SdkManagerTestCase { - - @SuppressWarnings("deprecation") - public void testSdkManager_LayoutlibVersion() { - SdkManager sdkman = getSdkManager(); - IAndroidTarget t = sdkman.getTargets()[0]; - - assertTrue(t instanceof PlatformTarget); - - LayoutlibVersion lv = ((PlatformTarget) t).getLayoutlibVersion(); - assertNotNull(lv); - assertEquals(5, lv.getApi()); - assertEquals(2, lv.getRevision()); - - assertSame(lv, sdkman.getMaxLayoutlibVersion()); - } - - public void testSdkManager_SystemImage() throws Exception { - SdkManager sdkman = getSdkManager(); - assertEquals("[PlatformTarget API 0 rev 1]", Arrays.toString(sdkman.getTargets())); - IAndroidTarget t = sdkman.getTargets()[0]; - - // By default SdkManagerTestCase creates an SDK with one platform containing - // a legacy armeabi system image. - assertEquals( - "[SystemImage ABI=armeabi, location in platform legacy='$SDK/platforms/v0_0/images']", - cleanPath(sdkman, Arrays.toString(t.getSystemImages()))); - - // Now add a few "platform subfolders" system images and reload the SDK. - // This disables the "legacy" mode, which means that although the armeabi - // target from above is present, it is no longer visible. - - makeSystemImageFolder(new SystemImage( - sdkman, t, LocationType.IN_PLATFORM_SUBFOLDER, SdkConstants.ABI_ARMEABI_V7A)); - makeSystemImageFolder(new SystemImage( - sdkman, t, LocationType.IN_PLATFORM_SUBFOLDER, SdkConstants.ABI_INTEL_ATOM)); - - sdkman.reloadSdk(getLog()); - assertEquals("[PlatformTarget API 0 rev 1]", Arrays.toString(sdkman.getTargets())); - t = sdkman.getTargets()[0]; - - assertEquals( - "[SystemImage ABI=armeabi-v7a, location in platform subfolder='$SDK/platforms/v0_0/images/armeabi-v7a', " + - "SystemImage ABI=x86, location in platform subfolder='$SDK/platforms/v0_0/images/x86']", - cleanPath(sdkman, Arrays.toString(t.getSystemImages()))); - - // Now add arm + arm v7a images using the new SDK/system-images. - // The x86 one from the platform subfolder is still visible. - // The armeabi one from the legacy folder is overridden by the new one. - // The armeabi-v7a one from the platform subfolder is overridden by the new one. - - makeSystemImageFolder(new SystemImage( - sdkman, t, LocationType.IN_SYSTEM_IMAGE, SdkConstants.ABI_ARMEABI)); - makeSystemImageFolder(new SystemImage( - sdkman, t, LocationType.IN_SYSTEM_IMAGE, SdkConstants.ABI_ARMEABI_V7A)); - - sdkman.reloadSdk(getLog()); - assertEquals("[PlatformTarget API 0 rev 1]", Arrays.toString(sdkman.getTargets())); - t = sdkman.getTargets()[0]; - - assertEquals( - "[SystemImage ABI=armeabi, location in system image='$SDK/system-images/android-0/armeabi', " + - "SystemImage ABI=armeabi-v7a, location in system image='$SDK/system-images/android-0/armeabi-v7a', " + - "SystemImage ABI=x86, location in platform subfolder='$SDK/platforms/v0_0/images/x86']", - cleanPath(sdkman, Arrays.toString(t.getSystemImages()))); - } - - public void testSdkManager_SystemImage_LegacyOverride() throws Exception { - SdkManager sdkman = getSdkManager(); - assertEquals("[PlatformTarget API 0 rev 1]", Arrays.toString(sdkman.getTargets())); - IAndroidTarget t = sdkman.getTargets()[0]; - - // By default SdkManagerTestCase creates an SDK with one platform containing - // a legacy armeabi system image. - assertEquals( - "[SystemImage ABI=armeabi, location in platform legacy='$SDK/platforms/v0_0/images']", - cleanPath(sdkman, Arrays.toString(t.getSystemImages()))); - - // Now add a different ABI system image in the new system-images folder. - // This does not hide the legacy one as long as the ABI type is different - // (to contrast: having at least one sub-folder in the platform's legacy images folder - // will hide the legacy system image. Whereas this does not happen with the new type.) - - makeSystemImageFolder(new SystemImage( - sdkman, t, LocationType.IN_SYSTEM_IMAGE, SdkConstants.ABI_INTEL_ATOM)); - - sdkman.reloadSdk(getLog()); - assertEquals("[PlatformTarget API 0 rev 1]", Arrays.toString(sdkman.getTargets())); - t = sdkman.getTargets()[0]; - - assertEquals( - "[SystemImage ABI=armeabi, location in platform legacy='$SDK/platforms/v0_0/images', " + - "SystemImage ABI=x86, location in system image='$SDK/system-images/android-0/x86']", - cleanPath(sdkman, Arrays.toString(t.getSystemImages()))); - - // Now if we have one new system-image using the same ABI type, it will override the - // legacy one. This gives us a good path for updates. - - makeSystemImageFolder(new SystemImage( - sdkman, t, LocationType.IN_SYSTEM_IMAGE, SdkConstants.ABI_ARMEABI)); - - - sdkman.reloadSdk(getLog()); - assertEquals("[PlatformTarget API 0 rev 1]", Arrays.toString(sdkman.getTargets())); - t = sdkman.getTargets()[0]; - - assertEquals( - "[SystemImage ABI=armeabi, location in system image='$SDK/system-images/android-0/armeabi', " + - "SystemImage ABI=x86, location in system image='$SDK/system-images/android-0/x86']", - cleanPath(sdkman, Arrays.toString(t.getSystemImages()))); - } - - /** - * Sanitizes the paths used when testing results. - * <p/> - * The system image text representation contains the absolute path to the SDK. - * However the SDK path is actually a randomized location. - * We clean it by replacing it by the constant '$SDK'. - * Also all the Windows path separators are converted to unix-like / separators. - */ - private String cleanPath(SdkManager sdkman, String string) { - return string - .replaceAll(Pattern.quote(sdkman.getLocation()), "\\$SDK") //$NON-NLS-1$ - .replace('\\', '/'); - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/SdkManagerTestCase.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/SdkManagerTestCase.java deleted file mode 100755 index 86a555a..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/SdkManagerTestCase.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib; - - -import com.android.SdkConstants; -import com.android.prefs.AndroidLocation; -import com.android.prefs.AndroidLocation.AndroidLocationException; -import com.android.sdklib.internal.avd.AvdManager; -import com.android.sdklib.io.FileOp; -import com.android.sdklib.mock.MockLog; -import com.android.sdklib.repository.PkgProps; -import com.android.utils.ILogger; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; - -import junit.framework.TestCase; - -/** - * Test case that allocates a temporary SDK, a temporary AVD base folder - * with an SdkManager and an AvdManager that points to them. - */ -public class SdkManagerTestCase extends TestCase { - - private File mFakeSdk; - private MockLog mLog; - private SdkManager mSdkManager; - private TmpAvdManager mAvdManager; - - /** Returns the {@link MockLog} for this test case. */ - public MockLog getLog() { - return mLog; - } - - /** Returns the {@link SdkManager} for this test case. */ - public SdkManager getSdkManager() { - return mSdkManager; - } - - /** Returns the {@link AvdManager} for this test case. */ - public TmpAvdManager getAvdManager() { - return mAvdManager; - } - - /** - * Sets up a {@link MockLog}, a fake SDK in a temporary directory - * and an AVD Manager pointing to an initially-empty AVD directory. - */ - @Override - public void setUp() throws Exception { - mLog = new MockLog(); - mFakeSdk = makeFakeSdk(); - mSdkManager = SdkManager.createManager(mFakeSdk.getAbsolutePath(), mLog); - assertNotNull("SdkManager location was invalid", mSdkManager); - - mAvdManager = new TmpAvdManager(mSdkManager, mLog); - } - - /** - * Removes the temporary SDK and AVD directories. - */ - @Override - public void tearDown() throws Exception { - deleteDir(mFakeSdk); - } - - /** - * A empty test method to placate the JUnit test runner, which doesn't - * like TestCase classes with no test methods. - */ - public void testPlaceholder() { - } - - /** - * An {@link AvdManager} that uses a temporary directory - * located <em>inside</em> the SDK directory for testing. - * The AVD list should be initially empty. - */ - protected static class TmpAvdManager extends AvdManager { - - /* - * Implementation detail: - * - When the super.AvdManager constructor is invoked, it will invoke - * the buildAvdFilesList() to fill the initial AVD list, which will in - * turn call getBaseAvdFolder(). - * - That's why mTmpAvdRoot is initialized in getAvdRoot() rather than - * in the constructor, since we can't initialize fields before the super() - * call. - */ - - /** - * AVD Root, initialized "lazily" when the AVD root is first requested. - */ - private File mTmpAvdRoot; - - public TmpAvdManager(SdkManager sdkManager, ILogger log) throws AndroidLocationException { - super(sdkManager, log); - } - - @Override - public String getBaseAvdFolder() throws AndroidLocationException { - if (mTmpAvdRoot == null) { - mTmpAvdRoot = new File(getSdkManager().getLocation(), "tmp_avds"); - mTmpAvdRoot.mkdirs(); - } - return mTmpAvdRoot.getAbsolutePath(); - } - } - - /** - * Build enough of a skeleton SDK to make the tests pass. - * <p/> - * Ideally this wouldn't touch the file system but the current - * structure of the SdkManager and AvdManager makes this difficult. - * - * @return Path to the temporary SDK root - * @throws IOException - */ - private File makeFakeSdk() throws IOException { - // First we create a temp file to "reserve" the temp directory name we want to use. - File sdkDir = File.createTempFile( - this.getClass().getSimpleName() + '_' + this.getName(), null); - // Then erase the file and make the directory - sdkDir.delete(); - sdkDir.mkdirs(); - - AndroidLocation.resetFolder(); - File addonsDir = new File(sdkDir, SdkConstants.FD_ADDONS); - addonsDir.mkdir(); - - File toolsDir = new File(sdkDir, SdkConstants.OS_SDK_TOOLS_FOLDER); - toolsDir.mkdir(); - new File(toolsDir, SdkConstants.androidCmdName()).createNewFile(); - new File(toolsDir, SdkConstants.FN_EMULATOR).createNewFile(); - - // TODO makePlatformTools with at least a source props - - File toolsLibEmuDir = new File(sdkDir, SdkConstants.OS_SDK_TOOLS_LIB_FOLDER + "emulator"); - toolsLibEmuDir.mkdirs(); - new File(toolsLibEmuDir, "snapshots.img").createNewFile(); - File platformsDir = new File(sdkDir, SdkConstants.FD_PLATFORMS); - - // Creating a fake target here on down - File targetDir = makeFakeTargetInternal(platformsDir); - - File imagesDir = new File(targetDir, "images"); - makeFakeSysImgInternal(imagesDir, SdkConstants.ABI_ARMEABI); - - makeFakeSkinInternal(targetDir); - makeFakeSourceInternal(sdkDir); - return sdkDir; - } - - /** - * Creates the system image folder and places a fake userdata.img in it. - * - * @param systemImage A system image with a valid location. - * @throws IOException if the file fails to be created. - */ - protected void makeSystemImageFolder(ISystemImage systemImage) throws IOException { - File imagesDir = systemImage.getLocation(); - imagesDir.mkdirs(); - - makeFakeSysImgInternal(imagesDir, systemImage.getAbiType()); - } - - //---- - - /** Utility used by {@link #makeFakeSdk()} to create a fake target with API 0, rev 0. */ - private File makeFakeTargetInternal(File platformsDir) throws IOException { - File targetDir = new File(platformsDir, "v0_0"); - targetDir.mkdirs(); - new File(targetDir, SdkConstants.FN_FRAMEWORK_LIBRARY).createNewFile(); - new File(targetDir, SdkConstants.FN_FRAMEWORK_AIDL).createNewFile(); - - File sourceProp = new File(targetDir, SdkConstants.FN_SOURCE_PROP); - sourceProp.createNewFile(); - FileWriter out = new FileWriter(sourceProp); - out.write(PkgProps.LAYOUTLIB_API + "=5\n"); - out.write(PkgProps.LAYOUTLIB_REV + "=2\n"); - out.close(); - - File buildProp = new File(targetDir, SdkConstants.FN_BUILD_PROP); - out = new FileWriter(buildProp); - out.write(SdkManager.PROP_VERSION_RELEASE + "=0.0\n"); - out.write(SdkManager.PROP_VERSION_SDK + "=0\n"); - out.write(SdkManager.PROP_VERSION_CODENAME + "=REL\n"); - out.close(); - return targetDir; - } - - /** Utility to create a fake sys image in the given folder. */ - private void makeFakeSysImgInternal(File imagesDir, String abiType) throws IOException { - imagesDir.mkdirs(); - new File(imagesDir, "userdata.img").createNewFile(); - - File sourceProp = new File(imagesDir, SdkConstants.FN_SOURCE_PROP); - sourceProp.createNewFile(); - FileWriter out = new FileWriter(sourceProp); - out.write(PkgProps.VERSION_API_LEVEL + "=0\n"); - out.write(PkgProps.SYS_IMG_ABI + "=" + abiType + "\n"); - out.close(); - } - - /** Utility to make a fake skin for the given target */ - private void makeFakeSkinInternal(File targetDir) { - FileOp.append(targetDir, "skins", "HVGA").mkdirs(); - } - - /** Utility to create a fake source with a few files in the given sdk folder. */ - private void makeFakeSourceInternal(File sdkDir) throws IOException { - File sourcesDir = FileOp.append(sdkDir, SdkConstants.FD_PKG_SOURCES, "android-0"); - sourcesDir.mkdirs(); - - File sourceProp = new File(sourcesDir, SdkConstants.FN_SOURCE_PROP); - sourceProp.createNewFile(); - FileWriter out = new FileWriter(sourceProp); - out.write(PkgProps.VERSION_API_LEVEL + "=0\n"); - out.close(); - - File dir1 = FileOp.append(sourcesDir, "src", "com", "android"); - dir1.mkdirs(); - FileOp.append(dir1, "File1.java").createNewFile(); - FileOp.append(dir1, "File2.java").createNewFile(); - - FileOp.append(sourcesDir, "res", "values").mkdirs(); - FileOp.append(sourcesDir, "res", "values", "styles.xml").createNewFile(); - } - - /** - * Recursive delete directory. Mostly for fake SDKs. - * - * @param root directory to delete - */ - private void deleteDir(File root) { - if (root.exists()) { - for (File file : root.listFiles()) { - if (file.isDirectory()) { - deleteDir(file); - } else { - file.delete(); - } - } - root.delete(); - } - } - -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/devices/DeviceParserTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/devices/DeviceParserTest.java deleted file mode 100644 index f24fbda..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/devices/DeviceParserTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.devices; - -import java.io.InputStream; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import junit.framework.TestCase; - -import org.xml.sax.SAXParseException; - -import com.android.dvlib.DeviceSchemaTest; -import com.android.resources.Density; -import com.android.resources.Keyboard; -import com.android.resources.KeyboardState; -import com.android.resources.Navigation; -import com.android.resources.NavigationState; -import com.android.resources.ScreenOrientation; -import com.android.resources.ScreenRatio; -import com.android.resources.ScreenSize; -import com.android.resources.TouchScreen; -import com.android.sdklib.devices.Storage.Unit; - -public class DeviceParserTest extends TestCase { - - public void testValidDevices() throws Exception { - InputStream devicesFile = DeviceSchemaTest.class.getResourceAsStream("devices_minimal.xml"); - List<Device> devices = DeviceParser.parse(devicesFile); - assertEquals("Parsing devices_minimal.xml produces the wrong number of devices", 1, - devices.size()); - - Device device = devices.get(0); - assertEquals("Galaxy Nexus", device.getName()); - assertEquals("Samsung", device.getManufacturer()); - - // Test Meta information - Meta meta = device.getMeta(); - assertFalse(meta.hasIconSixtyFour()); - assertFalse(meta.hasIconSixteen()); - assertFalse(meta.hasFrame()); - - // Test Hardware information - Hardware hw = device.getDefaultHardware(); - Screen screen = hw.getScreen(); - assertEquals(screen.getSize(), ScreenSize.NORMAL); - assertEquals(4.65, screen.getDiagonalLength()); - assertEquals(Density.XHIGH, screen.getPixelDensity()); - assertEquals(ScreenRatio.LONG, screen.getRatio()); - assertEquals(720, screen.getXDimension()); - assertEquals(1280, screen.getYDimension()); - assertEquals(316.0, screen.getXdpi()); - assertEquals(316.0, screen.getYdpi()); - assertEquals(Multitouch.JAZZ_HANDS, screen.getMultitouch()); - assertEquals(TouchScreen.FINGER, screen.getMechanism()); - assertEquals(ScreenType.CAPACITIVE, screen.getScreenType()); - Set<Network> networks = hw.getNetworking(); - assertTrue(networks.contains(Network.BLUETOOTH)); - assertTrue(networks.contains(Network.WIFI)); - assertTrue(networks.contains(Network.NFC)); - Set<Sensor> sensors = hw.getSensors(); - assertTrue(sensors.contains(Sensor.ACCELEROMETER)); - assertTrue(sensors.contains(Sensor.BAROMETER)); - assertTrue(sensors.contains(Sensor.GYROSCOPE)); - assertTrue(sensors.contains(Sensor.COMPASS)); - assertTrue(sensors.contains(Sensor.GPS)); - assertTrue(sensors.contains(Sensor.PROXIMITY_SENSOR)); - assertTrue(hw.hasMic()); - assertEquals(2, hw.getCameras().size()); - Camera c = hw.getCamera(CameraLocation.FRONT); - assertTrue(c != null); - assertEquals(c.getLocation(), CameraLocation.FRONT); - assertFalse(c.hasFlash()); - assertTrue(c.hasAutofocus()); - c = hw.getCamera(CameraLocation.BACK); - assertTrue(c != null); - assertEquals(c.getLocation(), CameraLocation.BACK); - assertTrue(c.hasFlash()); - assertTrue(c.hasAutofocus()); - assertEquals(Keyboard.NOKEY, hw.getKeyboard()); - assertEquals(Navigation.NONAV, hw.getNav()); - assertEquals(new Storage(1, Unit.GiB), hw.getRam()); - assertEquals(ButtonType.SOFT, hw.getButtonType()); - List<Storage> storage = hw.getInternalStorage(); - assertEquals(1, storage.size()); - assertEquals(new Storage(16, Unit.GiB), storage.get(0)); - storage = hw.getRemovableStorage(); - assertEquals(0, storage.size()); - assertEquals("OMAP 4460", hw.getCpu()); - assertEquals("PowerVR SGX540", hw.getGpu()); - Set<Abi> abis = hw.getSupportedAbis(); - assertEquals(2, abis.size()); - assertTrue(abis.contains(Abi.ARMEABI)); - assertTrue(abis.contains(Abi.ARMEABI_V7A)); - assertEquals(0, hw.getSupportedUiModes().size()); - assertEquals(PowerType.BATTERY, hw.getChargeType()); - - // Test Software - assertEquals(1, device.getAllSoftware().size()); - Software sw = device.getSoftware(15); - assertEquals(15, sw.getMaxSdkLevel()); - assertEquals(15, sw.getMinSdkLevel()); - assertTrue(sw.hasLiveWallpaperSupport()); - assertEquals(12, sw.getBluetoothProfiles().size()); - assertTrue(sw.getBluetoothProfiles().contains(BluetoothProfile.A2DP)); - assertEquals("2.0", sw.getGlVersion()); - assertEquals(29, sw.getGlExtensions().size()); - assertTrue(sw.getGlExtensions().contains("GL_OES_depth24")); - - // Test States - assertEquals(2, device.getAllStates().size()); - State s = device.getDefaultState(); - assertEquals("Portrait", s.getName()); - assertTrue(s.isDefaultState()); - assertEquals("The phone in portrait view", s.getDescription()); - assertEquals(ScreenOrientation.PORTRAIT, s.getOrientation()); - assertEquals(KeyboardState.SOFT, s.getKeyState()); - assertEquals(NavigationState.HIDDEN, s.getNavState()); - s = device.getState("Landscape"); - assertEquals("Landscape", s.getName()); - assertFalse(s.isDefaultState()); - assertEquals(ScreenOrientation.LANDSCAPE, s.getOrientation()); - } - - public void testApiRange() throws Exception { - Map<String, String> replacements = new HashMap<String, String>(); - replacements.put("api-level", "1-"); - InputStream stream = DeviceSchemaTest.getReplacedStream(replacements); - List<Device> devices = DeviceParser.parse(stream); - assertEquals(1, devices.size()); - Device device = devices.get(0); - assertTrue(device.getSoftware(1) != null); - assertTrue(device.getSoftware(2) != null); - assertTrue(device.getSoftware(0) == null); - replacements.put("api-level", "-2"); - stream = DeviceSchemaTest.getReplacedStream(replacements); - device = DeviceParser.parse(stream).get(0); - assertTrue(device.getSoftware(2) != null); - assertTrue(device.getSoftware(3) == null); - replacements.put("api-level", "1-2"); - stream = DeviceSchemaTest.getReplacedStream(replacements); - device = DeviceParser.parse(stream).get(0); - assertTrue(device.getSoftware(0) == null); - assertTrue(device.getSoftware(1) != null); - assertTrue(device.getSoftware(2) != null); - assertTrue(device.getSoftware(3) == null); - replacements.put("api-level", "-"); - stream = DeviceSchemaTest.getReplacedStream(replacements); - device = DeviceParser.parse(stream).get(0); - assertTrue(device.getSoftware(0) != null); - assertTrue(device.getSoftware(15) != null); - } - - public void testBadNetworking() throws Exception { - Map<String, String> replacements = new HashMap<String, String>(); - replacements.put("networking", "NFD"); - InputStream stream = DeviceSchemaTest.getReplacedStream(replacements); - try { - List<Device> devices = DeviceParser.parse(stream); - assertEquals(1, devices.size()); - assertEquals(0, devices.get(0).getDefaultHardware().getNetworking().size()); - fail(); - } catch (SAXParseException e) { - assertTrue(e.getMessage().startsWith("cvc-enumeration-valid: Value 'NFD'")); - } - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/devices/DeviceWriterTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/devices/DeviceWriterTest.java deleted file mode 100644 index 2b8474e..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/devices/DeviceWriterTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.devices; - -import com.android.dvlib.DeviceSchemaTest; - -import junit.framework.TestCase; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class DeviceWriterTest extends TestCase { - - public void testWriteIsValid() throws Exception { - InputStream devicesFile = - DeviceSchemaTest.class.getResourceAsStream("devices.xml"); - List<Device> devices = DeviceParser.parse(devicesFile); - assertEquals("Parsed devices contained an un expected number of devices", - 2, devices.size()); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DeviceWriter.writeToXml(baos, devices); - List<Device> writtenDevices = DeviceParser.parse( - new ByteArrayInputStream(baos.toString().getBytes())); - assertEquals("Writing and reparsing returns a different number of devices", - devices.size(), writtenDevices.size()); - for (int i = 0; i < devices.size(); i++){ - assertEquals(devices.get(i), writtenDevices.get(i)); - } - } - - public void testApiLowerBound() throws Exception { - Map<String, String> replacements = new HashMap<String, String>(); - replacements.put("api-level", "1-"); - InputStream stream = DeviceSchemaTest.getReplacedStream(replacements); - List<Device> devices = DeviceParser.parse(stream); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DeviceWriter.writeToXml(baos, devices); - List<Device> writtenDevices = DeviceParser.parse( - new ByteArrayInputStream(baos.toString().getBytes())); - assertEquals("Writing and reparsing returns a different number of devices", - devices.size(), writtenDevices.size()); - for (int i = 0; i < devices.size(); i++){ - assertEquals(devices.get(i), writtenDevices.get(i)); - } - } - - public void testApiUpperBound() throws Exception { - Map<String, String> replacements = new HashMap<String, String>(); - replacements.put("api-level", "-10"); - InputStream stream = DeviceSchemaTest.getReplacedStream(replacements); - List<Device> devices = DeviceParser.parse(stream); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DeviceWriter.writeToXml(baos, devices); - List<Device> writtenDevices = DeviceParser.parse( - new ByteArrayInputStream(baos.toString().getBytes())); - assertEquals("Writing and reparsing returns a different number of devices", - devices.size(), writtenDevices.size()); - for (int i = 0; i < devices.size(); i++){ - assertEquals(devices.get(i), writtenDevices.get(i)); - } - } - - public void testApiNeitherBound() throws Exception { - Map<String, String> replacements = new HashMap<String, String>(); - replacements.put("api-level", "-"); - InputStream stream = DeviceSchemaTest.getReplacedStream(replacements); - List<Device> devices = DeviceParser.parse(stream); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DeviceWriter.writeToXml(baos, devices); - List<Device> writtenDevices = DeviceParser.parse( - new ByteArrayInputStream(baos.toString().getBytes())); - assertEquals("Writing and reparsing returns a different number of devices", - devices.size(), writtenDevices.size()); - for (int i = 0; i < devices.size(); i++){ - assertEquals(devices.get(i), writtenDevices.get(i)); - } - } - - public void testApiBothBound() throws Exception { - Map<String, String> replacements = new HashMap<String, String>(); - replacements.put("api-level", "9-10"); - InputStream stream = DeviceSchemaTest.getReplacedStream(replacements); - List<Device> devices = DeviceParser.parse(stream); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DeviceWriter.writeToXml(baos, devices); - List<Device> writtenDevices = DeviceParser.parse( - new ByteArrayInputStream(baos.toString().getBytes())); - assertEquals("Writing and reparsing returns a different number of devices", - devices.size(), writtenDevices.size()); - for (int i = 0; i < devices.size(); i++){ - assertEquals(devices.get(i), writtenDevices.get(i)); - } - } - public void testApiSingle() throws Exception { - Map<String, String> replacements = new HashMap<String, String>(); - replacements.put("api-level", "10"); - InputStream stream = DeviceSchemaTest.getReplacedStream(replacements); - List<Device> devices = DeviceParser.parse(stream); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DeviceWriter.writeToXml(baos, devices); - List<Device> writtenDevices = DeviceParser.parse( - new ByteArrayInputStream(baos.toString().getBytes())); - assertEquals("Writing and reparsing returns a different number of devices", - devices.size(), writtenDevices.size()); - for (int i = 0; i < devices.size(); i++){ - assertEquals(devices.get(i), writtenDevices.get(i)); - } - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/build/DebugKeyProviderTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/build/DebugKeyProviderTest.java deleted file mode 100755 index ead66ee..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/build/DebugKeyProviderTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.build; - -import com.android.sdklib.internal.build.DebugKeyProvider.IKeyGenOutput; - -import java.io.File; -import java.security.PrivateKey; -import java.security.cert.X509Certificate; -import java.util.Calendar; - -import junit.framework.TestCase; - -public class DebugKeyProviderTest extends TestCase { - - private File mTmpFile; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - // We want to allocate a new tmp file but not have it actually exist - mTmpFile = File.createTempFile(this.getClass().getSimpleName(), ".keystore"); - assertTrue(mTmpFile.delete()); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - if (mTmpFile != null) { - if (!mTmpFile.delete()) { - mTmpFile.deleteOnExit(); - } - mTmpFile = null; - } - } - - public void testCreateAndCheckKey() throws Exception { - String osPath = mTmpFile.getAbsolutePath(); - - KeygenOutput keygenOutput = new KeygenOutput(); - - // "now" is just slightly before the key was created - long now = System.currentTimeMillis(); - - DebugKeyProvider provider; - try { - provider = new DebugKeyProvider(osPath, null /*storeType*/, keygenOutput); - } catch (Throwable t) { - // In case we get any kind of exception, rewrap it to make sure we output - // the path used. - String msg = String.format("%1$s in %2$s\n%3$s", - t.getClass().getSimpleName(), osPath, t.toString()); - throw new Exception(msg, t); - } - assertNotNull(provider); - - assertEquals("", keygenOutput.getOut()); - assertEquals("", keygenOutput.getErr()); - - PrivateKey key = provider.getDebugKey(); - assertNotNull(key); - - X509Certificate certificate = (X509Certificate) provider.getCertificate(); - assertNotNull(certificate); - - // The "not-after" (a.k.a. expiration) date should be after "now" - Calendar c = Calendar.getInstance(); - c.setTimeInMillis(now); - assertTrue(certificate.getNotAfter().compareTo(c.getTime()) > 0); - - // It should be valid after 1 year from now (adjust by a second since the 'now' time - // doesn't exactly match the creation time... 1 second should be enough.) - c.add(Calendar.DAY_OF_YEAR, 365); - c.add(Calendar.SECOND, -1); - assertTrue("1 year expiration failed", - certificate.getNotAfter().compareTo(c.getTime()) > 0); - - // and 30 years from now - c.add(Calendar.DAY_OF_YEAR, 29 * 365); - assertTrue("30 year expiration failed", - certificate.getNotAfter().compareTo(c.getTime()) > 0); - - // however expiration date should be passed in 30 years + 1 hour - c.add(Calendar.HOUR, 1); - assertFalse("30 year and 1 hour expiration failed", - certificate.getNotAfter().compareTo(c.getTime()) > 0); - } - - private static class KeygenOutput implements IKeyGenOutput { - private String mOut = ""; //$NON-NLS-1$ - private String mErr = ""; //$NON-NLS-1$ - - @Override - public void out(String message) { - mOut += message + "\n"; //$NON-NLS-1$ - } - - @Override - public void err(String message) { - mErr += message + "\n"; //$NON-NLS-1$ - } - - public String getOut() { - return mOut; - } - - public String getErr() { - return mErr; - } - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/AddonsListFetcherTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/AddonsListFetcherTest.java deleted file mode 100755 index f62533d..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/AddonsListFetcherTest.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.eclipse.org/org/documents/epl-v10.php - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository; - -import com.android.sdklib.internal.repository.AddonsListFetcher.Site; -import com.android.sdklib.repository.SdkAddonsListConstants; - -import org.w3c.dom.Document; - -import java.io.ByteArrayInputStream; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; - -import junit.framework.TestCase; - -/** - * Tests for {@link AddonsListFetcher} - */ -public class AddonsListFetcherTest extends TestCase { - - /** - * An internal helper class to give us visibility to the protected members we want - * to test. - */ - private static class MockAddonsListFetcher extends AddonsListFetcher { - - public Site[] _parseAddonsList(Document doc, - String nsUri, - String baseUrl, - ITaskMonitor monitor) { - return super.parseAddonsList(doc, nsUri, baseUrl, monitor); - } - - public int _getXmlSchemaVersion(InputStream xml) { - return super.getXmlSchemaVersion(xml); - } - - public String _validateXml(InputStream xml, - String url, - int version, - String[] outError, - Boolean[] validatorFound) { - return super.validateXml(xml, url, version, outError, validatorFound); - } - - public Document _getDocument(InputStream xml, ITaskMonitor monitor) { - return super.getDocument(xml, monitor); - } - - } - - private MockAddonsListFetcher mFetcher; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - mFetcher = new MockAddonsListFetcher(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - - mFetcher = null; - } - - /** - * Validate we can load a valid addon schema version 1 - */ - public void testLoadSample_1() throws Exception { - InputStream xmlStream = - getTestResource("/com/android/sdklib/testdata/addons_list_sample_1.xml"); - - // guess the version from the XML document - int version = mFetcher._getXmlSchemaVersion(xmlStream); - assertEquals(1, version); - - Boolean[] validatorFound = new Boolean[] { Boolean.FALSE }; - String[] validationError = new String[] { null }; - String url = "not-a-valid-url://addons_list.xml"; - - String uri = mFetcher._validateXml( - xmlStream, url, version, validationError, validatorFound); - assertEquals(Boolean.TRUE, validatorFound[0]); - assertEquals(null, validationError[0]); - assertEquals(SdkAddonsListConstants.getSchemaUri(1), uri); - - // Validation was successful, load the document - MockMonitor monitor = new MockMonitor(); - Document doc = mFetcher._getDocument(xmlStream, monitor); - assertNotNull(doc); - - // Get the sites - Site[] result = mFetcher._parseAddonsList(doc, uri, "http://base/url/", monitor); - - assertEquals("", monitor.getCapturedDescriptions()); - assertEquals("", monitor.getCapturedLog()); - assertEquals("", monitor.getCapturedErrorLog()); - assertEquals("", monitor.getCapturedVerboseLog()); - - // check the sites we found... - // The XML file is UTF-8 so we support character sets (but the Java source file is - // not, so we use the \\u notation to create the Unicode String) - assertEquals( - "[<ADDON_SITE URL='http://www.example.com/my_addons.xml' Name='My Example Add-ons.'>, " + - "<ADDON_SITE URL='http://www.example.co.jp/addons.xml' Name='\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002'>, " + - "<ADDON_SITE URL='http://www.example.com/' Name='Example of directory URL.'>, " + - "<ADDON_SITE URL='http://base/url/relative_url.xml' Name='Relative URL.'>]", - Arrays.toString(result)); - assertEquals(4, result.length); - } - - /** - * Validate we can load a valid addon schema version 2 - */ - public void testLoadSample_2() throws Exception { - InputStream xmlStream = - getTestResource("/com/android/sdklib/testdata/addons_list_sample_2.xml"); - - // guess the version from the XML document - int version = mFetcher._getXmlSchemaVersion(xmlStream); - assertEquals(2, version); - - Boolean[] validatorFound = new Boolean[] { Boolean.FALSE }; - String[] validationError = new String[] { null }; - String url = "not-a-valid-url://addons_list.xml"; - - String uri = mFetcher._validateXml( - xmlStream, url, version, validationError, validatorFound); - assertEquals(Boolean.TRUE, validatorFound[0]); - assertEquals(null, validationError[0]); - assertEquals(SdkAddonsListConstants.getSchemaUri(2), uri); - - // Validation was successful, load the document - MockMonitor monitor = new MockMonitor(); - Document doc = mFetcher._getDocument(xmlStream, monitor); - assertNotNull(doc); - - // Get the sites - Site[] result = mFetcher._parseAddonsList(doc, uri, "http://base/url/", monitor); - - assertEquals("", monitor.getCapturedDescriptions()); - assertEquals("", monitor.getCapturedLog()); - assertEquals("", monitor.getCapturedErrorLog()); - assertEquals("", monitor.getCapturedVerboseLog()); - - // check the sites we found... - // The XML file is UTF-8 so we support character sets (but the Java source file is - // not, so we use the \\u notation to create the Unicode String) - assertEquals( - "[<ADDON_SITE URL='http://www.example.com/my_addons.xml' Name='My Example Add-ons.'>, " + - "<ADDON_SITE URL='http://www.example.co.jp/addons.xml' Name='\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002'>, " + - "<ADDON_SITE URL='http://www.example.com/' Name='Example of directory URL.'>, " + - "<SYS_IMG_SITE URL='http://www.example.com/' Name='Example of sys-img URL using the default xml filename.'>, " + - "<SYS_IMG_SITE URL='http://www.example.com/specific_file.xml' Name='Example of sys-img URL using a specific xml filename.'>, " + - "<ADDON_SITE URL='http://base/url/relative/url.xml' Name='Relative URL.'>]", - Arrays.toString(result)); - assertEquals(6, result.length); - } - - // IMPORTANT: Each time you add a test here for a new version, you should - // also add a test in ValidateAddonsListXmlTest. - - /** - * Returns an SdkLib file resource as a {@link ByteArrayInputStream}, - * which has the advantage that we can use {@link InputStream#reset()} on it - * at any time to read it multiple times. - * <p/> - * The default for getResourceAsStream() is to return a {@link FileInputStream} that - * does not support reset(), yet we need it in the tested code. - * - * @throws IOException if some I/O read fails - */ - private ByteArrayInputStream getTestResource(String filename) throws IOException { - InputStream xmlStream = this.getClass().getResourceAsStream(filename); - - try { - byte[] data = new byte[8192]; - int offset = 0; - int n; - - while ((n = xmlStream.read(data, offset, data.length - offset)) != -1) { - offset += n; - - if (offset == data.length) { - byte[] newData = new byte[offset + 8192]; - System.arraycopy(data, 0, newData, 0, offset); - data = newData; - } - } - - return new ByteArrayInputStream(data, 0, offset); - } finally { - if (xmlStream != null) { - xmlStream.close(); - } - } - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/LocalSdkParserTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/LocalSdkParserTest.java deleted file mode 100755 index 4989ec3..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/LocalSdkParserTest.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository; - -import com.android.SdkConstants; -import com.android.sdklib.IAndroidTarget; -import com.android.sdklib.ISystemImage.LocationType; -import com.android.sdklib.SdkManager; -import com.android.sdklib.SdkManagerTestCase; -import com.android.sdklib.SystemImage; - -import java.util.Arrays; - -public class LocalSdkParserTest extends SdkManagerTestCase { - - public void testLocalSdkParser_SystemImages() throws Exception { - SdkManager sdkman = getSdkManager(); - LocalSdkParser parser = new LocalSdkParser(); - MockMonitor monitor = new MockMonitor(); - - // By default SdkManagerTestCase creates an SDK with one platform containing - // a legacy armeabi system image (this is not a separate system image package) - - assertEquals( - "[Android SDK Tools, revision 0, " + - "SDK Platform Android 0.0, API 0, revision 1, " + - "Sources for Android SDK, API 0, revision 0]", - Arrays.toString(parser.parseSdk(sdkman.getLocation(), sdkman, monitor))); - - assertEquals( - "[SDK Platform Android 0.0, API 0, revision 1, " + - "Sources for Android SDK, API 0, revision 0]", - Arrays.toString(parser.parseSdk(sdkman.getLocation(), - sdkman, - LocalSdkParser.PARSE_PLATFORMS | LocalSdkParser.PARSE_SOURCES, - monitor))); - - assertEquals( - "[SDK Platform Android 0.0, API 0, revision 1]", - Arrays.toString(parser.parseSdk(sdkman.getLocation(), - sdkman, - LocalSdkParser.PARSE_PLATFORMS, - monitor))); - - assertEquals( - "[Sources for Android SDK, API 0, revision 0]", - Arrays.toString(parser.parseSdk(sdkman.getLocation(), - sdkman, - LocalSdkParser.PARSE_SOURCES, - monitor))); - - assertEquals( - "[Android SDK Tools, revision 0]", - Arrays.toString(parser.parseSdk(sdkman.getLocation(), - sdkman, - LocalSdkParser.PARSE_TOOLS, - monitor))); - - // Now add a few "platform subfolders" system images and reload the SDK. - // This disables the "legacy" mode but it still doesn't create any system image package - - IAndroidTarget t = sdkman.getTargets()[0]; - makeSystemImageFolder(new SystemImage( - sdkman, t, LocationType.IN_PLATFORM_SUBFOLDER, SdkConstants.ABI_ARMEABI_V7A)); - makeSystemImageFolder(new SystemImage( - sdkman, t, LocationType.IN_PLATFORM_SUBFOLDER, SdkConstants.ABI_INTEL_ATOM)); - - sdkman.reloadSdk(getLog()); - t = sdkman.getTargets()[0]; - - assertEquals( - "[Android SDK Tools, revision 0, " + - "SDK Platform Android 0.0, API 0, revision 1, " + - "Sources for Android SDK, API 0, revision 0]", - Arrays.toString(parser.parseSdk(sdkman.getLocation(), sdkman, monitor))); - - // Now add arm + arm v7a images using the new SDK/system-images. - // The local parser will find the 2 system image packages which are associated - // with the PlatformTarger in the SdkManager. - - makeSystemImageFolder(new SystemImage( - sdkman, t, LocationType.IN_SYSTEM_IMAGE, SdkConstants.ABI_ARMEABI)); - makeSystemImageFolder(new SystemImage( - sdkman, t, LocationType.IN_SYSTEM_IMAGE, SdkConstants.ABI_ARMEABI_V7A)); - - sdkman.reloadSdk(getLog()); - - assertEquals( - "[Android SDK Tools, revision 0, " + - "SDK Platform Android 0.0, API 0, revision 1, " + - "ARM EABI v7a System Image, Android API 0, revision 0, " + - "ARM EABI System Image, Android API 0, revision 0, " + - "Sources for Android SDK, API 0, revision 0]", - Arrays.toString(parser.parseSdk(sdkman.getLocation(), sdkman, monitor))); - - // Now add an x86 image using the new SDK/system-images. - // Now this time we do NOT reload the SdkManager instance. Instead the parser - // will find an unused system image and load it as a "broken package". - - makeSystemImageFolder(new SystemImage( - sdkman, t, LocationType.IN_SYSTEM_IMAGE, SdkConstants.ABI_INTEL_ATOM)); - - assertEquals( - "[Android SDK Tools, revision 0, " + - "SDK Platform Android 0.0, API 0, revision 1, " + - "ARM EABI v7a System Image, Android API 0, revision 0, " + - "ARM EABI System Image, Android API 0, revision 0, " + - "Sources for Android SDK, API 0, revision 0, " + - "Broken Intel x86 Atom System Image, API 0]", - Arrays.toString(parser.parseSdk(sdkman.getLocation(), sdkman, monitor))); - - assertEquals( - "[Android SDK Tools, revision 0, " + - "SDK Platform Android 0.0, API 0, revision 1, " + - "ARM EABI v7a System Image, Android API 0, revision 0, " + - "ARM EABI System Image, Android API 0, revision 0, " + - "Sources for Android SDK, API 0, revision 0, " + - "Broken Intel x86 Atom System Image, API 0]", - Arrays.toString(parser.parseSdk(sdkman.getLocation(), - sdkman, - LocalSdkParser.PARSE_ALL, - monitor))); - - assertEquals( - "[SDK Platform Android 0.0, API 0, revision 1, " + - "ARM EABI v7a System Image, Android API 0, revision 0, " + - "ARM EABI System Image, Android API 0, revision 0, " + - "Sources for Android SDK, API 0, revision 0, " + - "Broken Intel x86 Atom System Image, API 0]", - Arrays.toString(parser.parseSdk(sdkman.getLocation(), - sdkman, - LocalSdkParser.PARSE_PLATFORMS | // platform also loads system-images - LocalSdkParser.PARSE_SOURCES, - monitor))); - - assertEquals( - "[Sources for Android SDK, API 0, revision 0]", - Arrays.toString(parser.parseSdk(sdkman.getLocation(), - sdkman, - LocalSdkParser.PARSE_SOURCES, - monitor))); - } - -} - diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockEmptySdkManager.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockEmptySdkManager.java deleted file mode 100755 index be1fb29..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockEmptySdkManager.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.eclipse.org/org/documents/epl-v10.php - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository; - -import com.android.sdklib.IAndroidTarget; -import com.android.sdklib.SdkManager; - -/** - * An invalid SDK Manager, just good enough to avoid passing a null reference. - */ -public class MockEmptySdkManager extends SdkManager { - public MockEmptySdkManager(String osSdkPath) { - super(osSdkPath); - setTargets(new IAndroidTarget[0]); - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockMonitor.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockMonitor.java deleted file mode 100755 index 72e7d93..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockMonitor.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.eclipse.org/org/documents/epl-v10.php - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository; - -import com.android.annotations.NonNull; - -/** - * Mock implementation of {@link ITaskMonitor} that simply captures - * the output in local strings. Does not provide any UI and has no - * support for creating sub-monitors. - */ -public class MockMonitor implements ITaskMonitor { - - String mCapturedLog = ""; //$NON-NLS-1$ - String mCapturedErrorLog = ""; //$NON-NLS-1$ - String mCapturedVerboseLog = ""; //$NON-NLS-1$ - String mCapturedDescriptions = ""; //$NON-NLS-1$ - - public String getCapturedLog() { - return mCapturedLog; - } - - public String getCapturedErrorLog() { - return mCapturedErrorLog; - } - - public String getCapturedVerboseLog() { - return mCapturedVerboseLog; - } - - public String getCapturedDescriptions() { - return mCapturedDescriptions; - } - - @Override - public void log(String format, Object... args) { - mCapturedLog += String.format(format, args) + "\n"; //$NON-NLS-1$ - } - - @Override - public void logError(String format, Object... args) { - mCapturedErrorLog += String.format(format, args) + "\n"; //$NON-NLS-1$ - } - - @Override - public void logVerbose(String format, Object... args) { - mCapturedVerboseLog += String.format(format, args) + "\n"; //$NON-NLS-1$ - } - - @Override - public void setProgressMax(int max) { - } - - @Override - public int getProgressMax() { - return 0; - } - - @Override - public void setDescription(String format, Object... args) { - mCapturedDescriptions += String.format(format, args) + "\n"; //$NON-NLS-1$ - } - - @Override - public boolean isCancelRequested() { - return false; - } - - @Override - public void incProgress(int delta) { - } - - @Override - public int getProgress() { - return 0; - } - - @Override - public boolean displayPrompt(String title, String message) { - return false; - } - - @Override - public ITaskMonitor createSubMonitor(int tickCount) { - return null; - } - - @Override - public void error(Throwable t, String errorFormat, Object... args) { - } - - @Override - public void info(@NonNull String msgFormat, Object... args) { - } - - @Override - public void verbose(@NonNull String msgFormat, Object... args) { - } - - @Override - public void warning(@NonNull String warningFormat, Object... args) { - } - - @Override - public UserCredentials displayLoginCredentialsPrompt(String title, String message) { - return null; - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockPlatformTarget.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockPlatformTarget.java deleted file mode 100755 index 1d9bb7b..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockPlatformTarget.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository; - -import com.android.SdkConstants; -import com.android.sdklib.AndroidVersion; -import com.android.sdklib.IAndroidTarget; -import com.android.sdklib.ISystemImage; -import com.android.sdklib.ISystemImage.LocationType; -import com.android.sdklib.SystemImage; -import com.android.sdklib.io.FileOp; - -import java.util.Map; - -/** - * A mock PlatformTarget. - * This reimplements the minimum needed from the interface for our limited testing needs. - */ -public class MockPlatformTarget implements IAndroidTarget { - - private final int mApiLevel; - private final int mRevision; - private ISystemImage[] mSystemImages; - - public MockPlatformTarget(int apiLevel, int revision) { - mApiLevel = apiLevel; - mRevision = revision; - } - - @Override - public String getClasspathName() { - return getName(); - } - - @Override - public String getShortClasspathName() { - return getName(); - } - - @Override - public String getDefaultSkin() { - return null; - } - - @Override - public String getDescription() { - return getName(); - } - - @Override - public String getFullName() { - return getName(); - } - - @Override - public ISystemImage[] getSystemImages() { - if (mSystemImages == null) { - SystemImage si = new SystemImage( - FileOp.append(getLocation(), SdkConstants.OS_IMAGES_FOLDER), - LocationType.IN_PLATFORM_LEGACY, - SdkConstants.ABI_ARMEABI); - mSystemImages = new SystemImage[] { si }; - } - return mSystemImages; - } - - @Override - public ISystemImage getSystemImage(String abiType) { - if (SdkConstants.ABI_ARMEABI.equals(abiType)) { - return getSystemImages()[0]; - } - return null; - } - - @Override - public String getLocation() { - return "/sdk/platforms/android-" + getVersion().getApiString(); - } - - @Override - public IOptionalLibrary[] getOptionalLibraries() { - return null; - } - - @Override - public IAndroidTarget getParent() { - return null; - } - - @Override - public String getPath(int pathId) { - throw new UnsupportedOperationException("Implement this as needed for tests"); - } - - @Override - public String[] getPlatformLibraries() { - return null; - } - - @Override - public String getProperty(String name) { - return null; - } - - @Override - public Integer getProperty(String name, Integer defaultValue) { - return defaultValue; - } - - @Override - public Boolean getProperty(String name, Boolean defaultValue) { - return defaultValue; - } - - @Override - public Map<String, String> getProperties() { - return null; - } - - @Override - public int getRevision() { - return mRevision; - } - - @Override - public String[] getSkins() { - return null; - } - - @Override - public int getUsbVendorId() { - return 0; - } - - /** - * Returns a vendor that depends on the parent *platform* API. - * This works well in Unit Tests where we'll typically have different - * platforms as unique identifiers. - */ - @Override - public String getVendor() { - return "vendor " + Integer.toString(mApiLevel); - } - - /** - * Create a synthetic name using the target API level. - */ - @Override - public String getName() { - return "platform r" + Integer.toString(mApiLevel); - } - - @Override - public AndroidVersion getVersion() { - return new AndroidVersion(mApiLevel, null /*codename*/); - } - - @Override - public String getVersionName() { - return String.format("android-%1$d", mApiLevel); - } - - @Override - public String hashString() { - return getVersionName(); - } - - /** Returns true for a platform. */ - @Override - public boolean isPlatform() { - return true; - } - - @Override - public boolean canRunOn(IAndroidTarget target) { - throw new UnsupportedOperationException("Implement this as needed for tests"); - } - - @Override - public int compareTo(IAndroidTarget o) { - throw new UnsupportedOperationException("Implement this as needed for tests"); - } - - @Override - public boolean hasRenderingLibrary() { - return false; - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/SdkStatsTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/SdkStatsTest.java deleted file mode 100755 index baff6f9..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/SdkStatsTest.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.eclipse.org/org/documents/epl-v10.php - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository; - -import com.android.sdklib.internal.repository.SdkStats.PlatformStat; -import com.android.sdklib.repository.SdkStatsConstants; -import com.android.sdklib.util.SparseArray; - -import org.w3c.dom.Document; - -import java.io.ByteArrayInputStream; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; - -import junit.framework.TestCase; - -/** - * Tests for {@link SdkStats} - */ -public class SdkStatsTest extends TestCase { - - /** - * An internal helper class to give us visibility to the protected members we want - * to test. - */ - private static class MockSdkStats extends SdkStats { - - public SparseArray<PlatformStat> _parseStatsDocument(Document doc, - String nsUri, - ITaskMonitor monitor) { - return super.parseStatsDocument(doc, nsUri, monitor); - } - - public int _getXmlSchemaVersion(InputStream xml) { - return super.getXmlSchemaVersion(xml); - } - - public String _validateXml(InputStream xml, String url, int version, - String[] outError, Boolean[] validatorFound) { - return super.validateXml(xml, url, version, outError, validatorFound); - } - - public Document _getDocument(InputStream xml, ITaskMonitor monitor) { - return super.getDocument(xml, monitor); - } - - } - - private MockSdkStats mStats; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - mStats = new MockSdkStats(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - - mStats = null; - } - - /** - * Validate we can still load a valid addon schema version 1 - */ - public void testLoadSample_1() throws Exception { - InputStream xmlStream = - getTestResource("/com/android/sdklib/testdata/stats_sample_1.xml"); - - // guess the version from the XML document - int version = mStats._getXmlSchemaVersion(xmlStream); - assertEquals(1, version); - - Boolean[] validatorFound = new Boolean[] { Boolean.FALSE }; - String[] validationError = new String[] { null }; - String url = "not-a-valid-url://stats.xml"; - - String uri = mStats._validateXml( - xmlStream, url, version, validationError, validatorFound); - assertEquals(Boolean.TRUE, validatorFound[0]); - assertEquals(null, validationError[0]); - assertEquals(SdkStatsConstants.getSchemaUri(1), uri); - - // Validation was successful, load the document - MockMonitor monitor = new MockMonitor(); - Document doc = mStats._getDocument(xmlStream, monitor); - assertNotNull(doc); - - // Get the sites - SparseArray<PlatformStat> result = mStats._parseStatsDocument(doc, uri, monitor); - - assertEquals("", monitor.getCapturedDescriptions()); - assertEquals("", monitor.getCapturedLog()); - assertEquals("", monitor.getCapturedErrorLog()); - assertEquals("", monitor.getCapturedVerboseLog()); - - // check what we found - assertEquals(3, result.size()); - int len = result.size(); - - int[] keys = new int[len]; - PlatformStat[] stats = new PlatformStat[len]; - for (int i = 0; i < len; i++) { - keys[i] = result.keyAt(i); - stats[i] = result.valueAt(i); - } - - assertEquals( - "[3, 5, 42]", - Arrays.toString(keys)); - - assertEquals( - "[<Stat api=3, code=Vanilla, vers=Android 0.5, share=0.1%, accum=100.0%>, " + - "<Stat api=5, code=Coffee, vers=Android 42.0, share=25.8%, accum=99.9%>, " + - "<Stat api=42, code=Chocolate, vers=Android 32.64, share=74.1%, accum=74.1%>]", - Arrays.toString(stats)); - } - - /** - * Returns an SdkLib file resource as a {@link ByteArrayInputStream}, - * which has the advantage that we can use {@link InputStream#reset()} on it - * at any time to read it multiple times. - * <p/> - * The default for getResourceAsStream() is to return a {@link FileInputStream} that - * does not support reset(), yet we need it in the tested code. - * - * @throws IOException if some I/O read fails - */ - private ByteArrayInputStream getTestResource(String filename) throws IOException { - InputStream xmlStream = this.getClass().getResourceAsStream(filename); - - try { - byte[] data = new byte[8192]; - int offset = 0; - int n; - - while ((n = xmlStream.read(data, offset, data.length - offset)) != -1) { - offset += n; - - if (offset == data.length) { - byte[] newData = new byte[offset + 8192]; - System.arraycopy(data, 0, newData, 0, offset); - data = newData; - } - } - - return new ByteArrayInputStream(data, 0, offset); - } finally { - if (xmlStream != null) { - xmlStream.close(); - } - } - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/archives/ArchiveInstallerTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/archives/ArchiveInstallerTest.java deleted file mode 100755 index b0b3f03..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/archives/ArchiveInstallerTest.java +++ /dev/null @@ -1,414 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.archives; - -import com.android.sdklib.internal.repository.DownloadCache; -import com.android.sdklib.internal.repository.ITaskMonitor; -import com.android.sdklib.internal.repository.MockEmptySdkManager; -import com.android.sdklib.internal.repository.MockMonitor; -import com.android.sdklib.internal.repository.archives.Archive.Arch; -import com.android.sdklib.internal.repository.archives.Archive.Os; -import com.android.sdklib.internal.repository.packages.ExtraPackage; -import com.android.sdklib.internal.repository.packages.MockEmptyPackage; -import com.android.sdklib.internal.repository.packages.MockExtraPackage; -import com.android.sdklib.internal.repository.sources.SdkRepoSource; -import com.android.sdklib.internal.repository.sources.SdkSource; -import com.android.sdklib.io.IFileOp; -import com.android.sdklib.io.MockFileOp; -import com.android.sdklib.repository.PkgProps; -import com.android.utils.Pair; - -import java.io.File; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.regex.Pattern; - -import junit.framework.TestCase; - -/** - * Unit tests for {@link ArchiveInstaller}. - */ -public class ArchiveInstallerTest extends TestCase { - - private MockMonitor mMon; - private String mSdkRoot; - private MockFileOp mFile; - private MockArchiveInstaller mArchInst; - private MockEmptySdkManager mSdkMan; - - private class MockArchiveInstaller extends ArchiveInstaller { - - private Map<Archive, File> mDownloadMap = new HashMap<Archive, File>(); - - public MockArchiveInstaller(IFileOp fileUtils) { - super(fileUtils); - } - - public void setDownloadResponse(Archive archive, File response) { - mDownloadMap.put(archive, response); - } - - @Override - protected Pair<File, File> downloadFile( - Archive archive, - String osSdkRoot, - DownloadCache cache, - ITaskMonitor monitor, - boolean forceHttp) { - File file = mDownloadMap.get(archive); - // register the file as "created" - ArchiveInstallerTest.this.mFile.recordExistingFile(file); - return Pair.of(file, null); - } - - @Override - protected boolean unzipFolder( - ArchiveReplacement archiveInfo, - File archiveFile, - File unzipDestFolder, - ITaskMonitor monitor) { - // Claim the unzip works if the input archiveFile is one we know about - // and the destination actually exists. - - if (getFileOp().isDirectory(unzipDestFolder) && - mDownloadMap.values().contains(archiveFile)) { - return true; - } - - return false; - } - - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - mFile = new MockFileOp(); - mArchInst = new MockArchiveInstaller(mFile); - mSdkRoot = "/sdk"; - mSdkMan = new MockEmptySdkManager(mSdkRoot); - mMon = new MockMonitor(); - } - - // ---- - - /** Test we don't try to install a local archive. */ - public void testInstall_SkipLocalArchive() throws Exception { - MockEmptyPackage p = new MockEmptyPackage("testPkg"); - ArchiveReplacement ar = new ArchiveReplacement(p.getArchives()[0], null /*replaced*/); - - assertFalse(mArchInst.install(ar, mSdkRoot, false /*forceHttp*/, mSdkMan, - null /*UrlCache*/, mMon)); - assertTrue(mMon.getCapturedLog().indexOf("Skipping already installed archive") != -1); - } - - /** Test we can install a simple new archive. */ - public void testInstall_NewArchive() throws Exception { - SdkSource src1 = new SdkRepoSource("http://repo.example.com/url", "repo1"); - MockEmptyPackage p = createRemoteEmptyPackage(src1, "testPkg"); - ArchiveReplacement ar = new ArchiveReplacement(p.getArchives()[0], null /*replaced*/); - - // associate the File that will be "downloaded" for this archive - mArchInst.setDownloadResponse( - p.getArchives()[0], createFile("/sdk", "tmp", "download1.zip")); - - assertTrue(mArchInst.install(ar, mSdkRoot, false /*forceHttp*/, mSdkMan, - null /*UrlCache*/, mMon)); - - // check what was created - assertEquals( - "[/sdk/mock/testPkg/source.properties]", - Arrays.toString(mFile.getExistingFiles())); - - assertEquals( - "[/, /sdk, /sdk/mock, /sdk/mock/testPkg]", - Arrays.toString(mFile.getExistingFolders())); - - assertEquals( - "[</sdk/mock/testPkg/source.properties: '### Android Tool: Source of this archive.\n" + - "#...date...\n" + - "Archive.Os=ANY\n" + - "Pkg.Revision=0\n" + - "Archive.Arch=ANY\n" + - "Pkg.SourceUrl=http\\://repo.example.com/url\n" + - "'>]", - stripDate(Arrays.toString(mFile.getOutputStreams()))); - - assertEquals( - "Installing 'testPkg'\n" + - "Installed 'testPkg'\n", - mMon.getCapturedLog()); - } - - /** Test we can replace and rename an Extra package. */ - public void testInstall_InstallExtraArchive() throws Exception { - SdkSource src1 = new SdkRepoSource("http://repo.example.com/url", "repo1"); - - MockExtraPackage newPkg = createRemoteExtraPackage(src1, "vendor1", "oldPath", 2, 1); - MockExtraPackage oldPkg = new MockExtraPackage(src1, "vendor1", "oldPath", 1, 1); - - // old pkg is installed, so its directory & files exists - mFile.recordExistingFile("/sdk/extras/vendor1/oldPath/source.properties"); - mFile.recordExistingFolder("/sdk/extras/vendor1/oldPath"); - - ArchiveReplacement ar = new ArchiveReplacement( - newPkg.getArchives()[0], - oldPkg.getArchives()[0]); - - // associate the File that will be "downloaded" for this archive - mArchInst.setDownloadResponse( - newPkg.getArchives()[0], createFile("/sdk", "tmp", "download1.zip")); - - assertTrue(mArchInst.install(ar, mSdkRoot, false /*forceHttp*/, mSdkMan, - null /*UrlCache*/, mMon)); - - // check what was created - assertEquals( - "[/sdk/extras/vendor1/oldPath/source.properties]", - Arrays.toString(mFile.getExistingFiles())); - - // This created the /sdk/temp folder to put the oldPath package whilst we unzipped - // the new one. The oldPath dir was then cleaned up but we still leave the root - // temp dir around. - assertEquals( - "[/, /sdk, /sdk/extras, /sdk/extras/vendor1, /sdk/extras/vendor1/oldPath, /sdk/temp]", - Arrays.toString(mFile.getExistingFolders())); - - assertEquals( - ( - "[</sdk/extras/vendor1/oldPath/source.properties: " + - "'### Android Tool: Source of this archive.\n" + - "#...date...\n" + - "Extra.VendorDisplay=vendor1\n" + - "Pkg.Desc=desc\n" + - "Extra.Path=oldPath\n" + - "Archive.Arch=ANY\n" + - "Pkg.DescUrl=url\n" + - "Extra.NameDisplay=Vendor1 OldPath\n" + - "Archive.Os=ANY\n" + - "Pkg.SourceUrl=http\\://repo.example.com/url\n" + - "Pkg.Revision=2\n" + - "Extra.VendorId=vendor1\n" + - "'>]"), - stripDate(Arrays.toString(mFile.getOutputStreams()))); - - assertEquals( - "Installing Vendor1 OldPath, revision 2\n" + - "Installed Vendor1 OldPath, revision 2\n", - mMon.getCapturedLog()); - } - - /** Test we can replace and rename an Extra package. */ - public void testInstall_InstallRenamedExtraArchive() throws Exception { - SdkSource src1 = new SdkRepoSource("http://repo.example.com/url", "repo1"); - - MockExtraPackage newPkg = createRemoteExtraPackage( - src1, - "vendor1", - "newPath", - "oldPath", - 2, // revision - 1); // min_platform_tools_rev - ExtraPackage oldPkg = (ExtraPackage) ExtraPackage.create( - src1, // source - null, // props - "vendor1", // vendor - "oldPath", // path - 1, // revision - null, // license - null, // description - null, // descUrl - Os.ANY, // archiveOs - Arch.ANY, // archiveArch - "/sdk/extras/vendor1/oldPath" // archiveOsPath - ); - - // old pkg is installed, so its directory & files exists - mFile.recordExistingFile("/sdk/extras/vendor1/oldPath/source.properties"); - mFile.recordExistingFolder("/sdk/extras/vendor1/oldPath"); - - ArchiveReplacement ar = new ArchiveReplacement( - newPkg.getArchives()[0], - oldPkg.getArchives()[0]); - - // associate the File that will be "downloaded" for this archive - mArchInst.setDownloadResponse( - newPkg.getArchives()[0], createFile("/sdk", "tmp", "download1.zip")); - - assertTrue(mArchInst.install(ar, mSdkRoot, false /*forceHttp*/, mSdkMan, - null /*UrlCache*/, mMon)); - - // check what was created - assertEquals( - "[/sdk/extras/vendor1/newPath/source.properties]", - Arrays.toString(mFile.getExistingFiles())); - - // oldPath directory has been deleted, we only have newPath now. - // No sdk/temp dir was created since we didn't have to move the old package dir out - // of the way. - assertEquals( - "[/, /sdk, /sdk/extras, /sdk/extras/vendor1, /sdk/extras/vendor1/newPath]", - Arrays.toString(mFile.getExistingFolders())); - - assertEquals( - ( - "[</sdk/extras/vendor1/newPath/source.properties: " + - "'### Android Tool: Source of this archive.\n" + - "#...date...\n" + - "Extra.VendorDisplay=vendor1\n" + - "Pkg.Desc=desc\n" + - "Extra.OldPaths=oldPath\n" + - "Extra.Path=newPath\n" + - "Archive.Arch=ANY\n" + - "Pkg.DescUrl=url\n" + - "Extra.NameDisplay=Vendor1 NewPath\n" + - "Archive.Os=ANY\n" + - "Pkg.SourceUrl=http\\://repo.example.com/url\n" + - "Pkg.Revision=2\n" + - "Extra.VendorId=vendor1\n" + - "'>]"), - stripDate(Arrays.toString(mFile.getOutputStreams()))); - - assertEquals( - "Installing Vendor1 NewPath, revision 2\n" + - "Installed Vendor1 NewPath, revision 2\n", - mMon.getCapturedLog()); - } - - // ---- - - /** - * Helper creator method to create a {@link MockEmptyPackage} with no local - * archive associated. - */ - private static MockEmptyPackage createRemoteEmptyPackage(SdkSource source, String testHandle) { - return new MockEmptyPackage(source, testHandle, 0 /*revision*/) { - @Override - protected Archive[] initializeArchives( - Properties props, - Os archiveOs, - Arch archiveArch, - String archiveOsPath) { - // Create one remote archive for this package - return new Archive[] { - new Archive( - this, - Os.ANY, - Arch.ANY, - "http://some.source/some_url", - 1234, // size - "abcdef") // sha1 - }; - } - }; - } - - /** - * Helper creator method to create a {@link MockExtraPackage} with no local - * archive associated. - */ - private static MockExtraPackage createRemoteExtraPackage( - SdkSource source, - String vendor, - String path, - int revision, - int min_platform_tools_rev) { - return new MockExtraPackage(source, vendor, path, revision, min_platform_tools_rev) { - @Override - protected Archive[] initializeArchives( - Properties props, - Os archiveOs, - Arch archiveArch, - String archiveOsPath) { - // Create one remote archive for this package - return new Archive[] { - new Archive( - this, - Os.ANY, - Arch.ANY, - "http://some.source/some_url", - 1234, // size - "abcdef") // sha1 - }; - } - }; - } - - /** - * Helper creator method to create a {@link MockExtraPackage} with no local - * archive associated and a specific oldPaths attribute. - */ - private static MockExtraPackage createRemoteExtraPackage( - SdkSource source, - String vendor, - String newPath, - String oldPaths, - int revision, - int min_platform_tools_rev) { - Properties props = new Properties(); - props.setProperty(PkgProps.EXTRA_OLD_PATHS, oldPaths); - props.setProperty(PkgProps.MIN_PLATFORM_TOOLS_REV, - Integer.toString((min_platform_tools_rev))); - return new MockExtraPackage(source, props, vendor, newPath, revision) { - @Override - protected Archive[] initializeArchives( - Properties props2, - Os archiveOs, - Arch archiveArch, - String archiveOsPath) { - // Create one remote archive for this package - return new Archive[] { - new Archive( - this, - Os.ANY, - Arch.ANY, - "http://some.source/some_url", - 1234, // size - "abcdef") // sha1 - }; - } - }; - } - - private File createFile(String...segments) { - File f = null; - for (String segment : segments) { - if (f == null) { - f = new File(segment); - } else { - f = new File(f, segment); - } - } - - return f; - } - - /** - * Strips the second line of the string. - * The source.properties generated by Java contain the generation data on the - * second line and this is of course not suitable for unit tests. - */ - private String stripDate(String string) { - // We know it's a date if it looks like: - // \n # ... YYYY\n - Pattern p = Pattern.compile("\n#[^#][^\n]*[0-9]{4}\\w*\n", Pattern.DOTALL); - string = p.matcher(string.replaceAll("\r\n", "\n")).replaceAll("\n#...date...\n"); - return string; - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/archives/ArchiveTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/archives/ArchiveTest.java deleted file mode 100755 index c0ae718..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/archives/ArchiveTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.archives; - -import com.android.sdklib.internal.repository.archives.Archive; -import com.android.sdklib.internal.repository.archives.Archive.Arch; -import com.android.sdklib.internal.repository.archives.Archive.Os; - -import junit.framework.TestCase; - -public class ArchiveTest extends TestCase { - - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - public void testShortDescription() throws Exception { - Archive a = new Archive( - null, //pkg, - Os.WINDOWS, //os - Arch.ANY, //arch, - null, //url - 0, //size - null); //checksum - assertEquals("Archive for Windows", a.getShortDescription()); - - a = new Archive( - null, //pkg, - Os.LINUX, //os - Arch.ANY, //arch, - null, //url - 0, //size - null); //checksum - assertEquals("Archive for Linux", a.getShortDescription()); - - a = new Archive( - null, //pkg, - Os.MACOSX, //os - Arch.ANY, //arch, - null, //url - 0, //size - null); //checksum - assertEquals("Archive for MacOS X", a.getShortDescription()); - - a = new Archive( - null, //pkg, - Os.ANY, //os - Arch.ANY, //arch, - null, //url - 0, //size - null); //checksum - assertEquals("Archive for any OS", a.getShortDescription()); - } - - public void testLongDescription() throws Exception { - Archive a = new Archive( - null, //pkg, - Os.WINDOWS, //os - Arch.ANY, //arch, - null, //url - 900, //size - "1234567890ABCDEF"); //checksum - assertEquals( - "Archive for Windows\n" + - "Size: 900 Bytes\n" + - "SHA1: 1234567890ABCDEF", - a.getLongDescription()); - - a = new Archive(null, Os.WINDOWS, Arch.ANY, null, 1100, "1234567890ABCDEF"); - assertEquals( - "Archive for Windows\n" + - "Size: 1 KiB\n" + - "SHA1: 1234567890ABCDEF", - a.getLongDescription()); - - a = new Archive(null, Os.WINDOWS, Arch.ANY, null, 1900, "1234567890ABCDEF"); - assertEquals( - "Archive for Windows\n" + - "Size: 2 KiB\n" + - "SHA1: 1234567890ABCDEF", - a.getLongDescription()); - - a = new Archive(null, Os.WINDOWS, Arch.ANY, null, (long)2e6, "1234567890ABCDEF"); - assertEquals( - "Archive for Windows\n" + - "Size: 1.9 MiB\n" + - "SHA1: 1234567890ABCDEF", - a.getLongDescription()); - - a = new Archive(null, Os.WINDOWS, Arch.ANY, null, (long)19e6, "1234567890ABCDEF"); - assertEquals( - "Archive for Windows\n" + - "Size: 18.1 MiB\n" + - "SHA1: 1234567890ABCDEF", - a.getLongDescription()); - - a = new Archive(null, Os.WINDOWS, Arch.ANY, null, (long)18e9, "1234567890ABCDEF"); - assertEquals( - "Archive for Windows\n" + - "Size: 16.8 GiB\n" + - "SHA1: 1234567890ABCDEF", - a.getLongDescription()); - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/BrokenPackageTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/BrokenPackageTest.java deleted file mode 100755 index 92a04c4..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/BrokenPackageTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import com.android.sdklib.internal.repository.packages.BrokenPackage; - -import junit.framework.TestCase; - -public class BrokenPackageTest extends TestCase { - - private BrokenPackage m; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - m = new BrokenPackage(null /*props*/, - "short description", - "long description", - 12, // min api level - 13, // exact api level - "os/path"); - - } - - public final void testGetShortDescription() { - assertEquals("short description", m.getShortDescription()); - } - - public final void testGetLongDescription() { - assertEquals("long description", m.getLongDescription()); - } - - public final void testGetMinApiLevel() { - assertEquals(12, m.getMinApiLevel()); - } - - public final void testGetExactApiLevel() { - assertEquals(13, m.getExactApiLevel()); - } - - public void testInstallId() { - assertEquals("", m.installId()); - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/ExtraPackageTest_v3.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/ExtraPackageTest_v3.java deleted file mode 100755 index 6102f13..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/ExtraPackageTest_v3.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import com.android.sdklib.internal.repository.archives.Archive.Arch; -import com.android.sdklib.internal.repository.archives.Archive.Os; -import com.android.sdklib.internal.repository.packages.ExtraPackage; -import com.android.sdklib.repository.PkgProps; - -import java.io.File; -import java.util.Arrays; -import java.util.Properties; - -/** - * Tests {@link ExtraPackage} using anddon-3.xsd: it has a {@code <path>} and {@code <vendor>}. - * (it lacks name-display, vendor-id and vendor-display with are in addon-4.xsd) - */ -public class ExtraPackageTest_v3 extends MinToolsPackageTest { - - private static final char PS = File.pathSeparatorChar; - - private ExtraPackage createExtraPackage(Properties props) { - ExtraPackage p = (ExtraPackage) ExtraPackage.create( - null, //source - props, - null, //vendor - null, //path - -1, //revision - null, //license - null, //description - null, //descUrl - Os.ANY, //archiveOs - Arch.ANY, //archiveArch - "/local/archive/path" //archiveOsPath - ); - return p; - } - - /** Properties used to "load" the package. When saved, they become different. */ - private Properties createLoadedProps() { - Properties props = super.createProps(); - - // ExtraPackage properties - props.setProperty(PkgProps.EXTRA_VENDOR, "vendor"); - props.setProperty(PkgProps.EXTRA_PATH, "the_path"); - props.setProperty(PkgProps.EXTRA_OLD_PATHS, "old_path1;oldpath2"); - props.setProperty(PkgProps.EXTRA_MIN_API_LEVEL, "11"); - props.setProperty(PkgProps.EXTRA_PROJECT_FILES, - "path1.jar" + PS + "dir2/jar 2.jar" + PS + "dir/3/path"); - - return props; - } - - /** Properties saved by the package. They differ from loaded ones in name and vendor. */ - private Properties createSavedProps() { - Properties props = super.createProps(); - - // ExtraPackage properties - props.setProperty(PkgProps.EXTRA_VENDOR_ID, "vendor"); - props.setProperty(PkgProps.EXTRA_VENDOR_DISPLAY, "vendor"); - props.setProperty(PkgProps.EXTRA_NAME_DISPLAY, "Vendor The Path"); - props.setProperty(PkgProps.EXTRA_PATH, "the_path"); - props.setProperty(PkgProps.EXTRA_OLD_PATHS, "old_path1;oldpath2"); - props.setProperty(PkgProps.EXTRA_MIN_API_LEVEL, "11"); - props.setProperty(PkgProps.EXTRA_PROJECT_FILES, - "path1.jar" + PS + "dir2/jar 2.jar" + PS + "dir/3/path"); - - return props; - } - - protected void testCreatedExtraPackage(ExtraPackage p) { - super.testCreatedPackage(p); - - // Package properties - // vendor becomes both vendor-id and vendor-display - assertEquals("vendor", p.getVendorId()); - assertEquals("vendor", p.getVendorDisplay()); - assertEquals("the_path", p.getPath()); - // path and vendor are combined in the default display name - assertEquals("Vendor The Path", p.getDisplayName()); - assertEquals("[old_path1, oldpath2]", Arrays.toString(p.getOldPaths())); - assertEquals(11, p.getMinApiLevel()); - assertEquals( - "[path1.jar, dir2/jar 2.jar, dir/3/path]", - Arrays.toString(p.getProjectFiles())); - } - - // ---- - - @Override - public final void testCreate() { - Properties props = createLoadedProps(); - ExtraPackage p = createExtraPackage(props); - - testCreatedExtraPackage(p); - } - - @Override - public void testSaveProperties() { - Properties props = createLoadedProps(); - ExtraPackage p = createExtraPackage(props); - - Properties props2 = new Properties(); - p.saveProperties(props2); - - assertEquals(props2, createSavedProps()); - } - - public void testSameItemAs() { - Properties props1 = createLoadedProps(); - ExtraPackage p1 = createExtraPackage(props1); - assertTrue(p1.sameItemAs(p1)); - - // different vendor, same path - Properties props2 = new Properties(props1); - props2.setProperty(PkgProps.EXTRA_VENDOR, "vendor2"); - ExtraPackage p2 = createExtraPackage(props2); - assertFalse(p1.sameItemAs(p2)); - assertFalse(p2.sameItemAs(p1)); - - // different vendor, different path - props2.setProperty(PkgProps.EXTRA_PATH, "new_path2"); - p2 = createExtraPackage(props2); - assertFalse(p1.sameItemAs(p2)); - assertFalse(p2.sameItemAs(p1)); - - // same vendor, but single path using the old paths from p1 - Properties props3 = new Properties(props1); - props3.setProperty(PkgProps.EXTRA_OLD_PATHS, ""); - props3.setProperty(PkgProps.EXTRA_PATH, "old_path1"); - ExtraPackage p3 = createExtraPackage(props3); - assertTrue(p1.sameItemAs(p3)); - assertTrue(p3.sameItemAs(p1)); - - props3.setProperty(PkgProps.EXTRA_PATH, "oldpath2"); - p3 = createExtraPackage(props3); - assertTrue(p1.sameItemAs(p3)); - assertTrue(p3.sameItemAs(p1)); - - // same vendor, different old paths but there's a path=>old_path match - Properties props4 = new Properties(props1); - props4.setProperty(PkgProps.EXTRA_OLD_PATHS, "new_path4;new_path5"); - props4.setProperty(PkgProps.EXTRA_PATH, "old_path1"); - ExtraPackage p4 = createExtraPackage(props4); - assertTrue(p1.sameItemAs(p4)); - assertTrue(p4.sameItemAs(p1)); - - // same vendor, incompatible paths - Properties props5 = new Properties(props1); - // and the only match is between old_paths, which doesn't count. - props5.setProperty(PkgProps.EXTRA_OLD_PATHS, "old_path1;new_path5"); - props5.setProperty(PkgProps.EXTRA_PATH, "new_path4"); - ExtraPackage p5 = createExtraPackage(props5); - assertFalse(p1.sameItemAs(p5)); - assertFalse(p5.sameItemAs(p1)); - } - - public void testInstallId() { - Properties props = createLoadedProps(); - ExtraPackage p = createExtraPackage(props); - - assertEquals("extra-vendor-the_path", p.installId()); - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/ExtraPackageTest_v4.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/ExtraPackageTest_v4.java deleted file mode 100755 index eff3020..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/ExtraPackageTest_v4.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import com.android.sdklib.internal.repository.archives.Archive.Arch; -import com.android.sdklib.internal.repository.archives.Archive.Os; -import com.android.sdklib.internal.repository.packages.ExtraPackage; -import com.android.sdklib.repository.PkgProps; - -import java.io.File; -import java.util.Arrays; -import java.util.Properties; - -/** - * Tests {@link ExtraPackage} using anddon-4.xsd: - * it has name-display, vendor-id and vendor-display. - */ -public class ExtraPackageTest_v4 extends MinToolsPackageTest { - - private static final char PS = File.pathSeparatorChar; - - private ExtraPackage createExtraPackage(Properties props) { - ExtraPackage p = (ExtraPackage) ExtraPackage.create( - null, //source - props, - null, //vendor - null, //path - -1, //revision - null, //license - null, //description - null, //descUrl - Os.ANY, //archiveOs - Arch.ANY, //archiveArch - "/local/archive/path" //archiveOsPath - ); - return p; - } - - @Override - protected Properties createProps() { - Properties props = super.createProps(); - - // ExtraPackage properties - props.setProperty(PkgProps.EXTRA_VENDOR_ID, "the_vendor"); - props.setProperty(PkgProps.EXTRA_VENDOR_DISPLAY, "The Company, Inc."); - props.setProperty(PkgProps.EXTRA_NAME_DISPLAY, "Some Extra Package"); - props.setProperty(PkgProps.EXTRA_PATH, "the_path"); - props.setProperty(PkgProps.EXTRA_OLD_PATHS, "old_path1;oldpath2"); - props.setProperty(PkgProps.EXTRA_MIN_API_LEVEL, "11"); - props.setProperty(PkgProps.EXTRA_PROJECT_FILES, - "path1.jar" + PS + "dir2/jar 2.jar" + PS + "dir/3/path"); - - return props; - } - - protected void testCreatedExtraPackage(ExtraPackage p) { - super.testCreatedPackage(p); - - // Package properties - assertEquals("the_vendor", p.getVendorId()); - assertEquals("The Company, Inc.", p.getVendorDisplay()); - assertEquals("Some Extra Package", p.getDisplayName()); - assertEquals("the_path", p.getPath()); - assertEquals("[old_path1, oldpath2]", Arrays.toString(p.getOldPaths())); - assertEquals(11, p.getMinApiLevel()); - assertEquals( - "[path1.jar, dir2/jar 2.jar, dir/3/path]", - Arrays.toString(p.getProjectFiles())); - } - - // ---- - - @Override - public final void testCreate() { - Properties props = createProps(); - ExtraPackage p = createExtraPackage(props); - - testCreatedExtraPackage(p); - } - - @Override - public void testSaveProperties() { - Properties props = createProps(); - ExtraPackage p = createExtraPackage(props); - - Properties props2 = new Properties(); - p.saveProperties(props2); - - assertEquals(props2, props); - } - - public void testSameItemAs() { - Properties props1 = createProps(); - ExtraPackage p1 = createExtraPackage(props1); - assertTrue(p1.sameItemAs(p1)); - - // different vendor, same path - Properties props2 = new Properties(props1); - props2.setProperty(PkgProps.EXTRA_VENDOR_ID, "vendor2"); - props2.setProperty(PkgProps.EXTRA_VENDOR_DISPLAY, "Another Vendor Name"); - ExtraPackage p2 = createExtraPackage(props2); - assertFalse(p1.sameItemAs(p2)); - assertFalse(p2.sameItemAs(p1)); - - // different vendor, different path - props2.setProperty(PkgProps.EXTRA_PATH, "new_path2"); - p2 = createExtraPackage(props2); - assertFalse(p1.sameItemAs(p2)); - assertFalse(p2.sameItemAs(p1)); - - // same vendor, but single path using the old paths from p1 - Properties props3 = new Properties(props1); - props3.setProperty(PkgProps.EXTRA_OLD_PATHS, ""); - props3.setProperty(PkgProps.EXTRA_PATH, "old_path1"); - ExtraPackage p3 = createExtraPackage(props3); - assertTrue(p1.sameItemAs(p3)); - assertTrue(p3.sameItemAs(p1)); - - props3.setProperty(PkgProps.EXTRA_PATH, "oldpath2"); - p3 = createExtraPackage(props3); - assertTrue(p1.sameItemAs(p3)); - assertTrue(p3.sameItemAs(p1)); - - // same vendor, different old paths but there's a path=>old_path match - Properties props4 = new Properties(props1); - props4.setProperty(PkgProps.EXTRA_OLD_PATHS, "new_path4;new_path5"); - props4.setProperty(PkgProps.EXTRA_PATH, "old_path1"); - ExtraPackage p4 = createExtraPackage(props4); - assertTrue(p1.sameItemAs(p4)); - assertTrue(p4.sameItemAs(p1)); - - // same vendor, incompatible paths - Properties props5 = new Properties(props1); - // and the only match is between old_paths, which doesn't count. - props5.setProperty(PkgProps.EXTRA_OLD_PATHS, "old_path1;new_path5"); - props5.setProperty(PkgProps.EXTRA_PATH, "new_path4"); - ExtraPackage p5 = createExtraPackage(props5); - assertFalse(p1.sameItemAs(p5)); - assertFalse(p5.sameItemAs(p1)); - } - - public void testInstallId() { - Properties props = createProps(); - ExtraPackage p = createExtraPackage(props); - - assertEquals("extra-the_vendor-the_path", p.installId()); - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/FullRevisionPackageTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/FullRevisionPackageTest.java deleted file mode 100755 index 9bf2703..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/FullRevisionPackageTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import com.android.sdklib.repository.PkgProps; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Properties; - -import junit.framework.TestCase; - -public class FullRevisionPackageTest extends TestCase { - - /** - * Helper that creates the {@link Properties} from a {@link FullRevision} - * as expected by {@link FullRevisionPackage}. - */ - public static Properties createProps(FullRevision revision) { - Properties props = new Properties(); - if (revision != null) { - props.setProperty(PkgProps.PKG_REVISION, revision.toString()); - } - return props; - } - - public void testCompareTo() throws Exception { - // Test order of full revision packages. - // - // Note that Package.compareTo() is designed to return the desired - // ordering for a list display and as such a final/release package - // needs to be listed before its rc/preview package. - // - // This differs from the order used by FullRevision.compareTo(). - - ArrayList<Package> list = new ArrayList<Package>(); - - list.add(new MockToolPackage(null, new FullRevision(1, 0, 0, 0), 8)); - list.add(new MockToolPackage(null, new FullRevision(1, 0, 0, 1), 8)); - list.add(new MockToolPackage(null, new FullRevision(1, 0, 1, 0), 8)); - list.add(new MockToolPackage(null, new FullRevision(1, 0, 1, 1), 8)); - list.add(new MockToolPackage(null, new FullRevision(1, 1, 0, 0), 8)); - list.add(new MockToolPackage(null, new FullRevision(1, 1, 0, 1), 8)); - list.add(new MockToolPackage(null, new FullRevision(2, 1, 1, 0), 8)); - list.add(new MockToolPackage(null, new FullRevision(2, 1, 1, 1), 8)); - - Collections.sort(list); - - assertEquals( - "[Android SDK Tools, revision 1, " + - "Android SDK Tools, revision 1 rc1, " + - "Android SDK Tools, revision 1.0.1, " + - "Android SDK Tools, revision 1.0.1 rc1, " + - "Android SDK Tools, revision 1.1, " + - "Android SDK Tools, revision 1.1 rc1, " + - "Android SDK Tools, revision 2.1.1, " + - "Android SDK Tools, revision 2.1.1 rc1]", - Arrays.toString(list.toArray())); - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/FullRevisionTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/FullRevisionTest.java deleted file mode 100755 index d072d05..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/FullRevisionTest.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import junit.framework.TestCase; - -public class FullRevisionTest extends TestCase { - - public final void testFullRevision() { - FullRevision p = new FullRevision(5); - assertEquals(5, p.getMajor()); - assertEquals(FullRevision.IMPLICIT_MINOR_REV, p.getMinor()); - assertEquals(FullRevision.IMPLICIT_MICRO_REV, p.getMicro()); - assertEquals(FullRevision.NOT_A_PREVIEW, p.getPreview()); - assertFalse (p.isPreview()); - assertEquals("5", p.toShortString()); - assertEquals(p, FullRevision.parseRevision("5")); - assertEquals("5.0.0", p.toString()); - assertEquals(p, FullRevision.parseRevision("5.0.0")); - - p = new FullRevision(5, 0, 0, 6); - assertEquals(5, p.getMajor()); - assertEquals(FullRevision.IMPLICIT_MINOR_REV, p.getMinor()); - assertEquals(FullRevision.IMPLICIT_MICRO_REV, p.getMicro()); - assertEquals(6, p.getPreview()); - assertTrue (p.isPreview()); - assertEquals("5 rc6", p.toShortString()); - assertEquals(p, FullRevision.parseRevision("5 rc6")); - assertEquals("5.0.0 rc6", p.toString()); - assertEquals(p, FullRevision.parseRevision("5.0.0 rc6")); - - p = new FullRevision(6, 7, 0); - assertEquals(6, p.getMajor()); - assertEquals(7, p.getMinor()); - assertEquals(0, p.getMicro()); - assertEquals(0, p.getPreview()); - assertFalse (p.isPreview()); - assertEquals("6.7", p.toShortString()); - assertEquals(p, FullRevision.parseRevision("6.7")); - assertEquals("6.7.0", p.toString()); - assertEquals(p, FullRevision.parseRevision("6.7.0")); - - p = new FullRevision(10, 11, 12, FullRevision.NOT_A_PREVIEW); - assertEquals(10, p.getMajor()); - assertEquals(11, p.getMinor()); - assertEquals(12, p.getMicro()); - assertEquals(0, p.getPreview()); - assertFalse (p.isPreview()); - assertEquals("10.11.12", p.toShortString()); - assertEquals("10.11.12", p.toString()); - assertEquals(p, FullRevision.parseRevision("10.11.12")); - - p = new FullRevision(10, 11, 12, 13); - assertEquals(10, p.getMajor()); - assertEquals(11, p.getMinor()); - assertEquals(12, p.getMicro()); - assertEquals(13, p.getPreview()); - assertTrue (p.isPreview()); - assertEquals("10.11.12 rc13", p.toShortString()); - assertEquals("10.11.12 rc13", p.toString()); - assertEquals(p, FullRevision.parseRevision("10.11.12 rc13")); - assertEquals(p, FullRevision.parseRevision(" 10.11.12 rc13")); - assertEquals(p, FullRevision.parseRevision("10.11.12 rc13 ")); - assertEquals(p, FullRevision.parseRevision(" 10.11.12 rc13 ")); - } - - public final void testParseError() { - String errorMsg = null; - try { - FullRevision.parseRevision("not a number"); - fail("FullRevision.parseRevision should thrown NumberFormatException"); - } catch (NumberFormatException e) { - errorMsg = e.getMessage(); - } - assertEquals("Invalid full revision: not a number", errorMsg); - - errorMsg = null; - try { - FullRevision.parseRevision("5 .6 .7"); - fail("FullRevision.parseRevision should thrown NumberFormatException"); - } catch (NumberFormatException e) { - errorMsg = e.getMessage(); - } - assertEquals("Invalid full revision: 5 .6 .7", errorMsg); - - errorMsg = null; - try { - FullRevision.parseRevision("5.0.0 preview 1"); - fail("FullRevision.parseRevision should thrown NumberFormatException"); - } catch (NumberFormatException e) { - errorMsg = e.getMessage(); - } - assertEquals("Invalid full revision: 5.0.0 preview 1", errorMsg); - - errorMsg = null; - try { - FullRevision.parseRevision(" 5.1.2 rc 42 "); - fail("FullRevision.parseRevision should thrown NumberFormatException"); - } catch (NumberFormatException e) { - errorMsg = e.getMessage(); - } - assertEquals("Invalid full revision: 5.1.2 rc 42 ", errorMsg); - } - - public final void testCompareTo() { - FullRevision s4 = new FullRevision(4); - FullRevision i4 = new FullRevision(4); - FullRevision g5 = new FullRevision(5, 1, 0, 6); - FullRevision y5 = new FullRevision(5); - FullRevision c5 = new FullRevision(5, 1, 0, 6); - FullRevision o5 = new FullRevision(5, 0, 0, 7); - FullRevision p5 = new FullRevision(5, 1, 0, 0); - - assertEquals(s4, i4); // 4.0.0-0 == 4.0.0-0 - assertEquals(g5, c5); // 5.1.0-6 == 5.1.0-6 - - assertFalse(y5.equals(p5)); // 5.0.0-0 != 5.1.0-0 - assertFalse(g5.equals(p5)); // 5.1.0-6 != 5.1.0-0 - assertTrue (s4.compareTo(i4) == 0); // 4.0.0-0 == 4.0.0-0 - assertTrue (s4.compareTo(y5) < 0); // 4.0.0-0 < 5.0.0-0 - assertTrue (y5.compareTo(y5) == 0); // 5.0.0-0 == 5.0.0-0 - assertTrue (y5.compareTo(p5) < 0); // 5.0.0-0 < 5.1.0-0 - assertTrue (o5.compareTo(y5) < 0); // 5.0.0-7 < 5.0.0-0 - assertTrue (p5.compareTo(p5) == 0); // 5.1.0-0 == 5.1.0-0 - assertTrue (c5.compareTo(p5) < 0); // 5.1.0-6 < 5.1.0-0 - assertTrue (p5.compareTo(c5) > 0); // 5.1.0-0 > 5.1.0-6 - assertTrue (p5.compareTo(o5) > 0); // 5.1.0-0 > 5.0.0-7 - assertTrue (c5.compareTo(o5) > 0); // 5.1.0-6 > 5.0.0-7 - assertTrue (o5.compareTo(o5) == 0); // 5.0.0-7 > 5.0.0-7 - } - -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MajorRevisionTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MajorRevisionTest.java deleted file mode 100755 index b77caad..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MajorRevisionTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import junit.framework.TestCase; - -public class MajorRevisionTest extends TestCase { - - public final void testMajorRevision() { - MajorRevision p = new MajorRevision(5); - assertEquals(5, p.getMajor()); - assertEquals(FullRevision.IMPLICIT_MINOR_REV, p.getMinor()); - assertEquals(FullRevision.IMPLICIT_MICRO_REV, p.getMicro()); - assertEquals(FullRevision.NOT_A_PREVIEW, p.getPreview()); - assertFalse (p.isPreview()); - assertEquals("5", p.toShortString()); - assertEquals(p, MajorRevision.parseRevision("5")); - assertEquals("5", p.toString()); - - assertEquals(new FullRevision(5, 0, 0, 0), p); - } - - public final void testParseError() { - String errorMsg = null; - try { - MajorRevision.parseRevision("5.0.0"); - fail("MajorRevision.parseRevision should thrown NumberFormatException"); - } catch (NumberFormatException e) { - errorMsg = e.getMessage(); - } - assertEquals("For input string: \"5.0.0\"", errorMsg); - } - - public final void testCompareTo() { - MajorRevision s4 = new MajorRevision(4); - MajorRevision i4 = new MajorRevision(4); - FullRevision g5 = new FullRevision (5, 1, 0, 6); - MajorRevision y5 = new MajorRevision(5); - FullRevision c5 = new FullRevision (5, 1, 0, 6); - FullRevision o5 = new FullRevision (5, 0, 0, 7); - FullRevision p5 = new FullRevision (5, 1, 0, 0); - - assertEquals(s4, i4); // 4.0.0-0 == 4.0.0-0 - assertEquals(g5, c5); // 5.1.0-6 == 5.1.0-6 - - assertFalse(y5.equals(p5)); // 5.0.0-0 != 5.1.0-0 - assertFalse(g5.equals(p5)); // 5.1.0-6 != 5.1.0-0 - assertTrue (s4.compareTo(i4) == 0); // 4.0.0-0 == 4.0.0-0 - assertTrue (s4.compareTo(y5) < 0); // 4.0.0-0 < 5.0.0-0 - assertTrue (y5.compareTo(y5) == 0); // 5.0.0-0 == 5.0.0-0 - assertTrue (y5.compareTo(p5) < 0); // 5.0.0-0 < 5.1.0-0 - assertTrue (o5.compareTo(y5) < 0); // 5.0.0-7 < 5.0.0-0 - assertTrue (p5.compareTo(p5) == 0); // 5.1.0-0 == 5.1.0-0 - assertTrue (c5.compareTo(p5) < 0); // 5.1.0-6 < 5.1.0-0 - assertTrue (p5.compareTo(c5) > 0); // 5.1.0-0 > 5.1.0-6 - assertTrue (p5.compareTo(o5) > 0); // 5.1.0-0 > 5.0.0-7 - assertTrue (c5.compareTo(o5) > 0); // 5.1.0-6 > 5.0.0-7 - assertTrue (o5.compareTo(o5) == 0); // 5.0.0-7 > 5.0.0-7 - } - -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MinToolsPackageTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MinToolsPackageTest.java deleted file mode 100755 index adffe2e..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MinToolsPackageTest.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import com.android.sdklib.SdkManager; -import com.android.sdklib.internal.repository.archives.Archive.Arch; -import com.android.sdklib.internal.repository.archives.Archive.Os; -import com.android.sdklib.internal.repository.packages.MinToolsPackage; -import com.android.sdklib.internal.repository.packages.Package; -import com.android.sdklib.internal.repository.sources.SdkSource; -import com.android.sdklib.repository.PkgProps; - -import java.io.File; -import java.util.Properties; - -public class MinToolsPackageTest extends PackageTest { - - /** Local class used to test the abstract MinToolsPackage class */ - protected static class MockMinToolsPackage extends MinToolsPackage { - public MockMinToolsPackage( - SdkSource source, - Properties props, - int revision, - String license, - String description, - String descUrl, - Os archiveOs, - Arch archiveArch, - String archiveOsPath) { - super(source, - props, - revision, - license, - description, - descUrl, - archiveOs, - archiveArch, - archiveOsPath); - } - - @Override - public File getInstallFolder(String osSdkRoot, SdkManager sdkManager) { - throw new UnsupportedOperationException("abstract method not used in test"); //$NON-NLS-1$ - } - - @Override - public String getListDescription() { - throw new UnsupportedOperationException("abstract method not used in test"); //$NON-NLS-1$ - } - - @Override - public String getShortDescription() { - throw new UnsupportedOperationException("abstract method not used in test"); //$NON-NLS-1$ - } - - @Override - public boolean sameItemAs(Package pkg) { - throw new UnsupportedOperationException("abstract method not used in test"); //$NON-NLS-1$ - } - - @Override - public String installId() { - return ""; //$NON-NLS-1$ - } - } - - @Override - public void testCreate() { - Properties props = createProps(); - - MockMinToolsPackage p = new MockMinToolsPackage( - null, //source - props, - -1, //revision - null, //license - null, //description - null, //descUrl - Os.ANY, //archiveOs - Arch.ANY, //archiveArch - LOCAL_ARCHIVE_PATH - ); - - testCreatedPackage(p); - } - - @Override - public void testSaveProperties() { - Properties props = createProps(); - - MockMinToolsPackage p = new MockMinToolsPackage( - null, //source - props, - -1, //revision - null, //license - null, //description - null, //descUrl - Os.ANY, //archiveOs - Arch.ANY, //archiveArch - LOCAL_ARCHIVE_PATH - ); - - Properties props2 = new Properties(); - p.saveProperties(props2); - - assertEquals(props2, props); - } - - @Override - protected Properties createProps() { - Properties props = super.createProps(); - - // MinToolsPackage properties - props.setProperty(PkgProps.MIN_TOOLS_REV, "3.0.1"); - - return props; - } - - protected void testCreatedMinToolsPackage(MockMinToolsPackage p) { - super.testCreatedPackage(p); - - // MinToolsPackage properties - assertEquals("3.0.1", p.getMinToolsRevision().toShortString()); - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockAddonPackage.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockAddonPackage.java deleted file mode 100755 index 7a52e7d..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockAddonPackage.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import com.android.SdkConstants; -import com.android.sdklib.AndroidVersion; -import com.android.sdklib.IAndroidTarget; -import com.android.sdklib.ISystemImage; -import com.android.sdklib.ISystemImage.LocationType; -import com.android.sdklib.SystemImage; -import com.android.sdklib.internal.repository.sources.SdkSource; -import com.android.sdklib.io.FileOp; -import com.android.sdklib.repository.PkgProps; - -import java.util.Map; -import java.util.Properties; - -/** - * A mock {@link AddonPackage} for testing. - * - * By design, this package contains one and only one archive. - */ -public class MockAddonPackage extends AddonPackage { - - /** - * Creates a {@link MockAddonTarget} with the requested base platform and addon revision - * and then a {@link MockAddonPackage} wrapping it and a default name of "addon". - * - * By design, this package contains one and only one archive. - */ - public MockAddonPackage(MockPlatformPackage basePlatform, int revision) { - this("addon", basePlatform, revision); //$NON-NLS-1$ - } - - /** - * Creates a {@link MockAddonTarget} with the requested base platform and addon revision - * and then a {@link MockAddonPackage} wrapping it. - * - * By design, this package contains one and only one archive. - */ - public MockAddonPackage(String name, MockPlatformPackage basePlatform, int revision) { - super(new MockAddonTarget(name, basePlatform.getTarget(), revision), null /*props*/); - } - - public MockAddonPackage( - SdkSource source, - String name, - MockPlatformPackage basePlatform, - int revision) { - super(source, - new MockAddonTarget(name, basePlatform.getTarget(), revision), - createProperties(name, basePlatform.getTarget())); - } - - private static Properties createProperties(String name, IAndroidTarget baseTarget) { - String vendor = baseTarget.getVendor(); - Properties props = new Properties(); - props.setProperty(PkgProps.ADDON_NAME_ID, name); - props.setProperty(PkgProps.ADDON_NAME_DISPLAY, - String.format("The %1$s from %2$s", //$NON-NLS-1$ - name, vendor)); - props.setProperty(PkgProps.ADDON_VENDOR_ID, - String.format("vendor-id-%1$s", vendor)); //$NON-NLS-1$ - props.setProperty(PkgProps.ADDON_VENDOR_DISPLAY, - String.format("The %1$s", vendor)); //$NON-NLS-1$ - return props; - } - - /** - * A mock AddonTarget. - * This reimplements the minimum needed from the interface for our limited testing needs. - */ - static class MockAddonTarget implements IAndroidTarget { - - private final IAndroidTarget mParentTarget; - private final int mRevision; - private final String mName; - private ISystemImage[] mSystemImages; - - public MockAddonTarget(String name, IAndroidTarget parentTarget, int revision) { - mName = name; - mParentTarget = parentTarget; - mRevision = revision; - } - - @Override - public String getClasspathName() { - return getName(); - } - - @Override - public String getShortClasspathName() { - return getName(); - } - - @Override - public String getDefaultSkin() { - return null; - } - - @Override - public String getDescription() { - return getName(); - } - - @Override - public String getFullName() { - return getName(); - } - - @Override - public ISystemImage[] getSystemImages() { - if (mSystemImages == null) { - SystemImage si = new SystemImage( - FileOp.append(getLocation(), SdkConstants.OS_IMAGES_FOLDER), - LocationType.IN_PLATFORM_LEGACY, - SdkConstants.ABI_ARMEABI); - mSystemImages = new SystemImage[] { si }; - } - return mSystemImages; - } - - @Override - public ISystemImage getSystemImage(String abiType) { - if (SdkConstants.ABI_ARMEABI.equals(abiType)) { - return getSystemImages()[0]; - } - return null; - } - - @Override - public String getLocation() { - return "/sdk/add-ons/addon-" + mName; - } - - @Override - public IOptionalLibrary[] getOptionalLibraries() { - return null; - } - - @Override - public IAndroidTarget getParent() { - return mParentTarget; - } - - @Override - public String getPath(int pathId) { - throw new UnsupportedOperationException("Implement this as needed for tests"); - } - - @Override - public String[] getPlatformLibraries() { - return null; - } - - @Override - public String getProperty(String name) { - return null; - } - - @Override - public Integer getProperty(String name, Integer defaultValue) { - return defaultValue; - } - - @Override - public Boolean getProperty(String name, Boolean defaultValue) { - return defaultValue; - } - - @Override - public Map<String, String> getProperties() { - return null; - } - - @Override - public int getRevision() { - return mRevision; - } - - @Override - public String[] getSkins() { - return null; - } - - @Override - public int getUsbVendorId() { - return 0; - } - - @Override - public AndroidVersion getVersion() { - return mParentTarget.getVersion(); - } - - @Override - public String getName() { - return mName; - } - - @Override - public String getVendor() { - return mParentTarget.getVendor(); - } - - @Override - public String getVersionName() { - return String.format("mock-addon-%1$d", getVersion().getApiLevel()); - } - - @Override - public String hashString() { - return getVersionName(); - } - - /** Returns false for an addon. */ - @Override - public boolean isPlatform() { - return false; - } - - @Override - public boolean canRunOn(IAndroidTarget target) { - throw new UnsupportedOperationException("Implement this as needed for tests"); - } - - @Override - public int compareTo(IAndroidTarget o) { - throw new UnsupportedOperationException("Implement this as needed for tests"); - } - - @Override - public boolean hasRenderingLibrary() { - return false; - } - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockBrokenPackage.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockBrokenPackage.java deleted file mode 100755 index e78e796..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockBrokenPackage.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import com.android.sdklib.internal.repository.packages.BrokenPackage; - - -/** - * A mock {@link BrokenPackage} for testing. - * <p/> - * By design, this package contains one and only one archive. - */ -public class MockBrokenPackage extends BrokenPackage { - - public MockBrokenPackage(int minApiLevel, int exactApiLevel) { - this(createDesription(minApiLevel, exactApiLevel), // short description - createDesription(minApiLevel, exactApiLevel), // long description - minApiLevel, - exactApiLevel); - } - - private static String createDesription(int minApiLevel, int exactApiLevel) { - String s = "Broken package"; - s += exactApiLevel == BrokenPackage.API_LEVEL_INVALID ? " (No API level)" : - String.format(" for API %d", exactApiLevel); - s += minApiLevel == BrokenPackage.MIN_API_LEVEL_NOT_SPECIFIED ? "" : - String.format(", min API %d", minApiLevel); - return s; - } - - public MockBrokenPackage( - String shortDescription, - String longDescription, - int minApiLevel, - int exactApiLevel) { - super(null /*props*/, - shortDescription, - longDescription, - minApiLevel, - exactApiLevel, - "/sdk/broken/package" /*osPath*/); - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockEmptyPackage.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockEmptyPackage.java deleted file mode 100755 index 70f57b4..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockEmptyPackage.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import com.android.sdklib.SdkManager; -import com.android.sdklib.internal.repository.archives.Archive; -import com.android.sdklib.internal.repository.archives.Archive.Arch; -import com.android.sdklib.internal.repository.archives.Archive.Os; -import com.android.sdklib.internal.repository.packages.Package; -import com.android.sdklib.internal.repository.sources.SdkSource; - -import java.io.File; -import java.util.Properties; - -/** - * A mock empty package, of no particular subpackage type. - * {@link #sameItemAs(Package)} will return true if these packages have the same handle. - */ -public class MockEmptyPackage extends MajorRevisionPackage { - private final String mTestHandle; - - /** - * Creates a new {@link MockEmptyPackage} with a local archive. - * - * @param testHandle The comparison handle for {@link #sameItemAs(Package)}. - */ - public MockEmptyPackage(String testHandle) { - super( - null /*source*/, - null /*props*/, - 0 /*revision*/, - null /*license*/, - null /*description*/, - null /*descUrl*/, - Os.ANY /*archiveOs*/, - Arch.ANY /*archiveArch*/, - "/sdk/tmp/empty_pkg" /*archiveOsPath*/ - ); - mTestHandle = testHandle; - } - - /** - * Creates a new {@link MockEmptyPackage} with a local archive. - * - * @param testHandle The comparison handle for {@link #sameItemAs(Package)}. - * @param revision The revision of the package, printed in the short description. - */ - public MockEmptyPackage(String testHandle, int revision) { - super( - null /*source*/, - null /*props*/, - revision, - null /*license*/, - null /*description*/, - null /*descUrl*/, - Os.ANY /*archiveOs*/, - Arch.ANY /*archiveArch*/, - "/sdk/tmp/empty_pkg" /*archiveOsPath*/ - ); - mTestHandle = testHandle; - } - - /** - * Creates a new {@link MockEmptyPackage} with a local archive. - * - * @param source The source associate with this package. - * @param testHandle The comparison handle for {@link #sameItemAs(Package)}. - * @param revision The revision of the package, printed in the short description. - */ - public MockEmptyPackage(SdkSource source, String testHandle, int revision) { - super( - source, - null /*props*/, - revision, - null /*license*/, - null /*description*/, - null /*descUrl*/, - Os.ANY /*archiveOs*/, - Arch.ANY /*archiveArch*/, - "/sdk/tmp/empty_pkg" /*archiveOsPath*/ - ); - mTestHandle = testHandle; - } - - @Override - protected Archive[] initializeArchives( - Properties props, - Os archiveOs, - Arch archiveArch, - String archiveOsPath) { - return new Archive[] { - new Archive(this, props, archiveOs, archiveArch, archiveOsPath) { - @Override - public String toString() { - return mTestHandle; - } - } }; - } - - public Archive getLocalArchive() { - return getArchives()[0]; - } - - @Override - public File getInstallFolder(String osSdkRoot, SdkManager sdkManager) { - return new File(new File(osSdkRoot, "mock"), mTestHandle); - } - - @Override - public String installId() { - return "mock-empty-" + mTestHandle; //$NON-NLS-1$ - } - - @Override - public String getListDescription() { - return this.getClass().getSimpleName(); - } - - @Override - public String getShortDescription() { - StringBuilder sb = new StringBuilder(this.getClass().getSimpleName()); - sb.append(" '").append(mTestHandle).append('\''); - if (getRevision().getMajor() > 0) { - sb.append(" rev=").append(getRevision()); - } - return sb.toString(); - } - - /** Returns true if these packages have the same handle. */ - @Override - public boolean sameItemAs(Package pkg) { - return (pkg instanceof MockEmptyPackage) && - mTestHandle.equals(((MockEmptyPackage) pkg).mTestHandle); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((mTestHandle == null) ? 0 : mTestHandle.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof MockEmptyPackage)) { - return false; - } - MockEmptyPackage other = (MockEmptyPackage) obj; - if (mTestHandle == null) { - if (other.mTestHandle != null) { - return false; - } - } else if (!mTestHandle.equals(other.mTestHandle)) { - return false; - } - return true; - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockExtraPackage.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockExtraPackage.java deleted file mode 100755 index ca5a6cf..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockExtraPackage.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import com.android.sdklib.internal.repository.archives.Archive.Arch; -import com.android.sdklib.internal.repository.archives.Archive.Os; -import com.android.sdklib.internal.repository.sources.SdkSource; -import com.android.sdklib.repository.PkgProps; - -import java.util.Properties; - -/** - * A mock {@link ExtraPackage} for testing. - * - * By design, this package contains one and only one archive. - */ -public class MockExtraPackage extends ExtraPackage { - - /** - * Creates a {@link MockExtraPackage} with the given revision and hardcoded defaults - * for everything else. - * <p/> - * By design, this creates a package with one and only one archive. - */ - public MockExtraPackage(String vendor, String path, int revision, int min_platform_tools_rev) { - this(null /*source*/, vendor, path, revision, min_platform_tools_rev); - } - - public MockExtraPackage( - SdkSource source, - Properties props, - String vendor, - String path, - int revision) { - super( - source, - props, // props, - vendor, - path, - revision, - null, // license, - "desc", // description, - "url", // descUrl, - Os.getCurrentOs(), // archiveOs, - Arch.getCurrentArch(), // archiveArch, - "foo" // archiveOsPath - ); - } - - public MockExtraPackage( - SdkSource source, - String vendor, - String path, - int revision, - int min_platform_tools_rev) { - this(source, createProps(min_platform_tools_rev), vendor, path, revision); - } - - private static Properties createProps(int min_platform_tools_rev) { - Properties props = new Properties(); - props.setProperty(PkgProps.MIN_PLATFORM_TOOLS_REV, - Integer.toString((min_platform_tools_rev))); - return props; - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockPlatformPackage.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockPlatformPackage.java deleted file mode 100755 index 1d70ba9..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockPlatformPackage.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import com.android.sdklib.IAndroidTarget; -import com.android.sdklib.internal.repository.MockPlatformTarget; -import com.android.sdklib.internal.repository.packages.PlatformPackage; -import com.android.sdklib.internal.repository.sources.SdkSource; -import com.android.sdklib.repository.PkgProps; - -import java.util.Properties; - -/** - * A mock {@link PlatformPackage} for testing. - * - * By design, this package contains one and only one archive. - */ -public class MockPlatformPackage extends PlatformPackage { - - private final IAndroidTarget mTarget; - - /** - * Creates a {@link MockPlatformTarget} with the requested API and revision - * and then a {@link MockPlatformPackage} wrapping it. - * - * By design, this package contains one and only one archive. - */ - public MockPlatformPackage(int apiLevel, int revision) { - this(null /*source*/, new MockPlatformTarget(apiLevel, revision), null /*props*/); - } - - /** - * Creates a {@link MockPlatformTarget} with the requested API and revision - * and then a {@link MockPlatformPackage} wrapping it. - * - * Also sets the min-tools-rev of the platform. - * - * By design, this package contains one and only one archive. - */ - public MockPlatformPackage(int apiLevel, int revision, int min_tools_rev) { - this(null /*source*/, - new MockPlatformTarget(apiLevel, revision), - createProps(min_tools_rev)); - } - - public MockPlatformPackage(SdkSource source, int apiLevel, int revision, int min_tools_rev) { - this(source, new MockPlatformTarget(apiLevel, revision), createProps(min_tools_rev)); - } - - /** A little trick to be able to capture the target new after passing it to the super. */ - private MockPlatformPackage(SdkSource source, IAndroidTarget target, Properties props) { - super(source, target, props); - mTarget = target; - } - - private static Properties createProps(int min_tools_rev) { - Properties props = new Properties(); - props.setProperty(PkgProps.MIN_TOOLS_REV, Integer.toString((min_tools_rev))); - return props; - } - - public IAndroidTarget getTarget() { - return mTarget; - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockPlatformToolPackage.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockPlatformToolPackage.java deleted file mode 100755 index b11c991..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockPlatformToolPackage.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import com.android.sdklib.internal.repository.archives.Archive.Arch; -import com.android.sdklib.internal.repository.archives.Archive.Os; -import com.android.sdklib.internal.repository.sources.SdkSource; - -/** - * A mock {@link PlatformToolPackage} for testing. - * - * By design, this package contains one and only one archive. - */ -public class MockPlatformToolPackage extends PlatformToolPackage { - - /** - * Creates a {@link MockPlatformToolPackage} with the given revision and hardcoded defaults - * for everything else. - * <p/> - * By design, this creates a package with one and only one archive. - */ - public MockPlatformToolPackage(int revision) { - this(null /*source*/, revision); - } - - /** - * Creates a {@link MockPlatformToolPackage} with the given revision and hardcoded defaults - * for everything else. - * <p/> - * By design, this creates a package with one and only one archive. - */ - public MockPlatformToolPackage(SdkSource source, int revision) { - super( - source, // source, - null, // props, - revision, - null, // license, - "desc", // description, - "url", // descUrl, - Os.getCurrentOs(), // archiveOs, - Arch.getCurrentArch(), // archiveArch, - "foo" // archiveOsPath - ); - } - - /** - * Creates a {@link MockPlatformToolPackage} with the given revision and hardcoded defaults - * for everything else. - * <p/> - * By design, this creates a package with one and only one archive. - */ - public MockPlatformToolPackage(SdkSource source, FullRevision revision) { - super( - source, // source, - FullRevisionPackageTest.createProps(revision), // props, - revision.getMajor(), - null, // license, - "desc", // description, - "url", // descUrl, - Os.getCurrentOs(), // archiveOs, - Arch.getCurrentArch(), // archiveArch, - "foo" // archiveOsPath - ); - } -} - diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockSourcePackage.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockSourcePackage.java deleted file mode 100755 index 4c129a3..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockSourcePackage.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import com.android.sdklib.AndroidVersion; -import com.android.sdklib.internal.repository.packages.SourcePackage; -import com.android.sdklib.internal.repository.packages.SystemImagePackage; -import com.android.sdklib.internal.repository.sources.SdkSource; - - -/** - * A mock {@link SystemImagePackage} for testing. - * - * By design, this package contains one and only one archive. - */ -public class MockSourcePackage extends SourcePackage { - /** - * Creates a {@link MockSourcePackage} using the given base platform version - * and package revision. - * - * By design, this package contains one and only one archive. - */ - public MockSourcePackage(AndroidVersion version, int revision) { - super(version, - revision, - null /*props*/, - String.format("/sdk/sources/android-%s", version.getApiString())); - } - - /** - * Creates a {@link MockSourcePackage} using the given version, - * sdk source and package revision. - * - * By design, this package contains one and only one archive. - */ - public MockSourcePackage( - SdkSource source, - AndroidVersion version, - int revision) { - super(source, - version, - revision, - null /*props*/, - String.format("/sdk/sources/android-%s", version.getApiString())); - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockSystemImagePackage.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockSystemImagePackage.java deleted file mode 100755 index 3c7baec..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockSystemImagePackage.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import com.android.sdklib.internal.repository.packages.SystemImagePackage; -import com.android.sdklib.internal.repository.sources.SdkSource; - - -/** - * A mock {@link SystemImagePackage} for testing. - * - * By design, this package contains one and only one archive. - */ -public class MockSystemImagePackage extends SystemImagePackage { - /** - * Creates a {@link MockSystemImagePackage} using the given base platform version - * and package revision. - * - * By design, this package contains one and only one archive. - */ - public MockSystemImagePackage(MockPlatformPackage basePlatform, int revision, String abi) { - super(basePlatform.getAndroidVersion(), - revision, - abi, - null /*props*/, - String.format("/sdk/system-images/android-%s/%s", - basePlatform.getAndroidVersion().getApiString(), abi)); - } - - /** - * Creates a {@link MockSystemImagePackage} using the given base platform version, - * sdk source and package revision. - * - * By design, this package contains one and only one archive. - */ - public MockSystemImagePackage( - SdkSource source, - MockPlatformPackage basePlatform, - int revision, - String abi) { - super(source, - basePlatform.getAndroidVersion(), - revision, - abi, - null /*props*/, - String.format("/sdk/system-images/android-%s/%s", - basePlatform.getAndroidVersion().getApiString(), abi)); - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockToolPackage.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockToolPackage.java deleted file mode 100755 index 32711d6..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockToolPackage.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import com.android.sdklib.internal.repository.archives.Archive.Arch; -import com.android.sdklib.internal.repository.archives.Archive.Os; -import com.android.sdklib.internal.repository.packages.ToolPackage; -import com.android.sdklib.internal.repository.sources.SdkSource; -import com.android.sdklib.repository.PkgProps; - -import java.util.Properties; - -/** - * A mock {@link ToolPackage} for testing. - * - * By design, this package contains one and only one archive. - */ -public class MockToolPackage extends ToolPackage { - - /** - * Creates a {@link MockToolPackage} with the given revision and hardcoded defaults - * for everything else. - * <p/> - * By design, this creates a package with one and only one archive. - */ - public MockToolPackage(int revision, int min_platform_tools_rev) { - this(null /*source*/, revision, min_platform_tools_rev); - } - - /** - * Creates a {@link MockToolPackage} with the given revision and hardcoded defaults - * for everything else. - * <p/> - * By design, this creates a package with one and only one archive. - */ - public MockToolPackage(SdkSource source, int revision, int minPlatformToolsRev) { - super( - source, // source, - createProps(null /*version*/, minPlatformToolsRev), // props, - revision, - null, // license, - "desc", // description, - "url", // descUrl, - Os.getCurrentOs(), // archiveOs, - Arch.getCurrentArch(), // archiveArch, - "foo" // archiveOsPath - ); - } - - /** - * Creates a {@link MockToolPackage} with the given revision and hardcoded defaults - * for everything else. - * <p/> - * By design, this creates a package with one and only one archive. - */ - public MockToolPackage( - SdkSource source, - FullRevision revision, - int minPlatformToolsRev) { - super( - source, // source, - createProps(revision, minPlatformToolsRev), // props, - revision.getMajor(), - null, // license, - "desc", // description, - "url", // descUrl, - Os.getCurrentOs(), // archiveOs, - Arch.getCurrentArch(), // archiveArch, - "foo" // archiveOsPath - ); - } - - private static Properties createProps(FullRevision revision, int minPlatformToolsRev) { - Properties props = FullRevisionPackageTest.createProps(revision); - props.setProperty(PkgProps.MIN_PLATFORM_TOOLS_REV, - Integer.toString((minPlatformToolsRev))); - return props; - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/PackageTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/PackageTest.java deleted file mode 100755 index f4d7b56..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/PackageTest.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import com.android.sdklib.SdkManager; -import com.android.sdklib.internal.repository.archives.Archive; -import com.android.sdklib.internal.repository.archives.Archive.Arch; -import com.android.sdklib.internal.repository.archives.Archive.Os; -import com.android.sdklib.internal.repository.packages.BrokenPackage; -import com.android.sdklib.internal.repository.packages.Package; -import com.android.sdklib.internal.repository.sources.SdkRepoSource; -import com.android.sdklib.internal.repository.sources.SdkSource; -import com.android.sdklib.repository.PkgProps; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Properties; - -import junit.framework.TestCase; - -public class PackageTest extends TestCase { - - protected static final String LOCAL_ARCHIVE_PATH = "/local/archive/path"; - - /** Local class used to test the abstract Package class */ - protected static class MockPackage extends MajorRevisionPackage { - public MockPackage( - SdkSource source, - Properties props, - int revision, - String license, - String description, - String descUrl, - Os archiveOs, - Arch archiveArch, - String archiveOsPath) { - super(source, - props, - revision, - license, - description, - descUrl, - archiveOs, - archiveArch, - archiveOsPath); - } - - @Override - public File getInstallFolder(String osSdkRoot, SdkManager sdkManager) { - throw new UnsupportedOperationException("abstract method not used in test"); //$NON-NLS-1$ - } - - @Override - public String getListDescription() { - throw new UnsupportedOperationException("abstract method not used in test"); //$NON-NLS-1$ - } - - @Override - public String getShortDescription() { - throw new UnsupportedOperationException("abstract method not used in test"); //$NON-NLS-1$ - } - - @Override - public boolean sameItemAs(Package pkg) { - throw new UnsupportedOperationException("abstract method not used in test"); //$NON-NLS-1$ - } - - @Override - public String installId() { - return "mock-pkg"; //$NON-NLS-1$ - } - } - - public void testCreate() throws Exception { - Properties props = createProps(); - - Package p = new MockPackage( - null, //source - props, - -1, //revision - null, //license - null, //description - null, //descUrl - Os.ANY, //archiveOs - Arch.ANY, //archiveArch - LOCAL_ARCHIVE_PATH //archiveOsPath - ); - - testCreatedPackage(p); - } - - public void testSaveProperties() throws Exception { - Properties props = createProps(); - - Package p = new MockPackage( - null, //source - props, - -1, //revision - null, //license - null, //description - null, //descUrl - Os.ANY, //archiveOs - Arch.ANY, //archiveArch - LOCAL_ARCHIVE_PATH //archiveOsPath - ); - - Properties props2 = new Properties(); - p.saveProperties(props2); - - assertEquals(props2, props); - } - - /** - * Sets the properties used by {@link #testCreate()} and - * {@link #testSaveProperties()}. - * This is protected and used by derived classes to perform - * a similar creation test. - */ - protected Properties createProps() { - Properties props = new Properties(); - - // Package properties - props.setProperty(PkgProps.PKG_REVISION, "42"); - props.setProperty(PkgProps.PKG_LICENSE, "The License"); - props.setProperty(PkgProps.PKG_DESC, "Some description."); - props.setProperty(PkgProps.PKG_DESC_URL, "http://description/url"); - props.setProperty(PkgProps.PKG_RELEASE_NOTE, "Release Note"); - props.setProperty(PkgProps.PKG_RELEASE_URL, "http://release/note"); - props.setProperty(PkgProps.PKG_SOURCE_URL, "http://source/url"); - props.setProperty(PkgProps.PKG_OBSOLETE, "true"); - return props; - } - - /** - * Tests the values set via {@link #createProps()} after the - * package has been created in {@link #testCreate()}. - * This is protected and used by derived classes to perform - * a similar creation test. - */ - protected void testCreatedPackage(Package p) { - // Package properties - assertEquals("42", p.getRevision().toShortString()); - assertEquals("The License", p.getLicense()); - assertEquals("Some description.", p.getDescription()); - assertEquals("http://description/url", p.getDescUrl()); - assertEquals("Release Note", p.getReleaseNote()); - assertEquals("http://release/note", p.getReleaseNoteUrl()); - assertEquals(new SdkRepoSource("http://source/url", null /*uiName*/), p.getParentSource()); - assertTrue(p.isObsolete()); - - assertNotNull(p.getArchives()); - assertEquals(1, p.getArchives().length); - Archive a = p.getArchives()[0]; - assertNotNull(a); - assertEquals(Os.ANY, a.getOs()); - assertEquals(Arch.ANY, a.getArch()); - assertEquals(LOCAL_ARCHIVE_PATH, a.getLocalOsPath()); - } - - // ---- - - public void testCompareTo() throws Exception { - ArrayList<Package> list = new ArrayList<Package>(); - MockPlatformPackage p1; - - list.add(p1 = new MockPlatformPackage(1, 2)); - list.add(new MockAddonPackage(p1, 3)); - list.add(new MockSystemImagePackage(p1, 4, "x86")); - list.add(new MockBrokenPackage(BrokenPackage.MIN_API_LEVEL_NOT_SPECIFIED, 1)); - list.add(new MockExtraPackage("vendor", "path", 5, 6)); - list.add(new MockToolPackage(7, 8)); - - Collections.sort(list); - - assertEquals( - "[Android SDK Tools, revision 7, " + - "SDK Platform Android android-1, API 1, revision 2, " + - "Intel x86 Atom System Image, Android API 1, revision 4, " + - "addon, Android API 1, revision 3, " + - "Broken package for API 1, " + - "Vendor Path, revision 5]", - Arrays.toString(list.toArray())); - } - - public void testGetPropertyInt() { - Properties p = new Properties(); - - assertEquals(42, Package.getPropertyInt(p, "key", 42)); - - p.setProperty("key", ""); - assertEquals(43, Package.getPropertyInt(p, "key", 43)); - - p.setProperty("key", "I am not a number"); - assertEquals(44, Package.getPropertyInt(p, "key", 44)); - - p.setProperty("key", "6"); - assertEquals(6, Package.getPropertyInt(p, "key", 45)); - } - -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/PlatformPackageTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/PlatformPackageTest.java deleted file mode 100755 index acb57ee..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/PlatformPackageTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import com.android.sdklib.IAndroidTarget; -import com.android.sdklib.internal.repository.MockPlatformTarget; -import com.android.sdklib.internal.repository.archives.Archive; -import com.android.sdklib.internal.repository.archives.Archive.Arch; -import com.android.sdklib.internal.repository.archives.Archive.Os; -import com.android.sdklib.internal.repository.packages.PlatformPackage; -import com.android.sdklib.repository.PkgProps; - -import java.util.Properties; - -public class PlatformPackageTest extends MinToolsPackageTest { - - /** - * PlatformPackage implicitly generates a local archive wrapper - * that matches the current platform OS and architecture. Since this - * is not convenient for testing, this class overrides it to always - * create archives for any OS and any architecture. - */ - private static class PlatformPackageWithFakeArchive extends PlatformPackage { - protected PlatformPackageWithFakeArchive(IAndroidTarget target, Properties props) { - super(target, props); - } - - @Override - protected Archive[] initializeArchives( - Properties props, - Os archiveOs, - Arch archiveArch, - String archiveOsPath) { - assert archiveOs == Os.getCurrentOs(); - assert archiveArch == Arch.getCurrentArch(); - return super.initializeArchives(props, Os.ANY, Arch.ANY, LOCAL_ARCHIVE_PATH); - } - } - - private PlatformPackage createPlatformPackage(Properties props) { - PlatformPackage p = new PlatformPackageWithFakeArchive( - new MockPlatformTarget(5 /*apiLevel*/, 1 /*revision*/), - props); - - return p; - } - - @Override - protected Properties createProps() { - Properties props = super.createProps(); - - // PlatformPackage properties - props.setProperty(PkgProps.VERSION_API_LEVEL, "5"); - props.setProperty(PkgProps.PLATFORM_VERSION, "android-5"); - props.setProperty(PkgProps.PLATFORM_INCLUDED_ABI, "armeabi"); - - return props; - } - - protected void testCreatedPlatformPackage(PlatformPackage p) { - super.testCreatedPackage(p); - - // Package properties - assertEquals("API 5", p.getAndroidVersion().toString()); - assertEquals("armeabi", p.getIncludedAbi()); - } - - // ---- - - @Override - public final void testCreate() { - Properties props = createProps(); - PlatformPackage p = createPlatformPackage(props); - - testCreatedPlatformPackage(p); - } - - @Override - public void testSaveProperties() { - Properties props = createProps(); - PlatformPackage p = createPlatformPackage(props); - - Properties props2 = new Properties(); - p.saveProperties(props2); - - assertEquals(props2.toString(), props.toString()); - assertEquals(props2, props); - } - - public void testInstallId() { - Properties props = createProps(); - PlatformPackage p = createPlatformPackage(props); - - assertEquals("android-5", p.installId()); - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/SourcePackageTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/SourcePackageTest.java deleted file mode 100755 index d87eab3..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/SourcePackageTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import com.android.sdklib.AndroidVersion; -import com.android.sdklib.AndroidVersion.AndroidVersionException; -import com.android.sdklib.internal.repository.archives.Archive; -import com.android.sdklib.internal.repository.archives.Archive.Arch; -import com.android.sdklib.internal.repository.archives.Archive.Os; -import com.android.sdklib.internal.repository.packages.SourcePackage; -import com.android.sdklib.repository.PkgProps; - -import java.util.Properties; - -public class SourcePackageTest extends PackageTest { - - /** - * SourcePackageTest implicitly generates a local archive wrapper - * that matches the current platform OS and architecture. Since this - * is not convenient for testing, this class overrides it to always - * create archives for any OS and any architecture. - */ - private static class SourcePackageFakeArchive extends SourcePackage { - protected SourcePackageFakeArchive( - AndroidVersion platformVersion, - int revision, - Properties props) { - super(platformVersion, - revision, - props, - String.format("/sdk/sources/android-%s", platformVersion.getApiString())); - } - - @Override - protected Archive[] initializeArchives( - Properties props, - Os archiveOs, - Arch archiveArch, - String archiveOsPath) { - assert archiveOs == Os.getCurrentOs(); - assert archiveArch == Arch.getCurrentArch(); - return super.initializeArchives(props, Os.ANY, Arch.ANY, LOCAL_ARCHIVE_PATH); - } - } - - private SourcePackage createSourcePackageTest(Properties props) throws AndroidVersionException { - SourcePackage p = new SourcePackageFakeArchive( - new AndroidVersion(props), - 1 /*revision*/, - props); - return p; - } - - @Override - protected Properties createProps() { - Properties props = super.createProps(); - - // SourcePackageTest properties - props.setProperty(PkgProps.VERSION_API_LEVEL, "5"); - - return props; - } - - protected void testCreatedSourcePackageTest(SourcePackage p) { - super.testCreatedPackage(p); - - // SourcePackageTest properties - assertEquals("API 5", p.getAndroidVersion().toString()); - } - - // ---- - - @Override - public final void testCreate() throws Exception { - Properties props = createProps(); - SourcePackage p = createSourcePackageTest(props); - - testCreatedSourcePackageTest(p); - } - - @Override - public void testSaveProperties() throws Exception { - Properties props = createProps(); - SourcePackage p = createSourcePackageTest(props); - - Properties props2 = new Properties(); - p.saveProperties(props2); - - assertEquals(props2, props); - } - - public void testSameItemAs() throws Exception { - Properties props1 = createProps(); - SourcePackage p1 = createSourcePackageTest(props1); - assertTrue(p1.sameItemAs(p1)); - - // different version - Properties props2 = new Properties(props1); - props2.setProperty(PkgProps.VERSION_API_LEVEL, "6"); - SourcePackage p2 = createSourcePackageTest(props2); - assertFalse(p1.sameItemAs(p2)); - assertFalse(p2.sameItemAs(p1)); - } - - public void testInstallId() throws Exception { - Properties props = createProps(); - SourcePackage p = createSourcePackageTest(props); - - assertEquals("source-5", p.installId()); - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/SystemImagePackageTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/SystemImagePackageTest.java deleted file mode 100755 index c32b81f..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/SystemImagePackageTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.packages; - -import com.android.sdklib.AndroidVersion; -import com.android.sdklib.AndroidVersion.AndroidVersionException; -import com.android.sdklib.internal.repository.archives.Archive; -import com.android.sdklib.internal.repository.archives.Archive.Arch; -import com.android.sdklib.internal.repository.archives.Archive.Os; -import com.android.sdklib.internal.repository.packages.SystemImagePackage; -import com.android.sdklib.repository.PkgProps; - -import java.util.Properties; - -public class SystemImagePackageTest extends PackageTest { - - /** - * SystemImagePackage implicitly generates a local archive wrapper - * that matches the current platform OS and architecture. Since this - * is not convenient for testing, this class overrides it to always - * create archives for any OS and any architecture. - */ - private static class SysImgPackageFakeArchive extends SystemImagePackage { - protected SysImgPackageFakeArchive( - AndroidVersion platformVersion, - int revision, - String abi, - Properties props) { - super(platformVersion, - revision, - abi, - props, - String.format("/sdk/system-images/android-%s/%s", - platformVersion.getApiString(), abi)); - } - - @Override - protected Archive[] initializeArchives( - Properties props, - Os archiveOs, - Arch archiveArch, - String archiveOsPath) { - assert archiveOs == Os.getCurrentOs(); - assert archiveArch == Arch.getCurrentArch(); - return super.initializeArchives(props, Os.ANY, Arch.ANY, LOCAL_ARCHIVE_PATH); - } - } - - private SystemImagePackage createSystemImagePackage(Properties props) - throws AndroidVersionException { - SystemImagePackage p = new SysImgPackageFakeArchive( - new AndroidVersion(props), - 1 /*revision*/, - null /*abi*/, - props); - return p; - } - - @Override - protected Properties createProps() { - Properties props = super.createProps(); - - // SystemImagePackage properties - props.setProperty(PkgProps.VERSION_API_LEVEL, "5"); - props.setProperty(PkgProps.SYS_IMG_ABI, "armeabi-v7a"); - - return props; - } - - protected void testCreatedSystemImagePackage(SystemImagePackage p) { - super.testCreatedPackage(p); - - // SystemImagePackage properties - assertEquals("API 5", p.getAndroidVersion().toString()); - assertEquals("armeabi-v7a", p.getAbi()); - } - - // ---- - - @Override - public final void testCreate() throws Exception { - Properties props = createProps(); - SystemImagePackage p = createSystemImagePackage(props); - - testCreatedSystemImagePackage(p); - } - - @Override - public void testSaveProperties() throws Exception { - Properties props = createProps(); - SystemImagePackage p = createSystemImagePackage(props); - - Properties props2 = new Properties(); - p.saveProperties(props2); - - assertEquals(props2, props); - } - - public void testSameItemAs() throws Exception { - Properties props1 = createProps(); - SystemImagePackage p1 = createSystemImagePackage(props1); - assertTrue(p1.sameItemAs(p1)); - - // different abi, same version - Properties props2 = new Properties(props1); - props2.setProperty(PkgProps.SYS_IMG_ABI, "x86"); - SystemImagePackage p2 = createSystemImagePackage(props2); - assertFalse(p1.sameItemAs(p2)); - assertFalse(p2.sameItemAs(p1)); - - // different abi, different version - props2.setProperty(PkgProps.VERSION_API_LEVEL, "6"); - p2 = createSystemImagePackage(props2); - assertFalse(p1.sameItemAs(p2)); - assertFalse(p2.sameItemAs(p1)); - - // same abi, different version - Properties props3 = new Properties(props1); - props3.setProperty(PkgProps.VERSION_API_LEVEL, "6"); - SystemImagePackage p3 = createSystemImagePackage(props3); - assertFalse(p1.sameItemAs(p3)); - assertFalse(p3.sameItemAs(p1)); - } - - public void testInstallId() throws Exception { - Properties props = createProps(); - SystemImagePackage p = createSystemImagePackage(props); - - assertEquals("sysimg-5", p.installId()); - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/sources/SdkAddonSourceTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/sources/SdkAddonSourceTest.java deleted file mode 100755 index 046cd1d..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/sources/SdkAddonSourceTest.java +++ /dev/null @@ -1,750 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.eclipse.org/org/documents/epl-v10.php - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.sources; - -import com.android.sdklib.SdkManager; -import com.android.sdklib.internal.repository.ITaskMonitor; -import com.android.sdklib.internal.repository.MockEmptySdkManager; -import com.android.sdklib.internal.repository.MockMonitor; -import com.android.sdklib.internal.repository.packages.AddonPackage; -import com.android.sdklib.internal.repository.packages.ExtraPackage; -import com.android.sdklib.internal.repository.packages.IMinToolsDependency; -import com.android.sdklib.internal.repository.packages.Package; -import com.android.sdklib.internal.repository.sources.SdkAddonSource; -import com.android.sdklib.repository.SdkAddonConstants; -import com.android.utils.Pair; - -import org.w3c.dom.Document; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Arrays; - -import junit.framework.TestCase; - -/** - * Tests for {@link SdkAddonSource}. - */ -public class SdkAddonSourceTest extends TestCase { - - /** - * An internal helper class to give us visibility to the protected members we want - * to test. - */ - private static class MockSdkAddonSource extends SdkAddonSource { - public MockSdkAddonSource() { - super("fake-url", null /*uiName*/); - } - - public Document _findAlternateToolsXml(InputStream xml) { - return super.findAlternateToolsXml(xml); - } - - public boolean _parsePackages(Document doc, String nsUri, ITaskMonitor monitor) { - return super.parsePackages(doc, nsUri, monitor); - } - - public int _getXmlSchemaVersion(InputStream xml) { - return super.getXmlSchemaVersion(xml); - } - - public String _validateXml(InputStream xml, String url, int version, - String[] outError, Boolean[] validatorFound) { - return super.validateXml(xml, url, version, outError, validatorFound); - } - - public Document _getDocument(InputStream xml, ITaskMonitor monitor) { - return super.getDocument(xml, monitor); - } - - } - - private MockSdkAddonSource mSource; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - mSource = new MockSdkAddonSource(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - - mSource = null; - } - - public void testFindAlternateToolsXml_Errors() throws Exception { - // Support null as input - Document result = mSource._findAlternateToolsXml(null); - assertNull(result); - - // Support an empty input - String str = ""; - ByteArrayInputStream input = new ByteArrayInputStream(str.getBytes()); - result = mSource._findAlternateToolsXml(input); - assertNull(result); - - // Support a random string as input - str = "Some random string, not even HTML nor XML"; - input = new ByteArrayInputStream(str.getBytes()); - result = mSource._findAlternateToolsXml(input); - assertNull(result); - - // Support an HTML input, e.g. a typical 404 document as returned by DL - str = "<html><head> " + - "<meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\"> " + - "<title>404 Not Found</title> " + "<style><!--" + "body {font-family: arial,sans-serif}" + - "div.nav { ... blah blah more css here ... color: green}" + - "//--></style> " + "<script><!--" + "var rc=404;" + "//-->" + "</script> " + "</head> " + - "<body text=#000000 bgcolor=#ffffff> " + - "<table border=0 cellpadding=2 cellspacing=0 width=100%><tr><td rowspan=3 width=1% nowrap> " + - "<b><font face=times color=#0039b6 size=10>G</font><font face=times color=#c41200 size=10>o</font><font face=times color=#f3c518 size=10>o</font><font face=times color=#0039b6 size=10>g</font><font face=times color=#30a72f size=10>l</font><font face=times color=#c41200 size=10>e</font> </b> " + - "<td> </td></tr> " + - "<tr><td bgcolor=\"#3366cc\"><font face=arial,sans-serif color=\"#ffffff\"><b>Error</b></td></tr> " + - "<tr><td> </td></tr></table> " + "<blockquote> " + "<H1>Not Found</H1> " + - "The requested URL <code>/404</code> was not found on this server." + " " + "<p> " + - "</blockquote> " + - "<table width=100% cellpadding=0 cellspacing=0><tr><td bgcolor=\"#3366cc\"><img alt=\"\" width=1 height=4></td></tr></table> " + - "</body></html> "; - input = new ByteArrayInputStream(str.getBytes()); - result = mSource._findAlternateToolsXml(input); - assertNull(result); - - // Support some random XML document, totally unrelated to our sdk-repository schema - str = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + - "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"" + - " package=\"some.cool.app\" android:versionName=\"1.6.04\" android:versionCode=\"1604\">" + - " <application android:label=\"@string/app_name\" android:icon=\"@drawable/icon\"/>" + - "</manifest>"; - input = new ByteArrayInputStream(str.getBytes()); - result = mSource._findAlternateToolsXml(input); - assertNull(result); - } - - /** - * Validate that findAlternateToolsXml doesn't work for addon even - * when trying to load a valid addon xml. - */ - public void testFindAlternateToolsXml_1() throws Exception { - InputStream xmlStream = getTestResource("/com/android/sdklib/testdata/addon_sample_1.xml"); - - Document result = mSource._findAlternateToolsXml(xmlStream); - assertNull(result); - } - - /** - * Validate we can load a valid add-on schema version 1 - */ - public void testLoadAddonXml_1() throws Exception { - InputStream xmlStream = getTestResource("/com/android/sdklib/testdata/addon_sample_1.xml"); - - // guess the version from the XML document - int version = mSource._getXmlSchemaVersion(xmlStream); - assertEquals(1, version); - - Boolean[] validatorFound = new Boolean[] { Boolean.FALSE }; - String[] validationError = new String[] { null }; - String url = "not-a-valid-url://" + SdkAddonConstants.URL_DEFAULT_FILENAME; - - String uri = mSource._validateXml(xmlStream, url, version, validationError, validatorFound); - assertEquals(Boolean.TRUE, validatorFound[0]); - assertEquals(null, validationError[0]); - assertEquals(SdkAddonConstants.getSchemaUri(1), uri); - - // Validation was successful, load the document - MockMonitor monitor = new MockMonitor(); - Document doc = mSource._getDocument(xmlStream, monitor); - assertNotNull(doc); - - // Get the packages - assertTrue(mSource._parsePackages(doc, uri, monitor)); - - assertEquals("Found My First add-on, Android API 1, revision 1\n" + - "Found My Second add-on, Android API 2, revision 42\n" + - "Found This add-on has no libraries, Android API 4, revision 3\n" + - "Found G USB Driver, revision 43 (Obsolete)\n" + - "Found Android Vendor Extra API Dep, revision 2 (Obsolete)\n" + - "Found Unknown Extra, revision 2 (Obsolete)\n", - monitor.getCapturedVerboseLog()); - assertEquals("", monitor.getCapturedLog()); - assertEquals("", monitor.getCapturedErrorLog()); - - // check the packages we found... we expected to find 11 packages with each at least - // one archive. - Package[] pkgs = mSource.getPackages(); - assertEquals(6, pkgs.length); - for (Package p : pkgs) { - assertTrue(p.getArchives().length >= 1); - } - - // Check the extra packages path, vendor, install folder - - final String osSdkPath = "SDK"; - final SdkManager sdkManager = new MockEmptySdkManager(osSdkPath); - - ArrayList<String> extraPaths = new ArrayList<String>(); - ArrayList<String> extraVendors = new ArrayList<String>(); - ArrayList<File> extraInstall = new ArrayList<File>(); - for (Package p : pkgs) { - if (p instanceof ExtraPackage) { - ExtraPackage ep = (ExtraPackage) p; - extraPaths.add(ep.getPath()); - extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay()); - extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager)); - } - } - assertEquals( - "[extra_api_dep, usb_driver, extra0000005f]", - Arrays.toString(extraPaths.toArray())); - assertEquals( - "[android_vendor/android_vendor, " + - "g/g, " + - "vendor0000005f/____]", - Arrays.toString(extraVendors.toArray())); - assertEquals( - ("[SDK/extras/android_vendor/extra_api_dep, " + - "SDK/extras/g/usb_driver, " + - "SDK/extras/vendor0000005f/extra0000005f]").replace('/', File.separatorChar), - Arrays.toString(extraInstall.toArray())); - } - - /** - * Validate we can still load a valid add-on schema version 2 - */ - public void testLoadAddonXml_2() throws Exception { - InputStream xmlStream = getTestResource("/com/android/sdklib/testdata/addon_sample_2.xml"); - - // guess the version from the XML document - int version = mSource._getXmlSchemaVersion(xmlStream); - assertEquals(2, version); - - Boolean[] validatorFound = new Boolean[] { Boolean.FALSE }; - String[] validationError = new String[] { null }; - String url = "not-a-valid-url://" + SdkAddonConstants.URL_DEFAULT_FILENAME; - - String uri = mSource._validateXml(xmlStream, url, version, validationError, validatorFound); - assertEquals(Boolean.TRUE, validatorFound[0]); - assertEquals(null, validationError[0]); - assertEquals(SdkAddonConstants.getSchemaUri(2), uri); - - // Validation was successful, load the document - MockMonitor monitor = new MockMonitor(); - Document doc = mSource._getDocument(xmlStream, monitor); - assertNotNull(doc); - - // Get the packages - assertTrue(mSource._parsePackages(doc, uri, monitor)); - - assertEquals("Found My First add-on, Android API 1, revision 1\n" + - "Found My Second add-on, Android API 2, revision 42\n" + - "Found This add-on has no libraries, Android API 4, revision 3\n" + - "Found G USB Driver, revision 43 (Obsolete)\n" + - "Found Android Vendor Extra API Dep, revision 2 (Obsolete)\n" + - "Found Unknown Extra, revision 2 (Obsolete)\n", - monitor.getCapturedVerboseLog()); - assertEquals("", monitor.getCapturedLog()); - assertEquals("", monitor.getCapturedErrorLog()); - - // check the packages we found... we expected to find 11 packages with each at least - // one archive. - // Note the order doesn't necessary match the one from the - // assertEquald(getCapturedVerboseLog) because packages are sorted using the - // Packages' sorting order, e.g. all platforms are sorted by descending API level, etc. - Package[] pkgs = mSource.getPackages(); - - assertEquals(6, pkgs.length); - for (Package p : pkgs) { - assertTrue(p.getArchives().length >= 1); - } - - // Check the layoutlib of the platform packages. - ArrayList<Pair<Integer, Integer>> layoutlibVers = new ArrayList<Pair<Integer,Integer>>(); - for (Package p : pkgs) { - if (p instanceof AddonPackage) { - layoutlibVers.add(((AddonPackage) p).getLayoutlibVersion()); - } - } - assertEquals( - "[Pair [first=3, second=42], " + // for #3 "This add-on has no libraries" - "Pair [first=0, second=0], " + // for #2 "My Second add-on" - "Pair [first=5, second=0]]", // for #1 "My First add-on" - Arrays.toString(layoutlibVers.toArray())); - - - // Check the extra packages path, vendor, install folder - - final String osSdkPath = "SDK"; - final SdkManager sdkManager = new MockEmptySdkManager(osSdkPath); - - ArrayList<String> extraPaths = new ArrayList<String>(); - ArrayList<String> extraVendors = new ArrayList<String>(); - ArrayList<File> extraInstall = new ArrayList<File>(); - for (Package p : pkgs) { - if (p instanceof ExtraPackage) { - ExtraPackage ep = (ExtraPackage) p; - extraPaths.add(ep.getPath()); - extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay()); - extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager)); - } - } - assertEquals( - "[extra_api_dep, usb_driver, extra0000005f]", - Arrays.toString(extraPaths.toArray())); - assertEquals( - "[android_vendor/android_vendor, " + - "g/g, " + - "vendor0000005f/____]", - Arrays.toString(extraVendors.toArray())); - assertEquals( - ("[SDK/extras/android_vendor/extra_api_dep, " + - "SDK/extras/g/usb_driver, " + - "SDK/extras/vendor0000005f/extra0000005f]").replace('/', File.separatorChar), - Arrays.toString(extraInstall.toArray())); - } - - /** - * Validate we can load a valid add-on schema version 3 - */ - public void testLoadAddonXml_3() throws Exception { - InputStream xmlStream = getTestResource("/com/android/sdklib/testdata/addon_sample_3.xml"); - - // guess the version from the XML document - int version = mSource._getXmlSchemaVersion(xmlStream); - assertEquals(3, version); - - Boolean[] validatorFound = new Boolean[] { Boolean.FALSE }; - String[] validationError = new String[] { null }; - String url = "not-a-valid-url://" + SdkAddonConstants.URL_DEFAULT_FILENAME; - - String uri = mSource._validateXml(xmlStream, url, version, validationError, validatorFound); - assertEquals(Boolean.TRUE, validatorFound[0]); - assertEquals(null, validationError[0]); - assertEquals(SdkAddonConstants.getSchemaUri(3), uri); - - // Validation was successful, load the document - MockMonitor monitor = new MockMonitor(); - Document doc = mSource._getDocument(xmlStream, monitor); - assertNotNull(doc); - - // Get the packages - assertTrue(mSource._parsePackages(doc, uri, monitor)); - - assertEquals("Found My First add-on, Android API 1, revision 1\n" + - "Found My Second add-on, Android API 2, revision 42\n" + - "Found This add-on has no libraries, Android API 4, revision 3\n" + - "Found G USB Driver, revision 43 (Obsolete)\n" + - "Found Android Vendor Extra API Dep, revision 2 (Obsolete)\n" + - "Found Unknown Extra, revision 2 (Obsolete)\n", - monitor.getCapturedVerboseLog()); - assertEquals("", monitor.getCapturedLog()); - assertEquals("", monitor.getCapturedErrorLog()); - - // check the packages we found... we expected to find 6 packages with each at least - // one archive. - // Note the order doesn't necessary match the one from the - // assertEquald(getCapturedVerboseLog) because packages are sorted using the - // Packages' sorting order, e.g. all platforms are sorted by descending API level, etc. - Package[] pkgs = mSource.getPackages(); - - assertEquals(6, pkgs.length); - for (Package p : pkgs) { - assertTrue(p.getArchives().length >= 1); - } - - // Check the layoutlib of the platform packages. - ArrayList<Pair<Integer, Integer>> layoutlibVers = new ArrayList<Pair<Integer,Integer>>(); - for (Package p : pkgs) { - if (p instanceof AddonPackage) { - layoutlibVers.add(((AddonPackage) p).getLayoutlibVersion()); - } - } - assertEquals( - "[Pair [first=3, second=42], " + // for #3 "This add-on has no libraries" - "Pair [first=0, second=0], " + // for #2 "My Second add-on" - "Pair [first=5, second=0]]", // for #1 "My First add-on" - Arrays.toString(layoutlibVers.toArray())); - - - // Check the extra packages: path, vendor, install folder, old-paths - - final String osSdkPath = "SDK"; - final SdkManager sdkManager = new MockEmptySdkManager(osSdkPath); - - ArrayList<String> extraPaths = new ArrayList<String>(); - ArrayList<String> extraVendors = new ArrayList<String>(); - ArrayList<File> extraInstall = new ArrayList<File>(); - ArrayList<ArrayList<String>> extraFilePaths = new ArrayList<ArrayList<String>>(); - for (Package p : pkgs) { - if (p instanceof ExtraPackage) { - ExtraPackage ep = (ExtraPackage) p; - // combine path and old-paths in the form "path [old_path1, old_path2]" - extraPaths.add(ep.getPath() + " " + Arrays.toString(ep.getOldPaths())); - extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay()); - extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager)); - - ArrayList<String> filePaths = new ArrayList<String>(); - for (String filePath : ep.getProjectFiles()) { - filePaths.add(filePath); - } - extraFilePaths.add(filePaths); - } - } - assertEquals( - "[extra_api_dep [path1, old_path2, oldPath3], " + - "usb_driver [], " + - "extra0000005f []]", - Arrays.toString(extraPaths.toArray())); - assertEquals( - "[android_vendor/android_vendor, " + - "g/g, " + - "vendor0000005f/____]", - Arrays.toString(extraVendors.toArray())); - assertEquals( - ("[SDK/extras/android_vendor/extra_api_dep, " + - "SDK/extras/g/usb_driver, " + - "SDK/extras/vendor0000005f/extra0000005f]").replace('/', File.separatorChar), - Arrays.toString(extraInstall.toArray())); - assertEquals( - "[[v8/veggies_8.jar, root.jar, dir1/dir 2 with space/mylib.jar], " + - "[], " + - "[]]", - Arrays.toString(extraFilePaths.toArray())); - } - - /** - * Validate we can load a valid add-on schema version 4 - */ - public void testLoadAddonXml_4() throws Exception { - InputStream xmlStream = getTestResource("/com/android/sdklib/testdata/addon_sample_4.xml"); - - // guess the version from the XML document - int version = mSource._getXmlSchemaVersion(xmlStream); - assertEquals(4, version); - - Boolean[] validatorFound = new Boolean[] { Boolean.FALSE }; - String[] validationError = new String[] { null }; - String url = "not-a-valid-url://" + SdkAddonConstants.URL_DEFAULT_FILENAME; - - String uri = mSource._validateXml(xmlStream, url, version, validationError, validatorFound); - assertEquals(Boolean.TRUE, validatorFound[0]); - assertEquals(null, validationError[0]); - assertEquals(SdkAddonConstants.getSchemaUri(4), uri); - - // Validation was successful, load the document - MockMonitor monitor = new MockMonitor(); - Document doc = mSource._getDocument(xmlStream, monitor); - assertNotNull(doc); - - // Get the packages - assertTrue(mSource._parsePackages(doc, uri, monitor)); - - assertEquals("Found My First add-on, Android API 1, revision 1\n" + - "Found My Second add-on, Android API 2, revision 42\n" + - "Found This add-on has no libraries, Android API 4, revision 3\n" + - "Found Random name, not an id!, revision 43 (Obsolete)\n" + - "Found Yet another extra, by Android, revision 2\n" + - "Found . -..- - .-. .-, revision 2 (Obsolete)\n", - monitor.getCapturedVerboseLog()); - assertEquals("", monitor.getCapturedLog()); - assertEquals("", monitor.getCapturedErrorLog()); - - // check the packages we found... we expected to find 6 packages with each at least - // one archive. - // Note the order doesn't necessary match the one from the - // assertEquald(getCapturedVerboseLog) because packages are sorted using the - // Packages' sorting order, e.g. all platforms are sorted by descending API level, etc. - Package[] pkgs = mSource.getPackages(); - - assertEquals(6, pkgs.length); - for (Package p : pkgs) { - assertTrue(p.getArchives().length >= 1); - } - - // Check the addon packages: vendor/name id vs display - ArrayList<String> addonNames = new ArrayList<String>(); - ArrayList<String> addonVendors = new ArrayList<String>(); - for (Package p : pkgs) { - if (p instanceof AddonPackage) { - AddonPackage ap = (AddonPackage) p; - addonNames.add(ap.getNameId() + "/" + ap.getDisplayName()); - addonVendors.add(ap.getVendorId() + "/" + ap.getDisplayVendor()); - } - } - // Addons are sorted by addon/vendor id and thus their order differs from the - // XML or the parsed package list. - assertEquals( - "[no_libs/This add-on has no libraries, " + - "My_Second_add-on/My Second add-on, " + - "My_First_add-on/My First add-on]", - Arrays.toString(addonNames.toArray())); - assertEquals( - "[Joe_Bar/Joe Bar, " + - "John_Deer/John Deer, " + - "John_Doe/John Doe]", - Arrays.toString(addonVendors.toArray())); - - // Check the layoutlib of the platform packages. - ArrayList<Pair<Integer, Integer>> layoutlibVers = new ArrayList<Pair<Integer,Integer>>(); - for (Package p : pkgs) { - if (p instanceof AddonPackage) { - layoutlibVers.add(((AddonPackage) p).getLayoutlibVersion()); - } - } - assertEquals( - "[Pair [first=3, second=42], " + // for #3 "This add-on has no libraries" - "Pair [first=0, second=0], " + // for #2 "My Second add-on" - "Pair [first=5, second=0]]", // for #1 "My First add-on" - Arrays.toString(layoutlibVers.toArray())); - - - // Check the extra packages: path, vendor, install folder, old-paths - final String osSdkPath = "SDK"; - final SdkManager sdkManager = new MockEmptySdkManager(osSdkPath); - - ArrayList<String> extraPaths = new ArrayList<String>(); - ArrayList<String> extraVendors = new ArrayList<String>(); - ArrayList<File> extraInstall = new ArrayList<File>(); - ArrayList<ArrayList<String>> extraFilePaths = new ArrayList<ArrayList<String>>(); - for (Package p : pkgs) { - if (p instanceof ExtraPackage) { - ExtraPackage ep = (ExtraPackage) p; - // combine path and old-paths in the form "path [old_path1, old_path2]" - extraPaths.add(ep.getPath() + " " + Arrays.toString(ep.getOldPaths())); - extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay()); - extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager)); - - ArrayList<String> filePaths = new ArrayList<String>(); - for (String filePath : ep.getProjectFiles()) { - filePaths.add(filePath); - } - extraFilePaths.add(filePaths); - } - } - // Extras are sorted by vendor-id/path and thus their order differs from the - // XML or the parsed package list. - assertEquals( - "[extra0000005f [], " + // for extra #3 - "extra_api_dep [path1, old_path2, oldPath3], " + // for extra #2 - "usb_driver []]", // for extra #1 - Arrays.toString(extraPaths.toArray())); - assertEquals( - "[____/____, " + - "android_vendor/Android Vendor, " + - "cyclop/The big bus]", - Arrays.toString(extraVendors.toArray())); - assertEquals( - ("[SDK/extras/____/extra0000005f, " + - "SDK/extras/android_vendor/extra_api_dep, " + - "SDK/extras/cyclop/usb_driver]").replace('/', File.separatorChar), - Arrays.toString(extraInstall.toArray())); - assertEquals( - "[[], " + - "[v8/veggies_8.jar, root.jar, dir1/dir 2 with space/mylib.jar], " + - "[]]", - Arrays.toString(extraFilePaths.toArray())); - } - - /** - * Validate we can load a valid add-on schema version 5 - */ - public void testLoadAddonXml_5() throws Exception { - InputStream xmlStream = getTestResource("/com/android/sdklib/testdata/addon_sample_5.xml"); - - // guess the version from the XML document - int version = mSource._getXmlSchemaVersion(xmlStream); - assertEquals(5, version); - - Boolean[] validatorFound = new Boolean[] { Boolean.FALSE }; - String[] validationError = new String[] { null }; - String url = "not-a-valid-url://" + SdkAddonConstants.URL_DEFAULT_FILENAME; - - String uri = mSource._validateXml(xmlStream, url, version, validationError, validatorFound); - assertEquals(Boolean.TRUE, validatorFound[0]); - assertEquals(null, validationError[0]); - assertEquals(SdkAddonConstants.getSchemaUri(5), uri); - - // Validation was successful, load the document - MockMonitor monitor = new MockMonitor(); - Document doc = mSource._getDocument(xmlStream, monitor); - assertNotNull(doc); - - // Get the packages - assertTrue(mSource._parsePackages(doc, uri, monitor)); - - assertEquals("Found My First add-on, Android API 1, revision 1\n" + - "Found My Second add-on, Android API 2, revision 42\n" + - "Found This add-on has no libraries, Android API 4, revision 3\n" + - "Found Random name, not an id!, revision 43 (Obsolete)\n" + - "Found Yet another extra, by Android, revision 2\n" + - "Found . -..- - .-. .-, revision 2 (Obsolete)\n", - monitor.getCapturedVerboseLog()); - assertEquals("", monitor.getCapturedLog()); - assertEquals("", monitor.getCapturedErrorLog()); - - // check the packages we found... we expected to find 6 packages with each at least - // one archive. - // Note the order doesn't necessary match the one from the - // assertEquald(getCapturedVerboseLog) because packages are sorted using the - // Packages' sorting order, e.g. all platforms are sorted by descending API level, etc. - Package[] pkgs = mSource.getPackages(); - - assertEquals(6, pkgs.length); - for (Package p : pkgs) { - assertTrue(p.getArchives().length >= 1); - } - - // Check the addon packages: vendor/name id vs display - ArrayList<String> addonNames = new ArrayList<String>(); - ArrayList<String> addonVendors = new ArrayList<String>(); - for (Package p : pkgs) { - if (p instanceof AddonPackage) { - AddonPackage ap = (AddonPackage) p; - addonNames.add(ap.getNameId() + "/" + ap.getDisplayName()); - addonVendors.add(ap.getVendorId() + "/" + ap.getDisplayVendor()); - } - } - // Addons are sorted by addon/vendor id and thus their order differs from the - // XML or the parsed package list. - assertEquals( - "[no_libs/This add-on has no libraries, " + - "My_Second_add-on/My Second add-on, " + - "My_First_add-on/My First add-on]", - Arrays.toString(addonNames.toArray())); - assertEquals( - "[Joe_Bar/Joe Bar, " + - "John_Deer/John Deer, " + - "John_Doe/John Doe]", - Arrays.toString(addonVendors.toArray())); - - // Check the layoutlib of the platform packages. - ArrayList<Pair<Integer, Integer>> layoutlibVers = new ArrayList<Pair<Integer,Integer>>(); - for (Package p : pkgs) { - if (p instanceof AddonPackage) { - layoutlibVers.add(((AddonPackage) p).getLayoutlibVersion()); - } - } - assertEquals( - "[Pair [first=3, second=42], " + // for #3 "This add-on has no libraries" - "Pair [first=0, second=0], " + // for #2 "My Second add-on" - "Pair [first=5, second=0]]", // for #1 "My First add-on" - Arrays.toString(layoutlibVers.toArray())); - - - // Check the extra packages: path, vendor, install folder, old-paths - final String osSdkPath = "SDK"; - final SdkManager sdkManager = new MockEmptySdkManager(osSdkPath); - - ArrayList<String> extraPaths = new ArrayList<String>(); - ArrayList<String> extraVendors = new ArrayList<String>(); - ArrayList<File> extraInstall = new ArrayList<File>(); - ArrayList<ArrayList<String>> extraFilePaths = new ArrayList<ArrayList<String>>(); - for (Package p : pkgs) { - if (p instanceof ExtraPackage) { - ExtraPackage ep = (ExtraPackage) p; - // combine path and old-paths in the form "path [old_path1, old_path2]" - extraPaths.add(ep.getPath() + " " + Arrays.toString(ep.getOldPaths())); - extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay()); - extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager)); - - ArrayList<String> filePaths = new ArrayList<String>(); - for (String filePath : ep.getProjectFiles()) { - filePaths.add(filePath); - } - extraFilePaths.add(filePaths); - } - } - // Extras are sorted by vendor-id/path and thus their order differs from the - // XML or the parsed package list. - assertEquals( - "[extra0000005f [], " + // for extra #3 - "extra_api_dep [path1, old_path2, oldPath3], " + // for extra #2 - "usb_driver []]", // for extra #1 - Arrays.toString(extraPaths.toArray())); - assertEquals( - "[____/____, " + - "android_vendor/Android Vendor, " + - "cyclop/The big bus]", - Arrays.toString(extraVendors.toArray())); - assertEquals( - ("[SDK/extras/____/extra0000005f, " + - "SDK/extras/android_vendor/extra_api_dep, " + - "SDK/extras/cyclop/usb_driver]").replace('/', File.separatorChar), - Arrays.toString(extraInstall.toArray())); - assertEquals( - "[[], " + - "[v8/veggies_8.jar, root.jar, dir1/dir 2 with space/mylib.jar], " + - "[]]", - Arrays.toString(extraFilePaths.toArray())); - - - // Check the min-tools-rev - ArrayList<String> minToolsRevs = new ArrayList<String>(); - for (Package p : pkgs) { - if (p instanceof IMinToolsDependency) { - minToolsRevs.add(p.getListDescription() + ": " + - ((IMinToolsDependency) p).getMinToolsRevision().toShortString()); - } - } - assertEquals( - "[. -..- - .-. .- (Obsolete): 3.0.1, " + - "Yet another extra, by Android: 3, " + - "Random name, not an id! (Obsolete): 3.2.1 rc42]", - Arrays.toString(minToolsRevs.toArray())); - } - - /** - * Returns an SdkLib file resource as a {@link ByteArrayInputStream}, - * which has the advantage that we can use {@link InputStream#reset()} on it - * at any time to read it multiple times. - * <p/> - * The default for getResourceAsStream() is to return a {@link FileInputStream} that - * does not support reset(), yet we need it in the tested code. - * - * @throws IOException if some I/O read fails - */ - private ByteArrayInputStream getTestResource(String filename) throws IOException { - InputStream xmlStream = this.getClass().getResourceAsStream(filename); - - try { - byte[] data = new byte[8192]; - int offset = 0; - int n; - - while ((n = xmlStream.read(data, offset, data.length - offset)) != -1) { - offset += n; - - if (offset == data.length) { - byte[] newData = new byte[offset + 8192]; - System.arraycopy(data, 0, newData, 0, offset); - data = newData; - } - } - - return new ByteArrayInputStream(data, 0, offset); - } finally { - if (xmlStream != null) { - xmlStream.close(); - } - } - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/sources/SdkRepoSourceTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/sources/SdkRepoSourceTest.java deleted file mode 100755 index 9df0bfd..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/sources/SdkRepoSourceTest.java +++ /dev/null @@ -1,1063 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.eclipse.org/org/documents/epl-v10.php - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.sources; - -import com.android.sdklib.SdkManager; -import com.android.sdklib.internal.repository.ITaskMonitor; -import com.android.sdklib.internal.repository.MockEmptySdkManager; -import com.android.sdklib.internal.repository.MockMonitor; -import com.android.sdklib.internal.repository.packages.ExtraPackage; -import com.android.sdklib.internal.repository.packages.IMinPlatformToolsDependency; -import com.android.sdklib.internal.repository.packages.IMinToolsDependency; -import com.android.sdklib.internal.repository.packages.Package; -import com.android.sdklib.internal.repository.packages.PlatformPackage; -import com.android.sdklib.internal.repository.packages.PlatformToolPackage; -import com.android.sdklib.internal.repository.packages.SourcePackage; -import com.android.sdklib.internal.repository.packages.SystemImagePackage; -import com.android.sdklib.internal.repository.packages.ToolPackage; -import com.android.sdklib.internal.repository.sources.SdkRepoSource; -import com.android.sdklib.repository.SdkRepoConstants; -import com.android.utils.Pair; - -import org.w3c.dom.Document; -import org.xml.sax.ErrorHandler; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Arrays; - -import junit.framework.TestCase; - -/** - * Tests for {@link SdkRepoSource} - */ -public class SdkRepoSourceTest extends TestCase { - - /** - * An internal helper class to give us visibility to the protected members we want - * to test. - */ - private static class MockSdkRepoSource extends SdkRepoSource { - public MockSdkRepoSource() { - super("fake-url", null /*uiName*/); - } - - /** - * Returns a pair of Document (which can be null) and the captured stdout/stderr output - * (which is the empty string by default). - */ - public Pair<Document, String> _findAlternateToolsXml(InputStream xml) throws IOException { - - final StringBuilder output = new StringBuilder(); - Document doc = super.findAlternateToolsXml(xml, new ErrorHandler() { - @Override - public void warning(SAXParseException exception) throws SAXException { - output.append("WARN: " + exception.getMessage()).append('\n'); - } - - @Override - public void fatalError(SAXParseException exception) throws SAXException { - output.append("FATAL: " + exception.getMessage()).append('\n'); - } - - @Override - public void error(SAXParseException exception) throws SAXException { - output.append("ERROR: " + exception.getMessage()).append('\n'); - } - }); - - return Pair.of(doc, output.toString()); - } - - public boolean _parsePackages(Document doc, String nsUri, ITaskMonitor monitor) { - return super.parsePackages(doc, nsUri, monitor); - } - - public int _getXmlSchemaVersion(InputStream xml) { - return super.getXmlSchemaVersion(xml); - } - - public String _validateXml(InputStream xml, String url, int version, - String[] outError, Boolean[] validatorFound) { - return super.validateXml(xml, url, version, outError, validatorFound); - } - - public Document _getDocument(InputStream xml, ITaskMonitor monitor) { - return super.getDocument(xml, monitor); - } - - } - - private MockSdkRepoSource mSource; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - mSource = new MockSdkRepoSource(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - - mSource = null; - } - - public void testFindAlternateToolsXml_Errors() throws Exception { - // Support null as input - Pair<Document, String> result = mSource._findAlternateToolsXml(null); - assertEquals(Pair.of((Document) null, ""), result); - - // Support an empty input - String str = ""; - ByteArrayInputStream input = new ByteArrayInputStream(str.getBytes()); - result = mSource._findAlternateToolsXml(input); - assertEquals( - Pair.of((Document) null, "FATAL: Premature end of file.\n"), - result); - - // Support a random string as input - str = "Some random string, not even HTML nor XML"; - input = new ByteArrayInputStream(str.getBytes()); - result = mSource._findAlternateToolsXml(input); - assertEquals( - Pair.of((Document) null, "FATAL: Content is not allowed in prolog.\n"), - result); - - // Support an HTML input, e.g. a typical 404 document as returned by DL - str = "<html><head> " + - "<meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\"> " + - "<title>404 Not Found</title> " + "<style><!--" + "body {font-family: arial,sans-serif}" + - "div.nav { ... blah blah more css here ... color: green}" + - "//--></style> " + "<script><!--" + "var rc=404;" + "//-->" + "</script> " + "</head> " + - "<body text=#000000 bgcolor=#ffffff> " + - "<table border=0 cellpadding=2 cellspacing=0 width=100%><tr><td rowspan=3 width=1% nowrap> " + - "<b><font face=times color=#0039b6 size=10>G</font><font face=times color=#c41200 size=10>o</font><font face=times color=#f3c518 size=10>o</font><font face=times color=#0039b6 size=10>g</font><font face=times color=#30a72f size=10>l</font><font face=times color=#c41200 size=10>e</font> </b> " + - "<td> </td></tr> " + - "<tr><td bgcolor=\"#3366cc\"><font face=arial,sans-serif color=\"#ffffff\"><b>Error</b></td></tr> " + - "<tr><td> </td></tr></table> " + "<blockquote> " + "<H1>Not Found</H1> " + - "The requested URL <code>/404</code> was not found on this server." + " " + "<p> " + - "</blockquote> " + - "<table width=100% cellpadding=0 cellspacing=0><tr><td bgcolor=\"#3366cc\"><img alt=\"\" width=1 height=4></td></tr></table> " + - "</body></html> "; - input = new ByteArrayInputStream(str.getBytes()); - result = mSource._findAlternateToolsXml(input); - assertEquals( - Pair.of((Document) null, "FATAL: The element type \"meta\" must be terminated by the matching end-tag \"</meta>\".\n"), - result); - - // Support some random XML document, totally unrelated to our sdk-repository schema - str = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + - "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"" + - " package=\"some.cool.app\" android:versionName=\"1.6.04\" android:versionCode=\"1604\">" + - " <application android:label=\"@string/app_name\" android:icon=\"@drawable/icon\"/>" + - "</manifest>"; - input = new ByteArrayInputStream(str.getBytes()); - result = mSource._findAlternateToolsXml(input); - assertEquals(Pair.of((Document) null, ""), result); - } - - /** - * Validate we can load a new schema version 3 using the "alternate future tool" mode. - */ - public void testFindAlternateToolsXml_3() throws Exception { - InputStream xmlStream = getTestResource( - "/com/android/sdklib/testdata/repository_sample_3.xml"); - - Pair<Document, String> result = mSource._findAlternateToolsXml(xmlStream); - assertNotNull(result.getFirst()); - assertEquals("", result.getSecond()); - MockMonitor monitor = new MockMonitor(); - assertTrue(mSource._parsePackages(result.getFirst(), SdkRepoConstants.NS_URI, monitor)); - - assertEquals("Found Android SDK Tools, revision 1\n" + - "Found Android SDK Tools, revision 42\n" + - "Found Android SDK Platform-tools, revision 3\n", - monitor.getCapturedVerboseLog()); - assertEquals("", monitor.getCapturedLog()); - assertEquals("", monitor.getCapturedErrorLog()); - - // check the packages we found... we expected to find 2 tool packages and 1 - // platform-tools package, with at least 1 archive each. - Package[] pkgs = mSource.getPackages(); - assertEquals(3, pkgs.length); - for (Package p : pkgs) { - assertTrue((p instanceof ToolPackage) || (p instanceof PlatformToolPackage)); - assertTrue(p.getArchives().length >= 1); - } - } - - /** - * Validate we can still load an old repository in schema version 1 - */ - public void testLoadXml_1() throws Exception { - InputStream xmlStream = getTestResource( - "/com/android/sdklib/testdata/repository_sample_1.xml"); - - // guess the version from the XML document - int version = mSource._getXmlSchemaVersion(xmlStream); - assertEquals(1, version); - - Boolean[] validatorFound = new Boolean[] { Boolean.FALSE }; - String[] validationError = new String[] { null }; - String url = "not-a-valid-url://" + SdkRepoConstants.URL_DEFAULT_FILENAME; - - String uri = mSource._validateXml(xmlStream, url, version, validationError, validatorFound); - assertEquals(Boolean.TRUE, validatorFound[0]); - assertEquals(null, validationError[0]); - assertEquals(SdkRepoConstants.getSchemaUri(1), uri); - - // Validation was successful, load the document - MockMonitor monitor = new MockMonitor(); - Document doc = mSource._getDocument(xmlStream, monitor); - assertNotNull(doc); - - // Get the packages - assertTrue(mSource._parsePackages(doc, uri, monitor)); - - assertEquals("Found SDK Platform Android 1.0, API 1, revision 3\n" + - "Found Documentation for Android SDK, API 1, revision 1\n" + - "Found My First add-on, Android API 1, revision 1\n" + - "Found SDK Platform Android 1.1, API 2, revision 12\n" + - "Found My Second add-on, Android API 2, revision 42\n" + - "Found SDK Platform Android Pastry Preview, revision 3\n" + - "Found Android SDK Tools, revision 1\n" + - "Found Documentation for Android SDK, API 2, revision 42\n" + - "Found Android SDK Tools, revision 42\n" + - "Found This add-on has no libraries, Android API 4, revision 3\n" + - "Found Usb Driver, revision 43\n", - monitor.getCapturedVerboseLog()); - assertEquals("", monitor.getCapturedLog()); - assertEquals("", monitor.getCapturedErrorLog()); - - // check the packages we found... we expected to find 11 packages with each at least - // one archive. - Package[] pkgs = mSource.getPackages(); - assertEquals(11, pkgs.length); - for (Package p : pkgs) { - assertTrue(p.getArchives().length >= 1); - } - - // Check the extra packages path, vendor, install folder - - final String osSdkPath = "SDK"; - final SdkManager sdkManager = new MockEmptySdkManager(osSdkPath); - - ArrayList<String> extraPaths = new ArrayList<String>(); - ArrayList<String> extraVendors = new ArrayList<String>(); - ArrayList<File> extraInstall = new ArrayList<File>(); - for (Package p : pkgs) { - if (p instanceof ExtraPackage) { - ExtraPackage ep = (ExtraPackage) p; - extraPaths.add(ep.getPath()); - extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay()); - extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager)); - } - } - assertEquals( - "[usb_driver]", - Arrays.toString(extraPaths.toArray())); - assertEquals( - "[/]", - Arrays.toString(extraVendors.toArray())); - assertEquals( - "[SDK/extras/usb_driver]".replace('/', File.separatorChar), - Arrays.toString(extraInstall.toArray())); - } - - /** - * Validate we can still load an old repository in schema version 2 - */ - public void testLoadXml_2() throws Exception { - InputStream xmlStream = getTestResource( - "/com/android/sdklib/testdata/repository_sample_2.xml"); - - // guess the version from the XML document - int version = mSource._getXmlSchemaVersion(xmlStream); - assertEquals(2, version); - - Boolean[] validatorFound = new Boolean[] { Boolean.FALSE }; - String[] validationError = new String[] { null }; - String url = "not-a-valid-url://" + SdkRepoConstants.URL_DEFAULT_FILENAME; - - String uri = mSource._validateXml(xmlStream, url, version, validationError, validatorFound); - assertEquals(Boolean.TRUE, validatorFound[0]); - assertEquals(null, validationError[0]); - assertEquals(SdkRepoConstants.getSchemaUri(2), uri); - - // Validation was successful, load the document - MockMonitor monitor = new MockMonitor(); - Document doc = mSource._getDocument(xmlStream, monitor); - assertNotNull(doc); - - // Get the packages - assertTrue(mSource._parsePackages(doc, uri, monitor)); - - assertEquals("Found SDK Platform Android 1.0, API 1, revision 3\n" + - "Found Documentation for Android SDK, API 1, revision 1\n" + - "Found My First add-on, Android API 1, revision 1\n" + - "Found SDK Platform Android 1.1, API 2, revision 12\n" + - "Found My Second add-on, Android API 2, revision 42\n" + - "Found SDK Platform Android Pastry Preview, revision 3\n" + - "Found Android SDK Tools, revision 1\n" + - "Found Documentation for Android SDK, API 2, revision 42\n" + - "Found Android SDK Tools, revision 42\n" + - "Found This add-on has no libraries, Android API 4, revision 3\n" + - "Found Usb Driver, revision 43 (Obsolete)\n" + - "Found Extra API Dep, revision 2 (Obsolete)\n" + - "Found Samples for SDK API 14, revision 24 (Obsolete)\n", - monitor.getCapturedVerboseLog()); - assertEquals("", monitor.getCapturedLog()); - assertEquals("", monitor.getCapturedErrorLog()); - - // check the packages we found... we expected to find 13 packages with each at least - // one archive. - Package[] pkgs = mSource.getPackages(); - assertEquals(13, pkgs.length); - for (Package p : pkgs) { - assertTrue(p.getArchives().length >= 1); - } - - // Check the extra packages path, vendor, install folder - - final String osSdkPath = "SDK"; - final SdkManager sdkManager = new MockEmptySdkManager(osSdkPath); - - ArrayList<String> extraPaths = new ArrayList<String>(); - ArrayList<String> extraVendors = new ArrayList<String>(); - ArrayList<File> extraInstall = new ArrayList<File>(); - for (Package p : pkgs) { - if (p instanceof ExtraPackage) { - ExtraPackage ep = (ExtraPackage) p; - extraPaths.add(ep.getPath()); - extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay()); - extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager)); - } - } - assertEquals( - "[extra_api_dep, usb_driver]", - Arrays.toString(extraPaths.toArray())); - assertEquals( - "[/, /]", - Arrays.toString(extraVendors.toArray())); - assertEquals( - "[SDK/extras/extra_api_dep, SDK/extras/usb_driver]".replace('/', File.separatorChar), - Arrays.toString(extraInstall.toArray())); - } - - /** - * Validate what we can load from repository in schema version 3 - */ - public void testLoadXml_3() throws Exception { - InputStream xmlStream = getTestResource( - "/com/android/sdklib/testdata/repository_sample_3.xml"); - - // guess the version from the XML document - int version = mSource._getXmlSchemaVersion(xmlStream); - assertEquals(3, version); - - Boolean[] validatorFound = new Boolean[] { Boolean.FALSE }; - String[] validationError = new String[] { null }; - String url = "not-a-valid-url://" + SdkRepoConstants.URL_DEFAULT_FILENAME; - - String uri = mSource._validateXml(xmlStream, url, version, validationError, validatorFound); - assertEquals(Boolean.TRUE, validatorFound[0]); - assertEquals(null, validationError[0]); - assertEquals(SdkRepoConstants.getSchemaUri(3), uri); - - // Validation was successful, load the document - MockMonitor monitor = new MockMonitor(); - Document doc = mSource._getDocument(xmlStream, monitor); - assertNotNull(doc); - - // Get the packages - assertTrue(mSource._parsePackages(doc, uri, monitor)); - - assertEquals("Found SDK Platform Android 1.0, API 1, revision 3\n" + - "Found Documentation for Android SDK, API 1, revision 1\n" + - "Found SDK Platform Android 1.1, API 2, revision 12\n" + - "Found SDK Platform Android Pastry Preview, revision 3\n" + - "Found Android SDK Tools, revision 1\n" + - "Found Documentation for Android SDK, API 2, revision 42\n" + - "Found Android SDK Tools, revision 42\n" + - "Found Android SDK Platform-tools, revision 3\n" + - "Found A USB Driver, revision 43 (Obsolete)\n" + - "Found Android Vendor Extra API Dep, revision 2 (Obsolete)\n" + - "Found Samples for SDK API 14, revision 24 (Obsolete)\n", - monitor.getCapturedVerboseLog()); - assertEquals("", monitor.getCapturedLog()); - assertEquals("", monitor.getCapturedErrorLog()); - - // check the packages we found... we expected to find 13 packages with each at least - // one archive. - Package[] pkgs = mSource.getPackages(); - assertEquals(11, pkgs.length); - for (Package p : pkgs) { - assertTrue(p.getArchives().length >= 1); - } - - // Check the extra packages path, vendor, install folder - - final String osSdkPath = "SDK"; - final SdkManager sdkManager = new MockEmptySdkManager(osSdkPath); - - ArrayList<String> extraPaths = new ArrayList<String>(); - ArrayList<String> extraVendors = new ArrayList<String>(); - ArrayList<File> extraInstall = new ArrayList<File>(); - for (Package p : pkgs) { - if (p instanceof ExtraPackage) { - ExtraPackage ep = (ExtraPackage) p; - extraPaths.add(ep.getPath()); - extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay()); - extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager)); - } - } - assertEquals( - "[extra_api_dep, usb_driver]", - Arrays.toString(extraPaths.toArray())); - assertEquals( - "[android_vendor/android_vendor, a/a]", - Arrays.toString(extraVendors.toArray())); - assertEquals( - "[SDK/extras/android_vendor/extra_api_dep, SDK/extras/a/usb_driver]" - .replace('/', File.separatorChar), - Arrays.toString(extraInstall.toArray())); - } - - /** - * Validate what we can load from repository in schema version 4 - */ - public void testLoadXml_4() throws Exception { - InputStream xmlStream = getTestResource( - "/com/android/sdklib/testdata/repository_sample_4.xml"); - - // guess the version from the XML document - int version = mSource._getXmlSchemaVersion(xmlStream); - assertEquals(4, version); - - Boolean[] validatorFound = new Boolean[] { Boolean.FALSE }; - String[] validationError = new String[] { null }; - String url = "not-a-valid-url://" + SdkRepoConstants.URL_DEFAULT_FILENAME; - - String uri = mSource._validateXml(xmlStream, url, version, validationError, validatorFound); - assertEquals(Boolean.TRUE, validatorFound[0]); - assertEquals(null, validationError[0]); - assertEquals(SdkRepoConstants.getSchemaUri(4), uri); - - // Validation was successful, load the document - MockMonitor monitor = new MockMonitor(); - Document doc = mSource._getDocument(xmlStream, monitor); - assertNotNull(doc); - - // Get the packages - assertTrue(mSource._parsePackages(doc, uri, monitor)); - - assertEquals("Found SDK Platform Android 1.0, API 1, revision 3\n" + - "Found Documentation for Android SDK, API 1, revision 1\n" + - "Found SDK Platform Android 1.1, API 2, revision 12\n" + - "Found SDK Platform Android Pastry Preview, revision 3\n" + - "Found Android SDK Tools, revision 1\n" + - "Found Documentation for Android SDK, API 2, revision 42\n" + - "Found Android SDK Tools, revision 42\n" + - "Found Android SDK Platform-tools, revision 3\n" + - "Found A USB Driver, revision 43 (Obsolete)\n" + - "Found Android Vendor Extra API Dep, revision 2 (Obsolete)\n" + - "Found Samples for SDK API 14, revision 24 (Obsolete)\n", - monitor.getCapturedVerboseLog()); - assertEquals("", monitor.getCapturedLog()); - assertEquals("", monitor.getCapturedErrorLog()); - - // check the packages we found... we expected to find 13 packages with each at least - // one archive. - // Note the order doesn't necessary match the one from the - // assertEquald(getCapturedVerboseLog) because packages are sorted using the - // Packages' sorting order, e.g. all platforms are sorted by descending API level, etc. - Package[] pkgs = mSource.getPackages(); - - assertEquals(11, pkgs.length); - for (Package p : pkgs) { - assertTrue(p.getArchives().length >= 1); - } - - // Check the layoutlib of the platform packages. - ArrayList<Pair<Integer, Integer>> layoutlibVers = new ArrayList<Pair<Integer,Integer>>(); - for (Package p : pkgs) { - if (p instanceof PlatformPackage) { - layoutlibVers.add(((PlatformPackage) p).getLayoutlibVersion()); - } - } - assertEquals( - "[Pair [first=1, second=0], " + // platform API 5 preview - "Pair [first=5, second=31415], " + // platform API 2 - "Pair [first=5, second=0]]", // platform API 1 - Arrays.toString(layoutlibVers.toArray())); - - // Check the extra packages path, vendor, install folder and project-files - - final String osSdkPath = "SDK"; - final SdkManager sdkManager = new MockEmptySdkManager(osSdkPath); - - ArrayList<String> extraPaths = new ArrayList<String>(); - ArrayList<String> extraVendors = new ArrayList<String>(); - ArrayList<File> extraInstall = new ArrayList<File>(); - ArrayList<ArrayList<String>> extraFilePaths = new ArrayList<ArrayList<String>>(); - for (Package p : pkgs) { - if (p instanceof ExtraPackage) { - ExtraPackage ep = (ExtraPackage) p; - extraPaths.add(ep.getPath()); - extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay()); - extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager)); - - ArrayList<String> filePaths = new ArrayList<String>(); - for (String filePath : ep.getProjectFiles()) { - filePaths.add(filePath); - } - extraFilePaths.add(filePaths); - } - } - assertEquals( - "[extra_api_dep, usb_driver]", - Arrays.toString(extraPaths.toArray())); - assertEquals( - "[android_vendor/android_vendor, a/a]", - Arrays.toString(extraVendors.toArray())); - assertEquals( - "[SDK/extras/android_vendor/extra_api_dep, SDK/extras/a/usb_driver]" - .replace('/', File.separatorChar), - Arrays.toString(extraInstall.toArray())); - assertEquals( - "[[v8/veggies_8.jar, readme.txt, dir1/dir 2 with space/mylib.jar], " + - "[]]", - Arrays.toString(extraFilePaths.toArray())); - } - - /** - * Validate what we can load from repository in schema version 5 - */ - public void testLoadXml_5() throws Exception { - InputStream xmlStream = getTestResource( - "/com/android/sdklib/testdata/repository_sample_5.xml"); - - // guess the version from the XML document - int version = mSource._getXmlSchemaVersion(xmlStream); - assertEquals(5, version); - - Boolean[] validatorFound = new Boolean[] { Boolean.FALSE }; - String[] validationError = new String[] { null }; - String url = "not-a-valid-url://" + SdkRepoConstants.URL_DEFAULT_FILENAME; - - String uri = mSource._validateXml(xmlStream, url, version, validationError, validatorFound); - assertEquals(Boolean.TRUE, validatorFound[0]); - assertEquals(null, validationError[0]); - assertEquals(SdkRepoConstants.getSchemaUri(5), uri); - - // Validation was successful, load the document - MockMonitor monitor = new MockMonitor(); - Document doc = mSource._getDocument(xmlStream, monitor); - assertNotNull(doc); - - // Get the packages - assertTrue(mSource._parsePackages(doc, uri, monitor)); - - assertEquals("Found SDK Platform Android 1.0, API 1, revision 3\n" + - "Found Documentation for Android SDK, API 1, revision 1\n" + - "Found Sources for Android SDK, API 1, revision 1\n" + - "Found SDK Platform Android 1.1, API 2, revision 12\n" + - "Found Intel x86 Atom System Image, Android API 2, revision 1\n" + - "Found ARM EABI v7a System Image, Android API 2, revision 2\n" + - "Found Sources for Android SDK, API 2, revision 2\n" + - "Found SDK Platform Android Pastry Preview, revision 3\n" + - "Found Android SDK Tools, revision 1\n" + - "Found Documentation for Android SDK, API 2, revision 42\n" + - "Found Android SDK Tools, revision 42\n" + - "Found Android SDK Platform-tools, revision 3\n" + - "Found A USB Driver, revision 43 (Obsolete)\n" + - "Found Android Vendor Extra API Dep, revision 2 (Obsolete)\n" + - "Found Samples for SDK API 14, revision 24 (Obsolete)\n" + - "Found ARM EABI System Image, Android API 42, revision 12\n" + - "Found Sources for Android SDK, API 42, revision 12\n", - monitor.getCapturedVerboseLog()); - assertEquals("", monitor.getCapturedLog()); - assertEquals("", monitor.getCapturedErrorLog()); - - // check the packages we found... we expected to find 13 packages with each at least - // one archive. - // Note the order doesn't necessary match the one from the - // assertEquald(getCapturedVerboseLog) because packages are sorted using the - // Packages' sorting order, e.g. all platforms are sorted by descending API level, etc. - Package[] pkgs = mSource.getPackages(); - - assertEquals(17, pkgs.length); - for (Package p : pkgs) { - assertTrue(p.getArchives().length >= 1); - } - - // Check the layoutlib & included-abi of the platform packages. - ArrayList<Pair<Integer, Integer>> layoutlibVers = new ArrayList<Pair<Integer,Integer>>(); - ArrayList<String> includedAbi = new ArrayList<String>(); - for (Package p : pkgs) { - if (p instanceof PlatformPackage) { - layoutlibVers.add(((PlatformPackage) p).getLayoutlibVersion()); - String abi = ((PlatformPackage) p).getIncludedAbi(); - includedAbi.add(abi == null ? "(null)" : abi); - } - } - assertEquals( - "[Pair [first=1, second=0], " + // platform API 5 preview - "Pair [first=5, second=31415], " + // platform API 2 - "Pair [first=5, second=0]]", // platform API 1 - Arrays.toString(layoutlibVers.toArray())); - assertEquals( - "[(null), " + // platform API 5 preview - "x86, " + // platform API 2 - "armeabi]", // platform API 1 - Arrays.toString(includedAbi.toArray())); - - // Check the extra packages path, vendor, install folder, project-files, old-paths - - final String osSdkPath = "SDK"; - final SdkManager sdkManager = new MockEmptySdkManager(osSdkPath); - - ArrayList<String> extraPaths = new ArrayList<String>(); - ArrayList<String> extraVendors = new ArrayList<String>(); - ArrayList<File> extraInstall = new ArrayList<File>(); - ArrayList<ArrayList<String>> extraFilePaths = new ArrayList<ArrayList<String>>(); - for (Package p : pkgs) { - if (p instanceof ExtraPackage) { - ExtraPackage ep = (ExtraPackage) p; - // combine path and old-paths in the form "path [old_path1, old_path2]" - extraPaths.add(ep.getPath() + " " + Arrays.toString(ep.getOldPaths())); - extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay()); - extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager)); - - ArrayList<String> filePaths = new ArrayList<String>(); - for (String filePath : ep.getProjectFiles()) { - filePaths.add(filePath); - } - extraFilePaths.add(filePaths); - } - } - assertEquals( - "[extra_api_dep [path1, old_path2, oldPath3], " + - "usb_driver []]", - Arrays.toString(extraPaths.toArray())); - assertEquals( - "[android_vendor/android_vendor, " + - "a/a]", - Arrays.toString(extraVendors.toArray())); - assertEquals( - ("[SDK/extras/android_vendor/extra_api_dep, " + - "SDK/extras/a/usb_driver]").replace('/', File.separatorChar), - Arrays.toString(extraInstall.toArray())); - assertEquals( - "[[v8/veggies_8.jar, readme.txt, dir1/dir 2 with space/mylib.jar], " + - "[]]", - Arrays.toString(extraFilePaths.toArray())); - - // Check the system-image packages - ArrayList<String> sysImgVersionAbi = new ArrayList<String>(); - for (Package p : pkgs) { - if (p instanceof SystemImagePackage) { - SystemImagePackage sip = (SystemImagePackage) p; - String v = sip.getAndroidVersion().getApiString(); - String a = sip.getAbi(); - sysImgVersionAbi.add(String.format("%1$s %2$s", v, a)); //$NON-NLS-1$ - } - } - assertEquals( - "[42 armeabi, " + - "2 armeabi-v7a, " + - "2 x86]", - Arrays.toString(sysImgVersionAbi.toArray())); - - // Check the source packages - ArrayList<String> sourceVersion = new ArrayList<String>(); - for (Package p : pkgs) { - if (p instanceof SourcePackage) { - SourcePackage sp = (SourcePackage) p; - String v = sp.getAndroidVersion().getApiString(); - sourceVersion.add(v); - } - } - assertEquals( - "[42, 2, 1]", - Arrays.toString(sourceVersion.toArray())); - } - - /** - * Validate what we can load from repository in schema version 6 - */ - public void testLoadXml_6() throws Exception { - InputStream xmlStream = getTestResource( - "/com/android/sdklib/testdata/repository_sample_6.xml"); - - // guess the version from the XML document - int version = mSource._getXmlSchemaVersion(xmlStream); - assertEquals(6, version); - - Boolean[] validatorFound = new Boolean[] { Boolean.FALSE }; - String[] validationError = new String[] { null }; - String url = "not-a-valid-url://" + SdkRepoConstants.URL_DEFAULT_FILENAME; - - String uri = mSource._validateXml(xmlStream, url, version, validationError, validatorFound); - assertEquals(Boolean.TRUE, validatorFound[0]); - assertEquals(null, validationError[0]); - assertEquals(SdkRepoConstants.getSchemaUri(6), uri); - - // Validation was successful, load the document - MockMonitor monitor = new MockMonitor(); - Document doc = mSource._getDocument(xmlStream, monitor); - assertNotNull(doc); - - // Get the packages - assertTrue(mSource._parsePackages(doc, uri, monitor)); - - assertEquals("Found SDK Platform Android 1.0, API 1, revision 3\n" + - "Found Documentation for Android SDK, API 1, revision 1\n" + - "Found Sources for Android SDK, API 1, revision 1\n" + - "Found SDK Platform Android 1.1, API 2, revision 12\n" + - "Found Intel x86 Atom System Image, Android API 2, revision 1\n" + - "Found ARM EABI v7a System Image, Android API 2, revision 2\n" + - "Found Sources for Android SDK, API 2, revision 2\n" + - "Found SDK Platform Android Pastry Preview, revision 3\n" + - "Found Android SDK Tools, revision 1\n" + - "Found Documentation for Android SDK, API 2, revision 42\n" + - "Found Android SDK Tools, revision 42\n" + - "Found Android SDK Platform-tools, revision 3\n" + - "Found Samples for SDK API 14, revision 24 (Obsolete)\n" + - "Found ARM EABI System Image, Android API 42, revision 12\n" + - "Found MIPS System Image, Android API 42, revision 12\n" + - "Found Sources for Android SDK, API 42, revision 12\n", - monitor.getCapturedVerboseLog()); - assertEquals("", monitor.getCapturedLog()); - assertEquals("", monitor.getCapturedErrorLog()); - - // check the packages we found... we expected to find 13 packages with each at least - // one archive. - // Note the order doesn't necessary match the one from the - // assertEquald(getCapturedVerboseLog) because packages are sorted using the - // Packages' sorting order, e.g. all platforms are sorted by descending API level, etc. - Package[] pkgs = mSource.getPackages(); - - assertEquals(16, pkgs.length); - for (Package p : pkgs) { - assertTrue(p.getArchives().length >= 1); - } - - // Check the layoutlib & included-abi of the platform packages. - ArrayList<Pair<Integer, Integer>> layoutlibVers = new ArrayList<Pair<Integer,Integer>>(); - ArrayList<String> includedAbi = new ArrayList<String>(); - for (Package p : pkgs) { - if (p instanceof PlatformPackage) { - layoutlibVers.add(((PlatformPackage) p).getLayoutlibVersion()); - String abi = ((PlatformPackage) p).getIncludedAbi(); - includedAbi.add(abi == null ? "(null)" : abi); - } - } - assertEquals( - "[Pair [first=1, second=0], " + // platform API 5 preview - "Pair [first=5, second=31415], " + // platform API 2 - "Pair [first=5, second=0]]", // platform API 1 - Arrays.toString(layoutlibVers.toArray())); - assertEquals( - "[(null), " + // platform API 5 preview - "x86, " + // platform API 2 - "armeabi]", // platform API 1 - Arrays.toString(includedAbi.toArray())); - - // Check the extra packages path, vendor, install folder, project-files, old-paths - - final String osSdkPath = "SDK"; - final SdkManager sdkManager = new MockEmptySdkManager(osSdkPath); - - ArrayList<String> extraPaths = new ArrayList<String>(); - ArrayList<String> extraVendors = new ArrayList<String>(); - ArrayList<File> extraInstall = new ArrayList<File>(); - ArrayList<ArrayList<String>> extraFilePaths = new ArrayList<ArrayList<String>>(); - for (Package p : pkgs) { - if (p instanceof ExtraPackage) { - ExtraPackage ep = (ExtraPackage) p; - // combine path and old-paths in the form "path [old_path1, old_path2]" - extraPaths.add(ep.getPath() + " " + Arrays.toString(ep.getOldPaths())); - extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay()); - extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager)); - - ArrayList<String> filePaths = new ArrayList<String>(); - for (String filePath : ep.getProjectFiles()) { - filePaths.add(filePath); - } - extraFilePaths.add(filePaths); - } - } - - // There are no extra packages anymore in repository-6 - assertEquals("[]", Arrays.toString(extraPaths.toArray())); - assertEquals("[]", Arrays.toString(extraVendors.toArray())); - assertEquals("[]", Arrays.toString(extraInstall.toArray())); - assertEquals("[]", Arrays.toString(extraFilePaths.toArray())); - - // Check the system-image packages - ArrayList<String> sysImgVersionAbi = new ArrayList<String>(); - for (Package p : pkgs) { - if (p instanceof SystemImagePackage) { - SystemImagePackage sip = (SystemImagePackage) p; - String v = sip.getAndroidVersion().getApiString(); - String a = sip.getAbi(); - sysImgVersionAbi.add(String.format("%1$s %2$s", v, a)); //$NON-NLS-1$ - } - } - assertEquals( - "[42 armeabi, " + - "42 mips, " + - "2 armeabi-v7a, " + - "2 x86]", - Arrays.toString(sysImgVersionAbi.toArray())); - - // Check the source packages - ArrayList<String> sourceVersion = new ArrayList<String>(); - for (Package p : pkgs) { - if (p instanceof SourcePackage) { - SourcePackage sp = (SourcePackage) p; - String v = sp.getAndroidVersion().getApiString(); - sourceVersion.add(v); - } - } - assertEquals( - "[42, 2, 1]", - Arrays.toString(sourceVersion.toArray())); - } - - /** - * Validate what we can load from repository in schema version 6 - */ - public void testLoadXml_7() throws Exception { - InputStream xmlStream = getTestResource( - "/com/android/sdklib/testdata/repository_sample_7.xml"); - - // guess the version from the XML document - int version = mSource._getXmlSchemaVersion(xmlStream); - assertEquals(7, version); - - Boolean[] validatorFound = new Boolean[] { Boolean.FALSE }; - String[] validationError = new String[] { null }; - String url = "not-a-valid-url://" + SdkRepoConstants.URL_DEFAULT_FILENAME; - - String uri = mSource._validateXml(xmlStream, url, version, validationError, validatorFound); - assertEquals(Boolean.TRUE, validatorFound[0]); - assertEquals(null, validationError[0]); - assertEquals(SdkRepoConstants.getSchemaUri(7), uri); - - // Validation was successful, load the document - MockMonitor monitor = new MockMonitor(); - Document doc = mSource._getDocument(xmlStream, monitor); - assertNotNull(doc); - - // Get the packages - assertTrue(mSource._parsePackages(doc, uri, monitor)); - - assertEquals("Found SDK Platform Android 1.0, API 1, revision 3\n" + - "Found Documentation for Android SDK, API 1, revision 1\n" + - "Found Sources for Android SDK, API 1, revision 1\n" + - "Found SDK Platform Android 1.1, API 2, revision 12\n" + - "Found Intel x86 Atom System Image, Android API 2, revision 1\n" + - "Found ARM EABI v7a System Image, Android API 2, revision 2\n" + - "Found Sources for Android SDK, API 2, revision 2\n" + - "Found SDK Platform Android Pastry Preview, revision 3\n" + - "Found Android SDK Tools, revision 1.2.3 rc4\n" + - "Found Documentation for Android SDK, API 2, revision 42\n" + - "Found Android SDK Tools, revision 42\n" + - "Found Android SDK Platform-tools, revision 3 rc5\n" + - "Found Samples for SDK API 14, revision 24 (Obsolete)\n" + - "Found Samples for SDK API 14, revision 25 (Obsolete)\n" + - "Found ARM EABI System Image, Android API 42, revision 12\n" + - "Found MIPS System Image, Android API 42, revision 12\n" + - "Found Sources for Android SDK, API 42, revision 12\n", - monitor.getCapturedVerboseLog()); - assertEquals("", monitor.getCapturedLog()); - assertEquals("", monitor.getCapturedErrorLog()); - - // check the packages we found... we expected to find 13 packages with each at least - // one archive. - // Note the order doesn't necessary match the one from the - // assertEquald(getCapturedVerboseLog) because packages are sorted using the - // Packages' sorting order, e.g. all platforms are sorted by descending API level, etc. - Package[] pkgs = mSource.getPackages(); - - assertEquals(17, pkgs.length); - for (Package p : pkgs) { - assertTrue(p.getArchives().length >= 1); - } - - // Check the layoutlib & included-abi of the platform packages. - ArrayList<Pair<Integer, Integer>> layoutlibVers = new ArrayList<Pair<Integer,Integer>>(); - ArrayList<String> includedAbi = new ArrayList<String>(); - for (Package p : pkgs) { - if (p instanceof PlatformPackage) { - layoutlibVers.add(((PlatformPackage) p).getLayoutlibVersion()); - String abi = ((PlatformPackage) p).getIncludedAbi(); - includedAbi.add(abi == null ? "(null)" : abi); - } - } - assertEquals( - "[Pair [first=1, second=0], " + // platform API 5 preview - "Pair [first=5, second=31415], " + // platform API 2 - "Pair [first=5, second=0]]", // platform API 1 - Arrays.toString(layoutlibVers.toArray())); - assertEquals( - "[(null), " + // platform API 5 preview - "x86, " + // platform API 2 - "armeabi]", // platform API 1 - Arrays.toString(includedAbi.toArray())); - - // Check the extra packages path, vendor, install folder, project-files, old-paths - - final String osSdkPath = "SDK"; - final SdkManager sdkManager = new MockEmptySdkManager(osSdkPath); - - ArrayList<String> extraPaths = new ArrayList<String>(); - ArrayList<String> extraVendors = new ArrayList<String>(); - ArrayList<File> extraInstall = new ArrayList<File>(); - ArrayList<ArrayList<String>> extraFilePaths = new ArrayList<ArrayList<String>>(); - for (Package p : pkgs) { - if (p instanceof ExtraPackage) { - ExtraPackage ep = (ExtraPackage) p; - // combine path and old-paths in the form "path [old_path1, old_path2]" - extraPaths.add(ep.getPath() + " " + Arrays.toString(ep.getOldPaths())); - extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay()); - extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager)); - - ArrayList<String> filePaths = new ArrayList<String>(); - for (String filePath : ep.getProjectFiles()) { - filePaths.add(filePath); - } - extraFilePaths.add(filePaths); - } - } - - // There are no extra packages anymore in repository-6 - assertEquals("[]", Arrays.toString(extraPaths.toArray())); - assertEquals("[]", Arrays.toString(extraVendors.toArray())); - assertEquals("[]", Arrays.toString(extraInstall.toArray())); - assertEquals("[]", Arrays.toString(extraFilePaths.toArray())); - - - // Check the system-image packages - ArrayList<String> sysImgVersionAbi = new ArrayList<String>(); - for (Package p : pkgs) { - if (p instanceof SystemImagePackage) { - SystemImagePackage sip = (SystemImagePackage) p; - String v = sip.getAndroidVersion().getApiString(); - String a = sip.getAbi(); - sysImgVersionAbi.add(String.format("%1$s %2$s", v, a)); //$NON-NLS-1$ - } - } - assertEquals( - "[42 armeabi, " + - "42 mips, " + - "2 armeabi-v7a, " + - "2 x86]", - Arrays.toString(sysImgVersionAbi.toArray())); - - - // Check the source packages - ArrayList<String> sourceVersion = new ArrayList<String>(); - for (Package p : pkgs) { - if (p instanceof SourcePackage) { - SourcePackage sp = (SourcePackage) p; - String v = sp.getAndroidVersion().getApiString(); - sourceVersion.add(v); - } - } - assertEquals( - "[42, 2, 1]", - Arrays.toString(sourceVersion.toArray())); - - - // Check the min-tools-rev - ArrayList<String> minToolsRevs = new ArrayList<String>(); - for (Package p : pkgs) { - if (p instanceof IMinToolsDependency) { - minToolsRevs.add(p.getListDescription() + ": " + - ((IMinToolsDependency) p).getMinToolsRevision().toShortString()); - } - } - assertEquals( - "[SDK Platform Android Pastry Preview: 0, " + - "SDK Platform Android 1.1: 0, " + - "SDK Platform Android 1.0: 2.0.1, " + - "Samples for SDK API 14 (Obsolete): 5, " + - "Samples for SDK API 14 (Obsolete): 5.1.2 rc3]", - Arrays.toString(minToolsRevs.toArray())); - - - // Check the min-platform-tools-rev - ArrayList<String> minPlatToolsRevs = new ArrayList<String>(); - for (Package p : pkgs) { - if (p instanceof IMinPlatformToolsDependency) { - minPlatToolsRevs.add(p.getListDescription() + ": " + - ((IMinPlatformToolsDependency) p).getMinPlatformToolsRevision().toShortString()); - } - } - assertEquals( - "[Android SDK Tools: 4, " + - "Android SDK Tools: 4 rc5]", - Arrays.toString(minPlatToolsRevs.toArray())); - } - - /** - * Returns an SdkLib file resource as a {@link ByteArrayInputStream}, - * which has the advantage that we can use {@link InputStream#reset()} on it - * at any time to read it multiple times. - * <p/> - * The default for getResourceAsStream() is to return a {@link FileInputStream} that - * does not support reset(), yet we need it in the tested code. - * - * @throws IOException if some I/O read fails - */ - private ByteArrayInputStream getTestResource(String filename) throws IOException { - InputStream xmlStream = this.getClass().getResourceAsStream(filename); - - try { - byte[] data = new byte[8192]; - int offset = 0; - int n; - - while ((n = xmlStream.read(data, offset, data.length - offset)) != -1) { - offset += n; - - if (offset == data.length) { - byte[] newData = new byte[offset + 8192]; - System.arraycopy(data, 0, newData, 0, offset); - data = newData; - } - } - - return new ByteArrayInputStream(data, 0, offset); - } finally { - if (xmlStream != null) { - xmlStream.close(); - } - } - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/sources/SdkSourcePropertiesTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/sources/SdkSourcePropertiesTest.java deleted file mode 100755 index 6313e69..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/sources/SdkSourcePropertiesTest.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.eclipse.org/org/documents/epl-v10.php - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.sources; - - -import com.android.sdklib.internal.repository.sources.SdkSourceProperties; - -import junit.framework.TestCase; - -public class SdkSourcePropertiesTest extends TestCase { - - private static class MockSdkSourceProperties extends SdkSourceProperties { - private int mLoadCount; - private int mSaveCount; - - public MockSdkSourceProperties() { - clear(); - } - - public int getLoadCount() { - return mLoadCount; - } - - public int getSaveCount() { - return mSaveCount; - } - - @Override - protected boolean loadProperties() { - // Don't actually load anthing. - mLoadCount++; - return false; - } - - @Override - protected void saveLocked() { - // Don't actually save anything. - mSaveCount++; - } - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - public final void testSdkSourceProperties() { - MockSdkSourceProperties m = new MockSdkSourceProperties(); - - assertEquals(0, m.getLoadCount()); - assertEquals(0, m.getSaveCount()); - assertEquals( - "<SdkSourceProperties>", - m.toString()); - - assertNull(m.getProperty(SdkSourceProperties.KEY_DISABLED, "http://example.com/1", null)); - assertEquals("None", - m.getProperty(SdkSourceProperties.KEY_NAME, "http://example.com/2", "None")); - assertEquals(1, m.getLoadCount()); - assertEquals(0, m.getSaveCount()); - assertEquals( - "<SdkSourceProperties\n" + - "@version@ = 1>", - m.toString()); - - m.setProperty(SdkSourceProperties.KEY_DISABLED, "http://example.com/1", "disabled"); - assertEquals("disabled", - m.getProperty(SdkSourceProperties.KEY_DISABLED, "http://example.com/1", "None")); - assertNull(m.getProperty(SdkSourceProperties.KEY_NAME, "http://example.com/1", null)); - assertEquals( - "<SdkSourceProperties\n" + - "@disabled@http://example.com/1 = disabled\n" + - "@version@ = 1>", - m.toString()); - - m.setProperty(SdkSourceProperties.KEY_NAME, "http://example.com/2", "Site Name"); - assertEquals("Site Name", - m.getProperty(SdkSourceProperties.KEY_NAME, "http://example.com/2", null)); - assertNull(m.getProperty(SdkSourceProperties.KEY_DISABLED, "http://example.com/2", null)); - assertEquals(1, m.getLoadCount()); - assertEquals(0, m.getSaveCount()); - assertEquals( - "<SdkSourceProperties\n" + - "@disabled@http://example.com/1 = disabled\n" + - "@name@http://example.com/2 = Site Name\n" + - "@version@ = 1>", - m.toString()); - - m.save(); - assertEquals(1, m.getSaveCount()); - - // saving a 2nd time doesn't do anything if no property has been modified - m.save(); - assertEquals(1, m.getSaveCount()); - - // setting things to the same value doesn't actually mark the properties as modified - m.setProperty(SdkSourceProperties.KEY_DISABLED, "http://example.com/1", "disabled"); - m.setProperty(SdkSourceProperties.KEY_NAME, "http://example.com/2", "Site Name"); - m.save(); - assertEquals(1, m.getSaveCount()); - - m.setProperty(SdkSourceProperties.KEY_DISABLED, "http://example.com/1", "not disabled"); - m.setProperty(SdkSourceProperties.KEY_NAME, "http://example.com/2", "New Name"); - assertEquals( - "<SdkSourceProperties\n" + - "@disabled@http://example.com/1 = not disabled\n" + - "@name@http://example.com/2 = New Name\n" + - "@version@ = 1>", - m.toString()); - m.save(); - assertEquals(2, m.getSaveCount()); - - // setting a value to null deletes it - m.setProperty(SdkSourceProperties.KEY_NAME, "http://example.com/2", null); - assertEquals( - "<SdkSourceProperties\n" + - "@disabled@http://example.com/1 = not disabled\n" + - "@version@ = 1>", - m.toString()); - - m.save(); - assertEquals(1, m.getLoadCount()); - assertEquals(3, m.getSaveCount()); - } - -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/sources/SdkSysImgSourceTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/sources/SdkSysImgSourceTest.java deleted file mode 100755 index c080d11..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/sources/SdkSysImgSourceTest.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.eclipse.org/org/documents/epl-v10.php - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.internal.repository.sources; - -import com.android.sdklib.internal.repository.ITaskMonitor; -import com.android.sdklib.internal.repository.MockMonitor; -import com.android.sdklib.internal.repository.packages.Package; -import com.android.sdklib.internal.repository.packages.SystemImagePackage; -import com.android.sdklib.repository.SdkSysImgConstants; - -import org.w3c.dom.Document; - -import java.io.ByteArrayInputStream; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Arrays; - -import junit.framework.TestCase; - -/** - * Tests for {@link SdkSysImgSource}. - */ -public class SdkSysImgSourceTest extends TestCase { - - /** - * An internal helper class to give us visibility to the protected members we want - * to test. - */ - private static class MockSdkSysImgSource extends SdkSysImgSource { - public MockSdkSysImgSource() { - super("fake-url", null /*uiName*/); - } - - public Document _findAlternateToolsXml(InputStream xml) { - return super.findAlternateToolsXml(xml); - } - - public boolean _parsePackages(Document doc, String nsUri, ITaskMonitor monitor) { - return super.parsePackages(doc, nsUri, monitor); - } - - public int _getXmlSchemaVersion(InputStream xml) { - return super.getXmlSchemaVersion(xml); - } - - public String _validateXml(InputStream xml, String url, int version, - String[] outError, Boolean[] validatorFound) { - return super.validateXml(xml, url, version, outError, validatorFound); - } - - public Document _getDocument(InputStream xml, ITaskMonitor monitor) { - return super.getDocument(xml, monitor); - } - - } - - private MockSdkSysImgSource mSource; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - mSource = new MockSdkSysImgSource(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - - mSource = null; - } - - /** - * Validate that findAlternateToolsXml doesn't work for this source even - * when trying to load a valid xml. That's because finding alternate tools - * is not supported by this kind of source. - */ - public void testFindAlternateToolsXml_1() throws Exception { - InputStream xmlStream = - getTestResource("/com/android/sdklib/testdata/sys_img_sample_1.xml"); - - Document result = mSource._findAlternateToolsXml(xmlStream); - assertNull(result); - } - - /** - * Validate we can load a valid schema version 1 - */ - public void testLoadSysImgXml_1() throws Exception { - InputStream xmlStream = - getTestResource("/com/android/sdklib/testdata/sys_img_sample_1.xml"); - - // guess the version from the XML document - int version = mSource._getXmlSchemaVersion(xmlStream); - assertEquals(1, version); - - Boolean[] validatorFound = new Boolean[] { Boolean.FALSE }; - String[] validationError = new String[] { null }; - String url = "not-a-valid-url://" + SdkSysImgConstants.URL_DEFAULT_FILENAME; - - String uri = mSource._validateXml(xmlStream, url, version, validationError, validatorFound); - assertEquals(Boolean.TRUE, validatorFound[0]); - assertEquals(null, validationError[0]); - assertEquals(SdkSysImgConstants.getSchemaUri(1), uri); - - // Validation was successful, load the document - MockMonitor monitor = new MockMonitor(); - Document doc = mSource._getDocument(xmlStream, monitor); - assertNotNull(doc); - - // Get the packages - assertTrue(mSource._parsePackages(doc, uri, monitor)); - - assertEquals( - "Found Intel x86 Atom System Image, Android API 2, revision 1\n" + - "Found ARM EABI v7a System Image, Android API 2, revision 2\n" + - "Found ARM EABI System Image, Android API 42, revision 12\n" + - "Found MIPS System Image, Android API 42, revision 12\n", - monitor.getCapturedVerboseLog()); - assertEquals("", monitor.getCapturedLog()); - assertEquals("", monitor.getCapturedErrorLog()); - - // check the packages we found... - // Note the order doesn't necessary match the one from the - // assertEquald(getCapturedVerboseLog) because packages are sorted using the - // Packages' sorting order, e.g. all platforms are sorted by descending API level, etc. - - Package[] pkgs = mSource.getPackages(); - - assertEquals(4, pkgs.length); - for (Package p : pkgs) { - // We expected to find packages with each at least one archive. - assertTrue(p.getArchives().length >= 1); - // And only system images are supported by this source - assertTrue(p instanceof SystemImagePackage); - } - - // Check the system-image packages - ArrayList<String> sysImgVersionAbi = new ArrayList<String>(); - for (Package p : pkgs) { - if (p instanceof SystemImagePackage) { - SystemImagePackage sip = (SystemImagePackage) p; - String v = sip.getAndroidVersion().getApiString(); - String a = sip.getAbi(); - sysImgVersionAbi.add(String.format("%1$s %2$s", v, a)); //$NON-NLS-1$ - } - } - assertEquals( - "[42 armeabi, " + - "42 mips, " + - "2 armeabi-v7a, " + - "2 x86]", - Arrays.toString(sysImgVersionAbi.toArray())); - - } - - - //----- - - /** - * Returns an SdkLib file resource as a {@link ByteArrayInputStream}, - * which has the advantage that we can use {@link InputStream#reset()} on it - * at any time to read it multiple times. - * <p/> - * The default for getResourceAsStream() is to return a {@link FileInputStream} that - * does not support reset(), yet we need it in the tested code. - * - * @throws IOException if some I/O read fails - */ - private ByteArrayInputStream getTestResource(String filename) throws IOException { - InputStream xmlStream = this.getClass().getResourceAsStream(filename); - - try { - byte[] data = new byte[8192]; - int offset = 0; - int n; - - while ((n = xmlStream.read(data, offset, data.length - offset)) != -1) { - offset += n; - - if (offset == data.length) { - byte[] newData = new byte[offset + 8192]; - System.arraycopy(data, 0, newData, 0, offset); - data = newData; - } - } - - return new ByteArrayInputStream(data, 0, offset); - } finally { - if (xmlStream != null) { - xmlStream.close(); - } - } - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/io/MockFileOp.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/io/MockFileOp.java deleted file mode 100755 index cbe5fdd..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/io/MockFileOp.java +++ /dev/null @@ -1,469 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.io; - -import com.android.SdkConstants; -import com.android.annotations.NonNull; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; -import java.util.Set; -import java.util.TreeSet; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - - -/** - * Mock version of {@link FileOp} that wraps some common {@link File} - * operations on files and folders. - * <p/> - * This version does not perform any file operation. Instead it records a textual - * representation of all the file operations performed. - * <p/> - * To avoid cross-platform path issues (e.g. Windows path), the methods here should - * always use rooted (aka absolute) unix-looking paths, e.g. "/dir1/dir2/file3". - * When processing {@link File}, you can convert them using {@link #getAgnosticAbsPath(File)}. - */ -public class MockFileOp implements IFileOp { - - private final Set<String> mExistinfFiles = new TreeSet<String>(); - private final Set<String> mExistinfFolders = new TreeSet<String>(); - private final List<StringOutputStream> mOutputStreams = new ArrayList<StringOutputStream>(); - - public MockFileOp() { - } - - /** Resets the internal state, as if the object had been newly created. */ - public void reset() { - mExistinfFiles.clear(); - mExistinfFolders.clear(); - } - - public String getAgnosticAbsPath(File file) { - return getAgnosticAbsPath(file.getAbsolutePath()); - } - - public String getAgnosticAbsPath(String path) { - if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_WINDOWS) { - // Try to convert the windows-looking path to a unix-looking one - path = path.replace('\\', '/'); - path = path.replace("C:", ""); //$NON-NLS-1$ //$NON-NLS-2$ - } - return path; - } - - /** - * Records a new absolute file path. - * Parent folders are not automatically created. - */ - public void recordExistingFile(File file) { - mExistinfFiles.add(getAgnosticAbsPath(file)); - } - - /** - * Records a new absolute file path. - * Parent folders are not automatically created. - * <p/> - * The syntax should always look "unix-like", e.g. "/dir/file". - * On Windows that means you'll want to use {@link #getAgnosticAbsPath(File)}. - * @param absFilePath A unix-like file path, e.g. "/dir/file" - */ - public void recordExistingFile(String absFilePath) { - mExistinfFiles.add(absFilePath); - } - - /** - * Records a new absolute folder path. - * Parent folders are not automatically created. - */ - public void recordExistingFolder(File folder) { - mExistinfFolders.add(getAgnosticAbsPath(folder)); - } - - /** - * Records a new absolute folder path. - * Parent folders are not automatically created. - * <p/> - * The syntax should always look "unix-like", e.g. "/dir/file". - * On Windows that means you'll want to use {@link #getAgnosticAbsPath(File)}. - * @param absFolderPath A unix-like folder path, e.g. "/dir/file" - */ - public void recordExistingFolder(String absFolderPath) { - mExistinfFolders.add(absFolderPath); - } - - /** - * Returns the list of paths added using {@link #recordExistingFile(String)} - * and eventually updated by {@link #delete(File)} operations. - * <p/> - * The returned list is sorted by alphabetic absolute path string. - */ - public String[] getExistingFiles() { - return mExistinfFiles.toArray(new String[mExistinfFiles.size()]); - } - - /** - * Returns the list of folder paths added using {@link #recordExistingFolder(String)} - * and eventually updated {@link #delete(File)} or {@link #mkdirs(File)} operations. - * <p/> - * The returned list is sorted by alphabetic absolute path string. - */ - public String[] getExistingFolders() { - return mExistinfFolders.toArray(new String[mExistinfFolders.size()]); - } - - /** - * Returns the {@link StringOutputStream#toString()} as an array, in creation order. - * Array can be empty but not null. - */ - public String[] getOutputStreams() { - int n = mOutputStreams.size(); - String[] result = new String[n]; - for (int i = 0; i < n; i++) { - result[i] = mOutputStreams.get(i).toString(); - } - return result; - } - - /** - * Helper to delete a file or a directory. - * For a directory, recursively deletes all of its content. - * Files that cannot be deleted right away are marked for deletion on exit. - * The argument can be null. - */ - @Override - public void deleteFileOrFolder(File fileOrFolder) { - if (fileOrFolder != null) { - if (isDirectory(fileOrFolder)) { - // Must delete content recursively first - for (File item : listFiles(fileOrFolder)) { - deleteFileOrFolder(item); - } - } - delete(fileOrFolder); - } - } - - /** - * {@inheritDoc} - * <p/> - * <em>Note: this mock version does nothing.</em> - */ - @Override - public void setExecutablePermission(File file) throws IOException { - // pass - } - - /** - * {@inheritDoc} - * <p/> - * <em>Note: this mock version does nothing.</em> - */ - @Override - public void setReadOnly(File file) { - // pass - } - - /** - * {@inheritDoc} - * <p/> - * <em>Note: this mock version does nothing.</em> - */ - @Override - public void copyFile(File source, File dest) throws IOException { - // pass - } - - /** - * Checks whether 2 binary files are the same. - * - * @param source the source file to copy - * @param destination the destination file to write - * @throws FileNotFoundException if the source files don't exist. - * @throws IOException if there's a problem reading the files. - */ - @Override - public boolean isSameFile(File source, File destination) throws IOException { - throw new UnsupportedOperationException("MockFileUtils.isSameFile is not supported."); //$NON-NLS-1$ - } - - /** Invokes {@link File#isFile()} on the given {@code file}. */ - @Override - public boolean isFile(File file) { - String path = getAgnosticAbsPath(file); - return mExistinfFiles.contains(path); - } - - /** Invokes {@link File#isDirectory()} on the given {@code file}. */ - @Override - public boolean isDirectory(File file) { - String path = getAgnosticAbsPath(file); - if (mExistinfFolders.contains(path)) { - return true; - } - - // If we defined a file or folder as a child of the requested file path, - // then the directory exists implicitely. - Pattern pathRE = Pattern.compile( - Pattern.quote(path + (path.endsWith("/") ? "" : '/')) + //$NON-NLS-1$ //$NON-NLS-2$ - ".*"); //$NON-NLS-1$ - - for (String folder : mExistinfFolders) { - if (pathRE.matcher(folder).matches()) { - return true; - } - } - for (String filePath : mExistinfFiles) { - if (pathRE.matcher(filePath).matches()) { - return true; - } - } - - return false; - } - - /** Invokes {@link File#exists()} on the given {@code file}. */ - @Override - public boolean exists(File file) { - return isFile(file) || isDirectory(file); - } - - /** Invokes {@link File#length()} on the given {@code file}. */ - @Override - public long length(File file) { - throw new UnsupportedOperationException("MockFileUtils.length is not supported."); //$NON-NLS-1$ - } - - @Override - public boolean delete(File file) { - String path = getAgnosticAbsPath(file); - - if (mExistinfFiles.remove(path)) { - return true; - } - - boolean hasSubfiles = false; - for (String folder : mExistinfFolders) { - if (folder.startsWith(path) && !folder.equals(path)) { - // the File.delete operation is not recursive and would fail to remove - // a root dir that is not empty. - return false; - } - } - if (!hasSubfiles) { - for (String filePath : mExistinfFiles) { - if (filePath.startsWith(path) && !filePath.equals(path)) { - // the File.delete operation is not recursive and would fail to remove - // a root dir that is not empty. - return false; - } - } - } - - return mExistinfFolders.remove(path); - } - - /** Invokes {@link File#mkdirs()} on the given {@code file}. */ - @Override - public boolean mkdirs(File file) { - for (; file != null; file = file.getParentFile()) { - String path = getAgnosticAbsPath(file); - mExistinfFolders.add(path); - } - return true; - } - - /** - * Invokes {@link File#listFiles()} on the given {@code file}. - * The returned list is sorted by alphabetic absolute path string. - */ - @Override - public File[] listFiles(File file) { - TreeSet<File> files = new TreeSet<File>(); - - String path = getAgnosticAbsPath(file); - Pattern pathRE = Pattern.compile( - Pattern.quote(path + (path.endsWith("/") ? "" : '/')) + //$NON-NLS-1$ //$NON-NLS-2$ - ".*"); //$NON-NLS-1$ - - for (String folder : mExistinfFolders) { - if (pathRE.matcher(folder).matches()) { - files.add(new File(folder)); - } - } - for (String filePath : mExistinfFiles) { - if (pathRE.matcher(filePath).matches()) { - files.add(new File(filePath)); - } - } - return files.toArray(new File[files.size()]); - } - - /** Invokes {@link File#renameTo(File)} on the given files. */ - @Override - public boolean renameTo(File oldFile, File newFile) { - boolean renamed = false; - - String oldPath = getAgnosticAbsPath(oldFile); - String newPath = getAgnosticAbsPath(newFile); - Pattern pathRE = Pattern.compile( - "^(" + Pattern.quote(oldPath) + //$NON-NLS-1$ - ")($|/.*)"); //$NON-NLS-1$ - - Set<String> newStrings = new HashSet<String>(); - for (Iterator<String> it = mExistinfFolders.iterator(); it.hasNext(); ) { - String folder = it.next(); - Matcher m = pathRE.matcher(folder); - if (m.matches()) { - it.remove(); - String newFolder = newPath + m.group(2); - newStrings.add(newFolder); - renamed = true; - } - } - mExistinfFolders.addAll(newStrings); - newStrings.clear(); - - for (Iterator<String> it = mExistinfFiles.iterator(); it.hasNext(); ) { - String filePath = it.next(); - Matcher m = pathRE.matcher(filePath); - if (m.matches()) { - it.remove(); - String newFilePath = newPath + m.group(2); - newStrings.add(newFilePath); - renamed = true; - } - } - mExistinfFiles.addAll(newStrings); - - return renamed; - } - - /** - * {@inheritDoc} - * <p/> - * <em>TODO: we might want to overload this to read mock properties instead of a real file.</em> - */ - @Override - public @NonNull Properties loadProperties(@NonNull File file) { - Properties props = new Properties(); - FileInputStream fis = null; - try { - fis = new FileInputStream(file); - props.load(fis); - } catch (IOException ignore) { - } finally { - if (fis != null) { - try { - fis.close(); - } catch (Exception ignore) {} - } - } - return props; - } - - /** - * {@inheritDoc} - * <p/> - * <em>Note that this uses the mock version of {@link #newFileOutputStream(File)} and thus - * records the write rather than actually performing it.</em> - */ - @Override - public boolean saveProperties(@NonNull File file, @NonNull Properties props, - @NonNull String comments) { - OutputStream fos = null; - try { - fos = newFileOutputStream(file); - - props.store(fos, comments); - return true; - } catch (IOException ignore) { - } finally { - if (fos != null) { - try { - fos.close(); - } catch (IOException e) { - } - } - } - - return false; - } - - /** - * Returns an OutputStream that will capture the bytes written and associate - * them with the given file. - */ - @Override - public OutputStream newFileOutputStream(File file) throws FileNotFoundException { - StringOutputStream os = new StringOutputStream(file); - mOutputStreams.add(os); - return os; - } - - /** - * An {@link OutputStream} that will capture the stream as an UTF-8 string once properly closed - * and associate it to the given {@link File}. - */ - public class StringOutputStream extends ByteArrayOutputStream { - private String mData; - private final File mFile; - - public StringOutputStream(File file) { - mFile = file; - recordExistingFile(file); - } - - public File getFile() { - return mFile; - } - - /** Can be null if the stream has never been properly closed. */ - public String getData() { - return mData; - } - - /** Once the stream is properly closed, convert the byte array to an UTF-8 string */ - @Override - public void close() throws IOException { - super.close(); - mData = new String(toByteArray(), "UTF-8"); //$NON-NLS-1$ - } - - /** Returns a string representation suitable for unit tests validation. */ - @Override - public synchronized String toString() { - StringBuilder sb = new StringBuilder(); - sb.append('<').append(getAgnosticAbsPath(mFile)).append(": "); //$NON-NLS-1$ - if (mData == null) { - sb.append("(stream not closed properly)>"); //$NON-NLS-1$ - } else { - sb.append('\'').append(mData).append("'>"); //$NON-NLS-1$ - } - return sb.toString(); - } - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/io/MockFileOpTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/io/MockFileOpTest.java deleted file mode 100755 index 8fb1784..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/io/MockFileOpTest.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.io; - -import java.io.File; -import java.io.OutputStream; -import java.util.Arrays; - -import junit.framework.TestCase; - -/** - * Unit-test for the {@link MockFileOp}, which is a mock of {@link FileOp} that doesn't - * touch the file system. Just testing the test. - */ -public class MockFileOpTest extends TestCase { - - private MockFileOp m; - - @Override - protected void setUp() throws Exception { - super.setUp(); - m = new MockFileOp(); - } - - private File createFile(String...segments) { - File f = null; - for (String segment : segments) { - if (f == null) { - f = new File(segment); - } else { - f = new File(f, segment); - } - } - - return f; - } - - public void testIsFile() { - File f1 = createFile("/dir1", "file1"); - assertFalse(m.isFile(f1)); - - m.recordExistingFile("/dir1/file1"); - assertTrue(m.isFile(f1)); - - assertEquals( - "[/dir1/file1]", - Arrays.toString(m.getExistingFiles())); - } - - public void testIsDirectory() { - File d4 = createFile("/dir1", "dir2", "dir3", "dir4"); - File f7 = createFile("/dir1", "dir2", "dir6", "file7"); - assertFalse(m.isDirectory(d4)); - - m.recordExistingFolder("/dir1/dir2/dir3/dir4"); - m.recordExistingFile("/dir1/dir2/dir6/file7"); - assertTrue(m.isDirectory(d4)); - assertFalse(m.isDirectory(f7)); - - // any intermediate directory exists implicitly - assertTrue(m.isDirectory(createFile("/"))); - assertTrue(m.isDirectory(createFile("/dir1"))); - assertTrue(m.isDirectory(createFile("/dir1", "dir2"))); - assertTrue(m.isDirectory(createFile("/dir1", "dir2", "dir3"))); - assertTrue(m.isDirectory(createFile("/dir1", "dir2", "dir6"))); - - assertEquals( - "[/dir1/dir2/dir3/dir4]", - Arrays.toString(m.getExistingFolders())); - } - - public void testDelete() { - m.recordExistingFolder("/dir1"); - m.recordExistingFile("/dir1/file1"); - m.recordExistingFile("/dir1/file2"); - - assertEquals( - "[/dir1/file1, /dir1/file2]", - Arrays.toString(m.getExistingFiles())); - - assertTrue(m.delete(createFile("/dir1", "file1"))); - assertFalse(m.delete(createFile("/dir1", "file3"))); - assertFalse(m.delete(createFile("/dir2", "file2"))); - assertEquals( - "[/dir1/file2]", - Arrays.toString(m.getExistingFiles())); - - // deleting a directory with files in it fails - assertFalse(m.delete(createFile("/dir1"))); - // but it works if the directory is empty - assertTrue(m.delete(createFile("/dir1", "file2"))); - assertTrue(m.delete(createFile("/dir1"))); - } - - public void testListFiles() { - m.recordExistingFolder("/dir1"); - m.recordExistingFile("/dir1/file1"); - m.recordExistingFile("/dir1/file2"); - m.recordExistingFile("/dir1/dir2/file3"); - m.recordExistingFile("/dir4/file4"); - - assertEquals( - "[]", - m.getAgnosticAbsPath(Arrays.toString(m.listFiles(createFile("/not_a_dir"))))); - - assertEquals( - "[/dir1/dir2/file3]", - m.getAgnosticAbsPath(Arrays.toString(m.listFiles(createFile("/dir1", "dir2"))))); - - assertEquals( - "[/dir1/dir2/file3, /dir1/file1, /dir1/file2]", - m.getAgnosticAbsPath(Arrays.toString(m.listFiles(createFile("/dir1"))))); - } - - public void testMkDirs() { - assertEquals("[]", Arrays.toString(m.getExistingFolders())); - - assertTrue(m.mkdirs(createFile("/dir1"))); - assertEquals("[/, /dir1]", Arrays.toString(m.getExistingFolders())); - - m.recordExistingFolder("/dir1"); - assertEquals("[/, /dir1]", Arrays.toString(m.getExistingFolders())); - - assertTrue(m.mkdirs(createFile("/dir1/dir2/dir3"))); - assertEquals( - "[/, /dir1, /dir1/dir2, /dir1/dir2/dir3]", - Arrays.toString(m.getExistingFolders())); - } - - public void testRenameTo() { - m.recordExistingFile("/dir1/dir2/dir6/file7"); - m.recordExistingFolder("/dir1/dir2/dir3/dir4"); - - assertEquals("[/dir1/dir2/dir6/file7]", Arrays.toString(m.getExistingFiles())); - assertEquals("[/dir1/dir2/dir3/dir4]", Arrays.toString(m.getExistingFolders())); - - assertTrue(m.renameTo(createFile("/dir1", "dir2"), createFile("/dir1", "newDir2"))); - assertEquals("[/dir1/newDir2/dir6/file7]", Arrays.toString(m.getExistingFiles())); - assertEquals("[/dir1/newDir2/dir3/dir4]", Arrays.toString(m.getExistingFolders())); - - assertTrue(m.renameTo( - createFile("/dir1", "newDir2", "dir6", "file7"), - createFile("/dir1", "newDir2", "dir6", "newFile7"))); - assertTrue(m.renameTo( - createFile("/dir1", "newDir2", "dir3", "dir4"), - createFile("/dir1", "newDir2", "dir3", "newDir4"))); - assertEquals("[/dir1/newDir2/dir6/newFile7]", Arrays.toString(m.getExistingFiles())); - assertEquals("[/dir1/newDir2/dir3/newDir4]", Arrays.toString(m.getExistingFolders())); - } - - public void testNewFileOutputStream() throws Exception { - assertEquals("[]", Arrays.toString(m.getOutputStreams())); - - File f = createFile("/dir1", "dir2", "simple ascii"); - OutputStream os = m.newFileOutputStream(f); - assertNotNull(os); - os.write("regular ascii".getBytes("UTF-8")); - os.close(); - - f = createFile("/dir1", "dir2", "utf-8 test"); - os = m.newFileOutputStream(f); - assertNotNull(os); - os.write("nihongo in UTF-8: 日本語".getBytes("UTF-8")); - os.close(); - - f = createFile("/dir1", "dir2", "forgot to close"); - os = m.newFileOutputStream(f); - assertNotNull(os); - os.write("wrote stuff but not closing the stream".getBytes("UTF-8")); - - assertEquals( - "[</dir1/dir2/simple ascii: 'regular ascii'>, " + - "</dir1/dir2/utf-8 test: 'nihongo in UTF-8: 日本語'>, " + - "</dir1/dir2/forgot to close: (stream not closed properly)>]", - Arrays.toString(m.getOutputStreams())); - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/mock/MockLog.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/mock/MockLog.java deleted file mode 100644 index f2e30d2..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/mock/MockLog.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.mock; - -import com.android.annotations.NonNull; -import com.android.utils.ILogger; - -import java.util.ArrayList; -import java.util.Formatter; -import java.util.List; - -/** - * An instance of {@link ILogger} that captures all messages to an internal list. - * Messages can be retrieved later using {@link #toString()}. - * Useful for unit-tests. - */ -public class MockLog implements ILogger { - private ArrayList<String> mMessages = new ArrayList<String>(); - - private void add(String code, String format, Object... args) { - Formatter formatter = new Formatter(); - mMessages.add(formatter.format(code + format, args).toString()); - formatter.close(); - } - - @Override - public void warning(@NonNull String format, Object... args) { - add("W ", format, args); - } - - @Override - public void info(@NonNull String format, Object... args) { - add("P ", format, args); - } - - @Override - public void verbose(@NonNull String format, Object... args) { - add("V ", format, args); - } - - @Override - public void error(Throwable t, String format, Object... args) { - if (t != null) { - add("T", "%s", t.toString()); - } - add("E ", format, args); - } - - @Override - public String toString() { - return mMessages.toString(); - } - - @NonNull - public List<String> getMessages() { - return mMessages; - } - - public void clear() { - mMessages.clear(); - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/CaptureErrorHandler.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/CaptureErrorHandler.java deleted file mode 100755 index dccec59..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/CaptureErrorHandler.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.eclipse.org/org/documents/epl-v10.php - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.repository; - -import org.xml.sax.ErrorHandler; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - -/** - * A SAX error handler that captures the errors and warnings. - * This allows us to capture *all* errors and just not get an exception on the first one. - */ -class CaptureErrorHandler implements ErrorHandler { - - private String mWarnings = ""; - private String mErrors = ""; - - public String getErrors() { - return mErrors; - } - - public String getWarnings() { - return mWarnings; - } - - /** - * Verifies if the handler captures some errors or warnings. - * Prints them on stderr. - * Also fails the unit test if any error was generated. - */ - public void verify() { - if (mWarnings.length() > 0) { - System.err.println(mWarnings); - } - - if (mErrors.length() > 0) { - System.err.println(mErrors); - junit.framework.Assert.fail(mErrors); - } - } - - /** - * @throws SAXException - */ - @Override - public void error(SAXParseException ex) throws SAXException { - mErrors += "Error: " + ex.getMessage() + "\n"; - } - - /** - * @throws SAXException - */ - @Override - public void fatalError(SAXParseException ex) throws SAXException { - mErrors += "Fatal Error: " + ex.getMessage() + "\n"; - } - - /** - * @throws SAXException - */ - @Override - public void warning(SAXParseException ex) throws SAXException { - mWarnings += "Warning: " + ex.getMessage() + "\n"; - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/ValidateAddonXmlTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/ValidateAddonXmlTest.java deleted file mode 100755 index ea56e0b..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/ValidateAddonXmlTest.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.eclipse.org/org/documents/epl-v10.php - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.repository; - -import com.android.annotations.Nullable; - -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - -import java.io.InputStream; -import java.io.StringReader; - -import javax.xml.XMLConstants; -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamSource; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; -import javax.xml.validation.Validator; - -import junit.framework.TestCase; - -/** - * Tests local validation of an SDK Addon sample XMLs using an XML Schema validator. - */ -public class ValidateAddonXmlTest extends TestCase { - - private static String OPEN_TAG_ADDON = - "<r:sdk-addon xmlns:r=\"http://schemas.android.com/sdk/android/addon/" + - Integer.toString(SdkAddonConstants.NS_LATEST_VERSION) + - "\">"; - private static String CLOSE_TAG_ADDON = "</r:sdk-addon>"; - - // --- Helpers ------------ - - /** - * Helper method that returns a validator for our Addon XSD - * - * @param version The version number, in range {@code 1..NS_LATEST_VERSION} - * @param handler A {@link CaptureErrorHandler}. If null the default will be used, - * which will most likely print errors to stderr. - */ - private Validator getAddonValidator(int version, @Nullable CaptureErrorHandler handler) - throws SAXException { - Validator validator = null; - InputStream xsdStream = SdkAddonConstants.getXsdStream(version); - if (xsdStream != null) { - SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - Schema schema = factory.newSchema(new StreamSource(xsdStream)); - validator = schema.newValidator(); - if (handler != null) { - validator.setErrorHandler(handler); - } - } - - return validator; - } - - /** An helper that validates a string against an expected regexp. */ - private void assertRegex(String expectedRegexp, String actualString) { - assertNotNull(actualString); - assertTrue( - String.format("Regexp Assertion Failed:\nExpected: %s\nActual: %s\n", - expectedRegexp, actualString), - actualString.matches(expectedRegexp)); - } - - // --- Tests ------------ - - /** Validates that NS_LATEST_VERSION points to the max available XSD schema. */ - public void testAddonLatestVersionNumber() throws Exception { - CaptureErrorHandler handler = new CaptureErrorHandler(); - - // There should be a schema matching NS_LATEST_VERSION - assertNotNull(getAddonValidator(SdkAddonConstants.NS_LATEST_VERSION, handler)); - - // There should NOT be a schema with NS_LATEST_VERSION+1 - assertNull( - String.format( - "There's an ADDON XSD at version %d but SdkAddonConstants.NS_LATEST_VERSION is still set to %d.", - SdkAddonConstants.NS_LATEST_VERSION + 1, - SdkAddonConstants.NS_LATEST_VERSION), - getAddonValidator(SdkAddonConstants.NS_LATEST_VERSION + 1, handler)); - } - - /** Validate a valid sample using namespace version 1 using an InputStream */ - public void testValidateLocalAddonFile1() throws Exception { - InputStream xmlStream = this.getClass().getResourceAsStream( - "/com/android/sdklib/testdata/addon_sample_1.xml"); - Source source = new StreamSource(xmlStream); - - CaptureErrorHandler handler = new CaptureErrorHandler(); - Validator validator = getAddonValidator(1, handler); - validator.validate(source); - handler.verify(); - } - - /** Validate a valid sample using namespace version 2 using an InputStream */ - public void testValidateLocalAddonFile2() throws Exception { - InputStream xmlStream = this.getClass().getResourceAsStream( - "/com/android/sdklib/testdata/addon_sample_2.xml"); - Source source = new StreamSource(xmlStream); - - CaptureErrorHandler handler = new CaptureErrorHandler(); - Validator validator = getAddonValidator(2, handler); - validator.validate(source); - handler.verify(); - } - - /** Validate a valid sample using namespace version 3 using an InputStream */ - public void testValidateLocalAddonFile3() throws Exception { - InputStream xmlStream = this.getClass().getResourceAsStream( - "/com/android/sdklib/testdata/addon_sample_3.xml"); - Source source = new StreamSource(xmlStream); - - CaptureErrorHandler handler = new CaptureErrorHandler(); - Validator validator = getAddonValidator(3, handler); - validator.validate(source); - handler.verify(); - } - - /** Validate a valid sample using namespace version 4 using an InputStream */ - public void testValidateLocalAddonFile4() throws Exception { - InputStream xmlStream = this.getClass().getResourceAsStream( - "/com/android/sdklib/testdata/addon_sample_4.xml"); - Source source = new StreamSource(xmlStream); - - CaptureErrorHandler handler = new CaptureErrorHandler(); - Validator validator = getAddonValidator(4, handler); - validator.validate(source); - handler.verify(); - } - - // IMPORTANT: each time you add a test here, you should add a corresponding - // test in SdkAddonSourceTest to validate the XML content is parsed correctly. - - // ---- - - /** - * An addon does not support a codename. - * There used to be a typo in the repository.XSD versions 1-2 & the addon XSD versions 1-2 - * where addons had an optional element 'codename'. This was a typo and it's been fixed. - */ - public void testAddonCodename() throws Exception { - // we define a license named "lic1" and then reference "lic2" instead - String document = "<?xml version=\"1.0\"?>" + - OPEN_TAG_ADDON + - "<r:license id=\"lic1\"> some license </r:license> " + - "<r:add-on> <r:uses-license ref=\"lic1\" /> <r:revision>1</r:revision> " + - "<r:name-id>AddonName</r:name-id> <r:name-display>The Addon Name</r:name-display> " + - "<r:vendor-id>AddonVendor</r:vendor-id> <r:vendor-display>The Addon Vendor</r:vendor-display> " + - "<r:api-level>42</r:api-level> " + - "<r:codename>Addons do not support codenames</r:codenames> " + - "<r:libs><r:lib><r:name>com.example.LibName</r:name></r:lib></r:libs> " + - "<r:archives> <r:archive os=\"any\"> <r:size>1</r:size> <r:checksum>2822ae37115ebf13412bbef91339ee0d9454525e</r:checksum> " + - "<r:url>url</r:url> </r:archive> </r:archives> </r:add-on>" + - CLOSE_TAG_ADDON; - - Source source = new StreamSource(new StringReader(document)); - - // don't capture the validator errors, we want it to fail and catch the exception - Validator validator = getAddonValidator(SdkAddonConstants.NS_LATEST_VERSION, null); - try { - validator.validate(source); - } catch (SAXParseException e) { - // We expect a parse error referring to this grammar rule - assertRegex("cvc-complex-type.2.4.a: Invalid content was found starting with element 'r:codename'.*", - e.getMessage()); - return; - } - // If we get here, the validator has not failed as we expected it to. - fail(); - } - - /** A document with a slash in an extra path. */ - public void testExtraPathWithSlash() throws Exception { - String document = "<?xml version=\"1.0\"?>" + - OPEN_TAG_ADDON + - "<r:extra> <r:revision>1</r:revision> <r:path>path/cannot\\contain\\segments</r:path> " + - "<r:archives> <r:archive os=\"any\"> <r:size>1</r:size> <r:checksum>2822ae37115ebf13412bbef91339ee0d9454525e</r:checksum> " + - "<r:url>url</r:url> </r:archive> </r:archives> </r:extra>" + - CLOSE_TAG_ADDON; - - Source source = new StreamSource(new StringReader(document)); - - // don't capture the validator errors, we want it to fail and catch the exception - Validator validator = getAddonValidator(SdkAddonConstants.NS_LATEST_VERSION, null); - try { - validator.validate(source); - } catch (SAXParseException e) { - // We expect a parse error referring to this grammar rule - assertRegex("cvc-pattern-valid: Value 'path/cannot\\\\contain\\\\segments' is not facet-valid with respect to pattern.*", - e.getMessage()); - return; - } - // If we get here, the validator has not failed as we expected it to. - fail(); - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/ValidateAddonsListXmlTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/ValidateAddonsListXmlTest.java deleted file mode 100755 index 0461c67..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/ValidateAddonsListXmlTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.eclipse.org/org/documents/epl-v10.php - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.repository; - -import com.android.annotations.Nullable; - -import org.xml.sax.SAXException; - -import java.io.InputStream; - -import javax.xml.XMLConstants; -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamSource; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; -import javax.xml.validation.Validator; - -import junit.framework.TestCase; - -/** - * Tests local validation of an SDK Addon-List sample XMLs using an XML Schema validator. - */ -public class ValidateAddonsListXmlTest extends TestCase { - - // --- Helpers ------------ - - /** - * Helper method that returns a validator for our Addons-List XSD - * - * @param version The version number, in range {@code 1..NS_LATEST_VERSION} - * @param handler A {@link CaptureErrorHandler}. If null the default will be used, - * which will most likely print errors to stderr. - */ - private Validator getValidator(int version, @Nullable CaptureErrorHandler handler) - throws SAXException { - Validator validator = null; - InputStream xsdStream = SdkAddonsListConstants.getXsdStream(version); - if (xsdStream != null) { - SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - Schema schema = factory.newSchema(new StreamSource(xsdStream)); - validator = schema.newValidator(); - if (handler != null) { - validator.setErrorHandler(handler); - } - } - - return validator; - } - - // --- Tests ------------ - - /** Validates that NS_LATEST_VERSION points to the max available XSD schema. */ - public void testAddonLatestVersionNumber() throws Exception { - CaptureErrorHandler handler = new CaptureErrorHandler(); - - // There should be a schema matching NS_LATEST_VERSION - assertNotNull(getValidator(SdkAddonsListConstants.NS_LATEST_VERSION, handler)); - - // There should NOT be a schema with NS_LATEST_VERSION+1 - assertNull( - String.format( - "There's an ADDON XSD at version %d but SdkAddonsListConstants.NS_LATEST_VERSION is still set to %d.", - SdkAddonsListConstants.NS_LATEST_VERSION + 1, - SdkAddonsListConstants.NS_LATEST_VERSION), - getValidator(SdkAddonsListConstants.NS_LATEST_VERSION + 1, handler)); - } - - /** Validate a valid sample using namespace version 1 using an InputStream */ - public void testValidateLocalAddonFile1() throws Exception { - InputStream xmlStream = this.getClass().getResourceAsStream( - "/com/android/sdklib/testdata/addons_list_sample_1.xml"); - Source source = new StreamSource(xmlStream); - - CaptureErrorHandler handler = new CaptureErrorHandler(); - Validator validator = getValidator(1, handler); - validator.validate(source); - handler.verify(); - } - - /** Validate a valid sample using namespace version 2 using an InputStream */ - public void testValidateLocalAddonFile2() throws Exception { - InputStream xmlStream = this.getClass().getResourceAsStream( - "/com/android/sdklib/testdata/addons_list_sample_2.xml"); - Source source = new StreamSource(xmlStream); - - CaptureErrorHandler handler = new CaptureErrorHandler(); - Validator validator = getValidator(2, handler); - validator.validate(source); - handler.verify(); - } - - // IMPORTANT: each time you add a test here, you should add a corresponding - // test in AddonsListFetcherTest to validate the XML content is parsed correctly. -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/ValidateRepositoryXmlTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/ValidateRepositoryXmlTest.java deleted file mode 100755 index bdc450c..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/ValidateRepositoryXmlTest.java +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.eclipse.org/org/documents/epl-v10.php - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.repository; - -import com.android.annotations.Nullable; - -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - -import java.io.InputStream; -import java.io.StringReader; - -import javax.xml.XMLConstants; -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamSource; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; -import javax.xml.validation.Validator; - -import junit.framework.TestCase; - -/** - * Tests local validation of an SDK Repository sample XMLs using an XML Schema validator. - * - * References: - * http://www.ibm.com/developerworks/xml/library/x-javaxmlvalidapi.html - */ -public class ValidateRepositoryXmlTest extends TestCase { - - private static String OPEN_TAG_REPO = - "<r:sdk-repository xmlns:r=\"http://schemas.android.com/sdk/android/repository/" + - Integer.toString(SdkRepoConstants.NS_LATEST_VERSION) + - "\">"; - private static String CLOSE_TAG_REPO = "</r:sdk-repository>"; - - // --- Helpers ------------ - - /** - * Helper method that returns a validator for our Repository XSD - * - * @param version The version number, in range {@code 1..NS_LATEST_VERSION} - * @param handler A {@link CaptureErrorHandler}. If null the default will be used, - * which will most likely print errors to stderr. - */ - private Validator getRepoValidator(int version, @Nullable CaptureErrorHandler handler) - throws SAXException { - Validator validator = null; - InputStream xsdStream = SdkRepoConstants.getXsdStream(version); - if (xsdStream != null) { - SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - Schema schema = factory.newSchema(new StreamSource(xsdStream)); - validator = schema.newValidator(); - - if (handler != null) { - validator.setErrorHandler(handler); - } - } - - return validator; - } - - /** An helper that validates a string against an expected regexp. */ - private void assertRegex(String expectedRegexp, String actualString) { - assertNotNull(actualString); - assertTrue( - String.format("Regexp Assertion Failed:\nExpected: %s\nActual: %s\n", - expectedRegexp, actualString), - actualString.matches(expectedRegexp)); - } - - // --- Tests ------------ - - /** Validates that NS_LATEST_VERSION points to the max available XSD schema. */ - public void testRepoLatestVersionNumber() throws Exception { - CaptureErrorHandler handler = new CaptureErrorHandler(); - - // There should be a schema matching NS_LATEST_VERSION - assertNotNull(getRepoValidator(SdkRepoConstants.NS_LATEST_VERSION, handler)); - - // There should NOT be a schema with NS_LATEST_VERSION+1 - assertNull( - String.format( - "There's a REPO XSD at version %d but SdkRepoConstants.NS_LATEST_VERSION is still set to %d.", - SdkRepoConstants.NS_LATEST_VERSION + 1, - SdkRepoConstants.NS_LATEST_VERSION), - getRepoValidator(SdkRepoConstants.NS_LATEST_VERSION + 1, handler)); - } - - /** Validate a valid sample using namespace version 1 using an InputStream */ - public void testValidateLocalRepositoryFile1() throws Exception { - InputStream xmlStream = this.getClass().getResourceAsStream( - "/com/android/sdklib/testdata/repository_sample_1.xml"); - Source source = new StreamSource(xmlStream); - - CaptureErrorHandler handler = new CaptureErrorHandler(); - Validator validator = getRepoValidator(1, handler); - validator.validate(source); - 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 = getRepoValidator(2, handler); - validator.validate(source); - handler.verify(); - } - - /** Validate a valid sample using namespace version 3 using an InputStream */ - public void testValidateLocalRepositoryFile3() throws Exception { - InputStream xmlStream = this.getClass().getResourceAsStream( - "/com/android/sdklib/testdata/repository_sample_3.xml"); - Source source = new StreamSource(xmlStream); - - CaptureErrorHandler handler = new CaptureErrorHandler(); - Validator validator = getRepoValidator(3, handler); - validator.validate(source); - handler.verify(); - } - - /** Validate a valid sample using namespace version 4 using an InputStream */ - public void testValidateLocalRepositoryFile4() throws Exception { - InputStream xmlStream = this.getClass().getResourceAsStream( - "/com/android/sdklib/testdata/repository_sample_4.xml"); - Source source = new StreamSource(xmlStream); - - CaptureErrorHandler handler = new CaptureErrorHandler(); - Validator validator = getRepoValidator(4, handler); - validator.validate(source); - handler.verify(); - - } - - /** Validate a valid sample using namespace version 5 using an InputStream */ - public void testValidateLocalRepositoryFile5() throws Exception { - InputStream xmlStream = this.getClass().getResourceAsStream( - "/com/android/sdklib/testdata/repository_sample_5.xml"); - Source source = new StreamSource(xmlStream); - - CaptureErrorHandler handler = new CaptureErrorHandler(); - Validator validator = getRepoValidator(5, handler); - validator.validate(source); - handler.verify(); - - } - - /** Validate a valid sample using namespace version 5 using an InputStream */ - public void testValidateLocalRepositoryFile6() throws Exception { - InputStream xmlStream = this.getClass().getResourceAsStream( - "/com/android/sdklib/testdata/repository_sample_6.xml"); - Source source = new StreamSource(xmlStream); - - CaptureErrorHandler handler = new CaptureErrorHandler(); - Validator validator = getRepoValidator(6, handler); - validator.validate(source); - handler.verify(); - - } - - /** Validate a valid sample using namespace version 5 using an InputStream */ - public void testValidateLocalRepositoryFile7() throws Exception { - InputStream xmlStream = this.getClass().getResourceAsStream( - "/com/android/sdklib/testdata/repository_sample_7.xml"); - Source source = new StreamSource(xmlStream); - - CaptureErrorHandler handler = new CaptureErrorHandler(); - Validator validator = getRepoValidator(7, handler); - validator.validate(source); - handler.verify(); - - } - - // IMPORTANT: each time you add a test here, you should add a corresponding - // test in SdkRepoSourceTest to validate the XML content is parsed correctly. - - - // --- - - /** A document should at least have a root to be valid */ - public void testEmptyXml() throws Exception { - String document = "<?xml version=\"1.0\"?>"; - - Source source = new StreamSource(new StringReader(document)); - - CaptureErrorHandler handler = new CaptureErrorHandler(); - Validator validator = getRepoValidator(SdkRepoConstants.NS_LATEST_VERSION, handler); - - try { - validator.validate(source); - } catch (SAXParseException e) { - // We expect to get this specific exception message - assertRegex("Premature end of file.*", e.getMessage()); - return; - } - // We shouldn't get here - handler.verify(); - fail(); - } - - /** A document with a root element containing no platform, addon, etc., is valid. */ - public void testEmptyRootXml() throws Exception { - String document = "<?xml version=\"1.0\"?>" + - OPEN_TAG_REPO + - CLOSE_TAG_REPO; - - Source source = new StreamSource(new StringReader(document)); - - CaptureErrorHandler handler = new CaptureErrorHandler(); - Validator validator = getRepoValidator(SdkRepoConstants.NS_LATEST_VERSION, handler); - validator.validate(source); - handler.verify(); - } - - /** A document with an unknown element. */ - public void testUnknownContentXml() throws Exception { - String document = "<?xml version=\"1.0\"?>" + - OPEN_TAG_REPO + - "<r:unknown />" + - CLOSE_TAG_REPO; - - Source source = new StreamSource(new StringReader(document)); - - // don't capture the validator errors, we want it to fail and catch the exception - Validator validator = getRepoValidator(SdkRepoConstants.NS_LATEST_VERSION, null); - try { - validator.validate(source); - } catch (SAXParseException e) { - // We expect a parse expression referring to this grammar rule - assertRegex("cvc-complex-type.2.4.a: Invalid content was found.*", e.getMessage()); - return; - } - // If we get here, the validator has not failed as we expected it to. - fail(); - } - - /** A document with an incomplete element. */ - public void testIncompleteContentXml() throws Exception { - String document = "<?xml version=\"1.0\"?>" + - OPEN_TAG_REPO + - "<r:platform> <r:api-level>1</r:api-level> <r:libs /> </r:platform>" + - CLOSE_TAG_REPO; - - Source source = new StreamSource(new StringReader(document)); - - // don't capture the validator errors, we want it to fail and catch the exception - Validator validator = getRepoValidator(SdkRepoConstants.NS_LATEST_VERSION, null); - try { - validator.validate(source); - } catch (SAXParseException e) { - // We expect a parse error referring to this grammar rule - assertRegex("cvc-complex-type.2.4.a: Invalid content was found.*", e.getMessage()); - return; - } - // If we get here, the validator has not failed as we expected it to. - fail(); - } - - /** A document with a wrong type element. */ - public void testWrongTypeContentXml() throws Exception { - String document = "<?xml version=\"1.0\"?>" + - OPEN_TAG_REPO + - "<r:platform> <r:api-level>NotAnInteger</r:api-level> <r:libs /> </r:platform>" + - CLOSE_TAG_REPO; - - Source source = new StreamSource(new StringReader(document)); - - // don't capture the validator errors, we want it to fail and catch the exception - Validator validator = getRepoValidator(SdkRepoConstants.NS_LATEST_VERSION, null); - try { - validator.validate(source); - } catch (SAXParseException e) { - // We expect a parse error referring to this grammar rule - assertRegex("cvc-datatype-valid.1.2.1: 'NotAnInteger' is not a valid value.*", - e.getMessage()); - return; - } - // If we get here, the validator has not failed as we expected it to. - fail(); - } - - /** A document with an unknown license id. */ - public void testLicenseIdNotFound() throws Exception { - // we define a license named "lic1" and then reference "lic2" instead - String document = "<?xml version=\"1.0\"?>" + - OPEN_TAG_REPO + - "<r:license id=\"lic1\"> some license </r:license> " + - "<r:tool> <r:uses-license ref=\"lic2\" /> <r:revision> <r:major>1</r:major> </r:revision> " + - "<r:min-platform-tools-rev> <r:major>1</r:major> </r:min-platform-tools-rev> " + - "<r:archives> <r:archive os=\"any\"> <r:size>1</r:size> <r:checksum>2822ae37115ebf13412bbef91339ee0d9454525e</r:checksum> " + - "<r:url>url</r:url> </r:archive> </r:archives> </r:tool>" + - CLOSE_TAG_REPO; - - Source source = new StreamSource(new StringReader(document)); - - // don't capture the validator errors, we want it to fail and catch the exception - Validator validator = getRepoValidator(SdkRepoConstants.NS_LATEST_VERSION, null); - try { - validator.validate(source); - } catch (SAXParseException e) { - // We expect a parse error referring to this grammar rule - assertRegex("cvc-id.1: There is no ID/IDREF binding for IDREF 'lic2'.*", - e.getMessage()); - return; - } - // If we get here, the validator has not failed as we expected it to. - fail(); - } - - /** The latest XSD repository-6 should fail when an 'extra' is present. */ - public void testExtraPathWithSlash() throws Exception { - String document = "<?xml version=\"1.0\"?>" + - OPEN_TAG_REPO + - "<r:extra> <r:revision>1</r:revision> <r:path>path</r:path> " + - "<r:archives> <r:archive os=\"any\"> <r:size>1</r:size> <r:checksum>2822ae37115ebf13412bbef91339ee0d9454525e</r:checksum> " + - "<r:url>url</r:url> </r:archive> </r:archives> </r:extra>" + - CLOSE_TAG_REPO; - - Source source = new StreamSource(new StringReader(document)); - - // don't capture the validator errors, we want it to fail and catch the exception - Validator validator = getRepoValidator(SdkRepoConstants.NS_LATEST_VERSION, null); - try { - validator.validate(source); - } catch (SAXParseException e) { - // We expect a parse error referring to this grammar rule - assertRegex("cvc-complex-type.2.4.a: Invalid content was found starting with element 'r:extra'.*", - e.getMessage()); - return; - } - // If we get here, the validator has not failed as we expected it to. - fail(); - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/ValidateSysImgXmlTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/ValidateSysImgXmlTest.java deleted file mode 100755 index fe7b1e8..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/ValidateSysImgXmlTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.eclipse.org/org/documents/epl-v10.php - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.repository; - -import com.android.annotations.Nullable; - -import org.xml.sax.SAXException; - -import java.io.InputStream; - -import javax.xml.XMLConstants; -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamSource; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; -import javax.xml.validation.Validator; - -import junit.framework.TestCase; - -/** - * Tests local validation of an SDK Repository sample XMLs using an XML Schema validator. - * - * References: - * http://www.ibm.com/developerworks/xml/library/x-javaxmlvalidapi.html - */ -public class ValidateSysImgXmlTest extends TestCase { - - // --- Helpers ------------ - - /** - * Helper method that returns a validator for our Repository XSD - * - * @param version The version number, in range {@code 1..NS_LATEST_VERSION} - * @param handler A {@link CaptureErrorHandler}. If null the default will be used, - * which will most likely print errors to stderr. - */ - private Validator getValidator(int version, @Nullable CaptureErrorHandler handler) - throws SAXException { - Validator validator = null; - InputStream xsdStream = SdkSysImgConstants.getXsdStream(version); - if (xsdStream != null) { - SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - Schema schema = factory.newSchema(new StreamSource(xsdStream)); - validator = schema.newValidator(); - - if (handler != null) { - validator.setErrorHandler(handler); - } - } - - return validator; - } - - // --- Tests ------------ - - /** Validates that NS_LATEST_VERSION points to the max available XSD schema. */ - public void testSysImgLatestVersionNumber() throws Exception { - CaptureErrorHandler handler = new CaptureErrorHandler(); - - // There should be a schema matching NS_LATEST_VERSION - assertNotNull(getValidator(SdkSysImgConstants.NS_LATEST_VERSION, handler)); - - // There should NOT be a schema with NS_LATEST_VERSION+1 - assertNull( - String.format( - "There's a REPO XSD at version %d but SdkSysImgConstants.NS_LATEST_VERSION is still set to %d.", - SdkSysImgConstants.NS_LATEST_VERSION + 1, - SdkSysImgConstants.NS_LATEST_VERSION), - getValidator(SdkSysImgConstants.NS_LATEST_VERSION + 1, handler)); - } - - /** Validate a valid sample using namespace version 1 using an InputStream */ - public void testValidateLocalRepositoryFile1() throws Exception { - InputStream xmlStream = this.getClass().getResourceAsStream( - "/com/android/sdklib/testdata/sys_img_sample_1.xml"); - Source source = new StreamSource(xmlStream); - - CaptureErrorHandler handler = new CaptureErrorHandler(); - Validator validator = getValidator(1, handler); - validator.validate(source); - handler.verify(); - } - - // IMPORTANT: each time you add a test here, you should add a corresponding - // test in SdkSysImgSourceTest to validate the XML content is parsed correctly. - -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/AndroidManifest-instrumentation.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/AndroidManifest-instrumentation.xml deleted file mode 100644 index f1dce67..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/AndroidManifest-instrumentation.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.android.AndroidProject.tests"> - - <!-- - This declares that this app uses the instrumentation test runner targeting - the package of com.android.samples. To run the tests use the command: - "adb shell am instrument -w com.android.samples.tests/android.test.InstrumentationTestRunner" - --> - <instrumentation android:name="android.test.InstrumentationTestRunner" - android:targetPackage="com.android.AndroidProject" - android:label="Sample test for deployment."/> - - <application> - <uses-library android:name="android.test.runner" /> - </application> - <uses-sdk android:minSdkVersion="foo"/> - -</manifest> diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/AndroidManifest-testapp.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/AndroidManifest-testapp.xml deleted file mode 100644 index f55b4e0..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/AndroidManifest-testapp.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.android.testapp" android:versionCode="42" - android:versionName="1.42"> - <application android:icon="@drawable/icon"> - <activity android:name="com.android.testapp.MainActivity" - android:label="@string/app_name"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - <category android:name="android.intent.category.DEFAULT" /> - </intent-filter> - </activity> - <uses-library android:name="android.test.runner" - android:required="false" /> - <uses-library android:name="android.test.runner2" /> - </application> - <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="8" /> - <supports-screens android:resizeable="true" - android:smallScreens="true" android:anyDensity="true" - android:largeScreens="true" android:normalScreens="true" /> - <uses-configuration android:reqKeyboardType="twelvekey" - android:reqTouchScreen="finger" android:reqFiveWayNav="true" - android:reqHardKeyboard="true" android:reqNavigation="nonav" /> - <uses-feature android:glEsVersion="0x00020001" /> - <uses-feature android:name="com.foo.feature" /> - <instrumentation android:name="android.test.InstrumentationTestRunner" - android:targetPackage="com.example.android.apis" android:label="Tests for Api Demos." /> -</manifest> diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/AndroidManifest-testapp2.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/AndroidManifest-testapp2.xml deleted file mode 100644 index d5bcac7..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/AndroidManifest-testapp2.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.android.testapp" android:versionCode="42" - android:versionName="1.42"> - <application android:icon="@drawable/icon"/> - <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="8" /> - <supports-screens android:largeScreens="false" /> -</manifest> diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addon_sample_1.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addon_sample_1.xml deleted file mode 100755 index d761d73..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addon_sample_1.xml +++ /dev/null @@ -1,164 +0,0 @@ -<?xml version="1.0"?> -<!-- - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. ---> -<sdk:sdk-addon - xmlns:sdk="http://schemas.android.com/sdk/android/addon/1"> - - <!-- Define a couple of licenses. These will be referenced by uses-license later. --> - - <sdk:license type="text" id="license1"> - This is the license - for this platform. - </sdk:license> - - <sdk:license id="license2"> - Licenses are only of type 'text' right now, so this is implied. - </sdk:license> - - <!-- Inner elements must be either platform, add-on, doc or tool. - There can be 0 or more of each, in any order. --> - - <sdk:add-on> - <sdk:name>My First add-on</sdk:name> - <sdk:api-level>1</sdk:api-level> - <sdk:vendor>John Doe</sdk:vendor> - <sdk:revision>1</sdk:revision> - <sdk:uses-license ref="license2" /> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/myfirstaddon</sdk:desc-url> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/add-ons/first.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <!-- The libs node is mandatory, however it can be empty. --> - <sdk:libs> - <sdk:lib> - <sdk:name>android.blah.somelib</sdk:name> - <sdk:description>The description for this library.</sdk:description> - </sdk:lib> - <sdk:lib> - <!-- sdk:description is optional, name is not --> - <sdk:name>com.android.mymaps</sdk:name> - </sdk:lib> - </sdk:libs> - </sdk:add-on> - - <sdk:add-on> - <sdk:name>My Second add-on</sdk:name> - <sdk:api-level>2</sdk:api-level> - <sdk:vendor>John Deer</sdk:vendor> - <sdk:revision>42</sdk:revision> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/second-42-win.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/second-42-linux.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:libs> - <sdk:lib> - <sdk:name>android.blah.somelib</sdk:name> - <sdk:description>The description for this library.</sdk:description> - </sdk:lib> - <sdk:lib> - <sdk:name>com.android.mymaps</sdk:name> - </sdk:lib> - </sdk:libs> - <sdk:uses-license ref="license2" /> - </sdk:add-on> - - <sdk:add-on> - <sdk:uses-license ref="license2" /> - <sdk:name>This add-on has no libraries</sdk:name> - <sdk:api-level>4</sdk:api-level> - <sdk:vendor>Joe Bar</sdk:vendor> - <sdk:revision>3</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/imnotanarchiveimadoctorjim.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <!-- The libs node is mandatory, however it can be empty. --> - <sdk:libs /> - </sdk:add-on> - - <sdk:extra> - <sdk:vendor>g</sdk:vendor> - <sdk:path>usb_driver</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>43</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extraduff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>An Extra package for the USB driver, it will install in $SDK/usb_driver</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:obsolete/> - </sdk:extra> - - <sdk:extra> - <sdk:vendor>android_vendor</sdk:vendor> - <sdk:path>extra_api_dep</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>2</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extra_mega_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some extra package that has a min-api-level of 42</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:min-api-level>42</sdk:min-api-level> - <sdk:obsolete></sdk:obsolete> - </sdk:extra> - - <sdk:extra> - <sdk:vendor>____</sdk:vendor> - <sdk:path>____</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>2</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extra_mega_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some extra package that has a min-api-level of 42</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:min-api-level>42</sdk:min-api-level> - <sdk:obsolete></sdk:obsolete> - </sdk:extra> - -</sdk:sdk-addon> diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addon_sample_2.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addon_sample_2.xml deleted file mode 100755 index 1033c15..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addon_sample_2.xml +++ /dev/null @@ -1,179 +0,0 @@ -<?xml version="1.0"?> -<!-- - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. ---> -<sdk:sdk-addon - xmlns:sdk="http://schemas.android.com/sdk/android/addon/2"> - - <!-- Define a couple of licenses. These will be referenced by uses-license later. --> - - <sdk:license type="text" id="license1"> - This is the license - for this platform. - </sdk:license> - - <sdk:license id="license2"> - Licenses are only of type 'text' right now, so this is implied. - </sdk:license> - - <!-- Inner elements must be either platform, add-on, doc or tool. - There can be 0 or more of each, in any order. --> - - <sdk:add-on> - <sdk:name>My First add-on</sdk:name> - <sdk:api-level>1</sdk:api-level> - <sdk:vendor>John Doe</sdk:vendor> - <sdk:revision>1</sdk:revision> - <sdk:uses-license ref="license2" /> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/myfirstaddon</sdk:desc-url> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/add-ons/first.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <!-- The libs node is mandatory, however it can be empty. --> - <sdk:libs> - <sdk:lib> - <sdk:name>android.blah.somelib</sdk:name> - <sdk:description>The description for this library.</sdk:description> - </sdk:lib> - <sdk:lib> - <!-- sdk:description is optional, name is not --> - <sdk:name>com.android.mymaps</sdk:name> - </sdk:lib> - </sdk:libs> - <sdk:layoutlib> - <sdk:api>5</sdk:api> - <sdk:revision>0</sdk:revision> - </sdk:layoutlib> - </sdk:add-on> - - <sdk:add-on> - <sdk:name>My Second add-on</sdk:name> - <sdk:api-level>2</sdk:api-level> - <sdk:vendor>John Deer</sdk:vendor> - <sdk:revision>42</sdk:revision> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/second-42-win.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/second-42-linux.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:libs> - <sdk:lib> - <sdk:name>android.blah.somelib</sdk:name> - <sdk:description>The description for this library.</sdk:description> - </sdk:lib> - <sdk:lib> - <sdk:name>com.android.mymaps</sdk:name> - </sdk:lib> - </sdk:libs> - <sdk:uses-license ref="license2" /> - <!-- No layoutlib element in this package. It's optional. --> - </sdk:add-on> - - <sdk:add-on> - <sdk:uses-license ref="license2" /> - <sdk:name>This add-on has no libraries</sdk:name> - <sdk:api-level>4</sdk:api-level> - <sdk:vendor>Joe Bar</sdk:vendor> - <sdk:revision>3</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/imnotanarchiveimadoctorjim.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <!-- The libs node is mandatory, however it can be empty. --> - <sdk:libs /> - <sdk:layoutlib> - <sdk:api>3</sdk:api> - <sdk:revision>42</sdk:revision> - </sdk:layoutlib> - </sdk:add-on> - - <sdk:extra> - <sdk:vendor>g</sdk:vendor> - <sdk:path>usb_driver</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>43</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extraduff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>An Extra package for the USB driver, it will install in $SDK/usb_driver</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:obsolete/> - </sdk:extra> - - <sdk:extra> - <sdk:vendor>android_vendor</sdk:vendor> - <sdk:path>extra_api_dep</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>2</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extra_mega_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some extra package that has a min-api-level of 42</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:min-api-level>42</sdk:min-api-level> - <sdk:obsolete></sdk:obsolete> - <sdk:project-files> - <sdk:path>v8/veggies_8.jar</sdk:path> - <sdk:path>root.jar</sdk:path> - <sdk:path>dir1/dir 2 with space/mylib.jar</sdk:path> - </sdk:project-files> - </sdk:extra> - - <sdk:extra> - <sdk:vendor>____</sdk:vendor> - <sdk:path>____</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>2</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extra_mega_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some extra package that has a min-api-level of 42</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:min-api-level>42</sdk:min-api-level> - <sdk:obsolete></sdk:obsolete> - <!-- No project-files element in this package. --> - </sdk:extra> - -</sdk:sdk-addon> diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addon_sample_3.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addon_sample_3.xml deleted file mode 100755 index 568cec1..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addon_sample_3.xml +++ /dev/null @@ -1,180 +0,0 @@ -<?xml version="1.0"?> -<!-- - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. ---> -<sdk:sdk-addon - xmlns:sdk="http://schemas.android.com/sdk/android/addon/3"> - - <!-- Define a couple of licenses. These will be referenced by uses-license later. --> - - <sdk:license type="text" id="license1"> - This is the license - for this platform. - </sdk:license> - - <sdk:license id="license2"> - Licenses are only of type 'text' right now, so this is implied. - </sdk:license> - - <!-- Inner elements must be either platform, add-on, doc or tool. - There can be 0 or more of each, in any order. --> - - <sdk:add-on> - <sdk:name>My First add-on</sdk:name> - <sdk:api-level>1</sdk:api-level> - <sdk:vendor>John Doe</sdk:vendor> - <sdk:revision>1</sdk:revision> - <sdk:uses-license ref="license2" /> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/myfirstaddon</sdk:desc-url> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/add-ons/first.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <!-- The libs node is mandatory, however it can be empty. --> - <sdk:libs> - <sdk:lib> - <sdk:name>android.blah.somelib</sdk:name> - <sdk:description>The description for this library.</sdk:description> - </sdk:lib> - <sdk:lib> - <!-- sdk:description is optional, name is not --> - <sdk:name>com.android.mymaps</sdk:name> - </sdk:lib> - </sdk:libs> - <sdk:layoutlib> - <sdk:api>5</sdk:api> - <sdk:revision>0</sdk:revision> - </sdk:layoutlib> - </sdk:add-on> - - <sdk:add-on> - <sdk:name>My Second add-on</sdk:name> - <sdk:api-level>2</sdk:api-level> - <sdk:vendor>John Deer</sdk:vendor> - <sdk:revision>42</sdk:revision> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/second-42-win.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/second-42-linux.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:libs> - <sdk:lib> - <sdk:name>android.blah.somelib</sdk:name> - <sdk:description>The description for this library.</sdk:description> - </sdk:lib> - <sdk:lib> - <sdk:name>com.android.mymaps</sdk:name> - </sdk:lib> - </sdk:libs> - <sdk:uses-license ref="license2" /> - <!-- No layoutlib element in this package. It's optional. --> - </sdk:add-on> - - <sdk:add-on> - <sdk:uses-license ref="license2" /> - <sdk:name>This add-on has no libraries</sdk:name> - <sdk:api-level>4</sdk:api-level> - <sdk:vendor>Joe Bar</sdk:vendor> - <sdk:revision>3</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/imnotanarchiveimadoctorjim.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <!-- The libs node is mandatory, however it can be empty. --> - <sdk:libs /> - <sdk:layoutlib> - <sdk:api>3</sdk:api> - <sdk:revision>42</sdk:revision> - </sdk:layoutlib> - </sdk:add-on> - - <sdk:extra> - <sdk:vendor>g</sdk:vendor> - <sdk:path>usb_driver</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>43</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extraduff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>An Extra package for the USB driver, it will install in $SDK/usb_driver</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:obsolete/> - </sdk:extra> - - <sdk:extra> - <sdk:vendor>android_vendor</sdk:vendor> - <sdk:path>extra_api_dep</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>2</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extra_mega_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some extra package that has a min-api-level of 42</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:min-api-level>42</sdk:min-api-level> - <sdk:obsolete></sdk:obsolete> - <sdk:project-files> - <sdk:path>v8/veggies_8.jar</sdk:path> - <sdk:path>root.jar</sdk:path> - <sdk:path>dir1/dir 2 with space/mylib.jar</sdk:path> - </sdk:project-files> - <sdk:old-paths>path1;old_path2;oldPath3</sdk:old-paths> - </sdk:extra> - - <sdk:extra> - <sdk:vendor>____</sdk:vendor> - <sdk:path>____</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>2</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extra_mega_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some extra package that has a min-api-level of 42</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:min-api-level>42</sdk:min-api-level> - <sdk:obsolete></sdk:obsolete> - <!-- No project-files element in this package. --> - </sdk:extra> - -</sdk:sdk-addon> diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addon_sample_4.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addon_sample_4.xml deleted file mode 100755 index 6fba439..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addon_sample_4.xml +++ /dev/null @@ -1,203 +0,0 @@ -<?xml version="1.0"?> -<!-- - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. ---> -<sdk:sdk-addon - xmlns:sdk="http://schemas.android.com/sdk/android/addon/4"> - - <!-- Define a couple of licenses. These will be referenced by uses-license later. --> - - <sdk:license type="text" id="license1"> - This is the license - for this platform. - </sdk:license> - - <sdk:license id="license2"> - Licenses are only of type 'text' right now, so this is implied. - </sdk:license> - - <!-- Inner elements must be either platform, add-on, doc or tool. - There can be 0 or more of each, in any order. --> - - <sdk:add-on> - <sdk:name-id>My_First_add-on</sdk:name-id> - <sdk:name-display>My First add-on</sdk:name-display> - - <sdk:vendor-id>John_Doe</sdk:vendor-id> - <sdk:vendor-display>John Doe</sdk:vendor-display> - - <sdk:api-level>1</sdk:api-level> - <sdk:revision>1</sdk:revision> - <sdk:uses-license ref="license2" /> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/myfirstaddon</sdk:desc-url> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/add-ons/first.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <!-- The libs node is mandatory, however it can be empty. --> - <sdk:libs> - <sdk:lib> - <sdk:name>android.blah.somelib</sdk:name> - <sdk:description>The description for this library.</sdk:description> - </sdk:lib> - <sdk:lib> - <!-- sdk:description is optional, name is not --> - <sdk:name>com.android.mymaps</sdk:name> - </sdk:lib> - </sdk:libs> - <sdk:layoutlib> - <sdk:api>5</sdk:api> - <sdk:revision>0</sdk:revision> - </sdk:layoutlib> - </sdk:add-on> - - <sdk:add-on> - <sdk:name-id>My_Second_add-on</sdk:name-id> - <sdk:name-display>My Second add-on</sdk:name-display> - - <sdk:vendor-id>John_Deer</sdk:vendor-id> - <sdk:vendor-display>John Deer</sdk:vendor-display> - - <sdk:api-level>2</sdk:api-level> - <sdk:revision>42</sdk:revision> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/second-42-win.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/second-42-linux.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:libs> - <sdk:lib> - <sdk:name>android.blah.somelib</sdk:name> - <sdk:description>The description for this library.</sdk:description> - </sdk:lib> - <sdk:lib> - <sdk:name>com.android.mymaps</sdk:name> - </sdk:lib> - </sdk:libs> - <sdk:uses-license ref="license2" /> - <!-- No layoutlib element in this package. It's optional. --> - </sdk:add-on> - - <sdk:add-on> - <sdk:name-id>no_libs</sdk:name-id> - <sdk:name-display>This add-on has no libraries</sdk:name-display> - - <sdk:vendor-id>Joe_Bar</sdk:vendor-id> - <sdk:vendor-display>Joe Bar</sdk:vendor-display> - - <sdk:uses-license ref="license2" /> - <sdk:api-level>4</sdk:api-level> - <sdk:revision>3</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/imnotanarchiveimadoctorjim.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <!-- The libs node is mandatory, however it can be empty. --> - <sdk:libs /> - <sdk:layoutlib> - <sdk:api>3</sdk:api> - <sdk:revision>42</sdk:revision> - </sdk:layoutlib> - </sdk:add-on> - - <sdk:extra> - <sdk:name-display>Random name, not an id!</sdk:name-display> - - <sdk:vendor-id>cyclop</sdk:vendor-id> - <sdk:vendor-display>The big bus</sdk:vendor-display> - - <sdk:path>usb_driver</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>43</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extraduff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>An Extra package for the USB driver, it will install in $SDK/usb_driver</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:obsolete/> - </sdk:extra> - - <sdk:extra> - <sdk:name-display>Yet another extra, by Android</sdk:name-display> - - <sdk:vendor-id>android_vendor</sdk:vendor-id> - <sdk:vendor-display>Android Vendor</sdk:vendor-display> - - <sdk:path>extra_api_dep</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>2</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extra_mega_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some extra package that has a min-api-level of 42</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:min-api-level>42</sdk:min-api-level> - <sdk:project-files> - <sdk:path>v8/veggies_8.jar</sdk:path> - <sdk:path>root.jar</sdk:path> - <sdk:path>dir1/dir 2 with space/mylib.jar</sdk:path> - </sdk:project-files> - <sdk:old-paths>path1;old_path2;oldPath3</sdk:old-paths> - </sdk:extra> - - <sdk:extra> - <sdk:name-display>. -..- - .-. .-</sdk:name-display> - - <sdk:vendor-id>____</sdk:vendor-id> - <sdk:vendor-display>____</sdk:vendor-display> - - <sdk:path>____</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>2</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extra_mega_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some extra package that has a min-api-level of 42</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:min-api-level>42</sdk:min-api-level> - <sdk:obsolete></sdk:obsolete> - <!-- No project-files element in this package. --> - </sdk:extra> - -</sdk:sdk-addon> diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addon_sample_5.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addon_sample_5.xml deleted file mode 100755 index 47b37be..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addon_sample_5.xml +++ /dev/null @@ -1,214 +0,0 @@ -<?xml version="1.0"?> -<!-- - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. ---> -<sdk:sdk-addon - xmlns:sdk="http://schemas.android.com/sdk/android/addon/5"> - - <!-- Define a couple of licenses. These will be referenced by uses-license later. --> - - <sdk:license type="text" id="license1"> - This is the license - for this platform. - </sdk:license> - - <sdk:license id="license2"> - Licenses are only of type 'text' right now, so this is implied. - </sdk:license> - - <!-- Inner elements must be either platform, add-on, doc or tool. - There can be 0 or more of each, in any order. --> - - <sdk:add-on> - <sdk:name-id>My_First_add-on</sdk:name-id> - <sdk:name-display>My First add-on</sdk:name-display> - - <sdk:vendor-id>John_Doe</sdk:vendor-id> - <sdk:vendor-display>John Doe</sdk:vendor-display> - - <sdk:api-level>1</sdk:api-level> - <sdk:revision>1</sdk:revision> - <sdk:uses-license ref="license2" /> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/myfirstaddon</sdk:desc-url> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/add-ons/first.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <!-- The libs node is mandatory, however it can be empty. --> - <sdk:libs> - <sdk:lib> - <sdk:name>android.blah.somelib</sdk:name> - <sdk:description>The description for this library.</sdk:description> - </sdk:lib> - <sdk:lib> - <!-- sdk:description is optional, name is not --> - <sdk:name>com.android.mymaps</sdk:name> - </sdk:lib> - </sdk:libs> - <sdk:layoutlib> - <sdk:api>5</sdk:api> - <sdk:revision>0</sdk:revision> - </sdk:layoutlib> - </sdk:add-on> - - <sdk:add-on> - <sdk:name-id>My_Second_add-on</sdk:name-id> - <sdk:name-display>My Second add-on</sdk:name-display> - - <sdk:vendor-id>John_Deer</sdk:vendor-id> - <sdk:vendor-display>John Deer</sdk:vendor-display> - - <sdk:api-level>2</sdk:api-level> - <sdk:revision>42</sdk:revision> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/second-42-win.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/second-42-linux.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:libs> - <sdk:lib> - <sdk:name>android.blah.somelib</sdk:name> - <sdk:description>The description for this library.</sdk:description> - </sdk:lib> - <sdk:lib> - <sdk:name>com.android.mymaps</sdk:name> - </sdk:lib> - </sdk:libs> - <sdk:uses-license ref="license2" /> - <!-- No layoutlib element in this package. It's optional. --> - </sdk:add-on> - - <sdk:add-on> - <sdk:name-id>no_libs</sdk:name-id> - <sdk:name-display>This add-on has no libraries</sdk:name-display> - - <sdk:vendor-id>Joe_Bar</sdk:vendor-id> - <sdk:vendor-display>Joe Bar</sdk:vendor-display> - - <sdk:uses-license ref="license2" /> - <sdk:api-level>4</sdk:api-level> - <sdk:revision>3</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/imnotanarchiveimadoctorjim.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <!-- The libs node is mandatory, however it can be empty. --> - <sdk:libs /> - <sdk:layoutlib> - <sdk:api>3</sdk:api> - <sdk:revision>42</sdk:revision> - </sdk:layoutlib> - </sdk:add-on> - - <sdk:extra> - <sdk:name-display>Random name, not an id!</sdk:name-display> - - <sdk:vendor-id>cyclop</sdk:vendor-id> - <sdk:vendor-display>The big bus</sdk:vendor-display> - - <sdk:path>usb_driver</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>43</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extraduff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>An Extra package for the USB driver, it will install in $SDK/usb_driver</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev> - <sdk:major>3</sdk:major> - <sdk:minor>2</sdk:minor> - <sdk:micro>1</sdk:micro> - <sdk:preview>42</sdk:preview> - </sdk:min-tools-rev> - <sdk:obsolete/> - </sdk:extra> - - <sdk:extra> - <sdk:name-display>Yet another extra, by Android</sdk:name-display> - - <sdk:vendor-id>android_vendor</sdk:vendor-id> - <sdk:vendor-display>Android Vendor</sdk:vendor-display> - - <sdk:path>extra_api_dep</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>2</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extra_mega_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some extra package that has a min-api-level of 42</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev> - <sdk:major>3</sdk:major> - </sdk:min-tools-rev> - <sdk:min-api-level>42</sdk:min-api-level> - <sdk:project-files> - <sdk:path>v8/veggies_8.jar</sdk:path> - <sdk:path>root.jar</sdk:path> - <sdk:path>dir1/dir 2 with space/mylib.jar</sdk:path> - </sdk:project-files> - <sdk:old-paths>path1;old_path2;oldPath3</sdk:old-paths> - </sdk:extra> - - <sdk:extra> - <sdk:name-display>. -..- - .-. .-</sdk:name-display> - - <sdk:vendor-id>____</sdk:vendor-id> - <sdk:vendor-display>____</sdk:vendor-display> - - <sdk:path>____</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>2</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extra_mega_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some extra package that has a min-api-level of 42</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev> - <sdk:major>3</sdk:major> - <!-- no minor, assumed to be 0 --> - <sdk:micro>1</sdk:micro> - </sdk:min-tools-rev> - <sdk:min-api-level>42</sdk:min-api-level> - <sdk:obsolete></sdk:obsolete> - <!-- No project-files element in this package. --> - </sdk:extra> - -</sdk:sdk-addon> diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addons_list_sample_1.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addons_list_sample_1.xml deleted file mode 100755 index 5ea5cb8..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addons_list_sample_1.xml +++ /dev/null @@ -1,43 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. ---> -<sdk:sdk-addons-list - xmlns:sdk="http://schemas.android.com/sdk/android/addons-list/1"> - - <sdk:addon-site> - <sdk:url>http://www.example.com/my_addons.xml</sdk:url> - <sdk:name> <!-- we'll ignore leading/trailing spacing --> - My Example Add-ons. - </sdk:name> - </sdk:addon-site> - - <sdk:addon-site> - <sdk:url>http://www.example.co.jp/addons.xml</sdk:url> - <!-- this file is UTF-8 so we support character sets --> - <sdk:name>ありがとうございます。</sdk:name> - </sdk:addon-site> - - <sdk:addon-site> - <sdk:url>http://www.example.com/</sdk:url> - <sdk:name>Example of directory URL.</sdk:name> - </sdk:addon-site> - - <sdk:addon-site> - <sdk:url>relative_url.xml</sdk:url> - <sdk:name>Relative URL.</sdk:name> - </sdk:addon-site> - -</sdk:sdk-addons-list> diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addons_list_sample_2.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addons_list_sample_2.xml deleted file mode 100755 index ef72b2c..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addons_list_sample_2.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. ---> -<sdk:sdk-addons-list - xmlns:sdk="http://schemas.android.com/sdk/android/addons-list/2"> - - <sdk:addon-site> - <sdk:url>http://www.example.com/my_addons.xml</sdk:url> - <sdk:name> <!-- we'll ignore leading/trailing spacing --> - My Example Add-ons. - </sdk:name> - </sdk:addon-site> - - <sdk:addon-site> - <sdk:url>http://www.example.co.jp/addons.xml</sdk:url> - <!-- this file is UTF-8 so we support character sets --> - <sdk:name>ありがとうございます。</sdk:name> - </sdk:addon-site> - - <sdk:addon-site> - <sdk:url>http://www.example.com/</sdk:url> - <sdk:name>Example of directory URL.</sdk:name> - </sdk:addon-site> - - <sdk:sys-img-site> - <sdk:url>http://www.example.com/</sdk:url> - <sdk:name>Example of sys-img URL using the default xml filename.</sdk:name> - </sdk:sys-img-site> - - <sdk:sys-img-site> - <sdk:url>http://www.example.com/specific_file.xml</sdk:url> - <sdk:name>Example of sys-img URL using a specific xml filename.</sdk:name> - </sdk:sys-img-site> - - <sdk:addon-site> - <sdk:url>relative/url.xml</sdk:url> - <sdk:name>Relative URL.</sdk:name> - </sdk:addon-site> - -</sdk:sdk-addons-list> diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_1.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_1.xml deleted file mode 100755 index 7e2bc36..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_1.xml +++ /dev/null @@ -1,274 +0,0 @@ -<?xml version="1.0"?> -<!-- - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. ---> -<sdk:sdk-repository - xmlns:sdk="http://schemas.android.com/sdk/android/repository/1"> - - <!-- Define a couple of licenses. These will be referenced by uses-license later. --> - - <sdk:license type="text" id="license1"> - This is the license - for this platform. - </sdk:license> - - <sdk:license id="license2"> - Licenses are only of type 'text' right now, so this is implied. - </sdk:license> - - <!-- Inner elements must be either platform, add-on, doc or tool. - There can be 0 or more of each, in any order. --> - - <sdk:platform> - <sdk:version>1.0</sdk:version> - <sdk:api-level>1</sdk:api-level> - <sdk:revision>3</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/platform1.html</sdk:desc-url> - <sdk:release-note>This is an optional release note - for this package. It's a free multi-line text. - </sdk:release-note> - <sdk:release-url>http://some/url/for/the/release/note.html</sdk:release-url> - <sdk:min-tools-rev>2</sdk:min-tools-rev> - <!-- The archives node is mandatory and it cannot be empty. --> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/plat1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:platform> - - <sdk:doc> - <sdk:api-level>1</sdk:api-level> - <sdk:revision>1</sdk:revision> - <!-- the license element is not mandatory. --> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/docs.html</sdk:desc-url> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/docs/docs1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:doc> - - <sdk:add-on> - <sdk:name>My First add-on</sdk:name> - <sdk:api-level>1</sdk:api-level> - <sdk:vendor>John Doe</sdk:vendor> - <sdk:revision>1</sdk:revision> - <sdk:uses-license ref="license2" /> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/myfirstaddon</sdk:desc-url> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/add-ons/first.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <!-- The libs node is mandatory, however it can be empty. --> - <sdk:libs> - <sdk:lib> - <sdk:name>android.blah.somelib</sdk:name> - <sdk:description>The description for this library.</sdk:description> - </sdk:lib> - <sdk:lib> - <!-- sdk:description is optional, name is not --> - <sdk:name>com.android.mymaps</sdk:name> - </sdk:lib> - </sdk:libs> - </sdk:add-on> - - <sdk:platform> - <sdk:version>1.1</sdk:version> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>12</sdk:revision> - <sdk:uses-license ref="license1" /> - <!-- sdk:description and sdk:desc-url are optional --> - <sdk:archives> - <sdk:archive os="windows"> - <!-- arch attribute is optional --> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-win.zip</sdk:url> - </sdk:archive> - <sdk:archive os="macosx" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-mac.zip</sdk:url> - </sdk:archive> - <sdk:archive os="macosx" arch="ppc"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-mac.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux" arch="x86"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="linux" arch="x86_64"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-linux.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:platform> - - <sdk:add-on> - <sdk:name>My Second add-on</sdk:name> - <sdk:api-level>2</sdk:api-level> - <sdk:vendor>John Deer</sdk:vendor> - <sdk:revision>42</sdk:revision> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/second-42-win.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/second-42-linux.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:libs> - <sdk:lib> - <sdk:name>android.blah.somelib</sdk:name> - <sdk:description>The description for this library.</sdk:description> - </sdk:lib> - <sdk:lib> - <sdk:name>com.android.mymaps</sdk:name> - </sdk:lib> - </sdk:libs> - <sdk:uses-license ref="license2" /> - </sdk:add-on> - - <sdk:platform> - <sdk:version>Pastry</sdk:version> - <sdk:api-level>5</sdk:api-level> - <sdk:codename>Pastry</sdk:codename> - <sdk:revision>3</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:description>Preview version for Pastry</sdk:description> - <sdk:desc-url>http://www.example.com/platform1.html</sdk:desc-url> - <!-- The archives node is mandatory and it cannot be empty. --> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/plat1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:platform> - - <sdk:tool> - <sdk:revision>1</sdk:revision> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/tools.html</sdk:desc-url> - <sdk:uses-license ref="license1" /> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/tools1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:tool> - - <sdk:doc> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>42</sdk:revision> - <sdk:uses-license ref="license2" /> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs/2.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs2-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="macosx"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs2-mac.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:doc> - - <sdk:tool> - <sdk:revision>42</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools/2.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools2-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="macosx"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools2-mac.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:tool> - - <sdk:add-on> - <sdk:uses-license ref="license2" /> - <sdk:name>This add-on has no libraries</sdk:name> - <sdk:api-level>4</sdk:api-level> - <sdk:vendor>Joe Bar</sdk:vendor> - <sdk:revision>3</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/imnotanarchiveimadoctorjim.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <!-- The libs node is mandatory, however it can be empty. --> - <sdk:libs /> - </sdk:add-on> - - <sdk:extra> - <sdk:path>usb_driver</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>43</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extraduff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>An Extra package for the USB driver, it will install in $SDK/usb_driver</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - </sdk:extra> - -</sdk:sdk-repository> diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_2.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_2.xml deleted file mode 100755 index 6b2d679..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_2.xml +++ /dev/null @@ -1,309 +0,0 @@ -<?xml version="1.0"?> -<!-- - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. ---> -<sdk:sdk-repository - xmlns:sdk="http://schemas.android.com/sdk/android/repository/2"> - - <!-- Define a couple of licenses. These will be referenced by uses-license later. --> - - <sdk:license type="text" id="license1"> - This is the license - for this platform. - </sdk:license> - - <sdk:license id="license2"> - Licenses are only of type 'text' right now, so this is implied. - </sdk:license> - - <!-- Inner elements must be either platform, add-on, doc or tool. - There can be 0 or more of each, in any order. --> - - <sdk:platform> - <sdk:version>1.0</sdk:version> - <sdk:api-level>1</sdk:api-level> - <sdk:revision>3</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/platform1.html</sdk:desc-url> - <sdk:release-note>This is an optional release note - for this package. It's a free multi-line text. - </sdk:release-note> - <sdk:release-url>http://some/url/for/the/release/note.html</sdk:release-url> - <sdk:min-tools-rev>2</sdk:min-tools-rev> - <!-- The archives node is mandatory and it cannot be empty. --> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/plat1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:platform> - - <sdk:doc> - <sdk:api-level>1</sdk:api-level> - <sdk:revision>1</sdk:revision> - <!-- the license element is not mandatory. --> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/docs.html</sdk:desc-url> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/docs/docs1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:doc> - - <sdk:add-on> - <sdk:name>My First add-on</sdk:name> - <sdk:api-level>1</sdk:api-level> - <sdk:vendor>John Doe</sdk:vendor> - <sdk:revision>1</sdk:revision> - <sdk:uses-license ref="license2" /> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/myfirstaddon</sdk:desc-url> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/add-ons/first.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <!-- The libs node is mandatory, however it can be empty. --> - <sdk:libs> - <sdk:lib> - <sdk:name>android.blah.somelib</sdk:name> - <sdk:description>The description for this library.</sdk:description> - </sdk:lib> - <sdk:lib> - <!-- sdk:description is optional, name is not --> - <sdk:name>com.android.mymaps</sdk:name> - </sdk:lib> - </sdk:libs> - </sdk:add-on> - - <sdk:platform> - <sdk:version>1.1</sdk:version> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>12</sdk:revision> - <sdk:uses-license ref="license1" /> - <!-- sdk:description and sdk:desc-url are optional --> - <sdk:archives> - <sdk:archive os="windows"> - <!-- arch attribute is optional --> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-win.zip</sdk:url> - </sdk:archive> - <sdk:archive os="macosx" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-mac.zip</sdk:url> - </sdk:archive> - <sdk:archive os="macosx" arch="ppc"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-mac.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux" arch="x86"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="linux" arch="x86_64"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-linux.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:platform> - - <sdk:add-on> - <sdk:name>My Second add-on</sdk:name> - <sdk:api-level>2</sdk:api-level> - <sdk:vendor>John Deer</sdk:vendor> - <sdk:revision>42</sdk:revision> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/second-42-win.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/second-42-linux.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:libs> - <sdk:lib> - <sdk:name>android.blah.somelib</sdk:name> - <sdk:description>The description for this library.</sdk:description> - </sdk:lib> - <sdk:lib> - <sdk:name>com.android.mymaps</sdk:name> - </sdk:lib> - </sdk:libs> - <sdk:uses-license ref="license2" /> - </sdk:add-on> - - <sdk:platform> - <sdk:version>Pastry</sdk:version> - <sdk:api-level>5</sdk:api-level> - <sdk:codename>Pastry</sdk:codename> - <sdk:revision>3</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:description>Preview version for Pastry</sdk:description> - <sdk:desc-url>http://www.example.com/platform1.html</sdk:desc-url> - <!-- The archives node is mandatory and it cannot be empty. --> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/plat1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:platform> - - <sdk:tool> - <sdk:revision>1</sdk:revision> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/tools.html</sdk:desc-url> - <sdk:uses-license ref="license1" /> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/tools1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:tool> - - <sdk:doc> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>42</sdk:revision> - <sdk:uses-license ref="license2" /> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs/2.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs2-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="macosx"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs2-mac.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:doc> - - <sdk:tool> - <sdk:revision>42</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools/2.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools2-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="macosx"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools2-mac.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:tool> - - <sdk:add-on> - <sdk:uses-license ref="license2" /> - <sdk:name>This add-on has no libraries</sdk:name> - <sdk:api-level>4</sdk:api-level> - <sdk:vendor>Joe Bar</sdk:vendor> - <sdk:revision>3</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/imnotanarchiveimadoctorjim.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <!-- The libs node is mandatory, however it can be empty. --> - <sdk:libs /> - </sdk:add-on> - - <sdk:extra> - <sdk:path>usb_driver</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>43</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extraduff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>An Extra package for the USB driver, it will install in $SDK/usb_driver</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:obsolete/> - </sdk:extra> - - <sdk:extra> - <sdk:path>extra_api_dep</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>2</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extra_mega_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some extra package that has a min-api-level of 42</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:min-api-level>42</sdk:min-api-level> - <sdk:obsolete></sdk:obsolete> - </sdk:extra> - - <sdk:sample> - <sdk:api-level>14</sdk:api-level> - <sdk:revision>24</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65537</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/sample_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some sample package</sdk:description> - <sdk:desc-url>http://www.example.com/sample.html</sdk:desc-url> - <sdk:min-tools-rev>5</sdk:min-tools-rev> - <sdk:obsolete>This is obsolete</sdk:obsolete> - </sdk:sample> - -</sdk:sdk-repository> diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_3.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_3.xml deleted file mode 100755 index 05a9c79..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_3.xml +++ /dev/null @@ -1,261 +0,0 @@ -<?xml version="1.0"?> -<!-- - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. ---> -<sdk:sdk-repository - xmlns:sdk="http://schemas.android.com/sdk/android/repository/3"> - - <!-- Define a couple of licenses. These will be referenced by uses-license later. --> - - <sdk:license type="text" id="license1"> - This is the license - for this platform. - </sdk:license> - - <sdk:license id="license2"> - Licenses are only of type 'text' right now, so this is implied. - </sdk:license> - - <!-- Inner elements must be either platform, add-on, doc or tool. - There can be 0 or more of each, in any order. --> - - <sdk:platform> - <sdk:version>1.0</sdk:version> - <sdk:api-level>1</sdk:api-level> - <sdk:revision>3</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/platform1.html</sdk:desc-url> - <sdk:release-note>This is an optional release note - for this package. It's a free multi-line text. - </sdk:release-note> - <sdk:release-url>http://some/url/for/the/release/note.html</sdk:release-url> - <sdk:min-tools-rev>2</sdk:min-tools-rev> - <!-- The archives node is mandatory and it cannot be empty. --> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/plat1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:platform> - - <sdk:doc> - <sdk:api-level>1</sdk:api-level> - <sdk:revision>1</sdk:revision> - <!-- the license element is not mandatory. --> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/docs.html</sdk:desc-url> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/docs/docs1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:doc> - - <sdk:platform> - <sdk:version>1.1</sdk:version> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>12</sdk:revision> - <sdk:uses-license ref="license1" /> - <!-- sdk:description and sdk:desc-url are optional --> - <sdk:archives> - <sdk:archive os="windows"> - <!-- arch attribute is optional --> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-win.zip</sdk:url> - </sdk:archive> - <sdk:archive os="macosx" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-mac.zip</sdk:url> - </sdk:archive> - <sdk:archive os="macosx" arch="ppc"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-mac.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux" arch="x86"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="linux" arch="x86_64"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-linux.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:platform> - - <sdk:platform> - <sdk:version>Pastry</sdk:version> - <sdk:api-level>5</sdk:api-level> - <sdk:codename>Pastry</sdk:codename> - <sdk:revision>3</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:description>Preview version for Pastry</sdk:description> - <sdk:desc-url>http://www.example.com/platform1.html</sdk:desc-url> - <!-- The archives node is mandatory and it cannot be empty. --> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/plat1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:platform> - - <sdk:tool> - <sdk:revision>1</sdk:revision> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/tools.html</sdk:desc-url> - <sdk:uses-license ref="license1" /> - <sdk:min-platform-tools-rev>4</sdk:min-platform-tools-rev> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/tools1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:tool> - - <sdk:doc> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>42</sdk:revision> - <sdk:uses-license ref="license2" /> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs/2.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs2-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="macosx"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs2-mac.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:doc> - - <sdk:tool> - <sdk:revision>42</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:min-platform-tools-rev>3</sdk:min-platform-tools-rev> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools/2.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools2-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="macosx"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools2-mac.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:tool> - - <sdk:platform-tool> - <sdk:revision>3</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-tools/2.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-tools2-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="macosx"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-tools2-mac.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:platform-tool> - - <sdk:extra> - <sdk:vendor>a</sdk:vendor> - <sdk:path>usb_driver</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>43</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extraduff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>An Extra package for the USB driver, it will install in $SDK/usb_driver</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:obsolete/> - </sdk:extra> - - <sdk:extra> - <sdk:vendor>android_vendor</sdk:vendor> - <sdk:path>extra_api_dep</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>2</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extra_mega_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some extra package that has a min-api-level of 42</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:min-api-level>42</sdk:min-api-level> - <sdk:obsolete></sdk:obsolete> - </sdk:extra> - - <sdk:sample> - <sdk:api-level>14</sdk:api-level> - <sdk:revision>24</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65537</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/sample_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some sample package</sdk:description> - <sdk:desc-url>http://www.example.com/sample.html</sdk:desc-url> - <sdk:min-tools-rev>5</sdk:min-tools-rev> - <sdk:obsolete>This is obsolete</sdk:obsolete> - </sdk:sample> - -</sdk:sdk-repository> diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_4.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_4.xml deleted file mode 100755 index f68b033..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_4.xml +++ /dev/null @@ -1,278 +0,0 @@ -<?xml version="1.0"?> -<!-- - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. ---> -<sdk:sdk-repository - xmlns:sdk="http://schemas.android.com/sdk/android/repository/4"> - - <!-- Define a couple of licenses. These will be referenced by uses-license later. --> - - <sdk:license type="text" id="license1"> - This is the license - for this platform. - </sdk:license> - - <sdk:license id="license2"> - Licenses are only of type 'text' right now, so this is implied. - </sdk:license> - - <!-- Inner elements must be either platform, add-on, doc or tool. - There can be 0 or more of each, in any order. --> - - <sdk:platform> - <sdk:version>1.0</sdk:version> - <sdk:api-level>1</sdk:api-level> - <sdk:revision>3</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/platform1.html</sdk:desc-url> - <sdk:release-note>This is an optional release note - for this package. It's a free multi-line text. - </sdk:release-note> - <sdk:release-url>http://some/url/for/the/release/note.html</sdk:release-url> - <sdk:min-tools-rev>2</sdk:min-tools-rev> - <!-- The archives node is mandatory and it cannot be empty. --> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/plat1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:layoutlib> - <sdk:api>5</sdk:api> - <sdk:revision>0</sdk:revision> - </sdk:layoutlib> - </sdk:platform> - - <sdk:doc> - <sdk:api-level>1</sdk:api-level> - <sdk:revision>1</sdk:revision> - <!-- the license element is not mandatory. --> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/docs.html</sdk:desc-url> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/docs/docs1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:doc> - - <sdk:platform> - <sdk:version>1.1</sdk:version> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>12</sdk:revision> - <sdk:uses-license ref="license1" /> - <!-- sdk:description and sdk:desc-url are optional --> - <sdk:archives> - <sdk:archive os="windows"> - <!-- arch attribute is optional --> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-win.zip</sdk:url> - </sdk:archive> - <sdk:archive os="macosx" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-mac.zip</sdk:url> - </sdk:archive> - <sdk:archive os="macosx" arch="ppc"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-mac.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux" arch="x86"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="linux" arch="x86_64"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-linux.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:layoutlib> - <sdk:api>5</sdk:api> - <sdk:revision>31415</sdk:revision> - </sdk:layoutlib> - </sdk:platform> - - <sdk:platform> - <sdk:version>Pastry</sdk:version> - <sdk:api-level>5</sdk:api-level> - <sdk:codename>Pastry</sdk:codename> - <sdk:revision>3</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:description>Preview version for Pastry</sdk:description> - <sdk:desc-url>http://www.example.com/platform1.html</sdk:desc-url> - <!-- The archives node is mandatory and it cannot be empty. --> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/plat1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:layoutlib> - <sdk:api>1</sdk:api> - </sdk:layoutlib> - </sdk:platform> - - <sdk:tool> - <sdk:revision>1</sdk:revision> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/tools.html</sdk:desc-url> - <sdk:uses-license ref="license1" /> - <sdk:min-platform-tools-rev>4</sdk:min-platform-tools-rev> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/tools1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:tool> - - <sdk:doc> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>42</sdk:revision> - <sdk:uses-license ref="license2" /> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs/2.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs2-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="macosx"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs2-mac.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:doc> - - <sdk:tool> - <sdk:revision>42</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:min-platform-tools-rev>3</sdk:min-platform-tools-rev> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools/2.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools2-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="macosx"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools2-mac.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:tool> - - <sdk:platform-tool> - <sdk:revision>3</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-tools/2.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-tools2-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="macosx"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-tools2-mac.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:platform-tool> - - <sdk:extra> - <sdk:vendor>a</sdk:vendor> - <sdk:path>usb_driver</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>43</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extraduff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>An Extra package for the USB driver, it will install in $SDK/usb_driver</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:obsolete/> - <!-- no project-files in this USB driver package. --> - </sdk:extra> - - <sdk:extra> - <sdk:vendor>android_vendor</sdk:vendor> - <sdk:path>extra_api_dep</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>2</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extra_mega_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some extra package that has a min-api-level of 42</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:min-api-level>42</sdk:min-api-level> - <sdk:obsolete></sdk:obsolete> - <sdk:project-files> - <sdk:path>v8/veggies_8.jar</sdk:path> - <sdk:path>readme.txt</sdk:path> - <sdk:path>dir1/dir 2 with space/mylib.jar</sdk:path> - </sdk:project-files> - </sdk:extra> - - <sdk:sample> - <sdk:api-level>14</sdk:api-level> - <sdk:revision>24</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65537</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/sample_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some sample package</sdk:description> - <sdk:desc-url>http://www.example.com/sample.html</sdk:desc-url> - <sdk:min-tools-rev>5</sdk:min-tools-rev> - <sdk:obsolete>This is obsolete</sdk:obsolete> - </sdk:sample> - -</sdk:sdk-repository> diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_5.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_5.xml deleted file mode 100755 index 471550e..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_5.xml +++ /dev/null @@ -1,356 +0,0 @@ -<?xml version="1.0"?> -<!-- - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. ---> -<sdk:sdk-repository - xmlns:sdk="http://schemas.android.com/sdk/android/repository/5"> - - <!-- Define a couple of licenses. These will be referenced by uses-license later. --> - - <sdk:license type="text" id="license1"> - This is the license - for this platform. - </sdk:license> - - <sdk:license id="license2"> - Licenses are only of type 'text' right now, so this is implied. - </sdk:license> - - <!-- Inner elements must be either platform, add-on, doc or tool. - There can be 0 or more of each, in any order. --> - - <sdk:platform> - <sdk:version>1.0</sdk:version> - <sdk:api-level>1</sdk:api-level> - <sdk:revision>3</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/platform1.html</sdk:desc-url> - <sdk:release-note>This is an optional release note - for this package. It's a free multi-line text. - </sdk:release-note> - <sdk:release-url>http://some/url/for/the/release/note.html</sdk:release-url> - <sdk:min-tools-rev>2</sdk:min-tools-rev> - <!-- The archives node is mandatory and it cannot be empty. --> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/plat1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:layoutlib> - <sdk:api>5</sdk:api> - <sdk:revision>0</sdk:revision> - </sdk:layoutlib> - <sdk:included-abi>armeabi</sdk:included-abi> - </sdk:platform> - - <sdk:doc> - <sdk:api-level>1</sdk:api-level> - <sdk:revision>1</sdk:revision> - <!-- the license element is not mandatory. --> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/docs.html</sdk:desc-url> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/docs/docs1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:doc> - - <sdk:source> - <sdk:api-level>1</sdk:api-level> - <sdk:revision>1</sdk:revision> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65535</sdk:size> - <sdk:checksum type="sha1">1234ae37115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat1/sources1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:source> - - <sdk:platform> - <sdk:version>1.1</sdk:version> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>12</sdk:revision> - <sdk:uses-license ref="license1" /> - <!-- sdk:description and sdk:desc-url are optional --> - <sdk:archives> - <sdk:archive os="windows"> - <!-- arch attribute is optional --> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-win.zip</sdk:url> - </sdk:archive> - <sdk:archive os="macosx" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-mac.zip</sdk:url> - </sdk:archive> - <sdk:archive os="macosx" arch="ppc"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-mac.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux" arch="x86"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="linux" arch="x86_64"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-linux.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:layoutlib> - <sdk:api>5</sdk:api> - <sdk:revision>31415</sdk:revision> - </sdk:layoutlib> - <sdk:included-abi>x86</sdk:included-abi> - </sdk:platform> - - <sdk:system-image> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>1</sdk:revision> - <sdk:abi>x86</sdk:abi> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65535</sdk:size> - <sdk:checksum type="sha1">1234ae37115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat1/x86/image1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:system-image> - - <sdk:system-image> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>2</sdk:revision> - <sdk:abi>armeabi-v7a</sdk:abi> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65534</sdk:size> - <sdk:checksum type="sha1">1234ae37115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat1/armv7/image2.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:system-image> - - <sdk:source> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>2</sdk:revision> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65534</sdk:size> - <sdk:checksum type="sha1">1234ae37115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat1/sources2.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:source> - - <sdk:platform> - <sdk:version>Pastry</sdk:version> - <sdk:api-level>5</sdk:api-level> - <sdk:codename>Pastry</sdk:codename> - <sdk:revision>3</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:description>Preview version for Pastry</sdk:description> - <sdk:desc-url>http://www.example.com/platform1.html</sdk:desc-url> - <!-- The archives node is mandatory and it cannot be empty. --> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/plat1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:layoutlib> - <sdk:api>1</sdk:api> - </sdk:layoutlib> - </sdk:platform> - - <sdk:tool> - <sdk:revision>1</sdk:revision> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/tools.html</sdk:desc-url> - <sdk:uses-license ref="license1" /> - <sdk:min-platform-tools-rev>4</sdk:min-platform-tools-rev> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/tools1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:tool> - - <sdk:doc> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>42</sdk:revision> - <sdk:uses-license ref="license2" /> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs/2.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs2-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="macosx"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs2-mac.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:doc> - - <sdk:tool> - <sdk:revision>42</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:min-platform-tools-rev>3</sdk:min-platform-tools-rev> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools/2.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools2-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="macosx"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools2-mac.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:tool> - - <sdk:platform-tool> - <sdk:revision>3</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-tools/2.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-tools2-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="macosx"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-tools2-mac.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:platform-tool> - - <sdk:extra> - <sdk:vendor>a</sdk:vendor> - <sdk:path>usb_driver</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>43</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extraduff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>An Extra package for the USB driver, it will install in $SDK/usb_driver</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:obsolete/> - <!-- no project-files in this USB driver package. --> - </sdk:extra> - - <sdk:extra> - <sdk:vendor>android_vendor</sdk:vendor> - <sdk:path>extra_api_dep</sdk:path> - <sdk:uses-license ref="license2" /> - <sdk:revision>2</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/extra_mega_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some extra package that has a min-api-level of 42</sdk:description> - <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url> - <sdk:min-tools-rev>3</sdk:min-tools-rev> - <sdk:min-api-level>42</sdk:min-api-level> - <sdk:obsolete></sdk:obsolete> - <sdk:project-files> - <sdk:path>v8/veggies_8.jar</sdk:path> - <sdk:path>readme.txt</sdk:path> - <sdk:path>dir1/dir 2 with space/mylib.jar</sdk:path> - </sdk:project-files> - <sdk:old-paths>path1;old_path2;oldPath3</sdk:old-paths> - </sdk:extra> - - <sdk:sample> - <sdk:api-level>14</sdk:api-level> - <sdk:revision>24</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65537</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/sample_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some sample package</sdk:description> - <sdk:desc-url>http://www.example.com/sample.html</sdk:desc-url> - <sdk:min-tools-rev>5</sdk:min-tools-rev> - <sdk:obsolete>This is obsolete</sdk:obsolete> - </sdk:sample> - - <sdk:system-image> - <sdk:api-level>42</sdk:api-level> - <sdk:revision>12</sdk:revision> - <sdk:abi>armeabi</sdk:abi> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>1234</sdk:size> - <sdk:checksum type="sha1">12345637115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat42/86/image12.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:system-image> - - <sdk:source> - <sdk:api-level>42</sdk:api-level> - <sdk:revision>12</sdk:revision> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>1234</sdk:size> - <sdk:checksum type="sha1">12345637115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat42/source12.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:source> - -</sdk:sdk-repository> diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_6.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_6.xml deleted file mode 100755 index 12be591..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_6.xml +++ /dev/null @@ -1,325 +0,0 @@ -<?xml version="1.0"?> -<!-- - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. ---> -<sdk:sdk-repository - xmlns:sdk="http://schemas.android.com/sdk/android/repository/6"> - - <!-- Define a couple of licenses. These will be referenced by uses-license later. --> - - <sdk:license type="text" id="license1"> - This is the license - for this platform. - </sdk:license> - - <sdk:license id="license2"> - Licenses are only of type 'text' right now, so this is implied. - </sdk:license> - - <!-- Inner elements must be either platform, add-on, doc or tool. - There can be 0 or more of each, in any order. --> - - <sdk:platform> - <sdk:version>1.0</sdk:version> - <sdk:api-level>1</sdk:api-level> - <sdk:revision>3</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/platform1.html</sdk:desc-url> - <sdk:release-note>This is an optional release note - for this package. It's a free multi-line text. - </sdk:release-note> - <sdk:release-url>http://some/url/for/the/release/note.html</sdk:release-url> - <sdk:min-tools-rev>2</sdk:min-tools-rev> - <!-- The archives node is mandatory and it cannot be empty. --> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/plat1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:layoutlib> - <sdk:api>5</sdk:api> - <sdk:revision>0</sdk:revision> - </sdk:layoutlib> - <sdk:included-abi>armeabi</sdk:included-abi> - </sdk:platform> - - <sdk:doc> - <sdk:api-level>1</sdk:api-level> - <sdk:revision>1</sdk:revision> - <!-- the license element is not mandatory. --> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/docs.html</sdk:desc-url> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/docs/docs1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:doc> - - <sdk:source> - <sdk:api-level>1</sdk:api-level> - <sdk:revision>1</sdk:revision> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65535</sdk:size> - <sdk:checksum type="sha1">1234ae37115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat1/sources1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:source> - - <sdk:platform> - <sdk:version>1.1</sdk:version> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>12</sdk:revision> - <sdk:uses-license ref="license1" /> - <!-- sdk:description and sdk:desc-url are optional --> - <sdk:archives> - <sdk:archive os="windows"> - <!-- arch attribute is optional --> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-win.zip</sdk:url> - </sdk:archive> - <sdk:archive os="macosx" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-mac.zip</sdk:url> - </sdk:archive> - <sdk:archive os="macosx" arch="ppc"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-mac.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux" arch="x86"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="linux" arch="x86_64"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-linux.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:layoutlib> - <sdk:api>5</sdk:api> - <sdk:revision>31415</sdk:revision> - </sdk:layoutlib> - <sdk:included-abi>x86</sdk:included-abi> - </sdk:platform> - - <sdk:system-image> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>1</sdk:revision> - <sdk:abi>x86</sdk:abi> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65535</sdk:size> - <sdk:checksum type="sha1">1234ae37115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat1/x86/image1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:system-image> - - <sdk:system-image> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>2</sdk:revision> - <sdk:abi>armeabi-v7a</sdk:abi> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65534</sdk:size> - <sdk:checksum type="sha1">1234ae37115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat1/armv7/image2.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:system-image> - - <sdk:source> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>2</sdk:revision> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65534</sdk:size> - <sdk:checksum type="sha1">1234ae37115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat1/sources2.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:source> - - <sdk:platform> - <sdk:version>Pastry</sdk:version> - <sdk:api-level>5</sdk:api-level> - <sdk:codename>Pastry</sdk:codename> - <sdk:revision>3</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:description>Preview version for Pastry</sdk:description> - <sdk:desc-url>http://www.example.com/platform1.html</sdk:desc-url> - <!-- The archives node is mandatory and it cannot be empty. --> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/plat1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:layoutlib> - <sdk:api>1</sdk:api> - </sdk:layoutlib> - </sdk:platform> - - <sdk:tool> - <sdk:revision>1</sdk:revision> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/tools.html</sdk:desc-url> - <sdk:uses-license ref="license1" /> - <sdk:min-platform-tools-rev>4</sdk:min-platform-tools-rev> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/tools1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:tool> - - <sdk:doc> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>42</sdk:revision> - <sdk:uses-license ref="license2" /> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs/2.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs2-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="macosx"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs2-mac.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:doc> - - <sdk:tool> - <sdk:revision>42</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:min-platform-tools-rev>3</sdk:min-platform-tools-rev> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools/2.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools2-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="macosx"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools2-mac.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:tool> - - <sdk:platform-tool> - <sdk:revision>3</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-tools/2.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-tools2-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="macosx"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-tools2-mac.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:platform-tool> - - <sdk:sample> - <sdk:api-level>14</sdk:api-level> - <sdk:revision>24</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65537</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/sample_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some sample package</sdk:description> - <sdk:desc-url>http://www.example.com/sample.html</sdk:desc-url> - <sdk:min-tools-rev>5</sdk:min-tools-rev> - <sdk:obsolete>This is obsolete</sdk:obsolete> - </sdk:sample> - - <sdk:system-image> - <sdk:api-level>42</sdk:api-level> - <sdk:revision>12</sdk:revision> - <sdk:abi>armeabi</sdk:abi> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>1234</sdk:size> - <sdk:checksum type="sha1">12345637115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat42/86/image12.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:system-image> - - <sdk:system-image> - <sdk:api-level>42</sdk:api-level> - <sdk:revision>12</sdk:revision> - <sdk:abi>mips</sdk:abi> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>12345</sdk:size> - <sdk:checksum type="sha1">12345637115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat42/mips/image12.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:system-image> - - <sdk:source> - <sdk:api-level>42</sdk:api-level> - <sdk:revision>12</sdk:revision> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>1234</sdk:size> - <sdk:checksum type="sha1">12345637115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat42/source12.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:source> - -</sdk:sdk-repository> diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_7.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_7.xml deleted file mode 100755 index 401521b..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/repository_sample_7.xml +++ /dev/null @@ -1,371 +0,0 @@ -<?xml version="1.0"?> -<!-- - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. ---> -<sdk:sdk-repository - xmlns:sdk="http://schemas.android.com/sdk/android/repository/7"> - - <!-- Define a couple of licenses. These will be referenced by uses-license later. --> - - <sdk:license type="text" id="license1"> - This is the license - for this platform. - </sdk:license> - - <sdk:license id="license2"> - Licenses are only of type 'text' right now, so this is implied. - </sdk:license> - - <!-- Inner elements must be either platform, add-on, doc or tool. - There can be 0 or more of each, in any order. --> - - <sdk:platform> - <sdk:version>1.0</sdk:version> - <sdk:api-level>1</sdk:api-level> - <sdk:revision>3</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/platform1.html</sdk:desc-url> - <sdk:release-note>This is an optional release note - for this package. It's a free multi-line text. - </sdk:release-note> - <sdk:release-url>http://some/url/for/the/release/note.html</sdk:release-url> - <sdk:min-tools-rev> - <sdk:major>2</sdk:major> - <!-- minor is missing and equivalent to 0 --> - <sdk:micro>1</sdk:micro> - </sdk:min-tools-rev> - <!-- The archives node is mandatory and it cannot be empty. --> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/plat1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:layoutlib> - <sdk:api>5</sdk:api> - <sdk:revision>0</sdk:revision> - </sdk:layoutlib> - <sdk:included-abi>armeabi</sdk:included-abi> - </sdk:platform> - - <sdk:doc> - <sdk:api-level>1</sdk:api-level> - <sdk:revision>1</sdk:revision> - <!-- the license element is not mandatory. --> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/docs.html</sdk:desc-url> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/docs/docs1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:doc> - - <sdk:source> - <sdk:api-level>1</sdk:api-level> - <sdk:revision>1</sdk:revision> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65535</sdk:size> - <sdk:checksum type="sha1">1234ae37115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat1/sources1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:source> - - <sdk:platform> - <sdk:version>1.1</sdk:version> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>12</sdk:revision> - <sdk:uses-license ref="license1" /> - <!-- sdk:description and sdk:desc-url are optional --> - <sdk:archives> - <sdk:archive os="windows"> - <!-- arch attribute is optional --> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-win.zip</sdk:url> - </sdk:archive> - <sdk:archive os="macosx" arch="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-mac.zip</sdk:url> - </sdk:archive> - <sdk:archive os="macosx" arch="ppc"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-mac.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux" arch="x86"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="linux" arch="x86_64"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-2-12-linux.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:layoutlib> - <sdk:api>5</sdk:api> - <sdk:revision>31415</sdk:revision> - </sdk:layoutlib> - <sdk:included-abi>x86</sdk:included-abi> - </sdk:platform> - - <sdk:system-image> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>1</sdk:revision> - <sdk:abi>x86</sdk:abi> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65535</sdk:size> - <sdk:checksum type="sha1">1234ae37115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat1/x86/image1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:system-image> - - <sdk:system-image> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>2</sdk:revision> - <sdk:abi>armeabi-v7a</sdk:abi> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65534</sdk:size> - <sdk:checksum type="sha1">1234ae37115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat1/armv7/image2.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:system-image> - - <sdk:source> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>2</sdk:revision> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65534</sdk:size> - <sdk:checksum type="sha1">1234ae37115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat1/sources2.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:source> - - <sdk:platform> - <sdk:version>Pastry</sdk:version> - <sdk:api-level>5</sdk:api-level> - <sdk:codename>Pastry</sdk:codename> - <sdk:revision>3</sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:description>Preview version for Pastry</sdk:description> - <sdk:desc-url>http://www.example.com/platform1.html</sdk:desc-url> - <!-- The archives node is mandatory and it cannot be empty. --> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/plat1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:layoutlib> - <sdk:api>1</sdk:api> - </sdk:layoutlib> - </sdk:platform> - - <sdk:tool> - <sdk:revision> - <sdk:major>1</sdk:major> - <sdk:minor>2</sdk:minor> - <sdk:micro>3</sdk:micro> - <sdk:preview>4</sdk:preview> - </sdk:revision> - <sdk:description>Some optional description</sdk:description> - <sdk:desc-url>http://www.example.com/tools.html</sdk:desc-url> - <sdk:uses-license ref="license1" /> - <sdk:min-platform-tools-rev> - <sdk:major>4</sdk:major> - </sdk:min-platform-tools-rev> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>http://www.example.com/files/tools1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:tool> - - <sdk:doc> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>42</sdk:revision> - <sdk:uses-license ref="license2" /> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs/2.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs2-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="macosx"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/docs2-mac.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:doc> - - <sdk:tool> - <sdk:revision> - <sdk:major>42</sdk:major> - </sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:min-platform-tools-rev> - <sdk:major>4</sdk:major> - <sdk:minor>0</sdk:minor> - <sdk:micro>0</sdk:micro> - <sdk:preview>5</sdk:preview> - </sdk:min-platform-tools-rev> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools/2.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools2-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="macosx"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/tools2-mac.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:tool> - - <sdk:platform-tool> - <sdk:revision> - <sdk:major>3</sdk:major> - <sdk:minor>0</sdk:minor> - <sdk:micro>0</sdk:micro> - <sdk:preview>5</sdk:preview> - </sdk:revision> - <sdk:uses-license ref="license1" /> - <sdk:archives> - <sdk:archive os="windows"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-tools/2.zip</sdk:url> - </sdk:archive> - <sdk:archive os="linux"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-tools2-linux.tar.bz2</sdk:url> - </sdk:archive> - <sdk:archive os="macosx"> - <sdk:size>65536</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/platform-tools2-mac.tar.bz2</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:platform-tool> - - <sdk:sample> - <sdk:api-level>14</sdk:api-level> - <sdk:revision>24</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65537</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/sample_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some sample package</sdk:description> - <sdk:desc-url>http://www.example.com/sample.html</sdk:desc-url> - <sdk:min-tools-rev> - <sdk:major>5</sdk:major> - </sdk:min-tools-rev> - <sdk:obsolete>This is obsolete</sdk:obsolete> - </sdk:sample> - - <sdk:sample> - <sdk:api-level>14</sdk:api-level> - <sdk:revision>25</sdk:revision> - <sdk:archives> - <sdk:archive os="any" arch="any"> - <sdk:size>65537</sdk:size> - <sdk:checksum type="sha1">3822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum> - <sdk:url>distrib/sample_duff.zip</sdk:url> - </sdk:archive> - </sdk:archives> - <sdk:description>Some sample package</sdk:description> - <sdk:desc-url>http://www.example.com/sample.html</sdk:desc-url> - <sdk:min-tools-rev> - <sdk:major>5</sdk:major> - <sdk:minor>1</sdk:minor> - <sdk:micro>2</sdk:micro> - <sdk:preview>3</sdk:preview> - </sdk:min-tools-rev> - <sdk:obsolete>This is obsolete</sdk:obsolete> - </sdk:sample> - - <sdk:system-image> - <sdk:api-level>42</sdk:api-level> - <sdk:revision>12</sdk:revision> - <sdk:abi>armeabi</sdk:abi> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>1234</sdk:size> - <sdk:checksum type="sha1">12345637115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat42/86/image12.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:system-image> - - <sdk:system-image> - <sdk:api-level>42</sdk:api-level> - <sdk:revision>12</sdk:revision> - <sdk:abi>mips</sdk:abi> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>12345</sdk:size> - <sdk:checksum type="sha1">12345637115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat42/mips/image12.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:system-image> - - <sdk:source> - <sdk:api-level>42</sdk:api-level> - <sdk:revision>12</sdk:revision> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>1234</sdk:size> - <sdk:checksum type="sha1">12345637115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat42/source12.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:source> - -</sdk:sdk-repository> diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/stats_sample_1.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/stats_sample_1.xml deleted file mode 100755 index 344b8a5..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/stats_sample_1.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. ---> -<sdk:sdk-stats - xmlns:sdk="http://schemas.android.com/sdk/android/stats/1"> - - <sdk:platform> - <sdk:api-level>3</sdk:api-level> - <sdk:codename>Vanilla</sdk:codename> - <sdk:version>Android 0.5</sdk:version> - <sdk:share>0.1</sdk:share> - </sdk:platform> - - <sdk:platform> - <sdk:api-level>5</sdk:api-level> - <sdk:codename>Coffee</sdk:codename> - <sdk:version>Android 42.0</sdk:version> - <sdk:share>25.8</sdk:share> - </sdk:platform> - - <sdk:platform> - <sdk:api-level>42</sdk:api-level> - <sdk:codename>Chocolate</sdk:codename> - <sdk:version>Android 32.64</sdk:version> - <sdk:share>74.1</sdk:share> - </sdk:platform> - - <sdk:platform> - <sdk:api-level>5</sdk:api-level> - <sdk:codename>Ignored</sdk:codename> - <sdk:version>API 5 was already seen above</sdk:version> - <sdk:share>99.9</sdk:share> - </sdk:platform> - -</sdk:sdk-stats> diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/sys_img_sample_1.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/sys_img_sample_1.xml deleted file mode 100755 index 6196db4..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/sys_img_sample_1.xml +++ /dev/null @@ -1,83 +0,0 @@ -<?xml version="1.0"?> -<!-- - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. ---> -<sdk:sdk-sys-img - xmlns:sdk="http://schemas.android.com/sdk/android/sys-img/1"> - - <!-- Define a couple of licenses. These will be referenced by uses-license later. --> - - <sdk:license type="text" id="license1"> - This is the license - for this platform. - </sdk:license> - - <sdk:license id="license2"> - Licenses are only of type 'text' right now, so this is implied. - </sdk:license> - - <sdk:system-image> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>1</sdk:revision> - <sdk:abi>x86</sdk:abi> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65535</sdk:size> - <sdk:checksum type="sha1">1234ae37115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat1/x86/image1.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:system-image> - - <sdk:system-image> - <sdk:api-level>2</sdk:api-level> - <sdk:revision>2</sdk:revision> - <sdk:abi>armeabi-v7a</sdk:abi> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>65534</sdk:size> - <sdk:checksum type="sha1">1234ae37115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat1/armv7/image2.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:system-image> - - <sdk:system-image> - <sdk:api-level>42</sdk:api-level> - <sdk:revision>12</sdk:revision> - <sdk:abi>armeabi</sdk:abi> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>1234</sdk:size> - <sdk:checksum type="sha1">12345637115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat42/86/image12.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:system-image> - - <sdk:system-image> - <sdk:api-level>42</sdk:api-level> - <sdk:revision>12</sdk:revision> - <sdk:abi>mips</sdk:abi> - <sdk:archives> - <sdk:archive os="any"> - <sdk:size>12345</sdk:size> - <sdk:checksum type="sha1">12345637115ebf13412bbef91339ee0d94541234</sdk:checksum> - <sdk:url>http://www.example.com/plat42/mips/image12.zip</sdk:url> - </sdk:archive> - </sdk:archives> - </sdk:system-image> - -</sdk:sdk-sys-img> diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/util/BSPatchTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/util/BSPatchTest.java deleted file mode 100755 index 6c6c405..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/util/BSPatchTest.java +++ /dev/null @@ -1,533 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.util; - -import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; - -import junit.framework.TestCase; - - -public class BSPatchTest extends TestCase { - - // $ bsdiff file1 file2 diff-1-2.patch - // $ hexdump -v -e '1/1 "0x%02x, "' diff-1-2.patch - - public void testBSPatch1() throws Exception { - byte[] file1 = toSignedBytes(new short[] { - 0x62, 0x73, 0x64, 0x69, 0x66, 0x66, 0x20, 0x69, 0x73, 0x20, - 0x61, 0x20, 0x74, 0x6f, 0x6f, 0x6c, 0x20, 0x66, 0x6f, 0x72, - 0x20, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x69, 0x6e, 0x67, 0x20, - 0x61, 0x6e, 0x64, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x69, - 0x6e, 0x67, 0x20, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, - 0x20, 0x74, 0x6f, 0x20, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, - 0x20, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x0a - }); - - byte[] file2 = toSignedBytes(new short[] { - 0x62, 0x73, 0x64, 0x69, 0x66, 0x66, 0x20, 0x61, 0x6e, 0x64, - 0x20, 0x62, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x20, 0x61, - 0x72, 0x65, 0x20, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x20, 0x66, - 0x6f, 0x72, 0x20, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x69, 0x6e, - 0x67, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x70, 0x70, 0x6c, - 0x79, 0x69, 0x6e, 0x67, 0x20, 0x70, 0x61, 0x74, 0x63, 0x68, - 0x65, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x69, 0x6e, 0x61, - 0x72, 0x79, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x0a, - }); - - byte[] patch = toSignedBytes(new short[] { - 0x42, 0x53, 0x44, 0x49, 0x46, 0x46, 0x34, 0x30, 0x35, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, - 0x53, 0x59, 0x93, 0x0d, 0x6a, 0xae, 0x00, 0x00, 0x0c, 0x68, - 0x40, 0x58, 0xa8, 0x02, 0x00, 0x04, 0x00, 0x40, 0x00, 0x20, - 0x00, 0x21, 0x88, 0x19, 0x08, 0x32, 0x62, 0x1b, 0xde, 0xbc, - 0x24, 0x08, 0xe9, 0x45, 0x3c, 0x5d, 0xc9, 0x14, 0xe1, 0x42, - 0x42, 0x4c, 0x35, 0xaa, 0xb8, 0x42, 0x5a, 0x68, 0x39, 0x31, - 0x41, 0x59, 0x26, 0x53, 0x59, 0x05, 0xb6, 0xa3, 0x63, 0x00, - 0x00, 0x00, 0x48, 0x00, 0x40, 0x00, 0x00, 0x80, 0x20, 0x00, - 0x21, 0x00, 0x82, 0x83, 0x17, 0x72, 0x45, 0x38, 0x50, 0x90, - 0x05, 0xb6, 0xa3, 0x63, 0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, - 0x59, 0x26, 0x53, 0x59, 0xdb, 0x41, 0x22, 0x6f, 0x00, 0x00, - 0x01, 0x91, 0x80, 0x40, 0x00, 0x3e, 0x45, 0xdc, 0x00, 0x20, - 0x00, 0x22, 0x9a, 0x19, 0x32, 0x7a, 0x7a, 0xa1, 0x00, 0x00, - 0x21, 0xe2, 0xf8, 0x98, 0x42, 0x13, 0x3c, 0xec, 0x35, 0x5f, - 0x17, 0x72, 0x45, 0x38, 0x50, 0x90, 0xdb, 0x41, 0x22, 0x6f - }); - - byte[] expected = file2; - byte[] actual = patchFile(file1, patch); - - assertEquals(toDiffString(expected, actual), - Arrays.toString(expected), Arrays.toString(actual)); - } - - public void testBSPatch2() throws Exception { - byte[] file1 = toSignedBytes(new short[] { - 0x62, 0x73, 0x64, 0x69, 0x66, 0x66, 0x20, 0x61, 0x6e, 0x64, - 0x20, 0x62, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x20, 0x61, - 0x72, 0x65, 0x20, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x20, 0x66, - 0x6f, 0x72, 0x20, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x69, 0x6e, - 0x67, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x70, 0x70, 0x6c, - 0x79, 0x69, 0x6e, 0x67, 0x20, 0x70, 0x61, 0x74, 0x63, 0x68, - 0x65, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x69, 0x6e, 0x61, - 0x72, 0x79, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x0a, - 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, - 0x2e, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x6f, 0x6c, 0x6f, - 0x67, 0x79, 0x2e, 0x6e, 0x65, 0x74, 0x2f, 0x62, 0x73, 0x64, - 0x69, 0x66, 0x66, 0x2f, 0x0a, 0x44, 0x65, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x67, 0x65, - 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x2f, 0x61, 0x70, 0x70, - 0x6c, 0x79, 0x20, 0x61, 0x20, 0x70, 0x61, 0x74, 0x63, 0x68, - 0x20, 0x62, 0x65, 0x74, 0x77, 0x65, 0x65, 0x6e, 0x20, 0x74, - 0x77, 0x6f, 0x20, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x20, - 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x0a - }); - - byte[] file2 = toSignedBytes(new short[] { - 0x62, 0x73, 0x64, 0x69, 0x66, 0x66, 0x20, 0x61, 0x6e, 0x64, - 0x20, 0x62, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x20, 0x61, - 0x72, 0x65, 0x20, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x20, 0x66, - 0x6f, 0x72, 0x20, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x69, 0x6e, - 0x67, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x70, 0x70, 0x6c, - 0x79, 0x69, 0x6e, 0x67, 0x20, 0x70, 0x61, 0x74, 0x63, 0x68, - 0x65, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x69, 0x6e, 0x61, - 0x72, 0x79, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x0a, - 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x3a, 0x20, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, - 0x65, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x20, 0x61, 0x20, - 0x70, 0x61, 0x74, 0x63, 0x68, 0x20, 0x62, 0x65, 0x74, 0x77, - 0x65, 0x65, 0x6e, 0x20, 0x74, 0x77, 0x6f, 0x20, 0x62, 0x69, - 0x6e, 0x61, 0x72, 0x79, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x73, - 0x2e, 0x0a, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, - 0x77, 0x77, 0x2e, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x6f, - 0x6c, 0x6f, 0x67, 0x79, 0x2e, 0x6e, 0x65, 0x74, 0x2f, 0x62, - 0x73, 0x64, 0x69, 0x66, 0x66, 0x2f, 0x0a, 0x42, 0x53, 0x44, - 0x20, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x2c, 0x20, - 0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, - 0x32, 0x30, 0x30, 0x33, 0x2d, 0x32, 0x30, 0x30, 0x35, 0x20, - 0x43, 0x6f, 0x6c, 0x69, 0x6e, 0x20, 0x50, 0x65, 0x72, 0x63, - 0x69, 0x76, 0x61, 0x6c, 0x0a, - }); - - byte[] patch = toSignedBytes(new short[] { - 0x42, 0x53, 0x44, 0x49, 0x46, 0x46, 0x34, 0x30, 0x3e, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xe1, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, - 0x53, 0x59, 0x3f, 0xa6, 0x07, 0x42, 0x00, 0x00, 0x14, 0x5d, - 0x40, 0x58, 0x08, 0x08, 0x00, 0xc8, 0x02, 0x00, 0x00, 0xa0, - 0x00, 0x40, 0x00, 0x20, 0x00, 0x21, 0xa4, 0x69, 0x84, 0xfd, - 0x41, 0x03, 0x40, 0xd0, 0x22, 0xef, 0xe1, 0x49, 0x33, 0x02, - 0xce, 0x2e, 0xe6, 0x8b, 0xb9, 0x22, 0x9c, 0x28, 0x48, 0x1f, - 0xd3, 0x03, 0xa1, 0x00, 0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, - 0x59, 0x26, 0x53, 0x59, 0x58, 0xc3, 0x04, 0xf0, 0x00, 0x00, - 0x00, 0x40, 0x10, 0x40, 0x00, 0x00, 0x02, 0x20, 0x00, 0x21, - 0x00, 0x82, 0x83, 0x17, 0x72, 0x45, 0x38, 0x50, 0x90, 0x58, - 0xc3, 0x04, 0xf0, 0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, 0x59, - 0x26, 0x53, 0x59, 0x26, 0xc7, 0xbc, 0x09, 0x00, 0x00, 0x08, - 0x5f, 0x80, 0x00, 0x10, 0x40, 0x06, 0x5a, 0x00, 0x1c, 0x00, - 0x48, 0x00, 0x2a, 0xe5, 0xdd, 0x20, 0x20, 0x00, 0x31, 0x46, - 0x86, 0x80, 0x00, 0x00, 0x1a, 0xa6, 0x26, 0x40, 0xfd, 0x50, - 0x34, 0x79, 0x27, 0x92, 0x78, 0xda, 0x4d, 0x37, 0xa9, 0x20, - 0x8d, 0x8c, 0x41, 0x90, 0xea, 0x1c, 0x3a, 0xb3, 0xaa, 0x63, - 0x64, 0xa4, 0x27, 0x6d, 0x5b, 0x2a, 0xfc, 0x25, 0x1b, 0xab, - 0xd2, 0xff, 0x8b, 0xb9, 0x22, 0x9c, 0x28, 0x48, 0x13, 0x63, - 0xde, 0x04, 0x80 - }); - - byte[] expected = file2; - byte[] actual = patchFile(file1, patch); - - assertEquals(toDiffString(expected, actual), - Arrays.toString(expected), Arrays.toString(actual)); - } - - public void testBSPatch3() throws Exception { - byte[] file1 = toSignedBytes(new short[] { - 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, - 0x2e, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x6f, 0x6c, 0x6f, - 0x67, 0x79, 0x2e, 0x6e, 0x65, 0x74, 0x2f, 0x62, 0x73, 0x64, - 0x69, 0x66, 0x66, 0x2f, 0x0a, 0x42, 0x69, 0x6e, 0x61, 0x72, - 0x79, 0x20, 0x64, 0x69, 0x66, 0x66, 0x2f, 0x70, 0x61, 0x74, - 0x63, 0x68, 0x20, 0x75, 0x74, 0x69, 0x6c, 0x69, 0x74, 0x79, - 0x0a, 0x53, 0x48, 0x41, 0x31, 0x3a, 0x20, 0x37, 0x32, 0x63, - 0x35, 0x37, 0x34, 0x33, 0x34, 0x62, 0x64, 0x64, 0x34, 0x63, - 0x33, 0x38, 0x33, 0x63, 0x36, 0x39, 0x62, 0x62, 0x30, 0x66, - 0x61, 0x64, 0x34, 0x32, 0x33, 0x35, 0x37, 0x38, 0x35, 0x32, - 0x32, 0x63, 0x64, 0x30, 0x64, 0x33, 0x61, 0x0a, 0x53, 0x48, - 0x41, 0x32, 0x35, 0x36, 0x3a, 0x20, 0x61, 0x62, 0x62, 0x64, - 0x32, 0x32, 0x30, 0x39, 0x33, 0x38, 0x35, 0x65, 0x38, 0x65, - 0x38, 0x38, 0x30, 0x61, 0x64, 0x64, 0x30, 0x62, 0x37, 0x38, - 0x31, 0x37, 0x37, 0x38, 0x64, 0x65, 0x64, 0x34, 0x39, 0x65, - 0x31, 0x30, 0x61, 0x36, 0x66, 0x30, 0x63, 0x37, 0x39, 0x39, - 0x64, 0x33, 0x32, 0x36, 0x61, 0x36, 0x61, 0x65, 0x36, 0x37, - 0x30, 0x33, 0x36, 0x39, 0x36, 0x38, 0x66, 0x62, 0x31, 0x64, - 0x0a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x3a, 0x20, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, - 0x74, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x20, 0x61, - 0x20, 0x70, 0x61, 0x74, 0x63, 0x68, 0x20, 0x62, 0x65, 0x74, - 0x77, 0x65, 0x65, 0x6e, 0x20, 0x74, 0x77, 0x6f, 0x20, 0x62, - 0x69, 0x6e, 0x61, 0x72, 0x79, 0x20, 0x66, 0x69, 0x6c, 0x65, - 0x73, 0x0a, 0x20, 0x62, 0x73, 0x64, 0x69, 0x66, 0x66, 0x20, - 0x61, 0x6e, 0x64, 0x20, 0x62, 0x73, 0x70, 0x61, 0x74, 0x63, - 0x68, 0x20, 0x61, 0x72, 0x65, 0x20, 0x74, 0x6f, 0x6f, 0x6c, - 0x73, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x62, 0x75, 0x69, 0x6c, - 0x64, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x61, - 0x70, 0x70, 0x6c, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x70, 0x61, - 0x74, 0x63, 0x68, 0x65, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x62, - 0x69, 0x6e, 0x61, 0x72, 0x79, 0x20, 0x66, 0x69, 0x6c, 0x65, - 0x73, 0x2e, 0x0a - }); - - byte[] file2 = toSignedBytes(new short[] { - 0x42, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x20, 0x64, 0x69, 0x66, - 0x66, 0x2f, 0x70, 0x61, 0x74, 0x63, 0x68, 0x20, 0x75, 0x74, - 0x69, 0x6c, 0x69, 0x74, 0x79, 0x0a, 0x48, 0x6f, 0x6d, 0x65, - 0x70, 0x61, 0x67, 0x65, 0x3a, 0x20, 0x20, 0x20, 0x20, 0x68, - 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, - 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x6f, 0x6c, 0x6f, 0x67, - 0x79, 0x2e, 0x6e, 0x65, 0x74, 0x2f, 0x62, 0x73, 0x64, 0x69, - 0x66, 0x66, 0x2f, 0x0a, 0x53, 0x48, 0x41, 0x31, 0x3a, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x37, 0x32, 0x63, - 0x35, 0x37, 0x34, 0x33, 0x34, 0x62, 0x64, 0x64, 0x34, 0x63, - 0x33, 0x38, 0x33, 0x63, 0x36, 0x39, 0x62, 0x62, 0x30, 0x66, - 0x61, 0x64, 0x34, 0x32, 0x33, 0x35, 0x37, 0x38, 0x35, 0x32, - 0x32, 0x63, 0x64, 0x30, 0x64, 0x33, 0x61, 0x0a, 0x53, 0x48, - 0x41, 0x32, 0x35, 0x36, 0x3a, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x61, 0x62, 0x62, 0x64, 0x32, 0x32, 0x30, 0x39, 0x33, - 0x38, 0x35, 0x65, 0x38, 0x65, 0x38, 0x38, 0x30, 0x61, 0x64, - 0x64, 0x30, 0x62, 0x37, 0x38, 0x31, 0x37, 0x37, 0x38, 0x64, - 0x65, 0x64, 0x34, 0x39, 0x65, 0x31, 0x30, 0x61, 0x36, 0x66, - 0x30, 0x63, 0x37, 0x39, 0x39, 0x64, 0x33, 0x32, 0x36, 0x61, - 0x36, 0x61, 0x65, 0x36, 0x37, 0x30, 0x33, 0x36, 0x39, 0x36, - 0x38, 0x66, 0x62, 0x31, 0x64, 0x0a, 0x44, 0x65, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x67, - 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x2f, 0x61, 0x70, - 0x70, 0x6c, 0x79, 0x20, 0x61, 0x20, 0x70, 0x61, 0x74, 0x63, - 0x68, 0x20, 0x62, 0x65, 0x74, 0x77, 0x65, 0x65, 0x6e, 0x20, - 0x74, 0x77, 0x6f, 0x20, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, - 0x20, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x0a, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x62, 0x73, 0x64, 0x69, 0x66, 0x66, 0x20, 0x61, 0x6e, 0x64, - 0x20, 0x62, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x20, 0x61, - 0x72, 0x65, 0x20, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x20, 0x66, - 0x6f, 0x72, 0x20, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x69, 0x6e, - 0x67, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x70, 0x70, 0x6c, - 0x79, 0x69, 0x6e, 0x67, 0x20, 0x70, 0x61, 0x74, 0x63, 0x68, - 0x65, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x69, 0x6e, 0x61, - 0x72, 0x79, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x0a, - }); - - byte[] patch = toSignedBytes(new short[] { - 0x42, 0x53, 0x44, 0x49, 0x46, 0x46, 0x34, 0x30, 0x48, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x68, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, - 0x53, 0x59, 0xea, 0x1c, 0x55, 0x4e, 0x00, 0x00, 0x07, 0xfa, - 0x40, 0x7c, 0x0e, 0x00, 0x10, 0x88, 0x00, 0x10, 0x02, 0x20, - 0x00, 0x40, 0x00, 0x20, 0x00, 0x21, 0x29, 0xa8, 0x00, 0x6d, - 0x42, 0x98, 0x00, 0x09, 0x9a, 0x99, 0xcc, 0xb7, 0x2b, 0xcd, - 0xf7, 0x1e, 0x00, 0x86, 0x22, 0x21, 0x09, 0x25, 0x14, 0xc5, - 0x0e, 0xd4, 0x61, 0xf1, 0x77, 0x24, 0x53, 0x85, 0x09, 0x0e, - 0xa1, 0xc5, 0x54, 0xe0, 0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, - 0x59, 0x26, 0x53, 0x59, 0xb2, 0xea, 0xe3, 0xb5, 0x00, 0x00, - 0x00, 0xc8, 0x00, 0xc0, 0x00, 0x00, 0x02, 0x00, 0x08, 0x20, - 0x00, 0x21, 0x26, 0x41, 0x98, 0xa8, 0x0e, 0x2e, 0xe4, 0x8a, - 0x70, 0xa1, 0x21, 0x65, 0xd5, 0xc7, 0x6a, 0x42, 0x5a, 0x68, - 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0x99, 0x1b, 0x67, - 0xdb, 0x00, 0x00, 0x07, 0xff, 0x80, 0x40, 0x00, 0x10, 0x00, - 0x40, 0x00, 0x20, 0x10, 0x20, 0x40, 0x08, 0x00, 0x22, 0x82, - 0xc0, 0x00, 0x20, 0x00, 0x31, 0x00, 0x00, 0x06, 0x81, 0x33, - 0x50, 0xc3, 0x00, 0x20, 0x73, 0xb3, 0x44, 0x9c, 0xfd, 0xde, - 0x1f, 0x68, 0xbb, 0x92, 0x29, 0xc2, 0x84, 0x84, 0xc8, 0xdb, - 0x3e, 0xd8 - }); - - byte[] expected = file2; - byte[] actual = patchFile(file1, patch); - - assertEquals(toDiffString(expected, actual), - Arrays.toString(expected), Arrays.toString(actual)); - } - - private String toDiffString(byte[] a1, byte[] a2) { - StringBuilder sb = new StringBuilder(); - int n1 = a1.length; - int n2 = a2.length; - boolean was_same = false; - - for (int i = 0; i < n1; i++) { - boolean same = i > 1 && - i+2 < n1 && - i+2 < n2 && - a1[i+0] == a2[i+0] && - a1[i+1] == a2[i+1] && - a1[i+2] == a2[i+2]; - if (!same) { - if (i >= n2) { - sb.append(String.format("[%1$3d] %2$02x %2$c | -- -\n", i, a1[i])); - } else { - sb.append(String.format("[%1$3d] %2$02x %2$c | %3$02x %3$c\n", i, a1[i], a2[i])); - } - } else if (!was_same) { - sb.append(String.format("[%1$3d] ...\n", i)); - } - was_same = same; - } - for (int i = n1; i < n2; i++) { - sb.append(String.format("[%1$3d] -- - | %2$02x %2$c\n", i, a2[i])); - } - - return sb.toString(); - } - - /** - * Work around the lack of unsigned bytes in java by providing an initialization - * array where each short is in the range 0..0xFF and converting it to signed bytes. - * - * unsigned byte: 0..127 => signed java byte: 0..127 - * unsigned byte: 128..255 => signed java byte: -128..-1 - * - * unsigned to signed java: (unsigned - 256) if unsigned > 127 - * signed java to unsigned: (256 + signed) if signed < 0 - */ - private byte[] toSignedBytes(short[] s) { - int n = s.length; - byte[] b = new byte[n]; - for (int i = 0; i < n; i++) { - short v = s[i]; - b[i] = v < 128 ? (byte)v : (byte)(v - 256); - } - return b; - } - - @SuppressWarnings("unused") - private byte toSigned(int unsigned) { - return unsigned < 128 ? (byte)unsigned : (byte)(unsigned - 256); - } - - private short toUnsigned(byte signed) { - if (signed >= 0) { - return signed; - } else { - return (short) ((short) 256 + signed); - } - } - - /** - * Patches the binary "file1" using the bsdiff/bspatch "patch" data. - * This implements bspatch.c in Java. - * - * Reference: http://www.daemonology.net/bsdiff/ <br/> - * Based on bspatch.c as identified by <br/> - * {@code $FreeBSD: src/usr.bin/bsdiff/bspatch/bspatch.c,v 1.1 2005/08/06 01:59:06 cperciva Exp $} - * (BSD license, Copyright 2003-2005 Colin Percival) - * - * @param file1 The base file to be patched. - * @param patch The binary patch to apply to base file. - * @return A new byte array representing the patched file. - * @throws PatchException when the patch header is invalid. - * @throws IOException if the BZIP2 decoder fails. - */ - private byte[] patchFile(byte[] file1, byte[] patch) throws PatchException, IOException { - /* - File format: - 0 8 "BSDIFF40" - 8 8 X - 16 8 Y - 24 8 sizeof(newfile) - 32 X bzip2(control block) - 32+X Y bzip2(diff block) - 32+X+Y ??? bzip2(extra block) - with control block a set of triples (x,y,z) meaning "add x bytes - from oldfile to x bytes from the diff block; copy y bytes from the - extra block; seek forwards in oldfile by z bytes". - */ - - /* Read header */ - if (patch.length < 32) { - throw new PatchException("Header.len < 32"); - } - byte[] header = patch; - - /* Check for appropriate magic */ - if (header[0] != 'B' || header[1] != 'S' || header[2] != 'D' || header[3] != 'I' || - header[4] != 'F' || header[5] != 'F' || header[6] != '4' || header[7] != '0') { - throw new PatchException("Invalid header signature"); - } - - /* Read lengths from header */ - long bzctrllen = offtin(header, 8); - long bzdatalen = offtin(header, 16); - long newsize = offtin(header, 24); - if (bzctrllen < 0 || bzdatalen < 0 || newsize < 0) { - throw new PatchException("Invalid header lengths"); - } - - // Note: bspatch uses long lengths everywhere; - // however new byte[] doesn't support that and we don't expect to - // have 2GB+ file sizes to diff any time soon so let's - // do a first implementation that only supports 2^32 sizes. - - /* Read embedded files using Apache Common Compress' BZIP2 */ - InputStream cpfbz2 = readBzip2Data(patch, 32, bzctrllen); - InputStream dpfbz2 = readBzip2Data(patch, 32 + bzctrllen, bzdatalen); - InputStream epfbz2 = readBzip2Data(patch, 32 + bzctrllen + bzdatalen, -1); - - int oldsize = file1.length; - byte[] old = file1; - - byte[] _new = new byte[(int) newsize]; - - long ctrl[] = new long[3]; - byte buf[] = new byte[8]; - long oldpos = 0; - long newpos = 0; - while (newpos < newsize) { - long lenread; - - /* Read control data */ - for(int i = 0; i <= 2; i++) { - lenread = BZ2_bzRead(cpfbz2, buf, 0, 8); - if (lenread < 8) { - throw new PatchException("Failed to read control data") ; - } - ctrl[i] = offtin(buf, 0); - }; - - /* Sanity-check */ - if (newpos + ctrl[0] > newsize) { - throw new PatchException("Sanity check failed") ; - } - - /* Read diff string */ - lenread = BZ2_bzRead(dpfbz2, _new, newpos, ctrl[0]); - if (lenread < ctrl[0]) { - throw new PatchException("Failed to read diff data") ; - } - - /* Add old data to diff string */ - for (int i = 0; i < ctrl[0]; i++) { - if (oldpos + i >= 0 && oldpos + i < oldsize) { - _new[(int) (newpos + i)] += old[(int) (oldpos + i)]; - } - } - - /* Adjust pointers */ - newpos += ctrl[0]; - oldpos += ctrl[0]; - - /* Sanity-check */ - if (newpos + ctrl[1] > newsize) { - throw new PatchException("Sanity check failed") ; - } - - /* Read extra string */ - lenread = BZ2_bzRead(epfbz2, _new, newpos, ctrl[1]); - if (lenread < ctrl[1]) { - throw new PatchException("Failed to read extra data") ; - } - - /* Adjust pointers */ - newpos += ctrl[1]; - oldpos += ctrl[2]; - } - - /* Clean up the bzip2 reads */ - cpfbz2.close(); - dpfbz2.close(); - epfbz2.close(); - - /* Write the new file */ - // nop - - return _new; - } - - private long offtin(byte[] header, int offset) { - long y = 0; - - offset += 7; - y = header[offset] & 0x7F; - boolean sign = (header[offset] & 0x80) != 0; - for (int i = 6; i >= 0; i--) { - y = y * 256 + toUnsigned(header[--offset]); - } - - if (sign) { - y = -y; - } - - return y; - } - - /** - * Decode a BZIP2 data block starting at the given offset. - * - * @param data The binary data of the file. - * @param offset The index where the file begins - * @param length The length to read. Use -1 to mean "up to the end". - * @return A new decoded byte array. - * @throws IOException when the BZIP2 decompression fails. - */ - private InputStream readBzip2Data(byte[] data, long offset, long length) throws IOException { - if (length == -1) { - length = data.length - offset; - } - ByteArrayInputStream is = new ByteArrayInputStream(data, (int) offset, (int) length); - BZip2CompressorInputStream bis = new BZip2CompressorInputStream(is); - return bis; - } - - /** - * Reads the {@code length} next bytes from the bzip2 input stream. - * - * @param bzip2is The input stream to read from. - * @param dest The destination buffer to fill. - * @param length The length to read in bytes. - * @return The number of bytes read. - * @throws IOException If there's not enough data to read. - */ - private long BZ2_bzRead(InputStream bzip2is, byte[] dest, long offset, long length) - throws IOException { - for (long i = 0; i < length; ) { - int len = bzip2is.read(dest, (int) (offset + i), (int) (length - i)); - if (len == -1) { - throw new IOException("Bzip2 EOF"); - } - i += len; - } - return length; - } - - - @SuppressWarnings("serial") - static class PatchException extends Exception { - public PatchException() { - super("Corrupt patch"); - } - public PatchException(String msg) { - super("Corrupt patch: " + msg); - } - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/util/CommandLineParserTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/util/CommandLineParserTest.java deleted file mode 100644 index 7d8a01f..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/util/CommandLineParserTest.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.util; - -import com.android.utils.ILogger; -import com.android.utils.StdLogger; - -import java.util.Arrays; -import java.util.List; - -import junit.framework.TestCase; - - -public class CommandLineParserTest extends TestCase { - - private StdLogger mLog; - - /** - * A mock version of the {@link CommandLineParser} class that does not - * exits and captures its stdout/stderr output. - */ - public static class MockCommandLineProcessor extends CommandLineParser { - private boolean mExitCalled; - private boolean mHelpCalled; - private String mStdOut = ""; - private String mStdErr = ""; - - public MockCommandLineProcessor(ILogger logger) { - super(logger, - new String[][] { - { "verb1", "action1", "Some action" }, - { "verb1", "action2", "Another action" }, - { "verb2", NO_VERB_OBJECT, "Action with string array" }, - }); - define(Mode.STRING, false /*mandatory*/, - "verb1", "action1", "1", "first", "non-mandatory flag", null); - define(Mode.STRING, true /*mandatory*/, - "verb1", "action1", "2", "second", "mandatory flag", null); - - define(Mode.STRING, true /*mandatory*/, - "verb2", NO_VERB_OBJECT, "1", "first", "1st mandatory flag", null); - define(Mode.STRING_ARRAY, true /*mandatory*/, - "verb2", NO_VERB_OBJECT, "2", "second", "2nd mandatory flag", null); - define(Mode.STRING, true /*mandatory*/, - "verb2", NO_VERB_OBJECT, "3", "third", "3rd mandatory flag", null); - } - - @Override - public void printHelpAndExitForAction(String verb, String directObject, - String errorFormat, Object... args) { - mHelpCalled = true; - super.printHelpAndExitForAction(verb, directObject, errorFormat, args); - } - - @Override - protected void exit() { - mExitCalled = true; - } - - @Override - protected void stdout(String format, Object... args) { - String s = String.format(format, args); - mStdOut += s + "\n"; - // don't call super to avoid printing stuff - } - - @Override - protected void stderr(String format, Object... args) { - String s = String.format(format, args); - mStdErr += s + "\n"; - // don't call super to avoid printing stuff - } - - public boolean wasHelpCalled() { - return mHelpCalled; - } - - public boolean wasExitCalled() { - return mExitCalled; - } - - public String getStdOut() { - return mStdOut; - } - - public String getStdErr() { - return mStdErr; - } - } - - @Override - protected void setUp() throws Exception { - mLog = new StdLogger(StdLogger.Level.VERBOSE); - super.setUp(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - - public void testPrintHelpAndExit() { - MockCommandLineProcessor c = new MockCommandLineProcessor(mLog); - assertFalse(c.wasExitCalled()); - assertFalse(c.wasHelpCalled()); - assertTrue(c.getStdOut().equals("")); - assertTrue(c.getStdErr().equals("")); - c.printHelpAndExit(null); - assertTrue(c.getStdOut().indexOf("-v") != -1); - assertTrue(c.getStdOut().indexOf("--verbose") != -1); - assertTrue(c.getStdErr().equals("")); - assertTrue(c.wasExitCalled()); - - c = new MockCommandLineProcessor(mLog); - assertFalse(c.wasExitCalled()); - assertTrue(c.getStdOut().equals("")); - assertTrue(c.getStdErr().indexOf("Missing parameter") == -1); - - c.printHelpAndExit("Missing %s", "parameter"); - assertTrue(c.wasExitCalled()); - assertFalse(c.getStdOut().equals("")); - assertTrue(c.getStdErr().indexOf("Missing parameter") != -1); - } - - public void testVerbose() { - MockCommandLineProcessor c = new MockCommandLineProcessor(mLog); - - assertFalse(c.isVerbose()); - c.parseArgs(new String[] { "-v" }); - assertTrue(c.isVerbose()); - assertTrue(c.wasExitCalled()); - assertTrue(c.wasHelpCalled()); - assertTrue(c.getStdErr().indexOf("Missing verb name.") != -1); - - c = new MockCommandLineProcessor(mLog); - c.parseArgs(new String[] { "--verbose" }); - assertTrue(c.isVerbose()); - assertTrue(c.wasExitCalled()); - assertTrue(c.wasHelpCalled()); - assertTrue(c.getStdErr().indexOf("Missing verb name.") != -1); - } - - public void testHelp() { - MockCommandLineProcessor c = new MockCommandLineProcessor(mLog); - - c.parseArgs(new String[] { "-h" }); - assertTrue(c.wasExitCalled()); - assertTrue(c.wasHelpCalled()); - assertTrue(c.getStdErr().indexOf("Missing verb name.") == -1); - - c = new MockCommandLineProcessor(mLog); - c.parseArgs(new String[] { "--help" }); - assertTrue(c.wasExitCalled()); - assertTrue(c.wasHelpCalled()); - assertTrue(c.getStdErr().indexOf("Missing verb name.") == -1); - } - - public void testMandatory() { - MockCommandLineProcessor c = new MockCommandLineProcessor(mLog); - - c.parseArgs(new String[] { "verb1", "action1", "-1", "value1", "-2", "value2" }); - assertFalse(c.wasExitCalled()); - assertFalse(c.wasHelpCalled()); - assertEquals("", c.getStdErr()); - assertEquals("value1", c.getValue("verb1", "action1", "first")); - assertEquals("value2", c.getValue("verb1", "action1", "second")); - - c = new MockCommandLineProcessor(mLog); - c.parseArgs(new String[] { "verb1", "action1", "-2", "value2" }); - assertFalse(c.wasExitCalled()); - assertFalse(c.wasHelpCalled()); - assertEquals("", c.getStdErr()); - assertEquals(null, c.getValue("verb1", "action1", "first")); - assertEquals("value2", c.getValue("verb1", "action1", "second")); - - c = new MockCommandLineProcessor(mLog); - c.parseArgs(new String[] { "verb1", "action1" }); - assertTrue(c.wasExitCalled()); - assertTrue(c.wasHelpCalled()); - assertTrue(c.getStdErr().indexOf("must be defined") != -1); - assertEquals(null, c.getValue("verb1", "action1", "first")); - assertEquals(null, c.getValue("verb1", "action1", "second")); - } - - public void testStringArray() { - MockCommandLineProcessor c = new MockCommandLineProcessor(mLog); - - c.parseArgs(new String[] { "verb2", - "-1", "value1", - "-2", "value2_a", "value2_b", "value2_c", "value2_d", - "-3", "value3" }); - assertFalse(c.wasExitCalled()); - assertFalse(c.wasHelpCalled()); - assertEquals("", c.getStdErr()); - assertEquals("value1", c.getValue("verb2", null, "first")); - assertTrue(c.getValue("verb2", null, "second") instanceof List<?>); - assertEquals("[value2_a, value2_b, value2_c, value2_d]", - Arrays.toString(((List<?>) c.getValue("verb2", null, "second")).toArray())); - assertEquals("value3", c.getValue("verb2", null, "third")); - } - - public void testStringArray_DashDash() { - MockCommandLineProcessor c = new MockCommandLineProcessor(mLog); - - // Use -- to tell argument -2 it can absorb any argument, including dashed ones. - // Logically -2 must be the last argument and -1/-3 must be placed before it. - c.parseArgs(new String[] { "verb2", - "-1", "value1", - "-3", "value3", - "-2", "value2_a", "--", "-value2_b", "--value2_c", "value2_d" }); - assertFalse(c.wasExitCalled()); - assertFalse(c.wasHelpCalled()); - assertEquals("", c.getStdErr()); - assertEquals("value1", c.getValue("verb2", null, "first")); - assertTrue(c.getValue("verb2", null, "second") instanceof List<?>); - assertEquals("[value2_a, --, -value2_b, --value2_c, value2_d]", - Arrays.toString(((List<?>) c.getValue("verb2", null, "second")).toArray())); - assertEquals("value3", c.getValue("verb2", null, "third")); - } - - public void testStringArray_EmptyStringArray() { - MockCommandLineProcessor c = new MockCommandLineProcessor(mLog); - - c.parseArgs(new String[] { "verb2", - "-1", "value1", - "-2", - "-3", "value3" }); - assertTrue(c.wasExitCalled()); - assertTrue(c.wasHelpCalled()); - assertEquals("Invalid usage for flag -2: No values provided.", c.getStdErr().trim()); - } -} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/util/LineUtilTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/util/LineUtilTest.java deleted file mode 100755 index 213efc2..0000000 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/util/LineUtilTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.sdklib.util; - -import com.android.sdklib.util.LineUtil; - -import junit.framework.TestCase; - - -public class LineUtilTest extends TestCase { - - public void testReflowLine() { - boolean gotNpe = false; - try { - LineUtil.reflowLine(null); - } catch(NullPointerException e) { - gotNpe = true; - } finally { - assertTrue(gotNpe); - } - - assertEquals("", LineUtil.reflowLine("")); - - assertEquals("1234567", LineUtil.reflowLine("1234567")); - - assertEquals( - "-- verbose, -v: This description for this flag fits in exactly 78 characters.", - LineUtil.reflowLine("-- verbose, -v: This description for this flag fits in exactly 78 characters.")); - - assertEquals( - "--verbose, -v : This description for this flag fits in more than 78\n" + - " characters and needs to wrap up at the colon.", - LineUtil.reflowLine("--verbose, -v : This description for this flag fits in more than 78 characters and needs to wrap up at the colon.")); - - assertEquals( - "If the line needs to wrap but there's no colon marker, the line will just wrap\n" + - " with 4 spaces.", - LineUtil.reflowLine("If the line needs to wrap but there's no colon marker, the line will just wrap with 4 spaces.")); - - assertEquals( - "--blah: More than 78 characters and lots of\n" + - " spaces. ", - LineUtil.reflowLine("--blah: More than 78 characters and lots of spaces. ")); - - assertEquals( - "In this case the colon is at the very end of the string and it's not going to\n" + - " wrap as expected:", - LineUtil.reflowLine("In this case the colon is at the very end of the string and it's not going to wrap as expected:")); - - assertEquals( - "--flag:In-this-case-there-is-no-whitespace-and-wrapping-will-cut-just-at-the-7\n" + - " 8-mark.", - LineUtil.reflowLine("--flag:In-this-case-there-is-no-whitespace-and-wrapping-will-cut-just-at-the-78-mark.")); - - assertEquals( - "Desc: This line is split in 2.\n" + - " The second line must align at the colon and yet still wrap as expected\n" + - " if it doesn't fit properly.\n" + - " The end.", - LineUtil.reflowLine("Desc: This line is split in 2.\nThe second line must align at the colon and yet still wrap as expected if it doesn't fit properly.\nThe end.")); - - assertEquals( - "Desc: This line is split in 2\n" + - " even though it doesn't need to wrap.", - LineUtil.reflowLine("Desc: This line is split in 2\n\n\n\n\n\neven though it doesn't need to wrap.")); - - } -} |