當前位置: 首頁>>代碼示例>>Java>>正文


Java ExternalResource類代碼示例

本文整理匯總了Java中org.junit.rules.ExternalResource的典型用法代碼示例。如果您正苦於以下問題:Java ExternalResource類的具體用法?Java ExternalResource怎麽用?Java ExternalResource使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ExternalResource類屬於org.junit.rules包,在下文中一共展示了ExternalResource類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildResourceFactory

import org.junit.rules.ExternalResource; //導入依賴的package包/類
@Override
protected GuiceyInterceptor.ExternalRuleAdapter buildResourceFactory(final UseGuiceyApp annotation) {
    return new GuiceyInterceptor.ExternalRuleAdapter() {
        private GuiceyAppRule rule;

        @Override
        @SuppressWarnings("unchecked")
        public ExternalResource newResource() {
            Preconditions.checkState(rule == null, "External resource creation could be called once.");
            rule = new GuiceyAppRule(annotation.value(), annotation.config(),
                    convertOverrides(annotation.configOverride()));
            return rule;
        }

        @Override
        public Injector getInjector() {
            Preconditions.checkState(rule != null, "External resource not created.");
            return rule.getInjector();
        }
    };
}
 
開發者ID:xvik,項目名稱:dropwizard-guicey,代碼行數:22,代碼來源:GuiceyAppExtension.java

示例2: withLogging

import org.junit.rules.ExternalResource; //導入依賴的package包/類
private Statement withLogging(final FrameworkMethod method, Object target, Statement statement) {
  final AtomicLong time = new AtomicLong();
  List<TestRule> rules = new ArrayList<>();
  rules.add(new ExternalResource() {
    @Override
    protected void before() throws Throwable {
      if (LOG.isDebugEnabled()) {
        time.set(System.currentTimeMillis());
        LOG.debug("Beginning [" + method.getDeclaringClass().getCanonicalName() + "." + method.getName() + "]");
      }
    }

    @Override
    protected void after() {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Completed [" + method.getDeclaringClass().getCanonicalName() + "." + method.getName() + "] in ["
          + (System.currentTimeMillis() - time.get()) + "] ms");
      }
    }
  });
  return new RunRules(statement, rules, getDescription());
}
 
開發者ID:ggear,項目名稱:cloudera-framework,代碼行數:23,代碼來源:TestRunner.java

示例3: classRules

import org.junit.rules.ExternalResource; //導入依賴的package包/類
@Override
protected List<TestRule> classRules() {
  List<TestRule> rules = super.classRules();
  rules.add(new ExternalResource() {
    @Override
    protected void before() throws Throwable {
      beforeClass();
      super.before();
    }

    @Override
    protected void after() {
      beforeAfterClass();
      super.after();
      afterClass();
    }
  });
  return rules;
}
 
開發者ID:bytor99999,項目名稱:vertx-junit-annotations,代碼行數:20,代碼來源:JUnit4ClassRunnerAdapter.java

示例4: createTestRule

import org.junit.rules.ExternalResource; //導入依賴的package包/類
public TestRule createTestRule() {
  final TemporaryFolder tempFolder = new TemporaryFolder();

  return RuleChain
    .outerRule(tempFolder)
    .around(new ExternalResource() {

      TomcatServerBootstrap bootstrap = new JerseyTomcatServerBootstrap(webXmlResource);

      protected void before() throws Throwable {
        bootstrap.setWorkingDir(tempFolder.getRoot().getAbsolutePath());
        bootstrap.start();
      }

      protected void after() {
        bootstrap.stop();
      }
    });
}
 
開發者ID:camunda,項目名稱:camunda-bpm-platform,代碼行數:20,代碼來源:JerseySpecifics.java

示例5: createTestRule

import org.junit.rules.ExternalResource; //導入依賴的package包/類
public TestRule createTestRule() {
  final TemporaryFolder tempFolder = new TemporaryFolder();

  return RuleChain
    .outerRule(tempFolder)
    .around(new ExternalResource() {

      WinkTomcatServerBootstrap bootstrap = new WinkTomcatServerBootstrap(webXmlResource);

      protected void before() throws Throwable {
        bootstrap.setWorkingDir(tempFolder.getRoot().getAbsolutePath());
        bootstrap.start();
      }

      protected void after() {
        bootstrap.stop();
      }
    });
}
 
開發者ID:camunda,項目名稱:camunda-bpm-platform,代碼行數:20,代碼來源:WinkSpecifics.java

示例6: createTestRule

import org.junit.rules.ExternalResource; //導入依賴的package包/類
public TestRule createTestRule() {
  final TemporaryFolder tempFolder = new TemporaryFolder();

  return RuleChain
    .outerRule(tempFolder)
    .around(new ExternalResource() {

      TomcatServerBootstrap bootstrap = new CXFTomcatServerBootstrap(webXmlResource);

      protected void before() throws Throwable {
        bootstrap.setWorkingDir(tempFolder.getRoot().getAbsolutePath());
        bootstrap.start();
      }

      protected void after() {
        bootstrap.stop();
      }
    });
}
 
開發者ID:camunda,項目名稱:camunda-bpm-platform,代碼行數:20,代碼來源:CXFSpecifics.java

示例7: createTestRule

import org.junit.rules.ExternalResource; //導入依賴的package包/類
public TestRule createTestRule() {
  final TemporaryFolder tempFolder = new TemporaryFolder();

  return RuleChain
    .outerRule(tempFolder)
    .around(new ExternalResource() {

      ResteasyTomcatServerBootstrap bootstrap = new ResteasyTomcatServerBootstrap(webXmlResource);

      protected void before() throws Throwable {
        bootstrap.setWorkingDir(tempFolder.getRoot().getAbsolutePath());
        bootstrap.start();
      }

      protected void after() {
        bootstrap.stop();
      }
    });
}
 
開發者ID:camunda,項目名稱:camunda-bpm-platform,代碼行數:20,代碼來源:ResteasySpecifics.java

示例8: maintainer

import org.junit.rules.ExternalResource; //導入依賴的package包/類
/**
 * A JUnit {@link TestRule} that stops tests from interfering with one 
 * another. JUnit will automatically set up/clean up the catalog when this
 * rule is used. <br/>
 * Usage:<br/>
 * {@code @Rule public final TestRule catalogMaintainer = TestCatalogModel.maintainer()}
 * @return the TestRule
 */
public static TestRule maintainer() {
    return new ExternalResource() {

        @Override
        protected void after() {
            getDefault().clearDocumentPool();
        }
    
    };
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:TestCatalogModel.java

示例9: getClassWatcher

import org.junit.rules.ExternalResource; //導入依賴的package包/類
/**
 * Get class watcher to manage local Grid servers.
 * 
 * @return external resource object
 */
public static ExternalResource getClassWatcher() {
    return new ExternalResource() {
        @Override
        protected void after() {
            DriverManager.onFinish();
        }
        
    };
}
 
開發者ID:Nordstrom,項目名稱:Selenium-Foundation,代碼行數:15,代碼來源:DriverWatcher.java

示例10: createRule

import org.junit.rules.ExternalResource; //導入依賴的package包/類
@Override
public TestRule createRule() {
	return new ExternalResource() {

	};
}
 
開發者ID:spring-io,項目名稱:artifactory-resource,代碼行數:7,代碼來源:ArtifactoryServerConnection.java

示例11: hasZeroFields

import org.junit.rules.ExternalResource; //導入依賴的package包/類
@Test
public void hasZeroFields() throws Exception {
  Field[] fields = ExternalResource.class.getDeclaredFields();
  assertThat(fields.length).as("Fields: " + Arrays.asList(fields)).isEqualTo(0);
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:6,代碼來源:SerializableExternalResourceTest.java

示例12: rule

import org.junit.rules.ExternalResource; //導入依賴的package包/類
@ClassRule
public static TestRule rule() {
  return new ExternalResource() {
  };
}
 
開發者ID:hcoles,項目名稱:pitest,代碼行數:6,代碼來源:JUnitCustomRunnerTestUnitFinderTest.java

示例13: newResource

import org.junit.rules.ExternalResource; //導入依賴的package包/類
/**
 * @return new rule instance
 */
ExternalResource newResource();
 
開發者ID:xvik,項目名稱:dropwizard-guicey,代碼行數:5,代碼來源:GuiceyInterceptor.java


注:本文中的org.junit.rules.ExternalResource類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。