Back to Repositories

Validating Hystrix Command Properties with AspectJ Configuration in Netflix/Hystrix

This test suite validates the configuration properties for Hystrix commands in AspectJ environment. It extends the basic command properties testing framework while specifically focusing on compile-time weaving mode for AspectJ integration.

Test Coverage Overview

The test suite provides comprehensive coverage of Hystrix command configuration properties in an AspectJ context.

Key areas covered include:
  • Command property initialization and validation
  • Compile-time weaving configuration
  • UserService implementation verification
  • Integration with basic command properties framework

Implementation Analysis

The testing approach leverages inheritance from BasicCommandPropertiesTest while implementing AspectJ-specific configurations. The suite employs compile-time weaving mode through system property configuration and customizes service creation through method overrides.

Technical patterns include:
  • Test inheritance for reusability
  • Environment configuration via @BeforeClass
  • Service factory method pattern

Technical Details

Testing infrastructure includes:
  • JUnit test framework
  • AspectJ compile-time weaver
  • Hystrix command configuration
  • System property management
  • Custom UserService implementation

Best Practices Demonstrated

The test implementation showcases several testing best practices for AspectJ and Hystrix integration.

Notable practices include:
  • Clean separation of concerns through inheritance
  • Proper test environment setup
  • Consistent service initialization pattern
  • Clear test scope definition

netflix/hystrix

hystrix-contrib/hystrix-javanica/src/ajcTest/java/com/netflix/hystrix/contrib/javanica/test/aspectj/configuration/command/CommandPropertiesTest.java

            
/**
 * Copyright 2016 Netflix, Inc.
 *
 * Licensed 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 com.netflix.hystrix.contrib.javanica.test.aspectj.configuration.command;

import com.netflix.hystrix.contrib.javanica.test.common.configuration.command.BasicCommandPropertiesTest;
import org.junit.BeforeClass;

/**
 * Created by dmgcodevil
 */
public class CommandPropertiesTest extends BasicCommandPropertiesTest {

    @BeforeClass
    public static void setUpEnv() {
        System.setProperty("weavingMode", "compile");
    }
    
    @Override
    protected UserService createUserService() {
        return new UserService();
    }
}