Permalink
Browse files

add unit test

  • Loading branch information...
1 parent a62ea35 commit a6aa00bcc693a005c24f9620cbb3106c845e1df9 @leejianwei committed Apr 7, 2012
@@ -89,5 +89,17 @@ public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
super.setApplicationContext(applicationContext);
}
+
+ Set<String> getJobNames(){
+ return this.jobNames;
+ }
+
+ boolean isWaitForJobs(){
+ return this.waitForJobs;
+ }
+
+ ApplicationContext getApplicationContext(){
+ return this.applicationContext;
+ }
}
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2011-2012 the original author or authors.
+ *
+ * Licensed 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.springframework.data.hadoop.mapreduce;
+
+import static org.junit.Assert.*;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * @author Jarred Li
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class HadoopJobDetailBeanTest {
+
+ @Autowired
+ private HadoopJobDetailBean jobDetailBean;
+
+ @Autowired
+ private ApplicationContext applicationContext;
+
+ /**
+ * Test method for {@link org.springframework.data.hadoop.mapreduce.HadoopJobDetailBean#afterPropertiesSet()}.
+ */
+ @Test
+ public void testAfterPropertiesSet() {
+ jobDetailBean.setApplicationContext(applicationContext);
+ assertNotNull(jobDetailBean.getApplicationContext());
+ }
+
+ /**
+ * Test method for {@link org.springframework.data.hadoop.mapreduce.HadoopJobDetailBean#setJobNames(java.util.Set)}.
+ */
+ @Test
+ public void testSetJobNames() {
+ Set<String> names = new HashSet<String>();
+ names.add("job1");
+ jobDetailBean.setJobNames(names);
+ assertEquals(1,jobDetailBean.getJobNames().size());
+ }
+
+ /**
+ * Test method for {@link org.springframework.data.hadoop.mapreduce.HadoopJobDetailBean#setWaitForJobs(boolean)}.
+ */
+ @Test
+ public void testSetWaitForJobs() {
+ jobDetailBean.setWaitForJobs(true);
+ assertTrue(jobDetailBean.isWaitForJobs());
+ }
+
+ /**
+ * Test method for {@link org.springframework.data.hadoop.mapreduce.HadoopJobDetailBean#setApplicationContext(org.springframework.context.ApplicationContext)}.
+ */
+ @Test
+ public void testSetApplicationContextApplicationContext() {
+ jobDetailBean.setApplicationContext(applicationContext);
+ assertNotNull(jobDetailBean.getApplicationContext());
+ }
+
+}
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2011-2012 the original author or authors.
+ *
+ * Licensed 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.springframework.data.hadoop.mapreduce;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * @author Jarred Li
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class ScheduledJobBeanTest {
+
+ @Autowired
+ private ScheduledJobBean jobBean;
+
+ @Test
+ public void test() {
+ assertNotNull(jobBean);
+ }
+
+}
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:hdp="http://www.springframework.org/schema/hadoop"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xmlns:p="http://www.springframework.org/schema/p"
+ xmlns:task="http://www.springframework.org/schema/task"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd
+ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
+ http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
+
+ <bean class="org.springframework.data.hadoop.mapreduce.HadoopJobDetailBean"/>
+
+</beans>
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:hdp="http://www.springframework.org/schema/hadoop"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xmlns:p="http://www.springframework.org/schema/p"
+ xmlns:task="http://www.springframework.org/schema/task"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd
+ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
+ http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
+
+ <bean class="org.springframework.data.hadoop.mapreduce.ScheduledJobBean"/>
+
+</beans>

0 comments on commit a6aa00b

Please sign in to comment.