Last active
December 30, 2015 06:08
-
-
Save kyberorg/7786960 to your computer and use it in GitHub Desktop.
Autowired issue
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
<?xml version="1.0" encoding="UTF-8"?> | |
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> | |
<bean id='actions' class="net.virtalab.jsonio.configuration.actions.ActionBeans" scope="singleton"> | |
<qualifier value="actions" /> | |
</bean> | |
</beans> |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> | |
<import resource="actions.xml" /> | |
<import resource="datasources.xml" /> | |
</beans> |
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
package net.virtalab.jsonio.test; | |
import net.virtalab.jsonio.configuration.actions.ActionBeans; | |
import net.virtalab.jsonio.test.temp.TestClazz; | |
import org.junit.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; | |
/** | |
* Spring Autowired test. | |
*/ | |
@ContextConfiguration(locations = {"classpath:applicationContext.xml"}) | |
@RunWith(SpringJUnit4ClassRunner.class) | |
public class AutowiredTest { | |
@Autowired | |
private ActionBeans localBeans; | |
@Test | |
public void autoWiredLocallyTest(){ | |
//pre-test | |
Assert.assertNotNull(localBeans); | |
} | |
@Test | |
public void autoWireAtClassTest(){ | |
TestClazz t = new TestClazz(); | |
boolean isAutoWiredFromClass = t.isAutowired(); | |
Assert.assertTrue(isAutoWiredFromClass); | |
} | |
} |
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
package net.virtalab.jsonio.test.temp; | |
import net.virtalab.jsonio.configuration.actions.ActionBeans; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.beans.factory.annotation.Qualifier; | |
/** | |
* Class description. | |
*/ | |
public class TestClazz { | |
@Autowired | |
@Qualifier("actions") | |
private ActionBeans tempowieBiny; | |
public boolean isAutowired(){ | |
return(this.tempowieBiny!=null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment