Пример #1
0
  private static void testPotato(
      Class<? extends Collection> implClazz, Class<? extends List> argClazz) throws Throwable {
    try {
      System.out.printf("implClazz=%s, argClazz=%s\n", implClazz.getName(), argClazz.getName());
      final int iterations = 100000;
      final List<Integer> list = (List<Integer>) argClazz.newInstance();
      final Integer one = Integer.valueOf(1);
      final List<Integer> oneElementList = Collections.singletonList(one);
      final Constructor<? extends Collection> constr = implClazz.getConstructor(Collection.class);
      final Thread t =
          new CheckedThread() {
            public void realRun() {
              for (int i = 0; i < iterations; i++) {
                list.add(one);
                list.remove(one);
              }
            }
          };
      t.setDaemon(true);
      t.start();

      for (int i = 0; i < iterations; i++) {
        Collection<?> coll = constr.newInstance(list);
        Object[] elts = coll.toArray();
        check(elts.length == 0 || (elts.length == 1 && elts[0] == one));
      }
    } catch (Throwable t) {
      unexpected(t);
    }
  }
 @Override
 public List<Type> extraInterfaces() {
   Type type = extractActualBoundedTypeOf(typeVariable);
   if (type instanceof BoundedType) {
     return Arrays.asList(((BoundedType) type).interfaceBounds());
   }
   if (type instanceof ParameterizedType) {
     return Collections.singletonList(type);
   }
   if (type instanceof Class) {
     return Collections.emptyList();
   }
   throw new MockitoException(
       "Cannot extract extra-interfaces from '" + typeVariable + "' : '" + type + "'");
 }
Пример #3
0
 public List<String> getDefaultSchemaPath() {
   final String schemaName = connection.getSchema();
   return schemaName == null
       ? Collections.<String>emptyList()
       : Collections.singletonList(schemaName);
 }