@Test public void testJaxbSafeJob() throws JAXBException { JobAdapter.JaxbSafeJob job = new JobAdapter.JaxbSafeJob(); final Date NOW = new Date(); job.lastRun = NOW; job.nextRun = NOW; job.jobName = "testName"; job.jobId = "testId"; job.schedulableClass = "test.schedulable.class"; job.state = Job.JobState.COMPLETE; job.userName = "******"; HashMap<String, ParamValue> params = new HashMap<String, ParamValue>(); params.put("testStringkey", new StringParamValue("testStringVal")); JaxBSafeMap safeMap = new JaxBSafeMap(params); job.jobParams = safeMap; JobAdapter.JaxbSafeJob unmarshalledJob = JaxBUtil.outin(job, JobAdapter.JaxbSafeJob.class); Assert.assertEquals(job.lastRun, unmarshalledJob.lastRun); Assert.assertEquals(job.nextRun, unmarshalledJob.nextRun); Assert.assertEquals(job.jobName, unmarshalledJob.jobName); Assert.assertEquals(job.jobId, unmarshalledJob.jobId); Assert.assertEquals(job.schedulableClass, unmarshalledJob.schedulableClass); Assert.assertEquals(job.userName, unmarshalledJob.userName); Assert.assertEquals(job.state, unmarshalledJob.state); Assert.assertEquals(job.jobTrigger, unmarshalledJob.jobTrigger); Assert.assertTrue("testStringkey".equals(unmarshalledJob.jobParams.entry.get(0).key)); Assert.assertTrue( "testStringVal".equals(unmarshalledJob.jobParams.entry.get(0).getStringValue().toString())); }
@Test public void testParamValue() throws JAXBException { ParamValue val = new StringParamValue("testval"); ParamValue unmarshalled = JaxBUtil.outin(val, StringParamValue.class); Assert.assertEquals("testval", unmarshalled.toString()); }
public static EarthPartCollection all() { EarthquakeCollection quakeCollection = JaxBUtil.unmarshall(); List<Earthpart> partList = new ArrayList<Earthpart>(); Set<String> distinctCountrys = new HashSet<String>(); for (Earthquake iterable_element : quakeCollection.getEntries()) { distinctCountrys.add(iterable_element.getCounrty()); } List<Earthquake> tmpList = new ArrayList<Earthquake>(); for (String country : distinctCountrys) { for (Earthquake iterable_element : quakeCollection.getEntries()) { if (iterable_element.getCounrty().equals(country)) { tmpList.add(iterable_element); } } partList.add(new Earthpart(country, new EarthquakeCollection(tmpList))); tmpList = new ArrayList<Earthquake>(); } EarthPartCollection partCollection = new EarthPartCollection(); partCollection.setEarthparts(partList); System.out.println("----------------->collection:" + partCollection); return partCollection; }
@Test public void testSimpleTrigger() throws JAXBException { { SimpleJobTrigger orig = new SimpleJobTrigger(); Date STARTTIME = new Date(); orig.setStartTime(STARTTIME); SimpleJobTrigger unmarshalled = JaxBUtil.outin(orig, SimpleJobTrigger.class); Assert.assertEquals(orig.getStartTime(), unmarshalled.getStartTime()); } }
@Test public void testJaxbSafeMap() throws JAXBException { HashMap<String, ParamValue> params = new HashMap<String, ParamValue>(); ListParamValue listValue = new ListParamValue(); listValue.add("testListVal0"); listValue.add("testListVal1"); MapParamValue mapValue = new MapParamValue(); mapValue.put("testMapValueKey", "testMapVal"); params.put("testStringkey", new StringParamValue("testStringVal")); params.put("testListKey", listValue); params.put("testMapKey", mapValue); JaxBSafeMap map = new JaxBSafeMap(params); JaxBSafeMap unmarshalled = JaxBUtil.outin(map, JaxBSafeMap.class, JaxBSafeEntry.class, StringParamValue.class); Assert.assertEquals("testStringVal", unmarshalled.entry.get(0).getStringValue().toString()); Assert.assertEquals("testListVal0", unmarshalled.entry.get(1).getListValue().get(0)); Assert.assertEquals( "testMapVal", unmarshalled.entry.get(2).getMapValue().get("testMapValueKey")); }