blob: b9f111c011ad3cdca21a7afa3a349434e9890449 [file] [log] [blame]
Stephan Herrmann36c26992010-04-01 23:18:59 +00001/**********************************************************************
2 * This file is part of "Object Teams Development Tooling"-Software
Stephan Herrmannc4606e82020-04-11 14:28:09 +02003 *
Stephan Herrmann36c26992010-04-01 23:18:59 +00004 * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
5 * for its Fraunhofer Institute and Computer Architecture and Software
6 * Technology (FIRST), Berlin, Germany and Technical University Berlin,
7 * Germany.
Stephan Herrmannc4606e82020-04-11 14:28:09 +02008 *
Stephan Herrmann35705382020-03-03 21:42:19 +01009 * This program and the accompanying materials
10 * are made available under the terms of the Eclipse Public License 2.0
Stephan Herrmann36c26992010-04-01 23:18:59 +000011 * which accompanies this distribution, and is available at
Stephan Herrmann35705382020-03-03 21:42:19 +010012 * https://www.eclipse.org/legal/epl-2.0/
13 *
14 * SPDX-License-Identifier: EPL-2.0
Stephan Herrmannc4606e82020-04-11 14:28:09 +020015 *
Stephan Herrmann36c26992010-04-01 23:18:59 +000016 * Please visit http://www.eclipse.org/objectteams for updates and contact.
Stephan Herrmannc4606e82020-04-11 14:28:09 +020017 *
Stephan Herrmann36c26992010-04-01 23:18:59 +000018 * Contributors:
19 * Fraunhofer FIRST - Initial API and implementation
20 * Technical University Berlin - Initial API and implementation
21 **********************************************************************/
22package org.eclipse.objectteams.otdt.tests.compiler.errorreporting;
23
24import org.eclipse.jdt.core.compiler.IProblem;
25import org.eclipse.objectteams.otdt.tests.compiler.TestBase;
26
27/**
28 * This class contains tests concerning roles.
Stephan Herrmannc4606e82020-04-11 14:28:09 +020029 *
Stephan Herrmann36c26992010-04-01 23:18:59 +000030 * @author kaschja
31 * @version $Id: RoleContainmentTest.java 23494 2010-02-05 23:06:44Z stephan $
32 */
33public class RoleContainmentTest extends TestBase
Stephan Herrmannc4606e82020-04-11 14:28:09 +020034{
Stephan Herrmann36c26992010-04-01 23:18:59 +000035 public RoleContainmentTest(String testName)
36 {
37 super(testName);
38 }
39
40 /**
41 * A role that is not declared as abstract contains an abstract method.
42 * Comment:
Stephan Herrmannc4606e82020-04-11 14:28:09 +020043 * A role has to be declared as abstract if it contains an abstract method.
Stephan Herrmann36c26992010-04-01 23:18:59 +000044 */
Stephan Herrmannc4606e82020-04-11 14:28:09 +020045 public void testAbstractMethodInNonAbstractRole1()
Stephan Herrmann36c26992010-04-01 23:18:59 +000046 {
47 createFile("MyTeam","public team class MyTeam { " +
48 NL + " protected class MyRole {" +
49 NL + " public abstract void roleMethod();" +
50 NL + " }"+
51 NL + "}");
Stephan Herrmannc4606e82020-04-11 14:28:09 +020052
Stephan Herrmann36c26992010-04-01 23:18:59 +000053 compileFile("MyTeam");
Stephan Herrmannc4606e82020-04-11 14:28:09 +020054
Stephan Herrmann36c26992010-04-01 23:18:59 +000055 assertTrue(hasExpectedProblems(new int[] { IProblem.AbstractMethodsInConcreteClass, IProblem.AbstractMethodInAbstractClass } ));
56 }
57}