Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 46df5a5dd28aaba9fa616f9bf036d1dcdc45d266 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package org.eclipse.ecf.tests.core.util;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.ecf.core.util.ECFException;
import org.eclipse.ecf.core.util.SerializableStatus;
import org.eclipse.ecf.internal.tests.Activator;

import junit.framework.TestCase;

public class SerializableStatusTest extends TestCase {

	
	protected IStatus createOKStatus() {
		return SerializableStatus.OK_STATUS;
	}
	
	protected IStatus createErrorStatus() {
		return new SerializableStatus(IStatus.ERROR,Activator.PLUGIN_ID,IStatus.ERROR,"error",new IllegalArgumentException("myexception"));
	}
	
	public static class MyNotSerializableException extends Exception {
		
		Object notSerializableObject = new Object();
		
		public MyNotSerializableException(String message) {
			super(message);
		}
	}
	
	protected IStatus createNotSerializableExceptionStatus() {
		return new SerializableStatus(IStatus.ERROR,Activator.PLUGIN_ID,IStatus.ERROR,"error",new MyNotSerializableException("myexception"));
	}
	
	public void testCreateStatus() throws Exception {
		IStatus s = createOKStatus();
		assertNotNull(s);
		assertTrue(s.isOK());
		assertTrue(s.getCode() == SerializableStatus.OK);
		assertTrue(s.getMessage().equals("ok"));
		assertTrue(s.getException() == null);
	}
	
	public void testCreateExceptionStatus() throws Exception {
		IStatus s = createErrorStatus();
		assertNotNull(s);
		assertFalse(s.isOK());
		assertTrue(s.getCode() == IStatus.ERROR);
		assertFalse(s.getMessage().equals("ok"));
		assertFalse(s.getException() == null);
	}

	public void testCreateNotSerializableExceptionStatus() throws Exception {
		IStatus s = createNotSerializableExceptionStatus();
		assertNotNull(s);
		assertFalse(s.isOK());
		assertTrue(s.getCode() == IStatus.ERROR);
		assertFalse(s.getMessage().equals("ok"));
		assertFalse(s.getException() == null);
		Throwable t = s.getException();
		assertFalse(t instanceof MyNotSerializableException);
	}
}

Back to the top