Even i am facing almost the same issue.I am not able to load config files 
using  *"class MyTestSpec extends TestKit(ActorSystem("*

*MyActorSystem", ConfigFactory.load()))*


Could you please provide pointers how to specify 
 -Dconfig.file=... VM parameter when running testcase.I have couple files 
to be specified.I am a newbie to scala and akka.


On Thursday, 29 March 2012 11:51:27 UTC-5, h3nk3 wrote:
>
> On Thu, Mar 29, 2012 at 16:58, Sergey Malov <sma...@mdialog.com 
> <javascript:>> wrote:
> > Hi Henrik,
> > Thanks for your reply, however one do not normally define ActorSystem in 
> a test suite which extends TestKit which is necessary to get access to 
> TestActorRef.  I am not even sure it is possible. Sorry, I probably was not 
> too clear about it.
>
> It is possible to use TestActorRef without extending TestKit - see gists 
> below.
>
> > Instead it is defined in a test class definition like this:
> >
> >        class MyTestSpec extends TestKit(ActorSystem("MyActorSystem")) { 
> … }
> >
> > However adding configuration like one would normally do in a code:
> >
> >        class MyTestSpec extends TestKit(ActorSystem("MyActorSystem", 
> ConfigFactory.load())) {
> >                …
> >                val actor = TestActorRef(new ServiceActor(val))
> >                …
> >        }
> >
> > doesn't work - ServiceActor fails to instantiate due to inability to 
> find configuration settings.
> >
>
> Make sure you use the -Dconfig.file=... VM parameter when you run your
> test in order to make ConfigFactory.load() work.
> Your issue seems to be related to this somehow. I can specify a
> specific file and use ConfigFactory.load().
>
> I have created some gists that you can have a look at for more information.
> https://gist.github.com/2239521
> https://gist.github.com/2239565
>
> Hope this solves your problem. Otherwise just let me know and we will
> eventually fix it.
> Cheers
> //Henrik
>
> > Thanks,
> >
> > Sergey
> >
> > On 2012-03-28, at 5:37 PM, Henrik Engström wrote:
> >
> >> Hello Sergey,
> >> See inline comment.
> >>
> >> On Wed, Mar 28, 2012 at 18:24, Sergey Malov <sma...@mdialog.com 
> <javascript:>> wrote:
> >>> In my test case I create reference for an actor being tested like:
> >>>
> >>>        val actor = TestActorRef(new ServiceActor(val)) (1)
> >>>
> >>> However ServiceActor get some of its settings from configuration file, 
> supplied to it through the ActorSystem("Name", config) in a real 
> application.
> >>>
> >>> Thus attempt to create actor like on line (1) causes an 
> com.typesafe.config.ConfigException$Missing exception.
> >>>
> >>> How can I inject my custom config into the unit test ?
> >>
> >> You can populate the actor system with a specific config values when
> >> you create it, e.g.:
> >> val system = ActorSystem("TestSystem", ConfigFactory.parseString(""" {
> >> awesome.movie = "The Big Lebowski" } """))
> >>
> >> HTH
> >> Henrik
> >>
> >>>
> >>> Thanks,
> >>> Sergey
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google 
> Groups "Akka User List" group.
> >>> To post to this group, send email to akka...@googlegroups.com 
> <javascript:>.
> >>> To unsubscribe from this group, send email to 
> akka-user+...@googlegroups.com <javascript:>.
> >>> For more options, visit this group at 
> http://groups.google.com/group/akka-user?hl=en.
> >>>
> >>
> >> --
> >> You received this message because you are subscribed to the Google 
> Groups "Akka User List" group.
> >> To post to this group, send email to akka...@googlegroups.com 
> <javascript:>.
> >> To unsubscribe from this group, send email to 
> akka-user+...@googlegroups.com <javascript:>.
> >> For more options, visit this group at 
> http://groups.google.com/group/akka-user?hl=en.
> >>
> >
> > --
> > You received this message because you are subscribed to the Google 
> Groups "Akka User List" group.
> > To post to this group, send email to akka...@googlegroups.com 
> <javascript:>.
> > To unsubscribe from this group, send email to 
> akka-user+...@googlegroups.com <javascript:>.
> > For more options, visit this group at 
> http://groups.google.com/group/akka-user?hl=en.
> >
>
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to