Package mykeynote.junit

Source Code of mykeynote.junit.VerifyTest

package mykeynote.junit;

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

import mykeynote.exceptions.configuration.ConfigurationUnacceptableValue;
import mykeynote.exceptions.configuration.MissingConfigOptionException;
import mykeynote.exceptions.configuration.UniqueFileException;
import mykeynote.exceptions.keynote.RetValStringNotParsableException;
import mykeynote.exceptions.keynote.cl.KeyNoteCLException;
import mykeynote.exceptions.keynote.cl.KeyNoteCLProcessCreationException;
import mykeynote.exceptions.report.ReportFileCreationException;
import mykeynote.exceptions.report.ReportNotInitializedException;
import mykeynote.keynote.KeyNoteCL;
import mykeynote.keynote.KeyNoteCommon;
import mykeynote.server.Report;
import mykeynote.server.configuration.Configuration;

import junit.framework.TestCase;

public class VerifyTest extends TestCase {
  File configuration = new File(new File("etc", "mykeynote"), "MyKeyNote.conf.example");
  File base = new File(new File("mykeynote", "junit"), "keynote");
  private Configuration config = null;
  private Report report = null;
 
  public void setUp() {
    configuration = new File("etc/mykeynote/MyKeyNote.conf.example");
    try {
      config = new Configuration(configuration, true);
      config.readConfigFile();
    } catch (FileNotFoundException e) {
      assertNull(e);
    } catch (IOException e) {
      assertNull(e);
    } catch (MissingConfigOptionException e) {
      assertNull(e);
    } catch (ReportFileCreationException e) {
      assertNull(e);
    } catch (ConfigurationUnacceptableValue e) {
      assertNull(e);
    } catch (UniqueFileException e) {
      assertNull(e);
    }
   
    try {
      report = config.getReport();
    } catch (ReportNotInitializedException e1) {
      assertNull(e1);
    }
  }
 
  public void testVerify(){
    KeyNoteCommon knc = new KeyNoteCommon();
    File resourceToTest = new File(base, "resource1");
    KeyNoteCL cl = new KeyNoteCL(config, report);
    String unique = "100";
    File environmentFile = null;
    File returnValueFile = null;
    try {
      environmentFile = knc.getEnvironmentFile(unique, report, resourceToTest, false);
      returnValueFile = knc.getReturnValueFile(unique, report, resourceToTest, false);
    } catch (FileNotFoundException e1) {
      assertNull(e1);
    }
   
    File assertionFile = new File(base, "resource1.ass");
    File key = new File(base, "key10");
    String answer = "";
    try {
      answer = cl.verify(unique, environmentFile, returnValueFile, assertionFile, key);
    } catch (KeyNoteCLProcessCreationException e) {
      assertNotNull(e);
    } catch (KeyNoteCLException e) {
      assertNotNull(e);
    } catch (InterruptedException e) {
      assertNotNull(e);
    } catch (IOException e) {
      assertNotNull(e);
    } catch (RetValStringNotParsableException e) {
      assertNotNull(e);
    }
   
    assertEquals("true", answer);
   
  }
 
  public void tearDown() {
    try {
      config.finalizeConfiguration();
    } catch (IOException e) {
      assertNull(e);
    }
  }
}
TOP

Related Classes of mykeynote.junit.VerifyTest

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.