Java Code Examples for org.powermock.api.easymock.PowerMock#mockStatic()
The following examples show how to use
org.powermock.api.easymock.PowerMock#mockStatic() .
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: DiscoveryEnabledLoadBalancerSupportsUseIpAddrTest.java From ribbon with Apache License 2.0 | 6 votes |
@Before public void setupMock(){ List<InstanceInfo> servers = LoadBalancerTestUtils.getDummyInstanceInfo("dummy", HOST1, IP1, 8080); List<InstanceInfo> servers2 = LoadBalancerTestUtils.getDummyInstanceInfo("dummy", HOST2, IP2, 8080); servers.addAll(servers2); PowerMock.mockStatic(DiscoveryManager.class); PowerMock.mockStatic(DiscoveryClient.class); DiscoveryClient mockedDiscoveryClient = LoadBalancerTestUtils.mockDiscoveryClient(); DiscoveryManager mockedDiscoveryManager = createMock(DiscoveryManager.class); expect(DiscoveryManager.getInstance()).andReturn(mockedDiscoveryManager).anyTimes(); expect(mockedDiscoveryManager.getDiscoveryClient()).andReturn(mockedDiscoveryClient).anyTimes(); expect(mockedDiscoveryClient.getInstancesByVipAddress("dummy", false, "region")).andReturn(servers).anyTimes(); replay(DiscoveryManager.class); replay(DiscoveryClient.class); replay(mockedDiscoveryManager); replay(mockedDiscoveryClient); }
Example 2
Source File: DynamoDBJSONRootWorkerTest.java From aws-dynamodb-mars-json-demo with Apache License 2.0 | 6 votes |
@Test public void testGetMissionToManifestMap() { final URL url = PowerMock.createMock(URL.class); PowerMock.mockStatic(JSONUtils.class); PowerMock.mockStatic(NetworkUtils.class); String manifest = null; try { manifest = WorkerTestUtils.readFile(ROOT_JSON_FILE); } catch (final IOException e1) { fail("Could not read file: " + ROOT_JSON_FILE); } try { NetworkUtils.getDataFromURL(url, null, ImageIngester.DEFAULT_CONNECT_TIMEOUT); PowerMock.expectLastCall().andReturn(manifest.getBytes()); PowerMock.replayAll(); final Map<String, String> missionMap = DynamoDBJSONRootWorker.getMissionToManifestMap(url, ImageIngester.DEFAULT_CONNECT_TIMEOUT); assertEquals(EXPECTED_MAP, missionMap); } catch (final IOException e) { fail(e.getMessage()); } }
Example 3
Source File: DynamoDBMissionWorkerTest.java From aws-dynamodb-mars-json-demo with Apache License 2.0 | 6 votes |
@Test public void testGetSolJSON() { final URL url = PowerMock.createMock(URL.class); PowerMock.mockStatic(JSONUtils.class); PowerMock.mockStatic(NetworkUtils.class); String manifest = null; try { manifest = WorkerTestUtils.readFile(IMAGE_RESOURCE_FILE); } catch (final IOException e1) { fail("Could not read file: " + IMAGE_RESOURCE_FILE); } try { NetworkUtils.getDataFromURL(url, null, ImageIngester.DEFAULT_CONNECT_TIMEOUT); PowerMock.expectLastCall().andReturn(manifest.getBytes()); PowerMock.replayAll(); final Map<Integer, String> actual = DynamoDBMissionWorker.getSolJSON(url, ImageIngester.DEFAULT_CONNECT_TIMEOUT); assertEquals(EXPECTED_MAP, actual); } catch (final IOException e) { fail(e.getMessage()); } }
Example 4
Source File: OdeAuthFilterTest.java From appinventor-extensions with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { helper.setUp(); localUserMock = PowerMock.createMock(LocalUser.class); PowerMock.mockStatic(LocalUser.class); expect(LocalUser.getInstance()).andReturn(localUserMock).anyTimes(); localUserMock.set(new User("1", "NonSuch", "NoName", null, 0, false, false, 0, null)); expectLastCall().times(1); expect(localUserMock.getUserEmail()).andReturn("NonSuch").times(1); localUserInfo = PowerMock.createMock(OdeAuthFilter.UserInfo.class); expect(localUserInfo.buildCookie(false)).andReturn("NoCookie").anyTimes(); expect(localUserInfo.buildCookie(true)).andReturn("NoCookie").anyTimes(); mockFilterChain = PowerMock.createNiceMock(FilterChain.class); mockServletRequest = PowerMock.createNiceMock(HttpServletRequest.class); mockServletResponse = PowerMock.createNiceMock(HttpServletResponse.class); }
Example 5
Source File: DownloadServletTest.java From appinventor-extensions with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { PowerMock.mockStatic(LocalUser.class); localUserMock = PowerMock.createNiceMock(LocalUser.class); expect(LocalUser.getInstance()).andReturn(localUserMock).anyTimes(); expect(localUserMock.getUserId()).andReturn(USER_ID).anyTimes(); exporterMock = PowerMock.createNiceMock(FileExporterImpl.class); PowerMock.expectNew(FileExporterImpl.class).andReturn(exporterMock).anyTimes(); storageIoMock = PowerMock.createNiceMock(StorageIo.class); StorageIoInstanceHolder.setInstance(storageIoMock); dummyZip = new ProjectSourceZip(DUMMY_ZIP_FILENAME, new byte[] {}, 2); dummyZipWithTitle = new ProjectSourceZip(DUMMY_ZIP_FILENAME_WITH_TITLE, new byte[] {}, 2); dummyApk = new RawFile(DUMMY_APK_FILENAME, new byte[] {}); dummyFile = new RawFile(DUMMY_FILENAME, new byte[] {}); }
Example 6
Source File: LBBuilderTest.java From ribbon with Apache License 2.0 | 6 votes |
@Before public void setupMock(){ List<InstanceInfo> instances = LoadBalancerTestUtils.getDummyInstanceInfo("dummy", expected.getHost(), "127.0.0.1", expected.getPort()); PowerMock.mockStatic(DiscoveryManager.class); PowerMock.mockStatic(DiscoveryClient.class); DiscoveryClient mockedDiscoveryClient = LoadBalancerTestUtils.mockDiscoveryClient(); DiscoveryManager mockedDiscoveryManager = createMock(DiscoveryManager.class); expect(DiscoveryManager.getInstance()).andReturn(mockedDiscoveryManager).anyTimes(); expect(mockedDiscoveryManager.getDiscoveryClient()).andReturn(mockedDiscoveryClient).anyTimes(); expect(mockedDiscoveryClient.getInstancesByVipAddress("dummy:7001", false, null)).andReturn(instances).anyTimes(); replay(DiscoveryManager.class); replay(DiscoveryClient.class); replay(mockedDiscoveryManager); replay(mockedDiscoveryClient); }
Example 7
Source File: TableCellTest.java From fastods with GNU General Public License v3.0 | 6 votes |
@Before public void setUp() { this.converter = new ObjectToCellValueConverter("USD"); this.locale = Locale.US; this.stc = PowerMock.createMock(StylesContainerImpl.class); this.table = PowerMock.createMock(Table.class); final WriteUtil writeUtil = WriteUtil.create(); this.xmlUtil = XMLUtil.create(); this.tcc = TableColdCell.create(this.xmlUtil); this.ds = DataStylesBuilder.create(Locale.US).build(); this.row = new TableRowImpl(writeUtil, this.xmlUtil, this.stc, this.ds, false, this.table, ROW_INDEX, 100); this.cell = new TableCellImpl(writeUtil, this.xmlUtil, this.stc, this.ds, false, this.row, COLUMN_INDEX); this.tcs = TableCellStyle.builder("name").build(); PowerMock.mockStatic(TableColdCell.class); }
Example 8
Source File: EurekaDynamicServerListLoadBalancerTest.java From ribbon with Apache License 2.0 | 6 votes |
@Before public void setUp() { PowerMock.mockStatic(DiscoveryClient.class); EasyMock .expect(DiscoveryClient.getZone(EasyMock.isA(InstanceInfo.class))) .andReturn("zone") .anyTimes(); eurekaClientMock = setUpEurekaClientMock(servers); eurekaClientProvider = new Provider<EurekaClient>() { @Override public EurekaClient get() { return eurekaClientMock; } }; config = DefaultClientConfigImpl.getClientConfigWithDefaultValues(); config.set(CommonClientConfigKey.DeploymentContextBasedVipAddresses, vipAddress); config.set(CommonClientConfigKey.ServerListUpdaterClassName, EurekaNotificationServerListUpdater.class.getName()); }
Example 9
Source File: StaticWithJdomTest.java From powermock-examples-maven with Apache License 2.0 | 6 votes |
@org.junit.Test public void test() throws Exception { PowerMock.mockStatic(StaticClass.class); EasyMock.expect(StaticClass.staticMethod()).andReturn(2).anyTimes(); PowerMock.replay(StaticClass.class); int i = StaticClass.staticMethod(); String xml = "<xml>" + i + "</xml>"; SAXBuilder b = new SAXBuilder(); Document d = b.build(new StringReader(xml)); Assert.assertTrue(d.getRootElement().getText().equals("2")); PowerMock.verify(StaticClass.class); }
Example 10
Source File: StartJobTaskTest.java From dropwizard-sundial with Apache License 2.0 | 6 votes |
@Test public void shouldStartNamedTask() throws Exception { StartJobTask task = new StartJobTask(); Map<String, List<String>> map = new HashMap<String, List<String>>(); map.put("JOB_NAME", Arrays.asList("test")); OutputStream stream = new ByteArrayOutputStream(); PrintWriter out = new PrintWriter(stream); PowerMock.mockStatic(SundialJobScheduler.class); SundialJobScheduler.startJob("test", Collections.singletonMap("JOB_NAME", (Object) "test")); EasyMock.expectLastCall(); PowerMock.replay(SundialJobScheduler.class); task.execute(map, out); PowerMock.verify(SundialJobScheduler.class); }
Example 11
Source File: StartJobTaskTest.java From dropwizard-sundial with Apache License 2.0 | 6 votes |
@Test public void shouldPassParameters() throws Exception { StartJobTask task = new StartJobTask(); Map<String, List<String>> map = new HashMap<String, List<String>>(); map.put("JOB_NAME", Arrays.asList("test")); map.put("Param1", Arrays.asList("1")); map.put("Param2", Arrays.asList("2")); OutputStream stream = new ByteArrayOutputStream(); PrintWriter out = new PrintWriter(stream); PowerMock.mockStatic(SundialJobScheduler.class); SundialJobScheduler.startJob( "test", ImmutableMap.of( "JOB_NAME", (Object) "test", "Param1", (Object) "1", "Param2", (Object) "2")); EasyMock.expectLastCall(); PowerMock.replay(SundialJobScheduler.class); task.execute(map, out); PowerMock.verify(SundialJobScheduler.class); }
Example 12
Source File: JSONParserTest.java From aws-dynamodb-mars-json-demo with Apache License 2.0 | 6 votes |
@Test public void testgetJSONFromURL() { PowerMock.mockStatic(NetworkUtils.class); try { final URL url = PowerMock.createMock(URL.class); NetworkUtils.getDataFromURL(url, null, ImageIngester.DEFAULT_CONNECT_TIMEOUT); PowerMock.expectLastCall().andReturn(ROOT_JSON.getBytes()); replayAll(); final ObjectMapper mapper = new ObjectMapper(); final JsonNode json = mapper.readTree(ROOT_JSON); final JsonNode result = JSONParser.getJSONFromURL(url, ImageIngester.DEFAULT_CONNECT_TIMEOUT); assertEquals(json, result); } catch (final IOException e) { fail(); } }
Example 13
Source File: MarsDynamoDBManagerTest.java From aws-dynamodb-mars-json-demo with Apache License 2.0 | 6 votes |
@Test public void testCreateResourceTable() { final AmazonDynamoDB dynamoDB = PowerMock.createMock(AmazonDynamoDB.class); PowerMock.mockStatic(DynamoDBManager.class); final CreateTableRequest request = new CreateTableRequest(); request.setAttributeDefinitions(MarsDynamoDBManager.RESOURCE_TABLE_ATTRIBUTE_DEFINITIONS); request.setKeySchema(MarsDynamoDBManager.RESOURCE_TABLE_KEY_SCHEMA); request.setProvisionedThroughput(PROVISIONED_THROUGHPUT); request.setTableName(TABLE_NAME); DynamoDBManager.createTable(dynamoDB, request); PowerMock.expectLastCall().andReturn(null); PowerMock.replayAll(); MarsDynamoDBManager.createResourceTable(dynamoDB, TABLE_NAME, PROVISIONED_THROUGHPUT); PowerMock.verifyAll(); }
Example 14
Source File: CreatedQueryLogicCacheBeanTest.java From datawave with Apache License 2.0 | 5 votes |
@Before public void setupCacheBean() throws IllegalAccessException, SecurityException, NoSuchMethodException { qlCache = new CreatedQueryLogicCacheBean(); queryLogic = PowerMock.createMock(QueryLogic.class); conn = PowerMock.createMock(Connector.class); internalCache = new ConcurrentHashMap<>(); PowerMock.field(CreatedQueryLogicCacheBean.class, "cache").set(qlCache, internalCache); PowerMock.mockStatic(System.class, System.class.getMethod("currentTimeMillis")); }
Example 15
Source File: DynamoDBManagerTest.java From aws-dynamodb-mars-json-demo with Apache License 2.0 | 5 votes |
@Before public void setUp() throws InterruptedException { PowerMock.resetAll(); PowerMock.mockStatic(Thread.class); Thread.sleep(EasyMock.anyLong()); PowerMock.expectLastCall().andThrow(new InterruptedException()).anyTimes(); }
Example 16
Source File: MarsDynamoDBManagerTest.java From aws-dynamodb-mars-json-demo with Apache License 2.0 | 5 votes |
@Test public void testCreateImageTable() { final AmazonDynamoDB dynamoDB = PowerMock.createMock(AmazonDynamoDB.class); PowerMock.mockStatic(DynamoDBManager.class); final CreateTableRequest request = new CreateTableRequest(); request.setAttributeDefinitions(MarsDynamoDBManager.IMAGE_TABLE_ATTRIBUTE_DEFINITIONS); request.setKeySchema(MarsDynamoDBManager.IMAGE_TABLE_KEY_SCHEMA); final GlobalSecondaryIndex timeGSI = new GlobalSecondaryIndex(); timeGSI.setIndexName(MarsDynamoDBManager.IMAGE_TABLE_TIME_GSI_NAME); timeGSI.setKeySchema(Arrays.asList(MarsDynamoDBManager.IMAGE_TABLE_TIME_GSI_HASH_KSE, MarsDynamoDBManager.IMAGE_TABLE_TIME_GSI_RANGE_KSE)); timeGSI.setProjection(MarsDynamoDBManager.IMAGE_TABLE_TIME_GSI_PROJECTION); timeGSI.setProvisionedThroughput(PROVISIONED_THROUGHPUT); final GlobalSecondaryIndex voteGSI = new GlobalSecondaryIndex(); voteGSI.setIndexName(MarsDynamoDBManager.IMAGE_TABLE_VOTE_GSI_NAME); voteGSI.setKeySchema(Arrays.asList(MarsDynamoDBManager.IMAGE_TABLE_VOTE_GSI_HASH_KSE, MarsDynamoDBManager.IMAGE_TABLE_VOTE_GSI_RANGE_KSE)); voteGSI.setProjection(MarsDynamoDBManager.IMAGE_TABLE_VOTE_GSI_PROJECTION); voteGSI.setProvisionedThroughput(PROVISIONED_THROUGHPUT); request.setGlobalSecondaryIndexes(Arrays.asList(timeGSI, voteGSI)); request.setProvisionedThroughput(PROVISIONED_THROUGHPUT); request.setTableName(TABLE_NAME); DynamoDBManager.createTable(dynamoDB, request); PowerMock.expectLastCall().andReturn(null); PowerMock.replayAll(); MarsDynamoDBManager.createImageTable(dynamoDB, TABLE_NAME, PROVISIONED_THROUGHPUT, PROVISIONED_THROUGHPUT, PROVISIONED_THROUGHPUT); PowerMock.verifyAll(); }
Example 17
Source File: DocumentTransformerTest.java From datawave with Apache License 2.0 | 5 votes |
private void basicExpects(Document d, Key key, Map.Entry<Key,Value> entry) throws MarkingFunctions.Exception { // AbstractMap.SimpleEntry<Key, Document> documentEntry = new AbstractMap.SimpleEntry<>(key, mockDocument); d.put("field1", new Numeric("5", key, true)); AbstractMap.SimpleEntry<Key,Document> documentEntry = new AbstractMap.SimpleEntry<>(key, d); // Map<String,Attribute<?extends Comparable<?>>> dictionary = new HashMap<>(); // dictionary.put("field1", mockNumeric); SimpleField simpleField = new SimpleField(); SimpleEvent simpleEvent = new SimpleEvent(); PowerMock.mockStatic(DocumentSerialization.class); EasyMock.expect(DocumentSerialization.getDocumentDeserializer(mockQuery)).andReturn(mockDeserializer); EasyMock.expect(mockLogic.getTableName()).andReturn("table1"); EasyMock.expect(mockQuery.getQueryAuthorizations()).andReturn("A,B,C"); EasyMock.expect(mockQuery.findParameter("log.timing.details")).andReturn(new QueryImpl.Parameter("", "")); EasyMock.expect(mockDeserializer.apply(entry)).andReturn(documentEntry); // EasyMock.expect(mockDocument.getDictionary()).andReturn(Collections.EMPTY_MAP); // mockDocument.debugDocumentSize(key); EasyMock.expect(mockMarkingFunctions.translateFromColumnVisibility(key.getColumnVisibilityParsed())).andReturn(Collections.EMPTY_MAP); // EasyMock.expect(mockDocument.getDictionary()).andReturn(dictionary); // EasyMock.expect(mockNumeric.getData()).andReturn("5"); EasyMock.expect(mockResponseFactory.getField()).andReturn(simpleField); EasyMock.expect(mockResponseFactory.getEvent()).andReturn(simpleEvent); // EasyMock.expect(mockDocument.sizeInBytes()).andReturn(1l); }
Example 18
Source File: ProcessLauncherImplTest.java From chrome-devtools-java-client with Apache License 2.0 | 4 votes |
@Test public void testIsExecutable() { PowerMock.mockStatic(Paths.class); PowerMock.mockStatic(Files.class); final Path path = mock(Path.class); Paths.get("test-file"); PowerMock.expectLastCall().andReturn(path); Files.isRegularFile(path); PowerMock.expectLastCall().andReturn(false); PowerMock.replayAll(); assertFalse(processLauncher.isExecutable("test-file")); PowerMock.verifyAll(); PowerMock.resetAll(); // -- Paths.get("test-file"); PowerMock.expectLastCall().andReturn(path); Files.isRegularFile(path); PowerMock.expectLastCall().andReturn(true); Files.isReadable(path); PowerMock.expectLastCall().andReturn(false); PowerMock.replayAll(); assertFalse(processLauncher.isExecutable("test-file")); PowerMock.verifyAll(); PowerMock.resetAll(); // -- Paths.get("test-file"); PowerMock.expectLastCall().andReturn(path); Files.isRegularFile(path); PowerMock.expectLastCall().andReturn(true); Files.isReadable(path); PowerMock.expectLastCall().andReturn(true); Files.isExecutable(path); PowerMock.expectLastCall().andReturn(false); PowerMock.replayAll(); assertFalse(processLauncher.isExecutable("test-file")); PowerMock.verifyAll(); PowerMock.resetAll(); // -- Paths.get("test-file"); PowerMock.expectLastCall().andReturn(path); Files.isRegularFile(path); PowerMock.expectLastCall().andReturn(true); Files.isReadable(path); PowerMock.expectLastCall().andReturn(true); Files.isExecutable(path); PowerMock.expectLastCall().andReturn(true); PowerMock.replayAll(); assertTrue(processLauncher.isExecutable("test-file")); PowerMock.verifyAll(); }
Example 19
Source File: ModelKeyParserTest.java From datawave with Apache License 2.0 | 4 votes |
@Before public void setup() throws Exception { FORWARD_FIELD_MAPPING = new FieldMapping(); FORWARD_FIELD_MAPPING.setColumnVisibility(COLVIZ); FORWARD_FIELD_MAPPING.setDatatype(DATATYPE); FORWARD_FIELD_MAPPING.setDirection(FORWARD); FORWARD_FIELD_MAPPING.setFieldName(FIELD_NAME); FORWARD_FIELD_MAPPING.setModelFieldName(MODEL_FIELD_NAME); REVERSE_FIELD_MAPPING = new FieldMapping(); REVERSE_FIELD_MAPPING.setColumnVisibility(COLVIZ); REVERSE_FIELD_MAPPING.setDatatype(DATATYPE); REVERSE_FIELD_MAPPING.setDirection(REVERSE); REVERSE_FIELD_MAPPING.setFieldName(FIELD_NAME); REVERSE_FIELD_MAPPING.setModelFieldName(MODEL_FIELD_NAME); NULL_CV_MAPPING = new FieldMapping(); NULL_CV_MAPPING.setColumnVisibility(""); NULL_CV_MAPPING.setDatatype(DATATYPE); NULL_CV_MAPPING.setDirection(REVERSE); NULL_CV_MAPPING.setFieldName(FIELD_NAME); NULL_CV_MAPPING.setModelFieldName(MODEL_FIELD_NAME); FORWARD_KEY = new Key(MODEL_FIELD_NAME, MODEL_NAME + ModelKeyParser.NULL_BYTE + DATATYPE, FIELD_NAME + ModelKeyParser.NULL_BYTE + FORWARD.getValue(), COLVIZ, TIMESTAMP); REVERSE_KEY = new Key(FIELD_NAME, MODEL_NAME + ModelKeyParser.NULL_BYTE + DATATYPE, MODEL_FIELD_NAME + ModelKeyParser.NULL_BYTE + REVERSE.getValue(), COLVIZ, TIMESTAMP); NULL_CV_KEY = new Key(FIELD_NAME, MODEL_NAME + ModelKeyParser.NULL_BYTE + DATATYPE, MODEL_FIELD_NAME + ModelKeyParser.NULL_BYTE + REVERSE.getValue(), "", TIMESTAMP); FORWARD_MUTATION = new Mutation(MODEL_FIELD_NAME); FORWARD_MUTATION.put(MODEL_NAME + ModelKeyParser.NULL_BYTE + DATATYPE, FIELD_NAME + ModelKeyParser.NULL_BYTE + FORWARD.getValue(), new ColumnVisibility(COLVIZ), TIMESTAMP, ModelKeyParser.NULL_VALUE); FORWARD_DELETE_MUTATION = new Mutation(MODEL_FIELD_NAME); FORWARD_DELETE_MUTATION.putDelete(MODEL_NAME + ModelKeyParser.NULL_BYTE + DATATYPE, FIELD_NAME + ModelKeyParser.NULL_BYTE + FORWARD.getValue(), new ColumnVisibility(COLVIZ), TIMESTAMP); FORWARD_DELETE_MUTATION.putDelete(MODEL_NAME + ModelKeyParser.NULL_BYTE + DATATYPE, FIELD_NAME + ModelKeyParser.NULL_BYTE + "index_only" + ModelKeyParser.NULL_BYTE + FORWARD.getValue(), new ColumnVisibility(COLVIZ), TIMESTAMP); REVERSE_MUTATION = new Mutation(FIELD_NAME); REVERSE_MUTATION.put(MODEL_NAME + ModelKeyParser.NULL_BYTE + DATATYPE, MODEL_FIELD_NAME + ModelKeyParser.NULL_BYTE + REVERSE.getValue(), new ColumnVisibility(COLVIZ), TIMESTAMP, ModelKeyParser.NULL_VALUE); REVERSE_DELETE_MUTATION = new Mutation(FIELD_NAME); REVERSE_DELETE_MUTATION.putDelete(MODEL_NAME + ModelKeyParser.NULL_BYTE + DATATYPE, MODEL_FIELD_NAME + ModelKeyParser.NULL_BYTE + REVERSE.getValue(), new ColumnVisibility(COLVIZ), TIMESTAMP); PowerMock.mockStatic(System.class, System.class.getMethod("currentTimeMillis")); }
Example 20
Source File: DiscoveryEnabledLoadBalancerSupportsPortOverrideTest.java From ribbon with Apache License 2.0 | 4 votes |
@Before public void setupMock(){ List<InstanceInfo> dummyII = LoadBalancerTestUtils.getDummyInstanceInfo("dummy", "http://www.host.com", "1.1.1.1", 8001); List<InstanceInfo> secureDummyII = LoadBalancerTestUtils.getDummyInstanceInfo("secureDummy", "http://www.host.com", "1.1.1.1", 8002); PowerMock.mockStatic(DiscoveryManager.class); PowerMock.mockStatic(DiscoveryClient.class); DiscoveryClient mockedDiscoveryClient = LoadBalancerTestUtils.mockDiscoveryClient(); DiscoveryManager mockedDiscoveryManager = createMock(DiscoveryManager.class); expect(DiscoveryManager.getInstance()).andReturn(mockedDiscoveryManager).anyTimes(); expect(mockedDiscoveryManager.getDiscoveryClient()).andReturn(mockedDiscoveryClient).anyTimes(); expect(mockedDiscoveryClient.getInstancesByVipAddress("dummy", false, "region")).andReturn(dummyII).anyTimes(); expect(mockedDiscoveryClient.getInstancesByVipAddress("secureDummy", true, "region")).andReturn(secureDummyII).anyTimes(); replay(DiscoveryManager.class); replay(DiscoveryClient.class); replay(mockedDiscoveryManager); replay(mockedDiscoveryClient); }