Java Code Examples for org.easymock.IMocksControl#replay()
The following examples show how to use
org.easymock.IMocksControl#replay() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DatabaseTest.java From database with Apache License 2.0 | 6 votes |
@Test public void extraNamedParameter() throws Exception { IMocksControl control = createStrictControl(); Connection c = control.createMock(Connection.class); control.replay(); try { Long value = new DatabaseImpl(c, options).toSelect("select a from b where c=:x") .argString("x", "hi").argString("y", "bye").queryLongOrNull(); fail("Should have thrown an exception but returned " + value); } catch (DatabaseException e) { assertEquals("Error executing SQL (errorCode=1)", e.getMessage()); } control.verify(); }
Example 2
Source File: DatabaseTest.java From database with Apache License 2.0 | 6 votes |
@Test public void transactRollbackOnErrorWithError() throws Exception { IMocksControl control = createStrictControl(); final Connection c = control.createMock(Connection.class); c.setAutoCommit(false); c.rollback(); c.close(); control.replay(); try { new DatabaseProvider(() -> c, new OptionsDefault(Flavor.postgresql)).transact(db -> { db.get(); throw new Exception("Oops"); }); fail("Should have thrown an exception"); } catch (Exception e) { assertEquals("Error during transaction", e.getMessage()); } control.verify(); }
Example 3
Source File: DatabaseTest.java From database with Apache License 2.0 | 6 votes |
@Test public void settingMaxRows() throws Exception { IMocksControl control = createStrictControl(); Connection c = control.createMock(Connection.class); PreparedStatement ps = control.createMock(PreparedStatement.class); ResultSet rs = control.createMock(ResultSet.class); expect(c.prepareStatement("select a from b")).andReturn(ps); ps.setMaxRows(15); expect(ps.executeQuery()).andReturn(rs); expect(rs.next()).andReturn(false); rs.close(); ps.close(); control.replay(); assertNull(new DatabaseImpl(c, options).toSelect("select a from b").withMaxRows(15).queryLongOrNull()); control.verify(); }
Example 4
Source File: DatabaseTest.java From database with Apache License 2.0 | 6 votes |
@Test public void mixedParameterTypes() throws Exception { IMocksControl control = createStrictControl(); Connection c = control.createMock(Connection.class); PreparedStatement ps = control.createMock(PreparedStatement.class); ResultSet rs = control.createMock(ResultSet.class); expect(c.prepareStatement("select a from b where c=? and d=?")).andReturn(ps); ps.setObject(eq(1), eq("bye")); ps.setNull(eq(2), eq(Types.TIMESTAMP)); expect(ps.executeQuery()).andReturn(rs); expect(rs.next()).andReturn(false); rs.close(); ps.close(); control.replay(); assertNull(new DatabaseImpl(c, options).toSelect("select a from b where c=:x and d=?") .argString(":x", "bye").argDate(null).queryLongOrNull()); control.verify(); }
Example 5
Source File: DatabaseTest.java From database with Apache License 2.0 | 6 votes |
@Test public void transactionCommitFail() throws Exception { IMocksControl control = createStrictControl(); Connection c = control.createMock(Connection.class); c.commit(); expectLastCall().andThrow(new SQLException("Oops")); control.replay(); try { new DatabaseImpl(c, new OptionsDefault(Flavor.postgresql) { @Override public boolean allowTransactionControl() { return true; } }).commitNow(); fail("Should have thrown an exception"); } catch (DatabaseException e) { assertEquals("Unable to commit transaction", e.getMessage()); } control.verify(); }
Example 6
Source File: DatabaseTest.java From database with Apache License 2.0 | 6 votes |
@Test public void sqlArgLongNull() throws Exception { IMocksControl control = createStrictControl(); Connection c = control.createMock(Connection.class); PreparedStatement ps = control.createMock(PreparedStatement.class); ResultSet rs = control.createMock(ResultSet.class); expect(c.prepareStatement("select a from b where c=?")).andReturn(ps); ps.setNull(eq(1), eq(Types.NUMERIC)); expect(ps.executeQuery()).andReturn(rs); expect(rs.next()).andReturn(false); rs.close(); ps.close(); control.replay(); assertNull(new DatabaseImpl(c, options).toSelect("select a from b where c=?").argLong(null).queryLongOrNull()); control.verify(); }
Example 7
Source File: DatabaseTest.java From database with Apache License 2.0 | 6 votes |
@Test public void sqlArgLongPositional() throws Exception { IMocksControl control = createStrictControl(); Connection c = control.createMock(Connection.class); PreparedStatement ps = control.createMock(PreparedStatement.class); ResultSet rs = control.createMock(ResultSet.class); expect(c.prepareStatement("select a from b where c=?")).andReturn(ps); ps.setObject(eq(1), eq(new Long(1))); expect(ps.executeQuery()).andReturn(rs); expect(rs.next()).andReturn(false); rs.close(); ps.close(); control.replay(); assertNull(new DatabaseImpl(c, options).toSelect("select a from b where c=?").argLong(1L).queryLongOrNull()); control.verify(); }
Example 8
Source File: DatabaseTest.java From database with Apache License 2.0 | 6 votes |
@Test public void transactCommitOnlyWithNoError() throws Exception { IMocksControl control = createStrictControl(); final Connection c = control.createMock(Connection.class); c.setAutoCommit(false); c.commit(); c.close(); control.replay(); new DatabaseProvider(() -> c, new OptionsDefault(Flavor.postgresql)).transact((db, tx) -> { tx.setRollbackOnError(false); db.get(); }); control.verify(); }
Example 9
Source File: ContextPathTest.java From dagger-servlet with Apache License 2.0 | 6 votes |
@Test public void testSimple() throws Exception { IMocksControl testControl = createControl(); TestFilterChain testFilterChain = new TestFilterChain(); HttpServletRequest req = testControl.createMock(HttpServletRequest.class); HttpServletResponse res = testControl.createMock(HttpServletResponse.class); expect(req.getMethod()).andReturn("GET").anyTimes(); expect(req.getRequestURI()).andReturn("/bar/foo").anyTimes(); expect(req.getServletPath()).andReturn("/bar/foo").anyTimes(); expect(req.getContextPath()).andReturn("").anyTimes(); testControl.replay(); daggerFilter.doFilter(req, res, testFilterChain); assertFalse(testFilterChain.isTriggered()); assertFalse(fooServlet.isTriggered()); assertTrue(barServlet.isTriggered()); testControl.verify(); }
Example 10
Source File: Wsdl11AttachmentPolicyProviderTest.java From cxf with Apache License 2.0 | 5 votes |
@BeforeClass public static void oneTimeSetUp() throws Exception { IMocksControl control = EasyMock.createNiceControl(); Bus bus = control.createMock(Bus.class); WSDLManager manager = new WSDLManagerImpl(); WSDLServiceBuilder builder = new WSDLServiceBuilder(bus); DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class); EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andReturn(dfm).anyTimes(); EasyMock.expect(dfm.getDestinationFactory(EasyMock.isA(String.class))).andReturn(null).anyTimes(); BindingFactoryManager bfm = control.createMock(BindingFactoryManager.class); EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bfm).anyTimes(); EasyMock.expect(bfm.getBindingFactory(EasyMock.isA(String.class))).andReturn(null).anyTimes(); control.replay(); int n = 19; services = new ServiceInfo[n]; endpoints = new EndpointInfo[n]; for (int i = 0; i < n; i++) { String resourceName = "/attachment/wsdl11/test" + i + ".wsdl"; URL url = Wsdl11AttachmentPolicyProviderTest.class.getResource(resourceName); try { services[i] = builder.buildServices(manager.getDefinition(url.toString())).get(0); } catch (WSDLException ex) { ex.printStackTrace(); fail("Failed to build service from resource " + resourceName); } assertNotNull(services[i]); endpoints[i] = services[i].getEndpoints().iterator().next(); assertNotNull(endpoints[i]); } control.verify(); }
Example 11
Source File: BareOutInterceptorTest.java From cxf with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { super.setUp(); interceptor = new BareOutInterceptor(); baos = new ByteArrayOutputStream(); writer = getXMLStreamWriter(baos); message.setContent(XMLStreamWriter.class, writer); message.getExchange().put(BindingOperationInfo.class, operation); IMocksControl control = EasyMock.createNiceControl(); InterceptorChain ic = control.createMock(InterceptorChain.class); message.setInterceptorChain(ic); control.replay(); }
Example 12
Source File: JAASLoginInterceptorTest.java From cxf with Apache License 2.0 | 5 votes |
private X509Certificate createTestCert(String subjectDn) { IMocksControl c = EasyMock.createControl(); X509Certificate cert = c.createMock(X509Certificate.class); Principal principal = c.createMock(Principal.class); EasyMock.expect(principal.getName()).andReturn(subjectDn); EasyMock.expect(cert.getSubjectDN()).andReturn(principal); c.replay(); return cert; }
Example 13
Source File: DvcsDraftRevisionTest.java From MOE with Apache License 2.0 | 5 votes |
public void testGetLocation() { final File mockRepoPath = new File("/mockrepo"); IMocksControl control = EasyMock.createControl(); LocalWorkspace mockRevClone = control.createMock(LocalWorkspace.class); expect(mockRevClone.getLocalTempDir()).andReturn(mockRepoPath); control.replay(); DvcsDraftRevision dr = new DvcsDraftRevision(mockRevClone); assertEquals(mockRepoPath.getAbsolutePath(), dr.getLocation()); control.verify(); }
Example 14
Source File: FileDbTest.java From MOE with Apache License 2.0 | 5 votes |
public void testWriteDbToFile() throws Exception { IMocksControl control = EasyMock.createControl(); FileSystem filesystem = control.createMock(FileSystem.class); File dbFile = new File("/path/to/db"); String dbText = "{\n \"equivalences\": [],\n \"migrations\": []\n}\n"; DbStorage dbStorage = GSON.fromJson(dbText, DbStorage.class); Db db = new FileDb(dbFile.getPath(), dbStorage, new FileDb.Writer(GSON, filesystem)); filesystem.write(dbText, dbFile); EasyMock.expectLastCall(); control.replay(); db.write(); control.verify(); }
Example 15
Source File: FileDbTest.java From MOE with Apache License 2.0 | 5 votes |
public void testMakeDbFromFile() throws Exception { IMocksControl control = EasyMock.createControl(); FileSystem filesystem = control.createMock(FileSystem.class); File dbFile = new File("/path/to/db"); FileDb.Factory factory = new FileDb.Factory(filesystem, GsonModule.provideGson()); String dbText = Joiner.on("\n") .join( "{", " 'equivalences': [", " {", " 'rev1': {", " 'revId': 'r1',", " 'repositoryName': 'name1'", " },", " 'rev2': {", " 'revId': 'r2',", " 'repositoryName': 'name2'", " }", " }", " ]", "}", ""); expect(filesystem.fileToString(dbFile)).andReturn(dbText); expect(filesystem.exists(dbFile)).andReturn(true); control.replay(); assertThat(factory.load(dbFile.toPath()).getEquivalences()) .isEqualTo(parseJson(dbFile.getPath(), dbText).getEquivalences()); control.verify(); }
Example 16
Source File: JdbcTest.java From tddl5 with Apache License 2.0 | 4 votes |
public void test() { IMocksControl control = EasyMock.createControl(); DBUtility mockDBUtility = control.createMock(DBUtility.class); Connection mockConnection = control.createMock(Connection.class); Statement mockStatement = control.createMock(Statement.class); ResultSet mockResultSet = control.createMock(ResultSet.class); try { mockDBUtility.getConnection(); EasyMock.expectLastCall().andStubReturn(mockConnection); mockConnection.createStatement(); EasyMock.expectLastCall().andStubReturn(mockStatement); mockStatement.executeQuery(SQLEquals.sqlEquals("SELECT * FROM sales_order_table")); EasyMock.expectLastCall().andStubReturn(mockResultSet); mockResultSet.next(); EasyMock.expectLastCall().andReturn(true).times(3); EasyMock.expectLastCall().andReturn(false).times(1); mockResultSet.getString(1); EasyMock.expectLastCall().andReturn("DEMO_ORDER_001").times(1); EasyMock.expectLastCall().andReturn("DEMO_ORDER_002").times(1); EasyMock.expectLastCall().andReturn("DEMO_ORDER_003").times(1); mockResultSet.getString(2); EasyMock.expectLastCall().andReturn("Asia Pacific").times(1); EasyMock.expectLastCall().andReturn("Europe").times(1); EasyMock.expectLastCall().andReturn("America").times(1); mockResultSet.getDouble(3); EasyMock.expectLastCall().andReturn(350.0).times(1); EasyMock.expectLastCall().andReturn(1350.0).times(1); EasyMock.expectLastCall().andReturn(5350.0).times(1); control.replay(); Connection conn = mockDBUtility.getConnection(); Statement stat = conn.createStatement(); ResultSet rs = stat.executeQuery("select * from sales_order_table"); int i = 0; String[] priceLevels = { "Level_A", "Level_C", "Level_E" }; while (rs.next()) { SalesOrder order = new SalesOrderImpl(); order.loadDataFromDB(rs); assertEquals(order.getPriceLevel(), priceLevels[i]); i++; } control.verify(); } catch (Exception e) { e.printStackTrace(); } }
Example 17
Source File: JdbcMigrationLauncherTest.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Test that when a migrationSuccessful event fires. If the * 'successful' patch level is less than the current patch level * for the context's that is updating, then do not blow away the * existing patch level. * This case occurs when running patching in force sync mode. * Example: * node 1 is at patch level 2 * node 2 is out of sync (or patch level zero). * When node 2 is forcesync'ed, node2 applies patch 1, * it succeeds and all migration listeners are notified. * If we do not protect the nodes, then node 1 would have it's patch level set * to 1. Then when patch 2 is executed, node 1 now thinks it needs to apply * it, and chaos ensues. * * @throws MigrationException */ public void testMigrationSuccessfulDoesNotOverWritePatchLevel() throws MigrationException { // not using the 'setup' method's initilization because I really just want // to unit test the migration successful method. launcher = new JdbcMigrationLauncher(); int migrationSuccessfulPatchLevel = 1; int node1PatchLevel = 2; int node2PatchLevel = 0; // create mocks MockControl node1ContextControl = MockControl.createControl(JdbcMigrationContext.class); MockControl node2ContextControl = MockControl.createControl(JdbcMigrationContext.class); JdbcMigrationContext node1Context = (JdbcMigrationContext) node1ContextControl.getMock(); JdbcMigrationContext node2Context = (JdbcMigrationContext) node2ContextControl.getMock(); MockControl node1PatchInfoStoreControl = MockControl.createControl(PatchInfoStore.class); MockControl node2PatchInfoStoreControl = MockControl.createControl(PatchInfoStore.class); PatchInfoStore node1PatchInfoStore = (PatchInfoStore) node1PatchInfoStoreControl.getMock(); PatchInfoStore node2PatchInfoStore = (PatchInfoStore) node2PatchInfoStoreControl.getMock(); LinkedHashMap contexts = new LinkedHashMap(); contexts.put(node1Context, node1PatchInfoStore); contexts.put(node2Context, node2PatchInfoStore); launcher.setContexts(contexts); MockControl taskControl = MockControl.createControl(RollbackableMigrationTask.class); MockControl contextControl = MockControl.createControl(MigrationContext.class); RollbackableMigrationTask task = (RollbackableMigrationTask) taskControl.getMock(); MigrationContext context = (MigrationContext) contextControl.getMock(); // set expectations // the migration successful event is for patch level 1 task.getLevel(); taskControl.setDefaultReturnValue(new Integer(migrationSuccessfulPatchLevel)); task.getName(); taskControl.setDefaultReturnValue("patch001_test.sql"); taskControl.replay(); IMocksControl migrationStrategyControl = createStrictControl(); MigrationRunnerStrategy migrationStrategyMock = migrationStrategyControl.createMock(MigrationRunnerStrategy.class); // node1 is at patchlevel 2 node1PatchInfoStore.getPatchLevel(); node1PatchInfoStoreControl.setDefaultReturnValue(node1PatchLevel); node1PatchInfoStoreControl.replay(); expect(migrationStrategyMock.shouldMigrationRun(1, node1PatchInfoStore)).andReturn(false); // node2 is at patchlevel 1 node2PatchInfoStore.getPatchLevel(); node2PatchInfoStoreControl.setDefaultReturnValue(node2PatchLevel); expect(migrationStrategyMock.shouldMigrationRun(1, node2PatchInfoStore)).andReturn(true); node2PatchInfoStore.updatePatchLevel(migrationSuccessfulPatchLevel); node2PatchInfoStoreControl.setVoidCallable(); node2PatchInfoStoreControl.replay(); migrationStrategyControl.replay(); launcher.getMigrationProcess().setMigrationRunnerStrategy(migrationStrategyMock); // test and validate launcher.migrationSuccessful(task, context); taskControl.verify(); node1PatchInfoStoreControl.verify(); node2PatchInfoStoreControl.verify(); }
Example 18
Source File: JdbcMigrationLauncherTest.java From lams with GNU General Public License v2.0 | 4 votes |
/** * 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(); }
Example 19
Source File: JdbcMigrationLauncherTest.java From lams with GNU General Public License v2.0 | 4 votes |
/** * 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(); }
Example 20
Source File: RepositoryContentConsumersTest.java From archiva with Apache License 2.0 | 4 votes |
@Test public void testExecution() throws Exception { IMocksControl knownControl = createNiceControl(); RepositoryContentConsumers consumers = lookupRepositoryConsumers(); KnownRepositoryContentConsumer selectedKnownConsumer = knownControl.createMock( KnownRepositoryContentConsumer.class ); KnownRepositoryContentConsumer unselectedKnownConsumer = createNiceControl().createMock( KnownRepositoryContentConsumer.class ); consumers.setApplicationContext( new MockApplicationContext( Arrays.asList( selectedKnownConsumer, unselectedKnownConsumer ), null ) ); consumers.setSelectedKnownConsumers( Collections.singletonList( selectedKnownConsumer ) ); IMocksControl invalidControl = createControl(); InvalidRepositoryContentConsumer selectedInvalidConsumer = invalidControl.createMock( InvalidRepositoryContentConsumer.class ); InvalidRepositoryContentConsumer unselectedInvalidConsumer = createControl().createMock( InvalidRepositoryContentConsumer.class ); consumers.setApplicationContext( new MockApplicationContext( null, Arrays.asList( selectedInvalidConsumer, unselectedInvalidConsumer ) ) ); consumers.setSelectedInvalidConsumers( Collections.singletonList( selectedInvalidConsumer ) ); ManagedRepository repo = createRepository( "id", "name", Paths.get( "target/test-repo" ) ); Path testFile = Paths.get( "target/test-repo/path/to/test-file.txt" ); Date startTime = new Date( System.currentTimeMillis() ); startTime.setTime( 12345678 ); selectedKnownConsumer.beginScan( repo, startTime, false ); expect( selectedKnownConsumer.getIncludes() ).andReturn( Collections.singletonList( "**/*.txt" ) ); selectedKnownConsumer.processFile( _OS( "path/to/test-file.txt" ), false ); knownControl.replay(); selectedInvalidConsumer.beginScan( repo, startTime, false ); invalidControl.replay(); consumers.executeConsumers( repo, testFile, true ); knownControl.verify(); invalidControl.verify(); knownControl.reset(); invalidControl.reset(); Path notIncludedTestFile = Paths.get( "target/test-repo/path/to/test-file.xml" ); selectedKnownConsumer.beginScan( repo, startTime, false ); expect( selectedKnownConsumer.getExcludes() ).andReturn( Collections.<String>emptyList() ); expect( selectedKnownConsumer.getIncludes() ).andReturn( Collections.singletonList( "**/*.txt" ) ); knownControl.replay(); selectedInvalidConsumer.beginScan( repo, startTime, false ); selectedInvalidConsumer.processFile( _OS( "path/to/test-file.xml" ), false ); expect( selectedInvalidConsumer.getId() ).andReturn( "invalid" ); invalidControl.replay(); consumers.executeConsumers( repo, notIncludedTestFile, true ); knownControl.verify(); invalidControl.verify(); knownControl.reset(); invalidControl.reset(); Path excludedTestFile = Paths.get( "target/test-repo/path/to/test-file.txt" ); selectedKnownConsumer.beginScan( repo, startTime, false ); expect( selectedKnownConsumer.getExcludes() ).andReturn( Collections.singletonList( "**/test-file.txt" ) ); knownControl.replay(); selectedInvalidConsumer.beginScan( repo, startTime, false ); selectedInvalidConsumer.processFile( _OS( "path/to/test-file.txt" ), false ); expect( selectedInvalidConsumer.getId() ).andReturn( "invalid" ); invalidControl.replay(); consumers.executeConsumers( repo, excludedTestFile, true ); knownControl.verify(); invalidControl.verify(); }