View Javadoc
1   package com.simpligility.maven.plugins.android.phase09package;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   
6   import org.junit.After;
7   import org.junit.Assert;
8   import org.junit.Before;
9   import org.junit.Ignore;
10  import org.junit.Test;
11  import org.junit.runner.RunWith;
12  import org.junit.runners.Parameterized;
13  import org.junit.runners.Parameterized.Parameters;
14  
15  import com.simpligility.maven.plugins.android.AbstractAndroidMojoTestCase;
16  import com.simpligility.maven.plugins.android.config.ConfigHandler;
17  import com.simpligility.maven.plugins.android.phase09package.ApkMojo;
18  
19  @Ignore("This test has to be migrated to be an IntegrationTest using AbstractAndroidMojoIntegrationTest") 
20  @RunWith( Parameterized.class )
21  public class ApkMojoTest
22  extends AbstractAndroidMojoTestCase<ApkMojo>
23  {
24  
25  	@Parameters
26  	static public List<Object[]> suite()
27  	{
28  		final List<Object[]> suite = new ArrayList<Object[]>();
29  
30  		suite.add( new Object[] { "apk-config-project1", null } );
31  		suite.add( new Object[] { "apk-config-project2", new String[] { "persistence.xml" } } );
32  		suite.add( new Object[] { "apk-config-project3", new String[] { "services/**", "persistence.xml" } } );
33  
34  		return suite;
35  	}
36  
37  	private final String	projectName;
38  
39  	private final String[]	expected;
40  
41  	public ApkMojoTest( String projectName, String[] expected )
42  	{
43  		this.projectName = projectName;
44  		this.expected = expected;
45  	}
46  
47  	@Override
48  	public String getPluginGoalName()
49  	{
50  		return "apk";
51  	}
52  
53  	@Override
54  	@Before
55  	public void setUp()
56  	throws Exception
57  	{
58  		super.setUp();
59  	}
60  
61  	@Override
62  	@After
63  	public void tearDown()
64  	throws Exception
65  	{
66  		super.tearDown();
67  	}
68  
69  	@Test
70  	public void testConfigHelper()
71  	throws Exception
72  	{
73  		final ApkMojo mojo = createMojo( this.projectName );
74  
75          final ConfigHandler cfh = new ConfigHandler( mojo, this.session, this.execution );
76  
77  		cfh.parseConfiguration();
78  
79  		final String[] includes = getFieldValue( mojo, "apkMetaIncludes" );
80  
81  		Assert.assertArrayEquals( this.expected, includes );
82  	}
83  
84  	protected <T> T getFieldValue( Object object, String fieldName )
85  	throws IllegalAccessException
86  	{
87  		return (T) super.getVariableValueFromObject( object, fieldName );
88  	}
89  
90  }