Package br.com.ingenieux.picloud

Source Code of br.com.ingenieux.picloud.PiCloudClientTest

package br.com.ingenieux.picloud;

import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;

import java.util.Collection;
import java.util.List;
import java.util.Properties;

import org.junit.Before;
import org.junit.Test;

import br.com.ingenieux.picloud.req.CreateVolumeRequest;
import br.com.ingenieux.picloud.req.VolumeSyncArgs;
import br.com.ingenieux.picloud.response.CreateVolumeResponse;
import br.com.ingenieux.picloud.response.Volume;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.filter.LoggingFilter;

public class PiCloudClientTest {
  private PiCloudClient piCloud;

  @Before
  public void before() throws Exception {
    PiCloudCreds creds = new PiCloudCreds();
   
    Properties properties = new Properties();
   
    properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("picloud.properties"));
   
    creds.setKey(properties.getProperty("picloud.key"));
    creds.setSecretKey(properties.getProperty("picloud.secretKey"));
   
    this.piCloud = new PiCloudClient(creds) {
      @Override
      protected Client getClient(PiCloudCreds credsToUse) {
        Client client = super.getClient(credsToUse);
       
        client.addFilter(new LoggingFilter(System.err));
       
        return client;
      }
    };
  }
 
  @Test
  public void testListServers() {
    Collection<String> serverList = piCloud.listServers();
   
    assertThat(serverList, hasSize(greaterThan(0)));
  }
 
  @Test
  public void testCreateVolume() {
    CreateVolumeRequest req = new CreateVolumeRequest();
   
    req.setName("apps");
    req.setDescription("Sample apps volume");
    req.setMountPath("apps");
   
    CreateVolumeResponse response = piCloud.createVolume(req);
  }
 
  @Test
  public void testListVolume() {
    List<Volume> volumeList = piCloud.listVolumes();
   
    assertThat(volumeList, hasSize(greaterThan(0)));
  }
 
  @Test
  public void testVolumeSync() {
    VolumeSyncArgs args = new VolumeSyncArgs();
   
    args.setDelete(true);
    //args.setSource(FileObject.)
    args.setTarget("apps:shared/commerce");
   
    piCloud.volumeSync(args);
  }

}
TOP

Related Classes of br.com.ingenieux.picloud.PiCloudClientTest

TOP
Copyright © 2018 www.massapi.com. 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.