Stephan Herrmann | 36c2699 | 2010-04-01 23:18:59 +0000 | [diff] [blame] | 1 | /********************************************************************** |
| 2 | * This file is part of "Object Teams Development Tooling"-Software |
Stephan Herrmann | c4606e8 | 2020-04-11 14:28:09 +0200 | [diff] [blame^] | 3 | * |
Stephan Herrmann | 36c2699 | 2010-04-01 23:18:59 +0000 | [diff] [blame] | 4 | * 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 Herrmann | c4606e8 | 2020-04-11 14:28:09 +0200 | [diff] [blame^] | 8 | * |
Stephan Herrmann | 3570538 | 2020-03-03 21:42:19 +0100 | [diff] [blame] | 9 | * This program and the accompanying materials |
| 10 | * are made available under the terms of the Eclipse Public License 2.0 |
Stephan Herrmann | 36c2699 | 2010-04-01 23:18:59 +0000 | [diff] [blame] | 11 | * which accompanies this distribution, and is available at |
Stephan Herrmann | 3570538 | 2020-03-03 21:42:19 +0100 | [diff] [blame] | 12 | * https://www.eclipse.org/legal/epl-2.0/ |
| 13 | * |
| 14 | * SPDX-License-Identifier: EPL-2.0 |
Stephan Herrmann | c4606e8 | 2020-04-11 14:28:09 +0200 | [diff] [blame^] | 15 | * |
Stephan Herrmann | 36c2699 | 2010-04-01 23:18:59 +0000 | [diff] [blame] | 16 | * Please visit http://www.eclipse.org/objectteams for updates and contact. |
Stephan Herrmann | c4606e8 | 2020-04-11 14:28:09 +0200 | [diff] [blame^] | 17 | * |
Stephan Herrmann | 36c2699 | 2010-04-01 23:18:59 +0000 | [diff] [blame] | 18 | * Contributors: |
| 19 | * Fraunhofer FIRST - Initial API and implementation |
| 20 | * Technical University Berlin - Initial API and implementation |
| 21 | **********************************************************************/ |
| 22 | package org.eclipse.objectteams.otdt.tests.compiler.errorreporting; |
| 23 | |
| 24 | import org.eclipse.jdt.core.compiler.IProblem; |
| 25 | import org.eclipse.objectteams.otdt.tests.compiler.TestBase; |
| 26 | |
| 27 | /** |
| 28 | * This class contains tests concerning roles. |
Stephan Herrmann | c4606e8 | 2020-04-11 14:28:09 +0200 | [diff] [blame^] | 29 | * |
Stephan Herrmann | 36c2699 | 2010-04-01 23:18:59 +0000 | [diff] [blame] | 30 | * @author kaschja |
| 31 | * @version $Id: RoleContainmentTest.java 23494 2010-02-05 23:06:44Z stephan $ |
| 32 | */ |
| 33 | public class RoleContainmentTest extends TestBase |
Stephan Herrmann | c4606e8 | 2020-04-11 14:28:09 +0200 | [diff] [blame^] | 34 | { |
Stephan Herrmann | 36c2699 | 2010-04-01 23:18:59 +0000 | [diff] [blame] | 35 | 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 Herrmann | c4606e8 | 2020-04-11 14:28:09 +0200 | [diff] [blame^] | 43 | * A role has to be declared as abstract if it contains an abstract method. |
Stephan Herrmann | 36c2699 | 2010-04-01 23:18:59 +0000 | [diff] [blame] | 44 | */ |
Stephan Herrmann | c4606e8 | 2020-04-11 14:28:09 +0200 | [diff] [blame^] | 45 | public void testAbstractMethodInNonAbstractRole1() |
Stephan Herrmann | 36c2699 | 2010-04-01 23:18:59 +0000 | [diff] [blame] | 46 | { |
| 47 | createFile("MyTeam","public team class MyTeam { " + |
| 48 | NL + " protected class MyRole {" + |
| 49 | NL + " public abstract void roleMethod();" + |
| 50 | NL + " }"+ |
| 51 | NL + "}"); |
Stephan Herrmann | c4606e8 | 2020-04-11 14:28:09 +0200 | [diff] [blame^] | 52 | |
Stephan Herrmann | 36c2699 | 2010-04-01 23:18:59 +0000 | [diff] [blame] | 53 | compileFile("MyTeam"); |
Stephan Herrmann | c4606e8 | 2020-04-11 14:28:09 +0200 | [diff] [blame^] | 54 | |
Stephan Herrmann | 36c2699 | 2010-04-01 23:18:59 +0000 | [diff] [blame] | 55 | assertTrue(hasExpectedProblems(new int[] { IProblem.AbstractMethodsInConcreteClass, IProblem.AbstractMethodInAbstractClass } )); |
| 56 | } |
| 57 | } |