Effective October 27, 2012, online and email support for FuseSource products will move to Red Hat support channels. For more information, please see the JIRA Migration to Red Hat FAQ.
As of October 27th, please open all new issues in the Red Hat Customer Portal .
Issue Details (XML | Word | Printable)

Key: ECLIPSE-47
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Lars Heinemann
Reporter: Claus Ibsen
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Fuse IDE

Creating new Camel Test Case - Should add camel-test dependency

Created: 25/Jan/11 12:47 PM   Updated: 04/Nov/11 04:39 PM
Component/s: Camel Editor
Affects Version/s: None
Fix Version/s: 2.1.0


 Description  « Hide
When you use the create Camel Test Case, to create a junit test for your Camel app. Then at some point in the wizard it suggest to add JUnit 4 to the "classpath".

1)
I think the first problem is that junit could already be added as a "Maven dependency".

<!-- for testing -->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<scope>test</scope>
		</dependency>

Which I already have.

2)
I have problem selecting the Camel XML file I want to use for creating an unit test.
If I select it using the wizard, the selection is not "returned" back to the main wizard. And thus its empty.
If I manually type the XML file name, it doesn't matter.

3)
The generated source may look like (code to load XML file is not present, could be because of #2)

package org.apache.camel.example.spring;

import static org.junit.Assert.*;

import org.apache.camel.test.junit4.CamelSpringTestSupport;

public class MyCoolTest extends CamelSpringTestSupport {

}

The import org.apache.camel.test.junit4.CamelSpringTestSupport; is from camel-test component.

So if the wizard could suggest or auto-add that dependency. But it should be added to the maven dependency in the pom.xml file.
I dont know if that is ever possible, as maven isn't native supported in eclipse.



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Claus Ibsen added a comment - 25/Jan/11 12:48 PM
btw I copied the camel-example-spring from the camel trunk to my eclipse workspace, and loaded it as a Maven project.

Claus Ibsen added a comment - 25/Jan/11 12:55 PM
Ah if I typed the full path for the XML file src/main/resources/META-INF/spring/camel-context.xml then the Create Camel Test wizard, generated source code which loads the xml file
/**
 * 
 */
package org.apache.camel.example.spring;

import static org.junit.Assert.*;

import org.apache.camel.EndpointInject;
import org.apache.camel.Produce;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.junit4.CamelSpringTestSupport;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author davsclaus
 *
 */
public class MyOtherCoolTest extends CamelSpringTestSupport {

	/* (non-Javadoc)
	 * @see org.apache.camel.test.junit4.CamelSpringTestSupport#setUp()
	 */
	@Before
	public void setUp() throws Exception {
		super.setUp();
	}

	@Test
	public void testCamelRoute() throws Exception {

		// define some expectations
		// TODO add some expectations here!!

		assertMockEndpointsSatisfied();
	}

	@Override
	protected ClassPathXmlApplicationContext createApplicationContext() {
		return new ClassPathXmlApplicationContext(
				"src/main/resources/META-INF/spring/camel-context.xml");
	}

}

Claus Ibsen added a comment - 11/Jul/11 01:19 PM
This is still a problem in 1.1.71.

The wizard asks about adding JUnit4, but it should also ask about camel-test artifact as well.


Claus Ibsen added a comment - 11/Jul/11 01:20 PM
Well in fact the wizard should only ask about adding camel-test as it got dependency on junit.

Lars Heinemann added a comment - 04/Nov/11 02:19 PM
camel-test is now added as scope "test" dependency if not already there.

James Strachan added a comment - 04/Nov/11 04:15 PM
its looking great now thanks!

One minor nit - after hitting Finish on the wizard the test case is created; its got red squiggles due to missing imports - and the pom.xml is updated to reflect the new camel-test dependency.

As soon as I double click on the pom.xml it recognises its changed & fires a build & the red squiggles go away.

I wonder could we fire a build/refresh of pom.xml in the IDE when we've updated it? Then the red squiggles should automatically disappear without the user doing anything. i.e. after pressing "Finish" on the wizard the IDE should show the newly created test case and the red squiggles should disappear as the IDE does a refresh/build on pom.xml


James Strachan added a comment - 04/Nov/11 04:17 PM
I just created a new camel-activemq project, created a test case from the camel-context.xml, then hit Finish - got the red squiggles, then I right clicked on the pom.xml and hit "refresh" and it noticed it'd changed and the red squiggles went. So I think just a refresh on pom.xml would do the trick.

James Strachan added a comment - 04/Nov/11 04:39 PM
Its a one liner, so I just added a refresh in there and it works perfectly now - thanks Lars!