1
/*******************************************************************************
2
* Copyright (c) 2000, 2008 QNX Software Systems and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* QNX Software Systems - Initial API and implementation
10
*******************************************************************************/
12
package org.eclipse.cdt.core.model.tests;
14
import junit.framework.TestCase;
15
import junit.framework.TestSuite;
17
import org.eclipse.cdt.core.model.CModelException;
18
import org.eclipse.cdt.core.model.ICModelStatusConstants;
19
import org.eclipse.cdt.internal.core.model.CModelStatus;
20
import org.eclipse.core.runtime.CoreException;
25
* @author Judy N. Green
28
public class CModelExceptionTest extends TestCase {
29
// Shared values setup and torn down
30
private CModelStatus cModelStatus;
31
private CoreException coreException;
34
* Constructor for TestCModelException.
37
public CModelExceptionTest(String name) {
42
* Sets up the test fixture.
44
* Called before every test case method.
46
* Example code test the packages in the project
47
* "com.qnx.tools.ide.cdt.core"
49
protected void setUp() {
50
// create shared resources and setup the test fixture
51
cModelStatus = new CModelStatus();
52
coreException = new CoreException(cModelStatus);
56
* Tears down the test fixture.
58
* Called after every test case method.
60
protected void tearDown() {
61
// release resources here and clean-up
64
public static TestSuite suite() {
65
return new TestSuite(CModelExceptionTest.class);
68
public static void main (String[] args){
69
junit.textui.TestRunner.run(suite());
72
public void testCreationNoStatus(){
73
CModelException testException = new CModelException(coreException);
74
// should be the same object inside
75
assertTrue("Object compare failed", testException.getException() == coreException);
77
public void testCreationWithStatus(){
78
CModelException testException = new CModelException(coreException,
79
ICModelStatusConstants.INDEX_OUT_OF_BOUNDS);
81
assertTrue("TestException.getStatus() is null", (testException.getStatus() != null));
83
// should have the same status as was set on creation
84
assertTrue("Object compare failed", testException.getStatus().getCode() == ICModelStatusConstants.INDEX_OUT_OF_BOUNDS);
87
public void testElementDoesNotExist(){
88
CModelException testException = new CModelException(coreException,
89
ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST);
90
// should not exist since this is the value we set on creation
91
assertTrue("Object unexpectedly exists", testException.doesNotExist());
94
public void testElementExists(){
95
CModelException testException = new CModelException(coreException,
96
ICModelStatusConstants.INVALID_CONTENTS);
97
// should not exist since this is the value we set on creation
98
assertTrue("Object unexpectedly does not exist", !testException.doesNotExist());