Created
February 20, 2014 03:20
-
-
Save lnramirez/9106547 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface UselessService | |
{ | |
public int blah(); | |
} | |
import org.springframework.context.annotation.Profile; | |
import org.springframework.stereotype.Component; | |
@Component | |
@Profile("crazy") | |
public class UselessServiceCrazyProfileImpl implements UselessService | |
{ | |
@Override | |
public int blah() | |
{ | |
return 2; | |
} | |
} | |
import org.springframework.context.annotation.Profile; | |
import org.springframework.stereotype.Component; | |
@Component | |
@Profile("prod") | |
public class UselessServiceProdImpl implements UselessService | |
{ | |
@Override | |
public int blah() | |
{ | |
return 3; | |
} | |
} | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.stereotype.Component; | |
@Component | |
public class UselessUserService | |
{ | |
@Autowired | |
private UselessService uselessService; | |
public int justInvokeIt() | |
{ | |
return uselessService.blah(); | |
} | |
} | |
import junit.framework.Assert; | |
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; | |
@RunWith(SpringJUnit4ClassRunner.class) | |
@ContextConfiguration("classpath:module-config-test.xml") | |
public class UselessServiceTest | |
{ | |
@Autowired | |
private UselessUserService uselessUserService; | |
@Test | |
public void testSomething() | |
{ | |
Assert.assertEquals(2,uselessUserService.justInvokeIt()); | |
} | |
} | |
/*changes I did on bzroot added crazy profile to spring profiles default | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-surefire-plugin</artifactId> | |
<version>${plugin.maven.surefire.version}</version> | |
<configuration> | |
<useFile>false</useFile> | |
<trimStackTrace>false</trimStackTrace> | |
<excludes> | |
<exclude>**/*ClientTest.java</exclude> | |
<exclude>**/Test*.java</exclude> | |
<exclude>**/*GwtTestCase.java</exclude> | |
</excludes> | |
<environmentVariables> | |
<SPRING_PROFILES_DEFAULT>dev,crazy</SPRING_PROFILES_DEFAULT> | |
</environmentVariables> | |
</configuration> | |
</plugin> | |
*/ | |
//build steps, build, brazenconnect/bc-services, test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment