Package org.spockframework.runtime.extension

Examples of org.spockframework.runtime.extension.ExtensionException


  public void start() {
    try {
      socket = new Socket(reportServerAddress, reportServerPort);
    } catch (IOException e) {
      throw new ExtensionException(String.format("Error opening connection to report server. " +
          "Server address: %s Server port: %d", reportServerAddress, reportServerPort), e);
    }
  }
View Full Code Here


      socket.getOutputStream().write(messageBuffer.toByteArray());
      socket.getOutputStream().flush();
    } catch (Exception e) {
      IoUtil.closeQuietly(socket);
      socket = null;
      throw new ExtensionException("Error sending data to report server. " +
          "Server address: $reportServerAddress Server port: $reportServerPort", e);
    }
  }
View Full Code Here

  private List<URL> locateDescriptors(String descriptorPath) {
    try {
      return Collections.list(RunContext.class.getClassLoader().getResources(descriptorPath));
    } catch (Exception e) {
      throw new ExtensionException("Failed to locate extension descriptors", e);
    }
  }
View Full Code Here

          lines.add(line);
        line = reader.readLine();
      }
      return lines;
    } catch (IOException e) {
      throw new ExtensionException("Failed to read extension descriptor '%s'", e).withArgs(url);
    } finally {
      IoUtil.closeQuietly(reader);
    }
  }
View Full Code Here

  private Class<?> loadExtensionClass(String className) {
    try {
      return RunContext.class.getClassLoader().loadClass(className);
    } catch (Exception e) {
      throw new ExtensionException("Failed to load extension class '%s'", e).withArgs(className);
    }
  }
View Full Code Here

    logFile.getParentFile().mkdirs();
    try {
      logFile.createNewFile();
      fileWriter = new OutputStreamWriter(new FileOutputStream(logFile), "utf-8");
    } catch (IOException e) {
      throw new ExtensionException("Error creating report log file: " + logFile, e);
    }
    jsonWriter = new JsonWriter(fileWriter);
    jsonWriter.setPrettyPrint(prettyPrint);
  }
View Full Code Here

      fileWriter.write(postfix);
      if (liveUpdate) {
        fileWriter.flush();
      }
    } catch (IOException e) {
      throw new ExtensionException("Error writing to report log file: " + logFile, e);
    }
  }
View Full Code Here

    return globalExtensions;
  }

  private void verifyGlobalExtension(Class<?> clazz) {
    if (!IGlobalExtension.class.isAssignableFrom(clazz))
      throw new ExtensionException(
          "Class '%s' is not a valid global extension because it is not derived from '%s'"
      ).withArgs(clazz.getName(), IGlobalExtension.class.getName());
  }
View Full Code Here

  private IGlobalExtension instantiateGlobalExtension(Class<?> clazz) {
    try {
      return (IGlobalExtension) clazz.newInstance();
    } catch (Exception e) {
      throw new ExtensionException("Failed to instantiate extension '%s'", e).withArgs(clazz.getName());
    }
  }
View Full Code Here

    return config;
  }

  private Object createConfiguration(Class<?> type, Object extension) {
    if (!(extension instanceof IGlobalExtension)) {
      throw new ExtensionException("Extension '%s' references unknown configuration class '%s'")
          .withArgs(extension.getClass(), type);
    }

    try {
      return type.newInstance();
    } catch (InstantiationException e) {
      throw new ExtensionException("Cannot instantiate configuration class %s").withArgs(type);
    } catch (IllegalAccessException e) {
      throw new ExtensionException("Configuration class '%s' has no public no-arg constructor").withArgs(type);
    }
  }
View Full Code Here

TOP

Related Classes of org.spockframework.runtime.extension.ExtensionException

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.