public void testCreateContextUnrelatedSessionsXmlInvalidPath() throws Exception { try { JAXBContext context = JAXBContextFactory.createContext( "org.eclipse.persistence.testing.jaxb.jaxbcontext.fake", new ClassLoader() { public URL getResource(String resourceName) { if (resourceName.equals("sessions.xml")) { return getParent() .getResource( "org/eclipse/persistence/testing/jaxb/jaxbcontext/sessions.xml"); } return this.getParent().getResource(resourceName); } }); } catch (JAXBException ex) { assertTrue( ((org.eclipse.persistence.exceptions.JAXBException) ex.getLinkedException()) .getErrorCode() == org.eclipse.persistence.exceptions.JAXBException .NO_OBJECT_FACTORY_OR_JAXB_INDEX_IN_PATH); assertTrue( ((org.eclipse.persistence.exceptions.JAXBException) ex.getLinkedException()) .getInternalException() instanceof SessionLoaderException); } }
public void testCreateContextNoClassesOrSessions() throws Exception { try { JAXBContext context = JAXBContextFactory.createContext( "org.eclipse.persistence.testing.jaxb.jaxbcontext.fake", Thread.currentThread().getContextClassLoader()); } catch (JAXBException ex) { assertTrue( ((org.eclipse.persistence.exceptions.JAXBException) ex.getLinkedException()) .getErrorCode() == org.eclipse.persistence.exceptions.JAXBException .NO_OBJECT_FACTORY_OR_JAXB_INDEX_IN_PATH); assertTrue( ((org.eclipse.persistence.exceptions.JAXBException) ex.getLinkedException()) .getInternalException() instanceof ValidationException); } }
public void testCreateConcreteClassWithMultiArgConstructor() throws JAXBException { try { Class[] classes = new Class[1]; classes[0] = ConcreteClassWithMultiArgConstructor.class; JAXBContextFactory.createContext(classes, null); } catch (JAXBException e) { org.eclipse.persistence.exceptions.JAXBException je = (org.eclipse.persistence.exceptions.JAXBException) e.getLinkedException(); assertEquals( org.eclipse.persistence.exceptions.JAXBException.FACTORY_METHOD_OR_ZERO_ARG_CONST_REQ, je.getErrorCode()); return; } fail(); }