当前位置: 首页>>代码示例>>Java>>正文


Java Statement.evaluate方法代码示例

本文整理汇总了Java中org.junit.runners.model.Statement.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Java Statement.evaluate方法的具体用法?Java Statement.evaluate怎么用?Java Statement.evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.junit.runners.model.Statement的用法示例。


在下文中一共展示了Statement.evaluate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import org.junit.runners.model.Statement; //导入方法依赖的package包/类
public Statement apply(final Statement base, FrameworkMethod method, Object target) {
    sampleName = getSampleName(method);
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            if (sampleName != null) {
                String hintForMissingSample = String.format("If '%s' is a new sample, try running 'gradle intTestImage'.", sampleName);
                TestFile srcDir = new IntegrationTestBuildContext().getSamplesDir().file(sampleName).assertIsDir(hintForMissingSample);
                logger.debug("Copying sample '{}' to test directory.", sampleName);
                srcDir.copyTo(getDir());
            } else {
                logger.debug("No sample specified for this test, skipping.");
            }
            base.evaluate();
        }
    };
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:Sample.java

示例2: apply

import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override
public Statement apply(Statement base, Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            server.start();

            retrofit = new Retrofit.Builder()
                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                    .addConverterFactory(new GsonService().getGsonConverterFactory())
                    .baseUrl(server.url("").toString())
                    .client(new HttpService(context).getHttpClient())
                    .build();

            base.evaluate();

            server.shutdown();
        }
    };
}
 
开发者ID:CoreFloDev,项目名称:OpenChat,代码行数:21,代码来源:ApiTestRule.java

示例3: apply

import org.junit.runners.model.Statement; //导入方法依赖的package包/类
public Statement apply(final Statement base, Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            // save the instance config
            LOG.debug("Saving instance config {}", instanceConfig.getClass());
            instanceConfig.save();
            
            // Call any actions if any
            for (Action action : actions) {
                LOG.debug("Calling action {}", action.getClass());
                action.call();
            }
            
            // run the base statement
            LOG.debug("Running base statement");
            base.evaluate();
            
            if (withRestore) {
                LOG.debug("Restoring instance config {}", instanceConfig.getClass());
                instanceConfig.restore();
            }
        }
    };
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-testing-rules,代码行数:26,代码来源:InstanceConfigRule.java

示例4: apply

import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            System.getProperties().putAll(customProperties);
            resetTempDirLocation();
            try {
                base.evaluate();
            } finally {
                System.setProperties(properties);
                resetTempDirLocation();
            }
        }
    };
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:SetSystemProperties.java

示例5: apply

import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override
public Statement apply(Statement base, Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            RxAndroidPlugins.reset();
            RxAndroidPlugins.setInitMainThreadSchedulerHandler(scheduler -> Schedulers.trampoline());
            RxJavaPlugins.reset();
            RxJavaPlugins.setIoSchedulerHandler(schedulerCallable -> Schedulers.trampoline());

            base.evaluate();

            RxAndroidPlugins.reset();
            RxJavaPlugins.reset();
        }
    };
}
 
开发者ID:CoreFloDev,项目名称:OpenChat,代码行数:18,代码来源:RxPluginTestRule.java

示例6: expect_exceptionThrownButExpectingDifferentError_shouldFail

import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Test
public void expect_exceptionThrownButExpectingDifferentError_shouldFail() throws Throwable {
  // given
  Statement originalStatement = new Statement() {
    @Override
    public void evaluate() throws Throwable {
      Single.just("bar")
          .map(s -> { throw new Exception("foo"); })
          .subscribe();
    }
  };
  ExpectedUncaughtException uncaughtThrown = ExpectedUncaughtException.none();
  uncaughtThrown.expect(Exception.class);
  uncaughtThrown.expectMessage("foo");
  Statement statement = uncaughtThrown.apply(originalStatement, description);
  thrown.expect(AssertionError.class);
  thrown.expectMessage("Uncaught exception occurred, " +
      "but is different than expected:\n" +
      "Expected: <java.lang.Exception>\n" +
      "     but: was <io.reactivex.exceptions.OnErrorNotImplementedException>");

  // when
  statement.evaluate();

  // then should fail
}
 
开发者ID:xemantic,项目名称:github-users,代码行数:27,代码来源:ExpectedUncaughtExceptionTest.java

示例7: apply

import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            RxAndroidPlugins.reset();
            RxAndroidPlugins.setInitMainThreadSchedulerHandler(mRxAndroidSchedulersHook);

            RxJavaPlugins.reset();
            RxJavaPlugins.setIoSchedulerHandler(mRxJavaImmediateScheduler);
            RxJavaPlugins.setNewThreadSchedulerHandler(mRxJavaImmediateScheduler);

            base.evaluate();

            RxAndroidPlugins.reset();
            RxJavaPlugins.reset();
        }
    };
}
 
开发者ID:sztomek,项目名称:cleanarchitecture-unidirectional,代码行数:20,代码来源:RxSchedulersOverrideRule.java

示例8: statementStartsAndStops

import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Test public void statementStartsAndStops() throws Throwable {
  final AtomicBoolean called = new AtomicBoolean();
  Statement statement = server.apply(new Statement() {
    @Override public void evaluate() throws Throwable {
      called.set(true);
      server.url("/").url().openConnection().connect();
    }
  }, Description.EMPTY);

  statement.evaluate();

  assertTrue(called.get());
  try {
    server.url("/").url().openConnection().connect();
    fail();
  } catch (ConnectException expected) {
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:MockWebServerTest.java

示例9: statement

import org.junit.runners.model.Statement; //导入方法依赖的package包/类
private Statement statement(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            Throwable caughtThrowable = null;

            // implement retry logic here
            for (int i = 0; i < retryCount; i++) {
                try {
                    base.evaluate();
                    return;
                } catch (Throwable t) {
                    caughtThrowable = t;
                    log.error(description.getDisplayName() + ": run " + (i+1) + " failed");
                }
            }
            log.info(description.getDisplayName() + ": giving up after " + retryCount + " failures");
            if (caughtThrowable != null) {
                throw caughtThrowable;
            }
        }
    };
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:24,代码来源:Retry.java

示例10: apply

import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            RxAndroidPlugins.getInstance().reset();
            RxAndroidPlugins.getInstance().registerSchedulersHook(mRxAndroidSchedulersHook);

            RxJavaPlugins.getInstance().reset();
            RxJavaPlugins.getInstance().registerSchedulersHook(mRxJavaSchedulersHook);

            base.evaluate();

            RxAndroidPlugins.getInstance().reset();
            RxJavaPlugins.getInstance().reset();
        }
    };
}
 
开发者ID:schul-cloud,项目名称:schulcloud-mobile-android,代码行数:19,代码来源:RxSchedulersOverrideRule.java

示例11: apply

import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override
public Statement apply(final Statement base, FrameworkMethod method, final Object target) {
  return new Statement() {
    @Override
    public void evaluate() throws Throwable {
      MockitoAnnotations.initMocks(target);
      try {
        base.evaluate();
      } finally {
        Mockito.validateMockitoUsage();
      }
    }
  };
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:15,代码来源:MockitoTestRule.java

示例12: apply

import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
  return new Statement() {
    @Override
    public void evaluate() throws Throwable {
      resetState();
      try {
        base.evaluate();
      } finally {
        resetState();
      }
    }
  };
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:15,代码来源:FirebaseAppRule.java

示例13: apply

import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            active = true;
            diagnostics = new ArrayList<Diagnostic<? extends JavaFileObject>>();
            boolean captureDiagnosticsStart = captureDiagnostics;
            try {
                File testRoot = methodNameDir(classNameDir(rootDirectory(), description.getClassName()),
                        description.getMethodName());
                generateDir = new File(testRoot, "generate");
                compileDir = new File(testRoot, "compile");

                base.evaluate();
            } finally {
                generateDir = null;
                compileDir = null;
                classLoader = null;
                sourceDirInitialized = false;
                classesDirInitialized = false;
                captureDiagnostics = captureDiagnosticsStart;
                diagnostics = null;
                active = false;
            }
        }
    };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:Jsonschema2PojoRule.java

示例14: apply

import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override public Statement apply(final Statement base, Description description) {
  return new Statement() {
    @Override public void evaluate() throws Throwable {
      base.evaluate();
      for (RecordingSingleObserver<?> subscriber : subscribers) {
        subscriber.assertNoEvents();
      }
    }
  };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:RecordingSingleObserver.java

示例15: apply

import org.junit.runners.model.Statement; //导入方法依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            try {
                setupDaggerTestComponentInApplication();
                base.evaluate();
            } finally {
                mTestComponent = null;
            }
        }
    };
}
 
开发者ID:sathishmscict,项目名称:Pickr,代码行数:15,代码来源:TestComponentRule.java


注:本文中的org.junit.runners.model.Statement.evaluate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。