You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Tommy Chheng <to...@gmail.com> on 2011/07/14 20:21:03 UTC

CamelTestSupport template variable missing/changed in 2.8.0?

I'm testing the latest 2.8.0 on my current application.

In Camel 2.7.2, I was able to reference template when I extend
CamelTestSupport
class PublishRequestTest extends CamelTestSupport{
  @Test
  def testValidRequest{
    val mock = getMockEndpoint("mock:output")

    val message = """{"username":"bob","permalink":"perma"}"""
    template.sendBody("seda:input", message)

In Camel 2.8.0, I get a template value missing error:

[ERROR] PublishRequestTest.scala:18: error: not found: value template
[INFO]     template.sendBody("seda:input", message)


Is this the expected behavior? If so, how should i reference a template
object in a test environment?


-- 
@tommychheng
http://tommy.chheng.com

Re: CamelTestSupport template variable missing/changed in 2.8.0?

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

I just created a JIRA[1] and submit a patch for it.
[1]https://issues.apache.org/jira/browse/CAMEL-4229

On 7/15/11 7:22 AM, Tommy Chheng wrote:
> Unfortunately, making the template variable protected static breaks in
> Scala.
>
> See:
> http://stackoverflow.com/questions/4445617/calling-a-protected-static-java-method-from-scala
>
> Is there a way to make this Scala compatible while still reaping the
> performance benefits?
>
>
>
> On Thu, Jul 14, 2011 at 3:06 PM, Richard Kettelerij<
> richardkettelerij@gmail.com>  wrote:
>
>> The only change I can spot between 2.7 and 2.8 concerning the template
>> variable is that in 2.8 the template variable is made "static". This is the
>> result of https://issues.apache.org/jira/browse/CAMEL-3960. But
>> referencing
>> a protected static variable in a superclass from a method in a child class
>> shouldn't be a problem.
>>
>> Take a look at the Camel unit tests, the template variable is referenced
>> all
>> the time.
>>
>> On Thu, Jul 14, 2011 at 8:21 PM, Tommy Chheng<tommy.chheng@gmail.com
>>> wrote:
>>
>>> I'm testing the latest 2.8.0 on my current application.
>>>
>>> In Camel 2.7.2, I was able to reference template when I extend
>>> CamelTestSupport
>>> class PublishRequestTest extends CamelTestSupport{
>>>   @Test
>>>   def testValidRequest{
>>>     val mock = getMockEndpoint("mock:output")
>>>
>>>     val message = """{"username":"bob","permalink":"perma"}"""
>>>     template.sendBody("seda:input", message)
>>>
>>> In Camel 2.8.0, I get a template value missing error:
>>>
>>> [ERROR] PublishRequestTest.scala:18: error: not found: value template
>>> [INFO]     template.sendBody("seda:input", message)
>>>
>>>
>>> Is this the expected behavior? If so, how should i reference a template
>>> object in a test environment?
>>>
>>>
>>> --
>>> @tommychheng
>>> http://tommy.chheng.com
>>>
>>
>
>
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang

Re: CamelTestSupport template variable missing/changed in 2.8.0?

Posted by Tommy Chheng <to...@gmail.com>.
Unfortunately, making the template variable protected static breaks in
Scala.

See:
http://stackoverflow.com/questions/4445617/calling-a-protected-static-java-method-from-scala

Is there a way to make this Scala compatible while still reaping the
performance benefits?



On Thu, Jul 14, 2011 at 3:06 PM, Richard Kettelerij <
richardkettelerij@gmail.com> wrote:

> The only change I can spot between 2.7 and 2.8 concerning the template
> variable is that in 2.8 the template variable is made "static". This is the
> result of https://issues.apache.org/jira/browse/CAMEL-3960. But
> referencing
> a protected static variable in a superclass from a method in a child class
> shouldn't be a problem.
>
> Take a look at the Camel unit tests, the template variable is referenced
> all
> the time.
>
> On Thu, Jul 14, 2011 at 8:21 PM, Tommy Chheng <tommy.chheng@gmail.com
> >wrote:
>
> > I'm testing the latest 2.8.0 on my current application.
> >
> > In Camel 2.7.2, I was able to reference template when I extend
> > CamelTestSupport
> > class PublishRequestTest extends CamelTestSupport{
> >  @Test
> >  def testValidRequest{
> >    val mock = getMockEndpoint("mock:output")
> >
> >    val message = """{"username":"bob","permalink":"perma"}"""
> >    template.sendBody("seda:input", message)
> >
> > In Camel 2.8.0, I get a template value missing error:
> >
> > [ERROR] PublishRequestTest.scala:18: error: not found: value template
> > [INFO]     template.sendBody("seda:input", message)
> >
> >
> > Is this the expected behavior? If so, how should i reference a template
> > object in a test environment?
> >
> >
> > --
> > @tommychheng
> > http://tommy.chheng.com
> >
>



-- 
@tommychheng
http://tommy.chheng.com

Re: CamelTestSupport template variable missing/changed in 2.8.0?

Posted by Richard Kettelerij <ri...@gmail.com>.
The only change I can spot between 2.7 and 2.8 concerning the template
variable is that in 2.8 the template variable is made "static". This is the
result of https://issues.apache.org/jira/browse/CAMEL-3960. But referencing
a protected static variable in a superclass from a method in a child class
shouldn't be a problem.

Take a look at the Camel unit tests, the template variable is referenced all
the time.

On Thu, Jul 14, 2011 at 8:21 PM, Tommy Chheng <to...@gmail.com>wrote:

> I'm testing the latest 2.8.0 on my current application.
>
> In Camel 2.7.2, I was able to reference template when I extend
> CamelTestSupport
> class PublishRequestTest extends CamelTestSupport{
>  @Test
>  def testValidRequest{
>    val mock = getMockEndpoint("mock:output")
>
>    val message = """{"username":"bob","permalink":"perma"}"""
>    template.sendBody("seda:input", message)
>
> In Camel 2.8.0, I get a template value missing error:
>
> [ERROR] PublishRequestTest.scala:18: error: not found: value template
> [INFO]     template.sendBody("seda:input", message)
>
>
> Is this the expected behavior? If so, how should i reference a template
> object in a test environment?
>
>
> --
> @tommychheng
> http://tommy.chheng.com
>