Java Code Examples for org.powermock.api.easymock.PowerMock#replay()

The following examples show how to use org.powermock.api.easymock.PowerMock#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: TestWBFreeMarkerTemplateLoader.java    From cms with Apache License 2.0 6 votes vote down vote up
@Test
public void test_findTemplateSource_module_ok()
{
	try
	{
		String templatePage = WPBTemplateEngine.WEBMODULES_PATH_PREFIX + "test";
	
		WPBPageModule webPageModuleMock = PowerMock.createMock(WPBPageModule.class);
		Date date = new Date();
		EasyMock.expect(webPageModuleMock.getLastModified()).andReturn(date);
		EasyMock.expect(wbWebPageModuleCacheMock.getByExternalKey("test")).andReturn(webPageModuleMock);
	
		PowerMock.replay(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock, webPageModuleMock);
		FreeMarkerTemplateLoader templateLoader = new FreeMarkerTemplateLoader(cacheInstances);
		FreeMarkerTemplateObject object = (FreeMarkerTemplateObject) templateLoader.findTemplateSource(templatePage);

		PowerMock.verify(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock, webPageModuleMock);
		assertTrue(object.getExternalKey().equals("test"));
		assertTrue(object.getType() == TemplateType.TEMPLATE_MODULE);
		assertTrue(object.getLastModified() == date.getTime());
		
	} catch (Exception e)
	{
		assertTrue(false);
	}
}
 
Example 2
Source File: TestWBFreeMarkerTemplateLoader.java    From cms with Apache License 2.0 6 votes vote down vote up
@Test
public void test_findTemplateSource_wrongNameFormat()
{
	try
	{
		String templatePage =  "random test";
		PowerMock.replay(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock);
		FreeMarkerTemplateLoader templateLoader = new FreeMarkerTemplateLoader(cacheInstances);
		FreeMarkerTemplateObject object = (FreeMarkerTemplateObject) templateLoader.findTemplateSource(templatePage);
		PowerMock.verify(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock);

		assertTrue(object == null);
		
	} catch (Exception e)
	{
		assertTrue(false);
	}
}
 
Example 3
Source File: StartJobTaskTest.java    From dropwizard-sundial with Apache License 2.0 6 votes vote down vote up
@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 4
Source File: StartJobTaskTest.java    From dropwizard-sundial with Apache License 2.0 6 votes vote down vote up
@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 5
Source File: TestWBFreeMarkerTemplateLoader.java    From cms with Apache License 2.0 6 votes vote down vote up
@Test
public void test_getLastModified_null()
{
	try
	{
	
	PowerMock.replay(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock);
	FreeMarkerTemplateLoader templateLoader = new FreeMarkerTemplateLoader(cacheInstances);
	
	long lastmodified = templateLoader.getLastModified(null);
	
	assertTrue (lastmodified == 0L);
	
	}catch (Exception e)
	{
		assertTrue(false);
	}
}
 
Example 6
Source File: TestWBFreeMarkerTemplateLoader.java    From cms with Apache License 2.0 6 votes vote down vote up
@Test
public void test_findTemplateSource_module_notfound()
{
	try
	{

		String templatePage = WPBTemplateEngine.WEBMODULES_PATH_PREFIX + "test";
	
		EasyMock.expect(wbWebPageModuleCacheMock.getByExternalKey("test")).andReturn(null);
	
		PowerMock.replay(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock);
		FreeMarkerTemplateLoader templateLoader = new FreeMarkerTemplateLoader(cacheInstances);
		FreeMarkerTemplateObject object = (FreeMarkerTemplateObject) templateLoader.findTemplateSource(templatePage);
		PowerMock.replay(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock);
		assertTrue(object == null);
		
	} catch (Exception e)
	{
		assertTrue(false);
	}
}
 
Example 7
Source File: TestWBFreeMarkerTemplateLoader.java    From cms with Apache License 2.0 6 votes vote down vote up
@Test
public void test_findTemplateSource_page_notfound()
{
	try
	{

		String templatePage = WPBTemplateEngine.WEBPAGES_PATH_PREFIX + "test";
	
		EasyMock.expect(wbWebPageCacheMock.getByExternalKey("test")).andReturn(null);	
		PowerMock.replay(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock);
		FreeMarkerTemplateLoader templateLoader = new FreeMarkerTemplateLoader(cacheInstances);
		FreeMarkerTemplateObject object = (FreeMarkerTemplateObject) templateLoader.findTemplateSource(templatePage);
		PowerMock.verify(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock);		
		assertTrue(object == null);
		
	} catch (Exception e)
	{
		assertTrue(false);
	}
}
 
Example 8
Source File: IntellijMocker.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Mocks static <code>getInstance()</code> calls.
 *
 * <p>If you use this utility, make sure to (1) run your test class with {@link PowerMockRunner}
 * and (2) add the class to be mocked to the "prepare for test" list:
 *
 * <p>
 *
 * <pre>
 * {@literal @}RunWith(PowerMockRunner.class)
 * {@literal @}PrepareForTest({ IntellijClassToMock.class })
 * public class MyTestClass {
 *     // ...
 * }
 * </pre>
 *
 * @param clazz Class to mock
 * @param argClass class of the argument that is passed to <code>getInstance()</code>, if any. Can
 *     be <code>null</code>
 */
public static <T> void mockStaticGetInstance(Class<T> clazz, Class<?> argClass) {
  String method = "getInstance";

  T instance = createNiceMock(clazz);
  EasyMock.replay(instance);

  PowerMock.mockStaticPartial(clazz, method);
  try {
    if (argClass == null) {
      // method has no arguments
      clazz.getMethod(method).invoke(null);
    } else {
      // method has one argument
      clazz.getMethod(method, argClass).invoke(null, anyObject(argClass));
    }
  } catch (Exception e) {
    e.printStackTrace();
    Assert.fail("reflection error, see stacktrace");
  }

  expectLastCall().andStubReturn(instance);
  PowerMock.replay(clazz);
}
 
Example 9
Source File: TestWBFreeMarkerTemplateLoader.java    From cms with Apache License 2.0 5 votes vote down vote up
@Test
public void test_getLastModified_module_exception()
{
	try
	{
	String templateName = "testX";
	
	FreeMarkerTemplateObject templateObjectMock = PowerMock.createMock(FreeMarkerTemplateObject.class);
	EasyMock.expect(templateObjectMock.getType()).andReturn(TemplateType.TEMPLATE_MODULE);
	
	//EasyMock.expect(templateObject.getLastModified()).andReturn(date.getTime());
	EasyMock.expect(templateObjectMock.getExternalKey()).andReturn(templateName);
	
	EasyMock.expect(wbWebPageModuleCacheMock.getByExternalKey(templateName)).andThrow(new WPBIOException(""));
	
	PowerMock.replay(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock, templateObjectMock);
	FreeMarkerTemplateLoader templateLoader = new FreeMarkerTemplateLoader(cacheInstances);

	long lastmodified = templateLoader.getLastModified(templateObjectMock);
	PowerMock.verify(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock, templateObjectMock);
	
	assertTrue (lastmodified == 0L);
	
	}catch (Exception e)
	{
		assertTrue(false);
	}
}
 
Example 10
Source File: EclipseMocker.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
/** Mock the static call {@link ResourcesPlugin#getWorkspace()}. */
public static void mockResourcesPlugin() {
  IWorkspaceRoot workspaceRoot = EasyMock.createNiceMock(IWorkspaceRoot.class);
  EasyMock.replay(workspaceRoot);

  final IWorkspace workspace = EasyMock.createNiceMock(IWorkspace.class);
  EasyMock.expect(workspace.getRoot()).andStubReturn(workspaceRoot);
  EasyMock.replay(workspace);

  PowerMock.mockStaticPartial(ResourcesPlugin.class, "getWorkspace");
  ResourcesPlugin.getWorkspace();
  EasyMock.expectLastCall().andReturn(workspace).anyTimes();
  PowerMock.replay(ResourcesPlugin.class);
}
 
Example 11
Source File: TestWBFreeMarkerTemplateLoader.java    From cms with Apache License 2.0 5 votes vote down vote up
@Test
public void test_getLastModified_page_notfound()
{
	try
	{
	String templateName = "testX";
	
	FreeMarkerTemplateObject templateObjectMock = PowerMock.createMock(FreeMarkerTemplateObject.class);
	EasyMock.expect(templateObjectMock.getType()).andReturn(TemplateType.TEMPLATE_PAGE);
	
	//EasyMock.expect(templateObject.getLastModified()).andReturn(date.getTime());
	EasyMock.expect(templateObjectMock.getExternalKey()).andReturn(templateName);
	
	EasyMock.expect(wbWebPageCacheMock.getByExternalKey(templateName)).andReturn(null);
	
	PowerMock.replay(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock, templateObjectMock);
	FreeMarkerTemplateLoader templateLoader = new FreeMarkerTemplateLoader(cacheInstances);
	
	long lastmodified = templateLoader.getLastModified(templateObjectMock);
	
	PowerMock.verify(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock, templateObjectMock);

	assertTrue (lastmodified == 0L);
	
	}catch (Exception e)
	{
		assertTrue(false);
	}
}
 
Example 12
Source File: TestWBFreeMarkerTemplateLoader.java    From cms with Apache License 2.0 5 votes vote down vote up
@Test
public void test_getLastModified_module()
{
	try
	{
	String templateName = "testX";
	Date date = new Date();
	
	FreeMarkerTemplateObject templateObjectMock = PowerMock.createMock(FreeMarkerTemplateObject.class);
	EasyMock.expect(templateObjectMock.getType()).andReturn(TemplateType.TEMPLATE_MODULE);
	
	//EasyMock.expect(templateObject.getLastModified()).andReturn(date.getTime());
	EasyMock.expect(templateObjectMock.getExternalKey()).andReturn(templateName);
	
	WPBPageModule pageModuleMock = PowerMock.createMock(WPBPageModule.class);
	EasyMock.expect(pageModuleMock.getLastModified()).andReturn(date);
	EasyMock.expect(wbWebPageModuleCacheMock.getByExternalKey(templateName)).andReturn(pageModuleMock);
	
	PowerMock.replay(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock, pageModuleMock, templateObjectMock);

	FreeMarkerTemplateLoader templateLoader = new FreeMarkerTemplateLoader(cacheInstances);
	
	long lastmodified = templateLoader.getLastModified(templateObjectMock);
	PowerMock.verify(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock, templateObjectMock);
	
	assertTrue (lastmodified == date.getTime());
	
	}catch (Exception e)
	{
		assertTrue(false);
	}
}
 
Example 13
Source File: TestWBFreeMarkerTemplateLoader.java    From cms with Apache License 2.0 5 votes vote down vote up
@Test
public void test_getLastModified_page()
{
	try
	{
	String templateName = "testX";
	Date date = new Date();
	
	FreeMarkerTemplateObject templateObjectMock = PowerMock.createMock(FreeMarkerTemplateObject.class);
	EasyMock.expect(templateObjectMock.getType()).andReturn(TemplateType.TEMPLATE_PAGE);
	
	//EasyMock.expect(templateObject.getLastModified()).andReturn(date.getTime());
	EasyMock.expect(templateObjectMock.getExternalKey()).andReturn(templateName);
	
	WPBPage pageMock = PowerMock.createMock(WPBPage.class);
	EasyMock.expect(pageMock.getLastModified()).andReturn(date);
	EasyMock.expect(wbWebPageCacheMock.getByExternalKey(templateName)).andReturn(pageMock);

	PowerMock.replay(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock, pageMock, templateObjectMock);
	FreeMarkerTemplateLoader templateLoader = new FreeMarkerTemplateLoader(cacheInstances);
	
	long lastmodified = templateLoader.getLastModified(templateObjectMock);
	PowerMock.verify(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock, pageMock, templateObjectMock);	
	assertTrue (lastmodified == date.getTime());
	
	}catch (Exception e)
	{
		assertTrue(false);
	}
}
 
Example 14
Source File: EurekaDynamicServerListLoadBalancerTest.java    From ribbon with Apache License 2.0 5 votes vote down vote up
@Test
public void testLoadBalancerHappyCase() throws Exception {
    Assert.assertNotEquals("the two test server list counts should be different",
            secondServerListSize, initialServerListSize);

    DynamicServerListLoadBalancer<DiscoveryEnabledServer> lb = null;
    try {
        Capture<EurekaEventListener> eventListenerCapture = new Capture<EurekaEventListener>();
        eurekaClientMock.registerEventListener(EasyMock.capture(eventListenerCapture));

        PowerMock.replay(DiscoveryClient.class);
        PowerMock.replay(eurekaClientMock);

        // actual testing
        // initial creation and loading of the first serverlist
        lb = new DynamicServerListLoadBalancer<DiscoveryEnabledServer>(
                config,
                new AvailabilityFilteringRule(),
                new DummyPing(),
                new DiscoveryEnabledNIWSServerList(vipAddress, eurekaClientProvider),
                new ZoneAffinityServerListFilter<DiscoveryEnabledServer>(),
                new EurekaNotificationServerListUpdater(eurekaClientProvider)
        );

        Assert.assertEquals(initialServerListSize, lb.getServerCount(false));

        // trigger an eureka CacheRefreshEvent
        eventListenerCapture.getValue().onEvent(new CacheRefreshedEvent());

        Assert.assertTrue(verifyFinalServerListCount(secondServerListSize, lb));

    } finally {
        if (lb != null) {
            lb.shutdown();

            PowerMock.verify(eurekaClientMock);
            PowerMock.verify(DiscoveryClient.class);
        }
    }
}
 
Example 15
Source File: TestWBFreeMarkerTemplateLoader.java    From cms with Apache License 2.0 5 votes vote down vote up
@Test
public void test_getLastModified_module_notfound()
{
	try
	{
	String templateName = "testX";
	
	FreeMarkerTemplateObject templateObjectMock = PowerMock.createMock(FreeMarkerTemplateObject.class);
	EasyMock.expect(templateObjectMock.getType()).andReturn(TemplateType.TEMPLATE_MODULE);
	
	//EasyMock.expect(templateObject.getLastModified()).andReturn(date.getTime());
	EasyMock.expect(templateObjectMock.getExternalKey()).andReturn(templateName);
	
	EasyMock.expect(wbWebPageModuleCacheMock.getByExternalKey(templateName)).andReturn(null);
	
	PowerMock.replay(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock, templateObjectMock);
	FreeMarkerTemplateLoader templateLoader = new FreeMarkerTemplateLoader(cacheInstances);

	long lastmodified = templateLoader.getLastModified(templateObjectMock);
	PowerMock.verify(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock, templateObjectMock);
	
	assertTrue (lastmodified == 0L);
	
	}catch (Exception e)
	{
		assertTrue(false);
	}
}
 
Example 16
Source File: ParamUtilsTest.java    From turin-programming-language with Apache License 2.0 5 votes vote down vote up
@Test
public void testDesugarizeAsteriskParamWithOnlyNonDefaultAvailable() {
    List<FormalParameterNode> formalParameters = ImmutableList.of(fn1, fn2, fd1, fd2);
    Expression value = createMock(Expression.class);
    value.setParent(EasyMock.anyObject());
    value.setParent(EasyMock.anyObject());
    value.setParent(EasyMock.anyObject());
    value.setParent(EasyMock.anyObject());
    SymbolResolver resolver = createMock(SymbolResolver.class);
    ReferenceTypeUsage typeUsageOfAsteriskParam = createMock(ReferenceTypeUsage.class);
    expect(value.calcType()).andReturn(typeUsageOfAsteriskParam);
    expect(typeUsageOfAsteriskParam.isReference()).andReturn(true);
    expect(typeUsageOfAsteriskParam.asReferenceTypeUsage()).andReturn(typeUsageOfAsteriskParam);
    TypeDefinition typeOfAsteriskParam = PowerMock.createMock(TypeDefinitionNode.class);
    expect(typeUsageOfAsteriskParam.getTypeDefinition()).andReturn(typeOfAsteriskParam);
    expect(typeOfAsteriskParam.hasMethodFor("getFn1", Collections.emptyList(), false)).andReturn(true);
    expect(typeOfAsteriskParam.hasMethodFor("getFn2", Collections.emptyList(), false)).andReturn(true);
    expect(typeOfAsteriskParam.hasMethodFor("getFd1", Collections.emptyList(), false)).andReturn(false);
    expect(typeOfAsteriskParam.hasMethodFor("getFd2", Collections.emptyList(), false)).andReturn(false);
    Node parent = new IntLiteral(3); // it does not really matter

    replay(value, resolver, typeUsageOfAsteriskParam);
    PowerMock.replay(typeOfAsteriskParam);
    Either<String, List<ActualParam>> res = desugarizeAsteriskParam(formalParameters, value, resolver, parent);
    assertEquals(true, res.isRight());
    // 2 + the map for default params
    assertEquals(3, res.getRight().size());
    verify(value, resolver, typeUsageOfAsteriskParam);
    PowerMock.verify(typeOfAsteriskParam);
}
 
Example 17
Source File: TestWBFreeMarkerTemplateEngine.java    From cms with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressStaticInitializationFor("WBFreeMarkerTemplateEngine.class")
@PrepareForTest({Environment.class, WPBFreeMarkerTemplateEngine.class})
public void process_ok_with_messages()
{
	try
	{
		WPBFreeMarkerTemplateEngine templateEngine = new WPBFreeMarkerTemplateEngine(cacheInstancesMock);
		Whitebox.setInternalState(templateEngine, "configuration", configurationMock);
		String nameTemplate = "textXYZ";
		Map rootMap = new HashMap();
		rootMap.put(WPBModel.LOCALE_LANGUAGE_KEY, "en");
		rootMap.put(WPBModel.LOCALE_MESSAGES, new Object());
		
		Writer out = new StringWriter();
		
		Template templateMock = PowerMock.createMock(Template.class);
		EasyMock.expect(configurationMock.getTemplate(nameTemplate)).andReturn(templateMock);
		
		
		Environment envMock = PowerMock.createMock(Environment.class);
		EasyMock.expect(templateMock.createProcessingEnvironment(rootMap, out)).andReturn(envMock);
			
		envMock.process();
		Whitebox.setInternalState(templateEngine, "wbFreeMarkerFactory", freeMarkerFactoryMock);
		
		PowerMock.replay(cloudFileStorageMock, envMock, templateMock, cacheFactoryMock, freeMarkerFactoryMock, configurationMock, templateLoaderMock, moduleDirectiveMock, messageCacheMock);
	
		templateEngine.process(nameTemplate, rootMap, out);
		
		PowerMock.verify(cloudFileStorageMock, envMock, templateMock, cacheFactoryMock, freeMarkerFactoryMock, configurationMock, templateLoaderMock, moduleDirectiveMock, messageCacheMock);

		assertTrue (rootMap.containsKey(WPBModel.LOCALE_MESSAGES));
	} catch (Exception e)
	{
		assertTrue (false);
	}
	
}
 
Example 18
Source File: TestWBFreeMarkerTemplateLoader.java    From cms with Apache License 2.0 5 votes vote down vote up
@Test
public void test_closeTemplateSource()
{
	FreeMarkerTemplateObject templateObjectMock = PowerMock.createMock(FreeMarkerTemplateObject.class);	
	PowerMock.replay(wbUriCacheMock, wbWebPageCacheMock, wbWebPageModuleCacheMock, wbParameterCacheMock, wbImageCacheMock, wbArticleCacheMock, wbMessageCacheMock, wbProjectCacheMock, templateObjectMock);
	FreeMarkerTemplateLoader templateLoader = new FreeMarkerTemplateLoader(cacheInstances);
	try
	{
		templateLoader.closeTemplateSource(templateObjectMock);
	} catch (Exception e)
	{
		assertTrue(false);
	}
}
 
Example 19
Source File: EurekaDynamicServerListLoadBalancerTest.java    From ribbon with Apache License 2.0 4 votes vote down vote up
@Test
public void testShutdownMultiple() {
    try {
        eurekaClientMock.registerEventListener(EasyMock.anyObject(EurekaEventListener.class));
        EasyMock.expectLastCall().anyTimes();

        PowerMock.replay(DiscoveryClient.class);
        PowerMock.replay(eurekaClientMock);

        DynamicServerListLoadBalancer<DiscoveryEnabledServer> lb1 = new DynamicServerListLoadBalancer<DiscoveryEnabledServer>(
                config,
                new AvailabilityFilteringRule(),
                new DummyPing(),
                new DiscoveryEnabledNIWSServerList(vipAddress, eurekaClientProvider),
                new ZoneAffinityServerListFilter<DiscoveryEnabledServer>(),
                new EurekaNotificationServerListUpdater(eurekaClientProvider)
        );

        DynamicServerListLoadBalancer<DiscoveryEnabledServer> lb2 = new DynamicServerListLoadBalancer<DiscoveryEnabledServer>(
                config,
                new AvailabilityFilteringRule(),
                new DummyPing(),
                new DiscoveryEnabledNIWSServerList(vipAddress, eurekaClientProvider),
                new ZoneAffinityServerListFilter<DiscoveryEnabledServer>(),
                new EurekaNotificationServerListUpdater(eurekaClientProvider)
        );

        DynamicServerListLoadBalancer<DiscoveryEnabledServer> lb3 = new DynamicServerListLoadBalancer<DiscoveryEnabledServer>(
                config,
                new AvailabilityFilteringRule(),
                new DummyPing(),
                new DiscoveryEnabledNIWSServerList(vipAddress, eurekaClientProvider),
                new ZoneAffinityServerListFilter<DiscoveryEnabledServer>(),
                new EurekaNotificationServerListUpdater(eurekaClientProvider)
        );

        lb3.shutdown();
        lb1.shutdown();
        lb2.shutdown();
    } finally {
        PowerMock.verify(eurekaClientMock);
        PowerMock.verify(DiscoveryClient.class);
    }
}
 
Example 20
Source File: BulkIngestMapFileLoaderTest.java    From datawave with Apache License 2.0 3 votes vote down vote up
protected FileStatus createMockFileStatus() {
    
    FileStatus mocked = PowerMock.createMock(FileStatus.class);
    
    PowerMock.replay(mocked);
    
    return mocked;
}