|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved. |
| 3 |
* This program and the accompanying materials are made available under the |
| 4 |
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 |
| 5 |
* which accompanies this distribution. |
| 6 |
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* and the Eclipse Distribution License is available at |
| 8 |
* http://www.eclipse.org/org/documents/edl-v10.php. |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* Denise Smith - October 18, 2012 |
| 12 |
******************************************************************************/ |
| 13 |
package org.eclipse.persistence.testing.jaxb.annotations.xmltransient; |
| 14 |
|
| 15 |
import java.util.ArrayList; |
| 16 |
|
| 17 |
import javax.xml.bind.MarshalException; |
| 18 |
|
| 19 |
import org.eclipse.persistence.exceptions.XMLMarshalException; |
| 20 |
import org.eclipse.persistence.testing.jaxb.JAXBWithJSONTestCases; |
| 21 |
|
| 22 |
public class ObjectWithTransientListTestCases extends JAXBWithJSONTestCases{ |
| 23 |
|
| 24 |
public ObjectWithTransientListTestCases(String name) throws Exception { |
| 25 |
super(name); |
| 26 |
setClasses(new Class[] { ObjectWithTransient.class }); |
| 27 |
} |
| 28 |
|
| 29 |
@Override |
| 30 |
protected Object getControlObject() { |
| 31 |
ObjectWithTransient obj = new ObjectWithTransient(); |
| 32 |
obj.testString = "theTest"; |
| 33 |
TransientClass transientThing = new TransientClass(); |
| 34 |
obj.transientThings = new ArrayList<TransientClass>(); |
| 35 |
obj.transientThings.add(transientThing); |
| 36 |
|
| 37 |
return obj; |
| 38 |
} |
| 39 |
|
| 40 |
public boolean isUnmarshalTest(){ |
| 41 |
return false; |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
public void testJSONMarshalToOutputStream() throws Exception{ |
| 46 |
try{ |
| 47 |
super.testJSONMarshalToOutputStream(); |
| 48 |
}catch(MarshalException e){ |
| 49 |
Throwable linkedException = e.getLinkedException(); |
| 50 |
assertTrue(linkedException instanceof XMLMarshalException); |
| 51 |
Throwable actualException = ((XMLMarshalException)linkedException).getCause(); |
| 52 |
assertTrue(actualException instanceof XMLMarshalException); |
| 53 |
assertEquals("Wrong XMLMarshalExcpetion was thrown",XMLMarshalException.DESCRIPTOR_NOT_FOUND_IN_PROJECT ,((XMLMarshalException)actualException).getErrorCode()); |
| 54 |
return; |
| 55 |
}catch (Exception e) { |
| 56 |
e.printStackTrace(); |
| 57 |
} |
| 58 |
fail("An exception should have been thrown"); |
| 59 |
} |
| 60 |
|
| 61 |
public void testJSONMarshalToOutputStream_FORMATTED() throws Exception{ |
| 62 |
try{ |
| 63 |
super.testJSONMarshalToOutputStream_FORMATTED(); |
| 64 |
}catch(MarshalException e){ |
| 65 |
Throwable linkedException = e.getLinkedException(); |
| 66 |
assertTrue(linkedException instanceof XMLMarshalException); |
| 67 |
Throwable actualException = ((XMLMarshalException)linkedException).getCause(); |
| 68 |
assertTrue(actualException instanceof XMLMarshalException); |
| 69 |
assertEquals("Wrong XMLMarshalExcpetion was thrown",XMLMarshalException.DESCRIPTOR_NOT_FOUND_IN_PROJECT ,((XMLMarshalException)actualException).getErrorCode()); |
| 70 |
return; |
| 71 |
} |
| 72 |
fail("An exception should have been thrown"); |
| 73 |
} |
| 74 |
|
| 75 |
public void testJSONMarshalToStringWriter() throws Exception{ |
| 76 |
try{ |
| 77 |
super.testJSONMarshalToStringWriter(); |
| 78 |
}catch(MarshalException e){ |
| 79 |
Throwable linkedException = e.getLinkedException(); |
| 80 |
assertTrue(linkedException instanceof XMLMarshalException); |
| 81 |
assertEquals("Wrong XMLMarshalExcpetion was thrown",XMLMarshalException.DESCRIPTOR_NOT_FOUND_IN_PROJECT ,((XMLMarshalException)linkedException).getErrorCode()); |
| 82 |
return; |
| 83 |
} |
| 84 |
fail("An exception should have been thrown"); |
| 85 |
} |
| 86 |
|
| 87 |
public void testJSONMarshalToStringWriter_FORMATTED() throws Exception{ |
| 88 |
try{ |
| 89 |
super.testJSONMarshalToStringWriter_FORMATTED(); |
| 90 |
}catch(MarshalException e){ |
| 91 |
Throwable linkedException = e.getLinkedException(); |
| 92 |
assertTrue(linkedException instanceof XMLMarshalException); |
| 93 |
assertEquals("Wrong XMLMarshalExcpetion was thrown",XMLMarshalException.DESCRIPTOR_NOT_FOUND_IN_PROJECT ,((XMLMarshalException)linkedException).getErrorCode()); |
| 94 |
return; |
| 95 |
} |
| 96 |
fail("An exception should have been thrown"); |
| 97 |
} |
| 98 |
|
| 99 |
public void testObjectToContentHandler() throws Exception{ |
| 100 |
try{ |
| 101 |
super.testObjectToContentHandler(); |
| 102 |
}catch(MarshalException e){ |
| 103 |
Throwable linkedException = e.getLinkedException(); |
| 104 |
assertTrue(linkedException instanceof XMLMarshalException); |
| 105 |
assertEquals("Wrong XMLMarshalExcpetion was thrown",XMLMarshalException.DESCRIPTOR_NOT_FOUND_IN_PROJECT ,((XMLMarshalException)linkedException).getErrorCode()); |
| 106 |
return; |
| 107 |
} |
| 108 |
fail("An exception should have been thrown"); |
| 109 |
} |
| 110 |
|
| 111 |
public void testObjectToOutputStream() throws Exception{ |
| 112 |
try{ |
| 113 |
super.testObjectToOutputStream(); |
| 114 |
}catch(MarshalException e){ |
| 115 |
Throwable linkedException = e.getLinkedException(); |
| 116 |
assertTrue(linkedException instanceof XMLMarshalException); |
| 117 |
Throwable actualException = ((XMLMarshalException)linkedException).getCause(); |
| 118 |
assertTrue(actualException instanceof XMLMarshalException); |
| 119 |
assertEquals("Wrong XMLMarshalExcpetion was thrown",XMLMarshalException.DESCRIPTOR_NOT_FOUND_IN_PROJECT ,((XMLMarshalException)actualException).getErrorCode()); |
| 120 |
return; |
| 121 |
} |
| 122 |
fail("An exception should have been thrown"); |
| 123 |
} |
| 124 |
|
| 125 |
public void testObjectToOutputStreamASCIIEncoding() throws Exception{ |
| 126 |
try{ |
| 127 |
super.testObjectToOutputStreamASCIIEncoding(); |
| 128 |
}catch(MarshalException e){ |
| 129 |
Throwable linkedException = e.getLinkedException(); |
| 130 |
assertTrue(linkedException instanceof XMLMarshalException); |
| 131 |
Throwable actualException = ((XMLMarshalException)linkedException).getCause(); |
| 132 |
assertTrue(actualException instanceof XMLMarshalException); |
| 133 |
assertEquals("Wrong XMLMarshalExcpetion was thrown",XMLMarshalException.DESCRIPTOR_NOT_FOUND_IN_PROJECT ,((XMLMarshalException)actualException).getErrorCode()); |
| 134 |
return; |
| 135 |
} |
| 136 |
fail("An exception should have been thrown"); |
| 137 |
} |
| 138 |
|
| 139 |
public void testObjectToXMLDocument() throws Exception{ |
| 140 |
try{ |
| 141 |
super.testObjectToXMLDocument(); |
| 142 |
}catch(MarshalException e){ |
| 143 |
Throwable linkedException = e.getLinkedException(); |
| 144 |
assertTrue(linkedException instanceof XMLMarshalException); |
| 145 |
assertEquals("Wrong XMLMarshalExcpetion was thrown",XMLMarshalException.DESCRIPTOR_NOT_FOUND_IN_PROJECT ,((XMLMarshalException)linkedException).getErrorCode()); return; |
| 146 |
} |
| 147 |
fail("An exception should have been thrown"); |
| 148 |
} |
| 149 |
|
| 150 |
public void testObjectToXMLEventWriter() throws Exception{ |
| 151 |
try{ |
| 152 |
super.testObjectToXMLEventWriter(); |
| 153 |
}catch(MarshalException e){ |
| 154 |
Throwable linkedException = e.getLinkedException(); |
| 155 |
assertTrue(linkedException instanceof XMLMarshalException); |
| 156 |
assertEquals("Wrong XMLMarshalExcpetion was thrown",XMLMarshalException.DESCRIPTOR_NOT_FOUND_IN_PROJECT ,((XMLMarshalException)linkedException).getErrorCode()); |
| 157 |
return; |
| 158 |
} |
| 159 |
fail("An exception should have been thrown"); |
| 160 |
} |
| 161 |
public void testObjectToXMLStreamWriter() throws Exception{ |
| 162 |
try{ |
| 163 |
super.testObjectToXMLStreamWriter(); |
| 164 |
}catch(MarshalException e){ |
| 165 |
Throwable linkedException = e.getLinkedException(); |
| 166 |
assertTrue(linkedException instanceof XMLMarshalException); |
| 167 |
assertEquals("Wrong XMLMarshalExcpetion was thrown",XMLMarshalException.DESCRIPTOR_NOT_FOUND_IN_PROJECT ,((XMLMarshalException)linkedException).getErrorCode()); |
| 168 |
return; |
| 169 |
} |
| 170 |
fail("An exception should have been thrown"); |
| 171 |
} |
| 172 |
public void testObjectToXMLStreamWriterRecord() throws Exception{ |
| 173 |
try{ |
| 174 |
super.testObjectToXMLStreamWriterRecord(); |
| 175 |
}catch(MarshalException e){ |
| 176 |
Throwable linkedException = e.getLinkedException(); |
| 177 |
assertTrue(linkedException instanceof XMLMarshalException); |
| 178 |
assertEquals("Wrong XMLMarshalExcpetion was thrown",XMLMarshalException.DESCRIPTOR_NOT_FOUND_IN_PROJECT ,((XMLMarshalException)linkedException).getErrorCode()); |
| 179 |
return; |
| 180 |
} |
| 181 |
fail("An exception should have been thrown"); |
| 182 |
} |
| 183 |
|
| 184 |
public void testObjectToXMLStringWriter() throws Exception{ |
| 185 |
try{ |
| 186 |
super.testObjectToXMLStringWriter(); |
| 187 |
}catch(MarshalException e){ |
| 188 |
Throwable linkedException = e.getLinkedException(); |
| 189 |
assertTrue(linkedException instanceof XMLMarshalException); |
| 190 |
assertEquals("Wrong XMLMarshalExcpetion was thrown",XMLMarshalException.DESCRIPTOR_NOT_FOUND_IN_PROJECT ,((XMLMarshalException)linkedException).getErrorCode()); |
| 191 |
return; |
| 192 |
} |
| 193 |
fail("An exception should have been thrown"); |
| 194 |
} |
| 195 |
} |