Skip to content

Instantly share code, notes, and snippets.

@gabanox
Created October 17, 2014 17:40
Show Gist options
  • Save gabanox/6b54a1b608a174429272 to your computer and use it in GitHub Desktop.
Save gabanox/6b54a1b608a174429272 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.TracingAspect;
import com.telcel.repository.MyRepository;
import com.telcel.service.MyService;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/system-configuration.xml")
public class AroundTracingAspectTest {
@Autowired
TracingAspect tracingAspect;
@Autowired
MyService myService;
@Autowired
MyRepository myRepository;
@Before
public void setUp() {
tracingAspect.resetCalled();
}
@Test
public void tracingIsCalledForRepositories() {
assertFalse(tracingAspect.isCalled());
myRepository.doIt();
assertTrue(tracingAspect.isCalled());
}
@Test
public void tracingIsCalledForServices() {
assertFalse(tracingAspect.isCalled());
myService.doIt();
assertTrue(tracingAspect.isCalled());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment