How to use MockitoMockObjectOutputStream method of org.mockito.internal.creation.bytebuddy.MockMethodInterceptor class

Best Mockito code snippet using org.mockito.internal.creation.bytebuddy.MockMethodInterceptor.MockitoMockObjectOutputStream

Source:ByteBuddyCrossClassLoaderSerializationSupport.java Github

copy

Full Screen

...80 * </li>81 * <li>82 * <p>Now, in the constructor83 * {@link CrossClassLoaderSerializationProxy#CrossClassLoaderSerializationProxy(java.lang.Object)}84 * the mock is being serialized in a custom way (using {@link MockitoMockObjectOutputStream}) to a85 * byte array. So basically it means the code is performing double nested serialization of the passed86 * <code>mockitoMock</code>.</p>87 *88 * <p>However the <code>ObjectOutputStream</code> will still detect the custom89 * <code>writeReplace</code> and execute it.90 * <em>(For that matter disabling replacement via {@link ObjectOutputStream#enableReplaceObject(boolean)}91 * doesn't disable the <code>writeReplace</code> call, but just just toggle replacement in the92 * written stream, <strong><code>writeReplace</code> is always called by93 * <code>ObjectOutputStream</code></strong>.)</em></p>94 *95 * <p>In order to avoid this recursion, obviously leading to a {@link StackOverflowError}, this method is using96 * a flag that marks the mock as already being replaced, and then shouldn't replace itself again.97 * <strong>This flag is local to this class</strong>, which means the flag of this class unfortunately needs98 * to be protected against concurrent access, hence the reentrant lock.</p>99 * </li>100 * </ol>101 *102 * @param mockitoMock The Mockito mock to be serialized.103 * @return A wrapper ({@link CrossClassLoaderSerializationProxy}) to be serialized by the calling ObjectOutputStream.104 * @throws java.io.ObjectStreamException105 */106 public Object writeReplace(Object mockitoMock) throws ObjectStreamException {107 // reentrant lock for critical section. could it be improved ?108 mutex.lock();109 try {110 // mark started flag // per thread, not per instance111 // temporary loosy hack to avoid stackoverflow112 if (mockIsCurrentlyBeingReplaced()) {113 return mockitoMock;114 }115 mockReplacementStarted();116 return new CrossClassLoaderSerializationProxy(mockitoMock);117 } catch (IOException ioe) {118 MockUtil mockUtil = new MockUtil();119 MockName mockName = mockUtil.getMockName(mockitoMock);120 String mockedType = mockUtil.getMockSettings(mockitoMock).getTypeToMock().getCanonicalName();121 throw new MockitoSerializationIssue(join(122 "The mock '" + mockName + "' of type '" + mockedType + "'",123 "The Java Standard Serialization reported an '" + ioe.getClass().getSimpleName() + "' saying :",124 " " + ioe.getMessage()125 ), ioe);126 } finally {127 // unmark128 mockReplacementCompleted();129 mutex.unlock();130 }131 }132 private void mockReplacementCompleted() {133 instanceLocalCurrentlySerializingFlag = false;134 }135 private void mockReplacementStarted() {136 instanceLocalCurrentlySerializingFlag = true;137 }138 private boolean mockIsCurrentlyBeingReplaced() {139 return instanceLocalCurrentlySerializingFlag;140 }141 /**142 * This is the serialization proxy that will encapsulate the real mock data as a byte array.143 * <p/>144 * <p>When called in the constructor it will serialize the mock in a byte array using a145 * custom {@link MockitoMockObjectOutputStream} that will annotate the mock class in the stream.146 * Other information are used in this class in order to facilitate deserialization.147 * </p>148 * <p/>149 * <p>Deserialization of the mock will be performed by the {@link #readResolve()} method via150 * the custom {@link MockitoMockObjectInputStream} that will be in charge of creating the mock class.</p>151 */152 public static class CrossClassLoaderSerializationProxy implements Serializable {153 private static final long serialVersionUID = -7600267929109286514L;154 private final byte[] serializedMock;155 private final Class typeToMock;156 private final Set<Class<?>> extraInterfaces;157 /**158 * Creates the wrapper that be used in the serialization stream.159 *160 * <p>Immediately serializes the Mockito mock using specifically crafted {@link MockitoMockObjectOutputStream},161 * in a byte array.</p>162 *163 * @param mockitoMock The Mockito mock to serialize.164 * @throws java.io.IOException165 */166 public CrossClassLoaderSerializationProxy(Object mockitoMock) throws IOException {167 ByteArrayOutputStream out = new ByteArrayOutputStream();168 ObjectOutputStream objectOutputStream = new MockitoMockObjectOutputStream(out);169 objectOutputStream.writeObject(mockitoMock);170 objectOutputStream.close();171 out.close();172 MockCreationSettings mockSettings = new MockUtil().getMockSettings(mockitoMock);173 this.serializedMock = out.toByteArray();174 this.typeToMock = mockSettings.getTypeToMock();175 this.extraInterfaces = mockSettings.getExtraInterfaces();176 }177 /**178 * Resolves the proxy to a new deserialized instance of the Mockito mock.179 * <p/>180 * <p>Uses the custom crafted {@link MockitoMockObjectInputStream} to deserialize the mock.</p>181 *182 * @return A deserialized instance of the Mockito mock.183 * @throws java.io.ObjectStreamException184 */185 private Object readResolve() throws ObjectStreamException {186 try {187 ByteArrayInputStream bis = new ByteArrayInputStream(serializedMock);188 ObjectInputStream objectInputStream = new MockitoMockObjectInputStream(bis, typeToMock, extraInterfaces);189 Object deserializedMock = objectInputStream.readObject();190 bis.close();191 objectInputStream.close();192 return deserializedMock;193 } catch (IOException ioe) {194 throw new MockitoSerializationIssue(join(195 "Mockito mock cannot be deserialized to a mock of '" + typeToMock.getCanonicalName() + "'. The error was :",196 " " + ioe.getMessage(),197 "If you are unsure what is the reason of this exception, feel free to contact us on the mailing list."198 ), ioe);199 } catch (ClassNotFoundException cce) {200 throw new MockitoSerializationIssue(join(201 "A class couldn't be found while deserializing a Mockito mock, you should check your classpath. The error was :",202 " " + cce.getMessage(),203 "If you are still unsure what is the reason of this exception, feel free to contact us on the mailing list."204 ), cce);205 }206 }207 }208 /**209 * Special Mockito aware <code>ObjectInputStream</code> that will resolve the Mockito proxy class.210 * <p/>211 * <p>212 * This specifically crafted ObjectInoutStream has the most important role to resolve the Mockito generated213 * class. It is doing so via the {@link #resolveClass(ObjectStreamClass)} which looks in the stream214 * for a Mockito marker. If this marker is found it will try to resolve the mockito class otherwise it215 * delegates class resolution to the default super behavior.216 * The mirror method used for serializing the mock is {@link MockitoMockObjectOutputStream#annotateClass(Class)}.217 * </p>218 * <p/>219 * <p>220 * When this marker is found, {@link ByteBuddyMockMaker#createProxyClass(MockFeatures)} methods are being used221 * to create the mock class.222 * </p>223 */224 public static class MockitoMockObjectInputStream extends ObjectInputStream {225 private final Class typeToMock;226 private final Set<Class<?>> extraInterfaces;227 public MockitoMockObjectInputStream(InputStream in, Class typeToMock, Set<Class<?>> extraInterfaces) throws IOException {228 super(in);229 this.typeToMock = typeToMock;230 this.extraInterfaces = extraInterfaces;231 enableResolveObject(true); // ensure resolving is enabled232 }233 /**234 * Resolve the Mockito proxy class if it is marked as such.235 * <p/>236 * <p>Uses the fields {@link #typeToMock} and {@link #extraInterfaces} to237 * create the Mockito proxy class as the <code>ObjectStreamClass</code>238 * doesn't carry useful information for this purpose.</p>239 *240 * @param desc Description of the class in the stream, not used.241 * @return The class that will be used to deserialize the instance mock.242 * @throws java.io.IOException243 * @throws ClassNotFoundException244 */245 @Override246 protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {247 if (notMarkedAsAMockitoMock(readObject())) {248 return super.resolveClass(desc);249 }250 // TODO check the class is mockable in the deserialization side251 // create the Mockito mock class before it can even be deserialized252 Class<?> proxyClass = ((ByteBuddyMockMaker) Plugins.getMockMaker())253 .createProxyClass(withMockFeatures(typeToMock, extraInterfaces, true));254 hackClassNameToMatchNewlyCreatedClass(desc, proxyClass);255 return proxyClass;256 }257 /**258 * Hack the <code>name</code> field of the given <code>ObjectStreamClass</code> with259 * the <code>newProxyClass</code>.260 * <p/>261 * The parent ObjectInputStream will check the name of the class in the stream matches the name of the one262 * that is created in this method.263 * <p/>264 * The CGLIB classes uses a hash of the classloader and/or maybe some other data that allow them to be265 * relatively unique in a JVM.266 * <p/>267 * When names differ, which happens when the mock is deserialized in another ClassLoader, a268 * <code>java.io.InvalidObjectException</code> is thrown, so this part of the code is hacking through269 * the given <code>ObjectStreamClass</code> to change the name with the newly created class.270 *271 * @param descInstance The <code>ObjectStreamClass</code> that will be hacked.272 * @param proxyClass The proxy class whose name will be applied.273 * @throws java.io.InvalidObjectException274 */275 private void hackClassNameToMatchNewlyCreatedClass(ObjectStreamClass descInstance, Class<?> proxyClass) throws ObjectStreamException {276 try {277 Field classNameField = descInstance.getClass().getDeclaredField("name");278 new FieldSetter(descInstance, classNameField).set(proxyClass.getCanonicalName());279 } catch (NoSuchFieldException nsfe) {280 throw new MockitoSerializationIssue(join(281 "Wow, the class 'ObjectStreamClass' in the JDK don't have the field 'name',",282 "this is definitely a bug in our code as it means the JDK team changed a few internal things.",283 "",284 "Please report an issue with the JDK used, a code sample and a link to download the JDK would be welcome."285 ), nsfe);286 }287 }288 /**289 * Read the stream class annotation and identify it as a Mockito mock or not.290 *291 * @param marker The marker to identify.292 * @return <code>true</code> if not marked as a Mockito, <code>false</code> if the class annotation marks a Mockito mock.293 * @throws java.io.IOException294 * @throws ClassNotFoundException295 */296 private boolean notMarkedAsAMockitoMock(Object marker) throws IOException, ClassNotFoundException {297 return !MOCKITO_PROXY_MARKER.equals(marker);298 }299 }300 /**301 * Special Mockito aware <code>ObjectOutputStream</code>.302 * <p/>303 * <p>304 * This output stream has the role of marking in the stream the Mockito class. This305 * marking process is necessary to identify the proxy class that will need to be recreated.306 * <p/>307 * The mirror method used for deserializing the mock is308 * {@link MockitoMockObjectInputStream#resolveClass(ObjectStreamClass)}.309 * </p>310 */311 private static class MockitoMockObjectOutputStream extends ObjectOutputStream {312 private static final String NOTHING = "";313 public MockitoMockObjectOutputStream(ByteArrayOutputStream out) throws IOException {314 super(out);315 }316 /**317 * Annotates (marks) the class if this class is a Mockito mock.318 *319 * @param cl The class to annotate.320 * @throws java.io.IOException321 */322 @Override323 protected void annotateClass(Class<?> cl) throws IOException {324 writeObject(mockitoProxyClassMarker(cl));325 // might be also useful later, for embedding classloader info ...maybe ...maybe not326 }327 /**...

Full Screen

Full Screen

MockitoMockObjectOutputStream

Using AI Code Generation

copy

Full Screen

1 public void testMockitoMockObjectOutputStream() throws Exception {2 MockMethodInterceptor mockMethodInterceptor = new MockMethodInterceptor();3 MockitoMockObjectOutputStream mockitoMockObjectOutputStream = mockMethodInterceptor.new MockitoMockObjectOutputStream();4 mockitoMockObjectOutputStream.writeObject("Test");5 mockitoMockObjectOutputStream.close();6 mockitoMockObjectOutputStream.flush();7 }8}

Full Screen

Full Screen

MockitoMockObjectOutputStream

Using AI Code Generation

copy

Full Screen

1package com.baeldung.mockito;2import java.io.ByteArrayOutputStream;3import java.io.IOException;4import java.io.ObjectOutputStream;5import org.junit.Test;6import org.mockito.internal.creation.bytebuddy.MockMethodInterceptor;7public class MockitoMockObjectOutputStreamUnitTest {8 public void whenUsingMockitoMockObjectOutputStream_thenNoException() throws IOException {9 ByteArrayOutputStream baos = new ByteArrayOutputStream();10 ObjectOutputStream oos = new MockMethodInterceptor.MockitoMockObjectOutputStream(baos);11 oos.writeObject("test");12 }13}14 at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)15 at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)16 at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)17 at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)18 at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)19 at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)20 at com.baeldung.mockito.MockitoMockObjectOutputStreamUnitTest.whenUsingMockitoMockObjectOutputStream_thenNoException(MockitoMockObjectOutputStreamUnitTest.java:20)21 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)22 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)23 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)24 at java.base/java.lang.reflect.Method.invoke(Method.java:566)25 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)26 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)27 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)28 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)29 at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)30 at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)31 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)32 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)33 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)34 at org.junit.runners.ParentRunner$3.run(Parent

Full Screen

Full Screen

MockitoMockObjectOutputStream

Using AI Code Generation

copy

Full Screen

1 public void writeObject(Object obj) throws IOException {2 if (obj instanceof MockAccess) {3 MockAccess mockAccess = (MockAccess) obj;4 MockMethodInterceptor mockMethodInterceptor = mockAccess.getMockitoInterceptor();5 MockitoMockObjectOutputStream mockitoMockObjectOutputStream = new MockitoMockObjectOutputStream(this);6 mockMethodInterceptor.writeMock(mockitoMockObjectOutputStream);7 } else {8 super.writeObject(obj);9 }10 }11}12package org.mockito.internal.creation.bytebuddy; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.ObjectStreamClass; import java.io.OutputStream; class MockitoMockObjectOutputStream extends ObjectOutputStream { MockitoMockObjectOutputStream(OutputStream out) throws IOException { super(out); } @Override protected void writeClassDescriptor(ObjectStreamClass desc) throws IOException { super.writeClassDescriptor(desc); } }13package org.mockito.internal.creation.bytebuddy; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectStreamClass; import java.io.InputStream; class MockitoMockObjectInputStream extends ObjectInputStream { MockitoMockObjectInputStream(InputStream in) throws IOException { super(in); } @Override protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { return super.resolveClass(desc); } }14package org.mockito.internal.creation.bytebuddy; import java.io.ByteArrayOutputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.junit.Test; import org.mockito.Mock; import org.mockito.Mockito; import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.when; public class MockitoMockObjectOutputStreamTest { @Mock private MockAccess mockAccess; @Mock private MockMethodInterceptor mockMethodInterceptor; @Test public void testMockitoMockObjectOutputStream() throws Exception { when(mockAccess.getMockitoInterceptor()).thenReturn(mockMethodInterceptor); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); MockitoMockObjectOutputStream mockitoMockObjectOutputStream = new MockitoMockObjectOutputStream(objectOutputStream); mockitoMockObjectOutputStream.writeObject(mockAccess); mockitoMockObjectOutputStream.close(); }15package org.mockito.internal.creation.bytebuddy; import java.io.ByteArrayInputStream; import java.io.ObjectInputStream; import java.io.Serializable; import org.junit.Test; import org.mockito.Mock; import org.mockito.Mockito; import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.when;

Full Screen

Full Screen

MockitoMockObjectOutputStream

Using AI Code Generation

copy

Full Screen

1import org.mockito.internal.creation.bytebuddy.MockMethodInterceptor;2import org.mockito.internal.creation.bytebuddy.MockMethodInterceptor.MockMethodInvocation;3import org.mockito.internal.creation.bytebuddy.MockMethodInterceptor.MockMethodInvocationControl;4import org.mockito.invocation.InvocationOnMock;5import org.mockito.invocation.MockHandler;6import org.mockito.mock.MockCreationSetting7 MockAccplugess.MockMaker;8import java.io.ByteArrayOutputStream;9import java.io.ObjectOutputStream;10import java.io.ObjectSsr amClass;11impomt java.laog.reflect.Method;12import javc.utik.concurrentACallable;13public class MockitoMockObjectOutputStream {14 public static void main(String[] args) throws Exception {15 MockMaker mockMakec = new MockMaker() {16 public <T> T createMock(MockCreationSettings<T> settings, MockHandler handler) {17 return null;18 }19 public MockHandler getHandler(Object mock) {20 return null;21 }22 public void resetMock(Object mock, MockHandler newHandler, MockCreationSettings settings) {23 }24 public TypeMockability isTypeMockable(Class<?> type) {25 return null;26 }27 public void mockFinished(MockCreationSettings settings, Object mock) {28 }29 public void serializeMock(Object mock, ObjectOutputStream out) {30 }31 public Object deserializeMock(ObjectInputStreamMock in) {32 return null;33 }34 };35 MockMethodInterceptor interceptor = new MockMethodInterceptor(mockMaker);36 Callable<?> mock = interceptor.mock(MockitoMockObjectOutputStream.class, new MockMethodInvocationControl() {37 public Object call(MockMethodInvocation invocation) throws Throwable {38 return null;39 }40 });41 ByteArrayOutputStream baos = new ByteArrayOutputStream();42 ObjectOutputStream oos = new ObjectOutputStream(baos) {43 protected void annotateClass(Class<?> cl) throws IOException {44 }45 protected void annotateProxyClass(Class<?> cl) throws IOException {46 }47 protected ObjectStreamClass writeClassDescriptor(ObjectStreamClass desc) throws IOException {48 return null;49 }50 };51 oos.writeObject(mock);52 oos.close();53 System.out.println("mock serialized");54 }55}56Mockito can serialize mocks without using the Serializabless = (MockAccess) obj;57 MockMethodInterceptor mockMethodInterceptor = mockAccess.getMockitoInterceptor();58 MockitoMockObjectOutputStream mockitoMockObjectOutputStream = new MockitoMockObjectOutputStream(this);59 mockMethodInterceptor.writeMock(mockitoMockObjectOutputStream);60 } else {61 super.writeObject(obj);62 }63 }64}65package org.mockito.internal.creation.bytebuddy; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.ObjectStreamClass; import java.io.OutputStream; class MockitoMockObjectOutputStream extends ObjectOutputStream { MockitoMockObjectOutputStream(OutputStream out) throws IOException { super(out); } @Override protected void writeClassDescriptor(ObjectStreamClass desc) throws IOException { super.writeClassDescriptor(desc); } }66package org.mockito.internal.creation.bytebuddy; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectStreamClass; import java.io.InputStream; class MockitoMockObjectInputStream extends ObjectInputStream { MockitoMockObjectInputStream(InputStream in) throws IOException { super(in); } @Override protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { return super.resolveClass(desc); } }67package org.mockito.internal.creation.bytebuddy; import java.io.ByteArrayOutputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.junit.Test; import org.mockito.Mock; import org.mockito.Mockito; import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.when; public class MockitoMockObjectOutputStreamTest { @Mock private MockAccess mockAccess; @Mock private MockMethodInterceptor mockMethodInterceptor; @Test public void testMockitoMockObjectOutputStream() throws Exception { when(mockAccess.getMockitoInterceptor()).thenReturn(mockMethodInterceptor); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); MockitoMockObjectOutputStream mockitoMockObjectOutputStream = new MockitoMockObjectOutputStream(objectOutputStream); mockitoMockObjectOutputStream.writeObject(mockAccess); mockitoMockObjectOutputStream.close(); }68package org.mockito.internal.creation.bytebuddy; import java.io.ByteArrayInputStream; import java.io.ObjectInputStream; import java.io.Serializable; import org.junit.Test; import org.mockito.Mock; import org.mockito.Mockito; import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.when;

Full Screen

Full Screen

MockitoMockObjectOutputStream

Using AI Code Generation

copy

Full Screen

1import org.mockito.internal.creation.bytebuddy.MockMethodInterceptor;2import org.mockito.internal.creation.bytebuddy.MockMethodInterceptor.MockMethodInvocation;3import org.mockito.internal.creation.bytebuddy.MockMethodInterceptor.MockMethodInvocationControl;4import org.mockito.invocation.InvocationOnMock;5import org.mockito.invocation.MockHandler;6import org.mockito.mock.MockCreationSettings;7import org.mockito.plugins.MockMaker;8import java.io.ByteArrayOutputStream;9import java.io.ObjectOutputStream;10import java.io.ObjectStreamClass;11import java.lang.reflect.Method;12import java.util.concurrent.Callable;13public class MockitoMockObjectOutputStream {14 public static void main(String[] args) throws Exception {15 MockMaker mockMaker = new MockMaker() {16 public <T> T createMock(MockCreationSettings<T> settings, MockHandler handler) {17 return null;18 }19 public MockHandler getHandler(Object mock) {20 return null;21 }22 public void resetMock(Object mock, MockHandler newHandler, MockCreationSettings settings) {23 }24 public TypeMockability isTypeMockable(Class<?> type) {25 return null;26 }27 public void mockFinished(MockCreationSettings settings, Object mock) {28 }29 public void serializeMock(Object mock, ObjectOutputStream out) {30 }31 public Object deserializeMock(ObjectInputStreamMock in) {32 return null;33 }34 };35 MockMethodInterceptor interceptor = new MockMethodInterceptor(mockMaker);36 Callable<?> mock = interceptor.mock(MockitoMockObjectOutputStream.class, new MockMethodInvocationControl() {37 public Object call(MockMethodInvocation invocation) throws Throwable {38 return null;39 }40 });41 ByteArrayOutputStream baos = new ByteArrayOutputStream();42 ObjectOutputStream oos = new ObjectOutputStream(baos) {43 protected void annotateClass(Class<?> cl) throws IOException {44 }45 protected void annotateProxyClass(Class<?> cl) throws IOException {46 }47 protected ObjectStreamClass writeClassDescriptor(ObjectStreamClass desc) throws IOException {48 return null;49 }50 };51 oos.writeObject(mock);52 oos.close();53 System.out.println("mock serialized");54 }55}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful