@Test public void testLoadXml() throws Exception { OozieJobExecutorJobEntry jobEntry = new OozieJobExecutorJobEntry(); OozieJobExecutorConfig jobConfig = new OozieJobExecutorConfig(); jobConfig.setOozieWorkflow("hdfs://localhost:9000/user/test-user/oozie/workflow.xml"); jobConfig.setOozieWorkflowConfig("file:///User/test-user/oozie/job.properties"); jobConfig.setOozieUrl("http://localhost:11000/oozie"); jobEntry.setJobConfig(jobConfig); JobEntryCopy jec = new JobEntryCopy(jobEntry); jec.setLocation(0, 0); String xml = jec.getXML(); Document d = XMLHandler.loadXMLString(xml); OozieJobExecutorJobEntry jobEntry2 = new OozieJobExecutorJobEntry(); jobEntry2.loadXML(d.getDocumentElement(), null, null, null); OozieJobExecutorConfig jobConfig2 = jobEntry2.getJobConfig(); assertEquals(jobConfig.getOozieWorkflow(), jobConfig2.getOozieWorkflow()); assertEquals(jobConfig.getOozieWorkflowConfig(), jobConfig2.getOozieWorkflowConfig()); assertEquals(jobConfig.getOozieUrl(), jobConfig2.getOozieUrl()); }
@Test public void testGetValidationWarnings_emptyConfig() throws Exception { OozieJobExecutorConfig config = new OozieJobExecutorConfig(); OozieJobExecutorJobEntry je = new OozieJobExecutorJobEntry(); List<String> warnings = je.getValidationWarnings(config); assertEquals(3, warnings.size()); }
@Test public void testGetValidationWarnings_everythingIsGood() throws Exception { OozieJobExecutorJobEntry je = new TestOozieJobExecutorJobEntry(getSucceedingTest()); OozieJobExecutorConfig config = new OozieJobExecutorConfig(); config.setOozieUrl( "http://localhost:11000/oozie"); // don't worry if it isn't running, we fake out our test // connection to it anyway config.setOozieWorkflowConfig("file:///test/job.properties"); config.setJobEntryName("name"); List<String> warnings = je.getValidationWarnings(config); assertEquals(0, warnings.size()); }
@Test public void testGetValidationWarnings_invalidOozieUrl() throws Exception { OozieJobExecutorConfig config = new OozieJobExecutorConfig(); OozieJobExecutorJobEntry je = new OozieJobExecutorJobEntry(); config.setOozieUrl("bad url"); config.setOozieWorkflowConfig("file:///test/job.properties"); config.setJobEntryName("name"); List<String> warnings = je.getValidationWarnings(config); assertEquals(1, warnings.size()); assertEquals( BaseMessages.getString( OozieJobExecutorJobEntry.class, "ValidationMessages.Invalid.Oozie.URL"), warnings.get(0)); }
@Test public void testGetValidationWarnings_incompatibleVersions() throws Exception { OozieJobExecutorConfig config = new OozieJobExecutorConfig(); OozieClient client = getBadConfigTest(); OozieJobExecutorJobEntry je = new TestOozieJobExecutorJobEntry(client); // just use this to force an error condition config.setOozieUrl("http://localhost/oozie"); config.setOozieWorkflowConfig("file:///test/job.properties"); config.setJobEntryName("name"); List<String> warnings = je.getValidationWarnings(config); assertEquals(1, warnings.size()); assertEquals( BaseMessages.getString( OozieJobExecutorJobEntry.class, "ValidationMessages.Incompatible.Oozie.Versions", client.getClientBuildVersion()), warnings.get(0)); }