Package org.jclouds.cloudfiles.domain

Examples of org.jclouds.cloudfiles.domain.ContainerCDNMetadata


            getApi().disableCDN(containerNameWithCDN);
            getApi().disableCDN(containerNameWithoutCDN);
         } catch (Exception e) {

         }
         ContainerCDNMetadata cdnMetadata = null;

         // Enable CDN with PUT for one container
         final URI cdnUri = getApi().enableCDN(containerNameWithCDN);
         assertNotNull(cdnUri);

         // Confirm CDN is enabled via HEAD request and has default TTL
         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());
         assertEquals(cdnMetadata.getCDNUri(), cdnUri);
        
         // Test static website metadata
         getApi().setCDNStaticWebsiteIndex(containerNameWithCDN, "index.html");
         getApi().setCDNStaticWebsiteError(containerNameWithCDN, "error.html");
        
         ContainerMetadata containerMetadata = getApi().getContainerMetadata(containerNameWithCDN);
        
         assertEquals(containerMetadata.getMetadata().get("web-index"), "index.html");
         assertEquals(containerMetadata.getMetadata().get("web-error"), "error.html");
        
         cdnMetadata = getApi().getCDNMetadata(containerNameWithoutCDN);
         assert cdnMetadata == null || !cdnMetadata.isCDNEnabled() : containerNameWithoutCDN
                  + " should not have metadata";

         assert getApi().getCDNMetadata("DoesNotExist") == null;
        
         // List CDN metadata for containers, and ensure all CDN info is
         // available for enabled
         // container
         Set<ContainerCDNMetadata> cdnMetadataList = getApi().listCDNContainers();
         assertTrue(cdnMetadataList.size() >= 1);

         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
         final boolean cdnEnabled = cdnMetadata.isCDNEnabled();
         final boolean logRetention = cdnMetadata.isLogRetention();
         final long initialTTL = cdnMetadata.getTTL();
         final URI cdnSslUri = cdnMetadata.getCDNSslUri();
         final URI cdnStreamingUri = cdnMetadata.getCDNStreamingUri();
         final URI cdnIosUri = cdnMetadata.getCDNIosUri();
         assertTrue(cdnMetadataList.contains(new ContainerCDNMetadata(
            containerNameWithCDN, cdnEnabled, logRetention, initialTTL, cdnUri, cdnSslUri, cdnStreamingUri, cdnIosUri)));

         // Test listing with options
         cdnMetadataList = getApi().listCDNContainers(ListCdnContainerOptions.Builder.enabledOnly());
         assertTrue(Iterables.all(cdnMetadataList, new Predicate<ContainerCDNMetadata>() {
            public boolean apply(ContainerCDNMetadata cdnMetadata) {
               return cdnMetadata.isCDNEnabled();
            }
         }));

         cdnMetadataList = getApi().listCDNContainers(
                  ListCdnContainerOptions.Builder.afterMarker(
                           containerNameWithCDN.substring(0, containerNameWithCDN.length() - 1)).maxResults(1));
         assertEquals(cdnMetadataList.size(), 1);

         // Enable CDN with PUT for the same container, this time with a custom TTL and Log Retention
         long ttl = 4000;
         getApi().enableCDN(containerNameWithCDN, ttl, true);

         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getTTL(), ttl);

         // Check POST by updating TTL settings
         ttl = minimumTTL;
         getApi().updateCDN(containerNameWithCDN, minimumTTL, false);

         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getTTL(), minimumTTL);

         // Confirm that minimum allowed value for TTL is 3600, lower values are
         // ignored.
         getApi().updateCDN(containerNameWithCDN, 3599L, false);
         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
         assertEquals(cdnMetadata.getTTL(), 3599L);
        
         // Test purging an object from a CDN container
         SwiftObject swiftObject = newSwiftObject("hello", "hello.txt");
         getApi().putObject(containerNameWithCDN, swiftObject);
        
         assertTrue(getApi().purgeCDNObject(containerNameWithCDN, swiftObject.getInfo().getName()));

         // Disable CDN with POST
         assertTrue(getApi().disableCDN(containerNameWithCDN));

         cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
         assertEquals(cdnMetadata.isCDNEnabled(), false);
      } finally {
         recycleContainer(containerNameWithCDN);
         recycleContainer(containerNameWithoutCDN);
      }
   }
View Full Code Here


   @Test
   public void testApplyInputStream() {

      InputStream is = getClass().getResourceAsStream("/test_list_cdn.json");
      Set<ContainerCDNMetadata> expects = ImmutableSortedSet.of(
         new ContainerCDNMetadata(
            "adriancole-blobstore.testCDNOperationsContainerWithCDN",
            false,
            false,
            3600,
            URI.create("http://c0354712.cdn.cloudfiles.rackspacecloud.com"),
            URI.create("https://c0354712.cdn.ssl.cloudfiles.rackspacecloud.com"),
            URI.create("http://c0354712.cdn.stream.cloudfiles.rackspacecloud.com"),
            URI.create("http://c0354712.cdn.iosr.cloudfiles.rackspacecloud.com")),
         new ContainerCDNMetadata(
            "adriancole-blobstore5",
            true,
            false,
            28800,
            URI.create("http://c0404671.cdn.cloudfiles.rackspacecloud.com"),
            URI.create("https://c0404671.cdn.ssl.cloudfiles.rackspacecloud.com"),
            URI.create("http://c0404671.cdn.stream.cloudfiles.rackspacecloud.com"),
            URI.create("http://c0404671.cdn.iosr.cloudfiles.rackspacecloud.com")),
         new ContainerCDNMetadata(
            "adriancole-cfcdnint.testCDNOperationsContainerWithCDN",
            false,
            false,
            3600,
            URI.create("http://c0320431.cdn.cloudfiles.rackspacecloud.com"),
View Full Code Here

TOP

Related Classes of org.jclouds.cloudfiles.domain.ContainerCDNMetadata

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.