[arquillian-issues] [JBoss JIRA] (ARQ-1438) TestNG dataprovider with custom object return null values and duplicate output

Claudinei Sartori (JIRA) jira-events at lists.jboss.org
Fri Jul 26 10:56:26 EDT 2013


     [ https://issues.jboss.org/browse/ARQ-1438?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claudinei Sartori updated ARQ-1438:
-----------------------------------

    Steps to Reproduce: 
{code:title=Country.java|borderStyle=solid}
public class Country implements Serializable {


	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	private Long id;

	@NotNull
	@Size(min = ConstantsNumeric.TWO, max = ConstantsNumeric.FIVE)
	@Column(length = ConstantsNumeric.FIVE, nullable = false, unique = true)
	private String sigla;

	@NotNull
	@Size(min = ConstantsNumeric.TWO, max = ConstantsNumeric.FIFTY)
	@Column(length = ConstantsNumeric.FIFTY, nullable = false)
	private String name;

//getters and setters
{code}

{code:title=CountryDAOTest.java|borderStyle=solid}
public class CountryDAOTest extends Arquillian {


	@Deployment
	public static Archive<?> createDeployment() {
		File[] files = Maven.resolver().loadPomFromFile("pom.xml").importRuntimeDependencies().resolve()
				.withTransitivity().asFile();

		final JavaArchive jar = ShrinkWrap.create(JavaArchive.class).addClass(Country.class)
				.addAsResource("test-persistence.xml", "META-INF/persistence.xml")
				.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");

		final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class).addAsLibraries(files).addAsModule(jar);

		return ear;
	}


	@Test(dataProvider = "dataListObject")
	public void testDataProviderObject(Country country) {
		Assert.assertNotNull(country); = true | true
		Assert.assertNotNull(country.getName()); = false | true
	}

	@DataProvider
	public Object[][] dataListObject() {
		final Country country1 = new Country();
		country1.setName("Portugal");
		country1.setSigla("pt");

		final Country country2 = new Country();
		country2.setName("Brasil");
		country2.setSigla("br");

		final Country country3 = new Country();
		country3.setName("França");
		country3.setSigla("fr");

		final Object[][] data = new Object[][] { 
			{ country1 }, 
			{ country2 },
			{ country3 } 
		};

		return data;
	}

}
{code} 

  was:
{code:title=Country.java|borderStyle=solid}
public class Country implements Serializable {


	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	private Long id;

	@NotNull
	@Size(min = ConstantsNumeric.TWO, max = ConstantsNumeric.FIVE)
	@Column(length = ConstantsNumeric.FIVE, nullable = false, unique = true)
	private String sigla;

	@NotNull
	@Size(min = ConstantsNumeric.TWO, max = ConstantsNumeric.FIFTY)
	@Column(length = ConstantsNumeric.FIFTY, nullable = false)
	private String name;

//getters and setters
{code}

{code:title=CountryDAOTest.java|borderStyle=solid}
public class CountryDAOTest extends Arquillian {

	
	@Test(dataProvider = "dataListObject")
	public void testDataProviderObject(Country country) {
		Assert.assertNotNull(country); = true | true
		Assert.assertNotNull(country.getName()); = false | true
	}

	@DataProvider
	public Object[][] dataListObject() {
		final Country country1 = new Country();
		country1.setName("Portugal");
		country1.setSigla("pt");

		final Country country2 = new Country();
		country2.setName("Brasil");
		country2.setSigla("br");

		final Country country3 = new Country();
		country3.setName("França");
		country3.setSigla("fr");

		final Object[][] data = new Object[][] { 
			{ country1 }, 
			{ country2 },
			{ country3 } 
		};

		return data;
	}

}
{code} 


    
> TestNG dataprovider with custom object return null values and duplicate output
> ------------------------------------------------------------------------------
>
>                 Key: ARQ-1438
>                 URL: https://issues.jboss.org/browse/ARQ-1438
>             Project: Arquillian
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: JBoss AS Containers
>    Affects Versions: 1.1.0.Final
>         Environment: Linux Ubuntu 13.04 64 Bits 
>            Reporter: Claudinei Sartori
>
> Expected
> Use dataprovider with Arquillian with custom objects like using String, Integer, etc.
>    
> Actual behavior
> When using a custom object with TestNG dataprovider and Arquillian the 
> attributes of object return "null" and output is duplicated.
> Actual output
> {quote}
> [stdout] (http-localhost-127.0.0.1-8080-1) Count: br.com.xxx.ejb.entity.domain.Country at 1e62801
> [stdout] (http-localhost-127.0.0.1-8080-1) Count: br.com.xxx.ejb.entity.domain.Country at 1e62801
> [stdout] (http-localhost-127.0.0.1-8080-1) Count: br.com.xxx.ejb.entity.domain.Country at 1e62801
> [stdout] (http-localhost-127.0.0.1-8080-1) Count: br.com.xxx.ejb.entity.domain.Country at 1e62801
> [stdout] (http-localhost-127.0.0.1-8080-1) Count: br.com.xxx.ejb.entity.domain.Country at 1e62801
> [stdout] (http-localhost-127.0.0.1-8080-1) Count: br.com.xxx.ejb.entity.domain.Country at 1e62801
> [stdout] (http-localhost-127.0.0.1-8080-1) Count: br.com.xxx.ejb.entity.domain.Country at 1e62801
> [stdout] (http-localhost-127.0.0.1-8080-1) Count: br.com.xxx.ejb.entity.domain.Country at 1e62801
> [stdout] (http-localhost-127.0.0.1-8080-1) Count: br.com.xxx.ejb.entity.domain.Country at 1e62801
> {quote}
> Expected output
> {quote}
> [stdout] (http-localhost-127.0.0.1-8080-1) Count: br.com.xxx.ejb.entity.domain.Country at 1e62801
> [stdout] (http-localhost-127.0.0.1-8080-1) Count: br.com.xxx.ejb.entity.domain.Country at 1e62801
> [stdout] (http-localhost-127.0.0.1-8080-1) Count: br.com.xxx.ejb.entity.domain.Country at 1e62801
> {quote}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the arquillian-issues mailing list