Hi Mehmet, Hi Ahmet-Serda be aware of what you actually want to test in your. You probably don't want to test the correct behaviour of our SMACK library or the rooster object itself, nether the Injecttion via Picocontainer, but your modified add contact function. You can mock all needed dependencies in your test (F.e. State facade). Therefor we often use the Easymock library [1].
An example of the usage be found here [2]. (Again not yet in the master, but an working example of an JUnit test inside the UI - PROJECT that uses movkes). You can also do find some examples in the saros - eclipse project just search for library usages. Bests Matthias Bohnstedt [1] http://easymock.org/getting-started.html [2] http://saros-build.imp.fu-berlin.de/gerrit/#/c/2749/11/de.fu_berlin.inf.dpp.ui/test/junit/de/fu_berlin/inf/dpp/ui/manager/ProjectListManagerTest.java -------- Ursprüngliche Nachricht -------- Von: Mehmet Bayram <mehmetbay...@zedat.fu-berlin.de> Datum: 10.11.2015 17:36 (GMT+01:00) An: dpp-devel@lists.sourceforge.net Betreff: [DPP-Devel] Bug 857 Greetings, We work to fix this bug (http://sourceforge.net/p/dpp/bugs/857/) and would like to write some JUnit test cases. But we can't access the Roster. We tried it like this: @Test public void testAddContact() { PicoBuilder picoBuilder = new PicoBuilder(new CompositeInjection( new ConstructorInjection(), new AnnotatedFieldInjection())) .withCaching().withLifecycle(); MutablePicoContainer container = picoBuilder.build(); new HTMLUIContextFactory().createComponents(container); StateFacade stateFacade = container.getComponent(StateFacade.class); Connection connection = stateFacade.getConnectionService() .getConnection(); Roster roster = connection.getRoster(); try { roster.createEntry("a...@def.ghi", "AB C", null); roster.createEntry("x...@def.ghi", "XY Z", null); } catch (XMPPException e) { // TODO Auto-generated catch block } If we would have a roster object, we would not try to create it like above. But if we try to create one, we get the following error: org.picocontainer.injectors.AbstractInjector$UnsatisfiableDependenciesException: de.fu_berlin.inf.dpp.ui.core_facades.StateFacade has unsatisfied dependency: class de.fu_berlin.inf.dpp.communication.connection.ConnectionHandler among unsatisfiable dependencies: [[class de.fu_berlin.inf.dpp.communication.connection.ConnectionHandler, class de.fu_berlin.inf.dpp.net.xmpp.XMPPConnectionService, class de.fu_berlin.inf.dpp.account.XMPPAccountStore]] where org.picocontainer.DefaultPicoContainer@6513cf0:15<(empty) was the leaf container being asked for dependencies. at org.picocontainer.injectors.ConstructorInjector.getGreediestSatisfiableConstructor(ConstructorInjector.java:188) at org.picocontainer.injectors.ConstructorInjector.getGreediestSatisfiableConstructor(ConstructorInjector.java:110) at org.picocontainer.injectors.ConstructorInjector.access$100(ConstructorInjector.java:51) at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:308) at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:268) at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:341) at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56) at org.picocontainer.injectors.CompositeInjector.getComponentInstance(CompositeInjector.java:42) at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56) at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64) at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91) at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:691) at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:645) at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:670) at de.fu_berlin.inf.dpp.ui.core_facades.StateFacadeTest.testAddContact(StateFacadeTest.java:24) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) any help would be appreciated. Best regards Ahmet-Serdar Karakaya Mehmet Bayram ------------------------------------------------------------------------------ _______________________________________________ DPP-Devel mailing list DPP-Devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dpp-devel
------------------------------------------------------------------------------
_______________________________________________ DPP-Devel mailing list DPP-Devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dpp-devel