Author: alien11689 Date: Sun Oct 1 20:12:05 2017 New Revision: 1810276 URL: http://svn.apache.org/viewvc?rev=1810276&view=rev Log: [MAINTENANCE] Refactor tests in BMP
Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/TransactionalDef.java Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java?rev=1810276&r1=1810275&r2=1810276&view=diff ============================================================================== --- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java (original) +++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java Sun Oct 1 20:12:05 2017 @@ -22,6 +22,7 @@ import com.google.common.collect.Sets; import org.apache.aries.blueprint.plugin.model.Blueprint; import org.apache.aries.blueprint.plugin.model.TransactionalDef; import org.apache.aries.blueprint.plugin.test.MyBean1; +import org.apache.aries.blueprint.plugin.test.MyBean5; import org.apache.aries.blueprint.plugin.test.MyProduced; import org.apache.aries.blueprint.plugin.test.interfaces.ServiceA; import org.apache.aries.blueprint.plugin.test.interfaces.ServiceB; @@ -231,9 +232,11 @@ public class BlueprintFileWriterTest { @Test public void testGenerateBeanWithConstructorInjection() throws Exception { - // Bean with constructor injection Node myBean5 = getBeanById("myBean5"); + assertXpathEquals(myBean5, "@class", MyBean5.class.getName()); assertXpathDoesNotExist(myBean5, "@field-injection"); + assertXpathDoesNotExist(myBean5, "property"); + assertXpathEquals(myBean5, "count(argument)", "8"); assertXpathEquals(myBean5, "argument[1]/@ref", "my2"); assertXpathEquals(myBean5, "argument[2]/@ref", "my1"); assertXpathEquals(myBean5, "argument[3]/@ref", "serviceABImpl"); @@ -241,6 +244,7 @@ public class BlueprintFileWriterTest { assertXpathEquals(myBean5, "argument[5]/@ref", "ser1"); assertXpathEquals(myBean5, "argument[6]/@ref", "ser2"); assertXpathEquals(myBean5, "argument[7]/@ref", "serviceAImplQualified"); + assertXpathEquals(myBean5, "argument[8]/@ref", "produced2"); } @Test @@ -479,6 +483,15 @@ public class BlueprintFileWriterTest { } @Test + public void testConfigPropertyInjection() throws Exception { + Node bean = getBeanById("beanWithConfig"); + assertXpathEquals(bean, "@class", "org.apache.aries.blueprint.plugin.test.configuration.BeanWithConfig"); + assertXpathDoesNotExist(bean, "argument"); + assertXpathEquals(bean, "count(property)", "1"); + assertXpathEquals(bean, "property[@name='title']/@value", "$[title]"); + } + + @Test public void testGenerateCmConfigProperties() throws Exception { Node testProps5 = getCmPropertiesById("testProps5"); assertXpathEquals(testProps5, "@persistent-id", "aries.test5"); Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java?rev=1810276&r1=1810275&r2=1810276&view=diff ============================================================================== --- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java (original) +++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java Sun Oct 1 20:12:05 2017 @@ -27,11 +27,9 @@ import org.apache.aries.blueprint.plugin import org.apache.aries.blueprint.plugin.bad.BadFieldBean2; import org.apache.aries.blueprint.plugin.bad.BadFieldBean3; import org.apache.aries.blueprint.plugin.bad.FieldBean4; -import org.apache.aries.blueprint.plugin.test.configuration.BeanWithConfig; import org.apache.aries.blueprint.plugin.test.MyBean1; import org.apache.aries.blueprint.plugin.test.MyBean3; import org.apache.aries.blueprint.plugin.test.MyBean4; -import org.apache.aries.blueprint.plugin.test.MyBean5; import org.apache.aries.blueprint.plugin.test.ServiceAImpl1; import org.junit.Test; @@ -40,7 +38,6 @@ import java.util.Arrays; import java.util.HashSet; import java.util.Set; -import static junit.framework.Assert.assertFalse; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -179,33 +176,4 @@ public class BeanTest { public void testFieldBean4() { new Blueprint(blueprintConfiguration, FieldBean4.class); } - - @Test - public void testParseBeanWithConstructorInject() { - Bean bean = new Bean(MyBean5.class, blueprint); - bean.resolveDependency(blueprint); - assertEquals(MyBean5.class, bean.clazz); - assertEquals("myBean5", bean.id); // Name derived from class name - assertTrue("There should be no persistenceUnit", getPersistenceFields(bean).isEmpty()); - assertEquals(0, bean.properties.size()); - assertEquals(8, bean.constructorArguments.size()); - assertEquals("my2", bean.constructorArguments.get(0).getRef()); - assertEquals("serviceA", bean.constructorArguments.get(1).getRef()); - assertEquals("serviceB", bean.constructorArguments.get(2).getRef()); - assertEquals("100", bean.constructorArguments.get(3).getValue()); - assertEquals("ser1", bean.constructorArguments.get(4).getRef()); - assertEquals("ser2", bean.constructorArguments.get(5).getRef()); - assertEquals("serviceA", bean.constructorArguments.get(6).getRef()); - assertEquals("produced2", bean.constructorArguments.get(7).getRef()); - } - - @Test - public void testParseBeanWithConfig() { - Bean bean = new Bean(BeanWithConfig.class, blueprint); - bean.resolveDependency(blueprint); - assertEquals("There should be a property", 1, bean.properties.size()); - Property prop = bean.properties.iterator().next(); - assertEquals("title", prop.name); - assertEquals("$[title]", prop.value); - } } Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/TransactionalDef.java URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/TransactionalDef.java?rev=1810276&r1=1810275&r2=1810276&view=diff ============================================================================== --- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/TransactionalDef.java (original) +++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/TransactionalDef.java Sun Oct 1 20:12:05 2017 @@ -19,8 +19,8 @@ package org.apache.aries.blueprint.plugin.model; public class TransactionalDef { - final String method; - final String type; + private final String method; + private final String type; public TransactionalDef(String method, String type) { this.method = method;