Java Code Examples for org.easymock.EasyMock#replay()
The following examples show how to use
org.easymock.EasyMock#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: HostmapFunctionProcessorTest.java From knox with Apache License 2.0 | 6 votes |
@Test public void testEmptyHostmapUseCase() throws Exception { URL configUrl = TestUtils.getResourceUrl( this.getClass(), "empty-hostmap.txt" ); UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class ); EasyMock.expect( environment.getResource( "/WEB-INF/hostmap.txt" ) ).andReturn( configUrl ).anyTimes(); Resolver resolver = EasyMock.createNiceMock( Resolver.class ); EasyMock.expect( resolver.resolve( "host" ) ).andReturn(Collections.singletonList("test-inbound-host")).anyTimes(); EasyMock.replay( environment, resolver ); UrlRewriteRulesDescriptor descriptor = UrlRewriteRulesDescriptorFactory.create(); UrlRewriteRuleDescriptor rule = descriptor.addRule( "test-rule" ); rule.pattern( "{*}://{host}:{*}/{**}?{**}" ); UrlRewriteActionRewriteDescriptorExt rewrite = rule.addStep( "rewrite" ); rewrite.template( "{*}://{$hostmap(host)}:{*}/{**}?{**}" ); UrlRewriteProcessor rewriter = new UrlRewriteProcessor(); rewriter.initialize( environment, descriptor ); Template input = Parser.parseLiteral( "test-scheme://test-inbound-host:42/test-path/test-file?test-name=test-value" ); Template output = rewriter.rewrite( resolver, input, UrlRewriter.Direction.IN, null ); assertThat( output, notNullValue() ); assertThat( output.getHost().getFirstValue().getPattern(), is( "test-inbound-host" ) ); }
Example 2
Source File: TestFileContentBuilder.java From cms with Apache License 2.0 | 6 votes |
@Test public void test_find() { WPBFile fileMock = EasyMock.createMock(WPBFile.class); String externalKey = "1234"; try { EasyMock.expect(filesCacheMock.getByExternalKey(externalKey)).andReturn(fileMock); EasyMock.replay(cloudFileStorageMock, cacheInstancesMock, filesCacheMock, fileMock); fileContentBuilder = new FileContentBuilder(cacheInstancesMock); WPBFile result = fileContentBuilder.find(externalKey); EasyMock.verify(cloudFileStorageMock, cacheInstancesMock, filesCacheMock, fileMock); assertTrue (result == fileMock); } catch (Exception e) { assertTrue (false); } }
Example 3
Source File: JettyHTTPDestinationTest.java From cxf with Apache License 2.0 | 6 votes |
private void verifyGetWSDLQuery() throws Exception { EasyMock.reset(bus); request.getRequestURL(); EasyMock.expectLastCall().andReturn(new StringBuffer("http://localhost/bar/foo")).times(2); request.getPathInfo(); EasyMock.expectLastCall().andReturn("/bar/foo"); request.getCharacterEncoding(); EasyMock.expectLastCall().andReturn(StandardCharsets.UTF_8.name()); request.getQueryString(); EasyMock.expectLastCall().andReturn("wsdl"); response.setContentType("text/xml"); EasyMock.expectLastCall(); response.getOutputStream(); EasyMock.expectLastCall().andReturn(os).anyTimes(); request.setHandled(true); EasyMock.expectLastCall(); EasyMock.replay(bus); }
Example 4
Source File: FutureFilterTest.java From dubbo3 with Apache License 2.0 | 5 votes |
@Test public void testSyncCallback() { @SuppressWarnings("unchecked") Invoker<DemoService> invoker = EasyMock.createMock(Invoker.class); EasyMock.expect(invoker.isAvailable()).andReturn(true).anyTimes(); EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class).anyTimes(); RpcResult result = new RpcResult(); result.setValue("High"); EasyMock.expect(invoker.invoke(invocation)).andReturn(result).anyTimes(); URL url = URL.valueOf("test://test:11/test?group=dubbo&version=1.1"); EasyMock.expect(invoker.getUrl()).andReturn(url).anyTimes(); EasyMock.replay(invoker); Result filterResult = eventFilter.invoke(invoker, invocation); assertEquals("High", filterResult.getValue()); }
Example 5
Source File: AmbariDynamicServiceURLCreatorTest.java From knox with Apache License 2.0 | 5 votes |
@Test public void testHdfsUIURLFederatedNNWithDefaultFS() throws Exception { final String NS1 = "myns1"; final String NS2 = "myns2"; final String NAMESERVICES = NS1 + "," + NS2; final String HTTP_ADDRESS_11 = "host11:50070"; final String HTTP_ADDRESS_12 = "host12:50077"; final String HTTP_ADDRESS_21 = "host21:50070"; final String HTTP_ADDRESS_22 = "host22:50077"; final String EXPECTED_ADDR_1 = "http://" + HTTP_ADDRESS_21; final String EXPECTED_ADDR_2 = "http://" + HTTP_ADDRESS_22; AmbariCluster.ServiceConfiguration hdfsSC = EasyMock.createNiceMock(AmbariCluster.ServiceConfiguration.class); Map<String, String> hdfsProps = new HashMap<>(); hdfsProps.put("dfs.nameservices", NAMESERVICES); hdfsProps.put("dfs.namenode.http-address." + NS1 + ".nn1", HTTP_ADDRESS_11); hdfsProps.put("dfs.namenode.http-address." + NS1 + ".nn2", HTTP_ADDRESS_12); hdfsProps.put("dfs.namenode.http-address." + NS2 + ".nn1", HTTP_ADDRESS_21); hdfsProps.put("dfs.namenode.http-address." + NS2 + ".nn2", HTTP_ADDRESS_22); EasyMock.expect(hdfsSC.getProperties()).andReturn(hdfsProps).anyTimes(); EasyMock.replay(hdfsSC); AmbariCluster.ServiceConfiguration coreSC = EasyMock.createNiceMock(AmbariCluster.ServiceConfiguration.class); Map<String, String> coreProps = new HashMap<>(); coreProps.put("fs.defaultFS", NS2); EasyMock.expect(coreSC.getProperties()).andReturn(coreProps).anyTimes(); EasyMock.replay(coreSC); AmbariCluster cluster = EasyMock.createNiceMock(AmbariCluster.class); EasyMock.expect(cluster.getServiceConfiguration("HDFS", "hdfs-site")).andReturn(hdfsSC).anyTimes(); EasyMock.expect(cluster.getServiceConfiguration("HDFS", "core-site")).andReturn(coreSC).anyTimes(); EasyMock.replay(cluster); // Create the URL List<String> webhdfsURLs = ServiceURLFactory.newInstance(cluster).create("HDFSUI", null); assertEquals(2, webhdfsURLs.size()); assertTrue(webhdfsURLs.contains(EXPECTED_ADDR_1)); assertTrue(webhdfsURLs.contains(EXPECTED_ADDR_2)); }
Example 6
Source File: TestActionList.java From arcusplatform with Apache License 2.0 | 5 votes |
@Test public void testSingleActionReturnsImmediately() { StatefulAction action = EasyMock.createMock(StatefulAction.class); EasyMock .expect(action.execute(new NamespaceContext("0", context))) .andReturn(ActionState.IDLE); EasyMock.replay(action); SequentialActionList list = new SequentialActionList.Builder().addAction(action).build(); assertEquals(ActionState.IDLE, list.execute(context)); EasyMock.verify(action); }
Example 7
Source File: TestWBPageController.java From cms with Apache License 2.0 | 5 votes |
@Test public void test_get_exception() { try { String json = "{}"; Object key = EasyMock.expect(requestMock.getAttribute("key")).andReturn("123"); EasyMock.expect(adminStorageMock.get("123", WPBPage.class)).andThrow(new WPBIOException("")); Capture<HttpServletResponse> captureHttpResponse = new Capture<HttpServletResponse>(); Capture<String> captureData = new Capture<String>(); Capture<Map<String, String>> captureErrors = new Capture<Map<String,String>>(); httpServletToolboxMock.writeBodyResponseAsJson(EasyMock.capture(captureHttpResponse), EasyMock.capture(captureData), EasyMock.capture(captureErrors)); EasyMock.replay(httpServletToolboxMock, requestMock, responseMock, jsonObjectConverterMock, validatorMock, adminStorageMock, objectForControllerMock); controllerForTest.get(requestMock, responseMock, "/abc"); EasyMock.verify(httpServletToolboxMock, requestMock, responseMock, jsonObjectConverterMock, validatorMock, adminStorageMock, objectForControllerMock); assertTrue (captureErrors.getValue().get("").compareTo(WPBErrors.WB_CANT_GET_RECORDS) == 0); assertTrue (captureData.getValue().compareTo(json) == 0); assertTrue (captureHttpResponse.getValue() == responseMock); } catch (Exception e) { assertTrue(false); } }
Example 8
Source File: LawnNGardenSubsystemTestCase.java From arcusplatform with Apache License 2.0 | 5 votes |
protected LawnNGardenSubsystem createSubsystem() { Scheduler scheduler = EasyMock.createMock(Scheduler.class); EasyMock.expect(scheduler.scheduleAt(EasyMock.isA(Runnable.class), EasyMock.isA(Date.class))).andReturn(new DummyScheduledTask()).anyTimes(); EasyMock.expect(scheduler.scheduleDelayed(EasyMock.isA(Runnable.class), EasyMock.anyLong(), EasyMock.isA(TimeUnit.class))).andReturn(new DummyScheduledTask()).anyTimes(); EasyMock.replay(scheduler); LawnNGardenConfig config = new LawnNGardenConfig(); return new LawnNGardenSubsystem(config, scheduler); }
Example 9
Source File: TimedSemaphoreTest.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Tests the acquire() method if more threads are involved than the limit. * This method starts a number of threads that all invoke the semaphore. The * semaphore's limit is set to 1, so in each period only a single thread can * acquire the semaphore. */ @Test public void testAcquireMultipleThreads() throws InterruptedException { ScheduledExecutorService service = EasyMock .createMock(ScheduledExecutorService.class); ScheduledFuture<?> future = EasyMock.createMock(ScheduledFuture.class); prepareStartTimer(service, future); EasyMock.replay(service, future); TimedSemaphoreTestImpl semaphore = new TimedSemaphoreTestImpl(service, PERIOD, UNIT, 1); semaphore.latch = new CountDownLatch(1); final int count = 10; SemaphoreThread[] threads = new SemaphoreThread[count]; for (int i = 0; i < count; i++) { threads[i] = new SemaphoreThread(semaphore, null, 1, 0); threads[i].start(); } for (int i = 0; i < count; i++) { semaphore.latch.await(); assertEquals("Wrong count", 1, semaphore.getAcquireCount()); semaphore.latch = new CountDownLatch(1); semaphore.endOfPeriod(); assertEquals("Wrong acquire count", 1, semaphore .getLastAcquiresPerPeriod()); } for (int i = 0; i < count; i++) { threads[i].join(); } EasyMock.verify(service, future); }
Example 10
Source File: AbstractClusterInvokerTest.java From dubbox with Apache License 2.0 | 5 votes |
@Test public void testCloseAvailablecheck(){ LoadBalance lb = EasyMock.createMock(LoadBalance.class); EasyMock.expect(lb.select(invokers, url, invocation)).andReturn(invoker1); EasyMock.replay(lb); initlistsize5(); Invoker sinvoker = cluster_nocheck.select(lb, invocation, invokers, selectedInvokers); Assert.assertEquals(false,sinvoker.isAvailable()); Assert.assertEquals(invoker1,sinvoker); }
Example 11
Source File: TestWBUriController.java From cms with Apache License 2.0 | 5 votes |
@Test public void test_getWBUri_exception() { try { String json = ""; Object key = EasyMock.expect(requestMock.getAttribute("key")).andReturn("123"); EasyMock.expect(adminStorageMock.get("123", WPBUri.class)).andThrow(new WPBIOException("")); Capture<HttpServletResponse> captureHttpResponse = new Capture<HttpServletResponse>(); Capture<String> captureData = new Capture<String>(); Capture<Map<String, String>> captureErrors = new Capture<Map<String,String>>(); httpServletToolboxMock.writeBodyResponseAsJson(EasyMock.capture(captureHttpResponse), EasyMock.capture(captureData), EasyMock.capture(captureErrors)); EasyMock.replay(httpServletToolboxMock, requestMock, responseMock, jsonObjectConverterMock, validatorMock, adminStorageMock, objectForControllerMock); controllerForTest.getWBUri(requestMock, responseMock, "/abc"); EasyMock.verify(httpServletToolboxMock, requestMock, responseMock, jsonObjectConverterMock, validatorMock, adminStorageMock, objectForControllerMock); assertTrue (captureErrors.getValue().get("").compareTo(WPBErrors.WB_CANT_GET_RECORDS) == 0); assertTrue (captureData.getValue().compareTo(json) == 0); assertTrue (captureHttpResponse.getValue() == responseMock); } catch (Exception e) { assertTrue(false); } }
Example 12
Source File: ProducerTest.java From luxun with Apache License 2.0 | 5 votes |
public void testSend() { Properties props = new Properties(); props.put("partitioner.class", StaticPartitioner.class.getName()); props.put("serializer.class", StringEncoder.class.getName()); props.put("broker.list", brokerList); ProducerConfig config = new ProducerConfig(props); IPartitioner<String> partitioner = new StaticPartitioner(); Encoder<String> serializer = new StringEncoder(); // 2 sync producers ConcurrentHashMap<Integer, SyncProducer> syncProducers = new ConcurrentHashMap<Integer, SyncProducer>(); SyncProducer syncProducer1 = EasyMock.createMock(SyncProducer.class); SyncProducer syncProducer2 = EasyMock.createMock(SyncProducer.class); // it should send to second broker MessageList messageList = new MessageList(); messageList.add(new Message("test1".getBytes())); syncProducer2.send(topic, messageList); EasyMock.expectLastCall(); syncProducer1.close(); EasyMock.expectLastCall(); syncProducer2.close(); EasyMock.expectLastCall(); EasyMock.replay(syncProducer1); EasyMock.replay(syncProducer2); syncProducers.put(brokerId1, syncProducer1); syncProducers.put(brokerId2, syncProducer2); ProducerPool<String> producerPool = new ProducerPool<String>(config, serializer, syncProducers, new ConcurrentHashMap<Integer, AsyncProducer<String>>(), null, null); Producer<String, String> producer = new Producer<String, String>(config, partitioner, producerPool, false, null); producer.send(new ProducerData<String, String>(topic, "test1", "test1")); producer.close(); EasyMock.verify(syncProducer1); EasyMock.verify(syncProducer2); }
Example 13
Source File: ConfigureProcessTest.java From c2mon with GNU Lesser General Public License v3.0 | 4 votes |
@Test public void createProcess() { // setup Configuration: Properties expectedProps = new Properties(); Process process = buildCreateBasicProcess(expectedProps); List<Process> processList = Arrays.asList(process); Configuration config = new Configuration(1L); config.setEntities(processList); // setUp Mocks: EasyMock.expect(sequenceDAO.getNextProcessId()).andReturn(1L); EasyMock.expect(processDAO.getIdByName("P_TEST")).andReturn(null); EasyMock.expect(processCache.hasKey(1L)).andReturn(false); EasyMock.expect(controlTagCache.get("P_TEST:ALIVE")).andReturn(null); EasyMock.expect(tagFacadeGateway.isInTagCache(101L)).andReturn(false); EasyMock.expect(sequenceDAO.getNextTagId()).andReturn(101L); EasyMock.expect(controlTagCache.get("P_TEST:STATUS")).andReturn(null); EasyMock.expect(tagFacadeGateway.isInTagCache(100L)).andReturn(false); EasyMock.expect(sequenceDAO.getNextTagId()).andReturn(100L); EasyMock.replay(processCache, sequenceDAO, tagFacadeGateway, controlTagCache); List<ConfigurationElement> parsed = parser.parse(config); assertEquals(parsed.size(), 3); assertEquals((long) parsed.get(0).getEntityId(), 101L); assertTrue(parsed.get(0).getEntity().equals(ConfigConstants.Entity.CONTROLTAG)); assertTrue(parsed.get(0).getAction().equals(ConfigConstants.Action.CREATE)); assertEquals(parsed.get(0).getElementProperties().size(), 6); assertEquals((long) parsed.get(1).getEntityId(), 100L); assertTrue(parsed.get(1).getEntity().equals(ConfigConstants.Entity.CONTROLTAG)); assertTrue(parsed.get(1).getAction().equals(ConfigConstants.Action.CREATE)); assertEquals(parsed.get(1).getElementProperties().size(), 6); assertEquals((long) parsed.get(2).getEntityId(), 1L); assertTrue(parsed.get(2).getEntity().equals(ConfigConstants.Entity.PROCESS)); assertTrue(parsed.get(2).getAction().equals(ConfigConstants.Action.CREATE)); assertEquals(parsed.get(2).getElementProperties(), expectedProps); EasyMock.verify(processCache, sequenceDAO, tagFacadeGateway, controlTagCache); }
Example 14
Source File: JPAQueryBuilderTest.java From olingo-odata2 with Apache License 2.0 | 4 votes |
private UriInfo mockURIInfoForEntitySetWithBinaryFilterExpression (EdmMapping mapping, String methodName) throws EdmException { UriInfo uriInfo = EasyMock.createMock(UriInfo.class); List<NavigationSegment> navSegments = new ArrayList<NavigationSegment>(); EasyMock.expect(uriInfo.getNavigationSegments()).andStubReturn(navSegments); EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class); EasyMock.expect(edmEntityType.getMapping()).andStubReturn(mapping); EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class); EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType); EasyMock.expect(uriInfo.getTargetEntitySet()).andStubReturn(edmEntitySet); EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class); EasyMock.expect(edmProperty.getMapping()).andStubReturn((EdmMapping)mockEdmMappingForProperty()); OrderByExpression orderbyExpression = EasyMock.createMock(OrderByExpression.class); List<OrderExpression> orders = new ArrayList<OrderExpression>(); EasyMock.expect(orderbyExpression.getOrders()).andStubReturn(orders); EasyMock.expect(uriInfo.getOrderBy()).andStubReturn(orderbyExpression); FilterExpression filterExpression = EasyMock.createMock(FilterExpression.class); BinaryExpression commonExpression = EasyMock.createMock(BinaryExpression.class); EasyMock.expect(commonExpression.getOperator()).andStubReturn(BinaryOperator.EQ); EasyMock.expect(commonExpression.getKind()).andStubReturn(ExpressionKind.BINARY); MethodExpression methodExp = EasyMock.createMock(MethodExpression.class); EasyMock.expect(commonExpression.getLeftOperand()).andStubReturn(methodExp); EdmSimpleType type = EasyMock.createMock(EdmSimpleType.class);; EasyMock.expect(methodExp.getEdmType()).andStubReturn(type ); LiteralExpression literalValueExp = EasyMock.createMock(LiteralExpression.class); EasyMock.expect(commonExpression.getRightOperand()).andStubReturn(literalValueExp); EasyMock.expect(literalValueExp.getUriLiteral()).andStubReturn("'a%.b*.c'"); EasyMock.expect(literalValueExp.getKind()).andStubReturn(ExpressionKind.LITERAL); EasyMock.expect(literalValueExp.getEdmType()).andStubReturn(EdmSimpleTypeKind.String.getEdmSimpleTypeInstance()); PropertyExpression propExp = EasyMock.createMock(PropertyExpression.class); LiteralExpression literalExp1 = EasyMock.createMock(LiteralExpression.class); LiteralExpression literalExp2 = EasyMock.createMock(LiteralExpression.class); List<CommonExpression> parameterList = new ArrayList<CommonExpression>(); if ("substring".equals(methodName)) { EasyMock.expect(methodExp.getMethod()).andStubReturn(MethodOperator.SUBSTRING); EasyMock.expect(methodExp.getKind()).andStubReturn(ExpressionKind.METHOD); EasyMock.expect(methodExp.getParameterCount()).andStubReturn(3); EasyMock.expect(propExp.getEdmProperty()).andStubReturn(edmProperty); EasyMock.expect(propExp.getKind()).andStubReturn(ExpressionKind.PROPERTY); parameterList.add(propExp); EasyMock.expect(literalExp1.getUriLiteral()).andStubReturn("1"); EasyMock.expect(literalExp1.getKind()).andStubReturn(ExpressionKind.LITERAL); EasyMock.expect(literalExp1.getEdmType()).andStubReturn(EdmSimpleTypeKind.Int16.getEdmSimpleTypeInstance()); parameterList.add(literalExp1); EasyMock.expect(literalExp2.getUriLiteral()).andStubReturn("2"); EasyMock.expect(literalExp2.getKind()).andStubReturn(ExpressionKind.LITERAL); EasyMock.expect(literalExp2.getEdmType()).andStubReturn(EdmSimpleTypeKind.Int16.getEdmSimpleTypeInstance()); parameterList.add(literalExp2); EasyMock.expect(methodExp.getParameters()).andStubReturn(parameterList); } else if ("toLower".equals(methodName)) { EasyMock.expect(methodExp.getMethod()).andStubReturn(MethodOperator.TOLOWER); EasyMock.expect(methodExp.getKind()).andStubReturn(ExpressionKind.METHOD); EasyMock.expect(methodExp.getParameterCount()).andStubReturn(1); EasyMock.expect(propExp.getEdmProperty()).andStubReturn(edmProperty); EasyMock.expect(propExp.getKind()).andStubReturn(ExpressionKind.PROPERTY); parameterList.add(propExp); EasyMock.expect(methodExp.getParameters()).andStubReturn(parameterList); } else if ("toUpper".equals(methodName)) { EasyMock.expect(methodExp.getMethod()).andStubReturn(MethodOperator.TOUPPER); EasyMock.expect(methodExp.getKind()).andStubReturn(ExpressionKind.METHOD); EasyMock.expect(methodExp.getParameterCount()).andStubReturn(1); EasyMock.expect(propExp.getEdmProperty()).andStubReturn(edmProperty); EasyMock.expect(propExp.getKind()).andStubReturn(ExpressionKind.PROPERTY); parameterList.add(propExp); EasyMock.expect(methodExp.getParameters()).andStubReturn(parameterList); } EasyMock.expect(filterExpression.getExpression()).andStubReturn(commonExpression); EasyMock.expect(filterExpression.getKind()).andStubReturn(ExpressionKind.FILTER); EasyMock.expect(filterExpression.getExpressionString()).andStubReturn("substring(CompanyName,1,2) eq 'a.b.c'"); EasyMock.expect(uriInfo.getFilter()).andStubReturn(filterExpression); EasyMock.replay(edmEntityType, edmEntitySet, orderbyExpression, filterExpression, commonExpression, literalExp1, literalExp2, propExp, uriInfo, edmProperty, methodExp, literalValueExp); return uriInfo; }
Example 15
Source File: JPQLJoinContextTest.java From olingo-odata2 with Apache License 2.0 | 4 votes |
@Before public void setUp() throws Exception { entitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class); EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class); EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class); List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>(); final EdmNavigationProperty navigationProperty = createNavigationProperty("a"); final EdmNavigationProperty navigationProperty1 = createNavigationProperty("b"); final List<KeyPredicate> keyPredicates = createKeyPredicates(); EdmProperty kpProperty = EasyMock.createMock(EdmProperty.class); NavigationSegment navigationSegment = new NavigationSegment() { @Override public EdmNavigationProperty getNavigationProperty() { return navigationProperty; } @Override public List<KeyPredicate> getKeyPredicates() { return keyPredicates; } @Override public EdmEntitySet getEntitySet() { // TODO Auto-generated method stub return null; } }; NavigationSegment navigationSegment1 = new NavigationSegment() { @Override public EdmNavigationProperty getNavigationProperty() { return navigationProperty1; } @Override public List<KeyPredicate> getKeyPredicates() { return keyPredicates; } @Override public EdmEntitySet getEntitySet() { // TODO Auto-generated method stub return null; } }; navigationSegments.add(navigationSegment); navigationSegments.add(navigationSegment1); EasyMock.expect(entitySetUriInfo.getNavigationSegments()).andStubReturn(navigationSegments); EasyMock.expect(entitySetUriInfo.getOrderBy()).andStubReturn(null); EasyMock.expect(entitySetUriInfo.getTop()).andStubReturn(null); EasyMock.expect(entitySetUriInfo.getSkip()).andStubReturn(null); EasyMock.expect(entitySetUriInfo.getSelect()).andStubReturn(null); EasyMock.expect(entitySetUriInfo.getFilter()).andStubReturn(null); EasyMock.expect(entitySetUriInfo.getKeyPredicates()).andStubReturn(keyPredicates); EasyMock.expect(entitySetUriInfo.getTargetEntitySet()).andStubReturn(edmEntitySet); EdmEntitySet startEdmEntitySet = EasyMock.createMock(EdmEntitySet.class); EdmEntityType startEdmEntityType = EasyMock.createMock(EdmEntityType.class); EasyMock.expect(startEdmEntityType.getMapping()).andStubReturn(null); EasyMock.expect(startEdmEntityType.getName()).andStubReturn("SOHeader"); EasyMock.expect(startEdmEntitySet.getEntityType()).andStubReturn(startEdmEntityType); EasyMock.expect(entitySetUriInfo.getStartEntitySet()).andStubReturn(startEdmEntitySet); EasyMock.replay(startEdmEntityType, startEdmEntitySet); EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType); EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null); EasyMock.expect(edmEntityType.getName()).andStubReturn("SOHeader"); EasyMock.replay(edmEntityType, edmEntitySet, entitySetUriInfo); }
Example 16
Source File: GroupsRestClientTest.java From gerrit-rest-java-client with Apache License 2.0 | 4 votes |
public GerritRestClient setupGerritRestClient() throws Exception { gerritRestClient = EasyMock.createMock(GerritRestClient.class); EasyMock.expect(gerritRestClient.getRequest(expectedUrl)).andReturn(mockJsonElement).once(); EasyMock.replay(gerritRestClient); return gerritRestClient; }
Example 17
Source File: ConfigureDataTagTest.java From c2mon with GNU Lesser General Public License v3.0 | 4 votes |
@Test public void createMultipleDataTagWithAllFields() { Properties expectedProps1 = new Properties(); Properties expectedProps2 = new Properties(); Properties expectedProps3 = new Properties(); Properties expectedProps4 = new Properties(); Properties expectedProps5 = new Properties(); DataTag tag1 = buildCreateAllFieldsDataTag(101L, expectedProps1); DataTag tag2 = buildCreateAllFieldsDataTag(102L, expectedProps2); DataTag tag3 = buildCreateAllFieldsDataTag(103L, expectedProps3); DataTag tag4 = buildCreateAllFieldsDataTag(104L, expectedProps4); DataTag tag5 = buildCreateAllFieldsDataTag(105L, expectedProps5); List<DataTag> dataTagList = Arrays.asList(tag1, tag2, tag3, tag4, tag5); Configuration config = new Configuration(1L); config.setEntities(dataTagList); // setUp Mocks: EasyMock.expect(tagFacadeGateway.isInTagCache(101L)).andReturn(false); EasyMock.expect(equipmentCache.hasKey(10L)).andReturn(true); EasyMock.expect(dataTagCache.get("DataTag101")).andReturn(null); EasyMock.expect(tagFacadeGateway.isInTagCache(102L)).andReturn(false); EasyMock.expect(equipmentCache.hasKey(10L)).andReturn(true); EasyMock.expect(dataTagCache.get("DataTag102")).andReturn(null); EasyMock.expect(tagFacadeGateway.isInTagCache(103L)).andReturn(false); EasyMock.expect(equipmentCache.hasKey(10L)).andReturn(true); EasyMock.expect(dataTagCache.get("DataTag103")).andReturn(null); EasyMock.expect(tagFacadeGateway.isInTagCache(104L)).andReturn(false); EasyMock.expect(equipmentCache.hasKey(10L)).andReturn(true); EasyMock.expect(dataTagCache.get("DataTag104")).andReturn(null); EasyMock.expect(tagFacadeGateway.isInTagCache(105L)).andReturn(false); EasyMock.expect(equipmentCache.hasKey(10L)).andReturn(true); EasyMock.expect(dataTagCache.get("DataTag105")).andReturn(null); EasyMock.replay(equipmentCache, sequenceDAO, tagFacadeGateway, dataTagCache); // run the parsing List<ConfigurationElement> elements = parser.parse(config); // Assert stuff assertTrue(elements.size() == 5); assertEquals(elements.get(0).getElementProperties(), expectedProps1); assertTrue(elements.get(0).getEntityId().equals(101L)); assertTrue(elements.get(0).getEntity().equals(ConfigConstants.Entity.DATATAG)); assertTrue(elements.get(0).getAction().equals(ConfigConstants.Action.CREATE)); assertEquals(elements.get(1).getElementProperties(), expectedProps2); assertTrue(elements.get(1).getEntityId().equals(102L)); assertTrue(elements.get(1).getEntity().equals(ConfigConstants.Entity.DATATAG)); assertTrue(elements.get(1).getAction().equals(ConfigConstants.Action.CREATE)); assertEquals(elements.get(2).getElementProperties(), expectedProps3); assertTrue(elements.get(2).getEntityId().equals(103L)); assertTrue(elements.get(2).getEntity().equals(ConfigConstants.Entity.DATATAG)); assertTrue(elements.get(2).getAction().equals(ConfigConstants.Action.CREATE)); assertEquals(elements.get(3).getElementProperties(), expectedProps4); assertTrue(elements.get(3).getEntityId().equals(104L)); assertTrue(elements.get(3).getEntity().equals(ConfigConstants.Entity.DATATAG)); assertTrue(elements.get(3).getAction().equals(ConfigConstants.Action.CREATE)); assertEquals(elements.get(4).getElementProperties(), expectedProps5); assertTrue(elements.get(4).getEntityId().equals(105L)); assertTrue(elements.get(4).getEntity().equals(ConfigConstants.Entity.DATATAG)); assertTrue(elements.get(4).getAction().equals(ConfigConstants.Action.CREATE)); EasyMock.verify(equipmentCache, sequenceDAO, tagFacadeGateway); }
Example 18
Source File: MockModule.java From arcusplatform with Apache License 2.0 | 4 votes |
public void replay() { EasyMock.replay(services.values().toArray()); }
Example 19
Source File: AbstractClusterInvokerTest.java From dubbox with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "unchecked" }) @Before public void setUp() throws Exception { invocation.setMethodName("sayHello"); invoker1 = EasyMock.createMock(Invoker.class); invoker2 = EasyMock.createMock(Invoker.class); invoker3 = EasyMock.createMock(Invoker.class); invoker4 = EasyMock.createMock(Invoker.class); invoker5 = EasyMock.createMock(Invoker.class); mockedInvoker1 = EasyMock.createMock(Invoker.class); URL turl = URL.valueOf("test://test:11/test"); EasyMock.expect(invoker1.isAvailable()).andReturn(false).anyTimes(); EasyMock.expect(invoker1.getInterface()).andReturn(IHelloService.class).anyTimes(); EasyMock.expect(invoker1.getUrl()).andReturn(turl.addParameter("name", "invoker1")).anyTimes(); EasyMock.expect(invoker2.isAvailable()).andReturn(true).anyTimes(); EasyMock.expect(invoker2.getInterface()).andReturn(IHelloService.class).anyTimes(); EasyMock.expect(invoker2.getUrl()).andReturn(turl.addParameter("name", "invoker2")).anyTimes(); EasyMock.expect(invoker3.isAvailable()).andReturn(false).anyTimes(); EasyMock.expect(invoker3.getInterface()).andReturn(IHelloService.class).anyTimes(); EasyMock.expect(invoker3.getUrl()).andReturn(turl.addParameter("name", "invoker3")).anyTimes(); EasyMock.expect(invoker4.isAvailable()).andReturn(true).anyTimes(); EasyMock.expect(invoker4.getInterface()).andReturn(IHelloService.class).anyTimes(); EasyMock.expect(invoker4.getUrl()).andReturn(turl.addParameter("name", "invoker4")).anyTimes(); EasyMock.expect(invoker5.isAvailable()).andReturn(false).anyTimes(); EasyMock.expect(invoker5.getInterface()).andReturn(IHelloService.class).anyTimes(); EasyMock.expect(invoker5.getUrl()).andReturn(turl.addParameter("name", "invoker5")).anyTimes(); EasyMock.expect(mockedInvoker1.isAvailable()).andReturn(false).anyTimes(); EasyMock.expect(mockedInvoker1.getInterface()).andReturn(IHelloService.class).anyTimes(); EasyMock.expect(mockedInvoker1.getUrl()).andReturn(turl.setProtocol("mock")).anyTimes(); EasyMock.replay(invoker1,invoker2,invoker3,invoker4,invoker5,mockedInvoker1); invokers.add(invoker1); dic = new StaticDirectory<IHelloService>(url, invokers, null); cluster = new AbstractClusterInvoker(dic) { @Override protected Result doInvoke(Invocation invocation, List invokers, LoadBalance loadbalance) throws RpcException { return null; } }; cluster_nocheck = new AbstractClusterInvoker(dic,url.addParameterIfAbsent(Constants.CLUSTER_AVAILABLE_CHECK_KEY, Boolean.FALSE.toString())) { @Override protected Result doInvoke(Invocation invocation, List invokers, LoadBalance loadbalance) throws RpcException { return null; } }; }
Example 20
Source File: DataTransferManagerTest.java From saros with GNU General Public License v2.0 | 3 votes |
@Test public void testEstablishConnectionWithMainAndFallbackTransportAndUsingFallback() throws Exception { IStreamService mainTransport = EasyMock.createMock(IStreamService.class); IStreamService fallbackTransport = new Transport(StreamMode.IBB); EasyMock.expect(mainTransport.connect(EasyMock.isA(String.class), EasyMock.isA(JID.class))) .andThrow(new IOException()) .anyTimes(); mainTransport.initialize( EasyMock.isA(Connection.class), EasyMock.isA(IByteStreamConnectionListener.class)); EasyMock.expectLastCall().once(); EasyMock.replay(mainTransport); IConnectionManager dtm = new DataTransferManager(connectionServiceStub, mainTransport, fallbackTransport); connectionListener.getValue().connectionStateChanged(connectionMock, ConnectionState.CONNECTED); dtm.connect(new JID("[email protected]")); EasyMock.verify(mainTransport); assertEquals( "Wrong transport fallback", StreamMode.IBB, dtm.getTransferMode(new JID("[email protected]"))); }