当前位置: 首页>>代码示例>>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;未经允许,请勿转载。