Package org.spockframework.runtime

Examples of org.spockframework.runtime.InvalidSpecException


    invalidMockCreation();
    return null;
  }

  private void invalidMockCreation() {
    throw new InvalidSpecException("Mock objects can only be created inside a spec, and only during the lifetime of a feature (iteration)");
  }
View Full Code Here


  public static final SpreadWildcardArgumentConstraint INSTANCE = new SpreadWildcardArgumentConstraint();

  private SpreadWildcardArgumentConstraint() {}

  public boolean isSatisfiedBy(Object arg) {
    throw new InvalidSpecException("*_ may only appear at the end of an argument list");
  }
View Full Code Here

  }

  private void checkRequiredInteractionAllowed(IMockInteraction interaction) {
    if (!verified && interaction.isRequired()) {
      String mockName = name != null ? name : "unnamed";
      throw new InvalidSpecException("Stub '%s' matches the following required interaction:" +
          "\n\n%s\n\nRemove the cardinality (e.g. '1 *'), or turn the stub into a mock.\n").withArgs(mockName, interaction);
    }
  }
View Full Code Here

  }

  private Object createDynamicProxyMock(Class<?> mockType, List<Class<?>> additionalInterfaces,
      List<Object> constructorArgs, IProxyBasedMockInterceptor mockInterceptor, ClassLoader classLoader) {
    if (constructorArgs != null) {
      throw new InvalidSpecException("Interface based mocks may not have constructor arguments");
    }
    List<Class<?>> interfaces = new ArrayList<Class<?>>();
    interfaces.add(mockType);
    interfaces.addAll(additionalInterfaces);
    interfaces.add(ISpockMockObject.class);
View Full Code Here

  public static final String SET_RANGE_COUNT = "setRangeCount";
  public InteractionBuilder setRangeCount(Object minCount, Object maxCount, boolean inclusive) {
    this.minCount = minCount instanceof Wildcard ? 0 : convertCount(minCount, true);
    this.maxCount = maxCount instanceof Wildcard ? Integer.MAX_VALUE : convertCount(maxCount, inclusive);
    if (this.minCount > this.maxCount)
      throw new InvalidSpecException("lower bound of invocation count must come before upper bound");
    return this;
  }
View Full Code Here

        responseGeneratorChain.isEmpty() ? new DefaultResponseGenerator() : responseGeneratorChain);
  }

  private static int convertCount(Object count, boolean inclusive) {
    if (!(count instanceof Number))
      throw new InvalidSpecException("invocation count must be a number");

    int intCount = ((Number)count).intValue();
    if (!inclusive) intCount--;
    if (intCount < 0)
      throw new InvalidSpecException("invocation count must be >= 0");
    return intCount;
  }
View Full Code Here

   * @param matcher a matcher describing the expected value
   * @param <T> the actual value's type
   */
  @SuppressWarnings("UnusedDeclaration")
  public static <T> void that(T value, Matcher<? super T> matcher) {
    throw new InvalidSpecException("that() can only be used where a condition is expected");
  }
View Full Code Here

  }

  private void checkRefersToException(FailsWith failsWith) {
    if (Throwable.class.isAssignableFrom(failsWith.value())) return;

    throw new InvalidSpecException("@FailsWith needs to refer to an exception type, " +
        "but does refer to '%s'").withArgs(failsWith.value().getName());
  }
View Full Code Here

  @Nullable
  protected static Class<?> testRuleClass = ReflectionUtil.loadClassIfAvailable("org.junit.rules.TestRule");

  protected void checkIsInstanceField(FieldInfo field) {
    if (field.isShared() || field.isStatic()) {
      throw new InvalidSpecException("@Rule fields cannot be @Shared. Either do not make '%s' @Shared, or use @ClassRule.").withArgs(field.getName());
    }
  }
View Full Code Here

    }
  }

  protected void checkIsSharedField(FieldInfo field) {
    if (!field.isShared()) {
      throw new InvalidSpecException("@ClassRule fields must be @Shared. Either make '%s' @Shared, or use @Rule.").withArgs(field.getName());
    }
  }
View Full Code Here

TOP

Related Classes of org.spockframework.runtime.InvalidSpecException

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.