Skip to content

Instantly share code, notes, and snippets.

@gabanox
Created October 17, 2014 17:41
Show Gist options
  • Save gabanox/6f8361cadc7d58c8911f to your computer and use it in GitHub Desktop.
Save gabanox/6f8361cadc7d58c8911f to your computer and use it in GitHub Desktop.
package com.telcel.aspects;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.telcel.aspects.PerformanceAspect;
import com.telcel.repository.MyRepository;
import com.telcel.service.MyService;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/system-configuration.xml")
public class PerformanceAspectTest {
@Autowired
PerformanceAspect performanceAspect;
@Autowired
MyService myService;
@Autowired
MyRepository myRepository;
@Before
public void setUp() {
performanceAspect.resetCalled();
}
@Test
public void performanceIsCalledForRepositories() {
assertFalse(performanceAspect.isCalled());
myRepository.doIt();
assertTrue(performanceAspect.isCalled());
}
@Test
public void performanceIsNotCalledForServices() {
assertFalse(performanceAspect.isCalled());
myService.doIt();
assertFalse(performanceAspect.isCalled());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment