Java Code Examples for org.powermock.reflect.Whitebox#invokeMethod()

The following examples show how to use org.powermock.reflect.Whitebox#invokeMethod() . 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: OvsdbConnectionManagerTest.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testPutandGetInstanceIdentifier() throws Exception {
    ConnectionInfo key = mock(ConnectionInfo.class);
    ConnectionInfo connectionInfo = mock(ConnectionInfo.class);
    PowerMockito.mockStatic(SouthboundMapper.class);
    when(SouthboundMapper.suppressLocalIpPort(key)).thenReturn(connectionInfo);

    instanceIdentifiers = new ConcurrentHashMap<>();
    field(OvsdbConnectionManager.class, "instanceIdentifiers").set(ovsdbConnManager, instanceIdentifiers);

    //Test putInstanceIdentifier()
    Whitebox.invokeMethod(ovsdbConnManager, "putInstanceIdentifier", key, iid);
    Map<ConnectionInfo, OvsdbConnectionInstance> testIids = Whitebox.getInternalState(ovsdbConnManager,
            "instanceIdentifiers");
    assertEquals("Error, size of the hashmap is incorrect", 1, testIids.size());

    //Test getInstanceIdentifier()
    assertEquals("Error returning correct InstanceIdentifier object", iid,
            ovsdbConnManager.getInstanceIdentifier(key));

    //Test removeInstanceIdentifier()
    Whitebox.invokeMethod(ovsdbConnManager, "removeInstanceIdentifier", key);
    Map<ConnectionInfo, OvsdbConnectionInstance> testRemoveIids = Whitebox.getInternalState(ovsdbConnManager,
            "instanceIdentifiers");
    assertEquals("Error, size of the hashmap is incorrect", 0, testRemoveIids.size());
}
 
Example 2
Source File: JAXBUtilTest.java    From aws-mock with MIT License 6 votes vote down vote up
@Test
public void Test_mashallNotElasticFox() throws Exception {

    PowerMockito.spy(PropertiesUtils.class);
    Mockito.when(PropertiesUtils.getProperty(Constants.PROP_NAME_ELASTICFOX_COMPATIBLE))
            .thenReturn("false");

    String imageID = "ami-1";
    String instanceType = InstanceType.C1_MEDIUM.getName();
    int minCount = 1;
    int maxCount = 1;

    MockEC2QueryHandler handler = MockEC2QueryHandler.getInstance();
    RunInstancesResponseType runInstancesResponseType = Whitebox.invokeMethod(handler,
            "runInstances", imageID,
            instanceType, minCount, maxCount);

    String xml = JAXBUtil.marshall(runInstancesResponseType, "RunInstancesResponse", null);

    Assert.assertTrue(xml != null && !xml.isEmpty());
    Assert.assertTrue(xml.contains("<imageId>ami-1</imageId>"));
    Assert.assertTrue(xml.contains("<instanceType>c1.medium</instanceType>"));
}
 
Example 3
Source File: WSManRemoteShellServiceTest.java    From cs-actions with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateShellThrowsFaultException() throws Exception {
    mockExecuteRequest();
    PowerMockito.mockStatic(WSManUtils.class);
    Mockito.when(WSManUtils.isSpecificResponseAction(RESPONSE_BODY, CREATE_RESPONSE_ACTION)).thenReturn(false);
    Mockito.when(WSManUtils.isFaultResponse(RESPONSE_BODY)).thenReturn(true);
    Mockito.when(WSManUtils.getResponseFault(RESPONSE_BODY)).thenReturn(FAULT_MESSAGE);

    thrownException.expectMessage(FAULT_MESSAGE);
    Whitebox.invokeMethod(new WSManRemoteShellService(), CREATE_SHELL_METHOD, csHttpClientMock, httpClientInputsMock, wsManRequestInputs);

    verifyStatic();
    WSManUtils.isSpecificResponseAction(RESPONSE_BODY, CREATE_RESPONSE_ACTION);
    WSManUtils.isFaultResponse(RESPONSE_BODY);
    WSManUtils.getResponseFault(RESPONSE_BODY);
}
 
Example 4
Source File: IDataReceiveListener802Test.java    From xbee-java with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Test method for {@link com.digi.xbee.api.listeners.IDataReceiveListener#dataReceived(XBeeMessage)} and
 * {@link com.digi.xbee.api.DataReader#packetReceived(XBeePacket)}.
 * 
 * <p>Verify that, when subscribed to receive data and a packet that does not correspond to 
 * data, the callback of the listener is not executed.</p>
 * 
 * @throws Exception
 */
@Test
public void testDataReceiveSubscribedInvalid() throws Exception {
	// Subscribe to listen for data.
	dataReader.addDataReceiveListener(receiveDataListener);
	
	// Fire the private packetReceived method of the dataReader with an invalid packet.
	Whitebox.invokeMethod(dataReader, PACKET_RECEIVED_METHOD, invalidPacket);
	
	// Verify that the notifyDataReceived private method was not called.
	PowerMockito.verifyPrivate(dataReader, Mockito.never()).invoke(NOTIFY_DATA_RECEIVED_METHOD, 
			Mockito.any(XBeeMessage.class));
	
	// Verify that the callback of the listener was not executed
	Mockito.verify(receiveDataListener, Mockito.never()).dataReceived(Mockito.any(XBeeMessage.class));
	
	// All the parameters of our listener should be empty.
	assertNull(receiveDataListener.get16BitAddress());
	assertNull(receiveDataListener.get64BitAddress());
	assertNull(receiveDataListener.getData());
	assertFalse(receiveDataListener.isBroadcast());
}
 
Example 5
Source File: OvsdbPortUpdateCommandTest.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testBuildTerminationPoint1() throws Exception {
    Interface interfaceUpdate = mock(Interface.class);
    when(interfaceUpdate.getName()).thenReturn(INTERFACE_NAME);
    when(interfaceUpdate.getUuid()).thenReturn(mock(UUID.class));
    PowerMockito.whenNew(Uuid.class).withAnyArguments().thenReturn(mock(Uuid.class));
    OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = mock(
            OvsdbTerminationPointAugmentationBuilder.class);
    when(tpAugmentationBuilder.setName(anyString())).thenReturn(tpAugmentationBuilder);
    when(tpAugmentationBuilder.setInterfaceUuid(any(Uuid.class))).thenReturn(tpAugmentationBuilder);

    doNothing().when(ovsdbPortUpdateCommand).updateInterfaces(any(Interface.class),
        any(OvsdbTerminationPointAugmentationBuilder.class));

    Whitebox.invokeMethod(ovsdbPortUpdateCommand, "buildTerminationPoint", tpAugmentationBuilder, interfaceUpdate);
    verify(tpAugmentationBuilder).setName(anyString());
    verify(tpAugmentationBuilder).setInterfaceUuid(any(Uuid.class));
    verify(ovsdbPortUpdateCommand).updateInterfaces(any(Interface.class),
            any(OvsdbTerminationPointAugmentationBuilder.class));
}
 
Example 6
Source File: WSManRemoteShellServiceTest.java    From cs-actions with Apache License 2.0 5 votes vote down vote up
@Test
public void testExecuteRequestThrowsException() throws Exception {
    doNothing().when(httpClientInputsMock).setBody(RESPONSE_BODY);
    doReturn(resultMock).when(csHttpClientMock).execute(httpClientInputsMock);
    doReturn(UNAUTHORIZED_STATUS_CODE).when(resultMock).get(STATUS_CODE);

    thrownException.expectMessage(UNAUTHORIZED_EXCEPTION_MESSAGE);
    Whitebox.invokeMethod(new WSManRemoteShellService(), EXECUTE_REQUEST_METHOD, csHttpClientMock, httpClientInputsMock, RESPONSE_BODY);

    verify(httpClientInputsMock).setBody(RESPONSE_BODY);
    verify(csHttpClientMock).execute(httpClientInputsMock);
    verify(resultMock).get(STATUS_CODE);
}
 
Example 7
Source File: IModemStatusReceiveListenerTest.java    From xbee-java with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Test method for {@link com.digi.xbee.api.listeners.IModemStatusReceiveListener#modemStatusEventReceived(ModemStatusEvent)} 
 * and {@link com.digi.xbee.api.DataReader#packetReceived(XBeePacket)}.
 * 
 * <p>Verify that if the listener is not subscribed to receive Modem Status events, the callback is not 
 * executed although a Modem Status packet is received.</p>
 * 
 * @throws Exception
 */
@Test
public void testModemStatusReceiveNotSubscribed() throws Exception {
	// Fire the private packetReceived method of the dataReader with a ModemStatusPacket.
	Whitebox.invokeMethod(dataReader, PACKET_RECEIVED_METHOD, modemStatusPacket);
	
	// Verify that the notifyModemStatusReceived private method was called with the correct Modem Status event.
	PowerMockito.verifyPrivate(dataReader, Mockito.times(1)).invoke(NOTIFY_MODEM_STATUS_RECEIVED_METHOD, MODEM_STATUS_EVENT);
	
	// As the receiveModemStatusListener was not subscribed in the modemStatusListeners of the dataReader object, the 
	// Modem Status of the receiveModemStatusListener should be null.
	assertNull(receiveModemStatusListener.getModemStatus());
}
 
Example 8
Source File: OverlayManagerTest.java    From android with Apache License 2.0 5 votes vote down vote up
@Test public void setMyLocationEnabled_shouldNotChangeTilt() throws Exception {
  doCallRealMethod().when(mapController).setPositionEased(any(LngLat.class), anyInt());
  doCallRealMethod().when(mapController).setTilt(anyFloat());
  when(mapController.getTilt()).thenCallRealMethod();

  mapController.setTilt(8);
  overlayManager.setMyLocationEnabled(true);
  Location location = new Location("test");
  Whitebox.invokeMethod(overlayManager.locationListener, "onLocationChanged", location);
  assertThat(mapController.getTilt()).isEqualTo(8);
}
 
Example 9
Source File: MockCloudWatchQueryHandlerTest.java    From aws-mock with MIT License 5 votes vote down vote up
@Test
public void Test_getMetricStatisticsForStatusCheckFailed() throws Exception {
    MockCloudWatchQueryHandler handler = MockCloudWatchQueryHandler.getInstance();
    DateTime startTime = new DateTime().plusHours(-1);
    String[] statistics = { "Average", "SampleCount" };
    GetMetricStatisticsResponse getMetric = Whitebox.invokeMethod(handler,
            "getMetricStatistics", statistics,
            startTime, new DateTime(), 60 * 60, "StatusCheckFailed");
    Assert.assertTrue(getMetric != null);
    Assert.assertTrue(
            getMetric.getGetMetricStatisticsResult().getDatapoints().getMember().size() == 1);
}
 
Example 10
Source File: MockCloudWatchQueryHandlerTest.java    From aws-mock with MIT License 5 votes vote down vote up
@Test
public void Test_getXmlError() throws Exception {
    MockCloudWatchQueryHandler handler = MockCloudWatchQueryHandler.getInstance();
    String output = Whitebox.invokeMethod(handler, "getXmlError", "101",
            "Error had taken place!");

    // check that the template file is populated
    Assert.assertTrue(output != null && !output.isEmpty());
    Assert.assertTrue(output.contains("<Code>101</Code>"));
    Assert.assertTrue(output.contains("<Message>Error had taken place!</Message>"));

}
 
Example 11
Source File: MockEC2QueryHandlerTest.java    From aws-mock with MIT License 5 votes vote down vote up
@Test
public void Test_getXmlError() throws Exception {
    MockEC2QueryHandler handler = MockEC2QueryHandler.getInstance();
    String output = Whitebox.invokeMethod(handler, "getXmlError", "101",
            "Error had taken place!");

    // check that the template file is populated
    Assert.assertTrue(output != null && !output.isEmpty());
    Assert.assertTrue(output.contains("<Code>101</Code>"));
    Assert.assertTrue(output.contains("<Message>Error had taken place!</Message>"));

}
 
Example 12
Source File: WSManRemoteShellServiceTest.java    From cs-actions with Apache License 2.0 5 votes vote down vote up
@Test
public void testExecuteCommandThrowsUnexpectedResponseException() throws Exception {
    mockExecuteRequest();
    PowerMockito.mockStatic(WSManUtils.class);
    Mockito.when(WSManUtils.isSpecificResponseAction(RESPONSE_BODY, COMMAND_RESPONSE_ACTION)).thenReturn(false);
    Mockito.when(WSManUtils.isFaultResponse(RESPONSE_BODY)).thenReturn(false);

    thrownException.expectMessage(UNEXPECTED_SERVICE_RESPONSE);
    Whitebox.invokeMethod(new WSManRemoteShellService(), EXECUTE_COMMAND_METHOD, csHttpClientMock, httpClientInputsMock, SHELL_UUID, wsManRequestInputs, COMMAND);

    verifyStatic();
    WSManUtils.isSpecificResponseAction(RESPONSE_BODY, COMMAND_RESPONSE_ACTION);
    WSManUtils.isFaultResponse(RESPONSE_BODY);
}
 
Example 13
Source File: TestPublicContentServlet.java    From cms with Apache License 2.0 5 votes vote down vote up
private void handleRequestTypeText_etag(Integer templateSource)
{
    try
    {
    WPBPage pageMock = EasyMock.createMock(WPBPage.class);
    InternalModel modelMock = EasyMock.createMock(InternalModel.class);
    PageContentBuilder pageBuilderMock = EasyMock.createMock(PageContentBuilder.class);
    Whitebox.setInternalState(publicServlet, "pageContentBuilder", pageBuilderMock);
    
    responseMock.setCharacterEncoding("UTF-8");
    EasyMock.expect(pageMock.getIsTemplateSource()).andReturn(0);
    Long hash = 123L;
    
    EasyMock.expect(requestMock.getHeader("If-None-Match")).andReturn(hash.toString());
    EasyMock.expect(pageMock.getHash()).andReturn(hash);
    
    responseMock.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
    
    EasyMock.replay(requestMock, responseMock, pageMock, modelMock, pageBuilderMock);
    Whitebox.invokeMethod(publicServlet, "handleRequestTypeText", pageMock, requestMock, responseMock, modelMock);
    
   
    } catch (Exception e)
    {
        assertTrue(false);
    }
}
 
Example 14
Source File: WSManRemoteShellServiceTest.java    From cs-actions with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetResourceIdThrowsUnexpectedResponseException() throws Exception {
    PowerMockito.mockStatic(WSManUtils.class);
    Mockito.when(WSManUtils.isSpecificResponseAction(RESPONSE_BODY, RECEIVE_RESPONSE_ACTION)).thenReturn(false);
    Mockito.when(WSManUtils.isFaultResponse(RESPONSE_BODY)).thenReturn(false);

    thrownException.expectMessage(UNEXPECTED_SERVICE_RESPONSE);
    Whitebox.invokeMethod(wsManRemoteShellServiceSpy, GET_RESOURCE_ID_METHOD, RESPONSE_BODY, RECEIVE_RESPONSE_ACTION,
            CREATE_RESPONSE_SHELL_ID_XPATH, SHELL_ID_NOT_RETRIEVED);

    verifyStatic();
    WSManUtils.isSpecificResponseAction(RESPONSE_BODY, RECEIVE_RESPONSE_ACTION);
    WSManUtils.isFaultResponse(RESPONSE_BODY);
}
 
Example 15
Source File: MetaInjectTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriteInjectedKtrWithRepo() throws Exception {
  PowerMockito.doNothing().when( metaInject, "writeInjectedKtrToRepo", "/home/admin/injected_trans.ktr" );
  PowerMockito.doNothing().when( metaInject, "writeInjectedKtrToFs", "/home/admin/injected_trans.ktr" );
  metaInject.setRepository( repository );
  Whitebox.<String>invokeMethod( metaInject, "writeInjectedKtr", "/home/admin/injected_trans.ktr" );
  PowerMockito.verifyPrivate( metaInject, times( 1 ) ).invoke( "writeInjectedKtrToRepo",
    "/home/admin/injected_trans.ktr" );
  PowerMockito.verifyPrivate( metaInject, times( 0 ) ).invoke( "writeInjectedKtrToFs",
    "/home/admin/injected_trans.ktr" );
}
 
Example 16
Source File: MkvMergeMuxerTest.java    From lancoder with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testMuxConcatVideoTrackAndOneAudioTrack() throws Exception {
	MasterConfig config = new MasterConfig();
	config.setAbsoluteSharedFolder(normalizePath("/shared"));
	config.setTempEncodingFolder(normalizePath("/tmp"));

	FilePathManager filePathManager = new FilePathManager(config);
	JobInitiator jobInitiator = new JobInitiator(null, config);

	MkvMerge mkvMerge = new MkvMerge(config);

	MkvMergeMuxer muxer = new MkvMergeMuxer(null, filePathManager, mkvMerge);

	PowerMockito.mockStatic(FFmpegWrapper.class);
	Mockito.when(FFmpegWrapper.getFileInfo((File) Mockito.any(), (String) Mockito.any(), (FFprobe) Mockito.any()))
			.thenReturn(FakeInfo.fakeFileInfo());

	Job job = null;
	try {
		job = Whitebox.<Job> invokeMethod(jobInitiator, FakeInfo.fakeAudioEncodeRequest(), new File(
				"testSource.mkv"));
	} catch (Exception e) {
		fail();
	}

	Field field = muxer.getClass().getDeclaredField("job");
	field.setAccessible(true);
	field.set(muxer, job);

	ArrayList<String> expected = new ArrayList<>(Arrays.asList(new String[] { "mkvmerge", "-o",
			normalizePath("/shared/encodes/testJob/testSource.mkv"),
			normalizePath("/shared/encodes/testJob/parts/0/part-0.mkv"), "+", normalizePath("/shared/encodes/testJob/parts/1/part-1.mkv"), normalizePath("/shared/encodes/testJob/parts/2/part-2.ogg") }));


	assertEquals(expected, muxer.getArgs());
}
 
Example 17
Source File: TestWBJSONToFromObjectConverter.java    From cms with Apache License 2.0 4 votes vote down vote up
@Test
public void testFieldFromJSON_ok()
{
	try
	{
		String name = "John";
		Integer age = 10;
		Long amount = 20L;
		Date date = new Date();
		long balance = 3L;
		int weight = 40;
		json.put("name", name);
		json.put("age", age);
		json.put("amount", amount);
		json.put("balance", balance);
		json.put("date", date.getTime());
		json.put("weight", weight);

		String objString = (String)Whitebox.invokeMethod(wbObjectfromJson, "fieldFromJSON", json, "name", name.getClass());
		assertTrue(objString.compareTo(name) == 0);
		
		Integer objInteger = (Integer)Whitebox.invokeMethod(wbObjectfromJson, "fieldFromJSON", json, "age", age.getClass());
		assertTrue(objInteger.compareTo(age) == 0);
		
		Long objLong = (Long)Whitebox.invokeMethod(wbObjectfromJson, "fieldFromJSON", json, "amount", amount.getClass());
		assertTrue(objLong.compareTo(amount) == 0);
			
		Date objDate = (Date)Whitebox.invokeMethod(wbObjectfromJson, "fieldFromJSON", json, "date", date.getClass());
		assertTrue(objDate.compareTo(date) == 0);

		Class longClass = long.class;
		Long objLong2 = (Long)Whitebox.invokeMethod(wbObjectfromJson, "fieldFromJSON", json, "balance", longClass);
		assertTrue(objLong2.compareTo(balance) == 0);

		Class intClass = int.class;
		Integer objInt2 = (Integer)Whitebox.invokeMethod(wbObjectfromJson, "fieldFromJSON", json, "weight", intClass);
		assertTrue(objInt2.compareTo(weight) == 0);

		Object objNull = Whitebox.invokeMethod(wbObjectfromJson, "fieldFromJSON", json, "null", Byte.class);
		assertTrue(objNull == null);
		
	} catch (Exception e)
	{
		assertTrue(false);
	}
}
 
Example 18
Source File: CompactingHashTableTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testDoubleResize() {
	// Only CompactingHashTable
	try {
		final int NUM_MEM_PAGES = 30 * NUM_PAIRS / PAGE_SIZE;
		final Random rnd = new Random(RANDOM_SEED);
		final IntPair[] pairs = getRandomizedIntPairs(NUM_PAIRS, rnd);

		List<MemorySegment> memory = getMemory(NUM_MEM_PAGES);
		CompactingHashTable<IntPair> table = new CompactingHashTable<IntPair>(intPairSerializer, intPairComparator, memory);
		table.open();

		for (int i = 0; i < NUM_PAIRS; i++) {
			table.insert(pairs[i]);
		}

		AbstractHashTableProber<IntPair, IntPair> prober =
			table.getProber(intPairComparator, new SameTypePairComparator<>(intPairComparator));
		IntPair target = new IntPair();

		for (int i = 0; i < NUM_PAIRS; i++) {
			assertNotNull(prober.getMatchFor(pairs[i], target));
			assertEquals(pairs[i].getValue(), target.getValue());
		}

		// make sure there is enough memory for resize
		memory.addAll(getMemory(ADDITIONAL_MEM));
		Boolean b = Whitebox.<Boolean>invokeMethod(table, "resizeHashTable");
		assertTrue(b);

		for (int i = 0; i < NUM_PAIRS; i++) {
			assertNotNull(pairs[i].getKey() + " " + pairs[i].getValue(), prober.getMatchFor(pairs[i], target));
			assertEquals(pairs[i].getValue(), target.getValue());
		}

		// make sure there is enough memory for resize
		memory.addAll(getMemory(ADDITIONAL_MEM));
		b = Whitebox.<Boolean>invokeMethod(table, "resizeHashTable");
		assertTrue(b);

		for (int i = 0; i < NUM_PAIRS; i++) {
			assertNotNull(pairs[i].getKey() + " " + pairs[i].getValue(), prober.getMatchFor(pairs[i], target));
			assertEquals(pairs[i].getValue(), target.getValue());
		}

		table.close();
		assertEquals("Memory lost", NUM_MEM_PAGES + ADDITIONAL_MEM + ADDITIONAL_MEM, table.getFreeMemory().size());
	} catch (Exception e) {
		e.printStackTrace();
		fail("Error: " + e.getMessage());
	}
}
 
Example 19
Source File: BulkIngestMapFileLoaderTest.java    From datawave with Apache License 2.0 4 votes vote down vote up
@Test
public void testMarkJobDirectoryFailedFailedRename() throws Exception {
    
    BulkIngestMapFileLoaderTest.logger.info("testMarkJobDirectoryFailedFailedRename called...");
    
    try {
        
        URL url = BulkIngestMapFileLoaderTest.class.getResource("/datawave/ingest/mapreduce/job/");
        
        String workDir = ".";
        String jobDirPattern = "jobs/";
        String instanceName = "localhost";
        String zooKeepers = "localhost";
        Credentials credentials = new Credentials("user", new PasswordToken("pass"));
        URI seqFileHdfs = url.toURI();
        URI srcHdfs = url.toURI();
        URI destHdfs = url.toURI();
        String jobtracker = "localhost";
        Map<String,Integer> tablePriorities = new HashMap<>();
        Configuration conf = new Configuration();
        
        BulkIngestMapFileLoader uut = new BulkIngestMapFileLoader(workDir, jobDirPattern, instanceName, zooKeepers, credentials, seqFileHdfs, srcHdfs,
                        destHdfs, jobtracker, tablePriorities, conf, 0);
        
        Assert.assertNotNull("BulkIngestMapFileLoader constructor failed to create an instance.", uut);
        
        BulkIngestMapFileLoaderTest.WrappedLocalFileSystem fs = new BulkIngestMapFileLoaderTest.WrappedLocalFileSystem(null, null, false, false, false,
                        true, null, false, false);
        
        Whitebox.invokeMethod(FileSystem.class, "addFileSystemForTesting", BulkIngestMapFileLoaderTest.FILE_SYSTEM_URI, conf, fs);
        
        Path jobDirectory = new Path(url.toString());
        
        boolean results = uut.markJobDirectoryFailed(url.toURI(), jobDirectory);
        
        List<String> calls = fs.callsLogs();
        
        Assert.assertTrue("BulkIngestMapFileLoader#markJobDirectoryFailed failed to return true as expected.", results);
        Assert.assertTrue("BulkIngestMapFileLoader#markJobDirectoryFailed failed to call FileSystem#rename",
                        processOutputContains(calls, "FileSystem#rename("));
        Assert.assertTrue("BulkIngestMapFileLoader#markJobDirectoryFailed failed to call FileSystem#createNewFile",
                        processOutputContains(calls, "FileSystem#createNewFile("));
    } finally {
        
        Whitebox.invokeMethod(FileSystem.class, "addFileSystemForTesting", BulkIngestMapFileLoaderTest.FILE_SYSTEM_URI, null, null);
        
        BulkIngestMapFileLoaderTest.logger.info("testMarkJobDirectoryFailedFailedRename completed.");
    }
    
}
 
Example 20
Source File: CommonUtilsTest.java    From pacbot with Apache License 2.0 4 votes vote down vote up
@Test
   public void initHeimdallElasticSearchRepository() throws Exception{
	final HeimdallElasticSearchRepository classUnderTest = PowerMockito.spy(new HeimdallElasticSearchRepository());
	Whitebox.invokeMethod(classUnderTest, "init");
}