Package com.microsoft.windowsazure.services.media.models

Examples of com.microsoft.windowsazure.services.media.models.AssetInfo


        writePolicy = createWritePolicy("uploadWritePolicy", 30);
    }

    @Test
    public void canCreateFileForUploadedBlob() throws Exception {
        AssetInfo asset = createTestAsset("createFileForUploadedBlob");
        LocatorInfo locator = createLocator(writePolicy, asset, 5);
        WritableBlobContainerContract blobWriter = service
                .createBlobWriter(locator);

        createAndUploadBlob(blobWriter, BLOB_NAME, firstPrimes);

        service.action(AssetFile.createFileInfos(asset.getId()));

        ListResult<AssetFileInfo> files = service.list(AssetFile.list(asset
                .getAssetFilesLink()));

        assertEquals(1, files.size());
        AssetFileInfo file = files.get(0);
        assertEquals(BLOB_NAME, file.getName());
View Full Code Here


        assertEquals(BLOB_NAME, file.getName());
    }

    @Test
    public void canCreateFileEntityDirectly() throws Exception {
        AssetInfo asset = createTestAsset("createFileEntityDirectly");
        LocatorInfo locator = createLocator(writePolicy, asset, 5);
        WritableBlobContainerContract blobWriter = service
                .createBlobWriter(locator);

        createAndUploadBlob(blobWriter, BLOB_NAME_2, firstPrimes);

        service.create(AssetFile.create(asset.getId(), BLOB_NAME_2));

        ListResult<AssetFileInfo> files = service.list(AssetFile.list(asset
                .getAssetFilesLink()));

        boolean found = false;
        for (AssetFileInfo file : files) {
            if (file.getName().equals(BLOB_NAME_2)) {
View Full Code Here

        assertTrue(found);
    }

    @Test
    public void canCreateAssetWithMultipleFiles() throws Exception {
        AssetInfo asset = createTestAsset("createWithMultipleFiles");
        AccessPolicyInfo policy = createWritePolicy("createWithMultipleFiles",
                10);
        LocatorInfo locator = createLocator(policy, asset, 5);

        WritableBlobContainerContract blobWriter = service
                .createBlobWriter(locator);

        createAndUploadBlob(blobWriter, "blob1.bin", firstPrimes);
        createAndUploadBlob(blobWriter, "blob2.bin", onesAndZeros);
        createAndUploadBlob(blobWriter, "blob3.bin", countingUp);

        AssetFileInfo file1 = service.create(AssetFile
                .create(asset.getId(), "blob1.bin").setIsPrimary(true)
                .setIsEncrypted(false)
                .setContentFileSize(new Long(firstPrimes.length)));

        AssetFileInfo file2 = service.create(AssetFile
                .create(asset.getId(), "blob2.bin").setIsPrimary(false)
                .setIsEncrypted(false)
                .setContentFileSize(new Long(onesAndZeros.length)));

        AssetFileInfo file3 = service.create(AssetFile
                .create(asset.getId(), "blob3.bin").setIsPrimary(false)
                .setIsEncrypted(false)
                .setContentFileSize(new Long(countingUp.length))
                .setContentChecksum("1234"));

        ListResult<AssetFileInfo> files = service.list(AssetFile.list(asset
                .getAssetFilesLink()));

        assertEquals(3, files.size());

        ArrayList<AssetFileInfo> results = new ArrayList<AssetFileInfo>(files);
View Full Code Here

        assertAssetFileInfoEquals("results.get(2)", file3, results.get(2));
    }

    @Test
    public void canCreateFileAndThenUpdateIt() throws Exception {
        AssetInfo asset = createTestAsset("createAndUpdate");
        AccessPolicyInfo policy = createWritePolicy("createAndUpdate", 10);
        LocatorInfo locator = createLocator(policy, asset, 5);
        WritableBlobContainerContract blobWriter = service
                .createBlobWriter(locator);

        createAndUploadBlob(blobWriter, "toUpdate.bin", firstPrimes);

        AssetFileInfo file = service.create(AssetFile.create(asset.getId(),
                "toUpdate.bin"));

        service.update(AssetFile.update(file.getId()).setMimeType(
                "application/octet-stream"));
View Full Code Here

        assertEquals("application/octet-stream", fromServer.getMimeType());
    }

    @Test
    public void canDeleteFileFromAsset() throws Exception {
        AssetInfo asset = createTestAsset("deleteFile");
        AccessPolicyInfo policy = createWritePolicy("deleteFile", 10);
        LocatorInfo locator = createLocator(policy, asset, 5);
        WritableBlobContainerContract blobWriter = service
                .createBlobWriter(locator);

        createAndUploadBlob(blobWriter, "todelete.bin", firstPrimes);
        createAndUploadBlob(blobWriter, "tokeep.bin", onesAndZeros);

        service.action(AssetFile.createFileInfos(asset.getId()));

        ListResult<AssetFileInfo> originalFiles = service.list(AssetFile
                .list(asset.getAssetFilesLink()));
        assertEquals(2, originalFiles.size());

        for (AssetFileInfo file : originalFiles) {
            if (file.getName().equals("todelete.bin")) {
                service.delete(AssetFile.delete(file.getId()));
                break;
            }
        }

        ListResult<AssetFileInfo> newFiles = service.list(AssetFile.list(asset
                .getAssetFilesLink()));
        assertEquals(1, newFiles.size());
        assertEquals("tokeep.bin", newFiles.get(0).getName());
    }
View Full Code Here

    @BeforeClass
    public static void setup() throws Exception {
        IntegrationTestBase.setup();

        AssetInfo asset = service.create(Asset.create().setName(
                testAssetPrefix + "uploadBlockBlobAsset"));

        AccessPolicyInfo policy = service.create(AccessPolicy.create(
                testPolicyPrefix + "uploadWritePolicy", 10,
                EnumSet.of(AccessPolicyPermission.WRITE)));
View Full Code Here

    }

    @Test
    public void canCreateDefaultAssetEntity() throws Exception {

        AssetInfo asset = entityService.create(Asset.create());

        assertNotNull(asset.getId());
    }
View Full Code Here

    @Test
    public void canCreateAssetOnServerWithNameAndAltId() throws Exception {
        String name = testAssetPrefix + "AName";
        String altId = "unit test alt id";

        AssetInfo asset = entityService.create(Asset.create().setName(name)
                .setAlternateId(altId));

        assertNotNull(asset.getId());
        assertEquals(name, asset.getName());
        assertEquals(altId, asset.getAlternateId());
    }
View Full Code Here

        assertEquals(altId, asset.getAlternateId());
    }

    @Test
    public void canRetrieveAssetById() throws Exception {
        AssetInfo createdAsset = entityService.create(Asset.create().setName(
                testAssetPrefix + "canRetrieveAssetById"));

        AssetInfo retrieved = entityService
                .get(Asset.get(createdAsset.getId()));

        assertEquals(createdAsset.getId(), retrieved.getId());
        assertEquals(createdAsset.getName(), retrieved.getName());

    }
View Full Code Here

    @Test
    public void canUpdateAssetNameAndAltId() throws Exception {
        String newName = testAssetPrefix + "newName";
        String newAltId = "updated alt id";

        AssetInfo initialAsset = entityService.create(Asset.create().setName(
                testAssetPrefix + "originalName"));

        entityService.update(Asset.update(initialAsset.getId())
                .setName(newName).setAlternateId(newAltId));

        AssetInfo updatedAsset = entityService.get(Asset.get(initialAsset
                .getId()));

        assertEquals(initialAsset.getId(), updatedAsset.getId());
        assertEquals(newName, updatedAsset.getName());
        assertEquals(newAltId, updatedAsset.getAlternateId());
    }
View Full Code Here

TOP

Related Classes of com.microsoft.windowsazure.services.media.models.AssetInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.