Package mykeynote.junit

Source Code of mykeynote.junit.JavaClientTest

package mykeynote.junit;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;

import mykeynote.client.JavaClient;
import mykeynote.misc.CommonFunctions;
import junit.framework.TestCase;

public class JavaClientTest extends TestCase{
  private int port = 4400;
  private String ip = "localhost";
  private File base = new File(new File("mykeynote", "junit"), "keynote");
 
 
  public void setUp() {
    //initializeClient(null);
  }
 
  public void testClient(){
    JavaClient client = new JavaClient(ip, port);
   
    setResource(client);
    try {
      setEnviroment(client);
      setKey(client);
      setCredentials(client);
    } catch (Exception e) {
      e.printStackTrace();
      assertNull(e);
    }
    setResource(client);
    //client.flush();
    assertTrue(client.flush());
    assertTrue("true".equals(client.getAnswer()));
  }
 
  public void setResource(JavaClient client){
    File resourceFile = new File(base, "resource1");
    client.setResource(resourceFile.getAbsolutePath());
  }
 
  public void setEnviroment(JavaClient client) throws FileNotFoundException, IOException{
    File envFile = new File(base, ".resource1.env");
    ArrayList<String> env = readFile(envFile);
    client.setEnv(env);
  }
 
  public void setCredentials(JavaClient client) throws FileNotFoundException, IOException{
    File credFile = new File(base, "resource1.ass");
    ArrayList<String> cred = readFile(credFile);
    client.setCred(cred);
  }
 
  public void setKey(JavaClient client) throws FileNotFoundException, IOException{
    File keyFile = new File(base, "key10");
    ArrayList<String> keys = readFile(keyFile);
    client.setKey(keys);
  }
 
 
  public ArrayList<String> readFile(File file) throws FileNotFoundException, IOException{
    CommonFunctions common = new CommonFunctions();
    return common.readFile(file);
  }
}
TOP

Related Classes of mykeynote.junit.JavaClientTest

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.