1414package org .eclipse .pde .api .tools .builder .tests .usage ;
1515
1616import org .eclipse .core .runtime .IPath ;
17+ import org .eclipse .core .runtime .IStatus ;
18+ import org .eclipse .core .runtime .Status ;
19+ import org .eclipse .core .runtime .preferences .IEclipsePreferences .IPreferenceChangeListener ;
20+ import org .eclipse .core .runtime .preferences .IEclipsePreferences .PreferenceChangeEvent ;
21+ import org .eclipse .core .runtime .preferences .InstanceScope ;
1722import org .eclipse .pde .api .tools .internal .problems .ApiProblemFactory ;
23+ import org .eclipse .pde .api .tools .internal .provisional .ApiPlugin ;
1824import org .eclipse .pde .api .tools .internal .provisional .descriptors .IElementDescriptor ;
1925import org .eclipse .pde .api .tools .internal .provisional .problems .IApiProblem ;
26+ import org .eclipse .pde .api .tools .internal .provisional .problems .IApiProblemTypes ;
2027import org .eclipse .pde .api .tools .model .tests .TestSuiteHelper ;
2128
2229import junit .framework .Test ;
3037 */
3138public class DependentUsageTests extends UsageTest {
3239
40+ private static final IPreferenceChangeListener PREFERENCE_LISTENER = new PreferenceListener ();
41+
3342 static final String WITHOUTTAG = "withouttag" ; //$NON-NLS-1$
3443 static final String WITHTAG = "withtag" ; //$NON-NLS-1$
3544 static final IPath C_PATH = IPath .fromOSString ("/refproject/src/c/" ); //$NON-NLS-1$
@@ -47,6 +56,21 @@ public static Test suite() {
4756 return buildTestSuite (DependentUsageTests .class );
4857 }
4958
59+ @ Override
60+ protected void setUp () throws Exception {
61+ super .setUp ();
62+ InstanceScope .INSTANCE .getNode (ApiPlugin .PLUGIN_ID ).addPreferenceChangeListener (PREFERENCE_LISTENER );
63+ }
64+
65+ @ Override
66+ protected void tearDown () throws Exception {
67+ try {
68+ InstanceScope .INSTANCE .getNode (ApiPlugin .PLUGIN_ID ).removePreferenceChangeListener (PREFERENCE_LISTENER );
69+ } finally {
70+ super .tearDown ();
71+ }
72+ }
73+
5074 @ Override
5175 protected int getDefaultProblemId () {
5276 return 0 ;
@@ -461,4 +485,18 @@ private void test12(boolean addtag) throws Exception {
461485 });
462486 deployTest ("test12" , XYZ_PATH , MPPATH , "mpClassRef.java" , addtag ); //$NON-NLS-1$ //$NON-NLS-2$
463487 }
488+
489+ private static class PreferenceListener implements IPreferenceChangeListener {
490+ @ Override
491+ public void preferenceChange (PreferenceChangeEvent event ) {
492+ String key = event .getKey ();
493+ Object value = event .getNewValue ();
494+ if (IApiProblemTypes .MISSING_DEFAULT_API_BASELINE .equals (key ) && !ApiPlugin .VALUE_IGNORE .equals (value )) {
495+ String message = "Value of \" " + IApiProblemTypes .MISSING_DEFAULT_API_BASELINE + "\" set to: " + value ; //$NON-NLS-1$//$NON-NLS-2$
496+ IStatus info = new Status (IStatus .INFO , ApiPlugin .PLUGIN_ID , message ,
497+ new RuntimeException ("stack trace info" )); //$NON-NLS-1$
498+ ApiPlugin .log (info );
499+ }
500+ }
501+ }
464502}
0 commit comments