Return-Path: X-Original-To: apmail-felix-commits-archive@www.apache.org Delivered-To: apmail-felix-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7CD6911235 for ; Sun, 15 Jun 2014 01:10:26 +0000 (UTC) Received: (qmail 25924 invoked by uid 500); 15 Jun 2014 01:10:26 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 25886 invoked by uid 500); 15 Jun 2014 01:10:26 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 25877 invoked by uid 99); 15 Jun 2014 01:10:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 15 Jun 2014 01:10:26 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 15 Jun 2014 01:10:24 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A3D0A23889F7; Sun, 15 Jun 2014 01:09:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1602640 - in /felix/trunk/scr/src/test: java/org/apache/felix/scr/integration/ resources/ Date: Sun, 15 Jun 2014 01:09:56 -0000 To: commits@felix.apache.org From: djencks@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140615010956.A3D0A23889F7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: djencks Date: Sun Jun 15 01:09:55 2014 New Revision: 1602640 URL: http://svn.apache.org/r1602640 Log: FELIX-4401 fix tests and test assumptions Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConcurrencyTest.java felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationChangeTest.java felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/TargetedPIDTest.java felix/trunk/scr/src/test/resources/integration_test_FELIX_4188_1.xml felix/trunk/scr/src/test/resources/integration_test_FELIX_4188_2.xml felix/trunk/scr/src/test/resources/integration_test_component_concurrency.xml Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java?rev=1602640&r1=1602639&r2=1602640&view=diff ============================================================================== --- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java (original) +++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java Sun Jun 15 01:09:55 2014 @@ -120,6 +120,7 @@ public class CircularReferenceTest exten A a = getServiceFromConfiguration(componentA, A.class); assertEquals( 1, a.getBs().size()); + delay(); //async binding of a to b after circular ref detected B b = getServiceFromConfiguration(componentB, B.class); assertEquals( 1, b.getAs().size() ); } @@ -130,7 +131,7 @@ public class CircularReferenceTest exten public void test_A11_B0n_delayed_B_first() throws InvalidSyntaxException { String componentNameA = "4.A.1.1.dynamic"; - final ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.SATISFIED ); + ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.SATISFIED ); String componentNameB = "4.B.0.n.dynamic"; final ComponentConfigurationDTO componentB = findComponentConfigurationByName( componentNameB, ComponentConfigurationDTO.SATISFIED); @@ -166,6 +167,8 @@ public class CircularReferenceTest exten // Object serviceA1 = bundleContext.getService( serviceReferenceA1 ); // assertNotNull( serviceA1 ); + //new component.id, refetch configuration. + componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.ACTIVE ); a = getServiceFromConfiguration(componentA, A.class); assertEquals( 1, a.getBs().size()); b = getServiceFromConfiguration(componentB, B.class); @@ -237,7 +240,7 @@ public class CircularReferenceTest exten public void test_A11_B01_delayed_B_first() throws InvalidSyntaxException { String componentNameA = "7.A.1.1.dynamic"; - final ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.SATISFIED ); + ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.SATISFIED ); String componentNameB = "7.B.0.1.dynamic"; final ComponentConfigurationDTO componentB = findComponentConfigurationByName( componentNameB, ComponentConfigurationDTO.SATISFIED ); @@ -274,6 +277,8 @@ public class CircularReferenceTest exten // Object serviceA1 = bundleContext.getService( serviceReferenceA1 ); // assertNotNull( serviceA1 ); + //new component.id, refetch configuration. + componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.ACTIVE ); a = getServiceFromConfiguration(componentA, A.class); assertEquals( 1, a.getBs().size()); b = getServiceFromConfiguration(componentB, B.class); Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConcurrencyTest.java URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConcurrencyTest.java?rev=1602640&r1=1602639&r2=1602640&view=diff ============================================================================== --- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConcurrencyTest.java (original) +++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConcurrencyTest.java Sun Jun 15 01:09:55 2014 @@ -31,11 +31,15 @@ public class ComponentConcurrencyTest ex // paxRunnerVmOption = DEBUG_VM_OPTION; descriptorFile = "/integration_test_component_concurrency.xml"; COMPONENT_PACKAGE = COMPONENT_PACKAGE + ".concurrency"; + restrictedLogging = true; + ignoredWarnings = new String[] {"FrameworkEvent: ERROR", + "FrameworkEvent ERROR", + "Could not get service from ref", + "Failed creating the component instance; see log for reason", + "Cannot create component instance due to failure to bind reference"}; + DS_LOGLEVEL = "warn"; } - @Inject - protected BundleContext bundleContext; - protected static void delay(int secs) { try @@ -56,16 +60,12 @@ public class ComponentConcurrencyTest ex ComponentConfigurationDTO ccC = getDisabledConfigurationAndEnable( "org.apache.felix.scr.integration.components.concurrency.CFactory", ComponentConfigurationDTO.ACTIVE ); delay( 30 ); - for ( Iterator it = log.foundWarnings().iterator(); it.hasNext();) + if ( ! log.foundWarnings().isEmpty() ) + { + TestCase.fail( "unexpected warning or error logged: " + log.foundWarnings() ); + } + for ( String message: log.foundWarnings() ) { - String message = ( String ) it.next(); - if ( message.contains( "FrameworkEvent ERROR" ) || - message.contains( "Could not get service from ref" ) || - message.contains( "Failed creating the component instance; see log for reason" ) || - message.contains( "Cannot create component instance due to failure to bind reference" )) - { - continue; - } TestCase.fail( "unexpected warning or error logged: " + message ); } } Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java?rev=1602640&r1=1602639&r2=1602640&view=diff ============================================================================== --- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java (original) +++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java Sun Jun 15 01:09:55 2014 @@ -127,6 +127,8 @@ public abstract class ComponentTestBase protected static boolean NONSTANDARD_COMPONENT_FACTORY_BEHAVIOR = false; protected volatile Log log; + + protected static String[] ignoredWarnings; //null unless you need it. //set to true to only get last 1000 lines of log. protected static boolean restrictedLogging; @@ -186,7 +188,7 @@ public abstract class ComponentTestBase @Before public void setUp() throws BundleException { - log = new Log(restrictedLogging); + log = new Log(restrictedLogging, ignoredWarnings); log.start(); bundleContext.addFrameworkListener( log ); bundleContext.registerService( LogService.class.getName(), log, null ); @@ -253,16 +255,16 @@ public abstract class ComponentTestBase { TestCase.fail("no ServiceComponentRuntime"); } - ComponentDescriptionDTO cd = scr.getComponentDescriptionDTO(bundle, name); - Collection ccs = scr.getComponentConfigurationDTOs(cd); - if (expected != -1) + ComponentDescriptionDTO cd = scr.getComponentDescriptionDTO(b, name); + Collection ccs = scr.getComponentConfigurationDTOs(cd); + if (expected != -1) + { + for (ComponentConfigurationDTO cc: ccs) { - for (ComponentConfigurationDTO cc: ccs) - { - Assert.assertEquals( "for ComponentConfiguration name: " + cc.description.name + " properties" + cc.properties + "Expected state " + STATES.get(expected) + " but was " + STATES.get(cc.state), expected, cc.state); - } + Assert.assertEquals( "for ComponentConfiguration name: " + cc.description.name + " properties" + cc.properties + "Expected state " + STATES.get(expected) + " but was " + STATES.get(cc.state), expected, cc.state); } - return ccs; + } + return ccs; } protected Collection findComponentConfigurationsByName( String name, int expected ) @@ -895,6 +897,7 @@ public abstract class ComponentTestBase private volatile Thread m_logThread; private volatile PrintStream m_realOut; private volatile PrintStream m_realErr; + private String[] ignoredWarnings; protected Throwable firstFrameworkThrowable; @@ -902,9 +905,10 @@ public abstract class ComponentTestBase private final String[] log = new String[1000]; private int i = 0; - public Log( boolean restrictedLogging ) + public Log( boolean restrictedLogging, String[] ignoredWarnings ) { this.restrictedLogging = restrictedLogging; + this.ignoredWarnings = ignoredWarnings; } public void start() @@ -971,7 +975,7 @@ public abstract class ComponentTestBase entry = m_logQueue.take(); if ( entry.getLevel() <= 2 ) { - if ( m_warnings.size() < 1024 ) + if ( m_warnings.size() < 1024 && acceptWarning( entry.getMessage() ) ) { m_warnings.add( entry.getMessage() ); } @@ -1017,7 +1021,19 @@ public abstract class ComponentTestBase // ------------- FrameworkListener ----------------------------------------------------------- - public void frameworkEvent( final FrameworkEvent event ) + private boolean acceptWarning(String message) { + if ( ignoredWarnings != null ) + { + for (String ignore : ignoredWarnings) { + if (message.contains(ignore)) { + return false; + } + } + } + return true; + } + + public void frameworkEvent( final FrameworkEvent event ) { int eventType = event.getType(); String msg = getFrameworkEventMessage( eventType ); Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationChangeTest.java URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationChangeTest.java?rev=1602640&r1=1602639&r2=1602640&view=diff ============================================================================== --- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationChangeTest.java (original) +++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationChangeTest.java Sun Jun 15 01:09:55 2014 @@ -110,7 +110,8 @@ public class ConfigurationChangeTest ext theConfig.put("ref.target", "(value=srv1)"); configure( pid ); - + delay();//all cm event to complete + getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE); final SimpleComponent comp10 = SimpleComponent.INSTANCE; TestCase.assertNotNull( comp10 ); @@ -212,7 +213,8 @@ public class ConfigurationChangeTest ext theConfig.put("ref.target", "(value=srv1)"); configure( pid ); - + delay();//let cm thread finish before enabling. + getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE); final SimpleComponent comp10 = SimpleComponent.INSTANCE; Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java?rev=1602640&r1=1602639&r2=1602640&view=diff ============================================================================== --- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java (original) +++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java Sun Jun 15 01:09:55 2014 @@ -49,9 +49,9 @@ public class Felix4188Test extends Compo static { // uncomment to enable debugging of this test class - // paxRunnerVmOption = DEBUG_VM_OPTION; +// paxRunnerVmOption = DEBUG_VM_OPTION; descriptorFile = "/integration_test_FELIX_4188.xml"; - restrictedLogging = true; +// restrictedLogging = true; //comment to get debug logging if the test fails. // DS_LOGLEVEL = "warn"; } @@ -62,19 +62,19 @@ public class Felix4188Test extends Compo @Test public void test_concurrent_deactivation() throws Exception { - final Bundle bundle1 = installBundle("/integration_test_FELIX_4188_1.xml", "", "simplecomponent1"); + final Bundle bundle1 = installBundle("/integration_test_FELIX_4188_1.xml", "org.apache.felix.scr.integration.components", "simplecomponent1"); bundle1.start(); - final Bundle bundle2 = installBundle("/integration_test_FELIX_4188_2.xml", "", "simplecomponent2"); + final Bundle bundle2 = installBundle("/integration_test_FELIX_4188_2.xml", "org.apache.felix.scr.integration.components", "simplecomponent2"); bundle2.start(); final ComponentConfigurationDTO aComp1 = - findComponentConfigurationByName( bundle1, "org.apache.felix.scr.integration.components.Felix4188Component-1", ComponentConfigurationDTO.ACTIVE); - final Felix4188Component aInst1 = getServiceFromConfiguration(aComp1, Felix4188Component.class); + findComponentConfigurationByName( bundle1, "org.apache.felix.scr.integration.components.Felix4188Component-1", ComponentConfigurationDTO.SATISFIED); + final Object aInst1 = getServiceFromConfiguration(aComp1, Felix4188Component.class); final ComponentConfigurationDTO aComp2 = - findComponentConfigurationByName( bundle1, "org.apache.felix.scr.integration.components.Felix4188Component-2", ComponentConfigurationDTO.ACTIVE); - final Felix4188Component aInst2 = getServiceFromConfiguration(aComp2, Felix4188Component.class); + findComponentConfigurationByName( bundle2, "org.apache.felix.scr.integration.components.Felix4188Component-2", ComponentConfigurationDTO.SATISFIED); + final Object aInst2 = getServiceFromConfiguration(aComp2, Felix4188Component.class); final CountDownLatch latch = new CountDownLatch(1); Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/TargetedPIDTest.java URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/TargetedPIDTest.java?rev=1602640&r1=1602639&r2=1602640&view=diff ============================================================================== --- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/TargetedPIDTest.java (original) +++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/TargetedPIDTest.java Sun Jun 15 01:09:55 2014 @@ -88,6 +88,8 @@ public class TargetedPIDTest extends Com Configuration configSNVL = configure( pidSNVL ); configSNVL.setBundleLocation( REGION ); + delay(); + //Add more and more specific components to check that they pick up the appropriate configuration Set known = new HashSet(); Modified: felix/trunk/scr/src/test/resources/integration_test_FELIX_4188_1.xml URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/resources/integration_test_FELIX_4188_1.xml?rev=1602640&r1=1602639&r2=1602640&view=diff ============================================================================== --- felix/trunk/scr/src/test/resources/integration_test_FELIX_4188_1.xml (original) +++ felix/trunk/scr/src/test/resources/integration_test_FELIX_4188_1.xml Sun Jun 15 01:09:55 2014 @@ -14,7 +14,7 @@ name='org.apache.felix.scr.integration.components.Felix4188Component-1' activate='start' deactivate='stop'> - org.apache.felix.scr.integration.components.felix4188.Felix4188Component + Modified: felix/trunk/scr/src/test/resources/integration_test_FELIX_4188_2.xml URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/resources/integration_test_FELIX_4188_2.xml?rev=1602640&r1=1602639&r2=1602640&view=diff ============================================================================== --- felix/trunk/scr/src/test/resources/integration_test_FELIX_4188_2.xml (original) +++ felix/trunk/scr/src/test/resources/integration_test_FELIX_4188_2.xml Sun Jun 15 01:09:55 2014 @@ -14,7 +14,7 @@ name='org.apache.felix.scr.integration.components.Felix4188Component-2' activate='start' deactivate='stop'> - org.apache.felix.scr.integration.components.felix4188.Felix4188Component + Modified: felix/trunk/scr/src/test/resources/integration_test_component_concurrency.xml URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/resources/integration_test_component_concurrency.xml?rev=1602640&r1=1602639&r2=1602640&view=diff ============================================================================== --- felix/trunk/scr/src/test/resources/integration_test_component_concurrency.xml (original) +++ felix/trunk/scr/src/test/resources/integration_test_component_concurrency.xml Sun Jun 15 01:09:55 2014 @@ -12,7 +12,7 @@ + factory='AFactory' activate='start'>