Search in sources :

Example 1 with Locator

use of org.apache.geode.test.dunit.rules.Locator in project geode by apache.

the class PDXGfshPostProcessorOnRemoteServerTest method testGfshCommand.

@Test
public void testGfshCommand() throws Exception {
    Properties locatorProps = new Properties();
    locatorProps.setProperty(TestSecurityManager.SECURITY_JSON, "org/apache/geode/management/internal/security/clientServer.json");
    locatorProps.setProperty(SECURITY_MANAGER, TestSecurityManager.class.getName());
    locatorProps.setProperty(SECURITY_POST_PROCESSOR, PDXPostProcessor.class.getName());
    MemberVM<Locator> locatorVM = lsRule.startLocatorVM(0, locatorProps);
    Properties serverProps = new Properties();
    serverProps.setProperty(TestSecurityManager.SECURITY_JSON, "org/apache/geode/management/internal/security/clientServer.json");
    serverProps.setProperty("security-username", "super-user");
    serverProps.setProperty("security-password", "1234567");
    MemberVM<Server> serverVM = lsRule.startServerVM(1, serverProps, locatorVM.getPort());
    serverVM.invoke(() -> {
        Cache cache = LocatorServerStartupRule.serverStarter.getCache();
        Region region = cache.createRegionFactory(RegionShortcut.REPLICATE).create(REGION_NAME);
        for (int i = 0; i < 5; i++) {
            SimpleClass obj = new SimpleClass(i, (byte) i);
            region.put("key" + i, obj);
        }
    });
    // wait until the region bean is visible
    locatorVM.invoke(() -> {
        Awaitility.await().pollInterval(500, TimeUnit.MICROSECONDS).atMost(5, TimeUnit.SECONDS).until(() -> {
            Cache cache = CacheFactory.getAnyInstance();
            Object bean = ManagementService.getManagementService(cache).getDistributedRegionMXBean("/" + REGION_NAME);
            return bean != null;
        });
    });
    gfsh.connectAndVerify(locatorVM.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger, CliStrings.CONNECT__USERNAME, "dataUser", CliStrings.CONNECT__PASSWORD, "1234567");
    // get command
    CommandResult result = gfsh.executeAndVerifyCommand("get --key=key1 --region=AuthRegion");
    assertTrue(result.getContent().toString().contains(SimpleClass.class.getName()));
    gfsh.executeAndVerifyCommand("query --query=\"select * from /AuthRegion\"");
    serverVM.invoke(() -> {
        PDXPostProcessor pp = (PDXPostProcessor) SecurityService.getSecurityService().getPostProcessor();
        // verify that the post processor is called 6 times. (5 for the query, 1 for the get)
        assertEquals(pp.getCount(), 6);
    });
}
Also used : Server(org.apache.geode.test.dunit.rules.Server) Properties(java.util.Properties) SimpleClass(org.apache.geode.pdx.SimpleClass) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Locator(org.apache.geode.test.dunit.rules.Locator) Region(org.apache.geode.cache.Region) Cache(org.apache.geode.cache.Cache) SecurityTest(org.apache.geode.test.junit.categories.SecurityTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 2 with Locator

use of org.apache.geode.test.dunit.rules.Locator in project geode by apache.

the class MainWithChildrenRollingFileHandlerDUnitTest method testGeode2874_nameWithoutExtensionDoesNotThrowOnMemberRestart.

@Test
public void testGeode2874_nameWithoutExtensionDoesNotThrowOnMemberRestart() throws Exception {
    MemberVM<Locator> locatorVM = locatorServerStartupRule.startLocatorVM(0);
    ClientCacheFactory clientCacheFactory = new ClientCacheFactory();
    clientCacheFactory.addPoolLocator(InetAddress.getLocalHost().toString(), locatorVM.getPort());
    clientCacheFactory.set(LOG_FILE, "nameWithoutExtension");
    ClientCache clientCache = clientCacheFactory.create();
    clientCache.close();
    ClientCache clientCache2 = clientCacheFactory.create();
}
Also used : Locator(org.apache.geode.test.dunit.rules.Locator) ClientCache(org.apache.geode.cache.client.ClientCache) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

Locator (org.apache.geode.test.dunit.rules.Locator)2 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)2 Test (org.junit.Test)2 Properties (java.util.Properties)1 Cache (org.apache.geode.cache.Cache)1 Region (org.apache.geode.cache.Region)1 ClientCache (org.apache.geode.cache.client.ClientCache)1 ClientCacheFactory (org.apache.geode.cache.client.ClientCacheFactory)1 CommandResult (org.apache.geode.management.internal.cli.result.CommandResult)1 SimpleClass (org.apache.geode.pdx.SimpleClass)1 Server (org.apache.geode.test.dunit.rules.Server)1 SecurityTest (org.apache.geode.test.junit.categories.SecurityTest)1