accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubbsii <...@git.apache.org>
Subject [GitHub] accumulo pull request #219: ACCUMULO-4584 Remove oneway method checks
Date Wed, 22 Feb 2017 18:43:59 GMT
Github user ctubbsii commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/219#discussion_r102539870
  
    --- Diff: test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java ---
    @@ -0,0 +1,191 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.accumulo.test.rpc;
    +
    +import java.util.Arrays;
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.accumulo.test.categories.SunnyDayTests;
    +import org.apache.accumulo.test.rpc.thrift.SimpleThriftService;
    +import org.apache.log4j.Level;
    +import org.apache.log4j.Logger;
    +import org.apache.thrift.ProcessFunction;
    +import org.apache.thrift.TApplicationException;
    +import org.apache.thrift.TException;
    +import org.apache.thrift.server.TSimpleServer;
    +import org.hamcrest.core.IsInstanceOf;
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.junit.rules.ExpectedException;
    +import org.junit.rules.TestName;
    +import org.junit.rules.Timeout;
    +
    +@Category(SunnyDayTests.class)
    +public class ThriftBehaviorIT {
    +
    +  @Rule
    +  public Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
    +
    +  @Rule
    +  public TestName testName = new TestName();
    +
    +  @Rule
    +  public ExpectedException exception = ExpectedException.none();
    +
    +  private SimpleThriftService.Client client;
    +  private SimpleThriftServiceHandler handler;
    +  private SimpleThriftServiceRunner serviceRunner;
    +  private String propName;
    +  private Map<Logger,Level> oldLogLevels = new HashMap<>();
    +
    +  private static final String KITTY_MSG = "🐈 Kitty! 🐈";
    +
    +  // can delete wrapper when tests pass without using it (assuming tests are good enough)
    +  private static final boolean USE_RPC_WRAPPER = true;
    +
    +  private static final boolean SUPPRESS_SPAMMY_LOGGERS = true;
    +
    +  @Before
    +  public void createClientAndServer() {
    +    Arrays.stream(new Class<?>[] {TSimpleServer.class, ProcessFunction.class}).forEach(spammyClass
-> {
    +      Logger spammyLogger = Logger.getLogger(spammyClass);
    +      oldLogLevels.put(spammyLogger, spammyLogger.getLevel());
    +      if (SUPPRESS_SPAMMY_LOGGERS) {
    +        spammyLogger.setLevel(Level.OFF);
    +      }
    +    });
    +
    +    String threadName = ThriftBehaviorIT.class.getSimpleName() + "." + testName.getMethodName();
    +    serviceRunner = new SimpleThriftServiceRunner(threadName, USE_RPC_WRAPPER);
    +    serviceRunner.startService();
    +    client = serviceRunner.client();
    +    handler = serviceRunner.handler();
    +
    +    propName = testName.getMethodName();
    +    if (propName.endsWith("Handler")) {
    +      propName = propName.substring(0, propName.length() - 7);
    +    }
    +    propName = SimpleThriftServiceHandler.class.getSimpleName() + "." + propName;
    +
    +    System.setProperty(propName, "-");
    +    Assert.assertEquals("-", System.getProperty(propName));
    +  }
    +
    +  @After
    +  public void shutdownServer() {
    +    serviceRunner.stopService();
    +
    +    oldLogLevels.forEach((spammyLogger, oldLevel) -> {
    +      spammyLogger.setLevel(oldLevel);
    +    });
    +
    +    Assert.assertEquals(KITTY_MSG, System.getProperty(propName));
    --- End diff --
    
    Yes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message