本文整理汇总了Java中org.easymock.MockControl.createStrictControl方法的典型用法代码示例。如果您正苦于以下问题:Java MockControl.createStrictControl方法的具体用法?Java MockControl.createStrictControl怎么用?Java MockControl.createStrictControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.easymock.MockControl
的用法示例。
在下文中一共展示了MockControl.createStrictControl方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.easymock.MockControl; //导入方法依赖的package包/类
public void setUp() throws Exception
{
super.setUp();
migrationProcess = new MigrationProcess();
migrationProcess.
setMigrationRunnerStrategy(MigrationRunnerFactory.getMigrationRunnerStrategy(null));
migrationContextControl = MockControl.createStrictControl(MigrationContext.class);
migrationContextMock =
(MigrationContext) migrationContextControl.getMock();
migrationTaskSourceControl = MockControl.createStrictControl(MigrationTaskSource.class);
migrationTaskSourceMock = (MigrationTaskSource) migrationTaskSourceControl.getMock();
migrationProcess.addPatchResourcePackage("testPackageName");
patchInfoStoreControl = MockControl.createStrictControl(PatchInfoStore.class);
patchInfoStoreMock = (PatchInfoStore) patchInfoStoreControl.getMock();
patchInfoStore = MockBuilder.getPatchInfoStore(3);
}
示例2: setUp
import org.easymock.MockControl; //导入方法依赖的package包/类
protected void setUp() throws Exception {
m_control = MockControl.createStrictControl(MockDelegate.class);
m_delegate = (MockDelegate) m_control.getMock();
m_chartBuilder = new AbstractChartBuilder(m_options, null) {
protected void initialiseSeriesColumn(String title) {
m_delegate.initialiseSeriesColumn(title);
}
protected void addYValue(int columnNumber, Object xValue, Object yValue) {
m_delegate.addYValue(columnNumber, xValue, yValue);
}
protected JFreeChart getChartImpl(Options options) {
return m_delegate.getChartImpl(options);
}
protected XYDataset getDataset() {
return m_delegate.getDataset();
}
protected XYToolTipGenerator getToolTipGenerator() {
return m_delegate.getToolTipGenerator();
}
};
}
示例3: setUp
import org.easymock.MockControl; //导入方法依赖的package包/类
protected void setUp() throws Exception {
classes = new String[] { Object.class.getName(), Cloneable.class.getName(), Serializable.class.getName() };
// lowest service reference
Dictionary dict1 = new Hashtable();
dict1.put(Constants.SERVICE_RANKING, new Integer(Integer.MIN_VALUE));
ref1 = new MockServiceReference(null, dict1, null);
// neutral service reference
Dictionary dict2 = new Hashtable();
dict2.put(Constants.SERVICE_ID, new Long(20));
ref2 = new MockServiceReference(null, dict2, null);
// neutral service reference
Dictionary dict3 = new Hashtable();
dict3.put(Constants.SERVICE_ID, new Long(30));
ref3 = new MockServiceReference(null, dict3, null);
ctrl = MockControl.createStrictControl(BundleContext.class);
context = (BundleContext) ctrl.getMock();
}
示例4: setUp
import org.easymock.MockControl; //导入方法依赖的package包/类
/**
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception
{
super.setUp();
runner = new MigrationProcess();
runner.setMigrationRunnerStrategy(MigrationRunnerFactory.getMigrationRunnerStrategy(null));
runner.addPatchResourceDirectory(getClass().getPackage().getName() + ".tasks.normal");
runner.addPatchResourceDirectory(getClass().getPackage().getName() + ".tasks.rollback");
runner.addPostPatchResourceDirectory(getClass().getPackage().getName() + ".tasks.post");
runner.addListener(this);
context = new TestMigrationContext();
patchInfoStoreControl = MockControl.createStrictControl(PatchInfoStore.class);
patchInfoStore = (PatchInfoStore) patchInfoStoreControl.getMock();
}
示例5: setUp
import org.easymock.MockControl; //导入方法依赖的package包/类
/**
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception
{
super.setUp();
runner = new MigrationProcess();
runner.setMigrationRunnerStrategy(MigrationRunnerFactory.getMigrationRunnerStrategy(null));
runner.addPatchResourceDirectory(getClass().getPackage().getName()
+ ".tasks.rollback");
runner.addPostPatchResourceDirectory(getClass().getPackage().getName()
+ ".tasks.post");
runner.addListener(this);
context = new TestMigrationContext();
patchInfoStoreControl = MockControl.createStrictControl(PatchInfoStore.class);
patchInfoStore = (PatchInfoStore) patchInfoStoreControl.getMock();
currentPatchInfoStore = MockBuilder.getPatchInfoStore(12);
mockControl = createStrictControl();
migrationStrategy = mockControl.createMock(MigrationRunnerStrategy.class);
List<MigrationTask> rollbackCandidates;
rollbackCandidates = new ArrayList<MigrationTask>();
rollbackCandidates.add(new TestRollbackableTask5());
rollbackCandidates.add(new TestRollbackableTask4());
rollbackCandidates.add(new TestRollbackableTask3());
rollbackCandidates.add(new TestRollbackableTask2());
expect(migrationStrategy.getRollbackCandidates(EasyMock.<List<MigrationTask>>anyObject(), eq(ROLLBACK_LEVELS), eq(currentPatchInfoStore))).andReturn(rollbackCandidates);
expect(migrationStrategy.getRollbackCandidates(EasyMock.<List<MigrationTask>>anyObject(), eq(ROLLBACK_LEVELS), eq(currentPatchInfoStore))).andReturn(Collections.EMPTY_LIST);
}
示例6: setUp
import org.easymock.MockControl; //导入方法依赖的package包/类
protected void setUp() throws IOException {
m_chartGeneratorControl = MockControl.createStrictControl(ChartGenerator.class);
m_chartGeneratorMock = (ChartGenerator) m_chartGeneratorControl.getMock();
m_cliServer = new CliServer();
m_cliServer.setChartGenerator(m_chartGeneratorMock);
}
示例7: setUp
import org.easymock.MockControl; //导入方法依赖的package包/类
protected void setUp() throws Exception {
m_sinkControl = MockControl.createStrictControl(DataSink.class);
m_sinkControl.setDefaultMatcher(MockControl.ARRAY_MATCHER);
m_sinkMock = (DataSink) m_sinkControl.getMock();
m_lineParserControl = MockControl.createStrictControl(LineParser.class);
m_lineParserMock = (LineParser) m_lineParserControl.getMock();
}
示例8: setUp
import org.easymock.MockControl; //导入方法依赖的package包/类
protected void setUp() throws Exception {
bundleCtrl = MockControl.createStrictControl(Bundle.class);
bundle = (Bundle) bundleCtrl.getMock();
classLoader = BundleDelegatingClassLoader.createBundleClassLoaderFor(bundle,
ProxyFactory.class.getClassLoader());
bundleCtrl.reset();
}
示例9: testFindResources
import org.easymock.MockControl; //导入方法依赖的package包/类
public void testFindResources() throws Exception {
String resource = "bla-bla";
MockControl enumCtrl = MockControl.createStrictControl(Enumeration.class);
Enumeration enumeration = (Enumeration) enumCtrl.getMock();
bundleCtrl.expectAndReturn(bundle.getResources(resource), enumeration);
bundleCtrl.replay();
assertSame(enumeration, classLoader.findResources(resource));
}
示例10: testDoMigrationsWithLockRace
import org.easymock.MockControl; //导入方法依赖的package包/类
/**
* Test doing migrations with a lock race from a quick cluster
*
* @throws Exception if there is a problem
*/
public void testDoMigrationsWithLockRace() throws Exception {
// Setup enough for the first
PreparedStatementResultSetHandler h = conn.getPreparedStatementResultSetHandler();
MockResultSet rs = h.createResultSet();
rs.addRow(new Integer[]{new Integer(0)});
h.prepareGlobalResultSet(rs);
MockControl mockControl = MockControl.createStrictControl(PatchInfoStore.class);
PatchInfoStore patchStore = (PatchInfoStore) mockControl.getMock();
// First they see if it is locked, and it is, so they spin
patchStore.isPatchStoreLocked();
mockControl.setReturnValue(true);
// Second they see if it is locked again, and it isn't, so they try and fail and spin
patchStore.isPatchStoreLocked();
mockControl.setReturnValue(false);
patchStore.getPatchLevel();
mockControl.setReturnValue(0);
patchStore.lockPatchStore();
mockControl.setThrowable(new IllegalStateException("The table is already locked"));
// Finally they see if it is locked again, and it isn't, and it works
patchStore.isPatchStoreLocked();
mockControl.setReturnValue(false);
patchStore.getPatchLevel();
mockControl.setReturnValue(2, MockControl.ONE_OR_MORE);
patchStore.lockPatchStore();
IMocksControl migrationRunnerStrategyControl = createStrictControl();
MigrationRunnerStrategy migrationStrategyMock = migrationRunnerStrategyControl.createMock(MigrationRunnerStrategy.class);
expect(migrationStrategyMock.shouldMigrationRun(anyInt(), eq(patchStore))).andReturn(true).anyTimes();
patchStore.updatePatchLevel(4);
patchStore.updatePatchLevel(5);
patchStore.updatePatchLevel(6);
patchStore.updatePatchLevel(7);
patchStore.unlockPatchStore();
mockControl.replay();
migrationRunnerStrategyControl.replay();
TestJdbcMigrationLauncher testLauncher = new TestJdbcMigrationLauncher(context);
testLauncher.getMigrationProcess().setMigrationRunnerStrategy(migrationStrategyMock);
testLauncher.setLockPollMillis(0);
testLauncher.setLockPollRetries(4);
testLauncher.setIgnoreMigrationSuccessfulEvents(false);
testLauncher.setPatchStore(patchStore);
testLauncher.setPatchPath("com.tacitknowledge.util.migration.tasks.normal");
testLauncher.doMigrations();
mockControl.verify();
}
示例11: testLockOverride
import org.easymock.MockControl; //导入方法依赖的package包/类
/**
* Test doing migrations with a lock override
*
* @throws Exception if there is a problem
*/
public void testLockOverride() throws Exception {
// Setup enough for the first
PreparedStatementResultSetHandler h = conn.getPreparedStatementResultSetHandler();
MockResultSet rs = h.createResultSet();
rs.addRow(new Integer[]{new Integer(0)});
h.prepareGlobalResultSet(rs);
MockControl mockControl = MockControl.createStrictControl(PatchInfoStore.class);
PatchInfoStore patchStore = (PatchInfoStore) mockControl.getMock();
// First they see if it is locked three times, and it is, so they spin
patchStore.isPatchStoreLocked();
mockControl.setReturnValue(true);
patchStore.isPatchStoreLocked();
mockControl.setReturnValue(true);
patchStore.isPatchStoreLocked();
mockControl.setReturnValue(true);
patchStore.isPatchStoreLocked();
mockControl.setReturnValue(true);
// after the third time, they unlock it
patchStore.unlockPatchStore();
// now the lock succeeds
patchStore.isPatchStoreLocked();
mockControl.setReturnValue(false);
patchStore.getPatchLevel();
mockControl.setReturnValue(2);
patchStore.lockPatchStore();
IMocksControl migrationRunnerStrategyControl = createStrictControl();
MigrationRunnerStrategy migrationStrategyMock = migrationRunnerStrategyControl.createMock(MigrationRunnerStrategy.class);
expect(migrationStrategyMock.shouldMigrationRun(anyInt(), eq(patchStore))).andReturn(true).anyTimes();
patchStore.updatePatchLevel(4);
patchStore.updatePatchLevel(5);
patchStore.updatePatchLevel(6);
patchStore.updatePatchLevel(7);
patchStore.unlockPatchStore();
TestJdbcMigrationLauncher testLauncher = new TestJdbcMigrationLauncher(context);
testLauncher.getMigrationProcess().setMigrationRunnerStrategy(migrationStrategyMock);
testLauncher.setLockPollMillis(0);
testLauncher.setLockPollRetries(3);
testLauncher.setIgnoreMigrationSuccessfulEvents(false);
testLauncher.setPatchStore(patchStore);
testLauncher.setPatchPath("com.tacitknowledge.util.migration.tasks.normal");
mockControl.replay();
migrationRunnerStrategyControl.replay();
testLauncher.doMigrations();
mockControl.verify();
}
示例12: setUp
import org.easymock.MockControl; //导入方法依赖的package包/类
protected void setUp() throws Exception {
context = new AbstractOsgiBundleApplicationContext() {
protected void loadBeanDefinitions(DefaultListableBeanFactory arg0) throws IOException, BeansException {
}
};
bundleCtxCtrl = MockControl.createStrictControl(BundleContext.class);
bundleCtx = (BundleContext) bundleCtxCtrl.getMock();
bundleCtrl = MockControl.createNiceControl(Bundle.class);
bundle = (Bundle) bundleCtrl.getMock();
bundleCtxCtrl.expectAndReturn(bundleCtx.getBundle(), bundle);
}
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:17,代码来源:AbstractRefreshableOsgiBundleApplicationContextTest.java
示例13: setUp
import org.easymock.MockControl; //导入方法依赖的package包/类
protected void setUp() throws Exception {
control = MockControl.createStrictControl(Bundle.class);
bundle = (Bundle) control.getMock();
loader = new OsgiBundleResourceLoader(bundle);
}