當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。