Thursday, December 8, 2011

svn commit: r1212227 - in /labs/magnet/core/src/test/java/org/apache/labs/magnet/core: JiraAccessTest.java RestServiceTest.java RouteTest.java

Author: hadrian
Date: Fri Dec 9 02:34:32 2011
New Revision: 1212227

URL: http://svn.apache.org/viewvc?rev=1212227&view=rev
Log:
Split tests

Added:
labs/magnet/core/src/test/java/org/apache/labs/magnet/core/JiraAccessTest.java
labs/magnet/core/src/test/java/org/apache/labs/magnet/core/RestServiceTest.java
- copied, changed from r1212219, labs/magnet/core/src/test/java/org/apache/labs/magnet/core/RouteTest.java
Removed:
labs/magnet/core/src/test/java/org/apache/labs/magnet/core/RouteTest.java

Added: labs/magnet/core/src/test/java/org/apache/labs/magnet/core/JiraAccessTest.java
URL: http://svn.apache.org/viewvc/labs/magnet/core/src/test/java/org/apache/labs/magnet/core/JiraAccessTest.java?rev=1212227&view=auto
==============================================================================
--- labs/magnet/core/src/test/java/org/apache/labs/magnet/core/JiraAccessTest.java (added)
+++ labs/magnet/core/src/test/java/org/apache/labs/magnet/core/JiraAccessTest.java Fri Dec 9 02:34:32 2011
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.labs.magnet.core;
+
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.apache.labs.magnet.bbs.Bulletin;
+import org.junit.Test;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+
+public class JiraAccessTest extends CamelSpringTestSupport {
+
+ protected ClassPathXmlApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("META-INF/spring/beans.xml");
+ }
+
+ @Test
+ public void testFetchIssue() throws Exception {
+ Object reply = template.requestBodyAndHeader("direct://apache-jira", "", "BulletinId", "CAMEL-1000");
+ assert(reply instanceof Bulletin);
+ Bulletin b = assertIsInstanceOf(Bulletin.class, reply);
+ assertEquals("CAMEL-1000", b.getId());
+ assertEquals("http://issues.apache.org/jira/browse/CAMEL-1000", b.getLink());
+ assertNotNull(b.getSummary());
+ }
+}

Copied: labs/magnet/core/src/test/java/org/apache/labs/magnet/core/RestServiceTest.java (from r1212219, labs/magnet/core/src/test/java/org/apache/labs/magnet/core/RouteTest.java)
URL: http://svn.apache.org/viewvc/labs/magnet/core/src/test/java/org/apache/labs/magnet/core/RestServiceTest.java?p2=labs/magnet/core/src/test/java/org/apache/labs/magnet/core/RestServiceTest.java&p1=labs/magnet/core/src/test/java/org/apache/labs/magnet/core/RouteTest.java&r1=1212219&r2=1212227&rev=1212227&view=diff
==============================================================================
--- labs/magnet/core/src/test/java/org/apache/labs/magnet/core/RouteTest.java (original)
+++ labs/magnet/core/src/test/java/org/apache/labs/magnet/core/RestServiceTest.java Fri Dec 9 02:34:32 2011
@@ -23,31 +23,18 @@ import org.apache.http.client.methods.Ht
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
-import org.apache.labs.magnet.bbs.Bulletin;
-
import org.junit.Test;
-
import org.springframework.context.support.ClassPathXmlApplicationContext;


-public class RouteTest extends CamelSpringTestSupport {
+public class RestServiceTest extends CamelSpringTestSupport {

protected ClassPathXmlApplicationContext createApplicationContext() {
return new ClassPathXmlApplicationContext("META-INF/spring/beans.xml");
}

@Test
- public void testFetchIssue() throws Exception {
- Object reply = template.requestBodyAndHeader("direct://apache-jira", "", "BulletinId", "CAMEL-1000");
- assert(reply instanceof Bulletin);
- Bulletin b = assertIsInstanceOf(Bulletin.class, reply);
- assertEquals("CAMEL-1000", b.getId());
- assertEquals("http://issues.apache.org/jira/browse/CAMEL-1000", b.getLink());
- assertNotNull(b.getSummary());
- }
-
- @Test
- public void testRoute() throws Exception {
+ public void testAddBulletin() throws Exception {
HttpPost post = new HttpPost("http://localhost:9100/bbs");
StringEntity entity = new StringEntity("<bulletin xmlns=\"http://labs.apache.org/magnet\" id=\"CAMEL-1234\" />", "UTF-8");
entity.setContentType("text/xml; charset=UTF-8");
@@ -61,6 +48,9 @@ public class RouteTest extends CamelSpri
} finally {
httpclient.getConnectionManager().shutdown();
}
- Thread.sleep(1000);
+ // this code may execute faster than it takes for the oneway method to complete
+ // sleep a bit to give it time to finish
+ // TODO: could improve this by using a mock endpoint in a test environment only
+ Thread.sleep(500);
}
}

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org

No comments:

Post a Comment