本文整理汇总了Java中org.easymock.MockControl.verify方法的典型用法代码示例。如果您正苦于以下问题:Java MockControl.verify方法的具体用法?Java MockControl.verify怎么用?Java MockControl.verify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.easymock.MockControl
的用法示例。
在下文中一共展示了MockControl.verify方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLoadTest
import org.easymock.MockControl; //导入方法依赖的package包/类
public void testLoadTest() throws Exception {
BundleContext ctx = new MockBundleContext();
MockControl servCtrl = MockControl.createControl(TestRunnerService.class);
TestRunnerService runner = (TestRunnerService) servCtrl.getMock();
try {
activator.executeTest();
fail("should have thrown exception");
}
catch (RuntimeException ex) {
// expected
}
setActivatorField("service", runner);
runner.runTest(null);
servCtrl.setMatcher(MockControl.ALWAYS_MATCHER);
servCtrl.replay();
setActivatorField("context", ctx);
OsgiTestInfoHolder.INSTANCE.setTestClassName(TestExample.class.getName());
activator.executeTest();
assertSame(ctx, TestExample.context);
servCtrl.verify();
}
示例2: testStart
import org.easymock.MockControl; //导入方法依赖的package包/类
public void testStart() throws Exception {
MockControl ctxCtrl = MockControl.createControl(BundleContext.class);
BundleContext ctx = (BundleContext) ctxCtrl.getMock();
MockControl servCtrl = MockControl.createControl(TestRunnerService.class);
TestRunnerService runner = (TestRunnerService) servCtrl.getMock();
ServiceReference ref = new MockServiceReference();
ctxCtrl.expectAndReturn(ctx.getServiceReference(TestRunnerService.class.getName()), ref);
ctxCtrl.expectAndReturn(ctx.getService(ref), runner);
ctx.registerService((String) null, null, null);
ctxCtrl.setMatcher(MockControl.ALWAYS_MATCHER);
ctxCtrl.setReturnValue(null);
ctxCtrl.replay();
servCtrl.replay();
activator.start(ctx);
ctxCtrl.verify();
}
示例3: testStop
import org.easymock.MockControl; //导入方法依赖的package包/类
public void testStop() throws Exception {
ServiceReference ref = new MockServiceReference();
MockControl regCtrl = MockControl.createControl(ServiceRegistration.class);
ServiceRegistration reg = (ServiceRegistration) regCtrl.getMock();
MockControl ctxCtrl = MockControl.createControl(BundleContext.class);
BundleContext ctx = (BundleContext) ctxCtrl.getMock();
reg.unregister();
ctxCtrl.replay();
regCtrl.replay();
setActivatorField("reference", ref);
setActivatorField("registration", reg);
activator.stop(ctx);
regCtrl.verify();
ctxCtrl.verify();
}
示例4: testGetResourceFromBundle
import org.easymock.MockControl; //导入方法依赖的package包/类
/**
* Test method for
* {@link org.springframework.osgi.io.OsgiBundleResource#getResourceFromBundleSpace(java.lang.String)}.
*/
public void testGetResourceFromBundle() throws Exception {
MockControl control = MockControl.createControl(Bundle.class);
Bundle mock = (Bundle) control.getMock();
String location = "foo";
URL result = new URL("file:/" + location);
control.expectAndReturn(mock.findEntries("/", "foo", false), new ArrayEnumerator(new URL[] { result }));
control.replay();
resource = new OsgiBundleResource(mock, location);
assertEquals(result, resource.getResourceFromBundleSpace(location).getURL());
control.verify();
}
示例5: testGetResourceFromBundleClasspath
import org.easymock.MockControl; //导入方法依赖的package包/类
/**
* Test method for
* {@link org.springframework.osgi.io.OsgiBundleResource#getResourceFromBundleClasspath(java.lang.String)}.
*/
public void testGetResourceFromBundleClasspath() throws Exception {
MockControl control = MockControl.createControl(Bundle.class);
Bundle mock = (Bundle) control.getMock();
String location = "file://foo";
URL result = new URL(location);
control.expectAndReturn(mock.getResource(location), result);
control.replay();
resource = new OsgiBundleResource(mock, location);
assertSame(result, resource.getResourceFromBundleClasspath(location));
control.verify();
}
示例6: testGetRemoteJar
import org.easymock.MockControl; //导入方法依赖的package包/类
public void testGetRemoteJar()
throws TransferFailedException, ResourceDoesNotExistException, UnsupportedProtocolException, IOException,
AuthorizationException
{
Artifact artifact = createTestArtifact( "target/test-data/get-remote-jar", "jar" );
ArtifactRepository repo = createStringRepo();
StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" );
wagon.addExpectedContent( repo.getLayout().pathOf( artifact ), "expected" );
MockControl control = MockControl.createControl( UpdateCheckManager.class );
control.replay();
wagonManager.getArtifact( artifact, repo, null, false );
assertTrue( artifact.getFile().exists() );
assertEquals( "expected", FileUtils.fileRead( artifact.getFile(), "UTF-8" ) );
control.verify();
}
示例7: testSybasePatchesCommitsOnEveryStatement
import org.easymock.MockControl; //导入方法依赖的package包/类
/**
* Test that sybase database patches are committed when illegal multi
* statement transaction commands are used.
*
* @throws IOException
* if an unexpected error occurs
* @throws MigrationException
* if an unexpected error occurs
* @throws SQLException
* if an unexpected error occurs
*/
public void testSybasePatchesCommitsOnEveryStatement() throws IOException,
MigrationException, SQLException
{
InputStream is = getClass().getResourceAsStream("test/sybase_tsql.sql");
assertNotNull(is);
task = new SqlScriptMigrationTask("sybase_tsql.sql", 1, is);
MockDatabaseType dbType = new MockDatabaseType("sybase");
dbType.setMultipleStatementsSupported(false);
context.setDatabaseType(dbType);
int numStatements = task.getSqlStatements(context).size();
// setup mocks to verify commits are called
MockControl dataSourceControl = MockControl
.createControl(DataSource.class);
DataSource dataSource = (DataSource) dataSourceControl.getMock();
context.setDataSource(dataSource);
MockControl connectionControl = MockControl
.createControl(Connection.class);
Connection connection = (Connection) connectionControl.getMock();
dataSourceControl.expectAndReturn(dataSource.getConnection(),
connection);
MockControl statementControl = MockControl
.createControl(Statement.class);
Statement statement = (Statement) statementControl.getMock();
statement.execute("");
statementControl.setMatcher(MockControl.ALWAYS_MATCHER);
statementControl.setReturnValue(true, MockControl.ONE_OR_MORE);
statementControl.expectAndReturn(statement.isClosed(), false, MockControl.ONE_OR_MORE);
statement.close();
statementControl.setVoidCallable(MockControl.ONE_OR_MORE);
connectionControl.expectAndReturn(connection.isClosed(), false,
MockControl.ONE_OR_MORE);
connectionControl.expectAndReturn(connection.createStatement(),
statement, numStatements);
connectionControl.expectAndReturn(connection.getAutoCommit(), false,
MockControl.ONE_OR_MORE);
connection.commit();
/*
* Magic Number 4 derived from the assumption that the fixture sql
* contains only one statement that is not allowed in a multi statement
* transaction: commit at beginning of migrate method commit prior to
* running the command not allowed in multi statement transaction to
* clear the transaction state. commit after running the multi statement
* transaction to clear transaction state for upcoming statements.
* commit at end of migrate method once all statements executed.
*
* Therefore, if you add more illegal statements to the fixture, add 2
* more commit call's for each illegal statement.
*/
connectionControl.setVoidCallable(4);
dataSourceControl.replay();
connectionControl.replay();
statementControl.replay();
// run tests
task.migrate(context);
dataSourceControl.verify();
connectionControl.verify();
}
示例8: testStart
import org.easymock.MockControl; //导入方法依赖的package包/类
public void testStart() throws Exception {
MockControl bundleContextControl = MockControl.createControl(BundleContext.class);
BundleContext context = (BundleContext) bundleContextControl.getMock();
// platform determination
// extracting bundle id from bundle
bundleContextControl.expectAndReturn(context.getBundle(), new MockBundle());
// look for existing resolved bundles
bundleContextControl.expectAndReturn(context.getBundles(), new Bundle[0], 2);
// register namespace and entity resolving service
// context.registerService((String[]) null, null, null);
// bundleContextControl.setMatcher(MockControl.ALWAYS_MATCHER);
// bundleContextControl.setReturnValue(null);
// register context service
context.registerService((String[]) null, null, null);
bundleContextControl.setMatcher(MockControl.ALWAYS_MATCHER);
bundleContextControl.setReturnValue(null, MockControl.ONE_OR_MORE);
// create task executor
EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(null);
aBundle.setEntryReturnOnNextCallToGetEntry(null);
bundleContextControl.expectAndReturn(context.getBundle(), aBundle, MockControl.ONE_OR_MORE);
// listen for bundle events
context.addBundleListener(null);
bundleContextControl.setMatcher(MockControl.ALWAYS_MATCHER);
bundleContextControl.setVoidCallable(2);
bundleContextControl.expectAndReturn(context.registerService(new String[0], null, new Properties()),
new MockServiceRegistration(), MockControl.ONE_OR_MORE);
bundleContextControl.setMatcher(MockControl.ALWAYS_MATCHER);
bundleContextControl.replay();
this.listener.start(context);
bundleContextControl.verify();
}
示例9: testUnregisterService
import org.easymock.MockControl; //导入方法依赖的package包/类
public void testUnregisterService() throws Exception {
MockControl ctrl = MockControl.createControl(ServiceRegistration.class);
ServiceRegistration reg = (ServiceRegistration) ctrl.getMock();
reg.unregister();
ctrl.replay();
exporter.unregisterService(reg);
ctrl.verify();
}
示例10: testUnregisterServiceAlreadyUnregistered
import org.easymock.MockControl; //导入方法依赖的package包/类
public void testUnregisterServiceAlreadyUnregistered() throws Exception {
MockControl ctrl = MockControl.createControl(ServiceRegistration.class);
ServiceRegistration reg = (ServiceRegistration) ctrl.getMock();
reg.unregister();
ctrl.setDefaultThrowable(new IllegalStateException());
ctrl.replay();
exporter.unregisterService(reg);
ctrl.verify();
}
示例11: testGetServiceProperties
import org.easymock.MockControl; //导入方法依赖的package包/类
public void testGetServiceProperties() {
MockControl bundleContextControl = MockControl.createControl(BundleContext.class);
BundleContext mockContext = (BundleContext) bundleContextControl.getMock();
MockControl bundleControl = MockControl.createControl(Bundle.class);
Bundle mockBundle = (Bundle) bundleControl.getMock();
mockContext.getBundle();
bundleContextControl.setReturnValue(mockBundle);
mockBundle.getSymbolicName();
bundleControl.setReturnValue("symbolic-name");
mockContext.getBundle();
bundleContextControl.setReturnValue(mockBundle);
mockBundle.getHeaders();
Properties props = new Properties();
props.put(Constants.BUNDLE_VERSION,"1.0.0");
bundleControl.setReturnValue(props);
bundleContextControl.replay();
bundleControl.replay();
BeanNameServicePropertiesResolver resolver = new BeanNameServicePropertiesResolver();
resolver.setBundleContext(mockContext);
Map ret = resolver.getServiceProperties("myBean");
bundleControl.verify();
bundleContextControl.verify();
assertEquals("3 properties",3,ret.size());
assertEquals("symbolic-name",ret.get("Bundle-SymbolicName"));
assertEquals("1.0.0",ret.get("Bundle-Version"));
assertEquals("myBean",ret.get("org.springframework.osgi.bean.name"));
}
示例12: testNestedBundleDeclaration
import org.easymock.MockControl; //导入方法依赖的package包/类
public void testNestedBundleDeclaration() throws Exception {
MockControl ctrl = MockControl.createControl(Bundle.class);
Bundle bnd = (Bundle) ctrl.getMock();
bnd.start();
ctrl.replay();
appContext.getBeanFactory().registerSingleton("createdByTheTest", bnd);
refresh();
appContext.getBean("nested");
BundleFactoryBean fb = (BundleFactoryBean) appContext.getBean("&nested", BundleFactoryBean.class);
ctrl.verify();
}
示例13: verifyAll
import org.easymock.MockControl; //导入方法依赖的package包/类
public void verifyAll()
{
for ( Iterator it = mockControls.iterator(); it.hasNext(); )
{
MockControl control = ( MockControl ) it.next();
control.verify();
}
}
示例14: 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();
}
示例15: 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();
}