Package powermock.examples.bypassencapsulation.nontest

Examples of powermock.examples.bypassencapsulation.nontest.Cache


    // Mock only the modifyData method
    ReportDao tested = createPartialMock(ReportDao.class, getReportFromTargetNameMethodName);

    // Create a mock of the distributed cache.
    Cache cacheMock = createMock(Cache.class);

    /*
     * Now that we have a mock of the cache we need to set this instance in
     * the class being tested.
     */
    Whitebox.setInternalState(tested, "cache", cacheMock);

    /*
     * Create an expectation for the private method
     * "getReportFromTargetName".
     */
    expectPrivate(tested, getReportFromTargetNameMethodName, reportName).andReturn(report);

    // Expect the call to invalidate cache.
    cacheMock.invalidateCache(report);
    expectLastCall().once();

    replay(tested, cacheMock);

    tested.deleteReport(reportName);
View Full Code Here


    // Mock only the modifyData method
    ReportDao tested = createPartialMock(ReportDao.class, getReportFromTargetNameMethodName);

    // Create a mock of the distributed cache.
    Cache cacheMock = createMock(Cache.class);

    /*
     * Now that we have a mock of the cache we need to set this instance in
     * the class being tested.
     */
    Whitebox.setInternalState(tested, cacheMock);

    /*
     * Create an expectation for the private method
     * "getReportFromTargetName".
     */
    expectPrivate(tested, getReportFromTargetNameMethodName, reportName).andReturn(report);

    // Expect the call to invalidate cache.
    cacheMock.invalidateCache(report);
    expectLastCall().once();

    replayAll();

    tested.deleteReport(reportName);
View Full Code Here

TOP

Related Classes of powermock.examples.bypassencapsulation.nontest.Cache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.