Skip to content

Commit

Permalink
[MNG-7138] Proper verify of plugin configuration Bean set method call
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski committed Nov 10, 2021
1 parent c1344c0 commit 3314a24
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
* under the License.
*/

import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;

import java.io.File;
Expand Down Expand Up @@ -95,6 +94,7 @@ public void testitMNG3827()

assertEquals( "field", props.getProperty( "beanParam.fieldParam" ) );
assertEquals( "setter", props.getProperty( "beanParam.setterParam" ) );
assertEquals( "false", props.getProperty( "beanParam.setCalled" ) );
assertEquals( "true", props.getProperty( "beanParam.setterCalled" ) );

assertEquals( "4", props.getProperty( "domParam.children" ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
* under the License.
*/

import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;

import java.io.File;
Expand Down Expand Up @@ -95,6 +94,7 @@ public void testitMNG3864()

assertEquals( "field", props.getProperty( "beanParam.fieldParam" ) );
assertEquals( "setter", props.getProperty( "beanParam.setterParam" ) );
assertEquals( "false", props.getProperty( "beanParam.setCalled" ) );
assertEquals( "true", props.getProperty( "beanParam.setterCalled" ) );

assertEquals( "4", props.getProperty( "domParam.children" ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
* under the License.
*/

import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;

import java.io.File;
Expand Down Expand Up @@ -54,7 +53,8 @@ public void testit()

Properties props = verifier.loadProperties( "target/config.properties" );
assertEquals( "PASSED", props.getProperty( "beanParam.fieldParam" ) );
assertEquals( "true", props.getProperty( "beanParam.setterCalled" ) );
assertEquals( "true", props.getProperty( "beanParam.setCalled" ) );
assertEquals( "false", props.getProperty( "beanParam.setterCalled" ) );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,20 @@ public class Bean

String setterParam;

/**
* default method of bean was called
*/
boolean setCalled;

/**
* setter method of ben was called
*/
boolean setterCalled;

public void set( String value )
{
fieldParam = value;
setterCalled = true;
setCalled = true;
}

public void setSetterParam( String value )
Expand All @@ -49,7 +57,7 @@ public void setSetterParam( String value )
public String toString()
{
return getClass().getName() + "[fieldParam=" + fieldParam + ", setterParam=" + setterParam
+ ", setterCalled=" + setterCalled + "]";
+ ", setterCalled=" + setterCalled + ", setCalled=" + setCalled + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ public class ConfigMojo
*
* @parameter
*/

private Bean beanParam;

/**
Expand Down Expand Up @@ -335,6 +336,7 @@ private void dumpConfiguration( Properties props )
{
PropertiesUtil.serialize( props, "beanParam.fieldParam", beanParam.fieldParam );
PropertiesUtil.serialize( props, "beanParam.setterParam", beanParam.setterParam );
PropertiesUtil.serialize( props, "beanParam.setCalled", beanParam.setCalled );
PropertiesUtil.serialize( props, "beanParam.setterCalled", beanParam.setterCalled );
}
}
Expand Down

0 comments on commit 3314a24

Please sign in to comment.